Commit 4aa54c1b authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

ask only for confirm if some project docs open

parent c682038e
......@@ -208,26 +208,29 @@ KateProject *KateProjectPlugin::projectForDir(QDir dir, bool userSpecified)
bool KateProjectPlugin::closeProject(KateProject *project)
{
QList<KTextEditor::Document *> documents = KTextEditor::Editor::instance()->application()->documents();
QVector<KTextEditor::Document *> projectDocuments;
QWidget *window = KTextEditor::Editor::instance()->application()->activeMainWindow()->window();
for (int i = 0; i < documents.size(); i++)
if (QUrl(project->baseDir()).isParentOf(documents[i]->url().adjusted(QUrl::RemoveScheme)))
projectDocuments.push_back(documents[i]);
const QString title = i18n("Confirm project closing: %1", project->name());
const QString text = i18n("Do you want to close the project %1 and the related %2 open documents?", project->name(), projectDocuments.size());
if (QMessageBox::Yes == QMessageBox::question(window, title, text, QMessageBox::No | QMessageBox::Yes, QMessageBox::Yes)) {
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;
for (auto doc : KTextEditor::Editor::instance()->application()->documents())
if (QUrl(project->baseDir()).isParentOf(doc->url().adjusted(QUrl::RemoveScheme)))
projectDocuments.push_back(doc);
// if we have some documents open for this project, ask if we want to close, else just do it
if (!projectDocuments.isEmpty()) {
QWidget *window = KTextEditor::Editor::instance()->application()->activeMainWindow()->window();
const QString title = i18n("Confirm project closing: %1", project->name());
const QString text = i18n("Do you want to close the project %1 and the related %2 open documents?", project->name(), projectDocuments.size());
if (QMessageBox::Yes != QMessageBox::question(window, title, text, QMessageBox::No | QMessageBox::Yes, QMessageBox::Yes)) {
return false;
}
for (auto doc : projectDocuments)
KTextEditor::Editor::instance()->application()->closeDocument(doc);
}
Q_EMIT pluginViewProjectClosing(project);
if (m_projects.removeOne(project)) {
m_fileWatcher.removePath(QFileInfo(project->fileName()).canonicalPath());
delete project;
return true;
}
return false;
......
Markdown is supported
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