Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
f051f32e
Commit
f051f32e
authored
Oct 22, 2022
by
Christoph Cullmann
🍨
Browse files
make it configurable if windows kill their documents on close
parent
21ee9e4a
Changes
3
Hide whitespace changes
Inline
Side-by-side
apps/lib/kateconfigdialog.cpp
View file @
f051f32e
...
...
@@ -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
());
...
...
apps/lib/katemainwindow.cpp
View file @
f051f32e
...
...
@@ -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
...
...
apps/lib/ui/sessionconfigwidget.ui
View file @
f051f32e
...
...
@@ -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>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment