diff --git a/CMakeLists.txt b/CMakeLists.txt index bca4c1fc..f5dc494c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,16 +100,6 @@ set(QML_ELEMENTS widgets/misc/CameraView widgets/misc/ErrorsWidget - widgets/config/BaseConfigDialog - widgets/config/LabeledTextField - widgets/config/LabeledSpinBox - widgets/config/LabeledDoubleSpinBox - widgets/config/LabeledComboBox - widgets/config/TitleComponent - widgets/config/ColorTable - widgets/config/ColorField - widgets/config/SectionHeader - dialogs/TopicView dialogs/TabNameDialog dialogs/TabSizeDialog @@ -123,7 +113,6 @@ set(ELEMENTS Constants SettingsManager TitleManager - Clipboard models/TabWidgetsModel models/TabListModel diff --git a/dialogs/WidgetConfig.qml b/dialogs/WidgetConfig.qml index 5c8ce248..aebce29f 100644 --- a/dialogs/WidgetConfig.qml +++ b/dialogs/WidgetConfig.qml @@ -45,12 +45,16 @@ Dialog { choices = item[sub + "Choices"] typeName = "list" - } else if (typeName === "QVariantList") { + } + + else if (typeName === "QVariantList") { obj["valueType"] = item[sub + "ValueType"] obj["valueName"] = item[sub + "ValueName"] - } else if (typeName === "int" || typeName === "double") { - let min = item[sub + "Min"] - let max = item[sub + "Max"] + } + + else if (typeName === "int" || typeName === "double") { + let min = item[sub + "Min"]; + let max = item[sub + "Max"]; obj["min"] = (typeof min === "undefined") ? 0 : min obj["max"] = (typeof max === "undefined") ? 100000 : max @@ -83,13 +87,13 @@ Dialog { } function getValues() { - for (var i = 0; i < rep.count; ++i) { + for (var i = 0; i < listView.count; ++i) { let idx = lm.get(i) item[idx.name] = idx.itemValue } } - Flow { + ListView { anchors { top: parent.top bottom: parent.bottom @@ -101,816 +105,412 @@ Dialog { spacing: 8 - id: flow - - Repeater { - id: rep + id: listView - clip: true + clip: true - // boundsBehavior: Flickable.StopAtBounds - model: lm + boundsBehavior: Flickable.StopAtBounds - component FieldLabel: Label { - Layout.fillWidth: true + model: lm - text: displayText(model.name) - font.pixelSize: 15 - color: Constants.palette.text - } - - delegate: DelegateChooser { - role: "type" - - // TODO: may want to find a way to avoid all this repeat code - DelegateChoice { - roleValue: "QString" - - RowLayout { - clip: true + component FieldLabel: Label { + Layout.fillWidth: true - FieldLabel {} + text: displayText(model.name) + font.pixelSize: 15 + color: Constants.palette.text + } - TextField { - id: txt - Layout.fillWidth: true + delegate: DelegateChooser { + role: "type" - font.pixelSize: 15 - text: model.itemValue + // TODO: may want to find a way to avoid all this repeat code + DelegateChoice { + roleValue: "QString" - onTextEdited: model.itemValue = text - } - } - } + RowLayout { + clip: true + width: parent.width - DelegateChoice { - roleValue: "bool" + uniformCellSizes: true - RowLayout { - clip: true + FieldLabel {} - FieldLabel {} + TextField { + id: txt + Layout.fillWidth: true - CheckBox { - checked: model.itemValue + font.pixelSize: 15 + text: model.itemValue - onClicked: model.itemValue = checked - - indicator.implicitHeight: 20 - indicator.implicitWidth: 20 - } + onTextEdited: model.itemValue = text } } + } - DelegateChoice { - roleValue: "int" + DelegateChoice { + roleValue: "bool" - RowLayout { - clip: true + RowLayout { + clip: true + width: parent.width - FieldLabel {} + uniformCellSizes: true - SpinBox { - from: map.min - to: map.max + FieldLabel {} - id: sb + CheckBox { + checked: model.itemValue - Layout.fillWidth: true + onClicked: model.itemValue = checked - font.pixelSize: 15 - value: model.itemValue - - onValueModified: model.itemValue = value - } + indicator.implicitHeight: 20 + indicator.implicitWidth: 20 } } + } - DelegateChoice { - roleValue: "double" + DelegateChoice { + roleValue: "int" - RowLayout { - clip: true + RowLayout { + clip: true + width: parent.width - FieldLabel {} + uniformCellSizes: true - DoubleSpinBox { - from: map.min - to: map.max + FieldLabel {} - id: dsb - font.pixelSize: 15 - Layout.fillWidth: true + SpinBox { + from: map.min + to: map.max - value: model.itemValue + id: sb - stepSize: 0.1 + Layout.fillWidth: true - onValueModified: model.itemValue = value - } + font.pixelSize: 15 + value: model.itemValue + + onValueModified: model.itemValue = value } } + } - DelegateChoice { - roleValue: "QColor" + DelegateChoice { + roleValue: "double" - RowLayout { - clip: true + RowLayout { + clip: true + width: parent.width - FieldLabel {} + uniformCellSizes: true - TextField { - id: colorField - font.pixelSize: 15 - Layout.fillWidth: true + FieldLabel {} - text: model.itemValue + DoubleSpinBox { + from: map.min + to: map.max - onTextEdited: model.itemValue = text - } + id: dsb + font.pixelSize: 15 + Layout.fillWidth: true - Button { - Layout.fillWidth: true - text: "Pick" + value: model.itemValue - function setColor() { - colorField.text = colorDialog.selectedColor - model.itemValue = colorDialog.selectedColor - colorDialog.accepted.disconnect(setColor) - } + stepSize: 0.1 - onClicked: { - colorDialog.selectedColor = colorField.text - colorDialog.accepted.connect(setColor) - colorDialog.open() - } - } + onValueModified: model.itemValue = value } } + } - DelegateChoice { - roleValue: "list" + DelegateChoice { + roleValue: "QColor" - RowLayout { - clip: true + RowLayout { + clip: true + width: parent.width - FieldLabel {} + uniformCellSizes: true - function setValue(v) { - model.itemValue = v - } + FieldLabel {} - ComboBox { - model: choices + TextField { + id: colorField + font.pixelSize: 15 + Layout.fillWidth: true - delegate: ItemDelegate { - id: delegate + text: model.itemValue - width: cb.width - contentItem: Text { - text: modelData - color: "white" - font.pixelSize: 15 - elide: Text.ElideRight - verticalAlignment: Text.AlignVCenter - } - highlighted: choices.highlightedIndex === index - } + onTextEdited: model.itemValue = text + } - id: cb - font.pixelSize: 15 - Layout.fillWidth: true + Button { + Layout.fillWidth: true + text: "Pick" - Component.onCompleted: { - currentIndex = choices.indexOf(itemValue) - currentIndexChanged.connect(updateValue) - } + function setColor() { + colorField.text = colorDialog.selectedColor + model.itemValue = colorDialog.selectedColor + colorDialog.accepted.disconnect(setColor) + } - function updateValue() { - setValue(valueAt(currentIndex)) - } + onClicked: { + colorDialog.selectedColor = colorField.text + colorDialog.accepted.connect(setColor) + colorDialog.open() } } } + } - DelegateChoice { - roleValue: "QVariantList" + DelegateChoice { + roleValue: "list" - GridLayout { - clip: true - width: parent.width + RowLayout { + clip: true + width: parent.width - rowSpacing: 0 + uniformCellSizes: true - rows: 4 - columns: 2 + FieldLabel {} - FieldLabel {} + function setValue(v) { + model.itemValue = v + } - function setValue(v) { - model.itemValue = v - } + ComboBox { + model: choices - function getValue() { - // stupid workaround because of cancer - // itemValue gets corrupted to a QQmlListModel for some reason - // kill me - return model.item[model.name] - } + delegate: ItemDelegate { + id: delegate - HorizontalHeaderView { - Layout.minimumWidth: parent.width - 90 - Layout.row: 0 - Layout.column: 1 + width: choices.width + contentItem: Text { + text: modelData + color: "white" + font.pixelSize: 15 + elide: Text.ElideRight + verticalAlignment: Text.AlignVCenter + } + highlighted: choices.highlightedIndex === index + } - Layout.fillWidth: true + id: cb + font.pixelSize: 15 + Layout.fillWidth: true - Layout.minimumHeight: 30 - Layout.columnSpan: 2 - id: horizontalHeader - syncView: tbl - clip: true + Component.onCompleted: { + currentIndex = choices.indexOf(itemValue) + currentIndexChanged.connect(updateValue) } - TableView { - Layout.minimumWidth: parent.width - 90 - Layout.minimumHeight: 40 - columnSpacing: 1 - rowSpacing: 1 - clip: true + function updateValue() { + setValue(valueAt(currentIndex)) + } + } + } + } - id: tbl + DelegateChoice { + roleValue: "QVariantList" - Layout.fillWidth: true + GridLayout { + clip: true + width: parent.width - Layout.row: 1 - Layout.column: 1 + rowSpacing: 0 - Layout.rowSpan: 3 + rows: 4 + columns: 2 - interactive: false + FieldLabel {} - function resetHeight() { - Layout.minimumHeight = 42 * tblModel.rowCount() - } + function setValue(v) { + model.itemValue = v + } - Component.onCompleted: { - let vl = map.valueName - let iv = getValue() + function getValue() { + // stupid workaround because of cancer + // itemValue gets corrupted to a QQmlListModel for some reason + // kill me + return model.item[model.name] + } - for (var i = 0; i < iv.length; ++i) { - tblModel.add(iv[i]["Value"], iv[i][vl]) - tbl.resetHeight() - } + HorizontalHeaderView { + Layout.minimumWidth: parent.width - 90 + Layout.row: 0 + Layout.column: 1 - setValue(tblModel.asList()) - tblModel.dataChanged.connect( - () => setValue(tblModel.asList())) - } + Layout.fillWidth: true - model: MapModel { - id: tblModel - valueName: map.valueName - } + Layout.minimumHeight: 30 + Layout.columnSpan: 2 + id: horizontalHeader + syncView: tbl + clip: true + } - selectionModel: ItemSelectionModel {} - selectionBehavior: TableView.SelectRows - selectionMode: TableView.SingleSelection + TableView { + Layout.minimumWidth: parent.width - 90 + Layout.minimumHeight: 40 + columnSpacing: 1 + rowSpacing: 1 + clip: true - delegate: Rectangle { - border { - color: Constants.palette.text - width: 2 - } + id: tbl - required property bool selected - required property bool current + Layout.fillWidth: true - implicitWidth: tbl.width / 2 - implicitHeight: 40 + Layout.row: 1 + Layout.column: 1 - color: current ? "blue" : "black" + Layout.rowSpan: 3 - Text { - font.pixelSize: 15 - anchors.centerIn: parent - text: display - color: Constants.palette.text - } + interactive: false - TableView.editDelegate: TextField { - font.pixelSize: 15 - anchors.fill: parent - text: display - horizontalAlignment: TextInput.AlignHCenter - verticalAlignment: TextInput.AlignVCenter - Component.onCompleted: selectAll() - - TableView.onCommit: { - display = text - } - } - } + function resetHeight() { + Layout.minimumHeight = 42 * tblModel.rowCount() } - Button { - Layout.alignment: Qt.AlignTop | Qt.AlignLeft - Layout.row: 1 - Layout.column: 0 - text: "Add" + Component.onCompleted: { + let vl = map.valueName + let iv = getValue() - onClicked: { - tblModel.add("", "") - setValue(tblModel.asList()) + for (let i = 0; i < iv.length; ++i) { + tblModel.add(iv[i]["Value"], iv[i][vl]) tbl.resetHeight() } - } - - Button { - Layout.alignment: Qt.AlignTop | Qt.AlignLeft - Layout.row: 2 - Layout.column: 0 - text: "Delete" - onClicked: { - tblModel.remove(tbl.currentRow) - setValue(tblModel.asList()) - tbl.resetHeight() - } + setValue(tblModel.asList()) + tblModel.dataChanged.connect(() => setValue(tblModel.asList())) } - } - } - - DelegateChoice { - roleValue: "QSizeF" - - RowLayout { - clip: true - FieldLabel { - Layout.rowSpan: 4 + model: MapModel { + id: tblModel + valueName: map.valueName } - Label { - text: "Width:" - font.pixelSize: 15 - } + selectionModel: ItemSelectionModel {} + selectionBehavior: TableView.SelectRows + selectionMode: TableView.SingleSelection - SpinBox { - from: 0 - to: 2000 + delegate: Rectangle { + border { + color: Constants.palette.text + width: 2 + } - id: width + required property bool selected + required property bool current - Layout.fillWidth: true + implicitWidth: tbl.width / 2 + implicitHeight: 40 - font.pixelSize: 15 - value: model.itemValue.width + color: current ? "blue" : "black" - onValueModified: model.itemValue.width = value - } + Text { + font.pixelSize: 15 + anchors.centerIn: parent + text: display + color: Constants.palette.text + } - Label { - text: "Height:" - font.pixelSize: 15 - } + TableView.editDelegate: TextField { + font.pixelSize: 15 + anchors.fill: parent + text: display + horizontalAlignment: TextInput.AlignHCenter + verticalAlignment: TextInput.AlignVCenter + Component.onCompleted: selectAll() - SpinBox { - from: 0 - to: 2000 + TableView.onCommit: { + display = text + } + } + } + } - id: height + Button { + Layout.alignment: Qt.AlignTop | Qt.AlignLeft + Layout.row: 1 + Layout.column: 0 + text: "Add" - Layout.fillWidth: true + onClicked: { + tblModel.add("", "") + setValue(tblModel.asList()) + tbl.resetHeight() + } + } - font.pixelSize: 15 - value: model.itemValue.height + Button { + Layout.alignment: Qt.AlignTop | Qt.AlignLeft + Layout.row: 2 + Layout.column: 0 + text: "Delete" - onValueModified: model.itemValue.height = value + onClicked: { + tblModel.remove(tbl.currentRow) + setValue(tblModel.asList()) + tbl.resetHeight() } } } } - } - } - - // ListView { - // anchors { - // top: parent.top - // bottom: parent.bottom - // left: parent.left - // right: parent.right - - // margins: 8 - // } - - // spacing: 8 - - // id: listView - - // clip: true - - // boundsBehavior: Flickable.StopAtBounds - - // model: lm - - // component FieldLabel: Label { - // Layout.fillWidth: true - - // text: displayText(model.name) - // font.pixelSize: 15 - // color: Constants.palette.text - // } - - // delegate: DelegateChooser { - // role: "type" - - // // TODO: may want to find a way to avoid all this repeat code - // DelegateChoice { - // roleValue: "QString" - - // RowLayout { - // clip: true - // width: parent.width - - // uniformCellSizes: true - - // FieldLabel {} - - // TextField { - // id: txt - // Layout.fillWidth: true - - // font.pixelSize: 15 - // text: model.itemValue - - // onTextEdited: model.itemValue = text - // } - // } - // } - - // DelegateChoice { - // roleValue: "bool" - - // RowLayout { - // clip: true - // width: parent.width - - // uniformCellSizes: true - - // FieldLabel {} - - // CheckBox { - // checked: model.itemValue - - // onClicked: model.itemValue = checked - - // indicator.implicitHeight: 20 - // indicator.implicitWidth: 20 - // } - // } - // } - // DelegateChoice { - // roleValue: "int" + DelegateChoice { + roleValue: "QSizeF" - // RowLayout { - // clip: true - // width: parent.width + RowLayout { + clip: true + width: parent.width - // uniformCellSizes: true - // FieldLabel {} - - // SpinBox { - // from: map.min - // to: map.max - - // id: sb - - // Layout.fillWidth: true - - // font.pixelSize: 15 - // value: model.itemValue - - // onValueModified: model.itemValue = value - // } - // } - // } - - // DelegateChoice { - // roleValue: "double" - - // RowLayout { - // clip: true - // width: parent.width - - // uniformCellSizes: true - - // FieldLabel {} - - // DoubleSpinBox { - // from: map.min - // to: map.max - - // id: dsb - // font.pixelSize: 15 - // Layout.fillWidth: true - - // value: model.itemValue - - // stepSize: 0.1 - - // onValueModified: model.itemValue = value - // } - // } - // } - - // DelegateChoice { - // roleValue: "QColor" - - // RowLayout { - // clip: true - // width: parent.width - - // uniformCellSizes: true - - // FieldLabel {} - - // TextField { - // id: colorField - // font.pixelSize: 15 - // Layout.fillWidth: true - - // text: model.itemValue - - // onTextEdited: model.itemValue = text - // } - - // Button { - // Layout.fillWidth: true - // text: "Pick" - - // function setColor() { - // colorField.text = colorDialog.selectedColor - // model.itemValue = colorDialog.selectedColor - // colorDialog.accepted.disconnect(setColor) - // } - - // onClicked: { - // colorDialog.selectedColor = colorField.text - // colorDialog.accepted.connect(setColor) - // colorDialog.open() - // } - // } - // } - // } - - // DelegateChoice { - // roleValue: "list" - - // RowLayout { - // clip: true - // width: parent.width - - // uniformCellSizes: true + FieldLabel { + Layout.rowSpan: 4 + } - // FieldLabel {} + Label { + text: "Width:" + font.pixelSize: 15 + } - // function setValue(v) { - // model.itemValue = v - // } + SpinBox { + from: 0 + to: 2000 - // ComboBox { - // model: choices + id: width - // delegate: ItemDelegate { - // id: delegate + Layout.fillWidth: true - // width: choices.width - // contentItem: Text { - // text: modelData - // color: "white" - // font.pixelSize: 15 - // elide: Text.ElideRight - // verticalAlignment: Text.AlignVCenter - // } - // highlighted: choices.highlightedIndex === index - // } + font.pixelSize: 15 + value: model.itemValue.width - // id: cb - // font.pixelSize: 15 - // Layout.fillWidth: true + onValueModified: model.itemValue.width = value + } - // Component.onCompleted: { - // currentIndex = choices.indexOf(itemValue) - // currentIndexChanged.connect(updateValue) - // } + Label { + text: "Height:" + font.pixelSize: 15 + } - // function updateValue() { - // setValue(valueAt(currentIndex)) - // } - // } - // } - // } + SpinBox { + from: 0 + to: 2000 - // DelegateChoice { - // roleValue: "QVariantList" + id: height - // GridLayout { - // clip: true - // width: parent.width + Layout.fillWidth: true - // rowSpacing: 0 - - // rows: 4 - // columns: 2 + font.pixelSize: 15 + value: model.itemValue.height - // FieldLabel {} - - // function setValue(v) { - // model.itemValue = v - // } - - // function getValue() { - // // stupid workaround because of cancer - // // itemValue gets corrupted to a QQmlListModel for some reason - // // kill me - // return model.item[model.name] - // } - - // HorizontalHeaderView { - // Layout.minimumWidth: parent.width - 90 - // Layout.row: 0 - // Layout.column: 1 - - // Layout.fillWidth: true - - // Layout.minimumHeight: 30 - // Layout.columnSpan: 2 - // id: horizontalHeader - // syncView: tbl - // clip: true - // } - - // TableView { - // Layout.minimumWidth: parent.width - 90 - // Layout.minimumHeight: 40 - // columnSpacing: 1 - // rowSpacing: 1 - // clip: true - - // id: tbl - - // Layout.fillWidth: true - - // Layout.row: 1 - // Layout.column: 1 - - // Layout.rowSpan: 3 - - // interactive: false - - // function resetHeight() { - // Layout.minimumHeight = 42 * tblModel.rowCount() - // } - - // Component.onCompleted: { - // let vl = map.valueName - // let iv = getValue() - - // for (let i = 0; i < iv.length; ++i) { - // tblModel.add(iv[i]["Value"], iv[i][vl]) - // tbl.resetHeight() - // } - - // setValue(tblModel.asList()) - // tblModel.dataChanged.connect(() => setValue(tblModel.asList())) - // } - - // model: MapModel { - // id: tblModel - // valueName: map.valueName - // } - - // selectionModel: ItemSelectionModel {} - // selectionBehavior: TableView.SelectRows - // selectionMode: TableView.SingleSelection - - // delegate: Rectangle { - // border { - // color: Constants.palette.text - // width: 2 - // } - - // required property bool selected - // required property bool current - - // implicitWidth: tbl.width / 2 - // implicitHeight: 40 - - // color: current ? "blue" : "black" - - // Text { - // font.pixelSize: 15 - // anchors.centerIn: parent - // text: display - // color: Constants.palette.text - // } - - // TableView.editDelegate: TextField { - // font.pixelSize: 15 - // anchors.fill: parent - // text: display - // horizontalAlignment: TextInput.AlignHCenter - // verticalAlignment: TextInput.AlignVCenter - // Component.onCompleted: selectAll() - - // TableView.onCommit: { - // display = text - // } - // } - // } - // } - - // Button { - // Layout.alignment: Qt.AlignTop | Qt.AlignLeft - // Layout.row: 1 - // Layout.column: 0 - // text: "Add" - - // onClicked: { - // tblModel.add("", "") - // setValue(tblModel.asList()) - // tbl.resetHeight() - // } - // } - - // Button { - // Layout.alignment: Qt.AlignTop | Qt.AlignLeft - // Layout.row: 2 - // Layout.column: 0 - // text: "Delete" - - // onClicked: { - // tblModel.remove(tbl.currentRow) - // setValue(tblModel.asList()) - // tbl.resetHeight() - // } - // } - // } - // } - - // DelegateChoice { - // roleValue: "QSizeF" - - // RowLayout { - // clip: true - // width: parent.width - - // FieldLabel { - // Layout.rowSpan: 4 - // } - - // Label { - // text: "Width:" - // font.pixelSize: 15 - // } - - // SpinBox { - // from: 0 - // to: 2000 - - // id: width - - // Layout.fillWidth: true - - // font.pixelSize: 15 - // value: model.itemValue.width - - // onValueModified: model.itemValue.width = value - // } - - // Label { - // text: "Height:" - // font.pixelSize: 15 - // } - - // SpinBox { - // from: 0 - // to: 2000 - - // id: height - - // Layout.fillWidth: true - - // font.pixelSize: 15 - // value: model.itemValue.height - - // onValueModified: model.itemValue.height = value - // } - // } - // } - // } - // } + onValueModified: model.itemValue.height = value + } + } + } + } + } } diff --git a/include/Clipboard.h b/include/Clipboard.h deleted file mode 100644 index 871b6a45..00000000 --- a/include/Clipboard.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef CLIPBOARD_H -#define CLIPBOARD_H - -#include -#include - -class Clipboard : public QObject -{ - Q_OBJECT - QML_ELEMENT - QML_SINGLETON -public: - Clipboard(QObject *parent = nullptr); - - Q_INVOKABLE void copy(const QString &text); - -signals: -}; - -#endif // CLIPBOARD_H diff --git a/include/models/MapModel.h b/include/models/MapModel.h index 8b024ef3..7ee564b3 100644 --- a/include/models/MapModel.h +++ b/include/models/MapModel.h @@ -39,7 +39,6 @@ class MapModel : public QAbstractTableModel Q_INVOKABLE void add(QString key = "", QString value = ""); Q_INVOKABLE void remove(int row); Q_INVOKABLE QVariantList asList(); - Q_INVOKABLE void toList(const QVariantList &list); QString valueName() const; void setValueName(const QString &newValueName); diff --git a/main.cpp b/main.cpp index e30f9fb5..12d3fb7e 100644 --- a/main.cpp +++ b/main.cpp @@ -5,7 +5,6 @@ #include "AccentsListModel.h" #include "BuildConfig.h" -#include "Clipboard.h" #include "Flags.h" #include "Globals.h" #include "TitleManager.h" @@ -35,8 +34,6 @@ int main(int argc, char *argv[]) AccentsListModel *accents = new AccentsListModel(&app); accents->load(); - Clipboard *clipboard = new Clipboard(&app); - Globals::inst.AddConnectionListener(true, [topics, &store, title] (const nt::Event &event) { bool connected = event.Is(nt::EventFlags::kConnected); @@ -94,7 +91,6 @@ int main(int argc, char *argv[]) engine.rootContext()->setContextProperty("tlm", tlm); engine.rootContext()->setContextProperty("titleManager", title); engine.rootContext()->setContextProperty("accents", accents); - engine.rootContext()->setContextProperty("clipboard", clipboard); QObject::connect( &engine, &QQmlApplicationEngine::objectCreationFailed, diff --git a/src/Clipboard.cpp b/src/Clipboard.cpp deleted file mode 100644 index 002e71cb..00000000 --- a/src/Clipboard.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "Clipboard.h" -#include -#include - -Clipboard::Clipboard(QObject *parent) - : QObject{parent} -{} - -void Clipboard::copy(const QString &text) -{ - qApp->clipboard()->setText(text); -} diff --git a/src/models/MapModel.cpp b/src/models/MapModel.cpp index 916b5122..c502eb84 100644 --- a/src/models/MapModel.cpp +++ b/src/models/MapModel.cpp @@ -124,18 +124,6 @@ QVariantList MapModel::asList() } -void MapModel::toList(const QVariantList &list) -{ - beginResetModel(); - m_data.clear(); - endResetModel(); - - for (const QVariant &v : list) { - QVariantMap m = v.toMap(); - add(m.value("Value").toString(), m.value(m_valueName).toString()); - } -} - QString MapModel::valueName() const { return m_valueName; diff --git a/widgets/BaseWidget.qml b/widgets/BaseWidget.qml index c32b70d1..10e35bb3 100644 --- a/widgets/BaseWidget.qml +++ b/widgets/BaseWidget.qml @@ -106,8 +106,7 @@ Rectangle { MenuItem { text: "Configure" - // onTriggered: openConf(rcMenu.parent) - onTriggered: config.openDialog() + onTriggered: openConf(rcMenu.parent) } MenuItem { @@ -302,76 +301,4 @@ Rectangle { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } - - /** - * This is the "base" configuration dialog containing the NT and font settings. - * Copy it for your widget. - */ - BaseConfigDialog { - // id: config - - height: 450 - - function openDialog() { - topicField.open() - titleFontField.open() - - open() - } - - onAccepted: { - topicField.accept() - titleFontField.accept() - } - - ColumnLayout { - id: layout - spacing: 25 - - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - right: parent.right - - topMargin: parent.headerHeight + 12 - bottomMargin: 45 - - leftMargin: 5 - rightMargin: 5 - } - - SectionHeader { - label: "Font Settings" - } - - LabeledSpinBox { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - id: titleFontField - - label: "Title Font Size" - - bindedProperty: "item_titleFontSize" - bindTarget: rect - } - - SectionHeader { - label: "NT Settings" - } - - LabeledTextField { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - id: topicField - - label: "Topic" - - bindedProperty: "item_topic" - bindTarget: rect - } - } - } } diff --git a/widgets/config/BaseConfigDialog.qml b/widgets/config/BaseConfigDialog.qml deleted file mode 100644 index 5dce1ce1..00000000 --- a/widgets/config/BaseConfigDialog.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick -import QtQuick.Controls - -import QFRCDashboard - -Dialog { - id: config - - property int headerHeight: 40 - - width: 375 - spacing: 10 - - standardButtons: Dialog.Ok | Dialog.Cancel - - TitleComponent {} - - background: Rectangle { - color: "transparent" - } - - contentItem: Rectangle { - color: Constants.palette.dialogBg - radius: 20 - anchors.fill: parent - } - - parent: Overlay.overlay - anchors.centerIn: parent -} diff --git a/widgets/config/ColorField.qml b/widgets/config/ColorField.qml deleted file mode 100644 index 18b02d49..00000000 --- a/widgets/config/ColorField.qml +++ /dev/null @@ -1,50 +0,0 @@ -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Layouts -import QtQuick.Shapes 2.15 -import QtQuick.Dialogs - -import QFRCDashboard - -RowLayout { - required property string label - - /** what property to bind to */ - required property string bindedProperty - - /** the target to bind the property to */ - required property var bindTarget - - function open() { - textField.open() - } - - function accept() { - textField.accept() - } - - ColorDialog { - id: colorDialog - - selectedColor: textField.text - onAccepted: textField.text = colorDialog.selectedColor - } - - LabeledTextField { - id: textField - Layout.fillWidth: true - - label: parent.label - bindedProperty: parent.bindedProperty - bindTarget: parent.bindTarget - } - - Button { - Layout.fillWidth: true - text: "Pick" - - onClicked: { - colorDialog.open() - } - } -} diff --git a/widgets/config/ColorTable.qml b/widgets/config/ColorTable.qml deleted file mode 100644 index afddc68b..00000000 --- a/widgets/config/ColorTable.qml +++ /dev/null @@ -1,155 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import QtQuick.Dialogs -import QtQuick.Shapes 2.15 - -import QFRCDashboard - -ColumnLayout { - required property string label - - /** what property to bind to */ - required property string bindedProperty - - /** the target to bind the property to */ - required property var bindTarget - - - function open() { - tblModel.toList(bindTarget[bindedProperty]) - tbl.resetHeight() - } - - function accept() { - bindTarget[bindedProperty] = tblModel.asList() - } - - id: col - - spacing: 0 - - ColorDialog { - id: colorDialog - - onAccepted: Clipboard.copy(selectedColor) - } - - Text { - id: floatingLabel - text: label - color: Constants.palette.text - - font.pixelSize: 15 - } - - HorizontalHeaderView { - Layout.minimumWidth: parent.width - 90 - Layout.row: 0 - Layout.column: 1 - - Layout.fillWidth: true - - Layout.minimumHeight: 30 - Layout.columnSpan: 2 - id: horizontalHeader - syncView: tbl - clip: true - } - - TableView { - Layout.minimumWidth: parent.width - 90 - Layout.minimumHeight: 40 - columnSpacing: 1 - rowSpacing: 1 - clip: true - - id: tbl - - Layout.fillWidth: true - - Layout.row: 1 - Layout.column: 1 - - Layout.rowSpan: 3 - - interactive: false - - function resetHeight() { - Layout.minimumHeight = 42 * tblModel.rowCount() - } - - model: MapModel { - id: tblModel - valueName: "Color" - } - - selectionModel: ItemSelectionModel {} - selectionBehavior: TableView.SelectRows - selectionMode: TableView.SingleSelection - - delegate: Rectangle { - border { - color: Constants.palette.text - width: 2 - } - - required property bool selected - required property bool current - - implicitWidth: tbl.width / 2 - implicitHeight: 40 - - color: current ? "blue" : "black" - - Text { - font.pixelSize: 15 - anchors.centerIn: parent - text: display - color: Constants.palette.text - } - - TableView.editDelegate: TextField { - font.pixelSize: 15 - anchors.fill: parent - text: display - horizontalAlignment: TextInput.AlignHCenter - verticalAlignment: TextInput.AlignVCenter - Component.onCompleted: selectAll() - - TableView.onCommit: { - display = text - } - } - } - } - - RowLayout { - Button { - Layout.alignment: Qt.AlignLeft - text: "Add" - - onClicked: { - tblModel.add("", "") - tbl.resetHeight() - } - } - - Button { - Layout.alignment: Qt.AlignLeft - text: "Delete" - - onClicked: { - tblModel.remove(tbl.currentRow) - tbl.resetHeight() - } - } - - Button { - Layout.alignment: Qt.AlignLeft - text: "Copy Color" - - onClicked: colorDialog.open() - } - } -} diff --git a/widgets/config/LabeledComboBox.qml b/widgets/config/LabeledComboBox.qml deleted file mode 100644 index cd719e47..00000000 --- a/widgets/config/LabeledComboBox.qml +++ /dev/null @@ -1,61 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import QtQuick.Shapes 2.15 - -import QFRCDashboard - -ComboBox { - required property string label - - /** what property to bind to */ - required property string bindedProperty - - /** the target to bind the property to */ - required property var bindTarget - - /** choices for the combobox */ - required property var choices - - id: combo - model: choices - font.pixelSize: 15 - - function open() { - currentIndex = indexOfValue(bindTarget[bindedProperty]) - } - - function accept() { - bindTarget[bindedProperty] = currentText - } - - delegate: ItemDelegate { - id: delegate - - width: combo.width - contentItem: Text { - text: modelData - color: "white" - font.pixelSize: 15 - elide: Text.ElideRight - verticalAlignment: Text.AlignVCenter - } - highlighted: combo.highlightedIndex === index - } - - Text { - id: floatingLabel - text: label - color: Constants.palette.text - - font.pixelSize: 15 - - anchors { - left: parent.left - bottom: parent.top - - bottomMargin: -2 - leftMargin: 10 - } - } -} diff --git a/widgets/config/LabeledDoubleSpinBox.qml b/widgets/config/LabeledDoubleSpinBox.qml deleted file mode 100644 index e7a6f3f7..00000000 --- a/widgets/config/LabeledDoubleSpinBox.qml +++ /dev/null @@ -1,115 +0,0 @@ -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Layouts 2.15 - -import QtMultimedia - -import QFRCDashboard - -DoubleSpinBox { - id: spin - required property string label - - /** what property to bind to */ - required property string bindedProperty - - /** the target to bind the property to */ - required property var bindTarget - - from: -1E9 - to: 1E9 - - font.pixelSize: 18 - - function open() { - value = bindTarget[bindedProperty] - } - - function accept() { - bindTarget[bindedProperty] = value - } - - contentItem: SpinBox { - width: spin.availableWidth - height: spin.availableHeight - editable: spin.editable - inputMethodHints: spin.inputMethodHints - validator: spin.validator - from: -0x7FFFFFFF; to: 0x7FFFFFFF; - - contentItem: TextInput { - text: parent.textFromValue(parent.value, parent.locale) - - font: parent.font - color: Constants.palette.text - // selectionColor: "#21be2b" - // selectedTextColor: "#ffffff" - horizontalAlignment: Qt.AlignHCenter - verticalAlignment: Qt.AlignVCenter - - inputMethodHints: Qt.ImhFormattedNumbersOnly - } - - up.indicator: Rectangle { - x: spin.mirrored ? 0 : parent.width - width - height: parent.height - implicitWidth: 40 - implicitHeight: 40 - color: Constants.palette.bg - border.color: Constants.palette.text - - Text { - text: "+" - font.pixelSize: spin.font.pixelSize * 2 - color: Constants.palette.text - anchors.fill: parent - fontSizeMode: Text.Fit - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - } - - down.indicator: Rectangle { - x: spin.mirrored ? parent.width - width : 0 - height: parent.height - implicitWidth: 40 - implicitHeight: 40 - color: Constants.palette.bg - border.color: Constants.palette.text - - Text { - text: "-" - font.pixelSize: spin.font.pixelSize * 2 - color: Constants.palette.text - anchors.fill: parent - fontSizeMode: Text.Fit - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - } - - background: Rectangle { - color: Constants.palette.bg - width: parent.width - border.color: Constants.palette.text - border.width: 2 - radius: 5 - } - } - - Text { - id: floatingLabel - text: label - color: Constants.palette.text - - font.pixelSize: 15 - - anchors { - left: spin.left - bottom: spin.top - - bottomMargin: -2 - leftMargin: 10 - } - } -} diff --git a/widgets/config/LabeledSpinBox.qml b/widgets/config/LabeledSpinBox.qml deleted file mode 100644 index 68f67a16..00000000 --- a/widgets/config/LabeledSpinBox.qml +++ /dev/null @@ -1,106 +0,0 @@ -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Layouts 2.15 - -import QtMultimedia - -import QFRCDashboard - -SpinBox { - id: spin - required property string label - - /** what property to bind to */ - required property string bindedProperty - - /** the target to bind the property to */ - required property var bindTarget - - font.pixelSize: 18 - - from: 0 - to: 1E9 - - contentItem: TextInput { - text: parent.textFromValue(parent.value, parent.locale) - - font: parent.font - color: Constants.palette.text - // selectionColor: "#21be2b" - // selectedTextColor: "#ffffff" - horizontalAlignment: Qt.AlignHCenter - verticalAlignment: Qt.AlignVCenter - - inputMethodHints: Qt.ImhFormattedNumbersOnly - } - - function open() { - value = bindTarget[bindedProperty] - } - - function accept() { - bindTarget[bindedProperty] = value - } - - up.indicator: Rectangle { - x: spin.mirrored ? 0 : parent.width - width - height: parent.height - implicitWidth: 40 - implicitHeight: 40 - color: Constants.palette.bg - border.color: Constants.palette.text - - Text { - text: "+" - font.pixelSize: spin.font.pixelSize * 2 - color: Constants.palette.text - anchors.fill: parent - fontSizeMode: Text.Fit - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - } - - down.indicator: Rectangle { - x: spin.mirrored ? parent.width - width : 0 - height: parent.height - implicitWidth: 40 - implicitHeight: 40 - color: Constants.palette.bg - border.color: Constants.palette.text - - Text { - text: "-" - font.pixelSize: spin.font.pixelSize * 2 - color: Constants.palette.text - anchors.fill: parent - fontSizeMode: Text.Fit - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - } - - background: Rectangle { - color: Constants.palette.bg - width: parent.width - border.color: Constants.palette.text - border.width: 2 - radius: 5 - } - - Text { - id: floatingLabel - text: label - color: Constants.palette.text - - font.pixelSize: 15 - - anchors { - left: spin.left - bottom: spin.top - - bottomMargin: -2 - leftMargin: 10 - } - } -} diff --git a/widgets/config/LabeledTextField.qml b/widgets/config/LabeledTextField.qml deleted file mode 100644 index 1726bc5d..00000000 --- a/widgets/config/LabeledTextField.qml +++ /dev/null @@ -1,54 +0,0 @@ -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Layouts 2.15 - -import QtMultimedia - -import QFRCDashboard - -TextField { - required property string label - - /** what property to bind to */ - required property string bindedProperty - - /** the target to bind the property to */ - required property var bindTarget - - id: textField - font.pixelSize: 18 - - color: Constants.palette.text - - function open() { - text = bindTarget[bindedProperty] - } - - function accept() { - bindTarget[bindedProperty] = text - } - - background: Rectangle { - color: Constants.palette.bg - width: parent.width - border.color: Constants.palette.text - border.width: 2 - radius: 5 - } - - Text { - id: floatingLabel - text: label - color: Constants.palette.text - - font.pixelSize: 15 - - anchors { - left: textField.left - bottom: textField.top - - bottomMargin: -2 - leftMargin: 10 - } - } -} diff --git a/widgets/config/SectionHeader.qml b/widgets/config/SectionHeader.qml deleted file mode 100644 index 5affe6ce..00000000 --- a/widgets/config/SectionHeader.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick - -import QFRCDashboard - -Text { - width: parent.width - - /** What text to display */ - required property string label - - font.pixelSize: 18 - font.bold: true - color: Constants.palette.text - text: label - - Rectangle { - height: 2 - width: 350 - color: Constants.palette.text - - anchors { - top: parent.bottom - left: parent.left - - margins: 2 - } - } -} diff --git a/widgets/config/TitleComponent.qml b/widgets/config/TitleComponent.qml deleted file mode 100644 index da710a39..00000000 --- a/widgets/config/TitleComponent.qml +++ /dev/null @@ -1,31 +0,0 @@ -import QtQuick -import QtQuick.Controls - -import QFRCDashboard - -Rectangle { - color: Constants.accent - topLeftRadius: 20 - topRightRadius: 20 - - height: 40 - width: parent.width - - Text { - id: txt - - text: "Configure Widget" - font.pixelSize: 24 - font.bold: true - - color: "white" - - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - - anchors { - fill: parent - margins: 8 - } - } -} diff --git a/widgets/misc/CameraView.qml b/widgets/misc/CameraView.qml index 09809112..ffb39307 100644 --- a/widgets/misc/CameraView.qml +++ b/widgets/misc/CameraView.qml @@ -1,13 +1,11 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 -import QtQuick.Layouts 6.6 import QtMultimedia import QFRCDashboard BaseWidget { - id: widget property string item_topic property var item_url: "" @@ -19,14 +17,12 @@ BaseWidget { property int item_fps: 0 property int fpsMax: 240 - property int item_resW: 0 - property int item_resH: 0 + property size item_resolution: Qt.size(0, 0) onItem_urlChanged: player.resetSource() onItem_fpsChanged: player.resetSource() onItem_qualityChanged: player.resetSource() - onItem_resWChanged: player.resetSource() - onItem_resHChanged: player.resetSource() + onItem_resolutionChanged: player.resetSource() MenuItem { id: reconnItem @@ -37,17 +33,9 @@ BaseWidget { } function fixUrls(value) { - for (var i = 0; i < value.length; ++i) { - if (value[i].startsWith("mjpg:")) - value[i] = value[i].substring(5) - - if (value[i].includes("local")) { - value.splice(i, 1) - --i - } + for (let i = 0; i < value.length; ++i) { + if (value[i].startsWith("mjpg:")) value[i] = value[i].substring(5) } - - console.log(value) } function updateTopic(ntTopic, ntValue) { @@ -55,10 +43,7 @@ BaseWidget { urlChoices = ntValue fixUrls(urlChoices) - if (urlChoices.length > 0 && item_url === "") - item_url = urlChoices[0] - - player.resetSource() + if (urlChoices.length > 0 && item_url === "") item_url = urlChoices[0] } } @@ -102,12 +87,7 @@ BaseWidget { } function resetSource() { - source = Qt.url(item_url + (item_quality !== 0 ? "compression=" - + item_quality + "&" : "") - + (item_fps !== 0 ? "fps=" + item_fps + "&" : "") - + (item_resH !== Qt.size( - 0, 0) ? "resolution=" + item_resW + "x" - + item_resH : "")) + source = Qt.url(item_url + (item_quality !== 0 ? "compression=" + item_quality + "&" : "") + (item_fps !== 0 ? "fps=" + item_fps + "&" : "") + (item_resolution !== Qt.size(0, 0) ? "resolution=" + item_resolution.width + "x" + item_resolution.height : "")) } function reconnect() { @@ -138,164 +118,6 @@ BaseWidget { topicStore.subscribe(item_topic + "/streams") model.topic = item_topic - updateTopic(item_topic + "/streams", - topicStore.getValue(model.topic + "/streams")) - } - - BaseConfigDialog { - id: config - - height: 450 - - function openDialog() { - topicField.open() - titleFontField.open() - fpsField.open() - resHField.open() - resWField.open() - qualityField.open() - - open() - } - - onAccepted: { - topicField.accept() - titleFontField.accept() - fpsField.accept() - resHField.accept() - resWField.accept() - qualityField.accept() - } - - ColumnLayout { - id: layout - spacing: 25 - - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - right: parent.right - - topMargin: config.headerHeight + 12 - bottomMargin: 45 - - leftMargin: 5 - rightMargin: 5 - } - - SectionHeader { - label: "Font Settings" - } - - LabeledSpinBox { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - id: titleFontField - - label: "Title Font Size" - - bindedProperty: "item_titleFontSize" - bindTarget: widget - } - - SectionHeader { - label: "Stream Settings" - } - - RowLayout { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - // Layout.preferredWidth: 300 - - LabeledSpinBox { - Layout.fillWidth: true - - id: fpsField - - label: "FPS" - - bindedProperty: "item_fps" - bindTarget: widget - } - - Text { - font.pixelSize: 16 - text: "Resolution" - color: Constants.palette.text - } - - LabeledSpinBox { - Layout.fillWidth: true - id: resWField - - label: "Width" - - bindedProperty: "item_resW" - bindTarget: widget - } - - Text { - font.pixelSize: 18 - text: "x" - color: Constants.palette.text - } - - LabeledSpinBox { - Layout.fillWidth: true - id: resHField - - label: "Height" - - bindedProperty: "item_resH" - bindTarget: widget - } - } - - RowLayout { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - Text { - font.pixelSize: 16 - text: "Quality" - color: Constants.palette.text - } - - Slider { - Layout.fillWidth: true - id: qualityField - - from: 0 - to: 100 - stepSize: 10 - - function open() { - value = widget.item_quality - } - - function accept() { - widget.item_quality = value - } - } - } - - SectionHeader { - label: "NT Settings" - } - - LabeledTextField { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - id: topicField - - label: "Topic" - - bindedProperty: "item_topic" - bindTarget: widget - } - } + updateTopic(item_topic + "/streams", topicStore.getValue(model.topic + "/streams")) } } diff --git a/widgets/misc/ErrorsWidget.qml b/widgets/misc/ErrorsWidget.qml index 879ff48b..b0ea1165 100644 --- a/widgets/misc/ErrorsWidget.qml +++ b/widgets/misc/ErrorsWidget.qml @@ -1,11 +1,9 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 -import QtQuick.Layouts import QFRCDashboard BaseWidget { - id: widget property string item_topic property int item_fontSize: 15 @@ -72,89 +70,5 @@ BaseWidget { errors = topicStore.getValue(topic) listView.model = errors.length / 2 } - - BaseConfigDialog { - id: config - - height: 300 - - function openDialog() { - topicField.open() - titleFontField.open() - fontField.open() - - open() - } - - onAccepted: { - topicField.accept() - titleFontField.accept() - fontField.accept() - } - - ColumnLayout { - id: layout - spacing: 25 - - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - right: parent.right - - topMargin: config.headerHeight + 12 - bottomMargin: 45 - - leftMargin: 5 - rightMargin: 5 - } - - SectionHeader { - label: "Font Settings" - } - - RowLayout { - uniformCellSizes: true - - LabeledSpinBox { - Layout.fillWidth: true - - id: titleFontField - - label: "Title Font Size" - - bindedProperty: "item_titleFontSize" - bindTarget: widget - } - - LabeledDoubleSpinBox { - Layout.fillWidth: true - - id: fontField - - label: "Font Size" - - bindedProperty: "item_fontSize" - bindTarget: widget - } - } - - SectionHeader { - label: "NT Settings" - } - - LabeledTextField { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - id: topicField - - label: "Topic" - - bindedProperty: "item_topic" - bindTarget: widget - } - } - } } diff --git a/widgets/primitive/BoolWidget.qml b/widgets/primitive/BoolWidget.qml index c3bb46e3..fa351dbe 100644 --- a/widgets/primitive/BoolWidget.qml +++ b/widgets/primitive/BoolWidget.qml @@ -1,16 +1,18 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 -import QtQuick.Layouts import QFRCDashboard BaseWidget { - id: widget - property string item_topic property int item_checkboxSize: 20 + property list item_test: [] + + property string testValueType: "color" + property string testValueName: "Color" + Menu { id: switchMenu title: "Switch Widget..." @@ -68,88 +70,4 @@ BaseWidget { control.checked = topicStore.getValue(item_topic) } - - BaseConfigDialog { - id: config - - height: 300 - - function openDialog() { - topicField.open() - titleFontField.open() - checkboxField.open() - - open() - } - - onAccepted: { - topicField.accept() - titleFontField.accept() - checkboxField.accept() - } - - ColumnLayout { - id: layout - spacing: 25 - - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - right: parent.right - - topMargin: config.headerHeight + 12 - bottomMargin: 45 - - leftMargin: 5 - rightMargin: 5 - } - - SectionHeader { - label: "Font Settings" - } - - RowLayout { - uniformCellSizes: true - - LabeledSpinBox { - Layout.fillWidth: true - - id: titleFontField - - label: "Title Font Size" - - bindedProperty: "item_titleFontSize" - bindTarget: widget - } - - LabeledSpinBox { - Layout.fillWidth: true - - id: checkboxField - - label: "Checkbox Size" - - bindedProperty: "item_checkboxSize" - bindTarget: widget - } - } - - SectionHeader { - label: "NT Settings" - } - - LabeledTextField { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - id: topicField - - label: "Topic" - - bindedProperty: "item_topic" - bindTarget: widget - } - } - } } diff --git a/widgets/primitive/ColorWidget.qml b/widgets/primitive/ColorWidget.qml index ac1e789f..3a03ba09 100644 --- a/widgets/primitive/ColorWidget.qml +++ b/widgets/primitive/ColorWidget.qml @@ -1,12 +1,10 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 -import QtQuick.Layouts import QtQuick.Shapes 2.15 import QFRCDashboard BaseWidget { - id: widget property string item_topic property color item_falseColor: "#FF0000" @@ -83,120 +81,4 @@ BaseWidget { model.topic = item_topic updateTopic(model.topic, topicStore.getValue(model.topic)) } - - BaseConfigDialog { - id: config - - height: 475 - - function openDialog() { - topicField.open() - titleFontField.open() - shapeField.open() - trueField.open() - falseField.open() - - open() - } - - onAccepted: { - topicField.accept() - titleFontField.accept() - shapeField.accept() - trueField.accept() - falseField.accept() - } - - ColumnLayout { - id: layout - spacing: 25 - - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - right: parent.right - - topMargin: 50 - bottomMargin: 45 - - leftMargin: 5 - rightMargin: 5 - } - - SectionHeader { - label: "Font Settings" - } - - LabeledSpinBox { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - id: titleFontField - - label: "Title Font Size" - - bindedProperty: "item_titleFontSize" - bindTarget: widget - } - - SectionHeader { - label: "Color Settings" - } - - LabeledComboBox { - id: shapeField - - Layout.fillWidth: true - choices: shapeChoices - - label: "Shape" - - bindedProperty: "item_shape" - bindTarget: widget - } - - RowLayout { - Layout.fillWidth: true - - ColorField { - id: trueField - - Layout.fillWidth: true - - label: "True Color" - - bindedProperty: "item_trueColor" - bindTarget: widget - } - - ColorField { - id: falseField - - Layout.fillWidth: true - - label: "False Color" - - bindedProperty: "item_falseColor" - bindTarget: widget - } - } - - SectionHeader { - label: "NT Settings" - } - - LabeledTextField { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - id: topicField - - label: "Topic" - - bindedProperty: "item_topic" - bindTarget: widget - } - } - } } diff --git a/widgets/primitive/DoubleDialWidget.qml b/widgets/primitive/DoubleDialWidget.qml index 2f0c1d66..4ad764c5 100644 --- a/widgets/primitive/DoubleDialWidget.qml +++ b/widgets/primitive/DoubleDialWidget.qml @@ -1,21 +1,19 @@ import QtQuick import QtQuick.Controls 6.6 -import QtQuick.Layouts import QFRCDashboard BaseWidget { - id: widget property string item_topic property int item_fontSize: 15 property double item_stepSize: 0.1 - property double item_startAngle: -180 - property double item_endAngle: 180 + property double item_startAngle: 180 + property double item_endAngle: 540 property double item_lowerBound: 0 - property double item_upperBound: 100000.0 + property double item_upperBound: 1000.0 Menu { id: switchMenu @@ -161,173 +159,4 @@ BaseWidget { spin.value = topicStore.getValue(item_topic) dial.value = topicStore.getValue(item_topic) } - - BaseConfigDialog { - id: config - - height: 600 - - function openDialog() { - topicField.open() - titleFontField.open() - fontField.open() - - upField.open() - lowField.open() - stepField.open() - startField.open() - endField.open() - - open() - } - - onAccepted: { - topicField.accept() - titleFontField.accept() - fontField.accept() - upField.accept() - lowField.accept() - stepField.accept() - startField.accept() - endField.accept() - } - - ColumnLayout { - id: layout - spacing: 25 - - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - right: parent.right - - topMargin: config.headerHeight + 12 - bottomMargin: 45 - - leftMargin: 5 - rightMargin: 5 - } - - SectionHeader { - label: "Font Settings" - } - - RowLayout { - uniformCellSizes: true - - LabeledSpinBox { - Layout.fillWidth: true - - id: titleFontField - - label: "Title Font Size" - - bindedProperty: "item_titleFontSize" - bindTarget: widget - } - - LabeledSpinBox { - Layout.fillWidth: true - - id: fontField - - label: "Font Size" - - bindedProperty: "item_fontSize" - bindTarget: widget - } - } - - SectionHeader { - label: "Spin Box Settings" - } - - RowLayout { - uniformCellSizes: true - - LabeledDoubleSpinBox { - Layout.fillWidth: true - - id: lowField - - label: "Lower Bound" - - bindedProperty: "item_lowerBound" - bindTarget: widget - } - - LabeledDoubleSpinBox { - Layout.fillWidth: true - - id: upField - - label: "Upper Bound" - - bindedProperty: "item_upperBound" - bindTarget: widget - } - } - - LabeledDoubleSpinBox { - Layout.fillWidth: true - - id: stepField - - label: "Step Size" - - bindedProperty: "item_stepSize" - bindTarget: widget - - from: 0 - stepSize: 0.1 - } - - SectionHeader { - label: "Dial Settings" - } - - RowLayout { - uniformCellSizes: true - - LabeledDoubleSpinBox { - Layout.fillWidth: true - - id: startField - - label: "Start Angle" - - bindedProperty: "item_startAngle" - bindTarget: widget - } - - LabeledDoubleSpinBox { - Layout.fillWidth: true - - id: endField - - label: "End Angle" - - bindedProperty: "item_endAngle" - bindTarget: widget - } - } - - SectionHeader { - label: "NT Settings" - } - - LabeledTextField { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - id: topicField - - label: "Topic" - - bindedProperty: "item_topic" - bindTarget: widget - } - } - } } diff --git a/widgets/primitive/DoubleWidget.qml b/widgets/primitive/DoubleWidget.qml index 897feef7..625a1260 100644 --- a/widgets/primitive/DoubleWidget.qml +++ b/widgets/primitive/DoubleWidget.qml @@ -1,19 +1,16 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 -import QtQuick.Layouts import QFRCDashboard BaseWidget { - id: widget - property string item_topic property int item_fontSize: 15 - property double item_stepSize: 0.1 + property double item_lowerBound: 0 - property double item_upperBound: 100000.0 + property double item_upperBound: 1000.0 Menu { id: switchMenu @@ -81,139 +78,4 @@ BaseWidget { model.topic = item_topic spin.value = topicStore.getValue(item_topic) } - - BaseConfigDialog { - id: config - - height: 500 - - function openDialog() { - topicField.open() - titleFontField.open() - fontField.open() - - upField.open() - lowField.open() - stepField.open() - - open() - } - - onAccepted: { - topicField.accept() - titleFontField.accept() - fontField.accept() - upField.accept() - lowField.accept() - stepField.accept() - } - - ColumnLayout { - id: layout - spacing: 25 - - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - right: parent.right - - topMargin: config.headerHeight + 12 - bottomMargin: 45 - - leftMargin: 5 - rightMargin: 5 - } - - SectionHeader { - label: "Font Settings" - } - - RowLayout { - uniformCellSizes: true - - LabeledSpinBox { - Layout.fillWidth: true - - id: titleFontField - - label: "Title Font Size" - - bindedProperty: "item_titleFontSize" - bindTarget: widget - } - - LabeledSpinBox { - Layout.fillWidth: true - - id: fontField - - label: "Font Size" - - bindedProperty: "item_fontSize" - bindTarget: widget - } - } - - SectionHeader { - label: "Spin Box Settings" - } - - RowLayout { - uniformCellSizes: true - - LabeledDoubleSpinBox { - Layout.fillWidth: true - - id: lowField - - label: "Lower Bound" - - bindedProperty: "item_lowerBound" - bindTarget: widget - } - - LabeledDoubleSpinBox { - Layout.fillWidth: true - - id: upField - - label: "Upper Bound" - - bindedProperty: "item_upperBound" - bindTarget: widget - } - } - - LabeledDoubleSpinBox { - Layout.fillWidth: true - - id: stepField - - label: "Step Size" - - bindedProperty: "item_stepSize" - bindTarget: widget - - from: 0 - stepSize: 0.1 - } - - SectionHeader { - label: "NT Settings" - } - - LabeledTextField { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - id: topicField - - label: "Topic" - - bindedProperty: "item_topic" - bindTarget: widget - } - } - } } diff --git a/widgets/primitive/EnumWidget.qml b/widgets/primitive/EnumWidget.qml index 0ed44299..a8e60f60 100644 --- a/widgets/primitive/EnumWidget.qml +++ b/widgets/primitive/EnumWidget.qml @@ -1,12 +1,10 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts +import QtQuick 2.15 +import QtQuick.Controls 2.15 import QtQuick.Shapes 2.15 import QFRCDashboard BaseWidget { - id: widget property string item_topic // @disable-check M311 @@ -18,6 +16,9 @@ BaseWidget { property list item_colorMap: [] + property string colorMapValueType: "color" + property string colorMapValueName: "Color" + Menu { id: switchMenu title: "Switch Widget..." @@ -35,7 +36,7 @@ BaseWidget { let obj = item_colorMap[i]; if (obj["Value"] === value) { - return obj["Color"] + return obj[colorMapValueName] } } @@ -94,110 +95,4 @@ BaseWidget { updateTopic(model.topic, topicStore.getValue(model.topic)) } - - BaseConfigDialog { - id: config - - height: 450 - - function openDialog() { - topicField.open() - titleFontField.open() - colorTable.open() - shapeField.open() - - open() - } - - onAccepted: { - topicField.accept() - titleFontField.accept() - colorTable.accept() - shapeField.accept() - } - - ScrollView { - clip: true - - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - right: parent.right - - topMargin: 50 - bottomMargin: 45 - - leftMargin: 5 - rightMargin: 5 - } - - ColumnLayout { - id: layout - spacing: 25 - anchors.fill: parent - clip: true - - SectionHeader { - label: "Font Settings" - } - - LabeledSpinBox { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - id: titleFontField - - label: "Title Font Size" - - bindedProperty: "item_titleFontSize" - bindTarget: widget - } - - SectionHeader { - label: "Color Settings" - } - - ColorTable { - id: colorTable - - Layout.fillWidth: true - clip: true - - label: "Color Map" - - bindedProperty: "item_colorMap" - bindTarget: widget - } - - LabeledComboBox { - id: shapeField - - Layout.fillWidth: true - choices: shapeChoices - - label: "Shape" - - bindedProperty: "item_shape" - bindTarget: widget - } - - SectionHeader { - label: "NT Settings" - } - - LabeledTextField { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - id: topicField - - label: "Topic" - - bindedProperty: "item_topic" - bindTarget: widget - } - } - } - } } diff --git a/widgets/primitive/IntWidget.qml b/widgets/primitive/IntWidget.qml index bde29243..60dc6016 100644 --- a/widgets/primitive/IntWidget.qml +++ b/widgets/primitive/IntWidget.qml @@ -1,20 +1,14 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 -import QtQuick.Layouts import QFRCDashboard BaseWidget { - id: widget - property string item_topic property int item_fontSize: 15 property int item_stepSize: 1 - property int item_upperBound: 100000 - property int item_lowerBound: 0 - Menu { id: switchMenu title: "Switch Widget..." @@ -44,8 +38,6 @@ BaseWidget { value: 0 stepSize: item_stepSize - from: item_lowerBound - to: item_upperBound anchors { verticalCenter: parent.verticalCenter @@ -79,138 +71,4 @@ BaseWidget { model.topic = item_topic spin.value = topicStore.getValue(item_topic) } - - BaseConfigDialog { - id: config - - height: 500 - - function openDialog() { - topicField.open() - titleFontField.open() - fontField.open() - - upField.open() - lowField.open() - stepField.open() - - open() - } - - onAccepted: { - topicField.accept() - titleFontField.accept() - fontField.accept() - upField.accept() - lowField.accept() - stepField.accept() - } - - ColumnLayout { - id: layout - spacing: 25 - - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - right: parent.right - - topMargin: config.headerHeight + 12 - bottomMargin: 45 - - leftMargin: 5 - rightMargin: 5 - } - - SectionHeader { - label: "Font Settings" - } - - RowLayout { - uniformCellSizes: true - - LabeledSpinBox { - Layout.fillWidth: true - - id: titleFontField - - label: "Title Font Size" - - bindedProperty: "item_titleFontSize" - bindTarget: widget - } - - LabeledSpinBox { - Layout.fillWidth: true - - id: fontField - - label: "Font Size" - - bindedProperty: "item_fontSize" - bindTarget: widget - } - } - - SectionHeader { - label: "Spin Box Settings" - } - - RowLayout { - uniformCellSizes: true - - LabeledSpinBox { - Layout.fillWidth: true - - id: lowField - - label: "Lower Bound" - - bindedProperty: "item_lowerBound" - bindTarget: widget - } - - LabeledSpinBox { - Layout.fillWidth: true - - id: upField - - label: "Upper Bound" - - bindedProperty: "item_upperBound" - bindTarget: widget - } - } - - LabeledSpinBox { - Layout.fillWidth: true - - id: stepField - - label: "Step Size" - - bindedProperty: "item_stepSize" - bindTarget: widget - - from: 0 - } - - SectionHeader { - label: "NT Settings" - } - - LabeledTextField { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - id: topicField - - label: "Topic" - - bindedProperty: "item_topic" - bindTarget: widget - } - } - } } diff --git a/widgets/primitive/TextWidget.qml b/widgets/primitive/TextWidget.qml index 5772c2d0..ee7d4668 100644 --- a/widgets/primitive/TextWidget.qml +++ b/widgets/primitive/TextWidget.qml @@ -1,11 +1,9 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 -import QtQuick.Layouts import QFRCDashboard BaseWidget { - id: widget property string item_topic property int item_fontSize: 15 @@ -69,88 +67,4 @@ BaseWidget { model.topic = item_topic textField.text = topicStore.getValue(item_topic) } - - BaseConfigDialog { - id: config - - height: 300 - - function openDialog() { - topicField.open() - titleFontField.open() - fontField.open() - - open() - } - - onAccepted: { - topicField.accept() - titleFontField.accept() - fontField.accept() - } - - ColumnLayout { - id: layout - spacing: 25 - - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - right: parent.right - - topMargin: config.headerHeight + 12 - bottomMargin: 45 - - leftMargin: 5 - rightMargin: 5 - } - - SectionHeader { - label: "Font Settings" - } - - RowLayout { - uniformCellSizes: true - - LabeledSpinBox { - Layout.fillWidth: true - - id: titleFontField - - label: "Title Font Size" - - bindedProperty: "item_titleFontSize" - bindTarget: widget - } - - LabeledSpinBox { - Layout.fillWidth: true - - id: fontField - - label: "Font Size" - - bindedProperty: "item_fontSize" - bindTarget: widget - } - } - - SectionHeader { - label: "NT Settings" - } - - LabeledTextField { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - id: topicField - - label: "Topic" - - bindedProperty: "item_topic" - bindTarget: widget - } - } - } } diff --git a/widgets/sendable/Command.qml b/widgets/sendable/Command.qml index a54d83f3..ba64eca4 100644 --- a/widgets/sendable/Command.qml +++ b/widgets/sendable/Command.qml @@ -1,12 +1,10 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 -import QtQuick.Layouts +import QtQuick.Layouts 2.15 import QFRCDashboard BaseWidget { - id: widget - property string item_topic property int item_fontSize: 18 @@ -69,88 +67,4 @@ BaseWidget { cmdButton.update() } - - BaseConfigDialog { - id: config - - height: 300 - - function openDialog() { - topicField.open() - titleFontField.open() - fontField.open() - - open() - } - - onAccepted: { - topicField.accept() - titleFontField.accept() - fontField.accept() - } - - ColumnLayout { - id: layout - spacing: 25 - - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - right: parent.right - - topMargin: config.headerHeight + 12 - bottomMargin: 45 - - leftMargin: 5 - rightMargin: 5 - } - - SectionHeader { - label: "Font Settings" - } - - RowLayout { - uniformCellSizes: true - - LabeledSpinBox { - Layout.fillWidth: true - - id: titleFontField - - label: "Title Font Size" - - bindedProperty: "item_titleFontSize" - bindTarget: widget - } - - LabeledSpinBox { - Layout.fillWidth: true - - id: fontField - - label: "Font Size" - - bindedProperty: "item_fontSize" - bindTarget: widget - } - } - - SectionHeader { - label: "NT Settings" - } - - LabeledTextField { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - id: topicField - - label: "Topic" - - bindedProperty: "item_topic" - bindTarget: widget - } - } - } } diff --git a/widgets/sendable/FMSInfo.qml b/widgets/sendable/FMSInfo.qml index 2f741780..55c933e6 100644 --- a/widgets/sendable/FMSInfo.qml +++ b/widgets/sendable/FMSInfo.qml @@ -1,12 +1,11 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 -import QtQuick.Layouts +import QtQuick.Layouts 2.15 import QFDFlags import QFRCDashboard BaseWidget { - id: widget property string item_topic property int item_fontSize: 18 @@ -283,88 +282,4 @@ BaseWidget { stateText.update() gsm.update() } - - BaseConfigDialog { - id: config - - height: 300 - - function openDialog() { - topicField.open() - titleFontField.open() - fontField.open() - - open() - } - - onAccepted: { - topicField.accept() - titleFontField.accept() - fontField.accept() - } - - ColumnLayout { - id: layout - spacing: 25 - - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - right: parent.right - - topMargin: config.headerHeight + 12 - bottomMargin: 45 - - leftMargin: 5 - rightMargin: 5 - } - - SectionHeader { - label: "Font Settings" - } - - RowLayout { - uniformCellSizes: true - - LabeledSpinBox { - Layout.fillWidth: true - - id: titleFontField - - label: "Title Font Size" - - bindedProperty: "item_titleFontSize" - bindTarget: widget - } - - LabeledSpinBox { - Layout.fillWidth: true - - id: fontField - - label: "Font Size" - - bindedProperty: "item_fontSize" - bindTarget: widget - } - } - - SectionHeader { - label: "NT Settings" - } - - LabeledTextField { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - id: topicField - - label: "Topic" - - bindedProperty: "item_topic" - bindTarget: widget - } - } - } } diff --git a/widgets/sendable/StringChooser.qml b/widgets/sendable/StringChooser.qml index 91a7b907..9c7744d8 100644 --- a/widgets/sendable/StringChooser.qml +++ b/widgets/sendable/StringChooser.qml @@ -1,12 +1,10 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 -import QtQuick.Layouts +import QtQuick.Layouts 2.15 import QFRCDashboard BaseWidget { - id: widget - property string item_topic property int item_fontSize: 18 @@ -102,88 +100,4 @@ BaseWidget { topic = item_topic combo.update() } - - BaseConfigDialog { - id: config - - height: 300 - - function openDialog() { - topicField.open() - titleFontField.open() - fontField.open() - - open() - } - - onAccepted: { - topicField.accept() - titleFontField.accept() - fontField.accept() - } - - ColumnLayout { - id: layout - spacing: 25 - - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - right: parent.right - - topMargin: config.headerHeight + 12 - bottomMargin: 45 - - leftMargin: 5 - rightMargin: 5 - } - - SectionHeader { - label: "Font Settings" - } - - RowLayout { - uniformCellSizes: true - - LabeledSpinBox { - Layout.fillWidth: true - - id: titleFontField - - label: "Title Font Size" - - bindedProperty: "item_titleFontSize" - bindTarget: widget - } - - LabeledSpinBox { - Layout.fillWidth: true - - id: fontField - - label: "Font Size" - - bindedProperty: "item_fontSize" - bindTarget: widget - } - } - - SectionHeader { - label: "NT Settings" - } - - LabeledTextField { - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - - id: topicField - - label: "Topic" - - bindedProperty: "item_topic" - bindTarget: widget - } - } - } }