From 530265eec3d6e1386e737e8982b1d1e6f940b86c Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Wed, 29 Mar 2023 13:20:45 +0300 Subject: [PATCH] Remove photo widgets (#1176) IB-7691 Signed-off-by: Raul Metsma --- client/CMakeLists.txt | 1 - client/MainWindow.cpp | 36 +- client/MainWindow.h | 1 - client/MainWindow_MyEID.cpp | 1 - client/common_enums.h | 2 - client/images/icon_person_blue.svg | 16 - client/images/images.qrc | 1 - client/sslConnect.cpp | 143 ------- client/sslConnect.h | 43 -- client/translations/en.ts | 50 --- client/translations/et.ts | 50 --- client/translations/ru.ts | 52 --- client/widgets/CardPopup.cpp | 15 +- client/widgets/CardWidget.cpp | 70 +-- client/widgets/CardWidget.h | 5 - client/widgets/CardWidget.ui | 224 +++------- client/widgets/InfoStack.cpp | 69 --- client/widgets/InfoStack.h | 7 - client/widgets/InfoStack.ui | 658 ++++++++++++----------------- client/widgets/LabelButton.cpp | 17 - client/widgets/LabelButton.h | 3 - 21 files changed, 352 insertions(+), 1112 deletions(-) delete mode 100644 client/images/icon_person_blue.svg delete mode 100644 client/sslConnect.cpp delete mode 100644 client/sslConnect.h diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index d172b6bb0..ae59c2efd 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -38,7 +38,6 @@ add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE QPKCS11.cpp QSigner.cpp QSmartCard.cpp - sslConnect.cpp Styles.cpp PrintSheet.cpp Settings.cpp diff --git a/client/MainWindow.cpp b/client/MainWindow.cpp index 327c04405..338474112 100644 --- a/client/MainWindow.cpp +++ b/client/MainWindow.cpp @@ -30,7 +30,6 @@ #include "QSigner.h" #include "Settings.h" #include "Styles.h" -#include "sslConnect.h" #include "TokenData.h" #include "effects/ButtonHoverFilter.h" #include "effects/FadeInNotification.h" @@ -165,19 +164,7 @@ MainWindow::MainWindow( QWidget *parent ) connect(ui->accordion, &Accordion::changePin1Clicked, this, &MainWindow::changePin1Clicked); connect(ui->accordion, &Accordion::changePin2Clicked, this, &MainWindow::changePin2Clicked); connect(ui->accordion, &Accordion::changePukClicked, this, &MainWindow::changePukClicked); - connect(ui->infoStack, &InfoStack::photoClicked, this, &MainWindow::photoClicked); - connect(ui->cardInfo, &CardWidget::photoClicked, this, &MainWindow::photoClicked); // To load photo connect(ui->cardInfo, &CardWidget::selected, ui->selector->selector, &DropdownButton::press); - connect(SSLConnect::instance(), &SSLConnect::error, this, [this](const QString &error) { - qWarning() << error; - showNotification(tr("Loading picture failed.")); - }); - connect(SSLConnect::instance(), &SSLConnect::image, this, [this] (const QImage &image) { - ui->infoStack->setProperty("PICTURE", image); - QPixmap pixmap = QPixmap::fromImage(image); - ui->cardInfo->showPicture(pixmap); - ui->infoStack->showPicture(pixmap); - }); updateSelectorData(qApp->signer()->tokensign()); updateMyEID(qApp->signer()->tokensign()); @@ -853,6 +840,8 @@ void MainWindow::showCardMenu(bool show) { if(show) { + if(ui->selector->list.isEmpty()) + return; auto *cardPopup = new CardPopup(ui->selector->list, this); connect(cardPopup, &CardPopup::activated, qApp->signer(), &QSigner::selectCard, Qt::QueuedConnection); connect(cardPopup, &CardPopup::activated, this, [this] { showCardMenu(false); }); // .. and hide card popup menu @@ -944,27 +933,6 @@ void MainWindow::sign(F &&sign) adjustDrops(); } -void MainWindow::photoClicked() -{ - if(!ui->infoStack->property("PICTURE").isValid()) - { - SSLConnect::instance()->fetch(); - return; - } - QString fileName = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); - fileName += "/" + qApp->signer()->tokenauth().card(); - fileName = QFileDialog::getSaveFileName(this,tr("Save photo"), fileName, - tr("Photo (*.jpg *.jpeg);;All Files (*)")); - if(fileName.isEmpty()) - return; - static const QStringList exts{QStringLiteral("jpg"), QStringLiteral("jpeg")}; - if(!exts.contains(QFileInfo(fileName).suffix(), Qt::CaseInsensitive)) - fileName.append(QStringLiteral(".jpg")); - auto pix = ui->infoStack->property("PICTURE").value(); - if(!pix.save(fileName)) - warnings->showWarning(DocumentModel::tr("Failed to save file '%1'").arg(fileName)); -} - void MainWindow::removeAddress(int index) { if(cryptoDoc) diff --git a/client/MainWindow.h b/client/MainWindow.h index f9861d525..c6df059f5 100644 --- a/client/MainWindow.h +++ b/client/MainWindow.h @@ -55,7 +55,6 @@ private Q_SLOTS: void changePukClicked(); void open(const QStringList ¶ms, bool crypto, bool sign); void pageSelected(PageIcon *page); - void photoClicked(); void warningClicked(const QString &link); protected: diff --git a/client/MainWindow_MyEID.cpp b/client/MainWindow_MyEID.cpp index b3f8a4600..c53025695 100644 --- a/client/MainWindow_MyEID.cpp +++ b/client/MainWindow_MyEID.cpp @@ -218,7 +218,6 @@ void MainWindow::updateMyEID(const TokenData &t) } else { - ui->infoStack->setProperty("PICTURE", QVariant()); ui->infoStack->clearData(); ui->accordion->clear(); ui->myEid->invalidIcon(false); diff --git a/client/common_enums.h b/client/common_enums.h index d72c8a11b..aab7c49a3 100644 --- a/client/common_enums.h +++ b/client/common_enums.h @@ -39,8 +39,6 @@ enum ContainerState { enum Actions { AddressAdd, - CardPhoto, - ContainerCancel, ContainerConvert, ContainerEncrypt, diff --git a/client/images/icon_person_blue.svg b/client/images/icon_person_blue.svg deleted file mode 100644 index 0280d1a0a..000000000 --- a/client/images/icon_person_blue.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - diff --git a/client/images/images.qrc b/client/images/images.qrc index f404ffe61..74cb9b6bb 100644 --- a/client/images/images.qrc +++ b/client/images/images.qrc @@ -40,7 +40,6 @@ icon_Krypto.svg icon_Minu_eID_hover.svg icon_Minu_eID.svg - icon_person_blue.svg icon_radio.png icon_radio_checked.png icon_remove_hover.svg diff --git a/client/sslConnect.cpp b/client/sslConnect.cpp deleted file mode 100644 index 81b65e077..000000000 --- a/client/sslConnect.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * QEstEidUtil - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "sslConnect.h" - -#include "Application.h" -#include "MainWindow.h" -#include "QSigner.h" -#include "TokenData.h" -#include "dialogs/WaitDialog.h" - -#include -#include -#include -#include -#include - -class SSLConnect::Private -{ -public: - QSslConfiguration ssl = QSslConfiguration::defaultConfiguration(); - QList trusted; -}; - -SSLConnect::SSLConnect(QObject *parent) - : QObject(parent) - , d(new Private) -{ -#ifdef CONFIG_URL - d->ssl.setCaCertificates({}); - for(const auto c: qApp->confValue(QLatin1String("CERT-BUNDLE")).toArray()) - d->trusted.append(QSslCertificate(QByteArray::fromBase64(c.toString().toLatin1()), QSsl::Der)); -#endif -} - -SSLConnect::~SSLConnect() -{ - delete d; -} - -void SSLConnect::fetch() -{ - QWidget *active = qApp->activeWindow(); - for(QWidget *w: qApp->topLevelWidgets()) - { - if(MainWindow *main = qobject_cast(w)) - { - active = main; - break; - } - } - WaitDialogHolder *popup = new WaitDialogHolder(active, tr("Downloading picture")); - - QSslCertificate cert = qApp->signer()->tokenauth().cert(); - QSslKey key = qApp->signer()->key(); - if(cert.isNull() || key.isNull()) - { - delete popup; - emit error(QStringLiteral("Private key is missing")); - return; - } - d->ssl.setPrivateKey(key); - d->ssl.setLocalCertificate(cert); - - QNetworkRequest req; - req.setSslConfiguration(d->ssl); - req.setRawHeader("User-Agent", QString(QStringLiteral("%1/%2 (%3)")) - .arg(qApp->applicationName(), qApp->applicationVersion(), Common::applicationOs()).toUtf8()); - req.setUrl(qApp->confValue(QLatin1String("PICTURE-URL")).toString(QStringLiteral("https://sisene.www.eesti.ee/idportaal/portaal.idpilt"))); - - QNetworkAccessManager *nam = new QNetworkAccessManager(this); - connect(nam, &QNetworkAccessManager::sslErrors, this, [=](QNetworkReply *reply, const QList &errors){ - QList ignore; - for(const QSslError &error: errors) - { - switch(error.error()) - { - case QSslError::UnableToGetLocalIssuerCertificate: - case QSslError::CertificateUntrusted: - case QSslError::SelfSignedCertificateInChain: - if(d->trusted.contains(reply->sslConfiguration().peerCertificate())) { - ignore << error; - break; - } - default: break; - } - } - reply->ignoreSslErrors(ignore); - }); - QNetworkReply *reply = nam->get(req); - connect(reply, &QNetworkReply::finished, this, [this, popup, reply] { - qApp->signer()->logout(); - delete popup; - if(reply->error() != QNetworkReply::NoError) - { - emit error(reply->errorString()); - return; - } - if(!reply->header(QNetworkRequest::ContentTypeHeader).toByteArray().contains("image/jpeg")) - { - emit error(QStringLiteral("Invalid Content-Type")); - return; - } - QByteArray result = reply->readAll(); - reply->manager()->deleteLater(); - - if(result.isEmpty()) - { - emit error(QStringLiteral("Empty content")); - return; - } - - QImage img; - if(!img.loadFromData(result)) - { - emit error(QStringLiteral("Failed to parse image")); - return; - } - emit image(img); - }); -} - -SSLConnect* SSLConnect::instance() -{ - static SSLConnect sslConnect; - return &sslConnect; -} diff --git a/client/sslConnect.h b/client/sslConnect.h deleted file mode 100644 index 3e4afe212..000000000 --- a/client/sslConnect.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * QEstEidUtil - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#pragma once - -#include - -class SSLConnect final: public QObject -{ - Q_OBJECT - -public: - ~SSLConnect() final; - - static SSLConnect* instance(); - void fetch(); - -signals: - void error(const QString &msg); - void image(const QImage &image); - -private: - explicit SSLConnect(QObject *parent = nullptr); - - class Private; - Private *d; -}; diff --git a/client/translations/en.ts b/client/translations/en.ts index 915c815dd..fe24cdf70 100644 --- a/client/translations/en.ts +++ b/client/translations/en.ts @@ -263,10 +263,6 @@ CardWidget - - LOAD - LOAD - ID-card ID-card @@ -279,16 +275,6 @@ e-Seal e-Seal - - Load picture - accessible - Load picture - - - Load - accessible - Load - Certificate for Encryption Certificate for Encryption @@ -889,10 +875,6 @@ Cannot add the file to the envelope. File '%1' is already in container. Cannot add the file to the envelope. File '%1' is already in container. - - Failed to save file '%1' - Failed to save file '%1' - Internal error Internal error @@ -1150,10 +1132,6 @@ InfoStack - - DOWNLOAD - LOAD PICTURE - CITIZENSHIP CITIZENSHIP @@ -1186,10 +1164,6 @@ COUNTRY COUNTRY - - SAVE THE PICTURE - SAVE THE PICTURE - You're using digital identity card You're using digital identity card @@ -1206,11 +1180,6 @@ Expired Expired - - Load picture - accessible - Load picture - Given names accessible @@ -1530,10 +1499,6 @@ ID-CARD The container has been successfully signed! The container has been successfully signed! - - Save photo - Save photo - Ver. Ver. @@ -1620,10 +1585,6 @@ ID-CARD %1 changed! %1 changed! - - Loading picture failed. - Loading picture failed. - Encrypting Encrypting @@ -1667,10 +1628,6 @@ ID-CARD Check internet connection Check internet connection - - Photo (*.jpg *.jpeg);;All Files (*) - Photo (*.jpg *.jpeg);;All Files (*) - Load file from disk for signing or verifying accessible @@ -2415,13 +2372,6 @@ and enter Smart-ID PIN2-code. Failed remove document from container - - SSLConnect - - Downloading picture - Downloading picture - - SettingsDialog diff --git a/client/translations/et.ts b/client/translations/et.ts index d3a943199..1a7def32d 100644 --- a/client/translations/et.ts +++ b/client/translations/et.ts @@ -263,10 +263,6 @@ CardWidget - - LOAD - LAADI - ID-card ID-kaart @@ -279,16 +275,6 @@ e-Seal e-Tempel - - Load picture - accessible - Laadi pilt - - - Load - accessible - Laadi - Certificate for Encryption krüpteerimissertifikaat @@ -889,10 +875,6 @@ Cannot add the file to the envelope. File '%1' is already in container. Faili lisamine ümbrikusse ebaõnnestus. Lisatud '%1' on juba ümbrikus olemas. - - Failed to save file '%1' - Faili '%1' salvestamine ebaõnnestus - Internal error Sisemine viga @@ -1150,10 +1132,6 @@ InfoStack - - DOWNLOAD - LAADI PILT - CITIZENSHIP KODAKONDSUS @@ -1186,10 +1164,6 @@ COUNTRY RIIK - - SAVE THE PICTURE - SALVESTA PILT - You're using digital identity card Kasutate digitaalset isikutunnistust @@ -1206,11 +1180,6 @@ Expired Aegunud - - Load picture - accessible - Laadi pilt - Given names accessible @@ -1530,10 +1499,6 @@ ID-KAARDIGA The container has been successfully signed! Ümbrik on edukalt allkirjastatud! - - Save photo - Salvesta foto - Ver. Ver. @@ -1620,10 +1585,6 @@ ID-KAARDIGA %1 changed! %1-kood muudetud! - - Loading picture failed. - Pildi laadimine ebaõnnestus. - Encrypting Krüpteerin @@ -1667,10 +1628,6 @@ ID-KAARDIGA Check internet connection Kontrolli internetiühendust - - Photo (*.jpg *.jpeg);;All Files (*) - Foto (*.jpg *.jpeg);;Kõik failid (*) - Load file from disk for signing or verifying accessible @@ -2415,13 +2372,6 @@ ja sisesta nutiseadmes Smart-ID PIN2-kood. Faili eemaldamine ümbrikust ebaõnnestus - - SSLConnect - - Downloading picture - Laadin pilti - - SettingsDialog diff --git a/client/translations/ru.ts b/client/translations/ru.ts index 59f2574fd..591f7207b 100644 --- a/client/translations/ru.ts +++ b/client/translations/ru.ts @@ -263,11 +263,6 @@ CardWidget - - LOAD - ЗАГРУ -ЗИТЬ - ID-card ID-kарта @@ -280,17 +275,6 @@ e-Seal э-Печать - - Load picture - accessible - Загрузить фото - - - Load - accessible - Загру -Зить - Certificate for Encryption сертификат шифрования @@ -891,10 +875,6 @@ Cannot add the file to the envelope. File '%1' is already in container. Невозможно добавить файл в контейнер. Файл '%1' уже в контейнере. - - Failed to save file '%1' - Неудачное сохранение файла '%1' - Internal error Внутренняя ошибка @@ -1152,10 +1132,6 @@ InfoStack - - DOWNLOAD - ЗАГРУЗИТЬ ФОТО - CITIZENSHIP ГРАЖДАНСТВО @@ -1188,10 +1164,6 @@ COUNTRY КОД СТРАНЫ - - SAVE THE PICTURE - СОХРАНИТЬ ФОТО - You're using digital identity card Вы используете дигитальное удостоверение личности @@ -1208,11 +1180,6 @@ Expired Истекший - - Load picture - accessible - Загрузить фото - Given names accessible @@ -1532,10 +1499,6 @@ ID-КАРТОЙ The container has been successfully signed! Контейнер успешно подписан! - - Save photo - Сохранить фото - Ver. Вер. @@ -1622,10 +1585,6 @@ ID-КАРТОЙ %1 changed! %1-код изменён! - - Loading picture failed. - Загрузка картинки неуспешна. - Encrypting Зашифровывание @@ -1670,10 +1629,6 @@ ID-КАРТОЙ Check internet connection Проверьте подключение к Интернету - - Photo (*.jpg *.jpeg);;All Files (*) - Фото (*.jpg *.jpeg);;Все файлы (*) - Load file from disk for signing or verifying accessible @@ -2418,13 +2373,6 @@ and enter Smart-ID PIN2-code. Не удается удалить файл из контейнера - - SSLConnect - - Downloading picture - Загрузка картинки - - SettingsDialog diff --git a/client/widgets/CardPopup.cpp b/client/widgets/CardPopup.cpp index 204778839..a61e443a2 100644 --- a/client/widgets/CardPopup.cpp +++ b/client/widgets/CardPopup.cpp @@ -26,21 +26,22 @@ CardPopup::CardPopup(const QVector &cache, QWidget *parent) : StyledWidget(parent) { - if(CardWidget *cardInfo = parent->findChild(QStringLiteral("cardInfo"))) + setObjectName(QStringLiteral("CardPopup")); + setStyleSheet(QStringLiteral("#CardPopup {" + "border: solid rgba(217, 217, 216, 0.45); " + "border-width: 0px 2px 2px 1px; " + "background-color: rgba(255, 255, 255, 0.95); }")); + if(auto *cardInfo = parent->findChild(QStringLiteral("cardInfo"))) { move(cardInfo->mapTo(parent, cardInfo->rect().bottomLeft()) + QPoint(0, 2)); setMinimumWidth(cardInfo->width()); } - setStyleSheet(QStringLiteral( - "border: solid rgba(217, 217, 216, 0.45); " - "border-width: 0px 2px 2px 1px; " - "background-color: rgba(255, 255, 255, 0.95);")); - QVBoxLayout *layout = new QVBoxLayout(this); + auto *layout = new QVBoxLayout(this); layout->setContentsMargins(1, 0, 2, 2); for(const TokenData &token: cache) { - auto cardWidget = new CardWidget(true, this); + auto *cardWidget = new CardWidget(true, this); cardWidget->setCursor(QCursor(Qt::PointingHandCursor)); cardWidget->update(token, true); connect(cardWidget, &CardWidget::selected, this, &CardPopup::activated); diff --git a/client/widgets/CardWidget.cpp b/client/widgets/CardWidget.cpp index e89a447fc..cc1ccc916 100644 --- a/client/widgets/CardWidget.cpp +++ b/client/widgets/CardWidget.cpp @@ -40,17 +40,8 @@ CardWidget::CardWidget(bool popup, QWidget *parent) ui->cardCode->installEventFilter(this); ui->cardStatus->setFont( font ); ui->cardStatus->installEventFilter(this); - ui->cardPhoto->init(LabelButton::None, QString(), CardPhoto); - ui->cardPhoto->installEventFilter(this); - ui->load->setFont(Styles::font(Styles::Condensed, 9)); - ui->load->hide(); ui->cardIcon->load(QStringLiteral(":/images/icon_IDkaart_green.svg")); - ui->contentLayout->setAlignment(ui->cardIcon, Qt::AlignBaseline); - - connect(ui->cardPhoto, &LabelButton::clicked, this, [this] { - if(!seal) - emit photoClicked(); - }); + ui->CardWidgetLayout->setAlignment(ui->cardIcon, Qt::AlignBaseline); } CardWidget::CardWidget(QWidget *parent) @@ -62,20 +53,6 @@ CardWidget::~CardWidget() delete ui; } -void CardWidget::clearPicture() -{ - clearSeal(); - ui->cardPhoto->clear(); -} - -void CardWidget::clearSeal() -{ - if(seal) - seal->deleteLater(); - seal = nullptr; - ui->cardPhoto->setCursor(QCursor(Qt::PointingHandCursor)); -} - TokenData CardWidget::token() const { return t; @@ -99,32 +76,17 @@ bool CardWidget::event( QEvent *ev ) bool CardWidget::eventFilter(QObject *o, QEvent *e) { - switch(e->type()) + if(e->type() == QEvent::MouseButtonRelease && + (o == ui->cardName || o == ui->cardStatus || o == ui->cardCode)) { - case QEvent::MouseButtonRelease: - if(o == ui->cardName || o == ui->cardStatus || o == ui->cardCode) - { - emit selected(t); - return true; - } - break; - case QEvent::HoverEnter: - if(o == ui->cardPhoto && !ui->cardPhoto->pixmap() && !seal) - ui->load->show(); - break; - case QEvent::HoverLeave: - if(o == ui->cardPhoto) - ui->load->hide(); - break; - default: break; + emit selected(t); + return true; } return StyledWidget::eventFilter(o, e); } void CardWidget::update(const TokenData &token, bool multiple) { - if(t != token) - ui->cardPhoto->clear(); t = token; SslCertificate c = t.cert(); QString id = c.personalCode(); @@ -135,7 +97,6 @@ void CardWidget::update(const TokenData &token, bool multiple) ui->cardName->setAccessibleName(ui->cardName->text().toLower()); ui->cardCode->setText(id + " |"); ui->cardCode->setAccessibleName(id); - ui->load->setText(tr("LOAD")); int type = c.type(); QString typeString = tr("ID-card"); @@ -155,25 +116,4 @@ void CardWidget::update(const TokenData &token, bool multiple) ui->cardStatus->setText(typeString); ui->cardIcon->load(QStringLiteral(":/images/icon_IDkaart_green.svg")); - ui->cardPhoto->setHidden(c.type() & SslCertificate::EResidentSubType); - ui->horizontalSpacer->changeSize(ui->cardPhoto->isVisible() ? 10 : 1, 20, QSizePolicy::Fixed); - - clearSeal(); - if(type & SslCertificate::TempelType) - { - ui->cardPhoto->clear(); - seal = new QSvgWidget(ui->cardPhoto); - seal->load(QStringLiteral(":/images/icon_digitempel.svg")); - seal->resize(32, 32); - seal->move(1, 6); - seal->show(); - seal->setStyleSheet(QStringLiteral("border: none;")); - ui->cardPhoto->unsetCursor(); - } -} - -void CardWidget::showPicture( const QPixmap &pix ) -{ - clearSeal(); - ui->cardPhoto->setPixmap(pix.scaled(ui->cardPhoto->width(), ui->cardPhoto->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); } diff --git a/client/widgets/CardWidget.h b/client/widgets/CardWidget.h index dfea78097..bb0957eed 100644 --- a/client/widgets/CardWidget.h +++ b/client/widgets/CardWidget.h @@ -36,23 +36,18 @@ class CardWidget final: public StyledWidget explicit CardWidget(bool popup, QWidget *parent = nullptr); ~CardWidget() final; - void clearPicture(); TokenData token() const; - void showPicture( const QPixmap &pix ); void update(const TokenData &token, bool multiple); signals: - void photoClicked(); void selected(const TokenData &token); private: bool event(QEvent *ev) final; bool eventFilter(QObject *o, QEvent *e) final; - void clearSeal(); Ui::CardWidget *ui; TokenData t; - QSvgWidget *seal = nullptr; bool isPopup = false; bool isMultiple = false; }; diff --git a/client/widgets/CardWidget.ui b/client/widgets/CardWidget.ui index 4efbc31a4..94d9b861f 100644 --- a/client/widgets/CardWidget.ui +++ b/client/widgets/CardWidget.ui @@ -11,13 +11,9 @@ - QWidget:!hover { border:none; } -QWidget:hover { border:none; background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 rgba(0, 118, 190, 0.15), stop: 1 rgba(255,255,255, 0.5)); } + #CardWidget:hover { background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 rgba(0, 118, 190, 0.15), stop: 1 rgba(255,255,255, 0.5)); } - - - 0 - + 10 @@ -30,183 +26,85 @@ QWidget:hover { border:none; background: qlineargradient(x1: 0, y1: 0, x2: 1, y2 7 - - - - - 34 - 45 - + + 5 + + + + + + false + - - - 34 - 45 - + + Qt::TabFocus - - PointingHandCursor + + color: #041E42; - - Load picture + + MARI MAASIKAS MUSTIKAS - - border: 1px solid #B1B3B3; -background-color: #FFFFFF; -opacity: 0.5; -border-radius: 3px; + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - 2 - 8 - 30 - 32 - - - - - 9 - - - - Load - - - border: none; color: #006EB5; - - - LOAD - - - Qt::AlignCenter - - - - - - Qt::Horizontal + + + + + 16 + + + + Qt::TabFocus + + + color: #727679; - - QSizePolicy::Fixed + + 48405050123 | - + + + + + + + 17 + 12 + + + - 10 - 20 + 17 + 12 - + - - + + + + + 16 + + + + Qt::TabFocus + - background: none; + color: #727679; + + + ID-card - - - 0 - - - 0 - - - 0 - - - 0 - - - 5 - - - - - - 50 - false - - - - Qt::TabFocus - - - color: #041E42; - - - MARI MAASIKAS MUSTIKAS - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 16 - - - - Qt::TabFocus - - - color: #727679; - - - 48405050123 | - - - - - - - - 17 - 12 - - - - - 17 - 12 - - - - - - - - - 16 - - - - Qt::TabFocus - - - color: #727679; - - - ID-card - - - - - - LabelButton - QToolButton -
widgets/LabelButton.h
-
QSvgWidget QWidget diff --git a/client/widgets/InfoStack.cpp b/client/widgets/InfoStack.cpp index 44fef1db7..df2a1a3f2 100644 --- a/client/widgets/InfoStack.cpp +++ b/client/widgets/InfoStack.cpp @@ -32,11 +32,6 @@ InfoStack::InfoStack( QWidget *parent ) { ui->setupUi( this ); - ui->btnPicture->setFont( Styles::font( Styles::Condensed, 12 ) ); - ui->btnPicture->hide(); - - connect(ui->btnPicture, &QPushButton::clicked, this, &InfoStack::photoClicked); - QFont labelFont = Styles::font(Styles::Condensed, 11); ui->labelGivenNames->setFont(labelFont); ui->labelSurname->setFont(labelFont); @@ -53,8 +48,6 @@ InfoStack::InfoStack( QWidget *parent ) ui->valueSerialNumber->setFont(font); ui->valueSpacer->setFont(font); ui->valueExpiryDate->setFont( Styles::font( Styles::Regular, 16 ) ); - - ui->photo->installEventFilter(this); } InfoStack::~InfoStack() @@ -65,7 +58,6 @@ InfoStack::~InfoStack() void InfoStack::clearData() { data = QSmartCardData(); - ui->alternateIcon->hide(); ui->valueGivenNames->clear(); ui->valueSurname->clear(); ui->valuePersonalCode->clear(); @@ -73,14 +65,6 @@ void InfoStack::clearData() ui->valueSerialNumber->clear(); ui->valueSpacer->hide(); ui->valueExpiryDate->clear(); - clearPicture(); - ui->btnPicture->hide(); -} - -void InfoStack::clearPicture() -{ - ui->photo->clear(); - ui->btnPicture->setText(tr(pictureText = "DOWNLOAD")); } void InfoStack::changeEvent(QEvent* event) @@ -94,37 +78,6 @@ void InfoStack::changeEvent(QEvent* event) QWidget::changeEvent(event); } - -bool InfoStack::eventFilter(QObject *o, QEvent *e) -{ -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - if(ui->photo != o || ui->alternateIcon->isVisible() || !ui->photo->pixmap()) - return StyledWidget::eventFilter(o, e); -#else - if(ui->photo != o || ui->alternateIcon->isVisible() || ui->photo->pixmap(Qt::ReturnByValue).isNull()) - return StyledWidget::eventFilter(o, e); -#endif - switch(e->type()) - { - case QEvent::Enter: - ui->btnPicture->show(); - return true; - case QEvent::Leave: - ui->btnPicture->hide(); - return true; - default: return StyledWidget::eventFilter(o, e); - } -} - -void InfoStack::showPicture( const QPixmap &pixmap ) -{ - ui->alternateIcon->hide(); - ui->photo->setPixmap( pixmap.scaled( 120, 150, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) ); - tr("SAVE THE PICTURE"); - ui->btnPicture->setText(tr(pictureText = "SAVE THE PICTURE")); - ui->btnPicture->hide(); -} - void InfoStack::update() { QString text; @@ -147,29 +100,10 @@ void InfoStack::update() ui->valueExpiryDate->setText(text); ui->valueSerialNumber->setText(serialNumberText); - ui->alternateIcon->setVisible(certType & SslCertificate::EResidentSubType || certType & SslCertificate::TempelType); - ui->btnPicture->setText(tr(pictureText)); -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - if(!ui->photo->pixmap()) - ui->btnPicture->setVisible(ui->alternateIcon->isHidden()); -#else - if(ui->photo->pixmap(Qt::ReturnByValue).isNull()) - ui->btnPicture->setVisible(ui->alternateIcon->isHidden()); -#endif ui->labelSerialNumber->setHidden(certType & SslCertificate::TempelType); ui->valueSerialNumber->setHidden(certType & SslCertificate::TempelType); - if(certType & SslCertificate::EResidentSubType) - { - ui->alternateIcon->load(QStringLiteral(":/images/icon_person_blue.svg")); - ui->alternateIcon->resize(109, 118); - ui->alternateIcon->move(10, 16); - } if(certType & SslCertificate::TempelType) { - ui->alternateIcon->load(QStringLiteral(":/images/icon_digitempel.svg")); - ui->alternateIcon->resize(100, 100); - ui->alternateIcon->move(10, 25); - ui->labelGivenNames->setText(tr("NAME")); ui->labelSurname->clear(); ui->labelPersonalCode->setText(tr("SERIAL")); @@ -188,7 +122,6 @@ void InfoStack::update() void InfoStack::update(const SslCertificate &cert) { - clearPicture(); certType = cert.type(); givenNamesText = cert.toString(QStringLiteral("CN")); surnameText.clear(); @@ -200,8 +133,6 @@ void InfoStack::update(const SslCertificate &cert) void InfoStack::update(const QSmartCardData &t) { - if(data != t) - clearPicture(); data = t; QStringList firstName { t.data( QSmartCardData::FirstName1 ).toString(), diff --git a/client/widgets/InfoStack.h b/client/widgets/InfoStack.h index d2b296721..d64a592b3 100644 --- a/client/widgets/InfoStack.h +++ b/client/widgets/InfoStack.h @@ -40,16 +40,10 @@ class InfoStack final: public StyledWidget void clearData(); void update(const SslCertificate &cert); void update(const QSmartCardData &t); - void showPicture(const QPixmap &pixmap); - -signals: - void photoClicked(); private: void changeEvent(QEvent* event) final; - bool eventFilter(QObject *o, QEvent *e) final; void update(); - void clearPicture(); Ui::InfoStack *ui; @@ -60,5 +54,4 @@ class InfoStack final: public StyledWidget QString personalCodeText; QString serialNumberText; QString surnameText; - const char *pictureText = "DOWNLOAD"; }; diff --git a/client/widgets/InfoStack.ui b/client/widgets/InfoStack.ui index 3eb43c48f..fc62434bb 100644 --- a/client/widgets/InfoStack.ui +++ b/client/widgets/InfoStack.ui @@ -23,15 +23,13 @@ - background-color: #F4F5F6; + #InfoStack { +background-color: #F4F5F6; border: solid #DEE4E9; border-width: 1px 0px 0px 0px; - +} - - - 15 - + 20 @@ -44,396 +42,292 @@ border-width: 1px 0px 0px 0px; 20 - - + + 5 + + + 0 + + + - 120 - 150 + 162 + 0 - - - 120 - 150 - + + + Roboto + 12 + + + + Qt::TabFocus + + + Given names - border: 1px solid #B1B3B3; -opacity: 0.5; -border-radius: 2px; -background-color: #F9FAFA; - - - - - 10 - 25 - 100 - 100 - - - - border: none - - - - - - 12 - 125 - 94 - 17 - - - - - 12 - - - - PointingHandCursor - - - Load picture - - - QPushButton { - border: 1px solid #006EB5; - border-radius: 2px; - color: #006EB5; -} -QPushButton:pressed { - background-color: #006EB5; - color: #FFFFFF; -} -QPushButton:hover:!pressed { - border-color: #008DCF; - color: #008DCF; -} - - - DOWNLOAD - - + color: #727679; + + + GIVEN NAMES + + + + + + + + Roboto + 12 + + + + Qt::TabFocus + + + Surname + + + color: #727679; + + + SURNAME + - - + + + + + Roboto + 16 + + + + Qt::TabFocus + - border: none; - - - - 0 - - - 0 - - - 0 - - - 0 - - - 5 - - - 0 - - - - - - 162 - 0 - - - - - Roboto - 12 - - - - Qt::TabFocus - - - Given names - - - color: #727679; - - - GIVEN NAMES - - - - - - - - Roboto - 12 - - - - Qt::TabFocus - - - Surname - - - color: #727679; - - - SURNAME - - - - - - - - Roboto - 16 - - - - Qt::TabFocus - - - color: #041E42; - - - valueGivenNames - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - - Roboto - 16 - - - - Qt::TabFocus - - - color: #041E42; - - - valueSurname - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - Roboto - 12 - - - - Qt::TabFocus - - - Personal code - - - color: #727679; - - - PERSONAL CODE - - - - - - - - Roboto - 12 - - - - Qt::TabFocus - - - Citizenship - - - color: #727679; - - - CITIZENSHIP - - - - - - - - Roboto - 16 - - - - Qt::TabFocus - - - color: #041E42; - - - valuePersonalCode - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - Roboto - 16 - - - - Qt::TabFocus - - - color: #041E42; - - - valueCitizenship - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - Roboto - 12 - - - - Qt::TabFocus - - - Document - - - color: #727679; - - - DOCUMENT - - - - - - - 6 - - - - - - Roboto - 16 - - - - Qt::TabFocus - - - color: #041E42; - - - valueSerialNumber - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - Roboto - 16 - - - - color: #041E42; - - - | - - - Qt::AlignHCenter|Qt::AlignTop - - - - - - - - Roboto - 16 - - - - Qt::TabFocus - - - color: #041E42; - - - valueExpiryDate - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - + color: #041E42; + + + valueGivenNames + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + Roboto + 16 + + + + Qt::TabFocus + + + color: #041E42; + + + valueSurname + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + Roboto + 12 + + + + Qt::TabFocus + + + Personal code + + + color: #727679; + + + PERSONAL CODE + + + + + + + + Roboto + 12 + + + + Qt::TabFocus + + + Citizenship + + + color: #727679; + + + CITIZENSHIP + + + + + + + + Roboto + 16 + + + + Qt::TabFocus + + + color: #041E42; + + + valuePersonalCode + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + Roboto + 16 + + + + Qt::TabFocus + + + color: #041E42; + + + valueCitizenship + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + Roboto + 12 + + + + Qt::TabFocus + + + Document + + + color: #727679; + + + DOCUMENT + + + + + + + 6 + + + + + + Roboto + 16 + + + + Qt::TabFocus + + + color: #041E42; + + + valueSerialNumber + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + Roboto + 16 + + + + color: #041E42; + + + | + + + Qt::AlignHCenter|Qt::AlignTop + + + + + + + + Roboto + 16 + + + + Qt::TabFocus + + + color: #041E42; + + + valueExpiryDate + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + - - - QSvgWidget - QWidget -
QtSvg/QSvgWidget
- 1 -
-
- btnPicture labelGivenNames valueGivenNames labelSurname diff --git a/client/widgets/LabelButton.cpp b/client/widgets/LabelButton.cpp index 2f1f3528f..a1ce47447 100644 --- a/client/widgets/LabelButton.cpp +++ b/client/widgets/LabelButton.cpp @@ -79,23 +79,6 @@ void LabelButton::init( Style style, const QString &label, int code ) } } -void LabelButton::clear() -{ - setPixmap(QPixmap()); -} - -void LabelButton::setPixmap(const QPixmap &pixmap) -{ - setIconSize(size()); - setIcon(pixmap); -} - -const QPixmap LabelButton::pixmap() -{ - QIcon icon = QToolButton::icon(); - return icon.availableSizes().isEmpty() ? QPixmap() : icon.pixmap(icon.availableSizes().first()); -} - void LabelButton::setIcons(const QString &normalIcon, const QString &hoverIcon, const QString &pressedIcon, int w, int h) { setIconSize(QSize(w, h)); diff --git a/client/widgets/LabelButton.h b/client/widgets/LabelButton.h index e724bd77e..59da02a6b 100644 --- a/client/widgets/LabelButton.h +++ b/client/widgets/LabelButton.h @@ -41,9 +41,6 @@ class LabelButton : public QToolButton void init( Style style, const QString &label, int code ); void setIcons(const QString &normalIcon, const QString &hoverIcon, const QString &pressedIcon, int w, int h); - void clear(); - const QPixmap pixmap(); - void setPixmap(const QPixmap &pixmap); signals: void clicked(int code);