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

Add autotest

parent 994f91d9
macro(add_kmail_editorpluginquicktext_unittest _source _additional)
set( _test ${_source} ${_additional})
get_filename_component(_name ${_source} NAME_WE)
add_executable( ${_name} ${_test} )
add_test(NAME ${_name} COMMAND ${_name} )
ecm_mark_as_test(kmail_editorpluginquicktext-${_name})
target_link_libraries( ${_name} Qt5::Test KF5::XmlGui KF5::IconThemes KF5::MessageComposer KF5::I18n KF5::PimTextEdit)
endmacro ()
add_kmail_editorpluginquicktext_unittest(quicktextmenutest.cpp "")
/*
Copyright (C) 2019 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "quicktextmenutest.h"
#include <QTest>
QTEST_MAIN(QuickTextMenuTest)
QuickTextMenuTest::QuickTextMenuTest(QObject *parent)
: QObject(parent)
{
}
/*
Copyright (C) 2019 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef QUICKTEXTMENUTEST_H
#define QUICKTEXTMENUTEST_H
#include <QObject>
class QuickTextMenuTest : public QObject
{
Q_OBJECT
public:
explicit QuickTextMenuTest(QObject *parent = nullptr);
~QuickTextMenuTest() = default;
};
#endif // QUICKTEXTMENUTEST_H
......@@ -18,14 +18,14 @@
*/
#include "quicktextmenu.h"
#include <MessageComposer/PluginComposerInterface>
#include <QMenu>
QuickTextMenu::QuickTextMenu(QWidget *parentWidget, QObject *parent)
: QObject(parent)
, mParentWidget(parentWidget)
{
mMenu = new QMenu(mParentWidget);
{
initializeMenu();
}
QuickTextMenu::~QuickTextMenu()
......@@ -33,7 +33,17 @@ QuickTextMenu::~QuickTextMenu()
}
void QuickTextMenu::initializeMenu()
{
mMenu = new QMenu(mParentWidget);
}
QMenu *QuickTextMenu::menu() const
{
return mMenu;
}
void QuickTextMenu::setPluginComposerInterface(MessageComposer::PluginComposerInterface *composerInterface)
{
mComposerInterface = composerInterface;
}
......@@ -22,6 +22,9 @@
#include <QObject>
class QMenu;
namespace MessageComposer {
class PluginComposerInterface;
}
class QuickTextMenu : public QObject
{
Q_OBJECT
......@@ -30,12 +33,16 @@ public:
~QuickTextMenu();
QMenu *menu() const;
void setPluginComposerInterface(MessageComposer::PluginComposerInterface *composerInterface);
Q_SIGNALS:
void insertText(const QString &str);
private:
void initializeMenu();
QWidget *mParentWidget = nullptr;
QMenu *mMenu = nullptr;
MessageComposer::PluginComposerInterface *mComposerInterface = nullptr;
};
#endif // QUICKTEXTMENU_H
......@@ -36,6 +36,7 @@ QuickTextPluginEditorInterface::~QuickTextPluginEditorInterface()
void QuickTextPluginEditorInterface::createAction(KActionCollection *ac)
{
QuickTextMenu *quickTextMenu = new QuickTextMenu(parentWidget(), this);
quickTextMenu->setPluginComposerInterface(composerInterface());
QAction *action = new QAction(i18n("Variables"), this);
action->setMenu(quickTextMenu->menu());
ac->addAction(QStringLiteral("insert_variables"), action);
......
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