Implementation of sizeHint based on systemsettings

BUG: 397678
This commit is contained in:
Noah Colberg 2021-10-18 11:11:01 +02:00
parent cc64011e3b
commit e3f8102a9d
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"
@ -21,6 +25,7 @@
PreferencesDialog::PreferencesDialog(QWidget *parent, KConfigSkeleton *skeleton, Okular::EmbedMode embedMode)
: KConfigDialog(parent, QStringLiteral("preferences"), skeleton)
{
setMinimumSize(PreferencesDialog::sizeHint());
setWindowModality(Qt::ApplicationModal);
m_general = new DlgGeneral(this, embedMode);
@ -66,3 +71,14 @@ void PreferencesDialog::switchToAnnotationsPage()
if (m_annotationsPage)
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