Warning, /plasma/latte-dock/shell/package/contents/controls/IndicatorConfigUiManager.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2021 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 import QtQuick 2.7
0007 import QtQuick.Layouts 1.3
0008 
0009 import org.kde.plasma.core 2.0 as PlasmaCore
0010 
0011 Item {
0012     id: uiManager
0013     visible: false
0014 
0015     property Item stackView: null
0016 
0017     Item {
0018         id: hiddenIndicatorPage
0019         anchors.fill: parent
0020 
0021         readonly property int optionsWidth: dialog.optionsWidth
0022         readonly property bool deprecatedOptionsAreHidden: true // @since 0.10.0
0023 
0024         readonly property Item nextPage: stackView.currentItem === page1 ? page2 : page1
0025         readonly property Item previousPage: nextPage === page1 ? page2 : page1
0026 
0027         function showNextIndicator() {
0028             var nextIndicator;
0029 
0030             //var pageShown = stackView.currentItem ? 1 : 0;
0031             //var total = page1.children.length + page2.children.length + hiddenPages.children.length + pageShown;
0032             //console.log(" org.kde.latte >>>>>>>>>>>>>>>>> ALL PAGES :: " + total);
0033 
0034             if (children.length > 0) {
0035                 nextIndicator = children[0];
0036             }
0037 
0038             if (nextIndicator && (!stackView.currentItem || !stackView.currentItem.isCurrent)) {
0039                 //!empty nextPage by moving its pages into hiddenPages
0040                 var childrenCount = nextPage.children.length;
0041                 for (var i=0; i<childrenCount; ++i) {
0042                     var previousIndicator = nextPage.children[0];
0043                     previousIndicator.visible = false;
0044                     previousIndicator.parent = hiddenPages;
0045                 }
0046 
0047                 nextIndicator.parent = nextPage;
0048                 nextIndicator.visible = true;
0049                 stackView.Layout.minimumHeight = nextIndicator.height;
0050                 nextPage.type = latteView.indicator.type;
0051 
0052                 var currentIndex = -1;
0053 
0054                 if (stackView.currentItem) {
0055                     currentIndex = viewConfig.indicatorUiManager.index(stackView.currentItem.type);
0056                 }
0057 
0058                 var nextIndex = viewConfig.indicatorUiManager.index(latteView.indicator.type);
0059 
0060                 stackView.forwardSliding = (nextIndex<currentIndex);
0061                 stackView.replace(stackView.currentItem, nextPage);
0062             }
0063 
0064             if (children.length>0) {
0065                 //!empty all remaining pages by moving them into hiddenPages
0066                 var tempcount = children.length;
0067                 for (var i=0; i<tempcount; ++i) {
0068                     var tempIndicator = children[0];
0069                     tempIndicator.visible = false;
0070                     tempIndicator.parent = hiddenPages;
0071                 }
0072             }
0073         }
0074 
0075         Component.onCompleted: {
0076             viewConfig.indicatorUiManager.setParentItem(hiddenIndicatorPage);
0077             tabBar.selectTab(latteView.indicator.type);
0078             viewConfig.indicatorUiManager.ui(latteView.indicator.type, latteView);
0079         }
0080 
0081         Connections {
0082             target: latteView.indicator
0083             onPluginChanged: {
0084                 if (viewConfig.isReady) {
0085                     tabBar.selectTab(latteView.indicator.type);
0086                     viewConfig.indicatorUiManager.ui(latteView.indicator.type, latteView);
0087                 }
0088             }
0089         }
0090 
0091         Connections {
0092             target: viewConfig
0093             onIsReadyChanged: {
0094                 if (viewConfig.isReady) {
0095                     tabBar.selectTab(latteView.indicator.type);
0096                     viewConfig.indicatorUiManager.ui(latteView.indicator.type, latteView);
0097                 }
0098             }
0099         }
0100     }
0101 
0102     Item {
0103         id: hidden
0104         visible: false
0105         ColumnLayout {
0106             id: page1
0107             width: stackView.width
0108             readonly property bool isCurrent: latteView.indicator.type === type && viewConfig.isReady/*update flag*/
0109             readonly property bool deprecatedOptionsAreHidden: true // @since 0.10.0
0110             readonly property int optionsWidth: dialog.optionsWidth
0111 
0112             property string type: ""
0113         }
0114 
0115         ColumnLayout {
0116             id: page2
0117             width: stackView.width
0118             readonly property bool isCurrent: latteView.indicator.type === type && viewConfig.isReady/*update flag*/
0119             readonly property bool deprecatedOptionsAreHidden: true // @since 0.10.0
0120             readonly property int optionsWidth: dialog.optionsWidth
0121 
0122             property string type: ""
0123         }
0124 
0125         ColumnLayout {
0126             id: hiddenPages
0127             width: stackView.width
0128             readonly property bool isCurrent: latteView.indicator.type === type && viewConfig.isReady/*update flag*/
0129             readonly property bool deprecatedOptionsAreHidden: true // @since 0.10.0
0130             readonly property int optionsWidth: dialog.optionsWidth
0131 
0132             property string type: ""
0133         }
0134     }
0135 }