diff --git a/src/imports/mvvmdatasyncquick/ChangeRemoteView11.qml b/src/imports/mvvmdatasyncquick/ChangeRemoteView11.qml new file mode 100644 index 0000000..7159631 --- /dev/null +++ b/src/imports/mvvmdatasyncquick/ChangeRemoteView11.qml @@ -0,0 +1,211 @@ +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Controls.Material 2.3 +import QtQuick.Controls.Universal 2.3 +import QtQuick.Layouts 1.3 +import de.skycoder42.QtDataSync 4.0 +import de.skycoder42.QtMvvm.Core 1.1 +import de.skycoder42.QtMvvm.Quick 1.1 +import de.skycoder42.QtMvvm.DataSync.Core 1.1 +import de.skycoder42.QtMvvm.Quick.Private 1.0 + +Page { + id: _changeRemoteView + property PChangeRemoteViewModel viewModel: null + + header: ContrastToolBar { + id: _toolBar + + RowLayout { + id: _toolLayout + anchors.fill: parent + spacing: 0 + + ActionButton { + id: _cancelButton + icon.name: "gtk-cancel" + icon.source: "qrc:/de/skycoder42/qtmvvm/quick/icons/ic_close.svg" + text: qsTr("Cancel") + onClicked: QuickPresenter.popView() + } + + ToolBarLabel { + id: _titleLabel + Layout.fillWidth: true + text: qsTr("Change Remote") + } + + ToolButton { + id: _syncButton + implicitHeight: 48 + text: qsTr("Change") + enabled: viewModel.valid + icon.width: 24 + icon.height: 24 + icon.name: "gtk-apply" + icon.source: "qrc:/de/skycoder42/qtmvvm/quick/icons/ic_check.svg" + display: AbstractButton.TextBesideIcon + rightPadding: 16 + + onClicked: { + if(viewModel.completeSetup()) + QuickPresenter.popView() + } + } + } + } + + Pane { + anchors.fill: parent + ColumnLayout { + id: _layout + anchors.fill: parent + + DecorLabel { + text: qsTr("Remote url:") + Layout.fillWidth: true + edit: _urlEdit + } + + TextField { + id: _urlEdit + Layout.fillWidth: true + + validator: UrlValidator { + allowedSchemes: ["ws", "wss"] + } + + MvvmBinding { + viewModel: _changeRemoteView.viewModel + viewModelProperty: "url" + view: _urlEdit + viewProperty: "text" + type: MvvmBinding.OneWayToViewModel + } + } + + DecorLabel { + text: qsTr("Access key:") + Layout.fillWidth: true + edit: _accessKeyEdit + } + + TextField { + id: _accessKeyEdit + Layout.fillWidth: true + echoMode: TextInput.Password + + MvvmBinding { + viewModel: _changeRemoteView.viewModel + viewModelProperty: "accessKey" + view: _accessKeyEdit + viewProperty: "text" + type: MvvmBinding.OneWayToViewModel + } + } + + DecorLabel { + text: qsTr("Keep-Alive timout:") + Layout.fillWidth: true + edit: _keepAliveEdit + } + + SpinBox { + id: _keepAliveEdit + Layout.fillWidth: true + editable: true + from: 1 + to: 1440 + + MvvmBinding { + viewModel: _changeRemoteView.viewModel + viewModelProperty: "accessKey" + view: _keepAliveEdit + viewProperty: "value" + } + } + + CheckBox { + id: _keepDataBox + text: qsTr("Keep data") + + MvvmBinding { + viewModel: _changeRemoteView.viewModel + viewModelProperty: "keepData" + view: _keepDataBox + viewProperty: "checked" + } + } + + DecorLabel { + text: qsTr("Extra Headers:") + Layout.fillWidth: true + edit: _headerScrollView + } + + ScrollView { + id: _headerScrollView + Layout.fillWidth: true + Layout.fillHeight: true + clip: true + + ListView { + id: _headerList + + model: viewModel.headerModel + + delegate: ItemDelegate { + width: _headerScrollView.width + text: qsTr("%1: %2").arg(key).arg(value) + + Button { + id: _rmButton + flat: true + icon.width: 24 + icon.height: 24 + icon.name: "user-trash" + icon.source: "qrc:/de/skycoder42/qtmvvm/quick/icons/ic_delete_forever.svg" + anchors.right: parent.right + implicitHeight: parent.height + implicitWidth: implicitHeight + + onClicked: viewModel.removeHeaderConfig(index) + } + } + + footer: RowLayout { + width: _headerScrollView.width + + TextField { + id: _keyEdit + placeholderText: qsTr("Key") + Layout.fillWidth: true + } + + TextField { + id: _valueEdit + placeholderText: qsTr("Value") + Layout.fillWidth: true + } + + Button { + id: _addButton + flat: true + enabled: _keyEdit.text !== "" + icon.width: 24 + icon.height: 24 + icon.name: "list-add" + icon.source: "qrc:/de/skycoder42/qtmvvm/quick/icons/ic_add.svg" + + onClicked: { + viewModel.addHeaderConfig(_keyEdit.text, _valueEdit.text); + _keyEdit.clear(); + _valueEdit.clear(); + } + } + } + } + } + } + } +} diff --git a/src/imports/mvvmdatasyncquick/ExportSetupView11.qml b/src/imports/mvvmdatasyncquick/ExportSetupView11.qml new file mode 100644 index 0000000..f1ffd48 --- /dev/null +++ b/src/imports/mvvmdatasyncquick/ExportSetupView11.qml @@ -0,0 +1,74 @@ +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.3 +import QtQuick.Window 2.2 +import de.skycoder42.QtMvvm.Core 1.1 +import de.skycoder42.QtMvvm.Quick 1.1 +import de.skycoder42.QtMvvm.DataSync.Core 1.1 + +AlertDialog { + id: _exportSetupView + + property PExportSetupViewModel viewModel: null + + title: viewModel.label + + ColumnLayout { + id: _layout + anchors.fill: parent + + CheckBox { + id: _trustBox + text: qsTr("Trusted") + Layout.fillWidth: true + + MvvmBinding { + viewModel: _exportSetupView.viewModel + viewModelProperty: "trusted" + view: _trustBox + viewProperty: "checked" + } + } + + CheckBox { + id: _includeBox + text: qsTr("Include Server") + Layout.fillWidth: true + + MvvmBinding { + viewModel: _exportSetupView.viewModel + viewModelProperty: "includeServer" + view: _includeBox + viewProperty: "checked" + } + } + + DecorLabel { + text: qsTr("Password:") + Layout.fillWidth: true + edit: _passwordEdit + enabled: viewModel.trusted + } + + TextField { + id: _passwordEdit + echoMode: TextInput.Password + Layout.fillWidth: true + enabled: viewModel.trusted + + MvvmBinding { + viewModel: _exportSetupView.viewModel + viewModelProperty: "password" + view: _passwordEdit + viewProperty: "text" + type: MvvmBinding.OneWayToViewModel + } + } + } + + standardButtons: Dialog.Ok | Dialog.Cancel + + onAccepted: viewModel.completeSetup() + + Component.onCompleted: standardButton(Dialog.Ok).enabled = Qt.binding(function(){ return viewModel.valid; }) +} diff --git a/src/imports/mvvmdatasyncquick/IdentityEditView11.qml b/src/imports/mvvmdatasyncquick/IdentityEditView11.qml new file mode 100644 index 0000000..ac6e1f1 --- /dev/null +++ b/src/imports/mvvmdatasyncquick/IdentityEditView11.qml @@ -0,0 +1,62 @@ +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.3 +import QtQuick.Window 2.2 +import de.skycoder42.QtMvvm.Core 1.1 +import de.skycoder42.QtMvvm.Quick 1.1 +import de.skycoder42.QtMvvm.DataSync.Core 1.1 + +AlertDialog { + id: _identityEditView + + property PIdentityEditViewModel viewModel: null + + title: qsTr("Edit Identity") + + ColumnLayout { + id: _layout + anchors.fill: parent + + DecorLabel { + text: qsTr("Device Name:") + Layout.fillWidth: true + edit: _nameEdit + } + + TextField { + id: _nameEdit + Layout.fillWidth: true + + MvvmBinding { + viewModel: _identityEditView.viewModel + viewModelProperty: "name" + view: _nameEdit + viewProperty: "text" + } + } + + DecorLabel { + id: _fpLabel + text: qsTr("Device Fingerprint:") + Layout.fillWidth: true + Layout.topMargin: 16 + edit: _fpText + } + + Label { + id: _fpText + text: viewModel.fingerPrint + Layout.fillWidth: true + wrapMode: Text.Wrap + verticalAlignment: Qt.AlignVCenter + font.pointSize: _fpLabel.font.pointSize * 0.8 + Layout.topMargin: 8 + } + } + + standardButtons: Dialog.Save | Dialog.Cancel + + onAccepted: viewModel.save() + + Component.onCompleted: standardButton(Dialog.Save).enabled = Qt.binding(function(){ return viewModel.valid; }) +} diff --git a/src/imports/mvvmdatasyncquick/NetworkExchangeView11.qml b/src/imports/mvvmdatasyncquick/NetworkExchangeView11.qml new file mode 100644 index 0000000..8959a5e --- /dev/null +++ b/src/imports/mvvmdatasyncquick/NetworkExchangeView11.qml @@ -0,0 +1,155 @@ +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Controls.Material 2.3 +import QtQuick.Controls.Universal 2.3 +import QtQuick.Layouts 1.3 +import de.skycoder42.QtDataSync 4.0 +import de.skycoder42.QtMvvm.Core 1.1 +import de.skycoder42.QtMvvm.Quick 1.1 +import de.skycoder42.QtMvvm.DataSync.Core 1.1 + +/*! @brief The view implementation for the QtMvvm::NetworkExchangeViewModel + * + * @extends QtQuick.Controls.Page + * + * @details This is the view used to present a network exchange view model. You can extend the + * class if you need to extend that view. + * + * @sa QtMvvm::NetworkExchangeViewModel + */ +Page { + id: _networkExchangeView + + /*! @brief The viewmodel to use + * + * @default{Injected} + * + * @accessors{ + * @memberAc{viewModel} + * @notifyAc{viewModelChanged()} + * } + * + * @sa QtMvvm::NetworkExchangeViewModel + */ + property NetworkExchangeViewModel viewModel: null + + header: ContrastToolBar { + ToolBarLabel { + id: _titleLabel + anchors.fill: parent + text: qsTr("Network Exchange") + } + } + + Pane { + anchors.fill: parent + ColumnLayout { + id: _layout + anchors.fill: parent + + DecorLabel { + text: qsTr("Port:") + Layout.fillWidth: true + edit: _portEdit + } + + SpinBox { + id: _portEdit + Layout.fillWidth: true + editable: true + from: 0 + to: 65535 + + MvvmBinding { + viewModel: _networkExchangeView.viewModel + viewModelProperty: "port" + view: _portEdit + viewProperty: "value" + } + } + + DecorLabel { + text: qsTr("Name:") + Layout.fillWidth: true + edit: _nameEdit + } + + TextField { + id: _nameEdit + Layout.fillWidth: true + + MvvmBinding { + viewModel: _networkExchangeView.viewModel + viewModelProperty: "deviceName" + view: _nameEdit + viewProperty: "text" + } + } + + Rectangle { + Layout.fillWidth: true + Layout.minimumHeight: 1 + Layout.maximumHeight: 1 + color: { + if(QuickPresenter.currentStyle === "Material") + return Material.foreground; + else if(QuickPresenter.currentStyle === "Universal") + return Universal.foreground; + else + return "black"; + } + } + + Switch { + id: _exchangeSwitch + text: qsTr("Exchange active:") + + MvvmBinding { + viewModel: _networkExchangeView.viewModel + viewModelProperty: "active" + view: _exchangeSwitch + viewProperty: "checked" + } + } + + ScrollView { + id: _exchangeScrollView + + Layout.fillWidth: true + Layout.fillHeight: true + clip: true + + ListView { + id: _exchangeList + + model: viewModel.sortedModel + delegate: ItemDelegate { + width: _exchangeScrollView.width + + contentItem: ColumnLayout { + id: _delegateLayout + spacing: 8 + + Label { + id: _nameLabel + Layout.fillWidth: true + text: name + } + + Label { + id: _addressLabel + font.pointSize: _nameLabel.font.pointSize * 0.8 + Layout.fillWidth: true + Layout.leftMargin: 8 + text: address + opacity: 0.75 + } + } + + onClicked: viewModel.exportTo(index) + } + } + } + } + } +} diff --git a/src/imports/mvvmdatasyncquick/mvvmdatasyncquick.pro b/src/imports/mvvmdatasyncquick/mvvmdatasyncquick.pro index abdb13c..ddab1b9 100644 --- a/src/imports/mvvmdatasyncquick/mvvmdatasyncquick.pro +++ b/src/imports/mvvmdatasyncquick/mvvmdatasyncquick.pro @@ -17,9 +17,13 @@ QML_FILES += \ DataSyncView.qml \ DataSyncView11.qml \ NetworkExchangeView.qml \ + NetworkExchangeView11.qml \ IdentityEditView.qml \ + IdentityEditView11.qml \ ExportSetupView.qml \ - ChangeRemoteView.qml + ExportSetupView11.qml \ + ChangeRemoteView.qml \ + ChangeRemoteView11.qml RESOURCES += \ qtmvvmdatasyncquick_plugin.qrc diff --git a/src/imports/mvvmdatasyncquick/qmldir b/src/imports/mvvmdatasyncquick/qmldir index 3336e06..0f33ba1 100644 --- a/src/imports/mvvmdatasyncquick/qmldir +++ b/src/imports/mvvmdatasyncquick/qmldir @@ -8,10 +8,14 @@ depends de.skycoder42.QtMvvm.Quick 1.0 internal SubButton SubButton.qml IdentityEditView 1.0 IdentityEditView.qml +IdentityEditView 1.1 IdentityEditView11.qml ExportSetupView 1.0 ExportSetupView.qml +ExportSetupView 1.1 ExportSetupView11.qml ChangeRemoteView 1.0 ChangeRemoteView.qml +ChangeRemoteView 1.1 ChangeRemoteView11.qml DataSyncView 1.0 DataSyncView.qml DataSyncView 1.1 DataSyncView11.qml NetworkExchangeView 1.0 NetworkExchangeView.qml +NetworkExchangeView 1.1 NetworkExchangeView11.qml diff --git a/src/imports/mvvmquick/DecorLabel.qml b/src/imports/mvvmquick/DecorLabel.qml new file mode 100644 index 0000000..84abf0d --- /dev/null +++ b/src/imports/mvvmquick/DecorLabel.qml @@ -0,0 +1,25 @@ +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Controls.Material 2.3 +import QtQuick.Controls.Universal 2.3 +import de.skycoder42.QtMvvm.Quick 1.1 + +Label { + id: _decorLabel + + property Item edit: _decorLabel.nextItemInFocusChain() + + readonly property bool editHasFocus: edit && edit.focus + + function highlightColor() { + if(QuickPresenter.currentStyle === "Material") + return Material.accentColor; + else if(QuickPresenter.currentStyle === "Universal") + return Universal.accent; + else + return palette.highlight; + } + + color: editHasFocus ? highlightColor() : palette.text + opacity: editHasFocus ? 1 : 0.5 +} diff --git a/src/imports/mvvmquick/mvvmquick.pro b/src/imports/mvvmquick/mvvmquick.pro index f460f49..25010ea 100644 --- a/src/imports/mvvmquick/mvvmquick.pro +++ b/src/imports/mvvmquick/mvvmquick.pro @@ -51,7 +51,8 @@ QML_FILES += \ SettingsView.qml \ SettingsView11.qml \ SearchBar.qml \ - RoundMenuButton.qml + RoundMenuButton.qml \ + DecorLabel.qml RESOURCES += \ qtmvvmquick_plugin.qrc diff --git a/src/imports/mvvmquick/qmldir b/src/imports/mvvmquick/qmldir index 4c7e47a..f66c088 100644 --- a/src/imports/mvvmquick/qmldir +++ b/src/imports/mvvmquick/qmldir @@ -25,6 +25,7 @@ MenuButton 1.0 MenuButton.qml SearchBar 1.1 SearchBar.qml RoundMenuButton 1.1 RoundMenuButton.qml +DecorLabel 1.1 DecorLabel.qml PresenterProgress 1.0 PresenterProgress.qml PresentingStackView 1.0 PresentingStackView.qml