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
This commit is contained in:
Martin Gräßlin 2014-03-26 12:06:01 +01:00
parent 1b7f66243d
commit 30dd9b7820
8 changed files with 30 additions and 6 deletions

View file

@ -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);
});

View file

@ -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

View file

@ -124,6 +124,9 @@ public:
Q_SIGNALS:
void changed();
private Q_SLOTS:
void slotImplicitSizeChanged();
private:
void init(ViewType type);
};

View file

@ -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

View file

@ -26,6 +26,8 @@ import org.kde.plasma.core 2.0
Item {
signal changed
implicitWidth: col.implicitWidth
implicitHeight: col.implicitHeight
Component {
id: sectionHeading

View file

@ -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" +

View file

@ -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();

View file

@ -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();