Commit 7990a08c authored by Marco Martin's avatar Marco Martin
Browse files

new top panel: shutdown icon and clock applet

parent 1e417bb7
/*
Copyright 2019 MArco MArtni <mart@kde.org>
Copyright 2013-2017 Jan Grulich <jgrulich@redhat.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 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 6 of version 3 of the license.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.2
import QtQuick.Layouts 1.4
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents
PlasmaComponents.Button {
id: button
Layout.fillHeight: true
Layout.preferredWidth: height
leftPadding: 0
topPadding: 0
rightPadding: 0
bottomPadding: 0
background: PlasmaCore.FrameSvgItem {
id: frame
imagePath: "widgets/viewitem"
prefix: "hover"
visible: button.activeFocus
}
contentItem: PlasmaCore.IconItem {
source: "system-shutdown"
colorGroup: PlasmaCore.ColorScope.colorGroup
Layout.fillHeight: true
Layout.preferredWidth: height
PlasmaCore.DataSource {
id: dataEngine
engine: "powermanagement"
connectedSources: ["PowerDevil"]
}
}
onClicked: {
var service = dataEngine.serviceForSource("PowerDevil");
var operation = service.operationDescription("requestShutDown");
service.startOperationCall(operation);
}
Keys.onReturnPressed: {
clicked();
}
}
......@@ -32,12 +32,14 @@ import "delegates" as Delegates
import "views" as Views
FocusScope {
anchors.fill: parent
anchors {
fill: parent
margins: units.smallSpacing
}
ColumnLayout {
id: launcherHomeColumn
width: parent.width
height: parent.height
anchors.fill: parent
spacing: 1
property Component activeHighlightItem: PlasmaComponents.Highlight{}
property Component disabledHighlightItem: Item {}
......@@ -58,7 +60,7 @@ FocusScope {
}
navigationUp: gridView3
navigationUp: shutdownButton
navigationDown: gridView2
}
......@@ -98,7 +100,7 @@ FocusScope {
}
navigationUp: gridView2
navigationDown: gridView
navigationDown: null
}
Component.onCompleted: {
......
......@@ -29,7 +29,7 @@ import org.kde.kquickcontrolsaddons 2.0
import org.kde.private.biglauncher 1.0 as Launcher
import org.kde.kirigami 2.5 as Kirigami
PlasmaCore.ColorScope {
FocusScope {
id: root
readonly property int reservedSpaceForLabel: metrics.height
......@@ -83,98 +83,5 @@ PlasmaCore.ColorScope {
visible: false
}
ColumnLayout {
anchors.fill: parent
RowLayout {
id: topButtonBar
Layout.fillWidth: true
Layout.preferredHeight: Kirigami.Units.iconSizes.medium
PlasmaComponents3.Button {
text: "Home"
Layout.fillWidth: true
focus: false
Layout.preferredHeight: Kirigami.Units.iconSizes.medium
flat: topBarLoader.currentIndex !== 0 ? 1 : 0
onClicked: {
topBarLoader.currentIndex = 0
root.activateAppView()
}
Rectangle {
id: homeBtnHighLighter
visible: topButtonBar.focus && topBarLoader.currentIndex == 0 ? 1 : 0
color: Kirigami.Theme.linkColor
height: Kirigami.Units.smallSpacing * 0.5
anchors.left: parent.left
anchors.leftMargin: Kirigami.Units.smallSpacing
anchors.right: parent.right
anchors.rightMargin: Kirigami.Units.smallSpacing
anchors.bottom: parent.bottom
anchors.bottomMargin: Kirigami.Units.smallSpacing
}
}
PlasmaComponents3.Button {
text: "Settings"
Layout.fillWidth: true
Layout.preferredHeight: Kirigami.Units.iconSizes.medium
focus: false
flat: topBarLoader.currentIndex !== 1 ? 1 : 0
onClicked: {
topBarLoader.currentIndex = 1
}
Rectangle {
id: settingsBtnHighLighter
visible: topButtonBar.focus && topBarLoader.currentIndex == 1 ? 1 : 0
color: Kirigami.Theme.linkColor
height: Kirigami.Units.smallSpacing * 0.5
anchors.left: parent.left
anchors.leftMargin: Kirigami.Units.smallSpacing
anchors.right: parent.right
anchors.rightMargin: Kirigami.Units.smallSpacing
anchors.bottom: parent.bottom
anchors.bottomMargin: Kirigami.Units.smallSpacing
}
}
Keys.onRightPressed: {
topBarLoader.currentIndex = 1
}
Keys.onLeftPressed: {
topBarLoader.currentIndex = 0
}
Keys.onDownPressed: {
if(topBarLoader.currentIndex == 0) {
root.activateAppView();
} else if (topBarLoader.currentIndex == 1) {
root.activateSettingsView();
}
}
}
StackLayout {
id: topBarLoader
Layout.fillWidth: true
Layout.preferredHeight: parent.height - (topButtonBar.height + Kirigami.Units.largeSpacing)
currentIndex: 0
clip: true
Item {
LauncherHome{}
}
Item {
PlaceHolderPage{}
}
Component.onCompleted: {
root.activateAppView();
}
}
}
LauncherHome {}
}
......@@ -27,8 +27,9 @@ import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.kirigami 2.5 as Kirigami
Item {
Layout.preferredWidth: appslabel.contentWidth + Kirigami.Units.largeSpacing * 3
Layout.preferredHeight: Kirigami.Units.iconSizes.small
implicitWidth: appslabel.implicitWidth
implicitHeight: appslabel.implicitHeight
property alias text: appslabel.text
PlasmaExtras.Heading {
......
......@@ -28,7 +28,7 @@ import org.kde.kirigami 2.5 as Kirigami
ListView {
id: view
//TODO:dynamic
property int columns: Math.max(3, Math.floor(width / (units.gridUnit * 20)))
property int columns: Math.max(3, Math.floor(width / (units.gridUnit * 25)))
readonly property int cellWidth: width / columns
......@@ -55,7 +55,7 @@ ListView {
id: rotation
axis { x: 0; y: 1; z: 0 }
angle: 0
property real targetAngle: 45
property real targetAngle: 30
Behavior on angle {
SmoothedAnimation {
duration: Kirigami.Units.longDuration * 10
......@@ -66,7 +66,7 @@ ListView {
Timer {
id: rotateTimeOut
interval: 100
interval: 25
}
Timer {
id: rotateTimer
......@@ -86,9 +86,9 @@ ListView {
property real oldContentX
onContentXChanged: {
if (oldContentX < contentX) {
rotation.targetAngle = 45;
rotation.targetAngle = 30;
} else {
rotation.targetAngle = -45;
rotation.targetAngle = -30;
}
PlasmaComponents.ScrollBar.horizontal.opacity = 1;
if (!rotateTimeOut.running) {
......
......@@ -21,8 +21,9 @@ import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.3 as Controls
import QtQuick.Window 2.3
import QtGraphicalEffects 1.12
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kquickcontrolsaddons 2.0
import org.kde.kirigami 2.5 as Kirigami
import Mycroft 1.0 as Mycroft
......@@ -38,23 +39,50 @@ Item {
property Item wallpaper
Containment.onAppletAdded: {
addApplet(applet, x, y);
}
function addApplet(applet, x, y) {
var container = appletContainerComponent.createObject(appletsLayout)
print("Applet added: " + applet + " " + applet.title)
//container.width = units.iconSizes.medium
container.height = appletsLayout.height
applet.parent = container;
container.applet = applet;
applet.anchors.fill = container;
applet.visible = true;
applet.expanded = false;
}
Component {
id: appletContainerComponent
Item {
property Item applet
visible: applet && applet.status !== PlasmaCore.Types.HiddenStatus && applet.status !== PlasmaCore.Types.PassiveStatus
Layout.fillHeight: true
Layout.minimumWidth: Math.max(applet.implicitWidth, applet.Layout.preferredWidth, applet.Layout.minimumWidth)
Layout.maximumWidth: Layout.minimumWidth
}
}
MycroftWindow {
id: mycroftWindow
}
Rectangle {
PlasmaCore.ColorScope {
id: topBar
anchors {
left: parent.left
top: parent.top
right: parent.right
}
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
height: units.iconSizes.medium + units.smallSpacing * 2
opacity: !mycroftWindow.visible
gradient: Gradient {
GradientStop { position: 0.0; color: Qt.rgba(0, 0, 0, 0.6) }
GradientStop { position: 1; color: "transparent" }
}
Behavior on opacity {
OpacityAnimator {
duration: units.longDuration
......@@ -62,6 +90,16 @@ Item {
}
}
RowLayout {
id: appletsLayout
anchors {
left: parent.left
top: parent.top
bottom: parent.bottom
margins: units.smallSpacing
}
}
RowLayout {
anchors {
right: parent.right
......@@ -72,15 +110,29 @@ Item {
Indicators.Wifi {
Layout.fillHeight: true
implicitWidth: height
anchors.centerIn: mycroftIndicator
}
Indicators.Shutdown {
id: shutdownButton
KeyNavigation.down: launcher
KeyNavigation.right: launcher
KeyNavigation.tab: launcher
KeyNavigation.backtab: launcher
}
}
layer.enabled: true
layer.effect: DropShadow {
verticalOffset: 2
color: Qt.rgba(0, 0, 0, 0.6)
radius: 8.0
samples: 17
}
}
LauncherMenu {
id: launcher
width: parent.width
height: parent.height
height: parent.height - topBar.height
states: [
......@@ -89,7 +141,7 @@ Item {
PropertyChanges {
target: launcher
opacity: 1
y: 0
y: topBar.height
}
},
State {
......
......@@ -2,6 +2,7 @@
var desktopsArray = desktopsForActivity(currentActivity());
for (var j = 0; j < desktopsArray.length; j++) {
var desk = desktopsArray[j];
desk.addWidget("org.kde.plasma.digitalclock");
desk.wallpaperPlugin = "org.kde.slideshow";
desk.currentConfigGroup = new Array("Wallpaper","org.kde.slideshow","General");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment