185 lines
5.2 KiB
QML
Raw Normal View History

2020-10-18 06:50:26 -05:00
/*
* Copyright (c) 2020 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 QtQuick 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
2020-12-27 17:21:19 -06:00
Page {
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()
2020-12-26 01:30:18 -06:00
signal devicesClicked()
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
property alias consoleChecked: consoleBt.checked
property alias widgetsChecked: widgetsBt.checked
property alias devicesChecked: devicesBt.checked
2020-10-18 06:50:26 -05:00
//
// Background gradient
//
Rectangle {
border.width: 1
color: Qt.rgba(33/255, 55/255, 63/255, 1)
border.color: Qt.darker(color)
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 {
2020-12-26 01:30:18 -06:00
id: devicesBt
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.devicesClicked()
2020-10-18 06:50:26 -05:00
icon.source: "qrc:/icons/usb.svg"
2020-12-26 01:30:18 -06:00
text: qsTr("Devices") + _btSpacer
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"
text: qsTr("Console") + _btSpacer
2020-12-27 17:21:19 -06:00
enabled: dataBt.enabled || widgetsBt.enabled
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()
enabled: CppQmlBridge.groupCount > 0
2020-10-18 06:50:26 -05:00
icon.source: "qrc:/icons/equalizer.svg"
text: qsTr("Data Display") + _btSpacer
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"
text: qsTr("Widgets") + _btSpacer
2020-12-27 17:21:19 -06:00
enabled: CppWidgets.totalWidgetCount > 0
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
text: qsTr("About")
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"
}
Item {
Layout.fillWidth: true
}
Button {
flat: true
icon.width: 24
icon.height: 24
Layout.fillHeight: true
icon.color: palette.text
opacity: enabled ? 1 : 0.5
onClicked: CppExport.openCsv()
2020-11-26 20:43:25 -06:00
icon.source: "qrc:/icons/update.svg"
text: qsTr("Open past CSV") + _btSpacer
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()
text: qsTr("Open current CSV") + _btSpacer
2020-10-18 06:50:26 -05:00
Behavior on opacity {NumberAnimation{}}
}
}
}