2024-08-10 12:58:21 -05:00

226 lines
5.7 KiB
QML

/*
* Copyright (c) 2020-2023 Alex Spataru <https://github.com/alex-spataru>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import QtCore
import QtQuick
import QtQuick.Window
import QtQuick.Layouts
import QtQuick.Controls
import "../ProjectEditor"
import "../Widgets" as Widgets
Window {
id: root
//
// Window options
//
minimumWidth: 910
minimumHeight: 720
title: qsTr("Project Editor - %1").arg(Cpp_Project_Model.jsonFileName)
//
// Ensure that current JSON file is shown
//
Component.onCompleted: Cpp_Project_Model.openJsonFile(Cpp_JSON_Generator.jsonMapFilepath)
//
// Ask user to save changes before closing the window
//
onClosing: (close) => close.accepted = Cpp_Project_Model.askSave()
//
// Dummy string to increase width of buttons
//
readonly property string _btSpacer: " "
//
// Save window size
//
Settings {
category: "ProjectEditor"
property alias windowX: root.x
property alias windowY: root.y
property alias windowWidth: root.width
property alias windowHeight: root.height
}
//
// Use page item to set application palette
//
Page {
clip: true
anchors.fill: parent
anchors.margins: root.shadowMargin
anchors.topMargin: titlebar.height + root.shadowMargin
palette.alternateBase: Cpp_ThemeManager.base
palette.base: Cpp_ThemeManager.base
palette.brightText: Cpp_ThemeManager.brightText
palette.button: Cpp_ThemeManager.button
palette.buttonText: Cpp_ThemeManager.buttonText
palette.highlight: Cpp_ThemeManager.highlight
palette.highlightedText: Cpp_ThemeManager.highlightedText
palette.link: Cpp_ThemeManager.link
palette.placeholderText: Cpp_ThemeManager.placeholderText
palette.text: Cpp_ThemeManager.text
palette.toolTipBase: Cpp_ThemeManager.tooltipBase
palette.toolTipText: Cpp_ThemeManager.tooltipText
palette.window: Cpp_ThemeManager.window
palette.windowText: Cpp_ThemeManager.windowText
background: Rectangle {
radius: root.radius
color: Cpp_ThemeManager.windowBackground
}
//
// Shadows
//
Widgets.Shadow {
anchors.fill: header
} Widgets.Shadow {
anchors.fill: footer
anchors.bottomMargin: footer.height / 2
}
//
// Header (project properties)
//
Header {
id: header
anchors {
margins: 0
top: parent.top
left: parent.left
right: parent.right
}
}
//
// Footer background
//
Footer {
id: footer
radius: root.radius
onCloseWindow: root.close()
onScrollToBottom: groupEditor.selectLastGroup()
anchors {
margins: 0
left: parent.left
right: parent.right
bottom: parent.bottom
}
}
//
// Window controls
//
RowLayout {
clip: true
anchors.fill: parent
spacing: app.spacing
anchors.topMargin: header.height
anchors.bottomMargin: footer.height
//
// Horizontal spacer
//
Item {
Layout.fillHeight: true
Layout.minimumWidth: app.spacing
Layout.maximumWidth: app.spacing
}
//
// JSON structure tree
//
/*TreeView {
id: jsonTree
Layout.fillHeight: true
Layout.minimumWidth: 240
Layout.maximumWidth: 240
Layout.topMargin: app.spacing * 2
Layout.bottomMargin: app.spacing * 2
visible: Cpp_Project_Model.groupCount !== 0
}*/
//
// Group editor
//
GroupEditor {
id: groupEditor
Layout.fillWidth: true
Layout.fillHeight: true
visible: Cpp_Project_Model.groupCount !== 0
}
//
// Empty project text & icon
//
Item {
Layout.fillWidth: true
Layout.fillHeight: true
visible: Cpp_Project_Model.groupCount === 0
ColumnLayout {
spacing: app.spacing
anchors.centerIn: parent
Widgets.Icon {
width: 128
height: 128
color: Cpp_ThemeManager.text
Layout.alignment: Qt.AlignHCenter
source: "qrc:/icons/developer-board.svg"
}
Label {
font.bold: true
font.pixelSize: 24
Layout.alignment: Qt.AlignHCenter
text: qsTr("Start something awesome")
}
Label {
opacity: 0.8
font.pixelSize: 18
Layout.alignment: Qt.AlignHCenter
text: qsTr("Click on the \"Add group\" button to begin")
}
}
}
//
// Horizontal spacer
//
Item {
Layout.fillHeight: true
Layout.minimumWidth: app.spacing
Layout.maximumWidth: app.spacing
}
}
}
}