Warning, /plasma/kdeplasma-addons/applets/konsoleprofiles/package/contents/ui/main.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   SPDX-FileCopyrightText: 2011, 2012 Shaun Reich <shaun.reich@kdemail.net>
0003  *   SPDX-License-Identifier: GPL-2.0-or-later
0004  */
0005 
0006 import QtQuick 2.0
0007 import QtQuick.Layouts 1.1
0008 import QtQuick.Controls
0009 import org.kde.plasma.plasmoid 2.0
0010 import org.kde.plasma.core as PlasmaCore
0011 import org.kde.kirigami 2.20 as Kirigami
0012 import org.kde.ksvg 1.0 as KSvg
0013 import org.kde.kitemmodels 1.0 as KItemModels
0014 import org.kde.plasma.components 3.0 as PlasmaComponents3
0015 import org.kde.plasma.extras 2.0 as PlasmaExtras
0016 import org.kde.plasma.private.profiles 1.0 as Profiles
0017 
0018 PlasmoidItem {
0019    id: konsoleProfiles
0020 
0021     readonly property bool inPanel: (Plasmoid.location === PlasmaCore.Types.TopEdge
0022         || Plasmoid.location === PlasmaCore.Types.RightEdge
0023         || Plasmoid.location === PlasmaCore.Types.BottomEdge
0024         || Plasmoid.location === PlasmaCore.Types.LeftEdge)
0025 
0026     switchWidth: Kirigami.Units.gridUnit * 11
0027     switchHeight: Kirigami.Units.gridUnit * 9
0028 
0029     Layout.minimumWidth: Kirigami.Units.gridUnit * 12
0030     Layout.minimumHeight: Kirigami.Units.gridUnit * 10
0031 
0032     Plasmoid.icon: inPanel ? "dialog-scripts-symbolic" : "utilities-terminal"
0033 
0034     fullRepresentation: FocusScope {
0035         anchors.fill: parent
0036 
0037         Connections {
0038             target: konsoleProfiles
0039             function onExpandedChanged() {
0040                 if (konsoleProfiles.expanded) {
0041                     view.forceActiveFocus();
0042                 }
0043             }
0044         }
0045 
0046         KItemModels.KSortFilterProxyModel {
0047             id: sortModel
0048             sortRoleName: "name"
0049             sortOrder: Qt.AscendingOrder
0050             sourceModel: Profiles.ProfilesModel {
0051                 id: profilesModel
0052                 appName: "konsole"
0053             }
0054         }
0055 
0056         Row {
0057             id: headerRow
0058             anchors { left: parent.left; right: parent.right }
0059 
0060             Kirigami.Icon {
0061                 id: appIcon
0062                 source: "utilities-terminal"
0063                 width: Kirigami.Units.iconSizes.medium
0064                 height: Kirigami.Units.iconSizes.medium
0065             }
0066 
0067             PlasmaComponents3.Label {
0068                 id: header
0069                 text: i18nc("@title", "Konsole Profiles")
0070                 textFormat: Text.PlainText
0071                 horizontalAlignment: Text.AlignHCenter
0072                 verticalAlignment: Text.AlignVCenter
0073                 width: parent.width - appIcon.width * 2
0074                 height: parent.height
0075             }
0076         }
0077 
0078         KSvg.SvgItem {
0079             id: separator
0080 
0081             anchors { left: headerRow.left; right: headerRow.right; top: headerRow.bottom }
0082             imagePath: "widgets/line"
0083             elementId: "horizontal-line"
0084         }
0085 
0086         Text {
0087             id: textMetric
0088             visible: false
0089             // translated but not used, we just need length/height
0090             text: i18n("Arbitrary String Which Says Something")
0091         }
0092 
0093         ScrollView {
0094             anchors { left: parent.left; right: parent.right; bottom: parent.bottom; top: separator.bottom; topMargin: Kirigami.Units.smallSpacing}
0095 
0096             ListView {
0097                 id: view
0098 
0099                 model: sortModel
0100                 clip: true
0101                 focus: true
0102                 keyNavigationWraps: true
0103 
0104                 delegate: PlasmaComponents3.ItemDelegate {
0105                     id: listdelegate
0106 
0107                     width: ListView.view.width
0108                     height: textMetric.paintedHeight * 2
0109 
0110                     hoverEnabled: true
0111                     text: model.name
0112 
0113                     Accessible.role: Accessible.Button
0114 
0115                     onClicked: {
0116                         openProfile();
0117                     }
0118 
0119                     onHoveredChanged: {
0120                         if (hovered) {
0121                             view.currentIndex = index;
0122                         }
0123                     }
0124 
0125                     function openProfile() {
0126                         /*var service = profilesSource.serviceForSource(model["DataEngineSource"])
0127                         var operation = service.operationDescription("open")
0128                         var  = service.startOperationCall(operation)*/
0129                         console.error(model.profileIdentifier)
0130                         profilesModel.openProfile(model.profileIdentifier)
0131                     }
0132                 }
0133 
0134                 highlight: PlasmaExtras.Highlight {}
0135 
0136                 highlightMoveDuration: Kirigami.Units.longDuration
0137                 highlightMoveVelocity: 1
0138             }
0139         }
0140     }
0141 }