Qt: Better window size handling
Jeffrey Pfau jeffrey@endrift.com
Wed, 05 Aug 2015 00:42:21 -0700
3 files changed,
8 insertions(+),
13 deletions(-)
M
src/platform/qt/GBAApp.cpp
→
src/platform/qt/GBAApp.cpp
@@ -51,10 +51,6 @@ m_windows[0] = nullptr;
}); m_windows[0] = w; -#ifndef Q_OS_MAC - w->show(); -#endif - GBAArguments args; if (m_configController.parseArguments(&args, argc, argv)) { w->argumentsPassed(&args);@@ -62,14 +58,12 @@ } else {
w->loadConfig(); } freeArguments(&args); + w->show(); AudioProcessor::setDriver(static_cast<AudioProcessor::Driver>(m_configController.getQtOption("audioDriver").toInt())); w->controller()->reloadAudioDriver(); w->controller()->setMultiplayerController(&m_multiplayer); -#ifdef Q_OS_MAC - w->show(); -#endif } bool GBAApp::event(QEvent* event) {@@ -91,14 +85,9 @@ m_windows[windowId] = nullptr;
}); m_windows[windowId] = w; w->setAttribute(Qt::WA_DeleteOnClose); -#ifndef Q_OS_MAC - w->show(); -#endif w->loadConfig(); + w->show(); w->controller()->setMultiplayerController(&m_multiplayer); -#ifdef Q_OS_MAC - w->show(); -#endif return w; }
M
src/platform/qt/Window.cpp
→
src/platform/qt/Window.cpp
@@ -172,6 +172,7 @@ }
void Window::resizeFrame(int width, int height) { QSize newSize(width, height); + m_screenWidget->setSizeHint(newSize); newSize -= m_screenWidget->size(); newSize += size(); resize(newSize);@@ -432,6 +433,10 @@ m_config->setOption("height", m_screenWidget->height());
m_config->setOption("width", m_screenWidget->width()); } m_config->setOption("fullscreen", isFullScreen()); +} + +void Window::showEvent(QShowEvent* event) { + resizeFrame(m_screenWidget->sizeHint().width(), m_screenWidget->sizeHint().height()); } void Window::closeEvent(QCloseEvent* event) {
M
src/platform/qt/Window.h
→
src/platform/qt/Window.h
@@ -104,6 +104,7 @@ protected:
virtual void keyPressEvent(QKeyEvent* event) override; virtual void keyReleaseEvent(QKeyEvent* event) override; virtual void resizeEvent(QResizeEvent*) override; + virtual void showEvent(QShowEvent*) override; virtual void closeEvent(QCloseEvent*) override; virtual void focusInEvent(QFocusEvent*) override; virtual void focusOutEvent(QFocusEvent*) override;