Commit 1b8b1383 authored by Karel Slaný's avatar Karel Slaný

Passing standard buttons into MessageDialogue.

parent 887eb280
......@@ -38,7 +38,7 @@ Item {
/* Expose children. */
property alias dialogue: dialogue
signal dialogueClosed()
signal dialogueClosed(int button, int customButton)
Dialog {
id: dialogue
......@@ -46,6 +46,7 @@ Item {
property int icon: Dialogues.NO_ICON
property alias content: content
property int dlgButtons: Dialogues.NO_BUTTON
//visible: true /* Set from C++. */
title: ""
......@@ -109,9 +110,19 @@ Item {
}
}
onDlgButtonsChanged: {
var buttons = Dialog.NoButton
buttons |= (dlgButtons & Dialogues.OK) ? Dialog.Ok : Dialog.NoButton
buttons |= (dlgButtons & Dialogues.CANCEL) ? Dialog.Cancel : Dialog.NoButton
buttons |= (dlgButtons & Dialogues.YES) ? Dialog.Yes : Dialog.NoButton
buttons |= (dlgButtons & Dialogues.NO) ? Dialog.No : Dialog.NoButton
console.log("New buttons " + dlgButtons + " " + buttons)
dialogue.standardButtons = buttons
}
onVisibleChanged: {
if (!visible) {
root.dialogueClosed()
root.dialogueClosed(-1, -1)
}
}
}
......
......@@ -418,8 +418,7 @@ ApplicationWindow {
dlgObj.dialogue.title = title
dlgObj.dialogue.content.messageText.text = message
dlgObj.dialogue.content.infoMessageText.text = infoMessage
dlgObj.dialogue.standardButtons = StandardButton.Ok
dlgObj.dialogue.dlgButtons = buttons
/* Connect signals. */
dlgObj.dialogueClosed.connect(gatherDataAndDeleteObject);
......@@ -427,9 +426,9 @@ ApplicationWindow {
dlgObj.dialogue.open();
}
function gatherDataAndDeleteObject() {
function gatherDataAndDeleteObject(button, customButton) {
/* TODO -- Gather pressed button value. */
dlgEmitter.emitClosed(1, -1)
dlgEmitter.emitClosed(button, customButton)
console.log("Destroying dialogue.");
dlgObj.destroy();
......
......@@ -106,7 +106,7 @@ signals:
* should be displayed.
*/
void dlgMessage(int icon, const QString &title, const QString &message,
const QString &infoMessage);
const QString &infoMessage, int buttons);
/*!
* @brief This signal should be emitted when QML message dialogue
......
......@@ -43,7 +43,8 @@ void QmlMessageDialogue::errorMessage(QWindow *parent,
&dialogue, SLOT(dlgClosed(int, int)));
/* Cause QML window to pop up. */
emit QmlDlgHelper::dlgEmitter->dlgMessage(icon, title, text, infoText);
emit QmlDlgHelper::dlgEmitter->dlgMessage(icon, title, text, infoText,
Dialogues::OK);
if (!dialogue.m_alreadyReturned) {
dialogue.m_loop.exec();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment