mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 07:58:59 +02:00
expose menu enablement to javascript
This commit is contained in:
parent
cd0416b5e9
commit
4d18a3cc3d
4 changed files with 42 additions and 0 deletions
|
@ -126,6 +126,23 @@ void MenuScriptingInterface::setIsOptionChecked(const QString& menuOption, bool
|
||||||
Q_ARG(bool, isChecked));
|
Q_ARG(bool, isChecked));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MenuScriptingInterface::isMenuEnabled(const QString& menuOption) {
|
||||||
|
if (QThread::currentThread() == qApp->thread()) {
|
||||||
|
return Menu::getInstance()->isOptionChecked(menuOption);
|
||||||
|
}
|
||||||
|
bool result;
|
||||||
|
QMetaObject::invokeMethod(Menu::getInstance(), "isMenuEnabled", Qt::BlockingQueuedConnection,
|
||||||
|
Q_RETURN_ARG(bool, result),
|
||||||
|
Q_ARG(const QString&, menuOption));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuScriptingInterface::setMenuEnabled(const QString& menuOption, bool isChecked) {
|
||||||
|
QMetaObject::invokeMethod(Menu::getInstance(), "setMenuEnabled",
|
||||||
|
Q_ARG(const QString&, menuOption),
|
||||||
|
Q_ARG(bool, isChecked));
|
||||||
|
}
|
||||||
|
|
||||||
void MenuScriptingInterface::triggerOption(const QString& menuOption) {
|
void MenuScriptingInterface::triggerOption(const QString& menuOption) {
|
||||||
QMetaObject::invokeMethod(Menu::getInstance(), "triggerOption", Q_ARG(const QString&, menuOption));
|
QMetaObject::invokeMethod(Menu::getInstance(), "triggerOption", Q_ARG(const QString&, menuOption));
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,9 @@ public slots:
|
||||||
|
|
||||||
void triggerOption(const QString& menuOption);
|
void triggerOption(const QString& menuOption);
|
||||||
|
|
||||||
|
bool isMenuEnabled(const QString& menuName);
|
||||||
|
void setMenuEnabled(const QString& menuName, bool isEnabled);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void menuItemEvent(const QString& menuItem);
|
void menuItemEvent(const QString& menuItem);
|
||||||
};
|
};
|
||||||
|
|
|
@ -428,6 +428,25 @@ bool Menu::menuExists(const QString& menuName) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Menu::isMenuEnabled(const QString& menuName) {
|
||||||
|
QAction* action = getMenuAction(menuName);
|
||||||
|
|
||||||
|
// only proceed if the menu actually exists
|
||||||
|
if (action) {
|
||||||
|
return action->isEnabled();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Menu::setMenuEnabled(const QString& menuName, bool isEnabled) {
|
||||||
|
QAction* action = getMenuAction(menuName);
|
||||||
|
|
||||||
|
// only proceed if the menu actually exists
|
||||||
|
if (action) {
|
||||||
|
action->setEnabled(isEnabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Menu::addSeparator(const QString& menuName, const QString& separatorName, const QString& grouping) {
|
void Menu::addSeparator(const QString& menuName, const QString& separatorName, const QString& grouping) {
|
||||||
MenuWrapper* menuObj = getMenu(menuName);
|
MenuWrapper* menuObj = getMenu(menuName);
|
||||||
if (menuObj) {
|
if (menuObj) {
|
||||||
|
|
|
@ -106,6 +106,9 @@ public slots:
|
||||||
bool isOptionChecked(const QString& menuOption) const;
|
bool isOptionChecked(const QString& menuOption) const;
|
||||||
void setIsOptionChecked(const QString& menuOption, bool isChecked);
|
void setIsOptionChecked(const QString& menuOption, bool isChecked);
|
||||||
|
|
||||||
|
bool isMenuEnabled(const QString& menuName);
|
||||||
|
void setMenuEnabled(const QString& menuName, bool isEnabled);
|
||||||
|
|
||||||
bool getGroupingIsVisible(const QString& grouping);
|
bool getGroupingIsVisible(const QString& grouping);
|
||||||
void setGroupingIsVisible(const QString& grouping, bool isVisible); /// NOTE: the "" grouping is always visible
|
void setGroupingIsVisible(const QString& grouping, bool isVisible); /// NOTE: the "" grouping is always visible
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue