provide visual limits for margins/padding

--based on the current indicator there minimum
thickness and indicator padding can be altered.
Providing some visual feedback for the user to
understand these limits is a good practice.
pull/5/head
Michail Vourlakos 6 years ago
parent 6d84b6eea2
commit 915bb1bd39

@ -230,6 +230,21 @@ QStringList Indicator::customLocalPluginIds() const
return m_corona->indicatorFactory()->customLocalPluginIds();
}
QQuickItem *Indicator::info() const
{
return m_info;
}
void Indicator::setIndicatorInfo(QQuickItem *info)
{
if (m_info == info) {
return;
}
m_info = info;
emit infoChanged();
}
QQmlComponent *Indicator::component() const
{
return m_component;

@ -66,6 +66,8 @@ class Indicator: public QObject
Q_PROPERTY(QStringList customPluginNames READ customPluginNames NOTIFY customPluginsChanged)
Q_PROPERTY(QStringList customLocalPluginIds READ customLocalPluginIds NOTIFY customPluginsChanged)
Q_PROPERTY(QQuickItem *info READ info NOTIFY infoChanged)
/**
* Configuration object: each config key will be a writable property of this object. property bindings work.
*/
@ -105,6 +107,8 @@ public:
QStringList customPluginNames() const;
QStringList customLocalPluginIds() const;
QQuickItem *info() const;
QObject *configuration() const;
QQmlComponent *component() const;
QQmlComponent *plasmaComponent() const;
@ -116,12 +120,14 @@ public slots:
Q_INVOKABLE void addIndicator();
Q_INVOKABLE void downloadIndicator();
Q_INVOKABLE void removeIndicator(QString pluginId);
Q_INVOKABLE void setIndicatorInfo(QQuickItem *info);
signals:
void customPluginsChanged();
void enabledChanged();
void enabledForAppletsChanged();
void customPluginChanged();
void infoChanged();
void latteTasksArePresentChanged();
void paddingChanged();
void plasmaComponentChanged();
@ -165,6 +171,8 @@ private:
KPluginMetaData m_metadata;
QPointer<QQuickItem> m_info;
QPointer<KDeclarative::ConfigPropertyMap> m_configuration;
QPointer<KDeclarative::QmlObjectSharedEngine> m_lastCreatedConfigUi;
};

@ -71,6 +71,15 @@ Item{
}
}
Connections {
target: root
onLatteViewChanged: {
if (latteView) {
latteView.indicator.setIndicatorInfo(indicators.info)
}
}
}
//! Metrics and values provided from an invisible indicator
Loader{
id: metricsLoader

@ -40,12 +40,42 @@ T.Slider {
snapMode: T.Slider.SnapOnRelease
readonly property bool minimumInternalValueIsSet: (minimumInternalValue!==from && minimumInternalValue !== -10000)
property int minimumInternalValue: -10000
PlasmaCore.Svg {
id: grooveSvg
imagePath: "widgets/slider"
colorGroup: PlasmaCore.ColorScope.colorGroup
}
PlasmaCore.FrameSvgItem {
id: minimumValueGroove
imagePath: "widgets/slider"
prefix: "groove-highlight"
x: limitedX - width/2
y: parent.height/2 - height/2
width: parent.height * 0.6
height: 2
rotation: 90
visible: minimumInternalValueIsSet
readonly property int limitedX: limitedPer * parent.width
readonly property real limitedPer: ((minimumInternalValue-from)/(to-from))
opacity: {
if (control.enabled && minimumInternalValueIsSet && value < minimumInternalValue) {
return 0.3
}
if (control.enabled) {
return 1;
}
return 0.4;
}
}
handle: Item {
property bool horizontal: control.orientation === Qt.Horizontal
x: leftFixedPadding + (horizontal ? control.visualPosition * (control.availableWidth - width / 2) : (control.availableWidth - width) / 2)
@ -85,13 +115,24 @@ T.Slider {
scale: horizontal && control.mirrored ? -1 : 1
PlasmaCore.FrameSvgItem {
id: grooveHighlight
imagePath: "widgets/slider"
prefix: "groove-highlight"
x: parent.horizontal ? 0 : (parent.width - width) / 2
y: parent.horizontal ? (parent.height - height) / 2 : control.visualPosition * parent.height
width: parent.horizontal ? control.position * parent.width + invisibleSpacer : parent.width
height: parent.horizontal ? parent.height : control.position * parent.height + invisibleSpacer
opacity: control.enabled ? 1 : 0.4
opacity: {
if (control.enabled && minimumInternalValueIsSet && value < minimumInternalValue) {
return 0.3
}
if (control.enabled) {
return 1;
}
return 0.4;
}
property int invisibleSpacer: control.position === 0 ? 4 : 0
}

@ -560,6 +560,7 @@ PlasmaComponents.Page {
to: 40
stepSize: 1
wheelEnabled: false
minimumInternalValue: latteView.indicator.info.minThicknessPadding * 100
onPressedChanged: {
if (!pressed) {
@ -569,10 +570,12 @@ PlasmaComponents.Page {
}
PlasmaComponents.Label {
text: i18nc("number in percentage, e.g. 85 %","%0 %").arg(thickMarginSlider.value)
text: i18nc("number in percentage, e.g. 85 %","%0 %").arg(currentValue)
horizontalAlignment: Text.AlignRight
Layout.minimumWidth: theme.mSize(theme.defaultFont).width * 4
Layout.maximumWidth: theme.mSize(theme.defaultFont).width * 4
readonly property int currentValue: Math.max(thickMarginSlider.minimumInternalValue, thickMarginSlider.value)
}
}
}

@ -550,6 +550,7 @@ PlasmaComponents.Page {
to: maxMargin
stepSize: 1
wheelEnabled: false
minimumInternalValue: latteView.indicator.info.minLengthPadding * 100
readonly property int maxMargin: 25
@ -561,10 +562,12 @@ PlasmaComponents.Page {
}
PlasmaComponents.Label {
text: i18nc("number in percentage, e.g. 85 %","%0 %").arg(lengthIntMarginSlider.value)
text: i18nc("number in percentage, e.g. 85 %","%0 %").arg(currentValue)
horizontalAlignment: Text.AlignRight
Layout.minimumWidth: theme.mSize(theme.defaultFont).width * 4
Layout.maximumWidth: theme.mSize(theme.defaultFont).width * 4
readonly property int currentValue: Math.max(lengthIntMarginSlider.minimumInternalValue, lengthIntMarginSlider.value)
}
}

Loading…
Cancel
Save