kcmutils/0001-Manually-resize-KCMUtilDialog-to-sizeHint.patch

73 lines
2.0 KiB
Diff

From cc4ecfdcd48a52a67f60eb69ed69e91ca42ee405 Mon Sep 17 00:00:00 2001
From: Valeriy Malov <jazzvoid@gmail.com>
Date: Mon, 10 Sep 2018 17:39:40 +0300
Subject: [PATCH] Manually resize KCMUtilDialog to sizeHint()
Summary:
Workaround for https://bugreports.qt.io/browse/QTBUG-3459
Currently adjustSize() is limited to 2/3 of the screen size for windows
This adds unnecessary scrollbars on dialogs that would otherwise fit the
screen
Manually resize the window after adjustSize() happens to avoid this
limitation
CCBUG: 389585
Test Plan:
Tested on a 1366x768 laptop, with this patch networkmanagement window opens
in full screen height (respecting the panel)
Reviewers: #frameworks, ngraham
Reviewed By: ngraham
Subscribers: davidedmundson, acrouthamel, kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D15406
---
src/kcmultidialog.cpp | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/kcmultidialog.cpp b/src/kcmultidialog.cpp
index d5f2f10..2fd7cb8 100644
--- a/src/kcmultidialog.cpp
+++ b/src/kcmultidialog.cpp
@@ -27,8 +27,10 @@
#include "kcmoduleproxy.h"
+#include <QApplication>
#include <QDebug>
#include <QDesktopServices>
+#include <QDesktopWidget>
#include <QProcess>
#include <QPushButton>
#include <QScrollArea>
@@ -261,9 +263,18 @@ KCMultiDialog::~KCMultiDialog()
void KCMultiDialog::showEvent(QShowEvent *ev)
{
- resize(QSize(800, 550));
- adjustSize();
KPageDialog::showEvent(ev);
+ adjustSize();
+ /**
+ * adjustSize() relies on sizeHint but is limited to 2/3 of the desktop size
+ * Workaround for https://bugreports.qt.io/browse/QTBUG-3459
+ *
+ * We adjust the size after passing the show event
+ * because otherwise window pos is set to (0,0)
+ */
+ const QSize maxSize = QApplication::desktop()->availableGeometry(pos()).size();
+ resize(qMin(sizeHint().width(), maxSize.width()),
+ qMin(sizeHint().height(), maxSize.height()));
}
void KCMultiDialog::slotDefaultClicked()
--
2.18.0