Make application close upon Ctrl+Q
ClosedPublic

Authored by apol on Sep 15 2016, 2:48 PM.

Details

Summary

Or whatever suggested by Qt.

Diff Detail

Repository
R169 Kirigami
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
apol updated this revision to Diff 6763.Sep 15 2016, 2:48 PM
apol retitled this revision from to Make application close upon Ctrl+Q.
apol updated this object.
apol edited the test plan for this revision. (Show Details)
apol added reviewers: Kirigami, mart.
Restricted Application added a project: Kirigami. · View Herald TranscriptSep 15 2016, 2:48 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
broulik added inline comments.
src/controls/AbstractApplicationWindow.qml
293

StandardKey.Quit should work (in Qt 5.2 iirc)

apol updated this revision to Diff 6764.Sep 15 2016, 2:53 PM

Turns out it was already there

apol marked an inline comment as done.Sep 15 2016, 2:53 PM

Thanks!

So, Ctrl+Q always quits without confirmation? What about having a

singal aboutToQuit(var event)

and then do:

onActivated: {
    var event = {accepted: false}
    aboutToQuit(event);
    if (!event.accepted) {
        Qt.quit();
    }
}

Then an app can

onAboutToQuit: {
    if (hasUnsavedChanges) {
        event.accepted = true;
        // ask for confirmation
    }
}
apol updated this object.Sep 15 2016, 2:54 PM

So, Ctrl+Q always quits without confirmation? What about having a

singal aboutToQuit(var event)

and then do:

onActivated: {
    var event = {accepted: false}
    aboutToQuit(event);
    if (!event.accepted) {
        Qt.quit();
    }
}

Then an app can

onAboutToQuit: {
    if (hasUnsavedChanges) {
        event.accepted = true;
        // ask for confirmation
    }
}

That could be interesting but could be out of scope for the patch? There's other ways the application can be closed.

broulik accepted this revision.Sep 15 2016, 2:57 PM
broulik added a reviewer: broulik.

Ok, so if this is a general problem with Kirigami, fine, but needs to be addressed eventually.

This revision is now accepted and ready to land.Sep 15 2016, 2:57 PM
mart edited edge metadata.Sep 15 2016, 5:53 PM

I would like it done as Kai's suggestion, I would call the signal quitRequested?
about the other ways to quit, i guess it's window closing, which i don't think we can intercept in any way?

apol updated this revision to Diff 6767.Sep 15 2016, 10:19 PM
apol edited edge metadata.

Use Window.close rather than Qt.quit

Gives the opportunity to the application to do something about the
closing

mart added a comment.Sep 16 2016, 9:25 AM

hmm, can it be intercepted since Applicationwindow can't be subclassed from c++? i can think about an ugly event filter, but ouch..

This revision was automatically updated to reflect the committed changes.