Git commit cc843f06f670fe2d06b1f7f84a0a3fc1a3d575ed by Aaron Seigo. Committed on 11/11/2013 at 08:56. Pushed by aseigo into branch 'KDE/4.11'.
implement min/max sizes for panel length in the scripting should be forward ported to plasma2's panel system CCMAIL:vercetti.m...@gmail.com CCMAIL:plasma-devel@kde.org M +80 -10 plasma/desktop/shell/scripting/panel.cpp M +9 -0 plasma/desktop/shell/scripting/panel.h http://commits.kde.org/kde-workspace/cc843f06f670fe2d06b1f7f84a0a3fc1a3d575ed diff --git a/plasma/desktop/shell/scripting/panel.cpp b/plasma/desktop/shell/scripting/panel.cpp index 925af7a..e48b9b5 100644 --- a/plasma/desktop/shell/scripting/panel.cpp +++ b/plasma/desktop/shell/scripting/panel.cpp @@ -225,33 +225,103 @@ int Panel::length() const } } -void Panel::setLength(int pixels) +void Panel::setLength(int minPixels, int maxPixels) { Plasma::Containment *c = containment(); - if (pixels < 0 || !c) { + if ((minPixels < 0 && maxPixels < 0) || !c) { return; } PanelView *v = panel(); if (v) { + if (minPixels < 0) { + minPixels = minLength(); + } + + if (maxPixels < 0) { + maxPixels = maxLength(); + } + + int pixels = 0; + pixels = minPixels; + + if (minPixels > maxPixels) { + maxPixels = minPixels; + } + + pixels = qBound(minPixels, pixels, maxPixels); + QRectF screen = c->corona()->screenGeometry(v->screen()); - QSizeF s = c->size(); + QSizeF size = c->size(); + QSizeF minSize = c->minimumSize(); + QSizeF maxSize = c->maximumSize(); if (c->formFactor() == Plasma::Vertical) { - if (pixels > screen.height() - v->offset()) { + if (minPixels > screen.height() - v->offset()) { return; } - s.setHeight(pixels); - } else if (pixels > screen.width() - v->offset()) { + size.setHeight(pixels); + minSize.setHeight(minPixels); + maxSize.setHeight(maxPixels); + } else if (minPixels > screen.width() - v->offset()) { return; } else { - s.setWidth(pixels); + size.setWidth(pixels); + minSize.setWidth(minPixels); + maxSize.setWidth(maxPixels); } - c->resize(s); - c->setMinimumSize(s); - c->setMaximumSize(s); + //kDebug() << "sizes:" << minSize << size << maxSize; + c->setMinimumSize(0, 0); + c->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); + c->resize(size); + c->setMinimumSize(minSize); + c->setMaximumSize(maxSize); + v->pinchContainmentToCurrentScreen(); + } +} + +void Panel::setLength(int pixels) +{ + setLength(pixels, pixels); +} + +int Panel::minLength() const +{ + Plasma::Containment *c = containment(); + if (!c) { + return 0; + } + + if (c->formFactor() == Plasma::Vertical) { + return c->minimumHeight(); + } else { + return c->minimumWidth(); + } +} + +void Panel::setMinLength(int pixels) +{ + setLength(pixels, -1); +} + +int Panel::maxLength() const +{ + Plasma::Containment *c = containment(); + if (!c) { + return 0; } + + if (c->formFactor() == Plasma::Vertical) { + return c->maximumHeight(); + } else { + return c->maximumWidth(); + } +} + +void Panel::setMaxLength(int pixels) +{ + setLength(-1, pixels); } int Panel::height() const diff --git a/plasma/desktop/shell/scripting/panel.h b/plasma/desktop/shell/scripting/panel.h index 2ef0fb8..8e3271d 100644 --- a/plasma/desktop/shell/scripting/panel.h +++ b/plasma/desktop/shell/scripting/panel.h @@ -51,6 +51,8 @@ class Panel : public Containment // panel properties Q_PROPERTY(QString alignment READ alignment WRITE setAlignment) Q_PROPERTY(int offset READ offset WRITE setOffset) + Q_PROPERTY(int minLength READ minLength WRITE setMinLength) + Q_PROPERTY(int maxLength READ maxLength WRITE setMaxLength) Q_PROPERTY(int length READ length WRITE setLength) Q_PROPERTY(int height READ height WRITE setHeight) Q_PROPERTY(QString hiding READ hiding WRITE setHiding) @@ -68,6 +70,12 @@ public: int offset() const; void setOffset(int pixels); + int minLength() const; + void setMinLength(int pixels); + + int maxLength() const; + void setMaxLength(int pixels); + int length() const; void setLength(int pixels); @@ -87,6 +95,7 @@ public Q_SLOTS: void reloadConfig() { Applet::reloadConfig(); } private: + void setLength(int minPixels, int maxPixels); PanelView *panel() const; }; _______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel