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
PIM
KMail
Commits
6a987399
Commit
6a987399
authored
May 13, 2021
by
Laurent Montel
😁
Browse files
Use directly KRecentFilesMenu
parent
98848489
Pipeline
#61761
passed with stage
in 24 minutes and 12 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ktnef/src/ktnefmain.cpp
View file @
6a987399
...
...
@@ -41,7 +41,7 @@
#include <kio_version.h>
#include <KConfigGroup>
#include <KRecentFiles
Action
>
#include <KRecentFiles
Menu
>
#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
()
...
...
ktnef/src/ktnefmain.h
View file @
6a987399
...
...
@@ -19,7 +19,7 @@ class QActionGroup;
class
QAction
;
class
QContextMenuEvent
;
class
QTreeWidgetItem
;
class
KRecentFiles
Action
;
class
KRecentFiles
Menu
;
class
QUrl
;
namespace
KTnef
...
...
@@ -88,6 +88,6 @@ private:
QString
mLastDir
;
KTNEFView
*
mView
=
nullptr
;
KTNEFParser
*
mParser
=
nullptr
;
KRecentFiles
Action
*
mOpenRecentFile
Action
=
nullptr
;
KRecentFiles
Menu
*
mOpenRecentFile
Menu
=
nullptr
;
};
Q_DECLARE_METATYPE
(
KService
::
Ptr
)
ktnef/src/ktnefui.rc
View file @
6a987399
<?xml version="1.0"?>
<!DOCTYPE gui SYSTEM "kpartgui.dtd">
<gui
name=
"kups"
version=
"
2
"
>
<gui
name=
"kups"
version=
"
3
"
>
<MenuBar>
<Menu
name=
"file"
>
<text>
&
File
</text>
<Action
name=
"ktnef_file_open_recent"
/>
</Menu>
<Menu
name=
"action"
><text>
&
Action
</text>
<Action
name=
"view_file"
/>
<Action
name=
"view_file_as"
/>
...
...
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