• 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
  • editor
  • widgets
cryptostateindicatorwidget.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 "cryptostateindicatorwidget.h"
19 #include "messagecore/settings/globalsettings.h"
20 
21 #include <KColorScheme>
22 #include <KLocalizedString>
23 
24 #include <QHBoxLayout>
25 #include <QLabel>
26 
27 CryptoStateIndicatorWidget::CryptoStateIndicatorWidget(QWidget *parent)
28  : QWidget(parent),
29  mShowAlwaysIndicator(true),
30  mIsSign(false),
31  mIsEncrypted(false)
32 {
33  QHBoxLayout *hbox = new QHBoxLayout;
34  setLayout(hbox);
35  hbox->setMargin(0);
36  mSignatureStateIndicator = new QLabel( this );
37  mSignatureStateIndicator->setObjectName(QLatin1String("signatureindicator"));
38  mSignatureStateIndicator->setAlignment( Qt::AlignHCenter );
39  hbox->addWidget( mSignatureStateIndicator );
40 
41  // Get the colors for the label
42  QPalette p( mSignatureStateIndicator->palette() );
43  KColorScheme scheme( QPalette::Active, KColorScheme::View );
44  const QColor defaultSignedColor = // pgp signed
45  scheme.background( KColorScheme::PositiveBackground ).color();
46  const QColor defaultEncryptedColor( 0x00, 0x80, 0xFF ); // light blue // pgp encrypted
47 
48  QColor signedColor = defaultSignedColor;
49  QColor encryptedColor = defaultEncryptedColor;
50  if ( !MessageCore::GlobalSettings::self()->useDefaultColors() ) {
51  signedColor = MessageCore::GlobalSettings::self()->pgpSignedMessageColor();
52  encryptedColor = MessageCore::GlobalSettings::self()->pgpEncryptedMessageColor();
53  }
54 
55  p.setColor( QPalette::Window, signedColor );
56  mSignatureStateIndicator->setPalette( p );
57  mSignatureStateIndicator->setAutoFillBackground( true );
58 
59  mEncryptionStateIndicator = new QLabel( this );
60  mEncryptionStateIndicator->setObjectName(QLatin1String("encryptionindicator"));
61  mEncryptionStateIndicator->setAlignment( Qt::AlignHCenter );
62  hbox->addWidget( mEncryptionStateIndicator );
63  p.setColor( QPalette::Window, encryptedColor);
64  mEncryptionStateIndicator->setPalette( p );
65  mEncryptionStateIndicator->setAutoFillBackground( true );
66 }
67 
68 
69 CryptoStateIndicatorWidget::~CryptoStateIndicatorWidget()
70 {
71 }
72 
73 void CryptoStateIndicatorWidget::setShowAlwaysIndicator(bool status)
74 {
75  if (mShowAlwaysIndicator != status) {
76  mShowAlwaysIndicator = status;
77  updateShowAlwaysIndicator();
78  }
79 }
80 
81 void CryptoStateIndicatorWidget::updateShowAlwaysIndicator()
82 {
83  if ( mShowAlwaysIndicator ) {
84  mSignatureStateIndicator->setVisible( mIsSign );
85  mEncryptionStateIndicator->setVisible( mIsEncrypted );
86  } else {
87  mSignatureStateIndicator->setVisible( false );
88  mEncryptionStateIndicator->setVisible( false );
89  }
90 }
91 
92 void CryptoStateIndicatorWidget::updateSignatureAndEncrypionStateIndicators(bool isSign, bool isEncrypted)
93 {
94  mIsEncrypted = isEncrypted;
95  mIsSign = isSign;
96  mSignatureStateIndicator->setText( isSign ?
97  i18n("Message will be signed") :
98  i18n("Message will not be signed") );
99  mEncryptionStateIndicator->setText( isEncrypted ?
100  i18n("Message will be encrypted") :
101  i18n("Message will not be encrypted") );
102  updateShowAlwaysIndicator();
103 }
QWidget
QWidget::palette
palette
QWidget::setVisible
virtual void setVisible(bool visible)
QHBoxLayout
QLabel::setAlignment
void setAlignment(QFlags< Qt::AlignmentFlag >)
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QWidget::setLayout
void setLayout(QLayout *layout)
QObject::setObjectName
void setObjectName(const QString &name)
QLabel::setText
void setText(const QString &)
CryptoStateIndicatorWidget::updateSignatureAndEncrypionStateIndicators
void updateSignatureAndEncrypionStateIndicators(bool isSign, bool isEncrypted)
Definition: cryptostateindicatorwidget.cpp:92
QColor
QLayout::setMargin
void setMargin(int margin)
cryptostateindicatorwidget.h
QLatin1String
CryptoStateIndicatorWidget::setShowAlwaysIndicator
void setShowAlwaysIndicator(bool status)
Definition: cryptostateindicatorwidget.cpp:73
CryptoStateIndicatorWidget::~CryptoStateIndicatorWidget
~CryptoStateIndicatorWidget()
Definition: cryptostateindicatorwidget.cpp:69
QWidget::setAutoFillBackground
void setAutoFillBackground(bool enabled)
QLabel
QPalette
CryptoStateIndicatorWidget::CryptoStateIndicatorWidget
CryptoStateIndicatorWidget(QWidget *parent=0)
Definition: cryptostateindicatorwidget.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