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

Create submenu

parent ebf93faf
......@@ -13,8 +13,8 @@ add_dependencies(dbustest kmail_xml)
target_link_libraries(dbustest ${KDE4_KIO_LIBS})
set( kmail_displaymenu_source displaymessageformatactionmenutest.cpp )
set( kmail_displaymenu_source displaymessageformatactionmenutest.cpp ../widgets/displaymessageformatactionmenu.cpp )
kde4_add_unit_test( displaymessageformatactionmenutest ${kmail_displaymenu_source})
target_link_libraries( displaymessageformatactionmenutest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS})
target_link_libraries( displaymessageformatactionmenutest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} messageviewer)
......@@ -16,11 +16,19 @@
*/
#include "displaymessageformatactionmenutest.h"
#include "../widgets/displaymessageformatactionmenu.h"
#include <qtest_kde.h>
#include <KMenu>
DisplayMessageFormatActionMenuTest::DisplayMessageFormatActionMenuTest()
{
}
void DisplayMessageFormatActionMenuTest::shouldHaveDefaultValue()
{
DisplayMessageFormatActionMenu menu;
QVERIFY(menu.menu());
QCOMPARE(menu.menu()->actions().count(), 3);
}
QTEST_KDEMAIN(DisplayMessageFormatActionMenuTest, GUI)
......@@ -25,6 +25,8 @@ class DisplayMessageFormatActionMenuTest : public QObject
Q_OBJECT
public:
DisplayMessageFormatActionMenuTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // DISPLAYMESSAGEFORMATACTIONMENUTEST_H
......@@ -18,10 +18,35 @@
#include "displaymessageformatactionmenu.h"
#include <KLocalizedString>
#include <KAction>
#include <KMenu>
#include <KToggleAction>
#include "messageviewer/viewer/viewer.h"
DisplayMessageFormatActionMenu::DisplayMessageFormatActionMenu(QObject *parent)
: KActionMenu(parent)
{
setText(i18n("Message Default Format"));
KMenu *subMenu = new KMenu;
setMenu(subMenu);
QActionGroup *actionGroup = new QActionGroup(this);
KToggleAction *act = new KToggleAction(i18n("Prefer &HTML to Plain Text"), this);
act->setData(MessageViewer::Viewer::Html);
actionGroup->addAction(act);
subMenu->addAction(act);
connect(act, SIGNAL(triggered(bool)), this, SLOT(slotChangeDisplayMessageFormat()));
act = new KToggleAction(i18n("Prefer &Plain Text to HTML"), this);
act->setData(MessageViewer::Viewer::Text);
actionGroup->addAction(act);
subMenu->addAction(act);
connect(act, SIGNAL(triggered(bool)), this, SLOT(slotChangeDisplayMessageFormat()));
act = new KToggleAction(i18n("Use KMail global setting"), this);
act->setData(MessageViewer::Viewer::UseGlobalSetting);
connect(act, SIGNAL(triggered(bool)), this, SLOT(slotChangeDisplayMessageFormat()));
actionGroup->addAction(act);
subMenu->addAction(act);
}
......@@ -29,3 +54,13 @@ DisplayMessageFormatActionMenu::~DisplayMessageFormatActionMenu()
{
}
void DisplayMessageFormatActionMenu::slotChangeDisplayMessageFormat()
{
if (sender()) {
KToggleAction *act = dynamic_cast<KToggleAction *>(sender());
if (act) {
}
}
}
......@@ -19,13 +19,21 @@
#define DisplayMessageFormatActionMenu_H
#include <KActionMenu>
#include "messageviewer/viewer/viewer.h"
class KToggleAction;
class DisplayMessageFormatActionMenu : public KActionMenu
{
Q_OBJECT
public:
explicit DisplayMessageFormatActionMenu(QObject *parent=0);
~DisplayMessageFormatActionMenu();
Q_SIGNALS:
void changeDisplayMessageFormat(MessageViewer::Viewer::DisplayFormatMessage format);
private slots:
void slotChangeDisplayMessageFormat();
};
#endif // DisplayMessageFormatActionMenu_H
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