diff --git a/kcmkwin/kwindecoration/qml/ButtonGroup.qml b/kcmkwin/kwindecoration/qml/ButtonGroup.qml index a64f446ab..a8f8ed55e 100644 --- a/kcmkwin/kwindecoration/qml/ButtonGroup.qml +++ b/kcmkwin/kwindecoration/qml/ButtonGroup.qml @@ -1,74 +1,75 @@ /* * Copyright 2014 Martin Gräßlin * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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 General Public License * along with this program. If not, see . */ import QtQuick 2.1 import QtQuick.Controls 1.2 import QtQuick.Layouts 1.1 import org.kde.kwin.private.kdecoration 1.0 as KDecoration import org.kde.plasma.core 2.0 as PlasmaCore; ListView { id: view property string key property bool dragging: false orientation: ListView.Horizontal interactive: false spacing: units.smallSpacing + implicitHeight: units.iconSizes.small + implicitWidth: count * (units.iconSizes.small + units.smallSpacing) - Math.min(1, count) * units.smallSpacing delegate: Item { width: units.iconSizes.small height: units.iconSizes.small KDecoration.Button { id: button property int itemIndex: index property var buttonsModel: parent.ListView.view.model bridge: bridgeItem.bridge settings: settingsItem type: model["button"] anchors.fill: Drag.active ? undefined : parent Drag.keys: [ "decoButtonRemove", view.key ] Drag.active: dragArea.drag.active Drag.onActiveChanged: view.dragging = Drag.active } MouseArea { id: dragArea cursorShape: Qt.PointingHandCursor anchors.fill: parent drag.target: button onReleased: { if (drag.target.Drag.target) { drag.target.Drag.drop(); } else { drag.target.Drag.cancel(); } } } } add: Transition { NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: units.longDuration/2 } NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: units.longDuration/2 } } move: Transition { NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: units.longDuration/2 } NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: units.longDuration/2 } } displaced: Transition { NumberAnimation { properties: "x,y"; duration: units.longDuration; easing.type: Easing.OutBounce } } - Layout.preferredWidth: count * (units.iconSizes.small + units.smallSpacing) - Math.min(1, count) * units.smallSpacing } diff --git a/kcmkwin/kwindecoration/qml/Buttons.qml b/kcmkwin/kwindecoration/qml/Buttons.qml index d8ca4258d..5d397a37a 100644 --- a/kcmkwin/kwindecoration/qml/Buttons.qml +++ b/kcmkwin/kwindecoration/qml/Buttons.qml @@ -1,233 +1,227 @@ /* * Copyright 2014 Martin Gräßlin * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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 General Public License * along with this program. If not, see . */ import QtQuick 2.3 import QtQuick.Controls 1.2 import QtQuick.Layouts 1.1 import org.kde.kwin.private.kdecoration 1.0 as KDecoration import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons; -import org.kde.plasma.core 2.0 as PlasmaCore; Item { objectName: "buttonLayout" Layout.preferredHeight: layout.height KDecoration.Bridge { id: bridgeItem plugin: "org.kde.breeze" } KDecoration.Settings { id: settingsItem bridge: bridgeItem.bridge } Rectangle { anchors.fill: parent anchors.topMargin: units.gridUnit / 2 border.width: Math.ceil(units.gridUnit / 16.0) color: backgroundColor; border.color: highlightColor; ColumnLayout { id: layout width: parent.width height: titlebarRect.height + availableGrid.height + dragHint.height + 5*layout.spacing Rectangle { id: titlebarRect height: buttonPreviewRow.height + units.smallSpacing Layout.fillWidth: true border.width: Math.ceil(units.gridUnit / 16.0) border.color: highlightColor color: backgroundColor; RowLayout { id: buttonPreviewRow anchors.top: parent.top; anchors.left: parent.left; anchors.right: parent.right; anchors.margins: units.smallSpacing / 2 height: Math.max(units.iconSizes.small, titlebar.implicitHeight) + units.smallSpacing/2 ButtonGroup { id: leftButtonsView - anchors.left: parent.left; height: buttonPreviewRow.height model: leftButtons key: "decoButtonLeft" } - Item { + Label { + id: titlebar Layout.fillWidth: true - anchors.centerIn: parent - height: titlebar.implicitHeight - Label { - id: titlebar - anchors.centerIn: parent - font: titleFont - text: i18n("Titlebar") - } + horizontalAlignment: Text.AlignHCenter + font: titleFont + text: i18n("Titlebar") } + ButtonGroup { id: rightButtonsView - anchors.right: parent.right; height: buttonPreviewRow.height model: rightButtons key: "decoButtonRight" } - DropArea { - anchors.fill: parent - keys: [ "decoButtonAdd", "decoButtonRight", "decoButtonLeft" ] - onEntered: { - drag.accept(); + } + DropArea { + anchors.fill: buttonPreviewRow + keys: [ "decoButtonAdd", "decoButtonRight", "decoButtonLeft" ] + onEntered: { + drag.accept(); + } + onDropped: { + var view = undefined; + var left = drag.x - (leftButtonsView.x + leftButtonsView.width); + var right = drag.x - rightButtonsView.x; + if (Math.abs(left) <= Math.abs(right)) { + view = leftButtonsView; + } else { + view = rightButtonsView; } - onDropped: { - var view = undefined; - var left = drag.x - (leftButtonsView.x + leftButtonsView.width); - var right = drag.x - rightButtonsView.x; - if (Math.abs(left) <= Math.abs(right)) { - view = leftButtonsView; - } else { - view = rightButtonsView; - } - if (!view) { - return; - } - var point = mapToItem(view, drag.x, drag.y); - var index = view.indexAt(point.x, point.y); - if (index == -1 && (view.x + view.width <= drag.x)) { - index = view.count - 1; - } - if (drop.keys.indexOf("decoButtonAdd") != -1) { - view.model.add(index, drag.source.type); - } else if (drop.keys.indexOf("decoButtonLeft") != -1) { - if (view == leftButtonsView) { - // move in same view - if (index != drag.source.itemIndex) { - drag.source.buttonsModel.move(drag.source.itemIndex, index); - } - } else { - // move to right view - view.model.add(index, drag.source.type); - drag.source.buttonsModel.remove(drag.source.itemIndex); + if (!view) { + return; + } + var point = mapToItem(view, drag.x, drag.y); + var index = view.indexAt(point.x, point.y); + if (index == -1 && (view.x + view.width <= drag.x)) { + index = view.count - 1; + } + if (drop.keys.indexOf("decoButtonAdd") != -1) { + view.model.add(index, drag.source.type); + } else if (drop.keys.indexOf("decoButtonLeft") != -1) { + if (view == leftButtonsView) { + // move in same view + if (index != drag.source.itemIndex) { + drag.source.buttonsModel.move(drag.source.itemIndex, index); } - } else if (drop.keys.indexOf("decoButtonRight") != -1) { - if (view == rightButtonsView) { - // move in same view - if (index != drag.source.itemIndex) { - drag.source.buttonsModel.move(drag.source.itemIndex, index); - } - } else { - // move to right view - view.model.add(index, drag.source.type); - drag.source.buttonsModel.remove(drag.source.itemIndex); + } else { + // move to right view + view.model.add(index, drag.source.type); + drag.source.buttonsModel.remove(drag.source.itemIndex); + } + } else if (drop.keys.indexOf("decoButtonRight") != -1) { + if (view == rightButtonsView) { + // move in same view + if (index != drag.source.itemIndex) { + drag.source.buttonsModel.move(drag.source.itemIndex, index); } + } else { + // move to right view + view.model.add(index, drag.source.type); + drag.source.buttonsModel.remove(drag.source.itemIndex); } } } } } Text { id: iCannotBelieveIDoThis text: "gnarf" visible: false } GridView { id: availableGrid Layout.fillWidth: true model: availableButtons interactive: false cellWidth: iconLabel.implicitWidth cellHeight: units.iconSizes.small + iCannotBelieveIDoThis.implicitHeight + 4*units.smallSpacing height: Math.ceil(cellHeight * 2.5) - opacity: (leftButtonsView.dragging || rightButtonsView.dragging) ? 0.25 : 1.0 delegate: Item { id: availableDelegate width: availableGrid.cellWidth height: availableGrid.cellHeight + opacity: (leftButtonsView.dragging || rightButtonsView.dragging) ? 0.25 : 1.0 KDecoration.Button { id: availableButton anchors.centerIn: Drag.active ? undefined : parent bridge: bridgeItem.bridge settings: settingsItem type: model["button"] width: units.iconSizes.small height: units.iconSizes.small Drag.keys: [ "decoButtonAdd" ] Drag.active: dragArea.drag.active } Label { id: iconLabel text: model["display"] horizontalAlignment: Text.AlignHCenter anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right elide: Text.ElideRight wrapMode: Text.NoWrap } MouseArea { id: dragArea anchors.fill: parent drag.target: availableButton cursorShape: Qt.PointingHandCursor onReleased: { if (availableButton.Drag.target) { availableButton.Drag.drop(); } else { availableButton.Drag.cancel(); } } } } + DropArea { + anchors.fill: parent + keys: [ "decoButtonRemove" ] + onEntered: { + drag.accept(); + } + onDropped: { + drag.source.buttonsModel.remove(drag.source.itemIndex); + } + ColumnLayout { + anchors.centerIn: parent + visible: leftButtonsView.dragging || rightButtonsView.dragging + Label { + text: i18n("Drop here to remove button") + font.bold: true + } + KQuickControlsAddons.QIconItem { + id: icon + width: 64 + height: 64 + icon: "list-remove" + Layout.alignment: Qt.AlignHCenter + } + Item { + Layout.fillHeight: true + } + } + } } Text { id: dragHint visible: !(leftButtonsView.dragging || rightButtonsView.dragging || availableGrid.dragging) Layout.fillWidth: true color: backgroundColor; opacity: 0.66 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignTop text: i18n("Drag buttons between here and the titlebar") } - DropArea { - anchors.fill: availableGrid - keys: [ "decoButtonRemove" ] - onEntered: { - drag.accept(); - } - onDropped: { - drag.source.buttonsModel.remove(drag.source.itemIndex); - } - ColumnLayout { - anchors.centerIn: parent - visible: leftButtonsView.dragging || rightButtonsView.dragging - Label { - text: i18n("Drop here to remove button") - font.bold: true - } - KQuickControlsAddons.QIconItem { - id: icon - width: 64 - height: 64 - icon: "list-remove" - Layout.alignment: Qt.AlignHCenter - } - Item { - Layout.fillHeight: true - } - } - } } } } diff --git a/kcmkwin/kwindecoration/qml/Previews.qml b/kcmkwin/kwindecoration/qml/Previews.qml index 700e72656..091692001 100644 --- a/kcmkwin/kwindecoration/qml/Previews.qml +++ b/kcmkwin/kwindecoration/qml/Previews.qml @@ -1,152 +1,151 @@ /* * Copyright 2014 Martin Gräßlin * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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 General Public License * along with this program. If not, see . */ import QtQuick 2.1 import QtQuick.Controls 1.2 import QtQuick.Layouts 1.1 import org.kde.kwin.private.kdecoration 1.0 as KDecoration -import org.kde.plasma.core 2.0 as PlasmaCore; ScrollView { objectName: "themeList" frameVisible: true GridView { id: gridView objectName: "listView" model: decorationsModel cellWidth: 20 * units.gridUnit cellHeight: cellWidth / 1.6 onContentHeightChanged: { if (gridView.currentIndex == -1) { gridView.currentIndex = savedIndex; } gridView.positionViewAtIndex(gridView.currentIndex, GridView.Visible); } Rectangle { z: -1 anchors.fill: parent color: baseColor } highlight: Rectangle { color: highlightColor opacity: 0.6 } highlightMoveDuration: units.longDuration boundsBehavior: Flickable.StopAtBounds property int borderSizesIndex: 3 // 3 == Normal delegate: Item { width: gridView.cellWidth height: gridView.cellHeight KDecoration.Bridge { id: bridgeItem plugin: model["plugin"] theme: model["theme"] } KDecoration.Settings { id: settingsItem bridge: bridgeItem.bridge borderSizesIndex: gridView.borderSizesIndex } MouseArea { hoverEnabled: false anchors.fill: parent onClicked: { gridView.currentIndex = index; } } ColumnLayout { id: decorationPreviews property string themeName: model["display"] anchors.fill: parent Item { KDecoration.Decoration { id: inactivePreview bridge: bridgeItem.bridge settings: settingsItem anchors.fill: parent Component.onCompleted: { client.caption = decorationPreviews.themeName client.active = false; anchors.leftMargin = Qt.binding(function() { return 40 - (inactivePreview.shadow ? inactivePreview.shadow.paddingLeft : 0);}); anchors.rightMargin = Qt.binding(function() { return 10 - (inactivePreview.shadow ? inactivePreview.shadow.paddingRight : 0);}); anchors.topMargin = Qt.binding(function() { return 10 - (inactivePreview.shadow ? inactivePreview.shadow.paddingTop : 0);}); anchors.bottomMargin = Qt.binding(function() { return 40 - (inactivePreview.shadow ? inactivePreview.shadow.paddingBottom : 0);}); } } KDecoration.Decoration { id: activePreview bridge: bridgeItem.bridge settings: settingsItem anchors.fill: parent Component.onCompleted: { client.caption = decorationPreviews.themeName client.active = true; anchors.leftMargin = Qt.binding(function() { return 10 - (activePreview.shadow ? activePreview.shadow.paddingLeft : 0);}); anchors.rightMargin = Qt.binding(function() { return 40 - (activePreview.shadow ? activePreview.shadow.paddingRight : 0);}); anchors.topMargin = Qt.binding(function() { return 40 - (activePreview.shadow ? activePreview.shadow.paddingTop : 0);}); anchors.bottomMargin = Qt.binding(function() { return 10 - (activePreview.shadow ? activePreview.shadow.paddingBottom : 0);}); } } MouseArea { hoverEnabled: false anchors.fill: parent onClicked: { gridView.currentIndex = index; } } Layout.fillWidth: true Layout.fillHeight: true /* Create an invisible rectangle that's the same size as the inner content rect of the foreground window preview so that we can center the button within it. We have to center rather than using anchors because the button width varies with different localizations */ Item { anchors { left: parent.left leftMargin: 10 right: parent.right rightMargin: 40 top: parent.top topMargin: 68 bottom: parent.bottom bottomMargin: 10 } Button { id: configureButton anchors { horizontalCenter: parent.horizontalCenter verticalCenter: parent.verticalCenter } enabled: model["configureable"] iconName: "configure" text: i18n("Configure %1...", decorationPreviews.themeName) onClicked: { gridView.currentIndex = index bridgeItem.bridge.configure() } } } } } } } Layout.preferredHeight: 20 * units.gridUnit } diff --git a/kcmkwin/kwindecoration/qml/main.qml b/kcmkwin/kwindecoration/qml/main.qml index 2a8653b53..75a754ea4 100644 --- a/kcmkwin/kwindecoration/qml/main.qml +++ b/kcmkwin/kwindecoration/qml/main.qml @@ -1,37 +1,37 @@ /* * Copyright 2014 Martin Gräßlin * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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 General Public License * along with this program. If not, see . */ import QtQuick 2.1 import QtQuick.Controls 1.2 import QtQuick.Layouts 1.1 Rectangle { color: backgroundColor ColumnLayout { anchors.fill: parent Previews { Layout.fillWidth: true Layout.fillHeight: true } Buttons { - anchors.top: parent.top + Layout.alignment: Qt.AlignTop Layout.fillWidth: true } } }