• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kmail

  • sources
  • kde-4.14
  • kdepim
  • kmail
  • widgets
displaymessageformatactionmenu.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2014-2015 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "displaymessageformatactionmenu.h"
19 
20 #include <KLocalizedString>
21 #include <KAction>
22 #include <KMenu>
23 #include <KToggleAction>
24 #include <QDebug>
25 
26 
27 DisplayMessageFormatActionMenu::DisplayMessageFormatActionMenu(QObject *parent)
28  : KActionMenu(parent),
29  mDisplayMessageFormat(MessageViewer::Viewer::UseGlobalSetting)
30 {
31  setText(i18n("Message Default Format"));
32  KMenu *subMenu = new KMenu;
33  setMenu(subMenu);
34 
35  QActionGroup *actionGroup = new QActionGroup(this);
36 
37  KToggleAction *act = new KToggleAction(i18n("Prefer &HTML to Plain Text"), this);
38  act->setObjectName(QLatin1String("prefer-html-action"));
39  act->setData(MessageViewer::Viewer::Html);
40  actionGroup->addAction(act);
41  subMenu->addAction(act);
42  connect(act, SIGNAL(triggered(bool)), this, SLOT(slotChangeDisplayMessageFormat()));
43 
44  act = new KToggleAction(i18n("Prefer &Plain Text to HTML"), this);
45  act->setData(MessageViewer::Viewer::Text);
46  act->setObjectName(QLatin1String("prefer-text-action"));
47  actionGroup->addAction(act);
48  subMenu->addAction(act);
49  connect(act, SIGNAL(triggered(bool)), this, SLOT(slotChangeDisplayMessageFormat()));
50 
51  act = new KToggleAction(i18n("Use Global Setting"), this);
52  act->setObjectName(QLatin1String("use-global-setting-action"));
53  act->setData(MessageViewer::Viewer::UseGlobalSetting);
54  connect(act, SIGNAL(triggered(bool)), this, SLOT(slotChangeDisplayMessageFormat()));
55  actionGroup->addAction(act);
56  subMenu->addAction(act);
57  updateMenu();
58 }
59 
60 
61 DisplayMessageFormatActionMenu::~DisplayMessageFormatActionMenu()
62 {
63 
64 }
65 
66 void DisplayMessageFormatActionMenu::slotChangeDisplayMessageFormat()
67 {
68  if (sender()) {
69  KToggleAction *act = dynamic_cast<KToggleAction *>(sender());
70  if (act) {
71  MessageViewer::Viewer::DisplayFormatMessage format = static_cast<MessageViewer::Viewer::DisplayFormatMessage>(act->data().toInt());
72  emit changeDisplayMessageFormat(format);
73  }
74  }
75 }
76 MessageViewer::Viewer::DisplayFormatMessage DisplayMessageFormatActionMenu::displayMessageFormat() const
77 {
78  return mDisplayMessageFormat;
79 }
80 
81 void DisplayMessageFormatActionMenu::setDisplayMessageFormat(MessageViewer::Viewer::DisplayFormatMessage displayMessageFormat)
82 {
83  if (mDisplayMessageFormat != displayMessageFormat) {
84  mDisplayMessageFormat = displayMessageFormat;
85  updateMenu();
86  }
87 }
88 
89 void DisplayMessageFormatActionMenu::updateMenu()
90 {
91  Q_FOREACH (QAction *act, menu()->actions()) {
92  MessageViewer::Viewer::DisplayFormatMessage format = static_cast<MessageViewer::Viewer::DisplayFormatMessage>(act->data().toInt());
93  if (format == mDisplayMessageFormat) {
94  act->setChecked(true);
95  break;
96  }
97  }
98 }
DisplayMessageFormatActionMenu::changeDisplayMessageFormat
void changeDisplayMessageFormat(MessageViewer::Viewer::DisplayFormatMessage format)
QActionGroup
QAction::setChecked
void setChecked(bool)
QAction::data
QVariant data() const
QActionGroup::addAction
QAction * addAction(QAction *action)
QVariant::toInt
int toInt(bool *ok) const
QObject
DisplayMessageFormatActionMenu::setDisplayMessageFormat
void setDisplayMessageFormat(MessageViewer::Viewer::DisplayFormatMessage displayMessageFormat)
Definition: displaymessageformatactionmenu.cpp:81
DisplayMessageFormatActionMenu::displayMessageFormat
MessageViewer::Viewer::DisplayFormatMessage displayMessageFormat() const
Definition: displaymessageformatactionmenu.cpp:76
KActionMenu
QLatin1String
DisplayMessageFormatActionMenu::~DisplayMessageFormatActionMenu
~DisplayMessageFormatActionMenu()
Definition: displaymessageformatactionmenu.cpp:61
QAction
displaymessageformatactionmenu.h
DisplayMessageFormatActionMenu::DisplayMessageFormatActionMenu
DisplayMessageFormatActionMenu(QObject *parent=0)
Definition: displaymessageformatactionmenu.cpp:27
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:32 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal