Switch Settings tab based system
This commit is contained in:
parent
66f11eaa1f
commit
ffc4db9d0f
4 changed files with 223 additions and 99 deletions
77
Components/Tabs.qml
Normal file
77
Components/Tabs.qml
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import qs.Settings
|
||||
|
||||
Item {
|
||||
id: root
|
||||
property var tabsModel: [] // [{icon: "videocam", label: "Video"}, ...]
|
||||
property int currentIndex: 0
|
||||
signal tabChanged(int index)
|
||||
|
||||
RowLayout {
|
||||
id: tabBar
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
spacing: 16
|
||||
|
||||
Repeater {
|
||||
model: root.tabsModel
|
||||
delegate: Column {
|
||||
width: 56
|
||||
spacing: 2
|
||||
property bool hovered: false
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
if (root.currentIndex !== index) {
|
||||
root.currentIndex = index;
|
||||
root.tabChanged(index);
|
||||
}
|
||||
}
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
hoverEnabled: true
|
||||
onEntered: parent.hovered = true
|
||||
onExited: parent.hovered = false
|
||||
}
|
||||
|
||||
// Icon
|
||||
Text {
|
||||
text: modelData.icon
|
||||
font.family: "Material Icons"
|
||||
font.pixelSize: 22
|
||||
color: index === root.currentIndex
|
||||
? (Theme ? Theme.accentPrimary : "#7C3AED")
|
||||
: parent.hovered
|
||||
? (Theme ? Theme.accentPrimary : "#7C3AED")
|
||||
: (Theme ? Theme.textSecondary : "#444")
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
// Label
|
||||
Text {
|
||||
text: modelData.label
|
||||
font.pixelSize: 12
|
||||
font.bold: index === root.currentIndex
|
||||
color: index === root.currentIndex
|
||||
? (Theme ? Theme.accentPrimary : "#7C3AED")
|
||||
: parent.hovered
|
||||
? (Theme ? Theme.accentPrimary : "#7C3AED")
|
||||
: (Theme ? Theme.textSecondary : "#444")
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
// Underline for active tab
|
||||
Rectangle {
|
||||
width: 24
|
||||
height: 2
|
||||
radius: 1
|
||||
color: index === root.currentIndex
|
||||
? (Theme ? Theme.accentPrimary : "#7C3AED")
|
||||
: "transparent"
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue