Browse Source

bug fix: new project modal dialog

cl-refactor
yann300 10 years ago
parent
commit
8946df118b
  1. 129
      mix/qml/NewProjectDialog.qml

129
mix/qml/NewProjectDialog.qml

@ -5,96 +5,104 @@ import QtQuick.Dialogs 1.2
import QtQuick.Window 2.0 import QtQuick.Window 2.0
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.1
Dialog { Item
id: newProjectWin {
modality: Qt.ApplicationModal
width: 640
height: 120
visible: false
property alias projectTitle: titleField.text
readonly property string projectPath: "file://" + pathField.text
property alias pathFieldText: pathField.text
signal accepted signal accepted
function open() { function open() {
newProjectWin.setX((Screen.width - width) / 2); newProjectWin.setX((Screen.width - width) / 2);
newProjectWin.setY((Screen.height - height) / 2); newProjectWin.setY((Screen.height - height) / 2);
visible = true; newProjectWin.visible = true;
titleField.focus = true; titleField.focus = true;
} }
function close() { function close() {
visible = false; newProjectWin.visible = false;
} }
function acceptAndClose() { function acceptAndClose() {
close(); close();
accepted(); accepted();
} }
contentItem: Rectangle {
anchors.fill: parent Dialog {
GridLayout id: newProjectWin
{ modality: Qt.ApplicationModal
id: dialogContent
columns: 2 width: 640
height: 120
visible: false
property alias projectTitle: titleField.text
readonly property string projectPath: "file://" + pathField.text
property alias pathFieldText: pathField.text
contentItem: Rectangle {
anchors.fill: parent anchors.fill: parent
anchors.margins: 10 GridLayout
rowSpacing: 10 {
columnSpacing: 10 id: dialogContent
columns: 2
anchors.fill: parent
anchors.margins: 10
rowSpacing: 10
columnSpacing: 10
Label { Label {
text: qsTr("Title") text: qsTr("Title")
}
TextField {
id: titleField
focus: true
Layout.fillWidth: true
Keys.onReturnPressed: {
if (okButton.enabled)
acceptAndClose();
} }
}
Label {
text: qsTr("Path")
}
RowLayout {
TextField { TextField {
id: pathField id: titleField
focus: true
Layout.fillWidth: true Layout.fillWidth: true
Keys.onReturnPressed: { Keys.onReturnPressed: {
if (okButton.enabled) if (okButton.enabled)
acceptAndClose(); acceptAndClose();
} }
} }
Button {
text: qsTr("Browse")
onClicked: createProjectFileDialog.open()
}
}
RowLayout Label {
{ text: qsTr("Path")
anchors.bottom: parent.bottom }
anchors.right: parent.right; RowLayout {
TextField {
Button { id: pathField
id: okButton; Layout.fillWidth: true
enabled: titleField.text != "" && pathField.text != "" Keys.onReturnPressed: {
text: qsTr("OK"); if (okButton.enabled)
onClicked: { acceptAndClose();
acceptAndClose(); }
}
Button {
text: qsTr("Browse")
onClicked: createProjectFileDialog.open()
} }
} }
Button {
text: qsTr("Cancel"); RowLayout
onClicked: close(); {
anchors.bottom: parent.bottom
anchors.right: parent.right;
Button {
id: okButton;
enabled: titleField.text != "" && pathField.text != ""
text: qsTr("OK");
onClicked: {
acceptAndClose();
}
}
Button {
text: qsTr("Cancel");
onClicked: close();
}
} }
} }
} }
Component.onCompleted: pathField.text = fileIo.homePath
} }
FileDialog { FileDialog {
@ -111,5 +119,4 @@ Dialog {
pathField.text = u; pathField.text = u;
} }
} }
Component.onCompleted: pathField.text = fileIo.homePath
} }

Loading…
Cancel
Save