Skip to content

Commit

Permalink
Update notification label style
Browse files Browse the repository at this point in the history
IB-7963

Signed-off-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
metsma committed May 23, 2024
1 parent d93909a commit 8a2c3f8
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 140 deletions.
6 changes: 2 additions & 4 deletions client/CDoc2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "Application.h"
#include "CheckConnection.h"
#include "Colors.h"
#include "Crypto.h"
#include "QCryptoBackend.h"
#include "QSigner.h"
Expand Down Expand Up @@ -58,9 +57,8 @@ namespace cdoc20 {
if(CheckConnection().check())
return true;
return dispatchToMain([] {
auto *notification = new FadeInNotification(Application::mainWindow(),
ria::qdigidoc4::colors::WHITE, ria::qdigidoc4::colors::MANTIS);
notification->start(QCoreApplication::translate("MainWindow", "Check internet connection"), 750, 3000, 1200);
FadeInNotification::error(Application::mainWindow()->findChild<QWidget*>(QStringLiteral("topBar")),
QCoreApplication::translate("MainWindow", "Check internet connection"));
return false;
});
}
Expand Down
1 change: 0 additions & 1 deletion client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE
CDoc2.h
CheckConnection.cpp
CheckConnection.h
Colors.h
Crypto.cpp
Crypto.h
CryptoDoc.cpp
Expand Down
44 changes: 0 additions & 44 deletions client/Colors.h

This file was deleted.

37 changes: 13 additions & 24 deletions client/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include "Application.h"
#include "CheckConnection.h"
#include "Colors.h"
#include "CryptoDoc.h"
#include "DigiDoc.h"
#include "PrintSheet.h"
Expand Down Expand Up @@ -56,7 +55,7 @@
#include <QtWidgets/QMessageBox>

using namespace ria::qdigidoc4;
using namespace ria::qdigidoc4::colors;
using namespace std::chrono;

MainWindow::MainWindow( QWidget *parent )
: QWidget( parent )
Expand Down Expand Up @@ -457,11 +456,8 @@ void MainWindow::onSignAction(int action, const QString &info1, const QString &i

void MainWindow::convertToBDoc()
{
if(!wrap(cryptoDoc->fileName(), cryptoDoc->state() == EncryptedContainer))
return;

auto *notification = new FadeInNotification(this, WHITE, MANTIS);
notification->start( tr("Converted to signed document!"), 750, 3000, 1200 );
if(wrap(cryptoDoc->fileName(), cryptoDoc->state() == EncryptedContainer))
FadeInNotification::success(ui->topBar, tr("Converted to signed document!"));
}

void MainWindow::convertToCDoc()
Expand All @@ -488,8 +484,7 @@ void MainWindow::convertToCDoc()
ui->cryptoContainerPage->transition(cryptoDoc, qApp->signer()->tokenauth().cert());
selectPage(CryptoDetails);

auto *notification = new FadeInNotification(this, WHITE, MANTIS);
notification->start( tr("Converted to crypto container!"), 750, 3000, 1200 );
FadeInNotification::success(ui->topBar, tr("Converted to crypto container!"));
}

void MainWindow::moveCryptoContainer()
Expand Down Expand Up @@ -523,16 +518,14 @@ void MainWindow::onCryptoAction(int action, const QString &/*id*/, const QString
if(decrypt())
{
ui->cryptoContainerPage->transition(cryptoDoc, qApp->signer()->tokenauth().cert());
auto *notification = new FadeInNotification(this, WHITE, MANTIS);
notification->start( tr("Decryption succeeded!"), 750, 3000, 1200 );
FadeInNotification::success(ui->topBar, tr("Decryption succeeded!"));
}
break;
case EncryptContainer:
if(encrypt())
{
ui->cryptoContainerPage->transition(cryptoDoc, qApp->signer()->tokenauth().cert());
auto *notification = new FadeInNotification(this, WHITE, MANTIS);
notification->start( tr("Encryption succeeded!"), 750, 3000, 1200 );
FadeInNotification::success(ui->topBar, tr("Encryption succeeded!"));
}
break;
case ContainerSaveAs:
Expand Down Expand Up @@ -823,15 +816,13 @@ void MainWindow::showEvent(QShowEvent * /*event*/)
static bool isShown = false;
if(isShown)
return;
static const int height = 94;
static const int width = 166;
auto *notification = new FadeInNotification(this, WHITE, NONE,
QPoint(this->width() - width - 15, this->height() - height - 70), width, height);
QRect r{{}, QSize{166, 94}};
r.moveBottomRight(rect().bottomRight() - QPoint{15, 70});
auto *notification = new FadeInNotification(this, r);
notification->setFocusPolicy(Qt::NoFocus);
auto *structureFunds = new QSvgWidget(QStringLiteral(":/images/Struktuurifondid.svg"), notification);
structureFunds->resize(width, height);
structureFunds->show();
notification->start({}, 400, 3000, 1100);
structureFunds->resize(notification->size());
notification->start(400ms);
isShown = true;
}

Expand All @@ -858,8 +849,7 @@ void MainWindow::sign(F &&sign)
{
if(!CheckConnection().check())
{
auto *notification = new FadeInNotification(this, MOJO, MARZIPAN);
notification->start(tr("Check internet connection"), 750, 3000, 1200);
FadeInNotification::error(ui->topBar, tr("Check internet connection"));
return;
}

Expand Down Expand Up @@ -889,8 +879,7 @@ void MainWindow::sign(F &&sign)

ui->signContainerPage->transition(digiDoc);

auto *notification = new FadeInNotification(this, WHITE, MANTIS);
notification->start(tr("The container has been successfully signed!"), 750, 3000, 1200);
FadeInNotification::success(ui->topBar, tr("The container has been successfully signed!"));
adjustDrops();
}

Expand Down
3 changes: 1 addition & 2 deletions client/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,10 @@ private Q_SLOTS:
QString selectFile( const QString &title, const QString &filename, bool fixedExt );
void selectPage(ria::qdigidoc4::Pages page);
void showCardMenu( bool show );
void showNotification( const QString &msg, bool isSuccess = false );
template <typename F>
void sign(F &&sign);
void updateCardWarnings(const QSmartCardData &data);
bool validateCardError(QSmartCardData::PinType type, QSmartCardData::PinType t, QSmartCard::ErrorType err);
bool validateCardError(QSmartCardData::PinType type, QSmartCardData::PinType src, QSmartCard::ErrorType err);
bool validateFiles(const QString &container, const QStringList &files);
void showPinBlockedWarning(const QSmartCardData& t);
void updateSelector();
Expand Down
43 changes: 13 additions & 30 deletions client/MainWindow_MyEID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void MainWindow::pinUnblock( QSmartCardData::PinType type, bool isForgotPin )
{
if( isForgotPin )
text = tr("%1 changed!").arg( QSmartCardData::typeString( type ) );
showNotification( text, true );
FadeInNotification::success(ui->topBar, text);
QSmartCardData data = qApp->signer()->smartcard()->data();
updateCardWarnings(data);
if (type == QSmartCardData::Pin1Type)
Expand All @@ -84,32 +84,22 @@ void MainWindow::pinUnblock( QSmartCardData::PinType type, bool isForgotPin )

void MainWindow::pinPukChange( QSmartCardData::PinType type )
{
if(validateCardError(type, type,
qApp->signer()->smartcard()->pinChange(type, this)))
{
showNotification( tr("%1 changed!")
.arg( QSmartCardData::typeString( type ) ), true );
}
if(validateCardError(type, type, qApp->signer()->smartcard()->pinChange(type, this)))
FadeInNotification::success(ui->topBar, tr("%1 changed!").arg(QSmartCardData::typeString(type)));
}

bool MainWindow::validateCardError(QSmartCardData::PinType type, QSmartCardData::PinType t, QSmartCard::ErrorType err)
bool MainWindow::validateCardError(QSmartCardData::PinType type, QSmartCardData::PinType src, QSmartCard::ErrorType err)
{
QSmartCardData data = qApp->signer()->smartcard()->data();
ui->accordion->updateInfo(data);
switch( err )
{
case QSmartCard::NoError: return true;
case QSmartCard::CancelError:
#ifdef Q_OS_WIN
if(!data.isNull() && data.isPinpad())
if(data.authCert().subjectInfo(QSslCertificate::CountryName) == QStringLiteral("EE")) // only for Estonian ID card
{
showNotification( tr("%1 timeout").arg( QSmartCardData::typeString( type ) ) );
}
#endif
FadeInNotification::warning(ui->topBar, tr("%1 timeout").arg(QSmartCardData::typeString(type)));
break;
case QSmartCard::BlockedError:
showNotification( tr("%1 blocked").arg( QSmartCardData::typeString( t ) ) );
FadeInNotification::warning(ui->topBar, tr("%1 blocked").arg(QSmartCardData::typeString(src)));
showPinBlockedWarning(data);
selectPage(Pages::MyEid);
ui->myEid->warningIcon(
Expand All @@ -118,33 +108,26 @@ bool MainWindow::validateCardError(QSmartCardData::PinType type, QSmartCardData:
data.retryCount(QSmartCardData::PukType) == 0 );
break;
case QSmartCard::DifferentError:
showNotification( tr("New %1 codes doesn't match").arg( QSmartCardData::typeString( type ) ) );
FadeInNotification::warning(ui->topBar, tr("New %1 codes doesn't match").arg(QSmartCardData::typeString(type)));
break;
case QSmartCard::LenghtError:
showNotification(tr("%1 length has to be between %2 and 12").arg(QSmartCardData::typeString(type)).arg(QSmartCardData::minPinLen(type)));
FadeInNotification::warning(ui->topBar, tr("%1 length has to be between %2 and 12")
.arg(QSmartCardData::typeString(type)).arg(QSmartCardData::minPinLen(type)));
break;
case QSmartCard::OldNewPinSameError:
showNotification( tr("Old and new %1 has to be different!").arg( QSmartCardData::typeString( type ) ) );
FadeInNotification::warning(ui->topBar, tr("Old and new %1 has to be different!").arg(QSmartCardData::typeString(type)));
break;
case QSmartCard::ValidateError:
showNotification( tr("Wrong %1 code. You can try %n more time(s).", nullptr,
data.retryCount(t)).arg( QSmartCardData::typeString(t)));
FadeInNotification::warning(ui->topBar, tr("Wrong %1 code. You can try %n more time(s).", nullptr,
data.retryCount(src)).arg(QSmartCardData::typeString(src)));
break;
default:
showNotification(tr("Changing %1 failed").arg(QSmartCardData::typeString(type)));
FadeInNotification::warning(ui->topBar, tr("Changing %1 failed").arg(QSmartCardData::typeString(type)));
break;
}
return false;
}

void MainWindow::showNotification( const QString &msg, bool isSuccess )
{
auto *notification = new FadeInNotification(this,
isSuccess ? QStringLiteral("#ffffff") : QStringLiteral("#353739"),
isSuccess ? QStringLiteral("#498526") : QStringLiteral("#F8DDA7"));
notification->start(msg, 750, 3000, 1200);
}

void MainWindow::showPinBlockedWarning(const QSmartCardData& t)
{
bool isBlockedPuk = t.retryCount(QSmartCardData::PukType) == 0;
Expand Down
9 changes: 2 additions & 7 deletions client/dialogs/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "CertStore.h"
#endif
#include "CheckConnection.h"
#include "Colors.h"
#include "Diagnostics.h"
#include "FileDialog.h"
#include "QSigner.h"
Expand Down Expand Up @@ -287,22 +286,18 @@ void SettingsDialog::checkConnection()
if(CheckConnection connection; !connection.check())
{
Application::restoreOverrideCursor();
auto *notification = new FadeInNotification(this,
ria::qdigidoc4::colors::MOJO, ria::qdigidoc4::colors::MARZIPAN, 0, 120);
QString error;
QString details = connection.errorDetails();
QTextStream s(&error);
s << connection.errorString();
if (!details.isEmpty())
s << "\n\n" << details << ".";
notification->start(error, 750, 3000, 1200);
FadeInNotification::error(this, error, 120);
}
else
{
Application::restoreOverrideCursor();
auto *notification = new FadeInNotification(this,
ria::qdigidoc4::colors::WHITE, ria::qdigidoc4::colors::MANTIS, 0, 120);
notification->start(tr("The connection to certificate status service is successful!"), 750, 3000, 1200);
FadeInNotification::success(this, tr("The connection to certificate status service is successful!"));
}
}

Expand Down
Loading

0 comments on commit 8a2c3f8

Please sign in to comment.