From 23ba2b37ef825f0efccc169455f45b0dcdac97cf Mon Sep 17 00:00:00 2001 From: Valeriy Malov Date: Wed, 8 Aug 2018 16:42:00 +0300 Subject: [PATCH] Use custom QScrollArea with size hint not limited by font size Summary: For some reason original QScrollArea has constraint on a size hint This causes large KCMShell pages open in relatively small windows, because QScrollArea inside reports small size hint BUG: 389585 Test Plan: patched 5.48.0 with this, tested networkmanager and few other kcms, they now seem to open in full size (except for kscreen which has custom sizehint, it probably needs size hint for the QML area specifically, not the whole window; and except for opengl that has it's own scrollable area which needs a size hint too) Reviewers: #frameworks, ngraham Reviewed By: ngraham Subscribers: ngraham, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D14692 --- src/kcmultidialog.cpp | 2 +- src/kcmultidialog.h | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/kcmultidialog.cpp b/src/kcmultidialog.cpp index 6526efb..d5f2f10 100644 --- a/src/kcmultidialog.cpp +++ b/src/kcmultidialog.cpp @@ -425,7 +425,7 @@ KPageWidgetItem *KCMultiDialog::addModule(const KCModuleInfo &moduleInfo, } // Create the scroller - QScrollArea *moduleScroll = new QScrollArea(this); + auto *moduleScroll = new UnboundScrollArea(this); // Prepare the scroll area moduleScroll->setWidgetResizable(true); moduleScroll->setFrameStyle(QFrame::NoFrame); diff --git a/src/kcmultidialog.h b/src/kcmultidialog.h index c405dc3..2073be5 100644 --- a/src/kcmultidialog.h +++ b/src/kcmultidialog.h @@ -23,6 +23,8 @@ #ifndef KCMULTIDIALOG_H #define KCMULTIDIALOG_H +#include + #include #include @@ -180,4 +182,24 @@ private: Q_PRIVATE_SLOT(d_func(), void _k_updateHeader(bool use, const QString &message)) }; +/** + * @brief Custom QScrollArea class that doesn't limit its size hint + * + * See original QScrollArea::sizeHint() function, + * where the size hint is bound by 36*24 font heights + * + * Workaround for https://bugreports.qt.io/browse/QTBUG-10459 + */ + +class UnboundScrollArea : public QScrollArea { + Q_OBJECT +public: + QSize sizeHint() const override { + return widget() ? widget()->sizeHint() : QSize(); + } + + UnboundScrollArea(QWidget * w) : QScrollArea(w) {} + virtual ~UnboundScrollArea() = default; +}; + #endif -- 2.18.0