mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:57:59 +02:00
Working on plugin menu items
This commit is contained in:
parent
ab1ae4aad5
commit
040f7c86ea
3 changed files with 20 additions and 4 deletions
|
@ -4799,6 +4799,8 @@ const DisplayPlugin * Application::getActiveDisplayPlugin() const {
|
||||||
return ((Application*)this)->getActiveDisplayPlugin();
|
return ((Application*)this)->getActiveDisplayPlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QVector<QPair<QString, QString>> _currentDisplayPluginActions;
|
||||||
|
|
||||||
void Application::updateDisplayMode() {
|
void Application::updateDisplayMode() {
|
||||||
auto menu = Menu::getInstance();
|
auto menu = Menu::getInstance();
|
||||||
auto displayPlugins = getDisplayPlugins();
|
auto displayPlugins = getDisplayPlugins();
|
||||||
|
@ -4822,6 +4824,14 @@ void Application::updateDisplayMode() {
|
||||||
oldDisplayPlugin->removeEventFilter(qApp);
|
oldDisplayPlugin->removeEventFilter(qApp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_currentDisplayPluginActions.isEmpty()) {
|
||||||
|
auto menu = Menu::getInstance();
|
||||||
|
foreach(auto itemInfo, _currentDisplayPluginActions) {
|
||||||
|
menu->removeMenuItem(itemInfo.first, itemInfo.second);
|
||||||
|
}
|
||||||
|
_currentDisplayPluginActions.clear();
|
||||||
|
}
|
||||||
|
|
||||||
if (newDisplayPlugin) {
|
if (newDisplayPlugin) {
|
||||||
_offscreenContext->makeCurrent();
|
_offscreenContext->makeCurrent();
|
||||||
newDisplayPlugin->activate(this);
|
newDisplayPlugin->activate(this);
|
||||||
|
@ -4850,8 +4860,14 @@ void Application::updateDisplayMode() {
|
||||||
Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin");
|
Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::addMenuItem(const QString& path, std::function<void()> onClicked, bool checkable, bool checked, const QString& groupName) {
|
void Application::addMenuItem(const QString& path, const QString& name, std::function<void()> onClicked, bool checkable, bool checked, const QString& groupName) {
|
||||||
|
auto menu = Menu::getInstance();
|
||||||
|
MenuWrapper* parentItem = menu->getMenu(path);
|
||||||
|
QAction* action = parentItem->addAction(name);
|
||||||
|
connect(action, &QAction::triggered, [=] {
|
||||||
|
onClicked();
|
||||||
|
});
|
||||||
|
_currentDisplayPluginActions.push_back({ path, name });
|
||||||
}
|
}
|
||||||
|
|
||||||
GlWindow* Application::getVisibleWindow() {
|
GlWindow* Application::getVisibleWindow() {
|
||||||
|
|
|
@ -296,7 +296,7 @@ public:
|
||||||
virtual qreal getDevicePixelRatio();
|
virtual qreal getDevicePixelRatio();
|
||||||
|
|
||||||
// Plugin container support
|
// Plugin container support
|
||||||
virtual void addMenuItem(const QString& path, std::function<void()> onClicked, bool checkable, bool checked, const QString& groupName);
|
virtual void addMenuItem(const QString& path, const QString& name, std::function<void()> onClicked, bool checkable, bool checked, const QString& groupName);
|
||||||
virtual GlWindow* getVisibleWindow();
|
virtual GlWindow* getVisibleWindow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -6,6 +6,6 @@ class GlWindow;
|
||||||
|
|
||||||
class PluginContainer {
|
class PluginContainer {
|
||||||
public:
|
public:
|
||||||
virtual void addMenuItem(const QString& path, std::function<void()> onClicked, bool checkable = false, bool checked = false, const QString& groupName = "") = 0;
|
virtual void addMenuItem(const QString& path, const QString& name, std::function<void()> onClicked, bool checkable = false, bool checked = false, const QString& groupName = "") = 0;
|
||||||
virtual GlWindow* getVisibleWindow() = 0;
|
virtual GlWindow* getVisibleWindow() = 0;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue