Merge branch 'sizeHint_for_settings' into 'master'

Implementation of sizeHint based on implementation of systemsettings

See merge request graphics/okular!499
This commit is contained in:
Noah Colberg 2024-06-24 23:21:46 +00:00
commit 562b1b6c87
2 changed files with 18 additions and 0 deletions

View File

@ -9,6 +9,10 @@
#include <KLocalizedString>
#include <QFontDatabase>
#include <QGuiApplication>
#include <QScreen>
// single config pages
#include "dlgaccessibility.h"
#include "dlgannotations.h"
@ -23,6 +27,7 @@
PreferencesDialog::PreferencesDialog(QWidget *parent, KConfigSkeleton *skeleton, Okular::EmbedMode embedMode, const QString &editCmd)
: KConfigDialog(parent, QStringLiteral("preferences"), skeleton)
{
setMinimumSize(PreferencesDialog::sizeHint());
setWindowModality(Qt::ApplicationModal);
m_general = new DlgGeneral(this, embedMode);
@ -78,3 +83,14 @@ void PreferencesDialog::switchToAnnotationsPage()
setCurrentPage(m_annotationsPage);
}
}
QSize PreferencesDialog::sizeHint() const
{ // Code based on the implementation of sizeHint of the systemsettings project
// Take the font size into account for the window size, as we do for UI elements
const float fontSize = QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSizeF();
const QSize targetSize = QSize(qRound(102 * fontSize), qRound(70 * fontSize));
// on smaller or portrait-rotated screens, do not max out height and/or width
const QSize screenSize = (QGuiApplication::primaryScreen()->availableSize() * 0.9);
return targetSize.boundedTo(screenSize);
}

View File

@ -33,7 +33,9 @@ public:
void switchToAccessibilityPage();
void switchToAnnotationsPage();
protected:
QSize sizeHint() const override;
// void updateSettings(); // Called when OK/Apply is pressed.
// void updateWidgets(); // Called upon construction or when Reset is pressed
// void updateWidgetsDefault(); // Called when Defaults button is pressed