File indexing completed on 2024-11-10 04:48:57
0001 /* 0002 * 0003 * This file is part of KMail, the KDE mail client. 0004 * 0005 * SPDX-FileCopyrightText: 2003 Zack Rusin <zack@kde.org> 0006 * 0007 * SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #include "ssllabel.h" 0011 0012 #include <KLocalizedString> 0013 0014 #include <QIcon> 0015 #include <QStyle> 0016 0017 using namespace KPIM; 0018 0019 SSLLabel::SSLLabel(QWidget *parent) 0020 : QLabel(parent) 0021 { 0022 setState(Done); 0023 } 0024 0025 void SSLLabel::setEncrypted(SSLLabel::State state) 0026 { 0027 m_lastEncryptionState = state; 0028 } 0029 0030 SSLLabel::State SSLLabel::lastState() const 0031 { 0032 return m_lastEncryptionState; 0033 } 0034 0035 void SSLLabel::setState(State state) 0036 { 0037 switch (state) { 0038 case Encrypted: 0039 setToolTip(i18n("Connection is encrypted")); 0040 setPixmap(QIcon::fromTheme(QStringLiteral("security-high")).pixmap(style()->pixelMetric(QStyle::PM_SmallIconSize))); 0041 show(); 0042 break; 0043 case Unencrypted: 0044 setToolTip(i18n("Connection is unencrypted")); 0045 setPixmap(QIcon::fromTheme(QStringLiteral("security-low")).pixmap(style()->pixelMetric(QStyle::PM_SmallIconSize))); 0046 show(); 0047 break; 0048 case Unknown: 0049 case Done: 0050 setToolTip(QString()); 0051 hide(); 0052 break; 0053 case Clean: 0054 setToolTip(QString()); 0055 hide(); 0056 // we return because we do not save the state as the only 0057 // action we want to perform is to hide ourself 0058 return; 0059 } 0060 m_lastEncryptionState = state; 0061 }