applets/activitybar: follow Plasma QML style

wilder-5.26
Fushan Wen 4 years ago
parent 3e769ff430
commit 0df153f30e
No known key found for this signature in database
GPG Key ID: 2E48D1487C91DCAA
  1. 15
      applets/activitybar/contents/ui/main.qml

@ -6,20 +6,24 @@
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents // PC3 Tabbar only has top and bottom tab positions, not left and right import org.kde.plasma.components 2.0 as PlasmaComponents // PC3 Tabbar only has top and bottom tab positions, not left and right
import org.kde.activities 0.1 as Activities import org.kde.activities 0.1 as Activities
Item { Item {
Layout.minimumWidth: tabBar.implicitWidth Layout.minimumWidth: tabBar.implicitWidth
Layout.minimumHeight: tabBar.implicitHeight Layout.minimumHeight: tabBar.implicitHeight
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
PlasmaComponents.TabBar { PlasmaComponents.TabBar {
id: tabBar id: tabBar
anchors.fill: parent anchors.fill: parent
tabPosition: { tabPosition: {
switch (Plasmoid.location) { switch (Plasmoid.location) {
case PlasmaCore.Types.LeftEdge: case PlasmaCore.Types.LeftEdge:
@ -40,9 +44,11 @@ Item {
} }
delegate: PlasmaComponents.TabButton { delegate: PlasmaComponents.TabButton {
id: tab id: tab
checked: model.current checked: model.current
text: model.name text: model.name
activeFocusOnTab: true activeFocusOnTab: true
Keys.onPressed: { Keys.onPressed: {
switch (event.key) { switch (event.key) {
case Qt.Key_Space: case Qt.Key_Space:
@ -57,15 +63,18 @@ Item {
Accessible.name: model.name Accessible.name: model.name
Accessible.description: i18n("Switch to activity %1", model.name) Accessible.description: i18n("Switch to activity %1", model.name)
Accessible.role: Accessible.Button Accessible.role: Accessible.Button
onClicked: { onClicked: {
activityModel.setCurrentActivity(model.id, function() {}); activityModel.setCurrentActivity(model.id, function() {});
} }
Component.onCompleted: {
onCheckedChanged: {
if(model.current) { if(model.current) {
tabBar.currentTab = tab; tabBar.currentTab = tab;
} }
} }
onCheckedChanged: {
Component.onCompleted: {
if(model.current) { if(model.current) {
tabBar.currentTab = tab; tabBar.currentTab = tab;
} }

Loading…
Cancel
Save