2023-06-29 13:38:10 -04:00
|
|
|
import QtCore
|
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Controls.Basic
|
|
|
|
import QtQuick.Layouts
|
2023-07-09 13:05:06 -04:00
|
|
|
import QtQuick.Dialogs
|
|
|
|
import Qt.labs.folderlistmodel
|
2023-06-29 13:38:10 -04:00
|
|
|
import mysettings
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: settingsStack
|
|
|
|
|
|
|
|
Theme {
|
|
|
|
id: theme
|
|
|
|
}
|
|
|
|
|
2023-07-01 11:34:21 -04:00
|
|
|
property alias title: titleLabel.text
|
2023-06-29 13:38:10 -04:00
|
|
|
property ListModel tabTitlesModel: ListModel { }
|
|
|
|
property list<Component> tabs: [ ]
|
|
|
|
|
2023-07-01 11:34:21 -04:00
|
|
|
Label {
|
|
|
|
id: titleLabel
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
color: theme.textColor
|
|
|
|
padding: 10
|
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: theme.fontSizeLarger
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.top: titleLabel.bottom
|
|
|
|
anchors.leftMargin: 15
|
|
|
|
anchors.rightMargin: 15
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
height: 1
|
|
|
|
color: theme.tabBorder
|
2023-06-30 09:50:09 -04:00
|
|
|
}
|
|
|
|
|
2023-06-29 13:38:10 -04:00
|
|
|
TabBar {
|
|
|
|
id: settingsTabBar
|
2023-07-01 11:34:21 -04:00
|
|
|
anchors.top: titleLabel.bottom
|
|
|
|
anchors.topMargin: 15
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
width: parent.width / 1.75
|
2023-06-29 13:38:10 -04:00
|
|
|
z: 200
|
2023-06-30 09:50:09 -04:00
|
|
|
visible: tabTitlesModel.count > 1
|
2023-07-01 11:34:21 -04:00
|
|
|
background: Rectangle {
|
|
|
|
color: "transparent"
|
|
|
|
}
|
2023-06-29 13:38:10 -04:00
|
|
|
Repeater {
|
|
|
|
model: settingsStack.tabTitlesModel
|
|
|
|
TabButton {
|
|
|
|
id: tabButton
|
2023-07-01 11:34:21 -04:00
|
|
|
padding: 10
|
2023-06-29 13:38:10 -04:00
|
|
|
contentItem: IconLabel {
|
|
|
|
color: theme.textColor
|
2023-08-07 13:54:13 -04:00
|
|
|
font.pixelSize: theme.fontSizeLarge
|
2023-06-29 13:38:10 -04:00
|
|
|
font.bold: tabButton.checked
|
|
|
|
text: model.title
|
|
|
|
}
|
|
|
|
background: Rectangle {
|
2023-07-01 11:34:21 -04:00
|
|
|
color: "transparent"
|
|
|
|
border.width: 1
|
|
|
|
border.color: tabButton.checked ? theme.tabBorder : "transparent"
|
|
|
|
radius: 10
|
2023-06-29 13:38:10 -04:00
|
|
|
}
|
|
|
|
Accessible.role: Accessible.Button
|
|
|
|
Accessible.name: model.title
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-01 11:34:21 -04:00
|
|
|
Rectangle {
|
|
|
|
id: dividerTabBar
|
|
|
|
visible: tabTitlesModel.count > 1
|
|
|
|
anchors.top: settingsTabBar.bottom
|
|
|
|
anchors.topMargin: 15
|
|
|
|
anchors.bottomMargin: 15
|
|
|
|
anchors.leftMargin: 15
|
|
|
|
anchors.rightMargin: 15
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
height: 1
|
|
|
|
color: theme.tabBorder
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
color: "transparent"
|
|
|
|
radius: 10
|
|
|
|
border.width: 1
|
|
|
|
border.color: theme.tabBorder
|
|
|
|
}
|
|
|
|
|
2023-07-09 13:05:06 -04:00
|
|
|
FolderDialog {
|
|
|
|
id: folderDialog
|
|
|
|
title: qsTr("Please choose a directory")
|
|
|
|
}
|
|
|
|
|
|
|
|
function openFolderDialog(currentFolder, onAccepted) {
|
|
|
|
folderDialog.currentFolder = currentFolder;
|
|
|
|
folderDialog.accepted.connect(function() { onAccepted(folderDialog.currentFolder); });
|
|
|
|
folderDialog.open();
|
|
|
|
}
|
|
|
|
|
2023-06-29 13:38:10 -04:00
|
|
|
StackLayout {
|
|
|
|
id: stackLayout
|
2023-07-01 11:34:21 -04:00
|
|
|
anchors.top: tabTitlesModel.count > 1 ? dividerTabBar.bottom : titleLabel.bottom
|
2023-06-29 13:38:10 -04:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
currentIndex: settingsTabBar.currentIndex
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
model: settingsStack.tabs
|
|
|
|
delegate: Loader {
|
|
|
|
id: loader
|
|
|
|
sourceComponent: model.modelData
|
|
|
|
onLoaded: {
|
|
|
|
settingsStack.tabTitlesModel.append({ "title": loader.item.title });
|
2023-07-09 13:05:06 -04:00
|
|
|
item.openFolderDialog = settingsStack.openFolderDialog;
|
2023-06-29 13:38:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|