Commit eb1150e1 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Remove duplicate code

parent 2c59e94d
......@@ -20,7 +20,7 @@
#include "headerstyle.h"
#include "headerstyleinterface.h"
#include "headerstyleplugin.h"
#include "utils/messageviewerutil_p.h"
#include <KActionMenu>
#include <QAction>
#include <KToggleAction>
......@@ -43,11 +43,7 @@ QList<KToggleAction *> HeaderStyleInterface::action() const
void HeaderStyleInterface::addHelpTextAction(QAction *act, const QString &text)
{
act->setStatusTip(text);
act->setToolTip(text);
if (act->whatsThis().isEmpty()) {
act->setWhatsThis(text);
}
MessageViewer::Util::addHelpTextAction(act, text);
}
void HeaderStyleInterface::addActionToMenu(KActionMenu *menu, QActionGroup *actionGroup)
......
......@@ -24,6 +24,7 @@
#include "header/headerstyle.h"
#include "header/headerstrategy.h"
#include "messageviewer_debug.h"
#include "utils/messageviewerutil_p.h"
#include "messageviewer/messageviewersettings.h"
#include <KActionMenu>
......@@ -43,7 +44,6 @@ public:
void readSettings();
void writeSettings(const QString &pluginName);
void initialize(KActionCollection *ac);
void addHelpTextAction(QAction *act, const QString &text);
void setPluginName(const QString &pluginName);
QHash<QString, MessageViewer::HeaderStyleInterface *> lstInterface;
QActionGroup *group = nullptr;
......@@ -51,15 +51,6 @@ public:
HeaderStyleMenuManager *q = nullptr;
};
void HeaderStyleMenuManagerPrivate::addHelpTextAction(QAction *act, const QString &text)
{
act->setStatusTip(text);
act->setToolTip(text);
if (act->whatsThis().isEmpty()) {
act->setWhatsThis(text);
}
}
void HeaderStyleMenuManagerPrivate::setPluginName(const QString &pluginName)
{
MessageViewer::HeaderStyleInterface *interface = lstInterface.value(pluginName);
......@@ -138,7 +129,7 @@ void HeaderStyleMenuManagerPrivate::initialize(KActionCollection *ac)
if (ac) {
ac->addAction(QStringLiteral("view_headers"), headerMenu);
}
addHelpTextAction(headerMenu, i18n("Choose display style of message headers"));
MessageViewer::Util::addHelpTextAction(headerMenu, i18n("Choose display style of message headers"));
group = new QActionGroup(q);
const QVector<MessageViewer::HeaderStylePlugin *> lstPlugin
......
......@@ -578,3 +578,12 @@ bool Util::excludeExtraHeader(const QString &s)
}
return false;
}
void Util::addHelpTextAction(QAction *act, const QString &text)
{
act->setStatusTip(text);
act->setToolTip(text);
if (act->whatsThis().isEmpty()) {
act->setWhatsThis(text);
}
}
......@@ -54,6 +54,7 @@ Q_REQUIRED_RESULT KMime::Content::List allContents(const KMime::Content *message
Q_REQUIRED_RESULT bool saveContents(QWidget *parent, const KMime::Content::List &contents, QList<QUrl> &urlList);
Q_REQUIRED_RESULT bool saveContent(QWidget *parent, KMime::Content *content, const QUrl &url);
void addHelpTextAction(QAction *act, const QString &text);
}
}
#endif
......@@ -1593,34 +1593,34 @@ void ViewerPrivate::createActions()
// attachment style
KActionMenu *attachmentMenu = new KActionMenu(i18nc("View->", "&Attachments"), this);
ac->addAction(QStringLiteral("view_attachments"), attachmentMenu);
addHelpTextAction(attachmentMenu, i18n("Choose display style of attachments"));
MessageViewer::Util::addHelpTextAction(attachmentMenu, i18n("Choose display style of attachments"));
QActionGroup *group = new QActionGroup(this);
KToggleAction *raction = new KToggleAction(i18nc("View->attachments->", "&As Icons"), this);
ac->addAction(QStringLiteral("view_attachments_as_icons"), raction);
connect(raction, &QAction::triggered, this, &ViewerPrivate::slotIconicAttachments);
addHelpTextAction(raction, i18n("Show all attachments as icons. Click to see them."));
MessageViewer::Util::addHelpTextAction(raction, i18n("Show all attachments as icons. Click to see them."));
group->addAction(raction);
attachmentMenu->addAction(raction);
raction = new KToggleAction(i18nc("View->attachments->", "&Smart"), this);
ac->addAction(QStringLiteral("view_attachments_smart"), raction);
connect(raction, &QAction::triggered, this, &ViewerPrivate::slotSmartAttachments);
addHelpTextAction(raction, i18n("Show attachments as suggested by sender."));
MessageViewer::Util::addHelpTextAction(raction, i18n("Show attachments as suggested by sender."));
group->addAction(raction);
attachmentMenu->addAction(raction);
raction = new KToggleAction(i18nc("View->attachments->", "&Inline"), this);
ac->addAction(QStringLiteral("view_attachments_inline"), raction);
connect(raction, &QAction::triggered, this, &ViewerPrivate::slotInlineAttachments);
addHelpTextAction(raction, i18n("Show all attachments inline (if possible)"));
MessageViewer::Util::addHelpTextAction(raction, i18n("Show all attachments inline (if possible)"));
group->addAction(raction);
attachmentMenu->addAction(raction);
raction = new KToggleAction(i18nc("View->attachments->", "&Hide"), this);
ac->addAction(QStringLiteral("view_attachments_hide"), raction);
connect(raction, &QAction::triggered, this, &ViewerPrivate::slotHideAttachments);
addHelpTextAction(raction, i18n("Do not show attachments in the message viewer"));
MessageViewer::Util::addHelpTextAction(raction, i18n("Do not show attachments in the message viewer"));
group->addAction(raction);
attachmentMenu->addAction(raction);
......@@ -1629,7 +1629,7 @@ void ViewerPrivate::createActions()
ac->addAction(QStringLiteral("view_attachments_headeronly"), mHeaderOnlyAttachmentsAction);
connect(mHeaderOnlyAttachmentsAction, &QAction::triggered,
this, &ViewerPrivate::slotHeaderOnlyAttachments);
addHelpTextAction(mHeaderOnlyAttachmentsAction,
MessageViewer::Util::addHelpTextAction(mHeaderOnlyAttachmentsAction,
i18n("Show Attachments only in the header of the mail"));
group->addAction(mHeaderOnlyAttachmentsAction);
attachmentMenu->addAction(mHeaderOnlyAttachmentsAction);
......@@ -1751,7 +1751,7 @@ void ViewerPrivate::createActions()
ac->setDefaultShortcut(mToggleDisplayModeAction, QKeySequence(Qt::SHIFT + Qt::Key_H));
connect(mToggleDisplayModeAction, &QAction::triggered,
this, &ViewerPrivate::slotToggleHtmlMode);
addHelpTextAction(mToggleDisplayModeAction,
MessageViewer::Util::addHelpTextAction(mToggleDisplayModeAction,
i18n("Toggle display mode between HTML and plain text"));
// Load external reference
......@@ -1761,7 +1761,7 @@ void ViewerPrivate::createActions()
QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_R));
connect(loadExternalReferenceAction, &QAction::triggered,
this, &ViewerPrivate::slotLoadExternalReference);
addHelpTextAction(loadExternalReferenceAction,
MessageViewer::Util::addHelpTextAction(loadExternalReferenceAction,
i18n("Load external references from the Internet for this message."));
mSpeakTextAction = new QAction(i18n("Speak Text"), this);
......@@ -3125,13 +3125,6 @@ void ViewerPrivate::slotFormSubmittedForbidden()
mSubmittedFormWarning->showWarning();
}
void ViewerPrivate::addHelpTextAction(QAction *act, const QString &text)
{
act->setStatusTip(text);
act->setToolTip(text);
act->setWhatsThis(text);
}
void ViewerPrivate::slotRefreshMessage(const Akonadi::Item &item)
{
if (item.id() == mMessageItem.id()) {
......
......@@ -599,7 +599,6 @@ Q_SIGNALS:
private:
QString attachmentHtml() const;
void addHelpTextAction(QAction *act, const QString &text);
void readGravatarConfig();
void replyMessageToAuthor(KMime::Content *atmNode);
......
......@@ -18,6 +18,7 @@
*/
#include "viewerplugininterface.h"
#include "utils/messageviewerutil_p.h"
#include <QAction>
using namespace MessageViewer;
......@@ -105,11 +106,7 @@ void ViewerPluginInterface::refreshActionList(KActionCollection *ac)
void ViewerPluginInterface::addHelpTextAction(QAction *act, const QString &text)
{
act->setStatusTip(text);
act->setToolTip(text);
if (act->whatsThis().isEmpty()) {
act->setWhatsThis(text);
}
MessageViewer::Util::addHelpTextAction(act, text);
}
void ViewerPluginInterface::slotActivatePlugin()
......
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