History

Replace deprecated screenCountChanged event

Dale Glass committed 4 years ago

Commit aeb082d1 parent 0c09ac62 files · +10 −10Browse files

Showing the changes to interface/src/ui/HMDToolsDialog.cpp (1 of 2 files). Show all

Unified · Split

interface/src/ui/HMDToolsDialog.cpp+9−9
@@ -108,9 +108,11 @@ HMDToolsDialog::HMDToolsDialog(QWidget* parent) : · 107 unmodified lines
108 updateUi();108 updateUi();
109 });109 });
110 110
111
111 // keep track of changes to the number of screens112 // keep track of changes to the number of screens
112 connect(QApplication::desktop(), &QDesktopWidget::screenCountChanged, this, &HMDToolsDialog::screenCountChanged);113 connect(qApp, &QGuiApplication::screenAdded, this, &HMDToolsDialog::screenCountChanged);
113 114 connect(qApp, &QGuiApplication::screenRemoved, this, &HMDToolsDialog::screenCountChanged);
115
114 updateUi();116 updateUi();
115}117}
116 118
@@ -130,14 +132,13 @@ QString HMDToolsDialog::getDebugDetails() const { · 13 unmodified lines
130 results += "HMD Screen Name: N/A\n";132 results += "HMD Screen Name: N/A\n";
131 }133 }
132 134
133 int desktopPrimaryScreenNumber = QApplication::desktop()->primaryScreen();135 QScreen* desktopPrimaryScreen = QGuiApplication::primaryScreen();
134 QScreen* desktopPrimaryScreen = QGuiApplication::screens()[desktopPrimaryScreenNumber];
135 results += "Desktop's Primary Screen: " + desktopPrimaryScreen->name() + "\n";136 results += "Desktop's Primary Screen: " + desktopPrimaryScreen->name() + "\n";
136 137
137 results += "Application Primary Screen: " + QGuiApplication::primaryScreen()->name() + "\n";138 results += "Application Primary Screen: " + QGuiApplication::primaryScreen()->name() + "\n";
138 QScreen* mainWindowScreen = qApp->getWindow()->windowHandle()->screen();139 QScreen* mainWindowScreen = qApp->getWindow()->windowHandle()->screen();
139 results += "Application Main Window Screen: " + mainWindowScreen->name() + "\n";140 results += "Application Main Window Screen: " + mainWindowScreen->name() + "\n";
140 results += "Total Screens: " + QString::number(QApplication::desktop()->screenCount()) + "\n";141 results += "Total Screens: " + QString::number(QGuiApplication::screens().count()) + "\n";
141 142
142 return results;143 return results;
143}144}
@@ -196,7 +197,7 @@ void HMDToolsDialog::hideEvent(QHideEvent* event) { · 52 unmodified lines
196 centerCursorOnWidget(qApp->getWindow());197 centerCursorOnWidget(qApp->getWindow());
197}198}
198 199
199void HMDToolsDialog::screenCountChanged(int newCount) {200void HMDToolsDialog::screenCountChanged() {
200 int hmdScreenNumber = -1;201 int hmdScreenNumber = -1;
201 const auto& displayPlugins = PluginManager::getInstance()->getDisplayPlugins();202 const auto& displayPlugins = PluginManager::getInstance()->getDisplayPlugins();
202 for(const auto& dp : displayPlugins) {203 for(const auto& dp : displayPlugins) {
@@ -256,7 +257,7 @@ void HMDWindowWatcher::windowGeometryChanged(int arg) { · 53 unmodified lines
256void HMDWindowWatcher::windowScreenChanged(QScreen* screen) {257void HMDWindowWatcher::windowScreenChanged(QScreen* screen) {
257 // if we have more than one screen, and a known hmdScreen then try to258 // if we have more than one screen, and a known hmdScreen then try to
258 // keep our dialog off of the hmdScreen259 // keep our dialog off of the hmdScreen
259 if (QApplication::desktop()->screenCount() > 1) {260 if (QGuiApplication::screens().count() > 1) {
260 int hmdScreenNumber = _hmdTools->_hmdScreenNumber;261 int hmdScreenNumber = _hmdTools->_hmdScreenNumber;
261 // we want to use a local variable here because we are not necesarily in HMD mode262 // we want to use a local variable here because we are not necesarily in HMD mode
262 if (hmdScreenNumber >= 0) {263 if (hmdScreenNumber >= 0) {
@@ -283,8 +284,7 @@ void HMDWindowWatcher::windowScreenChanged(QScreen* screen) { · 20 unmodified lines
283 betterScreen = lastApplicationScreen;284 betterScreen = lastApplicationScreen;
284 } else {285 } else {
285 // last, if we can't use the previous screen the use the primary desktop screen286 // last, if we can't use the previous screen the use the primary desktop screen
286 int desktopPrimaryScreenNumber = QApplication::desktop()->primaryScreen();287 QScreen* desktopPrimaryScreen = QGuiApplication::primaryScreen();
287 QScreen* desktopPrimaryScreen = QGuiApplication::screens()[desktopPrimaryScreenNumber];
288 betterScreen = desktopPrimaryScreen;288 betterScreen = desktopPrimaryScreen;
289 }289 }
290 290