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
108108 updateUi();
109109 });
110110
111+
111112 // keep track of changes to the number of screens
112− connect(QApplication::desktop(), &QDesktopWidget::screenCountChanged, this, &HMDToolsDialog::screenCountChanged);
113−
113+ connect(qApp, &QGuiApplication::screenAdded, this, &HMDToolsDialog::screenCountChanged);
114+ connect(qApp, &QGuiApplication::screenRemoved, this, &HMDToolsDialog::screenCountChanged);
115+
114116 updateUi();
115117 }
116118
@@ -130,14 +132,13 @@ QString HMDToolsDialog::getDebugDetails() const { · 13 unmodified lines
130132 results += "HMD Screen Name: N/A\n";
131133 }
132134
133− int desktopPrimaryScreenNumber = QApplication::desktop()->primaryScreen();
134− QScreen* desktopPrimaryScreen = QGuiApplication::screens()[desktopPrimaryScreenNumber];
135+ QScreen* desktopPrimaryScreen = QGuiApplication::primaryScreen();
135136 results += "Desktop's Primary Screen: " + desktopPrimaryScreen->name() + "\n";
136137
137138 results += "Application Primary Screen: " + QGuiApplication::primaryScreen()->name() + "\n";
138139 QScreen* mainWindowScreen = qApp->getWindow()->windowHandle()->screen();
139140 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";
141142
142143 return results;
143144 }
@@ -196,7 +197,7 @@ void HMDToolsDialog::hideEvent(QHideEvent* event) { · 52 unmodified lines
196197 centerCursorOnWidget(qApp->getWindow());
197198 }
198199
199−void HMDToolsDialog::screenCountChanged(int newCount) {
200+void HMDToolsDialog::screenCountChanged() {
200201 int hmdScreenNumber = -1;
201202 const auto& displayPlugins = PluginManager::getInstance()->getDisplayPlugins();
202203 for(const auto& dp : displayPlugins) {
@@ -256,7 +257,7 @@ void HMDWindowWatcher::windowGeometryChanged(int arg) { · 53 unmodified lines
256257 void HMDWindowWatcher::windowScreenChanged(QScreen* screen) {
257258 // if we have more than one screen, and a known hmdScreen then try to
258259 // keep our dialog off of the hmdScreen
259− if (QApplication::desktop()->screenCount() > 1) {
260+ if (QGuiApplication::screens().count() > 1) {
260261 int hmdScreenNumber = _hmdTools->_hmdScreenNumber;
261262 // we want to use a local variable here because we are not necesarily in HMD mode
262263 if (hmdScreenNumber >= 0) {
@@ -283,8 +284,7 @@ void HMDWindowWatcher::windowScreenChanged(QScreen* screen) { · 20 unmodified lines
283284 betterScreen = lastApplicationScreen;
284285 } else {
285286 // 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::screens()[desktopPrimaryScreenNumber];
287+ QScreen* desktopPrimaryScreen = QGuiApplication::primaryScreen();
288288 betterScreen = desktopPrimaryScreen;
289289 }
290290