diff --git a/src/shell/panelview.cpp b/src/shell/panelview.cpp index 116474f65..b69cf36f4 100644 --- a/src/shell/panelview.cpp +++ b/src/shell/panelview.cpp @@ -117,6 +117,7 @@ void PanelView::setAlignment(Qt::Alignment alignment) m_alignment = alignment; config().writeEntry("alignment", (int)m_alignment); + emit alignmentChanged(); positionPanel(); } @@ -324,38 +325,39 @@ void PanelView::restore() return; } - m_offset = config().readEntry("offset", 0); + static const int MINSIZE = 10; + + m_offset = qMax(0, config().readEntry("offset", 0)); m_maxLength = config().readEntry("maxLength", -1); m_minLength = config().readEntry("minLength", -1); m_alignment = (Qt::Alignment)config().readEntry("alignment", Qt::AlignLeft); setMinimumSize(QSize(-1, -1)); //FIXME: an invalid size doesn't work with QWindows - setMaximumSize(QSize(10000, 10000)); + setMaximumSize(screen()->size()); if (containment()->formFactor() == Plasma::Vertical) { - resize(config().readEntry("thickness", 32), - config().readEntry("length", screen()->size().height())); + const int maxSize = screen()->size().height() - m_offset; + m_maxLength = qBound(MINSIZE, m_maxLength, maxSize); + m_minLength = qBound(MINSIZE, m_minLength, maxSize); - if (m_minLength > 0) { - setMinimumHeight(m_minLength); - } - if (m_maxLength > 0) { - setMaximumHeight(m_maxLength); - } + resize(config().readEntry("thickness", 32), + qBound(MINSIZE, config().readEntry("length", screen()->size().height()), maxSize)); + + setMinimumHeight(m_minLength); + setMaximumHeight(m_maxLength); //Horizontal } else { - resize(config().readEntry("length", screen()->size().width()), + const int maxSize = screen()->size().width() - m_offset; + m_maxLength = qBound(MINSIZE, m_maxLength, maxSize); + m_minLength = qBound(MINSIZE, m_minLength, maxSize); + + resize(qBound(MINSIZE, config().readEntry("length", screen()->size().height()), maxSize), config().readEntry("thickness", 32)); - if (m_minLength > 0) { - setMinimumWidth(m_minLength); - } - - if (m_maxLength > 0) { - setMaximumWidth(m_maxLength); - } + setMinimumWidth(m_minLength); + setMaximumWidth(m_maxLength); } emit maximumLengthChanged(); diff --git a/src/shell/qmlpackages/desktop/contents/configuration/panelconfiguration/Ruler.qml b/src/shell/qmlpackages/desktop/contents/configuration/panelconfiguration/Ruler.qml index dacb8f28a..f13eb508f 100644 --- a/src/shell/qmlpackages/desktop/contents/configuration/panelconfiguration/Ruler.qml +++ b/src/shell/qmlpackages/desktop/contents/configuration/panelconfiguration/Ruler.qml @@ -49,17 +49,20 @@ PlasmaCore.FrameSvgItem { SliderHandle { id: offsetHandle + inverted: panel.alignment == Qt.AlignRight graphicElementName: "offsetslider" onValueChanged: panel.offset = value } SliderHandle { id: minimumLengthHandle + inverted: panel.alignment == Qt.AlignRight offset: panel.offset graphicElementName: "minslider" onValueChanged: panel.minimumLength = value } SliderHandle { id: maximumLengthHandle + inverted: panel.alignment == Qt.AlignRight offset: panel.offset graphicElementName: "maxslider" onValueChanged: panel.maximumLength = value diff --git a/src/shell/qmlpackages/desktop/contents/configuration/panelconfiguration/SliderHandle.qml b/src/shell/qmlpackages/desktop/contents/configuration/panelconfiguration/SliderHandle.qml index 79e389d96..1a6d4bbb4 100644 --- a/src/shell/qmlpackages/desktop/contents/configuration/panelconfiguration/SliderHandle.qml +++ b/src/shell/qmlpackages/desktop/contents/configuration/panelconfiguration/SliderHandle.qml @@ -34,21 +34,30 @@ PlasmaCore.SvgItem { property int value property string graphicElementName property int offset: 0 + property bool inverted: false - onValueChanged: { + function syncPos() { if (panel.location == 5 || panel.location == 6) { - y = value + offset - root.height/2 + if (inverted) { + y = root.parent.height - (value + offset + root.height/2) + } else { + y = value + offset - root.height/2 + } } else { - x = value + offset - root.width/2 + if (inverted) { + x = root.parent.width - (value + offset + root.width/2) + } else { + x = value + offset - root.width/2 + } } } - - onOffsetChanged: { - if (panel.location == 5 || panel.location == 6) { - y = value + offset - root.height/2 - } else { - x = value + offset - root.width/2 - } + onValueChanged: syncPos() + onOffsetChanged: syncPos() + onInvertedChanged: syncPos() + Connections { + target: root.parent + onWidthChanged: syncPos() + onHeightChanged: syncPos() } MouseArea { @@ -59,9 +68,17 @@ PlasmaCore.SvgItem { anchors.fill: parent onPositionChanged: { if (panel.location == 5 || panel.location == 6) { - root.value = parent.y - offset + root.height/2 + if (root.inverted) { + root.value = root.parent.height - (parent.y + offset + root.height/2) + } else { + root.value = parent.y - offset + root.height/2 + } } else { - root.value = parent.x - offset + root.width/2 + if (root.inverted) { + root.value = root.parent.width - (parent.x + offset + root.width/2) + } else { + root.value = parent.x - offset + root.width/2 + } } } }