Warning, /plasma/latte-dock/shell/package/contents/configuration/LatteDockConfiguration.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2016 Smith AR <audoban@openmailbox.org>
0003 SPDX-FileCopyrightText: 2016 Michail Vourlakos <mvourlakos@gmail.com>
0004 SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006
0007 import QtQuick 2.7
0008 import QtQuick.Controls 1.4
0009 import QtQuick.Controls 2.12 as QtQuickControls212
0010 import QtQuick.Layouts 1.3
0011 import QtGraphicalEffects 1.0
0012 import QtQuick.Window 2.2
0013
0014 import org.kde.plasma.core 2.0 as PlasmaCore
0015 import org.kde.plasma.components 2.0 as PlasmaComponents
0016 import org.kde.plasma.components 3.0 as PlasmaComponents3
0017 import org.kde.plasma.extras 2.0 as PlasmaExtras
0018 import QtQuick.Controls.Styles.Plasma 2.0 as Styles
0019
0020 import org.kde.kquickcontrolsaddons 2.0 as KQuickControlAddons
0021
0022 import org.kde.latte.core 0.2 as LatteCore
0023 import org.kde.latte.components 1.0 as LatteComponents
0024
0025 import "pages" as Pages
0026 import "../controls" as LatteExtraControls
0027
0028 Loader {
0029 active: plasmoid && plasmoid.configuration && latteView
0030
0031 sourceComponent: FocusScope {
0032 id: dialog
0033 width: appliedWidth
0034 height: appliedHeight
0035
0036 readonly property bool basicLevel: !advancedLevel
0037 readonly property bool advancedLevel: universalSettings.inAdvancedModeForEditSettings
0038
0039 readonly property bool inConfigureAppletsMode: universalSettings.inConfigureAppletsMode || !LatteCore.WindowSystem.compositingActive
0040
0041 readonly property bool kirigamiLibraryIsFound: LatteCore.Environment.frameworksVersion >= LatteCore.Environment.makeVersion(5,69,0)
0042
0043 //! max size based on screen resolution
0044 //! TODO: if we can access availableScreenGeometry.height this can be improved, currently
0045 //! we use 100px. or 50px. in order to give space for othe views to be shown and to have also
0046 //! some space around the settings window
0047 property int maxHeight: plasmoid.formFactor === PlasmaCore.Types.Horizontal ?
0048 viewConfig.availableScreenGeometry.height - canvasHeadThickness - units.largeSpacing :
0049 viewConfig.availableScreenGeometry.height - 2 * units.largeSpacing
0050
0051 property int maxWidth: 0.6 * latteView.screenGeometry.width
0052
0053 property int canvasThickness: plasmoid.formFactor === PlasmaCore.Types.Vertical ? latteView.positioner.canvasGeometry.width : latteView.positioner.canvasGeometry.height
0054 property int canvasHeadThickness: {
0055 var edgeMargin = latteView.behaveAsPlasmaPanel && latteView.screenEdgeMarginEnabled ? latteView.screenEdgeMargin : 0;
0056 return Math.max(0,canvasThickness - latteView.maxNormalThickness - Math.max(0,edgeMargin))
0057 }
0058
0059 //! propose size based on font size
0060 property int proposedWidth: 0.82 * proposedHeight + units.smallSpacing * 2
0061 property int proposedHeight: 36 * theme.mSize(theme.defaultFont).height
0062
0063 //! chosen size to be applied, if the user has set or not a different scale for the settings window
0064 property int chosenWidth: userScaleWidth !== 1 ? userScaleWidth * proposedWidth : proposedWidth
0065 property int chosenHeight: userScaleHeight !== 1 ? userScaleHeight * heightLevel * proposedHeight : heightLevel * proposedHeight
0066
0067 readonly property int optionsWidth: appliedWidth - units.smallSpacing * 10
0068
0069 //! user set scales based on its preference, e.g. 96% of the proposed size
0070 property real userScaleWidth: 1
0071 property real userScaleHeight: 1
0072
0073 readonly property real heightLevel: (dialog.advancedLevel ? 100 : 1) //in order to use all available space
0074
0075 onHeightChanged: viewConfig.syncGeometry();
0076
0077 //! applied size in order to not be out of boundaries
0078 //! width can be between 200px - maxWidth
0079 //! height can be between 400px - maxHeight
0080 property int appliedWidth: Math.min(maxWidth, Math.max(200, chosenWidth))
0081 property int appliedHeight: universalSettings.inAdvancedModeForEditSettings ? maxHeight : Math.min(maxHeight, Math.max(400, chosenHeight))
0082
0083 Layout.minimumWidth: width
0084 Layout.minimumHeight: height
0085 LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
0086 LayoutMirroring.childrenInherit: true
0087
0088 readonly property bool viewIsPanel: latteView.type === LatteCore.Types.PanelView
0089
0090 property bool panelIsVertical: plasmoid.formFactor === PlasmaCore.Types.Vertical
0091 property int subGroupSpacing: units.largeSpacing + units.smallSpacing * 1.5
0092
0093 property color bC: theme.backgroundColor
0094 property color tC: theme.textColor
0095 property color transparentBackgroundColor: Qt.rgba(bC.r, bC.g, bC.b, 0.7)
0096 property color borderColor: Qt.rgba(tC.r, tC.g, tC.b, 0.12)
0097
0098 readonly property Item currentPage: pagesStackView.currentItem
0099
0100 onAdvancedLevelChanged: {
0101 //! switch to appearancePage when effectsPage becomes hidden because
0102 //! advancedLevel was disabled by the user
0103 if (!advancedLevel && tabBar.currentTab === effectsTabBtn) {
0104 tabBar.currentTab = appearanceTabBtn;
0105 }
0106 }
0107
0108 Component.onCompleted: {
0109 updateScales();
0110 }
0111
0112 Connections {
0113 target: latteView.positioner
0114 onCurrentScreenNameChanged: dialog.updateScales();
0115 }
0116
0117 function updateScales() {
0118 userScaleWidth = universalSettings.screenWidthScale(latteView.positioner.currentScreenName);
0119 userScaleHeight = universalSettings.screenHeightScale(latteView.positioner.currentScreenName);
0120 }
0121
0122 PlasmaCore.FrameSvgItem{
0123 id: backgroundFrameSvgItem
0124 anchors.fill: parent
0125 imagePath: "dialogs/background"
0126 enabledBorders: viewConfig.enabledBorders
0127
0128 onEnabledBordersChanged: viewConfig.updateEffects()
0129 Component.onCompleted: viewConfig.updateEffects()
0130
0131 LatteExtraControls.DragCorner {
0132 id: dragCorner
0133 }
0134 }
0135
0136 PlasmaComponents.Label{
0137 anchors.top: parent.top
0138 anchors.horizontalCenter: parent.horizontalCenter
0139 text: dialog.advancedLevel ?
0140 i18nc("view settings width scale","Width %1%",userScaleWidth * 100) :
0141 i18nc("view settings width scale","Width %1% / Height %2%", userScaleWidth * 100, userScaleHeight * 100)
0142 visible: dragCorner.isActive
0143 }
0144
0145 ColumnLayout {
0146 id: content
0147
0148 Layout.minimumWidth: width
0149 Layout.minimumHeight: calculatedHeight
0150 Layout.preferredWidth: width
0151 Layout.preferredHeight: calculatedHeight
0152 width: (dialog.appliedWidth - units.smallSpacing * 2)
0153
0154 anchors.horizontalCenter: parent.horizontalCenter
0155 anchors.top: parent.top
0156 spacing: units.smallSpacing
0157
0158 property int calculatedHeight: header.height + headerSpacer.height+ tabBar.height + pagesBackground.height + actionButtons.height + spacing * 3
0159
0160 Keys.onPressed: {
0161 if (event.key === Qt.Key_Escape) {
0162 viewConfig.hideConfigWindow();
0163 }
0164 }
0165
0166 Component.onCompleted: forceActiveFocus();
0167
0168 RowLayout {
0169 id: header
0170 Layout.fillWidth: true
0171
0172 spacing: 0
0173
0174 Item {
0175 id: trademark
0176 Layout.alignment: Qt.AlignLeft | Qt.AlignTop
0177 Layout.fillWidth: false
0178 Layout.topMargin: units.smallSpacing
0179 Layout.preferredWidth: width
0180 Layout.preferredHeight: height
0181
0182 width: latteTrademark.width + units.smallSpacing
0183 height: trademarkHeight
0184
0185 readonly property int trademarkHeight: 48
0186
0187 PlasmaCore.SvgItem{
0188 id: latteTrademark
0189 width: Qt.application.layoutDirection !== Qt.RightToLeft ? Math.ceil(1.70 * height) : height
0190 height: trademark.height
0191
0192 svg: PlasmaCore.Svg{
0193 imagePath: Qt.application.layoutDirection !== Qt.RightToLeft ? universalSettings.trademarkPath() : universalSettings.trademarkIconPath()
0194 }
0195 }
0196 }
0197
0198 Item{
0199 id: headerSpacer
0200 Layout.minimumHeight: advancedSettings.height + 2*units.smallSpacing
0201 }
0202
0203 ColumnLayout {
0204 PlasmaComponents3.ToolButton {
0205 id: pinButton
0206 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
0207 Layout.bottomMargin: units.smallSpacing * 1.5
0208 Layout.topMargin: units.smallSpacing * 3
0209 Layout.rightMargin: units.smallSpacing * 2
0210 icon.name: "window-pin"
0211 checkable: true
0212
0213 property bool inStartup: true
0214
0215 onClicked: {
0216 plasmoid.configuration.configurationSticker = checked
0217 viewConfig.setSticker(checked)
0218 }
0219
0220 Component.onCompleted: {
0221 checked = plasmoid.configuration.configurationSticker
0222 viewConfig.setSticker(plasmoid.configuration.configurationSticker)
0223 }
0224 }
0225
0226 RowLayout {
0227 id: advancedSettings
0228 Layout.fillWidth: true
0229 Layout.rightMargin: units.smallSpacing * 2
0230 Layout.alignment: Qt.AlignRight | Qt.AlignTop
0231
0232 PlasmaComponents.Label {
0233 Layout.fillWidth: true
0234 Layout.alignment: Qt.AlignRight
0235 }
0236
0237 PlasmaComponents.Label {
0238 id: advancedLbl
0239 Layout.alignment: Qt.AlignRight
0240 // opacity: dialog.basicLevel ? basicOpacity : 1
0241
0242 //! TODO: the term here is not accurate because the expert settings mode
0243 //! is used currently. In the future this term will be rethought if
0244 //! it must remain or be changed
0245 text: i18nc("advanced settings", "Advanced")
0246
0247 readonly property real textColorBrightness: colorBrightness(theme.textColor)
0248 readonly property real basicOpacity: textColorBrightness > 127 ? 0.7 : 0.3
0249
0250 color: {
0251 if (dialog.basicLevel) {
0252 return textColorBrightness > 127 ? Qt.darker(theme.textColor, 1.4) : Qt.lighter(theme.textColor, 2.8);
0253 }
0254
0255 return theme.textColor;
0256 }
0257
0258 function colorBrightness(color) {
0259 return colorBrightnessFromRGB(color.r * 255, color.g * 255, color.b * 255);
0260 }
0261
0262 // formula for brightness according to:
0263 // https://www.w3.org/TR/AERT/#color-contrast
0264 function colorBrightnessFromRGB(r, g, b) {
0265 return (r * 299 + g * 587 + b * 114) / 1000
0266 }
0267
0268 MouseArea {
0269 id: advancedMouseArea
0270 anchors.fill: parent
0271 hoverEnabled: true
0272 onClicked: {
0273 advancedSwitch.checked = !advancedSwitch.checked;
0274 }
0275 }
0276 }
0277
0278 LatteComponents.Switch {
0279 id: advancedSwitch
0280 checked: universalSettings.inAdvancedModeForEditSettings && viewConfig.isReady
0281
0282 onCheckedChanged: {
0283 if (viewConfig.isReady) {
0284 universalSettings.inAdvancedModeForEditSettings = checked;
0285 }
0286 }
0287 }
0288 }
0289 }
0290 }
0291
0292 PlasmaComponents.TabBar {
0293 id: tabBar
0294 Layout.fillWidth: true
0295 Layout.maximumWidth: (dialog.appliedWidth - units.smallSpacing * 2)
0296
0297 readonly property int visibleStaticPages: dialog.advancedLevel ? 3 : 2
0298
0299 PlasmaComponents.TabButton {
0300 id: behaviorTabBtn
0301 text: i18n("Behavior")
0302 onCheckedChanged: {
0303 if (checked && pagesStackView.currentItem !== behaviorPage) {
0304 pagesStackView.forwardSliding = true;
0305 pagesStackView.replace(pagesStackView.currentItem, behaviorPage);
0306 }
0307 }
0308
0309 Connections {
0310 target: viewConfig
0311 onIsReadyChanged: {
0312 if (viewConfig.isReady) {
0313 tabBar.currentTab = behaviorTabBtn;
0314 }
0315 }
0316 }
0317 }
0318
0319 PlasmaComponents.TabButton {
0320 id: appearanceTabBtn
0321 text: i18n("Appearance")
0322 onCheckedChanged: {
0323 if (checked && pagesStackView.currentItem !== appearancePage) {
0324 pagesStackView.forwardSliding = (pagesStackView.currentItem.pageIndex > 1);
0325 pagesStackView.replace(pagesStackView.currentItem, appearancePage);
0326 }
0327 }
0328 }
0329 PlasmaComponents.TabButton {
0330 id: effectsTabBtn
0331 text: i18n("Effects")
0332 visible: dialog.advancedLevel
0333
0334 onCheckedChanged: {
0335 if (checked && pagesStackView.currentItem !== effectsPage) {
0336 pagesStackView.forwardSliding = (pagesStackView.currentItem.pageIndex > 2);
0337 pagesStackView.replace(pagesStackView.currentItem, effectsPage);
0338 }
0339 }
0340 }
0341
0342 Repeater {
0343 id: tasksTabButtonRepeater
0344 model: latteView.extendedInterface.latteTasksModel
0345
0346 PlasmaComponents.TabButton {
0347 text: index >= 1 ? i18nc("tasks header and index","Tasks <%1>", index+1) : i18n("Tasks")
0348 onCheckedChanged: {
0349 if (checked && pagesStackView.currentItem !== tasksRepeater.itemAt(index)) {
0350 pagesStackView.forwardSliding = (pagesStackView.currentItem.pageIndex > (tabBar.visibleStaticPages + index));
0351 pagesStackView.replace(pagesStackView.currentItem, tasksRepeater.itemAt(index));
0352 }
0353 }
0354 }
0355 }
0356 }
0357
0358 Item {
0359 id: pagesBackground
0360 Layout.fillWidth: true
0361 Layout.fillHeight: false
0362 Layout.minimumWidth: dialog.appliedWidth - units.smallSpacing * 4
0363 Layout.minimumHeight: height
0364 Layout.maximumHeight: height
0365
0366 width: dialog.appliedWidth - units.smallSpacing * 3
0367 height: availableFreeHeight + units.smallSpacing * 4
0368
0369 //fix the height binding loop when showing the configuration window
0370 property int availableFreeHeight: dialog.appliedHeight - header.height - headerSpacer.height - tabBar.height - actionButtons.height - 2 * units.smallSpacing
0371
0372 // Header
0373 Rectangle {
0374 anchors.top: parent.top
0375 anchors.left: parent.left
0376 anchors.right: parent.right
0377 anchors.topMargin: -units.smallSpacing + 2
0378 anchors.leftMargin: -2*units.smallSpacing
0379 anchors.rightMargin: -2*units.smallSpacing
0380
0381 height: parent.height // dialog.height - (header.height + tabBar.height + units.smallSpacing * 1.5) + 2
0382 color: theme.backgroundColor
0383 border.width: 1
0384 border.color: dialog.borderColor
0385 }
0386
0387 PlasmaExtras.ScrollArea {
0388 id: scrollArea
0389
0390 anchors.fill: parent
0391 verticalScrollBarPolicy: Qt.ScrollBarAsNeeded
0392 horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
0393
0394 flickableItem.flickableDirection: Flickable.VerticalFlick
0395
0396 QtQuickControls212.StackView {
0397 id: pagesStackView
0398 width: currentItem.width
0399 height: currentItem.height
0400
0401 property bool forwardSliding: true
0402
0403 replaceEnter: Transition {
0404 ParallelAnimation {
0405 PropertyAnimation {
0406 property: "x"
0407 from: pagesStackView.forwardSliding ? -pagesBackground.width : pagesBackground.width
0408 to: 0
0409 duration: 350
0410 }
0411
0412 PropertyAnimation {
0413 property: "opacity"
0414 from: 0
0415 to: 1
0416 duration: 350
0417 }
0418 }
0419 }
0420
0421 replaceExit: Transition {
0422 ParallelAnimation {
0423 PropertyAnimation {
0424 property: "x"
0425 from: 0
0426 to: pagesStackView.forwardSliding ? pagesBackground.width : -pagesBackground.width
0427 duration: 350
0428 }
0429
0430 PropertyAnimation {
0431 property: "opacity"
0432 from: 1
0433 to: 0
0434 duration: 350
0435 }
0436 }
0437 }
0438
0439 onDepthChanged: {
0440 if (depth === 0) {
0441 pagesStackView.forwardSliding = true;
0442 push(behaviorPage);
0443 }
0444 }
0445 }
0446 }
0447
0448 Item {
0449 id:hiddenPages
0450 anchors.fill: parent
0451 visible: false
0452
0453 Pages.BehaviorConfig {
0454 id: behaviorPage
0455 readonly property int pageIndex:0
0456
0457 Component.onCompleted: {
0458 pagesStackView.push(behaviorPage);
0459 }
0460 }
0461
0462 Pages.AppearanceConfig {
0463 id: appearancePage
0464 readonly property int pageIndex:1
0465 }
0466
0467 Pages.EffectsConfig {
0468 id: effectsPage
0469 readonly property int pageIndex:2
0470 }
0471
0472 Repeater {
0473 id: tasksRepeater
0474 model: plasmoid && plasmoid.configuration && latteView ? latteView.extendedInterface.latteTasksModel : 0
0475
0476 Pages.TasksConfig {
0477 readonly property int pageIndex: tabBar.visibleStaticPages+index
0478 }
0479 }
0480 }
0481 }
0482
0483 RowLayout {
0484 id: actionButtons
0485 Layout.fillWidth: true
0486 Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
0487
0488 spacing: units.largeSpacing
0489
0490 LatteComponents.ComboBoxButton {
0491 id: actionsComboBtn
0492 Layout.fillWidth: true
0493 implicitWidth: removeView.implicitWidth
0494 implicitHeight: removeView.implicitHeight
0495
0496 buttonEnabled: true
0497 buttonIsTriggeringMenu: true
0498 buttonText: i18n("Add...")
0499 buttonIconSource: "list-add"
0500 buttonToolTip: i18n("Add new docks and panels from various templates")
0501
0502 comboBoxEnabled: true
0503 comboBoxBlankSpaceForEmptyIcons: true
0504 comboBoxPopUpAlignRight: Qt.application.layoutDirection === Qt.RightToLeft
0505 comboBoxEnabledRole: "enabled"
0506 comboBoxTextRole: "name"
0507 comboBoxIconRole: "icon"
0508 comboBoxIsSeparatorRole: "isSeparator"
0509 comboBoxMinimumPopUpWidth: actionsModel.count > 1 ? dialog.width / 2 : 150
0510
0511 property var centralLayoutsNames: []
0512
0513 Component.onCompleted: {
0514 comboBox.model = actionsModel;
0515 }
0516
0517 ListModel {
0518 id: actionsModel
0519 }
0520
0521 Connections{
0522 target: actionsComboBtn.comboBox
0523
0524 Component.onCompleted:actionsComboBtn.updateModel();
0525
0526 onActivated: {
0527 var item = actionsModel.get(index);
0528
0529 if (item && item.actionId === "add:") {
0530 latteView.newView(item.templateId);
0531 } else if (item && item.actionId === "duplicate:") {
0532 latteView.duplicateView();
0533 }
0534
0535 actionsComboBtn.comboBox.currentIndex = -1;
0536 }
0537
0538 onEnabledChanged: {
0539 if (enabled) {
0540 actionsComboBtn.updateModel();
0541 } else {
0542 actionsComboBtn.emptyModel();
0543 }
0544 }
0545 }
0546
0547 Connections{
0548 target: viewConfig
0549 onIsReadyChanged: {
0550 if (viewConfig.isReady) {
0551 actionsComboBtn.updateModel();
0552 }
0553 }
0554 }
0555
0556 Connections{
0557 target: latteView
0558 onTypeChanged: actionsComboBtn.updateDuplicateText();
0559 }
0560
0561 Connections {
0562 target: layoutsManager
0563 onViewTemplatesChanged: actionsComboBtn.updateModel();
0564 }
0565
0566 function updateModel() {
0567 actionsModel.clear();
0568
0569 var duplicate = {actionId: 'duplicate:', enabled: true, name: '', icon: 'edit-copy'};
0570 actionsModel.append(duplicate);
0571 updateDuplicateText();
0572
0573 var separator = {isSeparator: true};
0574 actionsModel.append(separator);
0575
0576 var viewTemplateIds = layoutsManager.viewTemplateIds();
0577 var viewTemplateNames = layoutsManager.viewTemplateNames();
0578
0579 for(var i=viewTemplateIds.length-1; i>=0; --i) {
0580 //! add view templates on reverse
0581 var viewtemplate = {
0582 actionId: 'add:',
0583 enabled: true,
0584 templateId: viewTemplateIds[i],
0585 name: viewTemplateNames[i],
0586 icon: 'list-add'
0587 };
0588 actionsModel.append(viewtemplate);
0589 }
0590
0591 actionsComboBtn.comboBox.currentIndex = -1;
0592 }
0593
0594 function emptyModel() {
0595 actionsModel.clear();
0596 actionsComboBtn.comboBox.currentIndex = -1;
0597 }
0598
0599 function updateDuplicateText() {
0600 for (var i=0; i<actionsModel.count; ++i) {
0601 var item = actionsModel.get(i);
0602 if (item.actionId === "duplicate:") {
0603 var duplicateText = latteView.type === LatteCore.Types.DockView ? i18n("Duplicate Dock") : i18n("Duplicate Panel")
0604 item.name = duplicateText;
0605 break;
0606 }
0607 }
0608 }
0609
0610 }
0611
0612 PlasmaComponents.Button {
0613 id: removeView
0614 Layout.fillWidth: true
0615 enabled: dialog.advancedLevel
0616 text: i18n("Remove")
0617 iconSource: "delete"
0618 opacity: enabled ? 1 : 0
0619 tooltip: i18n("Remove current dock")
0620
0621 onClicked: latteView.removeView()
0622 }
0623
0624 PlasmaComponents.Button {
0625 id: closeButton
0626 Layout.fillWidth: true
0627
0628 text: i18n("Close")
0629 iconSource: "dialog-close"
0630 tooltip: i18n("Close settings window")
0631
0632 onClicked: viewConfig.hideConfigWindow();
0633 }
0634 }
0635 }
0636
0637 /*PlasmaExtras.PlasmoidHeading {
0638 id: plasmoidFooter
0639 location: PlasmaExtras.PlasmoidHeading.Location.Footer
0640 anchors {
0641 bottom: parent.bottom
0642 left: parent.left
0643 right: parent.right
0644 }
0645 height: actionButtons.height + units.smallSpacing * 2.5
0646 // So that it doesn't appear over the content view, which results in
0647 // the footer controls being inaccessible
0648 z: -9999
0649 }*/
0650 }
0651 }