diff --git a/src/imports/mvvmquick/MsgDelegate.qml b/src/imports/mvvmquick/MsgDelegate.qml new file mode 100644 index 0000000..ab634ac --- /dev/null +++ b/src/imports/mvvmquick/MsgDelegate.qml @@ -0,0 +1,62 @@ +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.3 +import de.skycoder42.QtMvvm.Quick 1.1 + +ItemDelegate { + id: _msgDelegate + + property alias sourceComponent: _indicator.sourceComponent + property alias source: _indicator.source + + property string editDialogType: type + + signal showInput(string key, string title, string type, var defaultValue, var properties); + + text: title + + ToolTip.visible: pressed && tooltip != "" + ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval + ToolTip.text: tooltip + onPressAndHold: QuickPresenter.hapticLongPress() + + onClicked: showInput(key, title, editDialogType, inputValue, properties) + + contentItem: GridLayout { + columns: 2 + rows: 2 + + Label { + id: _titleLabel + text: _msgDelegate.text + Layout.row: 0 + Layout.column: 0 + font.bold: true + elide: Label.ElideRight + Layout.fillWidth: true + } + + Label { + id: _peviewLabel + visible: preview + Layout.row: 1 + Layout.column: 0 + text: preview + wrapMode: Text.WordWrap + Layout.fillWidth: true + } + + Loader { + id: _indicator + visible: item + asynchronous: false + clip: true + + Layout.row: 0 + Layout.column: 1 + Layout.rowSpan: 2 + Layout.minimumWidth: item ? implicitWidth : 0 + Layout.maximumWidth: item ? implicitWidth : 0 + } + } +} diff --git a/src/imports/mvvmquick/mvvmquick.pro b/src/imports/mvvmquick/mvvmquick.pro index 25010ea..db7e55b 100644 --- a/src/imports/mvvmquick/mvvmquick.pro +++ b/src/imports/mvvmquick/mvvmquick.pro @@ -52,7 +52,8 @@ QML_FILES += \ SettingsView11.qml \ SearchBar.qml \ RoundMenuButton.qml \ - DecorLabel.qml + DecorLabel.qml \ + MsgDelegate.qml RESOURCES += \ qtmvvmquick_plugin.qrc diff --git a/src/imports/mvvmquick/qmldir b/src/imports/mvvmquick/qmldir index f66c088..cf7f2c9 100644 --- a/src/imports/mvvmquick/qmldir +++ b/src/imports/mvvmquick/qmldir @@ -26,6 +26,7 @@ MenuButton 1.0 MenuButton.qml SearchBar 1.1 SearchBar.qml RoundMenuButton 1.1 RoundMenuButton.qml DecorLabel 1.1 DecorLabel.qml +MsgDelegate 1.1 MsgDelegate.qml PresenterProgress 1.0 PresenterProgress.qml PresentingStackView 1.0 PresentingStackView.qml diff --git a/src/mvvmquick/ListDelegate.qml b/src/mvvmquick/ListDelegate.qml index 5277820..2687f6d 100644 --- a/src/mvvmquick/ListDelegate.qml +++ b/src/mvvmquick/ListDelegate.qml @@ -3,35 +3,7 @@ import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 import de.skycoder42.QtMvvm.Quick 1.1 -ItemDelegate { +MsgDelegate { id: _listDelegate - - text: title - - signal showInput(string key, string title, string type, var defaultValue, var properties); - - ToolTip.visible: pressed && tooltip != "" - ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval - ToolTip.text: tooltip - onPressAndHold: QuickPresenter.hapticLongPress() - - contentItem: ColumnLayout { - Label { - id: _titleLabel - text: _listDelegate.text - font.bold: true - elide: Label.ElideRight - Layout.fillWidth: true - } - - Label { - id: _previewLabel - visible: preview - text: preview - wrapMode: Text.WordWrap - Layout.fillWidth: true - } - } - - onClicked: showInput(key, title, "radiolist", inputValue, properties) + editDialogType: "radiolist" } diff --git a/src/mvvmquick/MsgDelegate.qml b/src/mvvmquick/MsgDelegate.qml index 24ea166..7e72a99 100644 --- a/src/mvvmquick/MsgDelegate.qml +++ b/src/mvvmquick/MsgDelegate.qml @@ -1,37 +1,3 @@ -import QtQuick 2.10 -import QtQuick.Controls 2.3 -import QtQuick.Layouts 1.3 -import de.skycoder42.QtMvvm.Quick 1.1 +import de.skycoder42.QtMvvm.Quick 1.1 as QtMvvm -ItemDelegate { - id: _msgDelegate - - text: title - - signal showInput(string key, string title, string type, var defaultValue, var properties); - - ToolTip.visible: pressed && tooltip != "" - ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval - ToolTip.text: tooltip - onPressAndHold: QuickPresenter.hapticLongPress() - - contentItem: ColumnLayout { - Label { - id: _titleLabel - text: _msgDelegate.text - font.bold: true - elide: Label.ElideRight - Layout.fillWidth: true - } - - Label { - id: _previewLabel - visible: preview - text: preview - wrapMode: Text.WordWrap - Layout.fillWidth: true - } - } - - onClicked: showInput(key, title, type, inputValue, properties) -} +QtMvvm.MsgDelegate {}