212 lines
5.8 KiB
QML
Raw Normal View History

2021-09-17 01:41:50 -05:00
/*
* Serial Studio - https://serial-studio.github.io/
2021-09-17 01:41:50 -05:00
*
* Copyright (C) 2020-2025 Alex Spataru <https://aspatru.com>
2021-09-17 01:41:50 -05:00
*
* 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
* (at your option) any later version.
2021-09-17 01:41:50 -05:00
*
* 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 <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later OR Commercial
2021-09-17 01:41:50 -05:00
*/
2024-04-01 02:42:21 -05:00
import QtCore
2022-05-02 04:31:32 -05:00
import QtQuick
import QtQuick.Window
import QtQuick.Layouts
import QtQuick.Controls
2021-09-17 01:41:50 -05:00
2024-09-18 21:48:57 -05:00
import SerialStudio
import "Views" as Views
import "Sections" as Sections
2021-09-30 19:07:39 -05:00
import "../Widgets" as Widgets
2021-09-17 01:41:50 -05:00
2024-11-07 22:54:25 -05:00
Widgets.SmartWindow {
id: root
//
// Window options
//
2024-11-07 22:54:25 -05:00
category: "ProjectEditor"
minimumWidth: layout.implicitWidth + 32
minimumHeight: layout.implicitHeight + 32
title: qsTr("%1 - Project Editor").arg(Cpp_JSON_ProjectModel.title + (Cpp_JSON_ProjectModel.modified ? " (" + qsTr("modified") + ")" : ""))
2024-09-18 21:48:57 -05:00
//
// Ask user to save changes when closing the dialog
//
onClosing: (close) => close.accepted = Cpp_JSON_ProjectModel.askSave()
//
// Ensure that current JSON file is shown
//
2024-08-30 23:15:37 -05:00
onVisibleChanged: {
if (visible) {
Cpp_NativeWindow.addWindow(root)
Cpp_JSON_ProjectModel.openJsonFile(Cpp_JSON_FrameBuilder.jsonMapFilepath)
2024-08-30 23:15:37 -05:00
}
2024-08-30 23:15:37 -05:00
else
Cpp_NativeWindow.removeWindow(root)
}
//
// Load project file on start
//
Component.onCompleted: Cpp_JSON_ProjectModel.openJsonFile(Cpp_JSON_FrameBuilder.jsonMapFilepath)
//
// Dummy string to increase width of buttons
//
readonly property string _btSpacer: " "
2024-09-18 21:48:57 -05:00
//
// Shortcuts
//
Shortcut {
sequences: [StandardKey.Open]
onActivated: Cpp_JSON_ProjectModel.openJsonFile()
2024-09-18 21:48:57 -05:00
} Shortcut {
sequences: [StandardKey.New]
onActivated: Cpp_JSON_ProjectModel.newJsonFile()
2024-09-18 21:48:57 -05:00
} Shortcut {
sequences: [StandardKey.Save]
onActivated: Cpp_JSON_ProjectModel.saveJsonFile()
2024-09-18 21:48:57 -05:00
}
//
// Use page item to set application palette
//
Page {
anchors.fill: parent
2024-09-19 16:51:27 -05:00
palette.mid: Cpp_ThemeManager.colors["mid"]
palette.dark: Cpp_ThemeManager.colors["dark"]
2024-08-11 18:20:03 -05:00
palette.text: Cpp_ThemeManager.colors["text"]
2024-09-19 16:51:27 -05:00
palette.base: Cpp_ThemeManager.colors["base"]
palette.link: Cpp_ThemeManager.colors["link"]
palette.light: Cpp_ThemeManager.colors["light"]
2024-08-11 18:20:03 -05:00
palette.window: Cpp_ThemeManager.colors["window"]
2024-09-19 16:51:27 -05:00
palette.shadow: Cpp_ThemeManager.colors["shadow"]
palette.accent: Cpp_ThemeManager.colors["accent"]
palette.button: Cpp_ThemeManager.colors["button"]
palette.midlight: Cpp_ThemeManager.colors["midlight"]
palette.highlight: Cpp_ThemeManager.colors["highlight"]
palette.windowText: Cpp_ThemeManager.colors["window_text"]
palette.brightText: Cpp_ThemeManager.colors["bright_text"]
2024-08-11 18:20:03 -05:00
palette.buttonText: Cpp_ThemeManager.colors["button_text"]
2024-09-19 16:51:27 -05:00
palette.toolTipBase: Cpp_ThemeManager.colors["tooltip_base"]
palette.toolTipText: Cpp_ThemeManager.colors["tooltip_text"]
palette.linkVisited: Cpp_ThemeManager.colors["link_visited"]
palette.alternateBase: Cpp_ThemeManager.colors["alternate_base"]
2024-08-11 18:20:03 -05:00
palette.placeholderText: Cpp_ThemeManager.colors["placeholder_text"]
palette.highlightedText: Cpp_ThemeManager.colors["highlighted_text"]
2021-09-17 17:45:05 -05:00
ColumnLayout {
id: layout
spacing: 0
anchors.fill: parent
//
// Toolbar
//
2024-09-18 21:48:57 -05:00
Sections.Toolbar {
z: 2
Layout.fillWidth: true
}
//
2024-08-30 23:15:37 -05:00
// Main Layout
//
RowLayout {
2024-08-30 23:15:37 -05:00
spacing: 0
Layout.topMargin: -1
Layout.fillWidth: true
Layout.fillHeight: true
Layout.minimumHeight: 540
2024-08-30 23:15:37 -05:00
//
// Project structure
//
2024-09-18 21:48:57 -05:00
Sections.ProjectStructure {
id: projectStructure
Layout.fillHeight: true
2024-08-30 23:15:37 -05:00
Layout.minimumWidth: 256
}
2024-08-30 23:15:37 -05:00
//
// Panel border
//
Rectangle {
z: 2
2024-10-14 15:10:00 -05:00
implicitWidth: 1
2024-08-30 23:15:37 -05:00
Layout.fillHeight: true
color: Cpp_ThemeManager.colors["setup_border"]
Rectangle {
width: 1
height: 32
anchors.top: parent.top
anchors.left: parent.left
color: Cpp_ThemeManager.colors["pane_caption_border"]
}
}
2024-09-25 18:09:13 -05:00
//
// Action view
//
Views.ActionView {
Layout.fillWidth: true
Layout.fillHeight: true
visible: Cpp_JSON_ProjectModel.currentView === ProjectModel.ActionView
2024-09-25 18:09:13 -05:00
}
2024-08-30 23:15:37 -05:00
//
2024-09-18 21:48:57 -05:00
// Project setup
2024-08-30 23:15:37 -05:00
//
2024-09-18 21:48:57 -05:00
Views.ProjectView {
Layout.fillWidth: true
Layout.fillHeight: true
visible: Cpp_JSON_ProjectModel.currentView === ProjectModel.ProjectView
2024-08-30 23:15:37 -05:00
}
2024-08-30 23:15:37 -05:00
//
2024-09-18 21:48:57 -05:00
// Group view
2024-08-30 23:15:37 -05:00
//
2024-09-18 21:48:57 -05:00
Views.GroupView {
2024-08-30 23:15:37 -05:00
Layout.fillWidth: true
Layout.fillHeight: true
visible: Cpp_JSON_ProjectModel.currentView === ProjectModel.GroupView
}
2024-09-18 21:48:57 -05:00
//
// Dataset view
//
Views.DatasetView {
Layout.fillWidth: true
Layout.fillHeight: true
visible: Cpp_JSON_ProjectModel.currentView === ProjectModel.DatasetView
2024-09-18 21:48:57 -05:00
}
2024-09-18 21:48:57 -05:00
//
// Frame parser function
//
Views.FrameParserView {
Layout.fillWidth: true
Layout.fillHeight: true
visible: Cpp_JSON_ProjectModel.currentView === ProjectModel.FrameParserView
2021-10-05 05:03:00 -05:00
}
}
2021-09-17 01:41:50 -05:00
}
}
2021-09-17 01:41:50 -05:00
}