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
23PluginContainerProxy::~PluginContainerProxy() {23PluginContainerProxy::~PluginContainerProxy() {
24}24}
25 25
26bool PluginContainerProxy::isForeground() {26ui::Menu* PluginContainerProxy::getPrimaryMenu() {
27 return qApp->isForeground() && !qApp->getWindow()->isMinimized();27 auto appMenu = qApp->_window->menuBar();
28}28 auto uiMenu = dynamic_cast<ui::Menu*>(appMenu);
29 29 return uiMenu;
30void PluginContainerProxy::addMenu(const QString& menuName) {
31 Menu::getInstance()->addMenu(menuName);
32}
33
34void PluginContainerProxy::removeMenu(const QString& menuName) {
35 Menu::getInstance()->removeMenu(menuName);
36}30}
37 31
38QAction* PluginContainerProxy::addMenuItem(PluginType type, const QString& path, const QString& name, std::function<void(bool)> onClicked, bool checkable, bool checked, const QString& groupName) {32bool PluginContainerProxy::isForeground() {
39 auto menu = Menu::getInstance();33 return qApp->isForeground() && !qApp->getWindow()->isMinimized();
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
65void PluginContainerProxy::removeMenuItem(const QString& menuName, const QString& menuItem) {
66 Menu::getInstance()->removeMenuItem(menuName, menuItem);
67}
68
69bool PluginContainerProxy::isOptionChecked(const QString& name) {
70 return Menu::getInstance()->isOptionChecked(name);
71}
72
73void 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.
82void 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
105void 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
142}34}
143 35
144void PluginContainerProxy::requestReset() {36void PluginContainerProxy::requestReset() {
@@ -154,8 +46,8 @@ GLWidget* PluginContainerProxy::getPrimaryWidget() { · 9 unmodified lines
154 return qApp->_glWidget;46 return qApp->_glWidget;
155}47}
156 48
157QWindow* PluginContainerProxy::getPrimaryWindow() {49MainWindow* PluginContainerProxy::getPrimaryWindow() {
158 return qApp->_glWidget->windowHandle();50 return qApp->getWindow();
159}51}
160 52
161QOpenGLContext* PluginContainerProxy::getPrimaryContext() {53QOpenGLContext* PluginContainerProxy::getPrimaryContext() {
@@ -184,13 +76,3 @@ void PluginContainerProxy::releaseOverlayTexture(const gpu::TexturePointer& text · 22 unmodified lines
184 qApp->_applicationOverlay.releaseOverlay(texture);76 qApp->_applicationOverlay.releaseOverlay(texture);
185}77}
186 78
187/// settings interface
188bool PluginContainerProxy::getBoolSetting(const QString& settingName, bool defaultValue) {
189 Setting::Handle<bool> settingValue(settingName, defaultValue);
190 return settingValue.get();
191}
192
193void PluginContainerProxy::setBoolSetting(const QString& settingName, bool value) {
194 Setting::Handle<bool> settingValue(settingName, value);
195 return settingValue.set(value);
196}