Qt: Toggle fullscreen like on all other platforms.

This commit is contained in:
Unknown W. Brackets 2018-06-09 16:28:15 -07:00
parent 82b6cda5ef
commit a448ef536b
7 changed files with 38 additions and 44 deletions

View File

@ -528,12 +528,7 @@ int main(int argc, char *argv[])
savegame_dir += "/";
external_dir += "/";
bool fullscreenCLI=false;
for (int i = 1; i < argc; i++) {
if (!strcmp(argv[i],"--fullscreen"))
fullscreenCLI=true;
}
NativeInit(argc, (const char **)argv, savegame_dir.c_str(), external_dir.c_str(), nullptr, fullscreenCLI);
NativeInit(argc, (const char **)argv, savegame_dir.c_str(), external_dir.c_str(), nullptr);
// TODO: Support other backends than GL, like Vulkan, in the Qt backend.
g_Config.iGPUBackend = (int)GPUBackend::OPENGL;

View File

@ -110,6 +110,8 @@ public:
explicit MainUI(QWidget *parent = 0);
~MainUI();
void resizeGL(int w, int h);
public slots:
QString InputBoxGetQString(QString title, QString defaultValue);
@ -123,7 +125,6 @@ protected:
bool event(QEvent *e);
void initializeGL();
void resizeGL(int w, int h);
void paintGL();
void updateAccelerometer();

View File

@ -36,10 +36,7 @@ MainWindow::MainWindow(QWidget *parent, bool fullscreen) :
createMenus();
updateMenus();
SetWindowScale(-1);
if(fullscreen)
fullscrAct();
SetFullScreen(fullscreen);
QObject::connect(emugl, SIGNAL(doubleClick()), this, SLOT(fullscrAct()));
QObject::connect(emugl, SIGNAL(newFrame()), this, SLOT(newFrame()));
@ -99,9 +96,6 @@ void MainWindow::updateMenus()
foreach(QAction * action, displayLayoutGroup->actions()) {
if (g_Config.iSmallDisplayZoomType == action->data().toInt()) {
NativeMessageReceived("gpu_resized", "");
action->setChecked(true);
break;
}
@ -135,8 +129,8 @@ void MainWindow::updateMenus()
void MainWindow::bootDone()
{
if(g_Config.bFullScreen != isFullScreen())
fullscrAct();
if (g_Config.bFullScreen != isFullScreen())
SetFullScreen(g_Config.bFullScreen);
if (nextState == CORE_RUNNING)
runAct();
@ -300,40 +294,43 @@ void MainWindow::raiseTopMost()
{
setWindowState( (windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
raise();
activateWindow();
activateWindow();
}
void MainWindow::fullscrAct()
{
if(isFullScreen()) {
g_Config.bFullScreen = false;
void MainWindow::SetFullScreen(bool fullscreen) {
if (fullscreen) {
menuBar()->hide();
emugl->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
emugl->resizeGL(emugl->size().width(), emugl->size().height());
// TODO: Won't showFullScreen do this for us?
setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
showFullScreen();
InitPadLayout(dp_xres, dp_yres);
if (GetUIState() == UISTATE_INGAME && !g_Config.bShowTouchControls)
QApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
} else {
menuBar()->show();
updateMenus();
showNormal();
SetWindowScale(-1);
InitPadLayout(dp_xres, dp_yres);
if (GetUIState() == UISTATE_INGAME && QApplication::overrideCursor())
QApplication::restoreOverrideCursor();
}
else {
g_Config.bFullScreen = true;
menuBar()->hide();
}
emugl->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
void MainWindow::fullscrAct()
{
// Toggle the current state.
g_Config.bFullScreen = !isFullScreen();
SetFullScreen(g_Config.bFullScreen);
showFullScreen();
NativeMessageReceived("gpu_resized", "");
InitPadLayout(dp_xres, dp_yres);
if (GetUIState() == UISTATE_INGAME && !g_Config.bShowTouchControls)
QApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
}
QTimer::singleShot(1000, this, SLOT(raiseTopMost()));
}
@ -396,6 +393,7 @@ void MainWindow::SetWindowScale(int zoom) {
g_Config.iWindowHeight = height;
emugl->setFixedSize(g_Config.iWindowWidth, g_Config.iWindowHeight);
emugl->resizeGL(g_Config.iWindowWidth, g_Config.iWindowHeight);
setFixedSize(sizeHint());
}

View File

@ -30,7 +30,7 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0, bool fullscreen=false);
explicit MainWindow(QWidget *parent = nullptr, bool fullscreen = false);
~MainWindow() { };
CoreState GetNextState() { return nextState; }
@ -144,6 +144,7 @@ private:
void bootDone();
void SetWindowScale(int zoom);
void SetGameTitle(QString text);
void SetFullScreen(bool fullscreen);
void loadLanguage(const QString &language, bool retranslate);
void createMenus();

View File

@ -345,7 +345,7 @@ void CreateDirectoriesAndroid() {
File::CreateEmptyFile(g_Config.memStickDirectory + "PSP/SAVEDATA/.nomedia");
}
void NativeInit(int argc, const char *argv[], const char *savegame_dir, const char *external_dir, const char *cache_dir, bool fs) {
void NativeInit(int argc, const char *argv[], const char *savegame_dir, const char *external_dir, const char *cache_dir) {
net::Init(); // This needs to happen before we load the config. So on Windows we also run it in Main. It's fine to call multiple times.
InitFastMath(cpu_info.bNEON);
@ -474,6 +474,8 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
#endif
if (!strncmp(argv[i], "--pause-menu-exit", strlen("--pause-menu-exit")))
g_Config.bPauseMenuExitsEmulator = true;
if (!strcmp(argv[i], "--fullscreen"))
g_Config.bFullScreen = true;
break;
}
} else {
@ -615,7 +617,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
isOuya = KeyMap::IsOuya(sysName);
#if !defined(MOBILE_DEVICE) && defined(USING_QT_UI)
MainWindow* mainWindow = new MainWindow(0,fs);
MainWindow *mainWindow = new MainWindow(nullptr, g_Config.bFullScreen);
mainWindow->show();
if (host == nullptr) {
host = new QtHost(mainWindow);

View File

@ -458,9 +458,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
break;
}
if (wideArgs[i] == L"--fullscreen")
g_Config.bFullScreen = true;
if (wideArgs[i] == L"--windowed")
g_Config.bFullScreen = false;

View File

@ -45,7 +45,7 @@ bool NativeIsAtTopLevel();
// The very first function to be called after NativeGetAppInfo. Even NativeMix is not called
// before this, although it may be called at any point in time afterwards (on any thread!)
// This functions must NOT call OpenGL. Main thread.
void NativeInit(int argc, const char *argv[], const char *savegame_dir, const char *external_dir, const char *cache_dir, bool fs=false);
void NativeInit(int argc, const char *argv[], const char *savegame_dir, const char *external_dir, const char *cache_dir);
// Runs after NativeInit() at some point. May (and probably should) call OpenGL.
// Should not initialize anything screen-size-dependent - do that in NativeResized.