This commit is contained in:
Sam Hadow 2024-03-13 18:46:28 +01:00
parent 7d0d0c112b
commit 8cdb49bd83

View File

@ -19,6 +19,9 @@
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
// module "org.kde.plasma.components" version 2.0 is not installed
import QtQuick 2.3 import QtQuick 2.3
import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.plasmoid 2.0
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
@ -26,7 +29,7 @@ import org.kde.plasma.plasmoid as PlasmaCore
import org.kde.ksvg as KSvg import org.kde.ksvg as KSvg
import org.kde.plasma.plasma5support as Plasma5Support import org.kde.plasma.plasma5support as Plasma5Support
import org.kde.kirigami 2.20 as Kirigami import org.kde.kirigami 2.20 as Kirigami
import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.components as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.kquickcontrolsaddons 2.0 import org.kde.kquickcontrolsaddons 2.0
@ -125,181 +128,274 @@ Item {
id: mainArea id: mainArea
anchors.topMargin: mainTabGroup.state == "top" ? Kirigami.Units.smallSpacing : 0 anchors.topMargin: mainTabGroup.state == "top" ? Kirigami.Units.smallSpacing : 0
Kirigami.Page { PlasmaComponents.TabGroup {
id: mainPage id: mainTabGroup
currentTab: favoritesPage
// Set anchors anchors {
anchors.fill: parent fill: parent
// Create a row for the tab buttons
Kirigami.PageRow {
id: tabRow
// Set row orientation based on plasmoid location
orientation: {
switch (plasmoid.location) {
case PlasmaCore.Types.LeftEdge:
case PlasmaCore.Types.RightEdge:
return Qt.Horizontal
default:
return Qt.Vertical
}
}
// Add tab buttons
PlasmaComponents.Button {
text: i18n("Favorites")
onClicked: mainPage.currentIndex = 0
}
PlasmaComponents.Button {
text: i18n("Applications")
onClicked: mainPage.currentIndex = 1
}
PlasmaComponents.Button {
text: i18n("Computer")
onClicked: mainPage.currentIndex = 2
}
PlasmaComponents.Button {
text: i18n("Recently Used")
onClicked: mainPage.currentIndex = 3
}
PlasmaComponents.Button {
text: i18n("Often Used")
onClicked: mainPage.currentIndex = 4
}
PlasmaComponents.Button {
text: i18n("Leave")
onClicked: mainPage.currentIndex = 5
}
PlasmaComponents.Button {
text: i18n("Search")
onClicked: root.state = "Search"
}
} }
// Add pages //pages
Kirigami.Page { FavoritesView {
id: favoritesPage id: favoritesPage
anchors.fill: parent
visible: mainPage.currentIndex === 0
// Add contents of the Favorites view here
} }
Kirigami.Page { PlasmaExtras.ConditionalLoader {
id: applicationsPage id: applicationsPage
anchors.fill: parent when: mainTabGroup.currentTab == applicationsPage
visible: mainPage.currentIndex === 1 source: Qt.resolvedUrl("ApplicationsView.qml")
// Add contents of the Applications view here
} }
Kirigami.Page { PlasmaExtras.ConditionalLoader {
id: computerPage id: systemPage
anchors.fill: parent when: mainTabGroup.currentTab == systemPage
visible: mainPage.currentIndex === 2 source: Qt.resolvedUrl("ComputerView.qml")
// Add contents of the Computer view here
} }
Kirigami.Page { PlasmaExtras.ConditionalLoader {
id: recentlyUsedPage id: recentlyUsedPage
anchors.fill: parent when: mainTabGroup.currentTab == recentlyUsedPage
visible: mainPage.currentIndex === 3 source: Qt.resolvedUrl("RecentlyUsedView.qml")
// Add contents of the Recently Used view here
} }
Kirigami.Page { PlasmaExtras.ConditionalLoader {
id: oftenUsedPage id: oftenUsedPage
anchors.fill: parent when: mainTabGroup.currentTab == oftenUsedPage
visible: mainPage.currentIndex === 4 source: Qt.resolvedUrl("OftenUsedView.qml")
// Add contents of the Often Used view here
} }
Kirigami.Page { PlasmaExtras.ConditionalLoader {
id: leavePage id: leavePage
anchors.fill: parent when: mainTabGroup.currentTab == leavePage
visible: mainPage.currentIndex === 5 source: Qt.resolvedUrl("LeaveView.qml")
// Add contents of the Leave view here
} }
Kirigami.Page { PlasmaExtras.ConditionalLoader {
id: searchPage id: searchPage
anchors.fill: parent when: root.state == "Search"
visible: root.state === "Search" //when: mainTabGroup.currentTab == searchPage || root.state == "Search"
// Add contents of the Search view here source: Qt.resolvedUrl("SearchView.qml")
} }
// Handle the plasmoid location states state: {
switch (plasmoid.location) {
case PlasmaCore.Types.LeftEdge:
return LayoutMirroring.enabled ? "right" : "left";
case PlasmaCore.Types.TopEdge:
return "top";
case PlasmaCore.Types.RightEdge:
return LayoutMirroring.enabled ? "left" : "right";
case PlasmaCore.Types.BottomEdge:
default:
return "bottom";
}
}
states: [ states: [
State { State {
name: "left" name: "left"
PropertyChanges { AnchorChanges {
target: tabRow target: header
rotation: 0 anchors {
left: root.left
top: undefined
right: root.right
bottom: root.bottom
}
} }
PropertyChanges { PropertyChanges {
target: tabRow target: header
width: header.implicitWidth
location: PlasmaExtras.PlasmoidHeading.Location.Footer
}
AnchorChanges {
target: mainArea
anchors { anchors {
left: parent.left left: tabBar.right
top: parent.top top: root.top
bottom: parent.bottom right: root.right
bottom: header.top
}
}
PropertyChanges {
target: tabBar
width: (tabBar.opacity == 0) ? 0 : PlasmaCore.Units.gridUnit * 5
}
AnchorChanges {
target: tabBar
anchors {
left: root.left
top: root.top
right: undefined
bottom: header.top
}
}
PropertyChanges {
target:tabBarSeparator
width: tabBarSeparatorLine.elementSize("vertical-line").width
elementId: "vertical-line"
}
AnchorChanges {
target: tabBarSeparator
anchors {
left: tabBar.right
top: tabBar.top
bottom:tabBar.bottom
} }
} }
}, },
State { State {
name: "top" name: "top"
PropertyChanges { AnchorChanges {
target: tabRow target: header
rotation: -90 anchors {
left: root.left
top: undefined
right: root.right
bottom: root.bottom
}
} }
PropertyChanges { PropertyChanges {
target: tabRow target: header
height: header.implicitHeight
location: PlasmaExtras.PlasmoidHeading.Location.Footer
}
AnchorChanges {
target: mainArea
anchors { anchors {
top: parent.top left: root.left
left: parent.left top: tabBar.bottom
right: parent.right right: root.right
bottom: header.top
}
}
PropertyChanges {
target: tabBar
height: (tabBar.opacity == 0) ? 0 : PlasmaCore.Units.gridUnit * 5
}
AnchorChanges {
target: tabBar
anchors {
left: root.left
top: root.top
right: root.right
bottom: undefined
}
}
PropertyChanges {
target:tabBarSeparator
height: tabBarSeparatorLine.elementSize("horizontal-line").height
elementId: "horizontal-line"
}
AnchorChanges {
target: tabBarSeparator
anchors {
left: tabBar.left
right: tabBar.right
top: tabBar.bottom
} }
} }
}, },
State { State {
name: "right" name: "right"
PropertyChanges { AnchorChanges {
target: tabRow target: header
rotation: 180 anchors {
left: root.left
top: undefined
right: root.right
bottom: root.bottom
}
} }
PropertyChanges { PropertyChanges {
target: tabRow target: header
width: header.implicitWidth
location: PlasmaExtras.PlasmoidHeading.Location.Footer
}
AnchorChanges {
target: mainArea
anchors { anchors {
right: parent.right left: root.left
top: parent.top top: root.top
bottom: parent.bottom right: tabBar.left
bottom: header.top
}
}
PropertyChanges {
target: tabBar
width: (tabBar.opacity == 0) ? 0 : PlasmaCore.Units.gridUnit * 5
}
AnchorChanges {
target: tabBar
anchors {
left: undefined
top: root.top
right: root.right
bottom: header.top
}
}
PropertyChanges {
target:tabBarSeparator
width: tabBarSeparatorLine.elementSize("vertical-line").width
elementId: "vertical-line"
}
AnchorChanges {
target: tabBarSeparator
anchors {
right: tabBar.left
top: tabBar.top
bottom: tabBar.bottom
} }
} }
}, },
State { State {
name: "bottom" name: "bottom"
PropertyChanges { AnchorChanges {
target: tabRow target: header
rotation: 90 anchors {
left: root.left
top: root.top
right: root.right
bottom: undefined
}
} }
PropertyChanges { PropertyChanges {
target: tabRow target: header
height: header.implicitHeight
location: PlasmaExtras.PlasmoidHeading.Location.Header
}
AnchorChanges {
target: mainArea
anchors { anchors {
bottom: parent.bottom left: root.left
left: parent.left top: header.bottom
right: parent.right right: root.right
bottom: tabBar.top
}
}
PropertyChanges {
target: tabBar
height: (tabBar.opacity == 0) ? 0 : PlasmaCore.Units.gridUnit * 5
}
AnchorChanges {
target: tabBar
anchors {
left: root.left
top: undefined
right: root.right
bottom: root.bottom
}
}
PropertyChanges {
target:tabBarSeparator
height: tabBarSeparatorLine.elementSize("horizontal-line").height
elementId: "horizontal-line"
}
AnchorChanges {
target: tabBarSeparator
anchors {
bottom: tabBar.top
left: tabBar.left
right: tabBar.right
} }
} }
} }
] ]
} // mainTabGroup
// Set initial plasmoid state
state: {
switch (plasmoid.location) {
case PlasmaCore.Types.LeftEdge:
return "left"
case PlasmaCore.Types.TopEdge:
return "top"
case PlasmaCore.Types.RightEdge:
return "right"
case PlasmaCore.Types.BottomEdge:
default:
return "bottom"
}
}
}
} }
PlasmaComponents.TabBar { PlasmaComponents.TabBar {