Commit 4b18174a authored by Laurent Montel's avatar Laurent Montel 😁

Use new api

parent 2edfc0b7
......@@ -74,7 +74,7 @@ set(KDEPIMLIBS_LIB_VERSION "5.2.40")
set(GRAVATAR_LIB_VERSION "5.2.40")
set(INCIDENCEEDITOR_LIB_VERSION "5.2.40")
set(KTNEF_LIB_VERSION "5.2.40")
set(MESSAGELIB_LIB_VERSION "5.2.43")
set(MESSAGELIB_LIB_VERSION "5.2.45")
find_package(KF5MailCommon ${MAILCOMMN_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5KaddressbookGrantlee ${KDEPIM_APPS_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5MessageViewer ${KDEPIM_APPS_LIB_VERSION} CONFIG REQUIRED)
......
......@@ -48,7 +48,7 @@ void ViewerPluginCreateeventTest::shouldCreateAction()
QWidget *parent = new QWidget(0);
parent->setLayout(new QHBoxLayout);
MessageViewer::ViewerPluginInterface *interface = event->createView(parent, new KActionCollection(this));
QVERIFY(interface->action());
QVERIFY(!interface->actions().isEmpty());
}
QTEST_MAIN(ViewerPluginCreateeventTest)
......@@ -49,7 +49,7 @@ void ViewerPluginCreateNoteTest::shouldCreateAction()
QWidget *parent = new QWidget(0);
parent->setLayout(new QHBoxLayout);
MessageViewer::ViewerPluginInterface *interface = event->createView(parent, new KActionCollection(this));
QVERIFY(interface->action());
QVERIFY(!interface->actions().isEmpty());
}
QTEST_MAIN(ViewerPluginCreateNoteTest)
......@@ -48,7 +48,7 @@ void ViewerPluginCreateTodoTest::shouldCreateAction()
QWidget *parent = new QWidget(0);
parent->setLayout(new QHBoxLayout);
MessageViewer::ViewerPluginInterface *interface = event->createView(parent, new KActionCollection(this));
QVERIFY(interface->action());
QVERIFY(!interface->actions().isEmpty());
}
QTEST_MAIN(ViewerPluginCreateTodoTest)
......@@ -52,7 +52,7 @@ void ViewerPluginTranslatorTest::shouldCreateAction()
parent->setLayout(new QHBoxLayout);
MessageViewer::ViewerPluginInterface *interface = translator->createView(parent, new KActionCollection(this));
QVERIFY(interface->action());
QVERIFY(!interface->actions().isEmpty());
}
QTEST_MAIN(ViewerPluginTranslatorTest)
......@@ -22,6 +22,6 @@
"ServiceTypes": [
"MessageViewer/ViewerCommonPlugin"
],
"Version": "1.0"
"Version": "2.0"
}
}
\ No newline at end of file
}
......@@ -31,8 +31,7 @@
using namespace MessageViewer;
ViewerPluginExpandurlInterface::ViewerPluginExpandurlInterface(KActionCollection *ac, QWidget *parent)
: ViewerPluginInterface(parent),
mAction(Q_NULLPTR)
: ViewerPluginInterface(parent)
{
createAction(ac);
}
......@@ -42,7 +41,7 @@ ViewerPluginExpandurlInterface::~ViewerPluginExpandurlInterface()
}
QAction *ViewerPluginExpandurlInterface::action() const
QList<QAction *> ViewerPluginExpandurlInterface::actions() const
{
return mAction;
}
......@@ -67,10 +66,11 @@ ViewerPluginInterface::SpecificFeatureTypes ViewerPluginExpandurlInterface::feat
void ViewerPluginExpandurlInterface::createAction(KActionCollection *ac)
{
if (ac) {
mAction = new QAction(i18n("Expand URL"), this);
ac->addAction(QStringLiteral("expand_short_url"), mAction);
ac->setShortcutsConfigurable(mAction, false);
connect(mAction, &QAction::triggered, this, &ViewerPluginExpandurlInterface::slotActivatePlugin);
QAction *act = new QAction(i18n("Expand URL"), this);
ac->addAction(QStringLiteral("expand_short_url"), act);
ac->setShortcutsConfigurable(act, false);
connect(act, &QAction::triggered, this, &ViewerPluginExpandurlInterface::slotActivatePlugin);
mAction.append(act);
}
}
......
......@@ -30,7 +30,7 @@ public:
explicit ViewerPluginExpandurlInterface(KActionCollection *ac, QWidget *parent = Q_NULLPTR);
~ViewerPluginExpandurlInterface();
QAction *action() const Q_DECL_OVERRIDE;
QList<QAction *> actions() const Q_DECL_OVERRIDE;
void execute() Q_DECL_OVERRIDE;
ViewerPluginInterface::SpecificFeatureTypes featureTypes() const Q_DECL_OVERRIDE;
......@@ -38,7 +38,7 @@ public:
private:
void createAction(KActionCollection *ac);
QUrl mCurrentUrl;
QAction *mAction;
QList<QAction *> mAction;
};
}
#endif // VIEWERPLUGINEXPANDURLINTERFACE_H
......@@ -27,6 +27,6 @@
"ServiceTypes": [
"MessageViewer/ViewerCommonPlugin"
],
"Version": "1.0"
"Version": "2.0"
}
}
\ No newline at end of file
}
......@@ -28,8 +28,7 @@
using namespace MessageViewer;
ViewerPluginTranslatorInterface::ViewerPluginTranslatorInterface(KActionCollection *ac, QWidget *parent)
: ViewerPluginInterface(parent),
mAction(Q_NULLPTR)
: ViewerPluginInterface(parent)
{
mTranslatorWidget = new PimCommon::TranslatorWidget(parent);
mTranslatorWidget->setObjectName(QStringLiteral("translatorwidget"));
......@@ -47,7 +46,7 @@ void ViewerPluginTranslatorInterface::setText(const QString &text)
mTranslatorWidget->setTextToTranslate(text);
}
QAction *ViewerPluginTranslatorInterface::action() const
QList<QAction *> ViewerPluginTranslatorInterface::actions() const
{
return mAction;
}
......@@ -65,10 +64,11 @@ ViewerPluginInterface::SpecificFeatureTypes ViewerPluginTranslatorInterface::fea
void ViewerPluginTranslatorInterface::createAction(KActionCollection *ac)
{
if (ac) {
mAction = new QAction(i18n("Translate..."), this);
ac->setDefaultShortcut(mAction, QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_T));
mAction->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-locale")));
ac->addAction(QStringLiteral("translate_text"), mAction);
connect(mAction, &QAction::triggered, this, &ViewerPluginTranslatorInterface::slotActivatePlugin);
QAction *act = new QAction(i18n("Translate..."), this);
ac->setDefaultShortcut(act, QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_T));
act->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-locale")));
ac->addAction(QStringLiteral("translate_text"), act);
connect(act, &QAction::triggered, this, &ViewerPluginTranslatorInterface::slotActivatePlugin);
mAction.append(act);
}
}
......@@ -34,13 +34,13 @@ public:
~ViewerPluginTranslatorInterface();
void setText(const QString &text) Q_DECL_OVERRIDE;
QAction *action() const Q_DECL_OVERRIDE;
QList<QAction *> actions() const Q_DECL_OVERRIDE;
void showWidget() Q_DECL_OVERRIDE;
ViewerPluginInterface::SpecificFeatureTypes featureTypes() const Q_DECL_OVERRIDE;
private:
void createAction(KActionCollection *ac);
QAction *mAction;
QList<QAction *> mAction;
PimCommon::TranslatorWidget *mTranslatorWidget;
};
......
......@@ -27,6 +27,6 @@
"ServiceTypes": [
"MessageViewer/ViewerPlugin"
],
"Version": "1.0"
"Version": "2.0"
}
}
\ No newline at end of file
}
......@@ -29,8 +29,7 @@
using namespace MessageViewer;
ViewerPluginCreateEventInterface::ViewerPluginCreateEventInterface(KActionCollection *ac, QWidget *parent)
: ViewerPluginInterface(parent),
mAction(Q_NULLPTR)
: ViewerPluginInterface(parent)
{
mEventEdit = new EventEdit(parent);
connect(mEventEdit, &EventEdit::createEvent, this, &ViewerPluginCreateEventInterface::slotCreateEvent);
......@@ -56,7 +55,7 @@ void ViewerPluginCreateEventInterface::setText(const QString &text)
//Nothing
}
QAction *ViewerPluginCreateEventInterface::action() const
QList<QAction *> ViewerPluginCreateEventInterface::actions() const
{
return mAction;
}
......@@ -84,12 +83,13 @@ void ViewerPluginCreateEventInterface::setMessageItem(const Akonadi::Item &item)
void ViewerPluginCreateEventInterface::createAction(KActionCollection *ac)
{
if (ac) {
mAction = new QAction(QIcon::fromTheme(QStringLiteral("appointment-new")), i18n("Create Event..."), this);
mAction->setIconText(i18n("Create Event"));
addHelpTextAction(mAction, i18n("Allows you to create a calendar Event"));
ac->addAction(QStringLiteral("create_event"), mAction);
ac->setDefaultShortcut(mAction, QKeySequence(Qt::CTRL + Qt::Key_E));
connect(mAction, &QAction::triggered, this, &ViewerPluginCreateEventInterface::slotActivatePlugin);
QAction *act = new QAction(QIcon::fromTheme(QStringLiteral("appointment-new")), i18n("Create Event..."), this);
act->setIconText(i18n("Create Event"));
addHelpTextAction(act, i18n("Allows you to create a calendar Event"));
ac->addAction(QStringLiteral("create_event"), act);
ac->setDefaultShortcut(act, QKeySequence(Qt::CTRL + Qt::Key_E));
connect(act, &QAction::triggered, this, &ViewerPluginCreateEventInterface::slotActivatePlugin);
mAction.append(act);
}
}
......
......@@ -32,7 +32,7 @@ public:
~ViewerPluginCreateEventInterface();
void setText(const QString &text) Q_DECL_OVERRIDE;
QAction *action() const Q_DECL_OVERRIDE;
QList<QAction *> actions() const Q_DECL_OVERRIDE;
void setMessage(const KMime::Message::Ptr &value) Q_DECL_OVERRIDE;
void closePlugin() Q_DECL_OVERRIDE;
void showWidget() Q_DECL_OVERRIDE;
......@@ -46,7 +46,7 @@ private:
void createAction(KActionCollection *ac);
Akonadi::Item mMessageItem;
EventEdit *mEventEdit;
QAction *mAction;
QList<QAction *> mAction;
};
}
......
......@@ -27,6 +27,6 @@
"ServiceTypes": [
"MessageViewer/ViewerPlugin"
],
"Version": "1.0"
"Version": "2.0"
}
}
\ No newline at end of file
}
......@@ -32,8 +32,7 @@
using namespace MessageViewer;
ViewerPluginCreatenoteInterface::ViewerPluginCreatenoteInterface(KActionCollection *ac, QWidget *parent)
: ViewerPluginInterface(parent),
mAction(Q_NULLPTR)
: ViewerPluginInterface(parent)
{
createAction(ac);
mNoteEdit = new NoteEdit(parent);
......@@ -54,7 +53,7 @@ void ViewerPluginCreatenoteInterface::setText(const QString &text)
//Nothing
}
QAction *ViewerPluginCreatenoteInterface::action() const
QList<QAction *> ViewerPluginCreatenoteInterface::actions() const
{
return mAction;
}
......@@ -132,7 +131,7 @@ ViewerPluginInterface::SpecificFeatureTypes ViewerPluginCreatenoteInterface::fea
void ViewerPluginCreatenoteInterface::updateAction(const Akonadi::Item &item)
{
mMessageItem = item;
if (mAction) {
if (!mAction.isEmpty()) {
QString createNoteText;
if (relatedNoteRelation().isValid()) {
createNoteText = i18nc("edit a note on this message", "Edit Note");
......@@ -140,20 +139,21 @@ void ViewerPluginCreatenoteInterface::updateAction(const Akonadi::Item &item)
createNoteText = i18nc("create a new note out of this message", "Create Note");
}
mAction->setText(createNoteText);
mAction->setIconText(createNoteText);
mAction.at(0)->setText(createNoteText);
mAction.at(0)->setIconText(createNoteText);
}
}
void ViewerPluginCreatenoteInterface::createAction(KActionCollection *ac)
{
if (ac) {
mAction = new QAction(QIcon::fromTheme(QStringLiteral("view-pim-notes")), i18nc("create a new note out of this message", "Create Note"), this);
mAction->setIconText(i18nc("create a new note out of this message", "Create Note"));
addHelpTextAction(mAction, i18n("Allows you to create a note from this message"));
mAction->setWhatsThis(i18n("This option starts an editor to create a note. Then you can edit the note to your liking before saving it."));
ac->addAction(QStringLiteral("create_note"), mAction);
connect(mAction, &QAction::triggered, this, &ViewerPluginCreatenoteInterface::slotActivatePlugin);
QAction *act = new QAction(QIcon::fromTheme(QStringLiteral("view-pim-notes")), i18nc("create a new note out of this message", "Create Note"), this);
act->setIconText(i18nc("create a new note out of this message", "Create Note"));
addHelpTextAction(act, i18n("Allows you to create a note from this message"));
act->setWhatsThis(i18n("This option starts an editor to create a note. Then you can edit the note to your liking before saving it."));
ac->addAction(QStringLiteral("create_note"), act);
connect(act, &QAction::triggered, this, &ViewerPluginCreatenoteInterface::slotActivatePlugin);
mAction.append(act);
}
}
......
......@@ -32,7 +32,7 @@ public:
~ViewerPluginCreatenoteInterface();
void setText(const QString &text) Q_DECL_OVERRIDE;
QAction *action() const Q_DECL_OVERRIDE;
QList<QAction *> actions() const Q_DECL_OVERRIDE;
void setMessage(const KMime::Message::Ptr &value) Q_DECL_OVERRIDE;
void closePlugin() Q_DECL_OVERRIDE;
void showWidget() Q_DECL_OVERRIDE;
......@@ -50,7 +50,7 @@ private:
void createAction(KActionCollection *ac);
Akonadi::Item mMessageItem;
NoteEdit *mNoteEdit;
QAction *mAction;
QList<QAction *> mAction;
};
}
#endif // VIEWERPLUGINCREATENOTEINTERFACE_H
......@@ -27,6 +27,6 @@
"ServiceTypes": [
"MessageViewer/ViewerPlugin"
],
"Version": "1.0"
"Version": "2.0"
}
}
\ No newline at end of file
}
......@@ -29,8 +29,7 @@
using namespace MessageViewer;
ViewerPluginCreateTodoInterface::ViewerPluginCreateTodoInterface(KActionCollection *ac, QWidget *parent)
: ViewerPluginInterface(parent),
mAction(Q_NULLPTR)
: ViewerPluginInterface(parent)
{
mTodoEdit = new TodoEdit(parent);
mTodoEdit->setObjectName(QStringLiteral("todoedit"));
......@@ -51,7 +50,7 @@ void ViewerPluginCreateTodoInterface::setText(const QString &text)
//Nothing
}
QAction *ViewerPluginCreateTodoInterface::action() const
QList<QAction *> ViewerPluginCreateTodoInterface::actions() const
{
return mAction;
}
......@@ -84,13 +83,14 @@ ViewerPluginInterface::SpecificFeatureTypes ViewerPluginCreateTodoInterface::fea
void ViewerPluginCreateTodoInterface::createAction(KActionCollection *ac)
{
if (ac) {
mAction = new QAction(QIcon::fromTheme(QStringLiteral("task-new")), i18n("Create Todo"), this);
mAction->setIconText(i18n("Create To-do"));
addHelpTextAction(mAction, i18n("Allows you to create a calendar to-do or reminder from this message"));
mAction->setWhatsThis(i18n("This option starts the KOrganizer to-do editor with initial values taken from the currently selected message. Then you can edit the to-do to your liking before saving it to your calendar."));
ac->addAction(QStringLiteral("create_todo"), mAction);
ac->setDefaultShortcut(mAction, QKeySequence(Qt::CTRL + Qt::Key_T));
connect(mAction, &QAction::triggered, this, &ViewerPluginCreateTodoInterface::slotActivatePlugin);
QAction *act = new QAction(QIcon::fromTheme(QStringLiteral("task-new")), i18n("Create Todo"), this);
act->setIconText(i18n("Create To-do"));
addHelpTextAction(act, i18n("Allows you to create a calendar to-do or reminder from this message"));
act->setWhatsThis(i18n("This option starts the KOrganizer to-do editor with initial values taken from the currently selected message. Then you can edit the to-do to your liking before saving it to your calendar."));
ac->addAction(QStringLiteral("create_todo"), act);
ac->setDefaultShortcut(act, QKeySequence(Qt::CTRL + Qt::Key_T));
connect(act, &QAction::triggered, this, &ViewerPluginCreateTodoInterface::slotActivatePlugin);
mAction.append(act);
}
}
......
......@@ -33,7 +33,7 @@ public:
~ViewerPluginCreateTodoInterface();
void setText(const QString &text) Q_DECL_OVERRIDE;
QAction *action() const Q_DECL_OVERRIDE;
QList<QAction *> actions() const Q_DECL_OVERRIDE;
void setMessage(const KMime::Message::Ptr &value) Q_DECL_OVERRIDE;
void closePlugin() Q_DECL_OVERRIDE;
void showWidget() Q_DECL_OVERRIDE;
......@@ -46,7 +46,7 @@ private Q_SLOTS:
private:
void createAction(KActionCollection *ac);
TodoEdit *mTodoEdit;
QAction *mAction;
QList<QAction *> mAction;
Akonadi::Item mMessageItem;
};
}
......
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