Commit cfb1d16e authored by Laurent Montel's avatar Laurent Montel 😁

Move to stack

parent be67b309
......@@ -580,7 +580,7 @@ void AttachmentControllerBase::showContextMenu()
Q_EMIT refreshSelection();
const int numberOfParts(d->selectedParts.count());
QMenu *menu = new QMenu;
QMenu menu;
const bool enableEditAction = (numberOfParts == 1)
&& (!d->selectedParts.first()->isMessageOrMessageCollection());
......@@ -601,40 +601,39 @@ void AttachmentControllerBase::showContextMenu()
|| parentMimeType.contains(QStringLiteral("image/png"))
|| parentMimeType.contains(QStringLiteral("image/jpeg"))
) {
menu->addAction(d->viewContextAction);
menu.addAction(d->viewContextAction);
}
d->createOpenWithMenu(menu, d->selectedParts.first());
d->createOpenWithMenu(&menu, d->selectedParts.first());
}
menu->addAction(d->openContextAction);
menu.addAction(d->openContextAction);
}
if (enableEditAction) {
menu->addAction(d->editWithContextAction);
menu->addAction(d->editContextAction);
menu.addAction(d->editWithContextAction);
menu.addAction(d->editContextAction);
}
if (numberOfParts > 0) {
menu->addAction(d->removeContextAction);
menu.addAction(d->removeContextAction);
}
if (numberOfParts == 1) {
if (!d->selectedParts.first()->url().isEmpty()) {
menu->addAction(d->reloadAttachmentAction);
menu.addAction(d->reloadAttachmentAction);
}
menu->addAction(d->saveAsContextAction);
menu->addSeparator();
menu->addAction(d->propertiesContextAction);
menu.addAction(d->saveAsContextAction);
menu.addSeparator();
menu.addAction(d->propertiesContextAction);
}
const int nbAttachment = d->model->rowCount();
if (nbAttachment != numberOfParts) {
menu->addSeparator();
menu->addAction(d->selectAllAction);
menu.addSeparator();
menu.addAction(d->selectAllAction);
}
if (numberOfParts == 0) {
menu->addSeparator();
menu->addAction(d->addContextAction);
menu.addSeparator();
menu.addAction(d->addContextAction);
}
menu->exec(QCursor::pos());
delete menu;
menu.exec(QCursor::pos());
}
void AttachmentControllerBase::slotOpenWithDialog()
......
......@@ -642,17 +642,17 @@ bool ContactUidURLHandler::handleContextMenuRequest(const QUrl &url, const QPoin
return false;
}
QMenu *menu = new QMenu();
QMenu menu;
QAction *open
= menu->addAction(QIcon::fromTheme(QStringLiteral("view-pim-contacts")),
= menu.addAction(QIcon::fromTheme(QStringLiteral("view-pim-contacts")),
i18n("&Open in Address Book"));
#ifndef QT_NO_CLIPBOARD
QAction *copy
= menu->addAction(QIcon::fromTheme(QStringLiteral("edit-copy")),
= menu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")),
i18n("&Copy Email Address"));
#endif
QAction *a = menu->exec(p);
QAction *a = menu.exec(p);
if (a == open) {
runKAddressBook(url);
#ifndef QT_NO_CLIPBOARD
......@@ -666,7 +666,6 @@ bool ContactUidURLHandler::handleContextMenuRequest(const QUrl &url, const QPoin
}
#endif
}
delete menu;
return true;
}
......
......@@ -594,7 +594,7 @@ void ViewerPrivate::showAttachmentPopup(KMime::Content *node, const QString &nam
{
Q_UNUSED(name);
prepareHandleAttachment(node);
QMenu *menu = new QMenu();
QMenu menu;
bool deletedAttachment = false;
if (node->contentType(false)) {
deletedAttachment = (node->contentType()->mimeType() == "text/x-moz-deleted");
......@@ -602,14 +602,14 @@ void ViewerPrivate::showAttachmentPopup(KMime::Content *node, const QString &nam
const QString contentTypeStr = QLatin1String(node->contentType()->mimeType());
QAction *action
= menu->addAction(QIcon::fromTheme(QStringLiteral("document-open")), i18nc("to open",
= menu.addAction(QIcon::fromTheme(QStringLiteral("document-open")), i18nc("to open",
"Open"));
action->setEnabled(!deletedAttachment);
connect(action, &QAction::triggered, this, [this]() {
slotHandleAttachment(Viewer::Open);
});
if (!deletedAttachment) {
createOpenWithMenu(menu, contentTypeStr, true);
createOpenWithMenu(&menu, contentTypeStr, true);
}
QMimeDatabase mimeDb;
......@@ -623,7 +623,7 @@ void ViewerPrivate::showAttachmentPopup(KMime::Content *node, const QString &nam
|| parentMimeType.contains(QStringLiteral("image/png"))
|| parentMimeType.contains(QStringLiteral("image/jpeg"))
) {
action = menu->addAction(i18nc("to view something", "View"));
action = menu.addAction(i18nc("to view something", "View"));
action->setEnabled(!deletedAttachment);
connect(action, &QAction::triggered, this, [this]() {
slotHandleAttachment(Viewer::View);
......@@ -642,14 +642,14 @@ void ViewerPrivate::showAttachmentPopup(KMime::Content *node, const QString &nam
}
#endif
action = menu->addAction(QIcon::fromTheme(QStringLiteral("document-save-as")), i18n(
action = menu.addAction(QIcon::fromTheme(QStringLiteral("document-save-as")), i18n(
"Save As..."));
action->setEnabled(!deletedAttachment);
connect(action, &QAction::triggered, this, [this]() {
slotHandleAttachment(Viewer::Save);
});
action = menu->addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18n("Copy"));
action = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18n("Copy"));
action->setEnabled(!deletedAttachment);
connect(action, &QAction::triggered, this, [this]() {
slotHandleAttachment(Viewer::Copy);
......@@ -663,7 +663,7 @@ void ViewerPrivate::showAttachmentPopup(KMime::Content *node, const QString &nam
if (MessageViewer::MessageViewerSettings::self()->allowAttachmentEditing()) {
action
= menu->addAction(QIcon::fromTheme(QStringLiteral("document-properties")), i18n(
= menu.addAction(QIcon::fromTheme(QStringLiteral("document-properties")), i18n(
"Edit Attachment"));
connect(action, &QAction::triggered, this, [this]() {
slotHandleAttachment(Viewer::Edit);
......@@ -672,7 +672,7 @@ void ViewerPrivate::showAttachmentPopup(KMime::Content *node, const QString &nam
action->setEnabled(canChange);
}
action
= menu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")),
= menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")),
i18n("Delete Attachment"));
connect(action, &QAction::triggered, this, [this]() {
slotHandleAttachment(Viewer::Delete);
......@@ -697,13 +697,12 @@ void ViewerPrivate::showAttachmentPopup(KMime::Content *node, const QString &nam
slotHandleAttachment(Viewer::ReplyMessageToAll);
});
#endif
menu->addSeparator();
action = menu->addAction(i18n("Properties"));
menu.addSeparator();
action = menu.addAction(i18n("Properties"));
connect(action, &QAction::triggered, this, [this]() {
slotHandleAttachment(Viewer::Properties);
});
menu->exec(globalPos);
delete menu;
menu.exec(globalPos);
}
void ViewerPrivate::prepareHandleAttachment(KMime::Content *node)
......
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