History

Working on crash bugs

Brad Davis committed 10 years ago

Commit d428f3b1 parent cac317620 files · +246 −218Browse files

Showing the changes to interface/src/PluginContainerProxy.cpp (1 of 20 files). Show all

Unified · Split

interface/src/PluginContainerProxy.cpp+8−126
@@ -23,122 +23,14 @@ PluginContainerProxy::PluginContainerProxy() { · 22 unmodified lines
2323 PluginContainerProxy::~PluginContainerProxy() {
2424 }
2525
26−bool PluginContainerProxy::isForeground() {
27− return qApp->isForeground() && !qApp->getWindow()->isMinimized();
28−}
29−
30−void PluginContainerProxy::addMenu(const QString& menuName) {
31− Menu::getInstance()->addMenu(menuName);
32−}
33−
34−void PluginContainerProxy::removeMenu(const QString& menuName) {
35− Menu::getInstance()->removeMenu(menuName);
26+ui::Menu* PluginContainerProxy::getPrimaryMenu() {
27+ auto appMenu = qApp->_window->menuBar();
28+ auto uiMenu = dynamic_cast<ui::Menu*>(appMenu);
29+ return uiMenu;
3630 }
3731
38−QAction* PluginContainerProxy::addMenuItem(PluginType type, const QString& path, const QString& name, std::function<void(bool)> onClicked, bool checkable, bool checked, const QString& groupName) {
39− auto menu = Menu::getInstance();
40− MenuWrapper* parentItem = menu->getMenu(path);
41− QAction* action = menu->addActionToQMenuAndActionHash(parentItem, name);
42− if (!groupName.isEmpty()) {
43− QActionGroup* group{ nullptr };
44− if (!_exclusiveGroups.count(groupName)) {
45− group = _exclusiveGroups[groupName] = new QActionGroup(menu);
46− group->setExclusive(true);
47− } else {
48− group = _exclusiveGroups[groupName];
49− }
50− group->addAction(action);
51− }
52− connect(action, &QAction::triggered, [=] {
53− onClicked(action->isChecked());
54− });
55− action->setCheckable(checkable);
56− action->setChecked(checked);
57− if (type == PluginType::DISPLAY_PLUGIN) {
58− _currentDisplayPluginActions.push_back({ path, name });
59− } else {
60− _currentInputPluginActions.push_back({ path, name });
61− }
62− return action;
63−}
64−
65−void PluginContainerProxy::removeMenuItem(const QString& menuName, const QString& menuItem) {
66− Menu::getInstance()->removeMenuItem(menuName, menuItem);
67−}
68−
69−bool PluginContainerProxy::isOptionChecked(const QString& name) {
70− return Menu::getInstance()->isOptionChecked(name);
71−}
72−
73−void PluginContainerProxy::setIsOptionChecked(const QString& path, bool checked) {
74− Menu::getInstance()->setIsOptionChecked(path, checked);
75−}
76−
77−// FIXME there is a bug in the fullscreen setting, where leaving
78−// fullscreen does not restore the window frame, making it difficult
79−// or impossible to move or size the window.
80−// Additionally, setting fullscreen isn't hiding the menu on windows
81−// make it useless for stereoscopic modes.
82−void PluginContainerProxy::setFullscreen(const QScreen* target, bool hideMenu) {
83− auto _window = qApp->getWindow();
84− if (!_window->isFullScreen()) {
85− _savedGeometry = _window->geometry();
86− }
87− if (nullptr == target) {
88− // FIXME target the screen where the window currently is
89− target = qApp->primaryScreen();
90− }
91−
92− _window->setGeometry(target->availableGeometry());
93− _window->windowHandle()->setScreen((QScreen*)target);
94− _window->showFullScreen();
95−
96−#ifndef Q_OS_MAC
97− // also hide the QMainWindow's menuBar
98− QMenuBar* menuBar = _window->menuBar();
99− if (menuBar && hideMenu) {
100− menuBar->setVisible(false);
101− }
102−#endif
103−}
104−
105−void PluginContainerProxy::unsetFullscreen(const QScreen* avoid) {
106− auto _window = qApp->getWindow();
107− _window->showNormal();
108−
109− QRect targetGeometry = _savedGeometry;
110− if (avoid != nullptr) {
111− QRect avoidGeometry = avoid->geometry();
112− if (avoidGeometry.contains(targetGeometry.topLeft())) {
113− QScreen* newTarget = qApp->primaryScreen();
114− if (newTarget == avoid) {
115− foreach(auto screen, qApp->screens()) {
116− if (screen != avoid) {
117− newTarget = screen;
118− break;
119− }
120− }
121− }
122− targetGeometry = newTarget->availableGeometry();
123− }
124− }
125−#ifdef Q_OS_MAC
126− QTimer* timer = new QTimer();
127− timer->singleShot(2000, [=] {
128− _window->setGeometry(targetGeometry);
129− timer->deleteLater();
130− });
131−#else
132− _window->setGeometry(targetGeometry);
133−#endif
134−
135−#ifndef Q_OS_MAC
136− // also show the QMainWindow's menuBar
137− QMenuBar* menuBar = _window->menuBar();
138− if (menuBar) {
139− menuBar->setVisible(true);
140− }
141−#endif
32+bool PluginContainerProxy::isForeground() {
33+ return qApp->isForeground() && !qApp->getWindow()->isMinimized();
14234 }
14335
14436 void PluginContainerProxy::requestReset() {
@@ -154,8 +46,8 @@ GLWidget* PluginContainerProxy::getPrimaryWidget() { · 9 unmodified lines
15446 return qApp->_glWidget;
15547 }
15648
157−QWindow* PluginContainerProxy::getPrimaryWindow() {
158− return qApp->_glWidget->windowHandle();
49+MainWindow* PluginContainerProxy::getPrimaryWindow() {
50+ return qApp->getWindow();
15951 }
16052
16153 QOpenGLContext* PluginContainerProxy::getPrimaryContext() {
@@ -184,13 +76,3 @@ void PluginContainerProxy::releaseOverlayTexture(const gpu::TexturePointer& text · 22 unmodified lines
18476 qApp->_applicationOverlay.releaseOverlay(texture);
18577 }
18678
187−/// settings interface
188−bool PluginContainerProxy::getBoolSetting(const QString& settingName, bool defaultValue) {
189− Setting::Handle<bool> settingValue(settingName, defaultValue);
190− return settingValue.get();
191−}
192−
193−void PluginContainerProxy::setBoolSetting(const QString& settingName, bool value) {
194− Setting::Handle<bool> settingValue(settingName, value);
195− return settingValue.set(value);
196−}