220 lines
6.3 KiB
QML
Raw Normal View History

2020-10-18 06:50:26 -05:00
/*
* Copyright (c) 2020-2021 Alex Spataru <https://github.com/alex-spataru>
2020-10-18 06:50:26 -05:00
*
* 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 QtQuick 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
2020-12-30 14:53:27 -06:00
import Qt.labs.settings 1.0
Control {
2020-12-27 17:21:19 -06:00
id: root
2020-10-18 06:50:26 -05:00
//
// Dummy string to increase width of buttons
//
readonly property string _btSpacer: " "
//
// Custom signals
//
2020-12-26 01:30:18 -06:00
signal dataClicked()
2020-10-18 06:50:26 -05:00
signal aboutClicked()
2021-01-20 15:06:40 -05:00
signal setupClicked()
2020-12-26 01:30:18 -06:00
signal consoleClicked()
signal widgetsClicked()
2020-10-18 06:50:26 -05:00
//
2020-12-26 01:30:18 -06:00
// Aliases to button check status
2020-10-18 06:50:26 -05:00
//
2020-12-26 01:30:18 -06:00
property alias dataChecked: dataBt.checked
property alias aboutChecked: aboutBt.checked
2021-01-20 15:06:40 -05:00
property alias setupChecked: setupBt.checked
2020-12-26 01:30:18 -06:00
property alias consoleChecked: consoleBt.checked
property alias widgetsChecked: widgetsBt.checked
2020-10-18 06:50:26 -05:00
2020-12-30 14:53:27 -06:00
//
// Settings
//
Settings {
property alias dataExport: csvLogging.checked
}
2020-10-18 06:50:26 -05:00
//
// Background gradient
//
Rectangle {
border.width: 1
2021-01-20 14:54:45 -05:00
border.color: palette.midlight
gradient: Gradient {
GradientStop { position: 0; color: "#21373f" }
GradientStop { position: 1; color: "#11272f" }
}
2020-10-18 06:50:26 -05:00
anchors {
fill: parent
topMargin: -border.width
leftMargin: -border.width * 10
rightMargin: -border.width * 10
}
}
//
// Toolbar icons
//
RowLayout {
spacing: app.spacing
anchors.fill: parent
anchors.margins: app.spacing
Button {
2021-01-20 15:06:40 -05:00
id: setupBt
2020-12-26 01:30:18 -06:00
2020-10-18 06:50:26 -05:00
flat: true
icon.width: 24
icon.height: 24
Layout.fillHeight: true
icon.color: palette.text
2021-01-20 15:06:40 -05:00
onClicked: root.setupClicked()
icon.source: "qrc:/icons/settings.svg"
text: qsTr("Setup") + _btSpacer + CppTranslator.dummy
2020-10-18 06:50:26 -05:00
}
Button {
2020-12-26 01:30:18 -06:00
id: consoleBt
2020-10-18 06:50:26 -05:00
flat: true
icon.width: 24
icon.height: 24
Layout.fillHeight: true
icon.color: palette.text
2020-12-27 17:21:19 -06:00
onClicked: root.consoleClicked()
2020-10-18 06:50:26 -05:00
icon.source: "qrc:/icons/code.svg"
2020-12-27 17:21:19 -06:00
enabled: dataBt.enabled || widgetsBt.enabled
2021-01-04 22:11:59 -06:00
text: qsTr("Console") + _btSpacer + CppTranslator.dummy
2020-10-18 06:50:26 -05:00
}
Button {
2020-12-26 01:30:18 -06:00
id: dataBt
2020-10-18 06:50:26 -05:00
flat: true
icon.width: 24
icon.height: 24
Layout.fillHeight: true
icon.color: palette.text
2020-12-27 17:21:19 -06:00
onClicked: root.dataClicked()
2021-01-13 14:38:12 -05:00
enabled: CppDataProvider.groupCount > 0
2020-10-18 06:50:26 -05:00
icon.source: "qrc:/icons/equalizer.svg"
2021-01-04 22:11:59 -06:00
text: qsTr("Dashboard") + _btSpacer + CppTranslator.dummy
2020-12-27 17:21:19 -06:00
opacity: enabled ? 1 : 0.5
Behavior on opacity {NumberAnimation{}}
2020-10-18 06:50:26 -05:00
}
Button {
2020-12-26 01:30:18 -06:00
id: widgetsBt
2020-10-18 06:50:26 -05:00
flat: true
icon.width: 24
icon.height: 24
Layout.fillHeight: true
icon.color: palette.text
2020-12-27 17:21:19 -06:00
onClicked: root.widgetsClicked()
2020-12-26 01:30:18 -06:00
icon.source: "qrc:/icons/chart.svg"
2020-12-27 17:21:19 -06:00
enabled: CppWidgets.totalWidgetCount > 0
2021-01-04 22:11:59 -06:00
text: qsTr("Widgets") + _btSpacer + CppTranslator.dummy
2020-12-27 17:21:19 -06:00
opacity: enabled ? 1 : 0.5
Behavior on opacity {NumberAnimation{}}
2020-10-18 06:50:26 -05:00
}
Button {
2020-12-26 01:30:18 -06:00
id: aboutBt
2020-10-18 06:50:26 -05:00
flat: true
icon.width: 24
icon.height: 24
Layout.fillHeight: true
icon.color: palette.text
2020-12-27 17:21:19 -06:00
onClicked: root.aboutClicked()
2020-10-18 06:50:26 -05:00
icon.source: "qrc:/icons/info.svg"
2021-01-04 22:11:59 -06:00
text: qsTr("About") + CppTranslator.dummy
2020-10-18 06:50:26 -05:00
}
Item {
Layout.fillWidth: true
}
2020-12-30 14:53:27 -06:00
Switch {
id: csvLogging
checked: true
Layout.alignment: Qt.AlignVCenter
2021-01-04 22:11:59 -06:00
text: qsTr("CSV Export") + CppTranslator.dummy
2020-12-30 14:53:27 -06:00
onCheckedChanged: CppExport.exportEnabled = checked
2020-12-30 16:11:51 -06:00
palette.highlight: Qt.rgba(46/255, 137/255, 92/255, 1)
2020-12-30 14:53:27 -06:00
}
Button {
flat: true
icon.width: 24
icon.height: 24
Layout.fillHeight: true
icon.color: palette.text
icon.source: "qrc:/icons/bug.svg"
onClicked: CppExport.openLogFile()
text: qsTr("Log") + _btSpacer + CppTranslator.dummy
Behavior on opacity {NumberAnimation{}}
}
2020-10-18 06:50:26 -05:00
Button {
flat: true
icon.width: 24
icon.height: 24
Layout.fillHeight: true
icon.color: palette.text
opacity: enabled ? 1 : 0.5
2021-01-04 23:33:50 -06:00
onClicked: CppCsvPlayer.openFile()
2020-11-26 20:43:25 -06:00
icon.source: "qrc:/icons/update.svg"
2021-01-04 23:33:50 -06:00
text: qsTr("CSV Player") + _btSpacer + CppTranslator.dummy
2020-11-26 20:43:25 -06:00
Behavior on opacity {NumberAnimation{}}
}
Button {
flat: true
icon.width: 24
icon.height: 24
Layout.fillHeight: true
icon.color: palette.text
enabled: CppExport.isOpen
opacity: enabled ? 1 : 0.5
2020-10-18 06:50:26 -05:00
icon.source: "qrc:/icons/open.svg"
2020-11-26 20:43:25 -06:00
onClicked: CppExport.openCurrentCsv()
2021-01-17 15:57:49 -05:00
text: qsTr("Open CSV") + _btSpacer + CppTranslator.dummy
2020-10-18 06:50:26 -05:00
Behavior on opacity {NumberAnimation{}}
}
}
}