Commit c4b20b89 authored by Christoph Cullmann's avatar Christoph Cullmann

register files not only at recently opened files menu but globally, too

BUG: 420504
parent 32a201a5
......@@ -51,6 +51,7 @@
#include <KMimeTypeTrader>
#include <KMultiTabBar>
#include <KOpenWithDialog>
#include <KRecentDocument>
#include <KRecentFilesAction>
#include <KRun>
#include <KSharedConfig>
......@@ -1282,3 +1283,17 @@ KateQuickOpenModel::List KateMainWindow::quickOpenListMode() const
{
return m_quickOpen->listMode();
}
void KateMainWindow::addRecentOpenedFile(const QUrl &url)
{
// skip non-existing urls for untitled documents
if (url.isEmpty()) {
return;
}
// to our local list, aka menu
m_fileOpenRecent->addUrl(url);
// to the global "Recent Document Menu", see bug 420504
KRecentDocument::add(url);
}
......@@ -315,10 +315,11 @@ public:
void setQuickOpenListMode(KateQuickOpenModelList mode);
KateQuickOpenModelList quickOpenListMode() const;
KRecentFilesAction *fileOpenRecent() const
{
return m_fileOpenRecent;
}
/**
* add given url to list of recently opened files
* @param url url that got opened
*/
void addRecentOpenedFile(const QUrl &url);
//
// KTextEditor::MainWindow interface, get called by invokeMethod from our wrapper object!
......
......@@ -292,9 +292,7 @@ KTextEditor::Document *KateViewManager::openUrl(const QUrl &url, const QString &
{
KTextEditor::Document *doc = KateApp::self()->documentManager()->openUrl(url, encoding, isTempFile, docInfo);
if (!doc->url().isEmpty()) {
m_mainWindow->fileOpenRecent()->addUrl(doc->url());
}
m_mainWindow->addRecentOpenedFile(doc->url());
if (activate) {
activateView(doc);
......@@ -308,9 +306,7 @@ KTextEditor::Document *KateViewManager::openUrls(const QList<QUrl> &urls, const
const QList<KTextEditor::Document *> docs = KateApp::self()->documentManager()->openUrls(urls, encoding, isTempFile, docInfo);
for (const KTextEditor::Document *doc : docs) {
if (!doc->url().isEmpty()) {
m_mainWindow->fileOpenRecent()->addUrl(doc->url());
}
m_mainWindow->addRecentOpenedFile(doc->url());
}
return docs.isEmpty() ? nullptr : docs.last();
......@@ -324,9 +320,7 @@ KTextEditor::View *KateViewManager::openUrlWithView(const QUrl &url, const QStri
return nullptr;
}
if (!doc->url().isEmpty()) {
m_mainWindow->fileOpenRecent()->addUrl(doc->url());
}
m_mainWindow->addRecentOpenedFile(doc->url());
activateView(doc);
......@@ -422,9 +416,7 @@ void KateViewManager::documentsDeleted(const QList<KTextEditor::Document *> &)
void KateViewManager::documentSavedOrUploaded(KTextEditor::Document *doc, bool)
{
if (!doc->url().isEmpty()) {
m_mainWindow->fileOpenRecent()->addUrl(doc->url());
}
m_mainWindow->addRecentOpenedFile(doc->url());
}
KTextEditor::View *KateViewManager::createView(KTextEditor::Document *doc, KateViewSpace *vs)
......
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