Commit f051f32e authored by Christoph Cullmann's avatar Christoph Cullmann 🍨
Browse files

make it configurable if windows kill their documents on close

parent 21ee9e4a
......@@ -572,6 +572,10 @@ void KateConfigDialog::addSessionPage()
sessionConfigUi.openNewDocumentPerWindow->setChecked(cgGeneral.readEntry("Open untitled document for new window", false));
connect(sessionConfigUi.openNewDocumentPerWindow, &QCheckBox::toggled, this, &KateConfigDialog::slotChanged);
// When a window is closed, close all documents only visible in that window, too
sessionConfigUi.winClosesDocuments->setChecked(cgGeneral.readEntry("Close documents with window", true));
connect(sessionConfigUi.winClosesDocuments, &QCheckBox::toggled, this, &KateConfigDialog::slotChanged);
// Closing last file closes Kate
sessionConfigUi.modCloseAfterLast->setChecked(m_mainWindow->modCloseAfterLast());
connect(sessionConfigUi.modCloseAfterLast, &QCheckBox::toggled, this, &KateConfigDialog::slotChanged);
......@@ -733,6 +737,8 @@ void KateConfigDialog::slotApply()
cg.writeEntry("Open untitled document for new window", sessionConfigUi.openNewDocumentPerWindow->isChecked());
cg.writeEntry("Close documents with window", sessionConfigUi.winClosesDocuments->isChecked());
cg.writeEntry("Close After Last", sessionConfigUi.modCloseAfterLast->isChecked());
m_mainWindow->setModCloseAfterLast(sessionConfigUi.modCloseAfterLast->isChecked());
......
......@@ -81,6 +81,14 @@
// END
// shall windows close the documents only visible inside them if the are closed?
static bool winClosesDocuments()
{
const auto config = KSharedConfig::openConfig();
const KConfigGroup cgGeneral(config, "General");
return cgGeneral.readEntry("Close documents with window", true);
}
KateMwModOnHdDialog *KateMainWindow::s_modOnHdDialog = nullptr;
KateContainerStackedLayout::KateContainerStackedLayout(QWidget *parent)
......@@ -189,14 +197,16 @@ KateMainWindow::~KateMainWindow()
saveOptions();
// close all documents not visible in other windows, we did ask for permission in queryClose
auto docs = KateApp::self()->documentManager()->documentList();
docs.erase(std::remove_if(docs.begin(),
docs.end(),
[this](auto doc) {
return KateApp::self()->documentVisibleInOtherWindows(doc, this);
}),
docs.end());
KateApp::self()->documentManager()->closeDocuments(docs, false);
if (winClosesDocuments()) {
auto docs = KateApp::self()->documentManager()->documentList();
docs.erase(std::remove_if(docs.begin(),
docs.end(),
[this](auto doc) {
return KateApp::self()->documentVisibleInOtherWindows(doc, this);
}),
docs.end());
KateApp::self()->documentManager()->closeDocuments(docs, false);
}
// unregister mainwindow in app
KateApp::self()->removeMainWindow(this);
......@@ -638,7 +648,7 @@ bool KateMainWindow::queryClose()
// normal closing of window
// if we are not the last window, just close the documents we own
if (KateApp::self()->mainWindowsCount() > 1) {
return queryClose_internal(nullptr, this);
return winClosesDocuments() ? queryClose_internal(nullptr, this) : true;
}
// last one: check if we can close all documents, try run
......
......@@ -99,6 +99,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="winClosesDocuments">
<property name="text">
<string>Close documents with the window they belong to</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
Supports Markdown
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