369 lines
10 KiB
QML
Raw Normal View History

2021-02-17 14:36:39 -05:00
/*
* Copyright (c) 2020-2021 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.
*/
2021-09-30 19:07:39 -05:00
import QtQuick
import QtQuick.Controls
2021-02-17 14:36:39 -05:00
MenuBar {
id: root
2021-10-01 11:22:11 -05:00
visible: app.mainWindow.menubarEnabled
2021-02-17 14:36:39 -05:00
//
// Set background color + border
//
background: Rectangle {
2021-02-20 15:19:35 -05:00
gradient: Gradient {
GradientStop {
position: 0
2021-09-05 17:05:17 -05:00
color: Cpp_ThemeManager.menubarGradient1
2021-02-20 15:19:35 -05:00
}
GradientStop {
position: 1
2021-09-05 17:05:17 -05:00
color: Cpp_ThemeManager.menubarGradient2
2021-02-20 15:19:35 -05:00
}
}
2021-02-17 14:36:39 -05:00
}
2021-10-05 14:42:22 -05:00
//
// Palette
//
palette.text: Cpp_ThemeManager.menubarText
palette.base: Cpp_ThemeManager.menubarGradient2
palette.window: Cpp_ThemeManager.menubarGradient1
palette.highlightedText: Cpp_ThemeManager.highlightedText
2021-02-17 14:36:39 -05:00
//
// File menu
//
Menu {
title: qsTr("File")
DecentMenuItem {
sequence: "ctrl+j"
text: qsTr("Select JSON file") + "..."
onTriggered: Cpp_JSON_Generator.loadJsonMap()
}
MenuSeparator {}
Menu {
title: qsTr("CSV export")
DecentMenuItem {
checkable: true
text: qsTr("Enable CSV export")
checked: Cpp_CSV_Export.exportEnabled
onTriggered: Cpp_CSV_Export.exportEnabled = checked
}
DecentMenuItem {
sequence: "ctrl+shift+o"
enabled: Cpp_CSV_Export.isOpen
text: qsTr("Show CSV in explorer")
onTriggered: Cpp_CSV_Export.openCurrentCsv()
}
}
DecentMenuItem {
sequence: "ctrl+o"
text: qsTr("Replay CSV") + "..."
onTriggered: Cpp_CSV_Player.openFile()
2021-09-30 23:15:32 -05:00
enabled: Cpp_JSON_Generator.operationMode === 0
2021-02-17 14:36:39 -05:00
}
MenuSeparator {}
DecentMenuItem {
2021-10-01 05:51:39 -05:00
sequence: "ctrl+p"
2021-02-20 15:19:35 -05:00
text: qsTr("Print") + "..."
2021-02-17 14:36:39 -05:00
enabled: Cpp_IO_Console.saveAvailable
2021-02-20 15:19:35 -05:00
onTriggered: Cpp_IO_Console.print(app.monoFont)
2021-02-17 14:36:39 -05:00
}
DecentMenuItem {
2021-10-01 05:51:39 -05:00
sequence: "ctrl+s"
2021-02-17 14:36:39 -05:00
onClicked: Cpp_IO_Console.save()
enabled: Cpp_IO_Console.saveAvailable
text: qsTr("Export console output") + "..."
}
MenuSeparator {}
DecentMenuItem {
text: qsTr("Quit")
onTriggered: Qt.quit()
2021-10-01 05:51:39 -05:00
sequence: "ctrl+q"
2021-02-17 14:36:39 -05:00
}
}
//
// Edit menu
//
Menu {
title: qsTr("Edit")
DecentMenuItem {
text: qsTr("Copy")
2021-10-01 05:51:39 -05:00
sequence: "ctrl+c"
2021-10-01 11:22:11 -05:00
onTriggered: app.mainWindow.consoleCopy()
2021-02-17 14:36:39 -05:00
}
DecentMenuItem {
2021-10-01 05:51:39 -05:00
sequence: "ctrl+a"
2021-02-17 14:36:39 -05:00
text: qsTr("Select all") + "..."
2021-10-01 11:22:11 -05:00
onTriggered: app.mainWindow.consoleSelectAll()
2021-02-17 14:36:39 -05:00
}
DecentMenuItem {
2021-10-01 05:51:39 -05:00
sequence: "ctrl+d"
2021-10-01 11:22:11 -05:00
onTriggered: app.mainWindow.consoleClear()
2021-02-17 14:36:39 -05:00
text: qsTr("Clear console output")
}
MenuSeparator{}
Menu {
title: qsTr("Communication mode")
DecentMenuItem {
checkable: true
text: qsTr("Device sends JSON")
2021-09-30 23:15:32 -05:00
checked: Cpp_JSON_Generator.operationMode === 1
2021-02-17 14:36:39 -05:00
onTriggered: Cpp_JSON_Generator.operationMode = checked ? 1 : 0
}
DecentMenuItem {
checkable: true
text: qsTr("Load JSON from computer")
2021-09-30 23:15:32 -05:00
checked: Cpp_JSON_Generator.operationMode === 0
2021-02-17 14:36:39 -05:00
onTriggered: Cpp_JSON_Generator.operationMode = checked ? 0 : 1
}
}
}
//
// View menu
//
Menu {
title: qsTr("View")
DecentMenuItem {
checkable: true
sequence: "ctrl+t"
text: qsTr("Console")
2021-10-01 11:22:11 -05:00
checked: app.mainWindow.consoleVisible
onTriggered: app.mainWindow.showConsole()
2021-02-17 14:36:39 -05:00
onCheckedChanged: {
2021-10-01 11:22:11 -05:00
if (app.mainWindow.consoleVisible !== checked)
checked = app.mainWindow.consoleVisible
2021-02-17 14:36:39 -05:00
}
}
DecentMenuItem {
checkable: true
sequence: "ctrl+d"
text: qsTr("Dashboard")
2021-10-01 11:22:11 -05:00
checked: app.mainWindow.dashboardVisible
2021-09-25 00:03:27 -05:00
enabled: Cpp_UI_Dashboard.available
2021-10-01 11:22:11 -05:00
onTriggered: app.mainWindow.showDashboard()
2021-02-17 14:36:39 -05:00
onCheckedChanged: {
2021-10-01 11:22:11 -05:00
if (app.mainWindow.dashboardVisible !== checked)
checked = app.mainWindow.dashboardVisible
2021-02-17 14:36:39 -05:00
}
}
MenuSeparator {}
DecentMenuItem {
checkable: true
sequence: "ctrl+,"
2021-10-01 11:22:11 -05:00
checked: app.mainWindow.setupVisible
2021-02-17 14:36:39 -05:00
text: qsTr("Show setup pane")
2021-10-01 11:22:11 -05:00
onTriggered: app.mainWindow.showSetup()
2021-02-17 14:36:39 -05:00
}
MenuSeparator {}
DecentMenuItem {
sequence: "alt+m"
2021-10-01 11:22:11 -05:00
onTriggered: app.mainWindow.toggleMenubar()
text: root.visible ? qsTr("Hide menubar") :
qsTr("Show menubar")
2021-02-17 14:36:39 -05:00
}
2021-02-18 23:41:10 -05:00
MenuSeparator {}
DecentMenuItem {
2021-10-01 05:51:39 -05:00
sequence: "f11"
2021-10-01 11:22:11 -05:00
onTriggered: app.mainWindow.toggleFullscreen()
text: app.mainWindow.fullScreen ? qsTr("Exit full screen") :
qsTr("Enter full screen")
2021-02-18 23:41:10 -05:00
}
2021-02-17 14:36:39 -05:00
}
//
// Console format
//
Menu {
title: qsTr("Console")
DecentMenuItem {
checkable: true
text: qsTr("Autoscroll")
checked: Cpp_IO_Console.autoscroll
onTriggered: Cpp_IO_Console.autoscroll = checked
}
DecentMenuItem {
checkable: true
text: qsTr("Show timestamp")
checked: Cpp_IO_Console.showTimestamp
onTriggered: Cpp_IO_Console.showTimestamp = checked
}
DecentMenuItem {
checkable: true
2021-10-01 11:22:11 -05:00
checked: app.mainWindow.vt100emulation
2021-02-17 14:36:39 -05:00
text: qsTr("VT-100 emulation")
2021-10-01 11:22:11 -05:00
onTriggered: app.mainWindow.vt100emulation = checked
2021-02-17 14:36:39 -05:00
}
DecentMenuItem {
checkable: true
text: qsTr("Echo user commands")
checked: Cpp_IO_Console.echo
onTriggered: Cpp_IO_Console.echo = checked
}
MenuSeparator{}
Menu {
title: qsTr("Display mode")
DecentMenuItem {
checkable: true
text: qsTr("Normal (plain text)")
2021-09-30 23:15:32 -05:00
checked: Cpp_IO_Console.displayMode === 0
2021-02-17 14:36:39 -05:00
onTriggered: Cpp_IO_Console.displayMode = checked ? 0 : 1
}
DecentMenuItem {
checkable: true
text: qsTr("Binary (hexadecimal)")
2021-09-30 23:15:32 -05:00
checked: Cpp_IO_Console.displayMode === 1
2021-02-17 14:36:39 -05:00
onTriggered: Cpp_IO_Console.displayMode = checked ? 1 : 0
}
}
Menu {
title: qsTr("Line ending character")
DecentMenuItem {
checkable: true
text: Cpp_IO_Console.lineEndings()[0]
checked: Cpp_IO_Console.lineEnding === 0
onTriggered: Cpp_IO_Console.lineEnding = 0
}
DecentMenuItem {
checkable: true
text: Cpp_IO_Console.lineEndings()[1]
2021-09-30 23:15:32 -05:00
checked: Cpp_IO_Console.lineEnding === 1
onTriggered: Cpp_IO_Console.lineEnding = 1
}
DecentMenuItem {
checkable: true
text: Cpp_IO_Console.lineEndings()[2]
2021-09-30 23:15:32 -05:00
checked: Cpp_IO_Console.lineEnding === 2
onTriggered: Cpp_IO_Console.lineEnding = 2
}
DecentMenuItem {
checkable: true
text: Cpp_IO_Console.lineEndings()[3]
2021-09-30 23:15:32 -05:00
checked: Cpp_IO_Console.lineEnding === 3
onTriggered: Cpp_IO_Console.lineEnding = 3
2021-02-17 14:36:39 -05:00
}
}
}
//
// Help menu
//
Menu {
title: qsTr("Help")
DecentMenuItem {
onTriggered: app.showAbout()
text: qsTr("About %1").arg(Cpp_AppName)
}
DecentMenuItem {
text: qsTr("About %1").arg("Qt")
onTriggered: Cpp_Misc_Utilities.aboutQt()
}
MenuSeparator {
visible: Cpp_UpdaterEnabled
enabled: Cpp_UpdaterEnabled
}
DecentMenuItem {
checkable: true
visible: Cpp_UpdaterEnabled
enabled: Cpp_UpdaterEnabled
2021-10-01 11:22:11 -05:00
checked: app.mainWindow.automaticUpdates
onTriggered: app.mainWindow.automaticUpdates = checked
2021-02-17 14:36:39 -05:00
text: qsTr("Auto-updater")
}
DecentMenuItem {
visible: Cpp_UpdaterEnabled
enabled: Cpp_UpdaterEnabled
onTriggered: app.checkForUpdates()
text: qsTr("Check for updates") + "..."
}
MenuSeparator{}
DecentMenuItem {
text: qsTr("Project website") + "..."
onTriggered: Qt.openUrlExternally("https://www.alex-spataru.com/serial-studio")
}
DecentMenuItem {
2021-10-01 05:51:39 -05:00
sequence: "f1"
2021-02-17 14:36:39 -05:00
text: qsTr("Documentation/wiki") + "..."
onTriggered: Qt.openUrlExternally("https://github.com/Serial-Studio/Serial-Studio/wiki")
}
MenuSeparator{}
DecentMenuItem {
text: qsTr("Report bug") + "..."
onTriggered: Qt.openUrlExternally("https://github.com/Serial-Studio/Serial-Studio/issues")
}
}
}