D17599: Confirm closing if multiple tabs are open.
noreply at phabricator.kde.org
Tue Jan 8 19:22:02 GMT 2019
dhaumann requested changes to this revision.
dhaumann added a comment.
This revision now requires changes to proceed.
Still requires some changes, see comments.
> shubham wrote in katemainwindow.cpp:1220
> how do I get the currently active KTextEditor::Document to pass to the closeDocument().
> Currently it closes last tab, just need to get the tab number of active tab, but how?
Please read a bit more in the code: KateMainWindow has a viewManager(), and this has a activeView(). Since you are currently in the KateMainWindow, you can simply write
auto view = viewManager()->activeView();
and you have the active KTextEditor::View, which will give you the document etc.
> dhaumann wrote in katemainwindow.cpp:1204
> This is wrong: we should not create new GUI widgets in a close event.
> Simply ask the Document manager (KateDocManager?) how many documents are open. You can find plenty of uses of the document manager in the code.
Well, now that you found KateApp::self(), the next step is also to first check whether the MainWindow is the last one to close, since we support multiple mainwindows (View > New Window).
That means, you have to also check:
&& KateApp::self()->mainWindowsCount() == 1
Otherwise the message box is raised even though the application is not shutting down.
To: shubham, dhaumann, #kate, cullmann, sars
Cc: ngraham, pino, kwrite-devel, hase, michaelh, demsking, cullmann, sars, dhaumann
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the KWrite-Devel