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
Utilities
Ark
Commits
37b3017b
Commit
37b3017b
authored
Apr 06, 2021
by
Nicolas Fella
Browse files
Port to KRecentFilesMenu
KRecentFilesAction will be deprecated
parent
f0a57e09
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/mainwindow.cpp
View file @
37b3017b
...
...
@@ -37,7 +37,7 @@
#include <KLocalizedString>
#include <KActionCollection>
#include <KStandardAction>
#include <KRecentFiles
Action
>
#include <KRecentFiles
Menu
>
#include <KSharedConfig>
#include <KConfigDialog>
#include <KXMLGUIFactory>
...
...
@@ -68,10 +68,6 @@ MainWindow::MainWindow(QWidget *)
MainWindow
::~
MainWindow
()
{
if
(
m_recentFilesAction
)
{
m_recentFilesAction
->
saveEntries
(
KSharedConfig
::
openConfig
()
->
group
(
"Recent Files"
));
}
guiFactory
()
->
removeClient
(
m_part
);
delete
m_part
;
m_part
=
nullptr
;
...
...
@@ -178,14 +174,9 @@ void MainWindow::setupActions()
actionCollection
()
->
addAction
(
QStringLiteral
(
"ark_file_open"
),
m_openAction
);
auto
quitAction
=
KStandardAction
::
quit
(
this
,
&
MainWindow
::
quit
,
this
);
actionCollection
()
->
addAction
(
QStringLiteral
(
"ark_quit"
),
quitAction
);
m_recentFilesAction
=
KStandardAction
::
openRecent
(
this
,
&
MainWindow
::
openUrl
,
this
);
actionCollection
()
->
addAction
(
QStringLiteral
(
"ark_file_open_recent"
),
m_recentFilesAction
);
m_recentFilesAction
->
setToolBarMode
(
KRecentFilesAction
::
MenuMode
);
m_recentFilesAction
->
setToolButtonPopupMode
(
QToolButton
::
DelayedPopup
);
m_recentFilesAction
->
setIconText
(
i18nc
(
"action, to open an archive"
,
"Open"
));
m_recentFilesAction
->
setToolTip
(
i18n
(
"Open an archive"
));
m_recentFilesAction
->
loadEntries
(
KSharedConfig
::
openConfig
()
->
group
(
"Recent Files"
));
m_recentFilesMenu
=
new
KRecentFilesMenu
(
this
);
actionCollection
()
->
addAction
(
QStringLiteral
(
"ark_file_open_recent"
),
m_recentFilesMenu
->
menuAction
());
connect
(
m_recentFilesMenu
,
&
KRecentFilesMenu
::
urlTriggered
,
this
,
&
MainWindow
::
openUrl
);
KStandardAction
::
preferences
(
this
,
&
MainWindow
::
showSettings
,
actionCollection
());
}
...
...
@@ -196,7 +187,7 @@ void MainWindow::updateActions()
Kerfuffle
::
PluginManager
pluginManager
;
m_newAction
->
setEnabled
(
!
iface
->
isBusy
()
&&
!
pluginManager
.
availableWritePlugins
().
isEmpty
());
m_openAction
->
setEnabled
(
!
iface
->
isBusy
());
m_recentFiles
Action
->
setEnabled
(
!
iface
->
isBusy
());
m_recentFiles
Menu
->
setEnabled
(
!
iface
->
isBusy
());
}
void
MainWindow
::
openArchive
()
...
...
@@ -294,7 +285,7 @@ void MainWindow::writeSettings()
void
MainWindow
::
addPartUrl
()
{
m_recentFiles
Action
->
addUrl
(
m_part
->
url
());
m_recentFiles
Menu
->
addUrl
(
m_part
->
url
());
}
void
MainWindow
::
newArchive
()
...
...
app/mainwindow.h
View file @
37b3017b
...
...
@@ -30,7 +30,7 @@ namespace KParts
class
ReadWritePart
;
}
class
KRecentFiles
Action
;
class
KRecentFiles
Menu
;
class
MainWindow
:
public
KParts
::
MainWindow
{
...
...
@@ -64,7 +64,7 @@ private:
void
setupActions
();
KParts
::
ReadWritePart
*
m_part
;
KRecentFiles
Action
*
m_recentFiles
Action
;
KRecentFiles
Menu
*
m_recentFiles
Menu
;
QAction
*
m_openAction
;
QAction
*
m_newAction
;
KParts
::
OpenUrlArguments
m_openArgs
;
...
...
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