From 30dd9b78204c6212d191014d5e6f80d639f3cbc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 26 Mar 2014 12:06:01 +0100 Subject: [PATCH] Fix the initial size of the KCMs Both KCMs had a hard coded default which is obviously bad. Instead we now calculate a useable implicitWidth and implicitHeight and use this as the minimum size for the KCM. Which means we need also track changes to these two root object properties and update the QWidget container accordingly. BUG: 332518 BUG: 332519 REVIEW: 117079 --- kcmkwin/kwincompositing/main.cpp | 4 ++-- kcmkwin/kwincompositing/model.cpp | 9 +++++++++ kcmkwin/kwincompositing/model.h | 3 +++ kcmkwin/kwincompositing/qml/CompositingView.qml | 4 ++++ kcmkwin/kwincompositing/qml/EffectView.qml | 2 ++ kcmkwin/kwincompositing/qml/OpenGLErrorView.qml | 4 ++++ kcmkwin/kwincompositing/qml/main-compositing.qml | 5 +++-- kcmkwin/kwincompositing/qml/main.qml | 5 +++-- 8 files changed, 30 insertions(+), 6 deletions(-) diff --git a/kcmkwin/kwincompositing/main.cpp b/kcmkwin/kwincompositing/main.cpp index bdeeeaa2d6..d3c40c65ea 100644 --- a/kcmkwin/kwincompositing/main.cpp +++ b/kcmkwin/kwincompositing/main.cpp @@ -74,11 +74,11 @@ KWinCompositingKCM::KWinCompositingKCM(QWidget* parent, const QVariantList& args QVBoxLayout *vl = new QVBoxLayout(this); QWidget *w = QWidget::createWindowContainer(m_view.data(), this); + connect(m_view.data(), &QWindow::minimumWidthChanged, w, &QWidget::setMinimumWidth); + connect(m_view.data(), &QWindow::minimumHeightChanged, w, &QWidget::setMinimumHeight); w->setMinimumSize(m_view->initialSize()); vl->addWidget(w); setLayout(vl); - m_view->setWidth(width()); - m_view->setHeight(height()); connect(m_view.data(), &KWin::Compositing::EffectView::changed, [this]{ emit changed(true); }); diff --git a/kcmkwin/kwincompositing/model.cpp b/kcmkwin/kwincompositing/model.cpp index 12a0cfb3bb..2634a69745 100644 --- a/kcmkwin/kwincompositing/model.cpp +++ b/kcmkwin/kwincompositing/model.cpp @@ -467,6 +467,9 @@ void EffectView::init(ViewType type) rootContext()->setContextProperty("engine", this); setSource(QUrl(mainFile)); connect(rootObject(), SIGNAL(changed()), this, SIGNAL(changed())); + setMinimumSize(initialSize()); + connect(rootObject(), SIGNAL(implicitWidthChanged()), this, SLOT(slotImplicitSizeChanged())); + connect(rootObject(), SIGNAL(implicitHeightChanged()), this, SLOT(slotImplicitSizeChanged())); } void EffectView::save() @@ -499,5 +502,11 @@ void EffectView::defaults() } } +void EffectView::slotImplicitSizeChanged() +{ + setMinimumSize(QSize(rootObject()->property("implicitWidth").toInt(), + rootObject()->property("implicitHeight").toInt())); +} + }//end namespace Compositing }//end namespace KWin diff --git a/kcmkwin/kwincompositing/model.h b/kcmkwin/kwincompositing/model.h index 2bbb04568b..6b03436a6f 100644 --- a/kcmkwin/kwincompositing/model.h +++ b/kcmkwin/kwincompositing/model.h @@ -124,6 +124,9 @@ public: Q_SIGNALS: void changed(); + +private Q_SLOTS: + void slotImplicitSizeChanged(); private: void init(ViewType type); }; diff --git a/kcmkwin/kwincompositing/qml/CompositingView.qml b/kcmkwin/kwincompositing/qml/CompositingView.qml index bb18019566..c918e04fb8 100644 --- a/kcmkwin/kwincompositing/qml/CompositingView.qml +++ b/kcmkwin/kwincompositing/qml/CompositingView.qml @@ -37,11 +37,15 @@ Item { property alias compositingTypeIndex: backend.type property bool compositingEnabledChecked: useCompositing.checked + implicitWidth: mainLayout.implicitWidth + implicitHeight: mainLayout.implicitHeight + CompositingType { id: compositingType } GridLayout { + id: mainLayout columns: 2 anchors.fill: parent diff --git a/kcmkwin/kwincompositing/qml/EffectView.qml b/kcmkwin/kwincompositing/qml/EffectView.qml index 74c3f8ffea..c96eac5e39 100644 --- a/kcmkwin/kwincompositing/qml/EffectView.qml +++ b/kcmkwin/kwincompositing/qml/EffectView.qml @@ -26,6 +26,8 @@ import org.kde.plasma.core 2.0 Item { signal changed + implicitWidth: col.implicitWidth + implicitHeight: col.implicitHeight Component { id: sectionHeading diff --git a/kcmkwin/kwincompositing/qml/OpenGLErrorView.qml b/kcmkwin/kwincompositing/qml/OpenGLErrorView.qml index 9de5769185..e0444a6359 100644 --- a/kcmkwin/kwincompositing/qml/OpenGLErrorView.qml +++ b/kcmkwin/kwincompositing/qml/OpenGLErrorView.qml @@ -27,7 +27,11 @@ import org.kde.plasma.core 2.0 Item { id: openGLErrorView signal activated + implicitWidth: mainLayout.implicitWidth + implicitHeight: mainLayout.implicitHeight + ColumnLayout { + id: mainLayout Text { id: openGLErrorText text: i18n("OpenGL compositing (the default) has crashed KWin in the past.\n" + diff --git a/kcmkwin/kwincompositing/qml/main-compositing.qml b/kcmkwin/kwincompositing/qml/main-compositing.qml index 7d97ca64f8..8ef6832ecf 100644 --- a/kcmkwin/kwincompositing/qml/main-compositing.qml +++ b/kcmkwin/kwincompositing/qml/main-compositing.qml @@ -26,13 +26,14 @@ import org.kde.kwin.kwincompositing 1.0 Rectangle { id: window - width: 780 - height: 480 + implicitWidth: openGLBrokeState ? glError.implicitWidth : view.implicitWidth + implicitHeight: openGLBrokeState ? glError.implicitHeight : view.implicitHeight color: engine.backgroundViewColor() property bool openGLBrokeState: true signal changed OpenGLErrorView { + id: glError visible: window.openGLBrokeState anchors.fill: parent onActivated: window.openGLBrokeState = compositing.OpenGLIsBroken(); diff --git a/kcmkwin/kwincompositing/qml/main.qml b/kcmkwin/kwincompositing/qml/main.qml index 4e455eb963..742d24c42d 100644 --- a/kcmkwin/kwincompositing/qml/main.qml +++ b/kcmkwin/kwincompositing/qml/main.qml @@ -26,13 +26,14 @@ import org.kde.kwin.kwincompositing 1.0 Rectangle { id: window - width: 780 - height: 480 + implicitWidth: openGLBrokeState ? glError.implicitWidth : view.implicitWidth + implicitHeight: openGLBrokeState ? glError.implicitHeight : view.implicitHeight color: engine.backgroundViewColor() property bool openGLBrokeState: true signal changed OpenGLErrorView { + id: glError visible: window.openGLBrokeState anchors.fill: parent onActivated: window.openGLBrokeState = compositing.OpenGLIsBroken();