Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit e451d579 authored by Jonathan Marten's avatar Jonathan Marten

Update the trash/delete action for the separate reader window

If a message which is in a trash folder is opened, the menu/toolbar
action would show "Move to trash", even though performing the action
would delete the message permanently.  Correctly reflect the action in
this case.

New function KMail::Util::setActionTrashOrDelete() to modify the action,
copied from KMMainWidget::updateFolderMenu().

Differential Revision: https://phabricator.kde.org/D11284
parent a41c23fe
......@@ -3938,10 +3938,7 @@ void KMMainWidget::updateFolderMenu()
const bool isInTrashFolder = (mCurrentFolderSettings && CommonKernel->folderIsTrash(mCurrentCollection));
QAction *moveToTrash = akonadiStandardAction(Akonadi::StandardMailActionManager::MoveToTrash);
moveToTrash->setText(isInTrashFolder ? i18nc("@action Hard delete, bypassing trash", "&Delete") : i18n("&Move to Trash"));
moveToTrash->setIcon(isInTrashFolder ? QIcon::fromTheme(QStringLiteral("edit-delete")) : QIcon::fromTheme(QStringLiteral("user-trash")));
//Use same text as in Text property. Change it in kf5
moveToTrash->setToolTip(isInTrashFolder ? i18nc("@action Hard delete, bypassing trash", "Delete") : i18n("Move to Trash"));
KMail::Util::setActionTrashOrDelete(moveToTrash, isInTrashFolder);
mTrashThreadAction->setIcon(isInTrashFolder ? QIcon::fromTheme(QStringLiteral("edit-delete")) : QIcon::fromTheme(QStringLiteral("user-trash")));
mTrashThreadAction->setText(isInTrashFolder ? i18n("Delete T&hread") : i18n("M&ove Thread to Trash"));
......
......@@ -160,6 +160,9 @@ void KMReaderMainWin::showMessage(const QString &encoding, const Akonadi::Item &
mReaderWin->viewer()->headerStylePlugin()->headerStyle()->setReadOnlyMessage(!canChange);
}
const bool isInTrashFolder = mParentCollection.isValid() ? CommonKernel->folderIsTrash(mParentCollection) : false;
QAction *moveToTrash = actionCollection()->action(QStringLiteral("move_to_trash"));
KMail::Util::setActionTrashOrDelete(moveToTrash, isInTrashFolder);
menuBar()->show();
toolBar(QStringLiteral("mainToolBar"))->show();
}
......
......@@ -44,6 +44,7 @@
#include <kmime/kmime_message.h>
#include <kmessagebox.h>
#include <klocalizedstring.h>
#include "kmail_debug.h"
#include <QAction>
......@@ -176,3 +177,13 @@ void Util::addQActionHelpText(QAction *action, const QString &text)
action->setWhatsThis(text);
}
}
void Util::setActionTrashOrDelete(QAction *action, bool isInTrashFolder)
{
if (action) {
action->setText(isInTrashFolder ? i18nc("@action Hard delete, bypassing trash", "&Delete") : i18n("&Move to Trash"));
action->setIcon(isInTrashFolder ? QIcon::fromTheme(QStringLiteral("edit-delete")) : QIcon::fromTheme(QStringLiteral("user-trash")));
//Use same text as in Text property. Change it in kf5
action->setToolTip(isInTrashFolder ? i18nc("@action Hard delete, bypassing trash", "Delete") : i18n("Move to Trash"));
}
}
......@@ -78,6 +78,13 @@ bool mailingListHelp(const QSharedPointer<MailCommon::FolderSettings> &fd, const
void lastEncryptAndSignState(bool &lastEncrypt, bool &lastSign, const KMime::Message::Ptr &msg);
void addQActionHelpText(QAction *action, const QString &text);
/**
* Set an action's text, icon etc. as appropriate for whether a message is
* in the trash folder (delete permanently) or any other (move to trash).
*/
void setActionTrashOrDelete(QAction *action, bool isInTrashFolder);
}
}
......
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