Skip to content
GitLab
Menu
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
568ac672
Commit
568ac672
authored
Apr 23, 2021
by
Krzysztof Stokop
Browse files
Added alert before project closing
parent
8b8f9cf7
Changes
2
Hide whitespace changes
Inline
Side-by-side
addons/project/kateprojectplugin.cpp
View file @
568ac672
...
...
@@ -21,6 +21,8 @@
#include <QCoreApplication>
#include <QFileInfo>
#include <QTime>
#include <QMessageBox>
#include <QString>
#include <vector>
...
...
@@ -193,19 +195,38 @@ KateProject *KateProjectPlugin::projectForDir(QDir dir)
bool
KateProjectPlugin
::
closeProject
(
KateProject
*
project
)
{
QList
<
KTextEditor
::
Document
*
>
documents
=
KTextEditor
::
Editor
::
instance
()
->
application
()
->
documents
();
QVector
<
KTextEditor
::
Document
*
>
projectDocuments
;
QString
text
=
i18n
(
"Documents will be closed:
\n
"
);
QString
title
=
i18n
(
"Confirm project closing: "
)
+
project
->
name
();
for
(
int
i
=
0
;
i
<
documents
.
size
();
i
++
)
{
if
(
QUrl
(
project
->
baseDir
()).
isParentOf
(
documents
[
i
]
->
url
().
adjusted
(
QUrl
::
RemoveScheme
)))
KTextEditor
::
Editor
::
instance
()
->
application
()
->
closeDocument
(
documents
[
i
]);
{
projectDocuments
.
push_back
(
documents
[
i
]);
text
+=
documents
[
i
]
->
url
().
adjusted
(
QUrl
::
RemoveScheme
).
toDisplayString
();
text
+=
i18n
(
"
\n
"
);
}
}
QMessageBox
confirmationBox
(
QMessageBox
::
Information
,
title
,
text
,
QMessageBox
::
Cancel
|
QMessageBox
::
Yes
);
confirmationBox
.
setDefaultButton
(
QMessageBox
::
Cancel
);
Q_EMIT
pluginViewProjectClosing
(
project
);
if
(
m_projects
.
removeOne
(
project
))
if
(
16384
==
confirmationBox
.
exec
())
//4194304 for QMessageBox::Cancel
{
m_fileWatcher
.
removePath
(
QFileInfo
(
project
->
fileName
()).
canonicalPath
());
delete
project
;
return
true
;
for
(
int
i
=
0
;
i
<
projectDocuments
.
size
();
i
++
)
KTextEditor
::
Editor
::
instance
()
->
application
()
->
closeDocument
(
projectDocuments
[
i
]);
Q_EMIT
pluginViewProjectClosing
(
project
);
if
(
m_projects
.
removeOne
(
project
))
{
m_fileWatcher
.
removePath
(
QFileInfo
(
project
->
fileName
()).
canonicalPath
());
delete
project
;
return
true
;
}
}
else
return
false
;
return
false
;
}
KateProject
*
KateProjectPlugin
::
projectForUrl
(
const
QUrl
&
url
)
...
...
addons/project/kateprojectpluginview.cpp
View file @
568ac672
...
...
@@ -114,7 +114,7 @@ KateProjectPluginView::KateProjectPluginView(KateProjectPlugin *plugin, KTextEdi
connect
(
m_projectsCombo
,
static_cast
<
void
(
QComboBox
::*
)(
int
)
>
(
&
QComboBox
::
currentIndexChanged
),
this
,
&
KateProjectPluginView
::
slotCurrentChanged
);
connect
(
m_reloadButton
,
&
QToolButton
::
clicked
,
this
,
&
KateProjectPluginView
::
slotProjectReload
);
//
connect(m_closeProjectButton, &QToolButton::clicked, this, &KateProjectPluginView::slotProjectAboutToClose);
connect
(
m_closeProjectButton
,
&
QToolButton
::
clicked
,
this
,
&
KateProjectPluginView
::
slotProjectAboutToClose
);
connect
(
m_plugin
,
&
KateProjectPlugin
::
pluginViewProjectClosing
,
this
,
&
KateProjectPluginView
::
slotProjectClose
);
connect
(
m_gitStatusRefreshButton
,
&
QToolButton
::
clicked
,
this
,
[
this
]
{
...
...
@@ -570,7 +570,7 @@ void KateProjectPluginView::slotProjectReload()
void
KateProjectPluginView
::
slotProjectAboutToClose
()
{
if
(
QWidget
*
current
=
m_stackedProjectViews
->
currentWidget
())
if
(
QWidget
*
current
=
m_stackedProjectViews
->
currentWidget
())
{
m_plugin
->
closeProject
(
static_cast
<
KateProjectView
*>
(
current
)
->
project
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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