diff --git a/doomsday/client/include/clientapp.h b/doomsday/client/include/clientapp.h index 7ed98ca166..5c36d002f2 100644 --- a/doomsday/client/include/clientapp.h +++ b/doomsday/client/include/clientapp.h @@ -81,6 +81,8 @@ class ClientApp : public de::BaseGuiApp public slots: void openHomepageInBrowser(); void openInBrowser(QUrl url); + void beginNativeUIMode(); + void endNativeUIMode(); private: DENG2_PRIVATE(d) diff --git a/doomsday/client/src/clientapp.cpp b/doomsday/client/src/clientapp.cpp index a68b9d8323..a1c50b3e2e 100644 --- a/doomsday/client/src/clientapp.cpp +++ b/doomsday/client/src/clientapp.cpp @@ -558,3 +558,25 @@ void ClientApp::openInBrowser(QUrl url) QDesktopServices::openUrl(url); } + +void ClientApp::beginNativeUIMode() +{ + // Switch temporarily to windowed mode. Not needed on OS X because the display mode + // is never changed on that platform. +#ifndef MACOSX + auto &win = ClientWindow::main(); + win.saveState(); + int windowedMode[] = { + ClientWindow::Fullscreen, false, + ClientWindow::End + }; + win.changeAttributes(windowedMode); +#endif +} + +void ClientApp::endNativeUIMode() +{ +#ifndef MACOSX + win.restoreState(); +#endif +} diff --git a/doomsday/client/src/ui/widgets/cvarnativepathwidget.cpp b/doomsday/client/src/ui/widgets/cvarnativepathwidget.cpp index 9cc407eba3..24af1bde63 100644 --- a/doomsday/client/src/ui/widgets/cvarnativepathwidget.cpp +++ b/doomsday/client/src/ui/widgets/cvarnativepathwidget.cpp @@ -18,6 +18,7 @@ #include "ui/widgets/cvarnativepathwidget.h" #include "ui/clientwindow.h" +#include "clientapp.h" #include #include @@ -98,23 +99,12 @@ void CVarNativePathWidget::updateFromCVar() void CVarNativePathWidget::chooseUsingNativeFileDialog() { - auto &win = ClientWindow::main(); - -#ifndef MACOSX - // Switch temporarily to windowed mode. Not needed on OS X because the display mode - // is never changed on that platform. - win.saveState(); - int windowedMode[] = { - ClientWindow::Fullscreen, false, - ClientWindow::End - }; - win.changeAttributes(windowedMode); -#endif + ClientApp::app().beginNativeUIMode(); // Use a native dialog to pick the path. QDir dir(d->path); if(d->path.isEmpty()) dir = QDir::home(); - QFileDialog dlg(&win, tr("Select File for \"%1\"").arg(d->cvar), dir.absolutePath()); + QFileDialog dlg(&ClientWindow::main(), tr("Select File for \"%1\"").arg(d->cvar), dir.absolutePath()); if(!d->filters.isEmpty()) { dlg.setNameFilters(d->filters); @@ -129,9 +119,7 @@ void CVarNativePathWidget::chooseUsingNativeFileDialog() setText(d->labelText()); } -#ifndef MACOSX - win.restoreState(); -#endif + ClientApp::app().endNativeUIMode(); } void CVarNativePathWidget::clearPath()