Warning, /plasma/latte-dock/shell/package/contents/configuration/canvas/maxlength/RulerMouseArea.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2018 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 import QtQuick 2.7
0007 
0008 import org.kde.plasma.plasmoid 2.0
0009 import org.kde.plasma.components 2.0 as PlasmaComponents
0010 import org.kde.plasma.core 2.0 as PlasmaCore
0011 
0012 import org.kde.latte.core 0.2 as LatteCore
0013 
0014 MouseArea{
0015     id: rulerMouseArea
0016     hoverEnabled: true
0017     cursorShape: root.isHorizontal ? Qt.SizeHorCursor : Qt.SizeVerCursor
0018 
0019     onVisibleChanged: {
0020         if (!visible) {
0021             tooltip.visible = false;
0022         }
0023     }
0024 
0025     onWheel: {
0026         var angle = wheel.angleDelta.y / 8;
0027 
0028         if (angle > 12) {
0029             updateMaxLength(6);
0030         } else if (angle < -12) {
0031             updateMaxLength(-6);
0032         }
0033     }
0034 
0035     //! replica of updating maximum length from configuration tab
0036     function updateMaxLength(step) {
0037         var updateminimumlength = (plasmoid.configuration.maxLength === plasmoid.configuration.minLength);
0038 
0039         var tempML = plasmoid.configuration.maxLength + step;
0040 
0041         var value = Math.max(Math.min(tempML,100), 30);
0042 
0043         if (updateminimumlength) {
0044             plasmoid.configuration.minLength = Math.max(30, value);
0045         }
0046 
0047         value = Math.max(plasmoid.configuration.minLength, value);
0048         plasmoid.configuration.maxLength = value;
0049 
0050         var newTotal = Math.abs(plasmoid.configuration.offset) + value;
0051 
0052         //centered and justify alignments based on offset and get out of the screen in some cases
0053         var centeredCheck = ((plasmoid.configuration.alignment === LatteCore.Types.Center)
0054                              || (plasmoid.configuration.alignment === LatteCore.Types.Justify))
0055                 && ((Math.abs(plasmoid.configuration.offset) + value/2) > 50);
0056 
0057         if (newTotal > 100 || centeredCheck) {
0058             if ((plasmoid.configuration.alignment === LatteCore.Types.Center)
0059                     || (plasmoid.configuration.alignment === LatteCore.Types.Justify)) {
0060 
0061                 var suggestedValue = (plasmoid.configuration.offset<0) ? Math.min(0, -(100-value)): Math.max(0, 100-value);
0062 
0063                 if ((Math.abs(suggestedValue) + value/2) > 50) {
0064                     if (suggestedValue < 0) {
0065                         suggestedValue = - (50 - value/2);
0066                     } else {
0067                         suggestedValue = 50 - value/2;
0068                     }
0069                 }
0070 
0071                 plasmoid.configuration.offset = suggestedValue;
0072             } else {
0073                 plasmoid.configuration.offset = Math.max(0, 100-value);
0074             }
0075         }
0076     }
0077 }