Skip to content

Commit

Permalink
Update page button style
Browse files Browse the repository at this point in the history
IB-7961

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed May 15, 2024
1 parent ccb29a5 commit 3ec56a1
Show file tree
Hide file tree
Showing 17 changed files with 361 additions and 760 deletions.
4 changes: 0 additions & 4 deletions client/Colors.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,14 @@ namespace qdigidoc4
namespace colors
{
// Blues
static const QString ASTRONAUT_BLUE = QStringLiteral("#023664");
static const QString BAHAMA_BLUE = QStringLiteral("#035894");
static const QString CURIOUS_BLUE = QStringLiteral("#31A3D9");
static const QString DEEP_CERULEAN = QStringLiteral("#006EB5");
static const QString LOCHMARA = QStringLiteral("#008DCF");
// Reds
static const QString MOJO = QStringLiteral("#981E32");
// Whites
static const QString PORCELAIN = QStringLiteral("#f4f5f6");
static const QString WHITE = QStringLiteral("#ffffff");
// Golds-yellows
static const QString CLAY_CREEK = QStringLiteral("#998B66");
static const QString MARZIPAN = QStringLiteral("#F8DDA7");
// Green
static const QString MANTIS = QStringLiteral("#498526");
Expand Down
89 changes: 27 additions & 62 deletions client/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,9 @@ MainWindow::MainWindow( QWidget *parent )
setAcceptDrops( true );
ui->setupUi(this);

QFont version = Styles::font(Styles::Regular, 12);
version.setUnderline(true);
QFont condensed11 = Styles::font( Styles::Condensed, 11 );
QFont condensed14 = Styles::font( Styles::Condensed, 14 );
QFont regular20 = Styles::font( Styles::Regular, 20 );
ui->version->setFont(version);
ui->signIntroLabel->setFont( regular20 );
ui->signIntroButton->setFont( condensed14 );
ui->signIntroButton->setFocus();
Expand All @@ -90,17 +87,17 @@ MainWindow::MainWindow( QWidget *parent )
connect(ui->version, &QPushButton::clicked, this, [this] {showSettings(SettingsDialog::DiagnosticsSettings);});

ui->coatOfArms->load(QStringLiteral(":/images/Logo_small.svg"));
ui->signature->init( Pages::SignIntro, ui->signatureShadow, true );
ui->crypto->init( Pages::CryptoIntro, ui->cryptoShadow, false );
ui->myEid->init( Pages::MyEid, ui->myEidShadow, false );

connect(ui->signature, &PageIcon::activated, this, &MainWindow::clearPopups);
connect(ui->signature, &PageIcon::activated, this, &MainWindow::pageSelected);
connect(ui->crypto, &PageIcon::activated, this, &MainWindow::clearPopups);
connect(ui->crypto, &PageIcon::activated, this, &MainWindow::pageSelected);
connect(ui->myEid, &PageIcon::activated, this, &MainWindow::clearPopups);
connect(ui->myEid, &PageIcon::activated, this, &MainWindow::pageSelected);

ui->pageButtonGroup->setId(ui->signature, Pages::SignIntro);
ui->pageButtonGroup->setId(ui->crypto, Pages::CryptoIntro);
ui->pageButtonGroup->setId(ui->myEid, Pages::MyEid);

connect(ui->pageButtonGroup, &QButtonGroup::buttonToggled, this, &MainWindow::clearPopups);
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
connect(ui->pageButtonGroup, &QButtonGroup::idToggled, this, &MainWindow::pageSelected);
#else
connect(ui->pageButtonGroup, QOverload<QAbstractButton *, bool>::of(&QButtonGroup::buttonToggled), this,
[=](QAbstractButton *button, bool checked){ pageSelected(ui->pageButtonGroup->id(button), checked); });
#endif
ui->help->installEventFilter(new ButtonHoverFilter(QStringLiteral(":/images/icon_Abi.svg"), QStringLiteral(":/images/icon_Abi_hover.svg"), this));
ui->settings->installEventFilter(new ButtonHoverFilter(QStringLiteral(":/images/icon_Seaded.svg"), QStringLiteral(":/images/icon_Seaded_hover.svg"), this));
connect(ui->help, &QToolButton::clicked, qApp, &Application::openHelp);
Expand Down Expand Up @@ -176,39 +173,15 @@ MainWindow::~MainWindow()
delete ui;
}

void MainWindow::pageSelected(PageIcon *page)
void MainWindow::pageSelected(int page, bool checked)
{
// Stay in current view if same page icon clicked
auto current = ui->startScreen->currentIndex();
bool navigate = false;
switch(current)
{
case SignIntro:
case SignDetails:
navigate = (page->getType() != SignIntro);
break;
case CryptoIntro:
case CryptoDetails:
navigate = (page->getType() != CryptoIntro);
break;
default:
navigate = (page->getType() != current);
break;
}

Pages toPage = page->getType();
if(toPage == SignIntro && digiDoc)
{
selectPage(SignDetails);
if(!checked)
return;
}
if(toPage == CryptoIntro && cryptoDoc)
{
selectPage(CryptoDetails);
return;
}
if(navigate)
navigateToPage(toPage);
if(page == SignIntro && digiDoc)
page = SignDetails;
if(page == CryptoIntro && cryptoDoc)
page = CryptoDetails;
selectPage(Pages(page));
}

void MainWindow::adjustDrops()
Expand Down Expand Up @@ -345,7 +318,7 @@ void MainWindow::mouseReleaseEvent(QMouseEvent *event)
{
resetCryptoDoc();
resetDigiDoc();
navigateToPage(Pages::SignIntro);
selectPage(Pages::SignIntro);
}
else
QWidget::mouseReleaseEvent(event);
Expand Down Expand Up @@ -448,7 +421,7 @@ void MainWindow::onSignAction(int action, const QString &info1, const QString &i
break;
case ContainerCancel:
resetDigiDoc();
navigateToPage(Pages::SignIntro);
selectPage(Pages::SignIntro);
break;
case ContainerConvert:
if(digiDoc)
Expand Down Expand Up @@ -539,7 +512,7 @@ void MainWindow::onCryptoAction(int action, const QString &/*id*/, const QString
{
case ContainerCancel:
resetCryptoDoc();
navigateToPage(Pages::CryptoIntro);
selectPage(Pages::CryptoIntro);
break;
case ContainerConvert:
if(cryptoDoc)
Expand Down Expand Up @@ -687,9 +660,9 @@ void MainWindow::openFiles(const QStringList &files, bool addFile, bool forceCre
void MainWindow::open(const QStringList &params, bool crypto, bool sign)
{
if (crypto && !sign)
navigateToPage(Pages::CryptoIntro);
selectPage(Pages::CryptoIntro);
else
navigateToPage(Pages::SignIntro);
selectPage(Pages::SignIntro);

QStringList files;
for(const auto &param: params)
Expand Down Expand Up @@ -820,22 +793,14 @@ QString MainWindow::selectFile( const QString &title, const QString &filename, b

void MainWindow::selectPage(Pages page)
{
selectPageIcon( page < CryptoIntro ? ui->signature : (page == MyEid ? ui->myEid : ui->crypto));
auto *btn = page < CryptoIntro ? ui->signature : (page == MyEid ? ui->myEid : ui->crypto);
btn->setChecked(true);
ui->startScreen->setCurrentIndex(page);
warnings->updateWarnings();
adjustDrops();
updateSelector();
}

void MainWindow::selectPageIcon( PageIcon* page )
{
ui->rightShadow->raise();
for(auto *pageIcon: { ui->signature, ui->crypto, ui->myEid })
{
pageIcon->activate( pageIcon == page );
}
}

void MainWindow::showCardMenu(bool show)
{
if(show)
Expand Down Expand Up @@ -948,7 +913,7 @@ void MainWindow::removeCryptoFile(int index)
if(QFile::exists(cryptoDoc->fileName()))
QFile::remove(cryptoDoc->fileName());
resetCryptoDoc();
navigateToPage(Pages::CryptoIntro);
selectPage(Pages::CryptoIntro);
}
}

Expand Down Expand Up @@ -1005,7 +970,7 @@ void MainWindow::removeSignatureFile(int index)
if(QFile::exists(digiDoc->fileName()))
QFile::remove(digiDoc->fileName());
resetDigiDoc(nullptr, false);
navigateToPage(Pages::SignIntro);
selectPage(Pages::SignIntro);
}
}

Expand Down
3 changes: 1 addition & 2 deletions client/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private Q_SLOTS:
void changePin2Clicked( bool isForgotPin, bool isBlockedPin );
void changePukClicked();
void open(const QStringList &params, bool crypto, bool sign);
void pageSelected(PageIcon *page);
void pageSelected(int page, bool checked = true);
void warningClicked(const QString &link);

protected:
Expand Down Expand Up @@ -94,7 +94,6 @@ private Q_SLOTS:
bool save(bool saveAs = false);
QString selectFile( const QString &title, const QString &filename, bool fixedExt );
void selectPage(ria::qdigidoc4::Pages page);
void selectPageIcon( PageIcon* page );
void showCardMenu( bool show );
void showNotification( const QString &msg, bool isSuccess = false );
template <typename F>
Expand Down
Loading

0 comments on commit 3ec56a1

Please sign in to comment.