• 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
vacationscriptindicatorwidget.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2013-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 "vacationscriptindicatorwidget.h"
19 #include <KIcon>
20 #include <KLocalizedString>
21 
22 #include <QHBoxLayout>
23 
24 using namespace KMail;
25 
26 ServerLabel::ServerLabel(const QString &serverName, QWidget * parent)
27  : QLabel( parent ),
28  mServerName(serverName)
29 {
30  setToolTip(serverName);
31  setPixmap(KIcon( QLatin1String("network-server") ).pixmap( 16, 16 ) );
32  setStyleSheet( QString::fromLatin1("background-color: %1;" ).arg( QColor(Qt::yellow).name() ) );
33  setContentsMargins( 2, 0, 4, 0 );
34 }
35 
36 ServerLabel::~ServerLabel()
37 {
38 
39 }
40 
41 void ServerLabel::mouseReleaseEvent(QMouseEvent * event)
42 {
43  Q_EMIT clicked(mServerName);
44  QLabel::mouseReleaseEvent( event );
45 }
46 
47 
48 VacationLabel::VacationLabel(const QString &text, QWidget * parent)
49  : QLabel( text, parent )
50 {
51  // changing the palette doesn't work, seems to be overwriten by the
52  // statusbar again, stylesheets seems to work though
53  setStyleSheet( QString::fromLatin1("background-color: %1; color: %2;" ).arg( QColor(Qt::yellow).name(), QColor(Qt::black).name() ) );
54  setContentsMargins( 4, 0, 2, 0 );
55  setCursor( QCursor( Qt::PointingHandCursor ) );
56 }
57 
58 VacationLabel::~VacationLabel()
59 {
60 
61 }
62 
63 void VacationLabel::mouseReleaseEvent(QMouseEvent * event)
64 {
65  Q_EMIT clicked();
66  QLabel::mouseReleaseEvent( event );
67 }
68 
69 VacationScriptIndicatorWidget::VacationScriptIndicatorWidget(QWidget *parent)
70  : QWidget(parent),
71  mBoxLayout(0),
72  mInfo(0)
73 {
74 }
75 
76 VacationScriptIndicatorWidget::~VacationScriptIndicatorWidget()
77 {
78 
79 }
80 
81 void VacationScriptIndicatorWidget::setVacationScriptActive(bool active, const QString &serverName)
82 {
83  if (active) {
84  if (!mServerActive.contains(serverName)) {
85  mServerActive.append(serverName);
86  updateIndicator();
87  }
88  } else {
89  if (mServerActive.contains(serverName)) {
90  mServerActive.removeAll(serverName);
91  updateIndicator();
92  }
93  }
94 }
95 
96 void VacationScriptIndicatorWidget::createIndicator()
97 {
98  delete mBoxLayout;
99  mBoxLayout = new QHBoxLayout;
100  mBoxLayout->setMargin(0);
101  mBoxLayout->setSpacing(0);
102  mInfo = new VacationLabel(i18np("Out of office reply active on server", "Out of office reply active on servers", mServerActive.count()));
103  connect(mInfo, SIGNAL(clicked()), this, SIGNAL(clicked()));
104  mBoxLayout->addWidget(mInfo);
105  Q_FOREACH (const QString &server, mServerActive) {
106  ServerLabel *lab = new ServerLabel(server);
107  connect(lab, SIGNAL(clicked(QString)), this, SIGNAL(clicked(QString)));
108  mBoxLayout->addWidget(lab);
109  }
110  setLayout(mBoxLayout);
111 }
112 
113 void VacationScriptIndicatorWidget::updateIndicator()
114 {
115  if (mServerActive.isEmpty()) {
116  hide();
117  } else {
118  createIndicator();
119  show();
120  }
121 }
122 
123 bool VacationScriptIndicatorWidget::hasVacationScriptActive() const
124 {
125  return !mServerActive.isEmpty();
126 }
KMail::VacationScriptIndicatorWidget::clicked
void clicked(const QString &serverName=QString())
QWidget::setStyleSheet
void setStyleSheet(const QString &styleSheet)
QWidget
QWidget::setCursor
void setCursor(const QCursor &)
KMail::ServerLabel::clicked
void clicked(const QString &serverName)
text
virtual QByteArray text(quint32 serialNumber) const =0
vacationscriptindicatorwidget.h
QLabel::setPixmap
void setPixmap(const QPixmap &)
KMail::VacationLabel::clicked
void clicked()
QStringList::contains
bool contains(const QString &str, Qt::CaseSensitivity cs) const
QHBoxLayout
KMail::VacationLabel::~VacationLabel
~VacationLabel()
Definition: vacationscriptindicatorwidget.cpp:58
QMouseEvent
KMail::VacationScriptIndicatorWidget::setVacationScriptActive
void setVacationScriptActive(bool active, const QString &serverName)
Definition: vacationscriptindicatorwidget.cpp:81
KMail::VacationLabel::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event)
Definition: vacationscriptindicatorwidget.cpp:63
KMail::VacationScriptIndicatorWidget::~VacationScriptIndicatorWidget
~VacationScriptIndicatorWidget()
Definition: vacationscriptindicatorwidget.cpp:76
QObject::name
const char * name() const
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QList::count
int count(const T &value) const
QList::append
void append(const T &value)
QWidget::setLayout
void setLayout(QLayout *layout)
KMail::ServerLabel::~ServerLabel
~ServerLabel()
Definition: vacationscriptindicatorwidget.cpp:36
KMail::ServerLabel
Definition: vacationscriptindicatorwidget.h:26
QList::isEmpty
bool isEmpty() const
QList::removeAll
int removeAll(const T &value)
QString
QWidget::hide
void hide()
QColor
QLayout::setMargin
void setMargin(int margin)
KMail::VacationScriptIndicatorWidget::VacationScriptIndicatorWidget
VacationScriptIndicatorWidget(QWidget *parent=0)
Definition: vacationscriptindicatorwidget.cpp:69
QLatin1String
QLabel::mouseReleaseEvent
virtual void mouseReleaseEvent(QMouseEvent *ev)
KMail::VacationScriptIndicatorWidget::hasVacationScriptActive
bool hasVacationScriptActive() const
Definition: vacationscriptindicatorwidget.cpp:123
KMail::VacationLabel::VacationLabel
VacationLabel(const QString &text, QWidget *parent=0)
Definition: vacationscriptindicatorwidget.cpp:48
QString::fromLatin1
QString fromLatin1(const char *str, int size)
KMail::ServerLabel::ServerLabel
ServerLabel(const QString &toolTip, QWidget *parent=0)
Definition: vacationscriptindicatorwidget.cpp:26
QWidget::show
void show()
QWidget::setToolTip
void setToolTip(const QString &)
KMail::VacationLabel
Definition: vacationscriptindicatorwidget.h:43
KMail::VacationScriptIndicatorWidget::updateIndicator
void updateIndicator()
Definition: vacationscriptindicatorwidget.cpp:113
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QLabel
QCursor
KMail::ServerLabel::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event)
Definition: vacationscriptindicatorwidget.cpp:41
QBoxLayout::setSpacing
void setSpacing(int spacing)
QWidget::setContentsMargins
void setContentsMargins(int left, int top, int right, int bottom)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:33 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