Qt: Store initial size externally

This commit is contained in:
Vicki Pfau 2022-08-21 01:13:58 -07:00
parent 25677679df
commit 2a9f32a840
2 changed files with 10 additions and 5 deletions

View File

@ -147,7 +147,9 @@ Window::Window(CoreManager* manager, ConfigController* config, int playerId, QWi
#endif #endif
setMinimumSize(minimumSize); setMinimumSize(minimumSize);
if (i > 0) { if (i > 0) {
resizeFrame(minimumSize * i); m_initialSize = minimumSize * i;
} else {
m_initialSize = minimumSize * 2;
} }
setLogo(); setLogo();
@ -203,7 +205,7 @@ void Window::argumentsPassed() {
} }
#endif #endif
if (m_config->graphicsOpts()->multiplier) { if (m_config->graphicsOpts()->multiplier > 0) {
m_savedScale = m_config->graphicsOpts()->multiplier; m_savedScale = m_config->graphicsOpts()->multiplier;
#if defined(M_CORE_GBA) #if defined(M_CORE_GBA)
@ -211,7 +213,7 @@ void Window::argumentsPassed() {
#elif defined(M_CORE_GB) #elif defined(M_CORE_GB)
QSize size(GB_VIDEO_HORIZONTAL_PIXELS, GB_VIDEO_VERTICAL_PIXELS); QSize size(GB_VIDEO_HORIZONTAL_PIXELS, GB_VIDEO_VERTICAL_PIXELS);
#endif #endif
resizeFrame(size * m_savedScale); m_initialSize = size * m_savedScale;
} }
if (args->fname) { if (args->fname) {
@ -265,7 +267,7 @@ void Window::loadConfig() {
reloadConfig(); reloadConfig();
if (opts->width && opts->height) { if (opts->width && opts->height) {
resizeFrame(QSize(opts->width, opts->height)); m_initialSize = QSize(opts->width, opts->height);
} }
if (opts->fullscreen) { if (opts->fullscreen) {
@ -741,7 +743,9 @@ void Window::showEvent(QShowEvent* event) {
return; return;
} }
m_wasOpened = true; m_wasOpened = true;
resizeFrame(centralWidget()->sizeHint()); if (m_initialSize.isValid()) {
resizeFrame(m_initialSize);
}
QVariant windowPos = m_config->getQtOption("windowPos", m_playerId > 0 ? QString("player%0").arg(m_playerId) : QString()); QVariant windowPos = m_config->getQtOption("windowPos", m_playerId > 0 ? QString("player%0").arg(m_playerId) : QString());
bool maximized = m_config->getQtOption("maximized").toBool(); bool maximized = m_config->getQtOption("maximized").toBool();
QRect geom = windowHandle()->screen()->availableGeometry(); QRect geom = windowHandle()->screen()->availableGeometry();

View File

@ -195,6 +195,7 @@ private:
std::unique_ptr<AudioProcessor> m_audioProcessor; std::unique_ptr<AudioProcessor> m_audioProcessor;
std::unique_ptr<QGBA::Display> m_display; std::unique_ptr<QGBA::Display> m_display;
QSize m_initialSize;
int m_savedScale; int m_savedScale;
// TODO: Move these to a new class // TODO: Move these to a new class