refs #720, improved menu action

* show info when DB is not available
* allow to grey out menus (better as hiding them)
This commit is contained in:
Klaus Basan
2016-08-09 01:53:35 +02:00
committed by Mathew Sutcliffe
parent 1167735897
commit 6f61d323c2
2 changed files with 15 additions and 2 deletions

View File

@@ -8,6 +8,8 @@
*/
#include "blackgui/menus/menuaction.h"
#include "blackgui/guiapplication.h"
#include "blackcore/webdataservices.h"
#include "blackmisc/icons.h"
#include "blackmisc/slot.h"
#include "blackmisc/verify.h"
@@ -20,6 +22,7 @@
#include <algorithm>
using namespace BlackMisc;
using namespace BlackGui;
namespace BlackGui
{
@@ -75,6 +78,12 @@ namespace BlackGui
return this->m_icon.pixmap(this->m_icon.actualSize(QSize(16, 16)));
}
void CMenuAction::setEnabled(bool enabled)
{
Q_ASSERT_X(this->m_action, Q_FUNC_INFO, "No action");
this->m_action->setEnabled(enabled);
}
QString CMenuAction::getLastPathPart() const
{
if (this->m_path.contains('/'))
@@ -377,7 +386,9 @@ namespace BlackGui
CMenuAction CMenuActions::addMenuStash()
{
if (this->containsMenu(CMenuAction::pathStash())) { return CMenuAction(); }
return this->addMenu(CIcons::appDbStash16(), "Stash tools", CMenuAction::pathStash());
const bool canConnectDb = sGui->getWebDataServices()->canConnectSwiftDb();
const QString txt(canConnectDb ? "Stash tools" : "Stash tools (Warning: no DB!)");
return this->addMenu(CIcons::appDbStash16(), txt, CMenuAction::pathStash());
}
CMenuAction CMenuActions::addMenuStashEditor()
@@ -445,6 +456,5 @@ namespace BlackGui
const int i = currentPath.lastIndexOf('/');
return currentPath.left(i);
}
} // ns
} // ns