Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Kleopatra
Commits
d26810c9
Commit
d26810c9
authored
Nov 23, 2021
by
Ingo Klöcker
Browse files
Modernize API of make_actions_from_data()
Use a std::vector instead of a C array and template magic. GnuPG-bug-id: 5688
parent
b22938a6
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/mainwindow.cpp
View file @
d26810c9
...
...
@@ -417,7 +417,7 @@ void MainWindow::Private::setupActions()
KActionCollection
*
const
coll
=
q
->
actionCollection
();
const
action_data
action_data
[]
=
{
const
std
::
vector
<
action_data
>
action_data
=
{
// most have been MOVED TO keylistcontroller.cpp
// Tools menu
#ifndef Q_OS_WIN
...
...
@@ -466,7 +466,7 @@ void MainWindow::Private::setupActions()
// most have been MOVED TO keylistcontroller.cpp
};
make_actions_from_data
(
action_data
,
/*sizeof action_data / sizeof *action_data,*/
coll
);
make_actions_from_data
(
action_data
,
coll
);
if
(
!
Settings
().
groupsEnabled
())
{
if
(
auto
action
=
coll
->
action
(
QStringLiteral
(
"configure_groups"
)))
{
...
...
src/utils/action_data.cpp
View file @
d26810c9
...
...
@@ -51,9 +51,9 @@ QAction *Kleo::make_action_from_data(const action_data &ad, KActionCollection *c
return
a
;
}
void
Kleo
::
make_actions_from_data
(
const
action_data
*
ads
,
unsigned
int
size
,
KActionCollection
*
coll
)
void
Kleo
::
make_actions_from_data
(
const
std
::
vector
<
action_data
>
&
data
,
KActionCollection
*
coll
)
{
for
(
unsigned
int
i
=
0
;
i
<
size
;
++
i
)
{
coll
->
addAction
(
QLatin1String
(
a
ds
[
i
]
.
name
),
make_action_from_data
(
a
ds
[
i
]
,
coll
));
for
(
const
auto
&
actionData
:
data
)
{
coll
->
addAction
(
QLatin1String
(
a
ctionData
.
name
),
make_action_from_data
(
a
ctionData
,
coll
));
}
}
src/utils/action_data.h
View file @
d26810c9
...
...
@@ -30,13 +30,7 @@ struct action_data {
bool
enabled
;
};
void
make_actions_from_data
(
const
action_data
*
data
,
unsigned
int
numData
,
KActionCollection
*
collection
);
template
<
unsigned
int
N
>
inline
void
make_actions_from_data
(
const
action_data
(
&
data
)[
N
],
KActionCollection
*
collection
)
{
make_actions_from_data
(
data
,
N
,
collection
);
}
void
make_actions_from_data
(
const
std
::
vector
<
action_data
>
&
data
,
KActionCollection
*
collection
);
QAction
*
make_action_from_data
(
const
action_data
&
ad
,
KActionCollection
*
coll
);
QAction
*
createAction
(
const
action_data
&
ad
,
KActionCollection
*
coll
);
...
...
src/view/keylistcontroller.cpp
View file @
d26810c9
...
...
@@ -344,7 +344,7 @@ TabWidget *KeyListController::tabWidget() const
void
KeyListController
::
createActions
(
KActionCollection
*
coll
)
{
const
action_data
action_data
[]
=
{
const
std
::
vector
<
action_data
>
action_data
=
{
// File menu
{
"file_new_certificate"
,
i18n
(
"New Key Pair..."
),
QString
(),
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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