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
KMail
Commits
b172ab64
Commit
b172ab64
authored
Nov 23, 2021
by
Laurent Montel
Browse files
Implement custom menu
parent
d008de57
Pipeline
#100209
passed with stage
in 23 minutes and 56 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
agents/unifiedmailboxagent/settingsdialog.cpp
View file @
b172ab64
...
...
@@ -20,6 +20,7 @@
#include
<KConfigGroup>
#include
<KLocalizedString>
#include
<KMessageBox>
#include
<QMenu>
#include
<memory>
...
...
@@ -49,7 +50,7 @@ SettingsDialog::SettingsDialog(const KSharedConfigPtr &config, UnifiedMailboxMan
h
->
addLayout
(
v
);
auto
addButton
=
new
QPushButton
(
QIcon
::
fromTheme
(
QStringLiteral
(
"list-add-symbolic"
)),
i18n
(
"Add"
));
v
->
addWidget
(
addButton
);
con
nect
(
addButton
,
&
QPushButton
::
clicked
,
this
,
[
this
]()
{
con
st
auto
addMailBox
=
[
this
]()
{
auto
mailbox
=
std
::
make_unique
<
UnifiedMailbox
>
();
auto
editor
=
new
UnifiedMailboxEditor
(
mailbox
.
get
(),
mConfig
,
this
);
if
(
editor
->
exec
())
{
...
...
@@ -59,7 +60,9 @@ SettingsDialog::SettingsDialog(const KSharedConfigPtr &config, UnifiedMailboxMan
mBoxManager
.
saveBoxes
();
}
delete
editor
;
});
};
connect
(
addButton
,
&
QPushButton
::
clicked
,
this
,
addMailBox
);
auto
editButton
=
new
QPushButton
(
QIcon
::
fromTheme
(
QStringLiteral
(
"entry-edit"
)),
i18n
(
"Modify"
));
editButton
->
setEnabled
(
false
);
v
->
addWidget
(
editButton
);
...
...
@@ -115,6 +118,30 @@ SettingsDialog::SettingsDialog(const KSharedConfigPtr &config, UnifiedMailboxMan
auto
box
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Close
,
this
);
connect
(
box
,
&
QDialogButtonBox
::
rejected
,
this
,
&
SettingsDialog
::
reject
);
l
->
addWidget
(
box
);
view
->
setContextMenuPolicy
(
Qt
::
CustomContextMenu
);
connect
(
view
,
&
QListView
::
customContextMenuRequested
,
this
,
[
=
](
const
QPoint
&
pos
)
{
Q_UNUSED
(
pos
);
const
auto
mboxSelected
=
view
->
selectionModel
()
->
selectedIndexes
();
QMenu
menu
(
this
);
QAction
*
addAction
=
menu
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"list-add-symbolic"
)),
i18n
(
"Add"
));
QAction
*
removeAction
=
nullptr
;
QAction
*
editAction
=
nullptr
;
if
(
!
mboxSelected
.
isEmpty
())
{
editAction
=
menu
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"entry-edit"
)),
i18n
(
"Modify"
));
menu
.
addSeparator
();
removeAction
=
menu
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"list-remove-symbolic"
)),
i18n
(
"Remove"
));
}
QAction
*
result
=
menu
.
exec
(
QCursor
::
pos
());
if
(
result
)
{
if
(
result
==
addAction
)
{
addMailBox
();
}
else
if
(
result
==
removeAction
)
{
removeMailBox
();
}
else
if
(
result
==
editAction
)
{
modifyMailBox
();
}
}
});
loadBoxes
();
readConfig
();
...
...
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