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

Clean code to allow to create unittest on it

parent 812e301a
......@@ -17,7 +17,6 @@
#include "cryptostateindicatorwidget.h"
#include "messagecore/settings/globalsettings.h"
#include "settings/globalsettings.h"
#include <KColorScheme>
#include <KLocalizedString>
......@@ -27,7 +26,9 @@
CryptoStateIndicatorWidget::CryptoStateIndicatorWidget(QWidget *parent)
: QWidget(parent),
mShowAlwaysIndicator(true)
mShowAlwaysIndicator(true),
mIsSign(false),
mIsEncrypted(false)
{
QHBoxLayout *hbox = new QHBoxLayout;
setLayout(hbox);
......@@ -60,7 +61,6 @@ CryptoStateIndicatorWidget::CryptoStateIndicatorWidget(QWidget *parent)
p.setColor( QPalette::Window, encryptedColor);
mEncryptionStateIndicator->setPalette( p );
mEncryptionStateIndicator->setAutoFillBackground( true );
mShowAlwaysIndicator = GlobalSettings::self()->showCryptoLabelIndicator();
}
......@@ -68,19 +68,34 @@ CryptoStateIndicatorWidget::~CryptoStateIndicatorWidget()
{
}
void CryptoStateIndicatorWidget::setShowAlwaysIndicator(bool status)
{
if (mShowAlwaysIndicator != status) {
mShowAlwaysIndicator = status;
updateShowAlwaysIndicator();
}
}
void CryptoStateIndicatorWidget::updateShowAlwaysIndicator()
{
if ( mShowAlwaysIndicator ) {
mSignatureStateIndicator->setVisible( mIsSign );
mEncryptionStateIndicator->setVisible( mIsEncrypted );
} else {
mSignatureStateIndicator->setVisible( false );
mEncryptionStateIndicator->setVisible( false );
}
}
void CryptoStateIndicatorWidget::updateSignatureAndEncrypionStateIndicators(bool isSign, bool isEncrypted)
{
mIsEncrypted = isEncrypted;
mIsSign = isSign;
mSignatureStateIndicator->setText( isSign ?
i18n("Message will be signed") :
i18n("Message will not be signed") );
mEncryptionStateIndicator->setText( isEncrypted ?
i18n("Message will be encrypted") :
i18n("Message will not be encrypted") );
if ( mShowAlwaysIndicator ) {
mSignatureStateIndicator->setVisible( isSign );
mEncryptionStateIndicator->setVisible( isEncrypted );
} else {
mSignatureStateIndicator->setVisible( false );
mEncryptionStateIndicator->setVisible( false );
}
updateShowAlwaysIndicator();
}
......@@ -30,10 +30,15 @@ public:
void updateSignatureAndEncrypionStateIndicators(bool isSign, bool isEncrypted);
void setShowAlwaysIndicator(bool status);
private:
void updateShowAlwaysIndicator();
QLabel *mSignatureStateIndicator;
QLabel *mEncryptionStateIndicator;
bool mShowAlwaysIndicator;
bool mIsSign;
bool mIsEncrypted;
};
#endif // CRYPTOSTATEINDICATORWIDGET_H
......@@ -357,6 +357,7 @@ KMComposeWin::KMComposeWin( const KMime::Message::Ptr &aMsg, bool lastSignState,
QWidget *editorAndCryptoStateIndicators = new QWidget( mSplitter );
mCryptoStateIndicatorWidget = new CryptoStateIndicatorWidget;
mCryptoStateIndicatorWidget->setShowAlwaysIndicator(GlobalSettings::self()->showCryptoLabelIndicator());
QVBoxLayout *vbox = new QVBoxLayout(editorAndCryptoStateIndicators);
vbox->setMargin(0);
......
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