/* * Copyright (C) 2021 CutefishOS Team. * * Author: revenmartin * * 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 3 of the License, or * any later version. * * 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.4 import QtQuick.Controls 2.4 import QtQuick.Layouts 1.3 import QtGraphicalEffects 1.0 import FishUI 1.0 as FishUI Item { implicitWidth: 230 property int itemRadiusV: 8 property alias view: listView property alias model: listModel property alias currentIndex: listView.currentIndex Rectangle { anchors.fill: parent color: FishUI.Theme.darkMode ? "#333333" : "#EBECF2" opacity: rootWindow.compositing ? 0.7 : 1.0 Behavior on color { ColorAnimation { duration: 250 easing.type: Easing.Linear } } } ListModel { id: listModel ListElement { title: qsTr("WLAN") name: "network" page: "qrc:/qml/WLAN/Main.qml" iconSource: "wlan.svg" iconColor: "#0067FF" category: qsTr("Network and connection") } ListElement { title: qsTr("Ethernet") name: "ethernet" page: "qrc:/qml/Wired/Main.qml" iconSource: "network.svg" iconColor: "#0067FF" category: qsTr("Network and connection") } // ListElement { // title: qsTr("Hotspot") // name: "hotspot" // page: "qrc:/qml/Hotspot/Main.qml" // iconSource: "hotspot.svg" // iconColor: "#0067FF" // category: qsTr("Network and connection") // } // ListElement { // title: qsTr("Bluetooth") // name: "bluetooth" // page: "qrc:/qml/BluetoothPage.qml" // iconSource: "bluetooth.svg" // } ListElement { title: qsTr("Display") name: "display" page: "qrc:/qml/Display/Main.qml" iconSource: "display.svg" iconColor: "#0087ED" category: qsTr("Display and appearance") } ListElement { title: qsTr("Appearance") name: "appearance" page: "qrc:/qml/Appearance/Main.qml" iconSource: "appearance.svg" iconColor: "#03B4CB" category: qsTr("Display and appearance") } ListElement { title: qsTr("Fonts") name: "fonts" page: "qrc:/qml/Fonts/Main.qml" iconSource: "fonts.svg" iconColor: "#FFBF36" category: qsTr("Display and appearance") } ListElement { title: qsTr("Background") name: "background" page: "qrc:/qml/Wallpaper/Main.qml" iconSource: "wallpaper.svg" iconColor: "#34B4A7" category: qsTr("Display and appearance") } ListElement { title: qsTr("Dock") name: "dock" page: "qrc:/qml/Dock/Main.qml" iconSource: "dock.svg" iconColor: "#8585FC" category: qsTr("Display and appearance") } ListElement { title: qsTr("User") name: "accounts" page: "qrc:/qml/User/Main.qml" iconSource: "accounts.svg" iconColor: "#DA7C43" category: qsTr("System") } // ListElement { // title: qsTr("Application") // name: "application" // page: "qrc:/qml/Application/Main.qml" // iconSource: "accounts.svg" // iconColor: "#DA7C43" // category: qsTr("System") // } ListElement { title: qsTr("Language") name: "language" page: "qrc:/qml/LanguagePage.qml" iconSource: "language.svg" iconColor: "#20A7FF" category: qsTr("System") } ListElement { title: qsTr("Battery") name: "battery" page: "qrc:/qml/Battery/Main.qml" iconSource: "battery.svg" iconColor: "#2EC347" category: qsTr("System") } // ListElement { // title: qsTr("Power") // name: "power" // page: "qrc:/qml/Power/Main.qml" // iconSource: "power.svg" // } ListElement { title: qsTr("About") name: "about" page: "qrc:/qml/About/Main.qml" iconSource: "about.svg" iconColor: "#24A7FD" category: qsTr("System") } } ColumnLayout { anchors.fill: parent anchors.margins: 0 spacing: 0 Label { text: rootWindow.title Layout.preferredHeight: rootWindow.header.height leftPadding: FishUI.Units.largeSpacing + FishUI.Units.smallSpacing topPadding: FishUI.Units.largeSpacing bottomPadding: 0 font.pointSize: 15 } ListView { id: listView Layout.fillHeight: true Layout.fillWidth: true clip: true model: listModel spacing: FishUI.Units.smallSpacing leftMargin: FishUI.Units.largeSpacing rightMargin: FishUI.Units.largeSpacing topMargin: 0 ScrollBar.vertical: ScrollBar {} highlightFollowsCurrentItem: true highlightMoveDuration: 0 highlightResizeDuration : 0 highlight: Rectangle { radius: FishUI.Theme.mediumRadius color: Qt.rgba(FishUI.Theme.textColor.r, FishUI.Theme.textColor.g, FishUI.Theme.textColor.b, 0.1) smooth: true } section.property: "category" section.delegate: Item { width: ListView.view.width - ListView.view.leftMargin - ListView.view.rightMargin height: FishUI.Units.fontMetrics.height + FishUI.Units.largeSpacing + FishUI.Units.smallSpacing Text { anchors.fill: parent anchors.leftMargin: FishUI.Units.smallSpacing anchors.rightMargin: FishUI.Units.largeSpacing anchors.topMargin: FishUI.Units.largeSpacing anchors.bottomMargin: FishUI.Units.smallSpacing color: FishUI.Theme.disabledTextColor font.pointSize: 8 text: section } } FishUI.WheelHandler { target: listView } delegate: Item { id: item width: ListView.view.width - ListView.view.leftMargin - ListView.view.rightMargin height: 35 property bool isCurrent: listView.currentIndex === index Rectangle { anchors.fill: parent MouseArea { id: mouseArea anchors.fill: parent hoverEnabled: true acceptedButtons: Qt.LeftButton onClicked: listView.currentIndex = index } radius: FishUI.Theme.mediumRadius color: mouseArea.pressed ? Qt.rgba(FishUI.Theme.textColor.r, FishUI.Theme.textColor.g, FishUI.Theme.textColor.b, FishUI.Theme.darkMode ? 0.05 : 0.1) : mouseArea.containsMouse || isCurrent ? Qt.rgba(FishUI.Theme.textColor.r, FishUI.Theme.textColor.g, FishUI.Theme.textColor.b, FishUI.Theme.darkMode ? 0.1 : 0.05) : "transparent" smooth: true } RowLayout { anchors.fill: parent anchors.leftMargin: FishUI.Units.smallSpacing spacing: FishUI.Units.smallSpacing Rectangle { id: iconRect width: 24 height: 24 Layout.alignment: Qt.AlignVCenter radius: 6 color: model.iconColor gradient: Gradient { GradientStop { position: 0.0; color: Qt.lighter(model.iconColor, 1.15) } GradientStop { position: 1.0; color: model.iconColor } } Image { id: icon anchors.centerIn: parent width: 16 height: width source: "qrc:/images/sidebar/dark/" + model.iconSource sourceSize: Qt.size(22, 22) Layout.alignment: Qt.AlignVCenter antialiasing: true smooth: true } } Label { id: itemTitle text: model.title color: FishUI.Theme.darkMode ? FishUI.Theme.textColor : "#363636" font.pointSize: 8 } Item { Layout.fillWidth: true } } } } } }