diff --git a/src/blackgui/components/dbownmodelscomponent.cpp b/src/blackgui/components/dbownmodelscomponent.cpp index 9734a4912..ee2be7cc2 100644 --- a/src/blackgui/components/dbownmodelscomponent.cpp +++ b/src/blackgui/components/dbownmodelscomponent.cpp @@ -233,6 +233,7 @@ namespace BlackGui } // with models loaded I allow a refresh reload + // I need those models because I want to merge with DM data in the loader if (sGui->getWebDataServices() && sGui->getWebDataServices()->getModelsCount() > 0) { if (this->m_reloadActions.isEmpty()) { this->m_reloadActions = QList({nullptr, nullptr, nullptr, nullptr}); } @@ -290,6 +291,12 @@ namespace BlackGui menuActions.addAction(this->m_reloadActions[3], CMenuAction::pathSimulatorModelsReload()); } } + else + { + // dummy action grayed out + CMenuAction a = menuActions.addAction(CIcons::refresh16(), "Force model reload impossible, no DB data", CMenuAction::pathSimulator()); + a.setActionEnabled(false); // gray out + } } this->nestedCustomMenu(menuActions); } diff --git a/src/blackgui/menus/menuaction.cpp b/src/blackgui/menus/menuaction.cpp index 0adc86a9a..7da1134ea 100644 --- a/src/blackgui/menus/menuaction.cpp +++ b/src/blackgui/menus/menuaction.cpp @@ -48,6 +48,17 @@ namespace BlackGui if (this->m_action) { m_action->setChecked(checked); } } + bool CMenuAction::isActionEnabled() const + { + if (!this->m_action) { return false; } + return this->m_action->isEnabled(); + } + + void CMenuAction::setActionEnabled(bool enabled) + { + if (this->m_action) { m_action->setEnabled(enabled); } + } + bool CMenuAction::hasNoPathWithSeparator() const { return this->m_separator && this->hasNoPath(); @@ -244,6 +255,11 @@ namespace BlackGui return action; } + CMenuAction CMenuActions::addAction(const QIcon &actionIcon, const QString &text, const QString &path) + { + return this->addAction(actionIcon, text, path, nullptr); + } + CMenuAction CMenuActions::addAction(const QIcon &actionIcon, const QString &text, const QString &path, const BlackMisc::CSlot &slot, const QKeySequence &shortcut) { return this->addAction(actionIcon, text, path, slot.object(), slot, shortcut); diff --git a/src/blackgui/menus/menuaction.h b/src/blackgui/menus/menuaction.h index a63021c71..b38d58dc6 100644 --- a/src/blackgui/menus/menuaction.h +++ b/src/blackgui/menus/menuaction.h @@ -60,6 +60,12 @@ namespace BlackGui //! Set a checkable action, QAction::setChecked void setActionChecked(bool checked); + //! Enabled action? + bool isActionEnabled() const; + + //! Enable action (allow gray out) + void setActionEnabled(bool enabled); + //! Path const QString &getPath() const { return m_path; } @@ -241,6 +247,9 @@ namespace BlackGui //! Add action CMenuAction addAction(const QIcon &actionIcon, const QString &text, const QString &path, QObject *actionOwner, const BlackMisc::CSlot &slot, const QKeySequence &shortcut = 0); + //! Add action without slot + CMenuAction addAction(const QIcon &actionIcon, const QString &text, const QString &path); + //! Add action CMenuAction addAction(const QIcon &actionIcon, const QString &text, const QString &path, const BlackMisc::CSlot &slot, const QKeySequence &shortcut = 0);