From 1c8c728927e872aa878ee6f82c8c90552b1b7b98 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Fri, 6 Apr 2018 11:00:14 +0300 Subject: [PATCH] fix #963,disable wheel for sliders --fork the PlasmaComponents Slider in order to update to newer Qt version and support the wheelEnabled property. After that just disable wheel for all sliders in Appearance page. --- .../configuration/AppearanceConfig.qml | 35 ++++--- .../contents/configuration/BehaviorConfig.qml | 7 +- shell/package/contents/controls/Slider.qml | 92 +++++++++++++++++++ .../TextField.qml} | 0 4 files changed, 120 insertions(+), 14 deletions(-) create mode 100644 shell/package/contents/controls/Slider.qml rename shell/package/contents/{configuration/LatteTextField.qml => controls/TextField.qml} (100%) diff --git a/shell/package/contents/configuration/AppearanceConfig.qml b/shell/package/contents/configuration/AppearanceConfig.qml index cf8f1909f..cba63ae84 100644 --- a/shell/package/contents/configuration/AppearanceConfig.qml +++ b/shell/package/contents/configuration/AppearanceConfig.qml @@ -31,6 +31,8 @@ import org.kde.plasma.plasmoid 2.0 import org.kde.latte 0.1 as Latte +import "../controls" as LatteExtraControls + PlasmaComponents.Page { Layout.maximumWidth: content.width + content.Layout.leftMargin * 2 Layout.maximumHeight: content.height + units.smallSpacing * 2 @@ -156,7 +158,7 @@ PlasmaComponents.Page { horizontalAlignment: Text.AlignLeft } - PlasmaComponents.Slider { + LatteExtraControls.Slider { id: appletsSizeSlider Layout.fillWidth: true value: plasmoid.configuration.iconSize @@ -164,6 +166,7 @@ PlasmaComponents.Page { stepSize: (!plasmoid.configuration.autoDecreaseIconSize && (plasmoid.configuration.advanced || (plasmoid.configuration.iconSize % 8 !== 0))) || dialog.dockIsPanel ? 1 : 8 + wheelEnabled: false function updateIconSize() { if (!pressed) { @@ -210,7 +213,7 @@ PlasmaComponents.Page { horizontalAlignment: Text.AlignLeft } - PlasmaComponents.Slider { + LatteExtraControls.Slider { Layout.fillWidth: true id: zoomSlider @@ -221,6 +224,7 @@ PlasmaComponents.Page { minimumValue: 1 maximumValue: 2 stepSize: 0.05 + wheelEnabled: false function updateZoomLevel() { if (!pressed) { @@ -262,13 +266,14 @@ PlasmaComponents.Page { enabled: proportionSizeSlider.value >= proportionSizeSlider.realMinimum } - PlasmaComponents.Slider { + LatteExtraControls.Slider { id: proportionSizeSlider Layout.fillWidth: true value: plasmoid.configuration.proportionIconSize minimumValue: 1.0 maximumValue: 10 stepSize: 0.5 + wheelEnabled: false property real realMinimum: minimumValue + 0.5 function updateProportionIconSize() { @@ -316,13 +321,14 @@ PlasmaComponents.Page { enabled: iconMarginSlider.value > 0 } - PlasmaComponents.Slider { + LatteExtraControls.Slider { id: iconMarginSlider Layout.fillWidth: true value: plasmoid.configuration.iconMargin minimumValue: 0 maximumValue: 100 stepSize: 5 + wheelEnabled: false onPressedChanged: { if (!pressed) { @@ -378,7 +384,7 @@ PlasmaComponents.Page { horizontalAlignment: Text.AlignLeft } - PlasmaComponents.Slider { + LatteExtraControls.Slider { id: panelSizeSlider Layout.fillWidth: true enabled: showBackground.checked @@ -387,6 +393,7 @@ PlasmaComponents.Page { minimumValue: 0 maximumValue: 100 stepSize: 5 + wheelEnabled: false function updatePanelSize() { if (!pressed) @@ -426,7 +433,7 @@ PlasmaComponents.Page { enabled: transparencySlider.enabled } - PlasmaComponents.Slider { + LatteExtraControls.Slider { id: transparencySlider Layout.fillWidth: true //! transparency can be set when the user doesnt want solidness all the time @@ -437,6 +444,7 @@ PlasmaComponents.Page { minimumValue: 0 maximumValue: 100 stepSize: 5 + wheelEnabled: false property bool blockOpacityAdjustment: (plasmoid.configuration.solidBackgroundForMaximized && plasmoid.configuration.backgroundOnlyOnMaximized) || (solidBackground.checked @@ -781,7 +789,7 @@ PlasmaComponents.Page { horizontalAlignment: Text.AlignLeft } - PlasmaComponents.Slider { + LatteExtraControls.Slider { id: glowOpacitySlider Layout.fillWidth: true enabled: showGlowChk.checked @@ -790,6 +798,7 @@ PlasmaComponents.Page { minimumValue: 0 maximumValue: 100 stepSize: 5 + wheelEnabled: false function updateGlowOpacity() { if (!pressed) @@ -1009,7 +1018,7 @@ PlasmaComponents.Page { horizontalAlignment: Text.AlignLeft } - PlasmaComponents.Slider { + LatteExtraControls.Slider { id: shadowOpacitySlider Layout.fillWidth: true enabled: showAppletShadow.checked @@ -1018,6 +1027,7 @@ PlasmaComponents.Page { minimumValue: 0 maximumValue: 100 stepSize: 5 + wheelEnabled: false function updateShadowOpacity() { if (!pressed) @@ -1058,7 +1068,7 @@ PlasmaComponents.Page { horizontalAlignment: Text.AlignLeft } - PlasmaComponents.Slider { + LatteExtraControls.Slider { id: shadowSizeSlider Layout.fillWidth: true enabled: showAppletShadow.checked @@ -1067,6 +1077,7 @@ PlasmaComponents.Page { minimumValue: 0 maximumValue: 100 stepSize: 5 + wheelEnabled: false function updateShadowSize() { if (!pressed) @@ -1119,7 +1130,7 @@ PlasmaComponents.Page { horizontalAlignment: Text.AlignLeft } - PlasmaComponents.Slider { + LatteExtraControls.Slider { Layout.fillWidth: true id: maxLengthSlider @@ -1130,6 +1141,7 @@ PlasmaComponents.Page { minimumValue: 30 maximumValue: 100 stepSize: 2 + wheelEnabled: false function updateMaxLength() { if (!pressed) { @@ -1194,7 +1206,7 @@ PlasmaComponents.Page { horizontalAlignment: Text.AlignLeft } - PlasmaComponents.Slider { + LatteExtraControls.Slider { Layout.fillWidth: true id: offsetSlider @@ -1207,6 +1219,7 @@ PlasmaComponents.Page { maximumValue: ((plasmoid.configuration.panelPosition === Latte.Dock.Center) || (plasmoid.configuration.panelPosition === Latte.Dock.Justify)) ? 20 : 40 stepSize: 2 + wheelEnabled: false function updateOffset() { if (!pressed) { diff --git a/shell/package/contents/configuration/BehaviorConfig.qml b/shell/package/contents/configuration/BehaviorConfig.qml index 3742423e3..ff377509e 100644 --- a/shell/package/contents/configuration/BehaviorConfig.qml +++ b/shell/package/contents/configuration/BehaviorConfig.qml @@ -29,7 +29,8 @@ import org.kde.plasma.components 3.0 as PlasmaComponents3 import org.kde.plasma.plasmoid 2.0 import org.kde.latte 0.1 as Latte -import "../controls" as ExtraControls + +import "../controls" as LatteExtraControls PlasmaComponents.Page { Layout.maximumWidth: content.width + content.Layout.leftMargin * 2 @@ -467,7 +468,7 @@ PlasmaComponents.Page { horizontalAlignment: Text.AlignRight text: i18n("Show:") } - LatteTextField { + LatteExtraControls.TextField { Layout.preferredWidth: width text: dock.visibility.timerShow @@ -482,7 +483,7 @@ PlasmaComponents.Page { horizontalAlignment: Text.AlignRight text: i18n("Hide:") } - LatteTextField{ + LatteExtraControls.TextField{ Layout.preferredWidth: width text: dock.visibility.timerHide diff --git a/shell/package/contents/controls/Slider.qml b/shell/package/contents/controls/Slider.qml new file mode 100644 index 000000000..cfe743033 --- /dev/null +++ b/shell/package/contents/controls/Slider.qml @@ -0,0 +1,92 @@ +/* +* Copyright (C) 2011 by Daker Fernandes Pinheiro +* Copyright (C) 2014 by Marco Martin +* Copyright (C) 2018 by Michail Vourlakos +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Library General Public License as +* published by the Free Software Foundation; either version 2, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details +* +* You should have received a copy of the GNU Library General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. +*/ + +import QtQuick 2.7 +import org.kde.plasma.core 2.0 as PlasmaCore +import QtQuick.Controls 1.6 as QtControls +import QtQuick.Controls.Styles.Plasma 2.0 as Styles + + +/** + * An interactive slider component with Plasma look and feel. + * + * @inherit QtQuick.Controls.Slider + */ +QtControls.Slider { + id: slider + + /** + * This property holds if a value indicator element will be shown while is + * dragged or not. + * + * @warning The value indicator is not implemented in the Plasma Slider. + * + * The default value is false. + */ + property bool valueIndicatorVisible: false + + /** + * This property holds the text being displayed in the value indicator. + * + * @warning The value indicator is not implemented in the Plasma Slider. + */ + property string valueIndicatorText: value + + /** + * type:bool + * This property holds if the slider visualizations has an inverted + * direction. + * + * @warning: deprecated and not supported, here for retrocompatibility + */ + property bool inverted: false + + width: slider.isVertical ? theme.mSize(theme.defaultFont).height*1.6 : 200 + height: slider.isVertical ? 200 : theme.mSize(theme.defaultFont).height*1.6 + // TODO: needs to define if there will be specific graphics for + // disabled sliders + opacity: enabled ? 1.0 : 0.5 + + activeFocusOnTab: true + + //FIXME: remove those 2 functions once we can depend from 5.4*/ + function accessibleIncreaseAction() { increase() } + function accessibleDecreaseAction() { decrease() } + + function increase() { + if (!enabled) + return; + if (inverted) + value += stepSize; + else + value -= stepSize; + } + function decrease() { + if (!enabled) + return; + if (inverted) + value -= stepSize; + else + value += stepSize; + } + + style: Styles.SliderStyle {} +} diff --git a/shell/package/contents/configuration/LatteTextField.qml b/shell/package/contents/controls/TextField.qml similarity index 100% rename from shell/package/contents/configuration/LatteTextField.qml rename to shell/package/contents/controls/TextField.qml