Commit 6a987399 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use directly KRecentFilesMenu

parent 98848489
Pipeline #61761 passed with stage
in 24 minutes and 12 seconds
......@@ -41,7 +41,7 @@
#include <kio_version.h>
#include <KConfigGroup>
#include <KRecentFilesAction>
#include <KRecentFilesMenu>
#include <KSharedConfig>
#include <QContextMenuEvent>
......@@ -63,9 +63,6 @@ KTNEFMain::KTNEFMain(QWidget *parent)
KConfigGroup config(KSharedConfig::openConfig(), "Settings");
mDefaultDir = config.readPathEntry("defaultdir", QStringLiteral("/tmp/"));
config = KConfigGroup(KSharedConfig::openConfig(), "Recent Files");
mOpenRecentFileAction->loadEntries(config);
mLastDir = mDefaultDir;
// create personal temp extract dir
......@@ -102,7 +99,9 @@ void KTNEFMain::setupActions()
// File menu
KStandardAction::open(this, &KTNEFMain::openFile, actionCollection());
mOpenRecentFileAction = KStandardAction::openRecent(this, &KTNEFMain::openRecentFile, actionCollection());
mOpenRecentFileMenu = new KRecentFilesMenu(this);
actionCollection()->addAction(QStringLiteral("ktnef_file_open_recent"), mOpenRecentFileMenu->menuAction());
connect(mOpenRecentFileMenu, &KRecentFilesMenu::urlTriggered, this, &KTNEFMain::openRecentFile);
// Action menu
QAction *openAction = actionCollection()->addAction(QStringLiteral("view_file"));
......@@ -219,10 +218,7 @@ void KTNEFMain::openRecentFile(const QUrl &url)
void KTNEFMain::addRecentFile(const QUrl &url)
{
mOpenRecentFileAction->addUrl(url);
KConfigGroup config(KSharedConfig::openConfig(), "Recent Files");
mOpenRecentFileAction->saveEntries(config);
config.sync();
mOpenRecentFileMenu->addUrl(url);
}
void KTNEFMain::viewFile()
......
......@@ -19,7 +19,7 @@ class QActionGroup;
class QAction;
class QContextMenuEvent;
class QTreeWidgetItem;
class KRecentFilesAction;
class KRecentFilesMenu;
class QUrl;
namespace KTnef
......@@ -88,6 +88,6 @@ private:
QString mLastDir;
KTNEFView *mView = nullptr;
KTNEFParser *mParser = nullptr;
KRecentFilesAction *mOpenRecentFileAction = nullptr;
KRecentFilesMenu *mOpenRecentFileMenu = nullptr;
};
Q_DECLARE_METATYPE(KService::Ptr)
<?xml version="1.0"?>
<!DOCTYPE gui SYSTEM "kpartgui.dtd">
<gui name="kups" version="2">
<gui name="kups" version="3">
<MenuBar>
<Menu name="file" >
<text>&amp;File</text>
<Action name="ktnef_file_open_recent"/>
</Menu>
<Menu name="action"><text>&amp;Action</text>
<Action name="view_file" />
<Action name="view_file_as" />
......
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