diff --git a/src/dialogs/katedialogs.h b/src/dialogs/katedialogs.h --- a/src/dialogs/katedialogs.h +++ b/src/dialogs/katedialogs.h @@ -341,6 +341,7 @@ void ignoreTriggered(); void reloadTriggered(); void autoReloadTriggered(); + void closeTriggered(); private Q_SLOTS: /** diff --git a/src/dialogs/katedialogs.cpp b/src/dialogs/katedialogs.cpp --- a/src/dialogs/katedialogs.cpp +++ b/src/dialogs/katedialogs.cpp @@ -1291,6 +1291,12 @@ m_message->addAction(aReload); connect(aReload, SIGNAL(triggered()), this, SIGNAL(reloadTriggered())); } else { + QAction * closeFile = new QAction(i18n("&Close"), this); + closeFile->setIcon(QIcon::fromTheme(QStringLiteral("document-close"))); + closeFile->setToolTip(i18n("Close the file, discarding its content.")); + m_message->addAction(closeFile, false); + connect(closeFile, &QAction::triggered, this, &KateModOnHdPrompt::closeTriggered); + QAction * aSaveAs = new QAction(i18n("&Save As..."), this); aSaveAs->setIcon(QIcon::fromTheme(QStringLiteral("document-save-as"))); aSaveAs->setToolTip(i18n("Lets you select a location and save the file again.")); diff --git a/src/document/katedocument.h b/src/document/katedocument.h --- a/src/document/katedocument.h +++ b/src/document/katedocument.h @@ -989,6 +989,7 @@ private Q_SLOTS: void onModOnHdSaveAs(); + void onModOnHdClose(); void onModOnHdReload(); void onModOnHdAutoReload(); void onModOnHdIgnore(); diff --git a/src/document/katedocument.cpp b/src/document/katedocument.cpp --- a/src/document/katedocument.cpp +++ b/src/document/katedocument.cpp @@ -4280,6 +4280,7 @@ m_modOnHdHandler = new KateModOnHdPrompt(this, m_modOnHdReason, reasonedMOHString()); connect(m_modOnHdHandler.data(), &KateModOnHdPrompt::saveAsTriggered, this, &DocumentPrivate::onModOnHdSaveAs); + connect(m_modOnHdHandler.data(), &KateModOnHdPrompt::closeTriggered, this, &DocumentPrivate::onModOnHdClose); connect(m_modOnHdHandler.data(), &KateModOnHdPrompt::reloadTriggered, this, &DocumentPrivate::onModOnHdReload); connect(m_modOnHdHandler.data(), &KateModOnHdPrompt::autoReloadTriggered, this, &DocumentPrivate::onModOnHdAutoReload); connect(m_modOnHdHandler.data(), &KateModOnHdPrompt::ignoreTriggered, this, &DocumentPrivate::onModOnHdIgnore); @@ -4305,6 +4306,18 @@ } } +void KTextEditor::DocumentPrivate::onModOnHdClose() +{ + // avoid prompt in closeUrl() + m_fileChangedDialogsActivated = false; + + // close the file without prompt confirmation + closeUrl(); + + // Useful for kate only + closeDocumentInApplication(); +} + void KTextEditor::DocumentPrivate::onModOnHdReload() { m_modOnHd = false;