Skycoder42
7 years ago
16 changed files with 279 additions and 23 deletions
@ -0,0 +1,42 @@ |
|||
import QtQuick 2.10 |
|||
import QtQuick.Controls 2.3 |
|||
import QtQuick.Layouts 1.3 |
|||
import de.skycoder42.QtMvvm.Core 1.0 |
|||
import de.skycoder42.QtMvvm.Quick 1.0 |
|||
import de.skycoder42.quickextras 2.0 |
|||
import de.skycoder42.QtMvvm.Sample 1.0 |
|||
|
|||
AlertDialog { |
|||
id: resultDialog |
|||
|
|||
property ResultViewModel viewModel: null |
|||
|
|||
title: qsTr("Enter something") |
|||
|
|||
ColumnLayout { |
|||
anchors.fill: parent |
|||
|
|||
Label { |
|||
text: qsTr("Enter a result to be reported as event to the main view:") |
|||
wrapMode: Text.WordWrap |
|||
Layout.fillWidth: true |
|||
} |
|||
|
|||
TextField { |
|||
id: resultEdit |
|||
Layout.fillWidth: true |
|||
selectByMouse: true |
|||
|
|||
MvvmBinding { |
|||
viewModel: resultDialog.viewModel |
|||
viewModelProperty: "result" |
|||
view: resultEdit |
|||
viewProperty: "text" |
|||
} |
|||
} |
|||
} |
|||
|
|||
standardButtons: Dialog.Ok | Dialog.Cancel |
|||
|
|||
onAccepted: viewModel.done() |
|||
} |
@ -1,11 +1,114 @@ |
|||
import QtQuick 2.10 |
|||
import QtQuick.Controls 2.3 |
|||
import QtQuick.Layouts 1.3 |
|||
import de.skycoder42.QtMvvm.Core 1.0 |
|||
import de.skycoder42.QtMvvm.Quick 1.0 |
|||
import de.skycoder42.quickextras 2.0 |
|||
import de.skycoder42.QtMvvm.Sample 1.0 |
|||
|
|||
Rectangle { |
|||
property QtObject viewModel: null |
|||
Page { |
|||
id: sampleView |
|||
property SampleViewModel viewModel: null |
|||
|
|||
anchors.fill: parent |
|||
header: ActionBar { |
|||
showMenuButton: false |
|||
title: qsTr("Sample") |
|||
|
|||
color: "red" |
|||
moreMenu: Menu { |
|||
Action { |
|||
text: qsTr("Another &Input") |
|||
onTriggered: viewModel.getInput() |
|||
} |
|||
Action { |
|||
text: qsTr("Add &Files") |
|||
onTriggered: viewModel.getFiles() |
|||
} |
|||
|
|||
Component.onCompleted: console.log(viewModel) |
|||
MenuSeparator {} |
|||
|
|||
Action { |
|||
text: qsTr("&About") |
|||
onTriggered: viewModel.about() |
|||
} |
|||
} |
|||
} |
|||
|
|||
PresenterProgress {} |
|||
|
|||
Pane { |
|||
anchors.fill: parent |
|||
|
|||
GridLayout { |
|||
columns: 2 |
|||
anchors.fill: parent |
|||
|
|||
Label { |
|||
text: qsTr("Name:") |
|||
} |
|||
|
|||
TextField { |
|||
id: nameEdit |
|||
Layout.fillWidth: true |
|||
selectByMouse: true |
|||
|
|||
MvvmBinding { |
|||
viewModel: sampleView.viewModel |
|||
view: nameEdit |
|||
viewModelProperty: "name" |
|||
viewProperty: "text" |
|||
} |
|||
} |
|||
|
|||
Label { |
|||
text: qsTr("Active:") |
|||
} |
|||
|
|||
Switch { |
|||
id: activeSwitch |
|||
Layout.alignment: Qt.AlignLeft |
|||
|
|||
MvvmBinding { |
|||
viewModel: sampleView.viewModel |
|||
view: activeSwitch |
|||
viewModelProperty: "active" |
|||
viewProperty: "checked" |
|||
} |
|||
} |
|||
|
|||
Label { |
|||
text: qsTr("Events:") |
|||
} |
|||
|
|||
RowLayout { |
|||
Layout.fillWidth: true |
|||
|
|||
Button { |
|||
text: qsTr("&Clear") |
|||
onClicked: viewModel.clearEvents() |
|||
} |
|||
|
|||
Button { |
|||
text: qsTr("Get &Result") |
|||
onClicked: viewModel.getResult() |
|||
} |
|||
} |
|||
|
|||
ListView { |
|||
id: lView |
|||
Layout.columnSpan: 2 |
|||
Layout.fillWidth: true |
|||
Layout.fillHeight: true |
|||
clip: true |
|||
|
|||
ScrollBar.vertical: ScrollBar {} |
|||
|
|||
model: viewModel.eventsModel |
|||
|
|||
delegate: ItemDelegate { |
|||
width: parent.width |
|||
text: viewModel.eventsModel.data(viewModel.eventsModel.index(index, 0)) //because "display" is not accessible |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
@ -0,0 +1,20 @@ |
|||
{ |
|||
"dependencies": [ |
|||
{ |
|||
"package": "de.skycoder42.quickextras", |
|||
"provider": "qpm", |
|||
"version": "2.1.0" |
|||
} |
|||
], |
|||
"license": { |
|||
"file": "", |
|||
"name": "" |
|||
}, |
|||
"prcFile": "", |
|||
"priFile": "", |
|||
"priIncludes": [ |
|||
], |
|||
"publishers": { |
|||
}, |
|||
"source": false |
|||
} |
@ -0,0 +1,30 @@ |
|||
import QtQuick 2.10 |
|||
import QtQuick.Controls 2.3 |
|||
|
|||
QtObject { |
|||
id: _popPresenter |
|||
|
|||
property var popups: [] |
|||
|
|||
function presentPopup(root, popup) { |
|||
popup.parent = root; |
|||
popup.closed.connect(function() { |
|||
var index = popups.indexOf(popup); |
|||
if(index > -1) { |
|||
popup.destroy(); |
|||
popups.splice(index, 1); |
|||
} |
|||
}); |
|||
popup.open(); |
|||
popups.push(popup); |
|||
return true; |
|||
} |
|||
|
|||
function closeAction() { |
|||
if(popups.length > 0) { |
|||
popups[popups.length - 1].close(); |
|||
return true; |
|||
} else |
|||
return false; |
|||
} |
|||
} |
Loading…
Reference in new issue