From b54cde2cbf71aadf3cd29323f237aa69c4960ca2 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Fri, 24 Jul 2026 15:14:24 +0800 Subject: [PATCH] refactor: remove "auto" in window-size behavior - "auto" is not essential for our hard fork, so i simply remove it. - remove all useless code after removing it. - enlarge the min size of window because previous may trigger bad layout when showing navigation view. --- app/mainwindow.cpp | 41 +++-------------------------------------- app/mainwindow.h | 1 - app/settings.h | 2 -- app/settingsdialog.cpp | 1 - 4 files changed, 3 insertions(+), 42 deletions(-) diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp index 9e475ca..dd1018e 100644 --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -59,8 +59,8 @@ MainWindow::MainWindow(QWidget *parent) // YYC MARK: // Blumis set original value is 350 x 330. // It is too small for modern device, - // so I level it up to standard VGA resolution 640 x 480. - this->setMinimumSize(640, 480); + // so I level it up to SVGA resolution 800 x 600. + this->setMinimumSize(800, 600); this->setWindowIcon(QIcon(u":/icons/app-icon.svg"_s)); this->setAcceptDrops(true); @@ -193,48 +193,13 @@ void MainWindow::showFiles(const QList& urls) void MainWindow::initWindowSize() { switch (Settings::instance()->initWindowSizeBehavior()) { - case Settings::WindowSizeBehavior::Auto: - adjustWindowSizeBySceneRect(); - break; case Settings::WindowSizeBehavior::Maximized: showMaximized(); break; case Settings::WindowSizeBehavior::Windowed: + default: showNormal(); break; - default: - adjustWindowSizeBySceneRect(); - break; - } -} - -void MainWindow::adjustWindowSizeBySceneRect() -{ - if (m_pm->totalCount() < 1) return; - - QSize sceneSize = ui->m_gv->sceneRect().toRect().size(); - QSize sceneSizeWithMargins = sceneSize + QSize(130, 125); - - if (ui->m_gv->scaleFactor() < 1 || size().expandedTo(sceneSizeWithMargins) != size()) { - // if it scaled down by the resize policy: - QSize screenSize = qApp->screenAt(QCursor::pos())->availableSize(); - if (screenSize.expandedTo(sceneSize) == screenSize) { - // we can show the picture by increase the window size. - QSize finalSize = (screenSize.expandedTo(sceneSizeWithMargins) == screenSize) ? - sceneSizeWithMargins : screenSize; - // We have a very reasonable sizeHint() value ;P - this->resize(finalSize.expandedTo(this->sizeHint())); - - // We're sure the window can display the whole thing with 1:1 scale. - // The old window size may cause fitInView call from resize() and the - // above resize() call won't reset the scale back to 1:1, so we - // just call resetScale() here to ensure the thing is no longer scaled. - ui->m_gv->resetScale(); - centerWindow(); - } else { - // toggle maximum - showMaximized(); - } } } diff --git a/app/mainwindow.h b/app/mainwindow.h index 2a78fb0..efac9c1 100644 --- a/app/mainwindow.h +++ b/app/mainwindow.h @@ -28,7 +28,6 @@ public: void showFiles(const QStringList& files); void showFiles(const QList& urls); void initWindowSize(); - void adjustWindowSizeBySceneRect(); void clearGallery(); void galleryPrev(); diff --git a/app/settings.h b/app/settings.h index 94cdbbb..83762a3 100644 --- a/app/settings.h +++ b/app/settings.h @@ -17,9 +17,7 @@ public: }; Q_ENUM(MouseWheelBehavior) - // TODO: I want to remove Auto behavior in future. enum WindowSizeBehavior { - Auto, Maximized, Windowed, }; diff --git a/app/settingsdialog.cpp b/app/settingsdialog.cpp index b27f513..b365eb8 100644 --- a/app/settingsdialog.cpp +++ b/app/settingsdialog.cpp @@ -58,7 +58,6 @@ static EnumComboBoxTransformer MW_OPTIONS static EnumComboBoxTransformer IWS_OPTIONS { { - { Settings::WindowSizeBehavior::Auto, QCoreApplication::translate("SettingsDialog", "Auto size") }, { Settings::WindowSizeBehavior::Maximized, QCoreApplication::translate("SettingsDialog", "Maximized") }, { Settings::WindowSizeBehavior::Windowed, QCoreApplication::translate("SettingsDialog", "Windowed") } }