From 5693de9d62ca3cc04058d14c3a7e5cc1fb57651f Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Fri, 1 Mar 2024 10:54:49 +0200 Subject: [PATCH] Fix coverity warnings (#1247) IB-7930 Signed-off-by: Raul Metsma --- client/Application.cpp | 19 +++++++-------- client/CDoc2.cpp | 8 +++---- client/CryptoDoc.cpp | 2 +- client/DigiDoc.cpp | 4 ++-- client/IKValidator.cpp | 32 +++++++++++++++---------- client/IKValidator.h | 10 ++++---- client/MainWindow.cpp | 4 ++-- client/QSigner.cpp | 2 +- client/QSmartCard.cpp | 8 +++---- client/Utils.h | 7 +++--- client/dialogs/PinUnblock.cpp | 4 +++- client/dialogs/RoleAddressDialog.cpp | 4 ++-- client/dialogs/SettingsDialog.cpp | 8 +++---- client/dialogs/SignatureDialog.cpp | 20 ++++++++-------- client/dialogs/SignatureDialog.h | 4 ++-- client/dialogs/SmartIDProgress.cpp | 2 +- client/widgets/ContainerPage.cpp | 36 +++++++++++++++------------- client/widgets/LabelButton.cpp | 6 ++--- client/widgets/LabelButton.h | 6 +---- client/widgets/MainAction.cpp | 2 +- common | 2 +- 21 files changed, 99 insertions(+), 91 deletions(-) diff --git a/client/Application.cpp b/client/Application.cpp index 8d22cdfb0..f090a80f8 100644 --- a/client/Application.cpp +++ b/client/Application.cpp @@ -184,7 +184,7 @@ class DigidocConf final: public digidoc::XmlConfCurrent std::vector TSLCerts() const final { std::vector tslcerts = toCerts(QLatin1String("TSL-CERTS")); - return tslcerts.empty() ? digidoc::XmlConfCurrent::TSLCerts() : tslcerts; + return tslcerts.empty() ? digidoc::XmlConfCurrent::TSLCerts() : std::move(tslcerts); } digidoc::X509Cert verifyServiceCert() const final @@ -334,7 +334,7 @@ Application::Application( int &argc, char **argv ) #ifdef CONFIG_URL d->conf = new Configuration(this); - QTimer::singleShot(0, this, [this] { + QMetaObject::invokeMethod(this, [this] { auto lessThanVersion = [](QLatin1String key) { return QVersionNumber::fromString(applicationVersion()) < QVersionNumber::fromString(confValue(key).toString()); @@ -456,7 +456,7 @@ Application::Application( int &argc, char **argv ) return; } - QTimer::singleShot(0, this, [this] { + QMetaObject::invokeMethod(this, [this] { #ifdef Q_OS_MAC if(!Settings::PLUGINS.isSet()) { @@ -486,7 +486,7 @@ Application::Application( int &argc, char **argv ) }); if( !args.isEmpty() || topLevelWindows().isEmpty() ) - parseArgs( args ); + parseArgs(std::move(args)); } Application::~Application() @@ -626,7 +626,7 @@ bool Application::event(QEvent *event) case QEvent::FileOpen: { QString fileName = static_cast(event)->file().normalized(QString::NormalizationForm_C); - QTimer::singleShot(0, this, [fileName] { + QMetaObject::invokeMethod(this, [fileName = std::move(fileName)] { parseArgs({ fileName }); }); return true; @@ -669,7 +669,7 @@ void Application::mailTo( const QUrl &url ) { QUrlQuery q(url); #if defined(Q_OS_WIN) - if(QLibrary lib("mapi32"); LPMAPISENDMAILW mapi = LPMAPISENDMAILW(lib.resolve("MAPISendMailW"))) + if(QLibrary lib("mapi32"); auto mapi = LPMAPISENDMAILW(lib.resolve("MAPISendMailW"))) { QString file = q.queryItemValue( "attachment", QUrl::FullyDecoded ); QString filePath = QDir::toNativeSeparators( file ); @@ -704,9 +704,8 @@ void Application::mailTo( const QUrl &url ) "--group", "PROFILE_Default", "--key", "EmailClient"}); p.waitForFinished(); - QByteArray data = p.readAllStandardOutput().trimmed(); - if( data.contains("thunderbird") ) - thunderbird = data; + if(QByteArray data = p.readAllStandardOutput().trimmed(); data.contains("thunderbird")) + thunderbird = std::move(data); } else if(env.indexOf(QRegularExpression(QStringLiteral("GNOME_DESKTOP_SESSION_ID.*"))) != -1) { @@ -800,7 +799,7 @@ void Application::parseArgs( const QString &msg ) QUrl url( param, QUrl::StrictMode ); params.append(param != QLatin1String("-crypto") && !url.toLocalFile().isEmpty() ? url.toLocalFile() : param); } - parseArgs( params ); + parseArgs(std::move(params)); } void Application::parseArgs(QStringList args) diff --git a/client/CDoc2.cpp b/client/CDoc2.cpp index 3c637ee0c..d57b92a0e 100644 --- a/client/CDoc2.cpp +++ b/client/CDoc2.cpp @@ -425,10 +425,10 @@ CDoc2::CDoc2(const QString &path) return; setLastError({}); - auto toByteArray = [](const flatbuffers::Vector *data) { + auto toByteArray = [](const flatbuffers::Vector *data) -> QByteArray { return data ? QByteArray((const char*)data->Data(), int(data->size())) : QByteArray(); }; - auto toString = [](const flatbuffers::String *data) { + auto toString = [](const flatbuffers::String *data) -> QString { return data ? QString::fromUtf8(data->c_str(), data->size()) : QString(); }; for(const auto *recipient: *recipients){ @@ -734,9 +734,9 @@ QByteArray CDoc2::transportKey(const CKey &_key) QByteArray key_material = QByteArray::fromBase64( json.value(QLatin1String("ephemeral_key_material")).toString().toLatin1()); if(json.value(QLatin1String("capsule_type")) == QLatin1String("rsa")) - key.encrypted_kek = key_material; + key.encrypted_kek = std::move(key_material); else - key.publicKey = key_material; + key.publicKey = std::move(key_material); } #ifndef NDEBUG qDebug() << "publicKeyDer" << key.key.toHex(); diff --git a/client/CryptoDoc.cpp b/client/CryptoDoc.cpp index 1b5ad7754..45a35af08 100644 --- a/client/CryptoDoc.cpp +++ b/client/CryptoDoc.cpp @@ -177,7 +177,7 @@ void CDocumentModel::open(int row) d->tempFiles.append(path); FileDialog::setReadOnly(path); if(FileDialog::isSignedPDF(path)) - Application::showClient({ path }, false, false, true); + Application::showClient({ std::move(path) }, false, false, true); else QDesktopServices::openUrl(QUrl::fromLocalFile(path)); } diff --git a/client/DigiDoc.cpp b/client/DigiDoc.cpp index cb2fa5063..bf5f00fb7 100644 --- a/client/DigiDoc.cpp +++ b/client/DigiDoc.cpp @@ -355,7 +355,7 @@ void SDocumentModel::open(int row) doc->m_tempFiles.append(path); FileDialog::setReadOnly(path); if(!doc->fileName().endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive) && FileDialog::isSignedPDF(path)) - qApp->showClient({ path }, false, false, true); + qApp->showClient({ std::move(path) }, false, false, true); else QDesktopServices::openUrl(QUrl::fromLocalFile(path)); } @@ -372,7 +372,7 @@ bool SDocumentModel::removeRow(int row) emit removed(row); return true; } - catch( const Exception &e ) { doc->setLastError( tr("Failed remove document from container"), e ); } + catch( const Exception &e ) { DigiDoc::setLastError(tr("Failed remove document from container"), e); } return false; } diff --git a/client/IKValidator.cpp b/client/IKValidator.cpp index c77a951c2..0873c02e6 100644 --- a/client/IKValidator.cpp +++ b/client/IKValidator.cpp @@ -22,12 +22,20 @@ #include #include -QDate IKValidator::birthDate(const QString &ik) +inline int toInt(QStringView str) { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + return QLocale::system().toInt(str); // QLocale, workaround for Qt 5 +#else + return str.toInt(); +#endif +} + +QDate IKValidator::birthDate(QStringView ik) { if(ik.size() != 11) return {}; quint16 year = 0; - switch(ik.left(1).toUInt()) + switch(toInt(ik.left(1))) { case 1: case 2: year = 1800; break; case 3: case 4: year = 1900; break; @@ -37,13 +45,13 @@ QDate IKValidator::birthDate(const QString &ik) } QDate date( - ik.mid(1, 2).toInt() + year, - ik.mid(3, 2).toInt(), - ik.mid(5, 2).toInt()); + toInt(ik.mid(1, 2)) + year, + toInt(ik.mid(3, 2)), + toInt(ik.mid(5, 2))); return date.isValid() ? date : QDate(); } -bool IKValidator::isValid(const QString &ik) +bool IKValidator::isValid(QStringView ik) { if(ik.size() != 11) return false; @@ -72,18 +80,18 @@ bool IKValidator::isValid(const QString &ik) int sum1 = 0, sum2 = 0; for(int i = 0, pos1 = 1, pos2 = 3; i < 10; ++i) { - sum1 += ik.mid(i, 1).toInt() * pos1; - sum2 += ik.mid(i, 1).toInt() * pos2; + sum1 += toInt(ik.mid(i, 1)) * pos1; + sum2 += toInt(ik.mid(i, 1)) * pos2; pos1 = pos1 == 9 ? 1 : pos1 + 1; pos2 = pos2 == 9 ? 1 : pos2 + 1; } - int result; + int result = 0; if((result = sum1 % 11) >= 10 && (result = sum2 % 11) >= 10) result = 0; - return ik.right( 1 ).toInt() == result; + return toInt(ik.right(1)) == result; } @@ -95,10 +103,10 @@ NumberValidator::NumberValidator(QObject *parent) NumberValidator::State NumberValidator::validate(QString &input, int & /*pos*/) const { QString out; - QRegularExpression rx(QStringLiteral("(\\d+)")); + static const QRegularExpression rx(QStringLiteral("(\\d+)")); QRegularExpressionMatch match = rx.match(input); for(int i = 0; i < match.lastCapturedIndex(); ++i) out += match.captured(i); - input = out; + input = std::move(out); return Acceptable; } diff --git a/client/IKValidator.h b/client/IKValidator.h index e0cc24f81..483335ada 100644 --- a/client/IKValidator.h +++ b/client/IKValidator.h @@ -24,17 +24,17 @@ class IKValidator { public: - static QDate birthDate(const QString &ik); - static bool isValid(const QString &ik); + static QDate birthDate(QStringView ik); + static bool isValid(QStringView ik); }; -class NumberValidator: public QValidator +class NumberValidator final: public QValidator { Q_OBJECT public: - explicit NumberValidator(QObject *parent = 0); + explicit NumberValidator(QObject *parent = nullptr); - State validate(QString &input, int &pos) const; + State validate(QString &input, int &pos) const final; }; diff --git a/client/MainWindow.cpp b/client/MainWindow.cpp index 43ca32748..62b0db295 100644 --- a/client/MainWindow.cpp +++ b/client/MainWindow.cpp @@ -913,7 +913,7 @@ void MainWindow::sign(F &&sign) if(!sign(city, state, zip, country, role)) { resetDigiDoc(nullptr, false); - navigateToPage(SignDetails, {wrappedFile}, false); + navigateToPage(SignDetails, {std::move(wrappedFile)}, false); return; } } @@ -1145,7 +1145,7 @@ void MainWindow::containerSummary() return; } #endif - QPrintPreviewDialog *dialog = new QPrintPreviewDialog( this ); + auto *dialog = new QPrintPreviewDialog( this ); dialog->printer()->setPageSize( QPageSize( QPageSize::A4 ) ); dialog->printer()->setPageOrientation( QPageLayout::Portrait ); dialog->setMinimumHeight( 700 ); diff --git a/client/QSigner.cpp b/client/QSigner.cpp index ff2c8283d..68dc49ceb 100644 --- a/client/QSigner.cpp +++ b/client/QSigner.cpp @@ -342,7 +342,7 @@ void QSigner::run() std::sort(cache.begin(), cache.end(), cardsOrder); if(cache != d->cache) { - d->cache = cache; + d->cache = std::move(cache); Q_EMIT cacheChanged(); } for(const TokenData &t: d->cache) diff --git a/client/QSmartCard.cpp b/client/QSmartCard.cpp index 8f237a039..e4a6116a3 100644 --- a/client/QSmartCard.cpp +++ b/client/QSmartCard.cpp @@ -514,7 +514,7 @@ QSmartCard::ErrorType QSmartCard::Private::handlePinResult(QPCSCReader *reader, case 0x6402: return QSmartCard::DifferentError; case 0x6403: return QSmartCard::LenghtError; case 0x6983: return QSmartCard::BlockedError; - case 0x6985: return QSmartCard::OldNewPinSameError; + case 0x6985: case 0x6A80: return QSmartCard::OldNewPinSameError; default: return QSmartCard::UnknownError; } @@ -635,7 +635,7 @@ void QSmartCard::reload() t->data.clear(); t->authCert = QSslCertificate(); t->signCert = QSslCertificate(); - d->t.d = t; + d->t.d = std::move(t); Q_EMIT dataChanged(d->t); QTimer::singleShot(0, this, [this] { reloadCard(d->token); }); } @@ -659,7 +659,7 @@ void QSmartCard::reloadCard(const TokenData &token) t->data.clear(); t->authCert = QSslCertificate(); t->signCert = QSslCertificate(); - d->t.d = t; + d->t.d = std::move(t); } if(!d->t.isNull() || token.reader().isEmpty()) @@ -690,7 +690,7 @@ void QSmartCard::reloadCard(const TokenData &token) d->card = new EstEIDCard(); if(d->card->loadPerso(selectedReader.data(), t)) { - d->t.d = t; + d->t.d = std::move(t); emit dataChanged(d->t); } else diff --git a/client/Utils.h b/client/Utils.h index 8b9712aa0..a13ebe7ec 100644 --- a/client/Utils.h +++ b/client/Utils.h @@ -42,21 +42,22 @@ namespace { }).detach(); l.exec(); if(exception) - std::rethrow_exception(exception); + std::rethrow_exception(std::move(exception)); return result; } template inline auto dispatchToMain(F&& function, Args&& ...args) { QEventLoop l; - if constexpr (std::is_void_v>) { + using result_t = typename std::invoke_result_t; + if constexpr (std::is_void_v) { QMetaObject::invokeMethod(qApp, [&, function = std::forward(function)] { std::invoke(function, args...); l.exit(); }, Qt::QueuedConnection); l.exec(); } else { - std::invoke_result_t result{}; + result_t result{}; QMetaObject::invokeMethod(qApp, [&, function = std::forward(function)] { result = std::invoke(function, args...); l.exit(); diff --git a/client/dialogs/PinUnblock.cpp b/client/dialogs/PinUnblock.cpp index cb3d5f448..11eea3444 100644 --- a/client/dialogs/PinUnblock.cpp +++ b/client/dialogs/PinUnblock.cpp @@ -152,7 +152,9 @@ PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType t connect(ui->puk, &QLineEdit::textEdited, ui->errorPuk, [this, setError] { setError(ui->puk, ui->errorPuk, {}); }); - connect(ui->change, &QPushButton::clicked, this, [=] { + connect(ui->change, &QPushButton::clicked, this, [=, + regexpNewCode = std::move(regexpNewCode), + regexpValidateCode = std::move(regexpValidateCode)] { const static QString SEQUENCE_ASCENDING = QStringLiteral("1234567890123456789012"); const static QString SEQUENCE_DESCENDING = QStringLiteral("0987654321098765432109"); ui->puk->setStyleSheet({}); diff --git a/client/dialogs/RoleAddressDialog.cpp b/client/dialogs/RoleAddressDialog.cpp index 3c23882ab..9b6256c47 100644 --- a/client/dialogs/RoleAddressDialog.cpp +++ b/client/dialogs/RoleAddressDialog.cpp @@ -60,7 +60,7 @@ RoleAddressDialog::RoleAddressDialog(QWidget *parent) list.first()->setFocus(); for(QLineEdit *line: list) { - Settings::Option s{line->objectName()}; + Settings::Option s{line->objectName(), {}}; auto *completer = new QCompleter(s, line); completer->setMaxVisibleItems(10); completer->setCompletionMode(QCompleter::PopupCompletion); @@ -68,7 +68,7 @@ RoleAddressDialog::RoleAddressDialog(QWidget *parent) line->setText(QStringList(s).value(0)); line->setFont(regularFont); line->setCompleter(completer); - connect(line, &QLineEdit::editingFinished, this, [=] { + connect(line, &QLineEdit::editingFinished, this, [line, s = std::move(s)] { QStringList list = s; list.removeAll(line->text()); list.insert(0, line->text()); diff --git a/client/dialogs/SettingsDialog.cpp b/client/dialogs/SettingsDialog.cpp index b07b9a0c5..4ba11c4a8 100644 --- a/client/dialogs/SettingsDialog.cpp +++ b/client/dialogs/SettingsDialog.cpp @@ -196,7 +196,7 @@ SettingsDialog::SettingsDialog(int page, QWidget *parent) WarningDialog::show(this, tr("Checking updates has failed.") + "
" + tr("Please try again."), error); return; } - auto dlg = WarningDialog::show(this, tr("DigiDoc4 Client configuration update was successful.")); + auto *dlg = WarningDialog::show(this, tr("DigiDoc4 Client configuration update was successful.")); new Overlay(dlg); #ifdef Q_OS_WIN QString path = QApplication::applicationDirPath() + QLatin1String("/id-updater.exe"); @@ -424,7 +424,7 @@ void SettingsDialog::initFunctionality() ui->txtTimeStamp->setEnabled(ui->rdTimeStampCustom->isChecked()); ui->txtTimeStamp->setPlaceholderText(Application::confValue(Settings::TSA_URL.KEY).toString()); QString TSA_URL = Settings::TSA_URL.value(Application::confValue(Application::TSAUrl)); - ui->txtTimeStamp->setText(ui->txtTimeStamp->placeholderText() == TSA_URL ? QString() : TSA_URL); + ui->txtTimeStamp->setText(ui->txtTimeStamp->placeholderText() == TSA_URL ? QString() : std::move(TSA_URL)); ui->wgtTSACert->setDisabled(Settings::TSA_CERT.isLocked()); ui->wgtTSACert->setVisible(ui->rdTimeStampCustom->isChecked()); connect(ui->rdTimeStampCustom, &QRadioButton::toggled, ui->txtTimeStamp, [this](bool checked) { @@ -481,7 +481,7 @@ void SettingsDialog::initFunctionality() ui->txtSiVa->setEnabled(ui->rdSiVaCustom->isChecked()); ui->txtSiVa->setPlaceholderText(Application::confValue(Settings::SIVA_URL.KEY).toString()); QString SIVA_URL = Settings::SIVA_URL.value(Application::confValue(Application::SiVaUrl)); - ui->txtSiVa->setText(ui->txtSiVa->placeholderText() == SIVA_URL ? QString() : SIVA_URL); + ui->txtSiVa->setText(ui->txtSiVa->placeholderText() == SIVA_URL ? QString() : std::move(SIVA_URL)); ui->wgtSiVaCert->setDisabled(Settings::SIVA_CERT.isLocked()); ui->wgtSiVaCert->setVisible(ui->rdSiVaCustom->isChecked()); connect(ui->rdSiVaCustom, &QRadioButton::toggled, ui->txtSiVa, [this](bool checked) { @@ -650,7 +650,7 @@ void SettingsDialog::updateDiagnostics() ui->btnNavSaveReport->setDisabled(true); QApplication::setOverrideCursor( Qt::WaitCursor ); - Diagnostics *worker = new Diagnostics(); + auto *worker = new Diagnostics(); connect(worker, &Diagnostics::update, ui->txtDiagnostics, &QTextBrowser::insertHtml, Qt::QueuedConnection); connect(worker, &Diagnostics::destroyed, this, [=]{ ui->txtDiagnostics->setEnabled(true); diff --git a/client/dialogs/SignatureDialog.cpp b/client/dialogs/SignatureDialog.cpp index 4a2b7c0e1..da70e6730 100644 --- a/client/dialogs/SignatureDialog.cpp +++ b/client/dialogs/SignatureDialog.cpp @@ -55,7 +55,7 @@ SignatureDialog::SignatureDialog(const DigiDocSignature &signature, QWidget *par if(isTS) status = tr("Timestamp"); status += ' '; - auto isValid = [](bool isTS) { + auto isValid = [](bool isTS) -> QString { return isTS ? tr("is valid", "Timestamp") : tr("is valid", "Signature"); }; switch(s.status()) @@ -69,8 +69,9 @@ SignatureDialog::SignatureDialog(const DigiDocSignature &signature, QWidget *par if(!s.lastError().isEmpty()) d->error->setPlainText( s.lastError() ); if(s.warning() & DigiDocSignature::DigestWeak ) - d->info->setText( tr( - "The signature is technically correct, but it is based on the currently weak hash algorithm SHA-1, therefore it is not protected against forgery or alteration.") ); + d->info->setText(tr( + "The signature is technically correct, but it is based on the currently weak hash algorithm SHA-1, " + "therefore it is not protected against forgery or alteration.")); else d->info->setText(tr("SIGNATURE_WARNING")); break; @@ -177,9 +178,8 @@ SignatureDialog::SignatureDialog(const DigiDocSignature &signature, QWidget *par addItem(t, tr("Signature format"), s.profile()); if( !s.policy().isEmpty() ) { - #define toVer(X) ((X)->toUInt() - 1) - QStringList ver = s.policy().split('.'); - if( ver.size() >= 3 ) + auto toVer = [](auto elem) { return elem->toUInt() - 1; }; + if(QStringList ver = s.policy().split('.'); ver.size() >= 3) addItem(t, tr("Signature policy"), QStringLiteral("%1.%2.%3").arg(toVer(ver.end()-3)).arg(toVer(ver.end()-2)).arg(toVer(ver.end()-1))); else addItem( t, tr("Signature policy"), s.policy() ); @@ -210,7 +210,7 @@ SignatureDialog::~SignatureDialog() void SignatureDialog::addItem(QTreeWidget *view, const QString &variable, QWidget *value) { - QTreeWidgetItem *i = new QTreeWidgetItem(view); + auto *i = new QTreeWidgetItem(view); QLabel *header = itemLabel(variable, view); view->setItemWidget(i, 0, header); view->setItemWidget(i, 1, value); @@ -239,7 +239,7 @@ void SignatureDialog::addItem(QTreeWidget *view, const QString &variable, const SslCertificate c(value); QPushButton *button = itemButton( c.toString(c.showCN() ? QStringLiteral("CN") : QStringLiteral("GN,SN,serialNumber")), view); - connect(button, &QPushButton::clicked, this, [=]{ CertificateDetails::showCertificate(c, this); }); + connect(button, &QPushButton::clicked, this, [this, c = std::move(c)]{ CertificateDetails::showCertificate(c, this); }); addItem(view, variable, button); } @@ -259,7 +259,7 @@ void SignatureDialog::decorateNotice(const QString &color) QPushButton* SignatureDialog::itemButton(const QString &text, QTreeWidget *view) { - QPushButton *button = new QPushButton(text, view); + auto *button = new QPushButton(text, view); #ifdef Q_OS_MAC QFont font = Styles::font(Styles::Regular, 13); #else @@ -274,7 +274,7 @@ QPushButton* SignatureDialog::itemButton(const QString &text, QTreeWidget *view) QLabel* SignatureDialog::itemLabel(const QString &text, QTreeWidget *view) { - QLabel *label = new QLabel(text, view); + auto *label = new QLabel(text, view); label->setToolTip(text); #ifdef Q_OS_MAC label->setFont(Styles::font(Styles::Regular, 13)); diff --git a/client/dialogs/SignatureDialog.h b/client/dialogs/SignatureDialog.h index 9f24b1236..75b90127e 100644 --- a/client/dialogs/SignatureDialog.h +++ b/client/dialogs/SignatureDialog.h @@ -40,8 +40,8 @@ class SignatureDialog : public QDialog ~SignatureDialog() final; private: - QPushButton *itemButton(const QString &text, QTreeWidget *view); - QLabel *itemLabel(const QString &text, QTreeWidget *view); + static QPushButton *itemButton(const QString &text, QTreeWidget *view); + static QLabel *itemLabel(const QString &text, QTreeWidget *view); void addItem(QTreeWidget *view, const QString &variable, QWidget *value); void addItem(QTreeWidget *view, const QString &variable, const QString &value); void addItem(QTreeWidget *view, const QString &variable, const QDateTime &value); diff --git a/client/dialogs/SmartIDProgress.cpp b/client/dialogs/SmartIDProgress.cpp index 0e51a6d02..72b5a0287 100644 --- a/client/dialogs/SmartIDProgress.cpp +++ b/client/dialogs/SmartIDProgress.cpp @@ -252,7 +252,7 @@ bool SmartIDProgress::init(const QString &country, const QString &idCode, const if(displayFile.size() > 6) displayFile = displayFile.left(3) + QStringLiteral("...") + displayFile.right(3); displayFile += QStringLiteral(".") + info.suffix(); - d->fileName = displayFile; + d->fileName = std::move(displayFile); d->sessionID.clear(); QByteArray data = QJsonDocument({ {"relyingPartyUUID", d->UUID.isEmpty() ? QStringLiteral("00000000-0000-0000-0000-000000000000") : d->UUID}, diff --git a/client/widgets/ContainerPage.cpp b/client/widgets/ContainerPage.cpp index dba8bc5a1..8fa79bc2b 100644 --- a/client/widgets/ContainerPage.cpp +++ b/client/widgets/ContainerPage.cpp @@ -53,31 +53,35 @@ ContainerPage::ContainerPage(QWidget *parent) ui->changeLocation->setIcons(QStringLiteral("/images/icon_Edit.svg"), QStringLiteral("/images/icon_Edit_hover.svg"), QStringLiteral("/images/icon_Edit_pressed.svg"), 18, 18); - ui->changeLocation->init( LabelButton::BoxedDeepCeruleanWithCuriousBlue, tr("CHANGE"), Actions::ContainerLocation ); + ui->changeLocation->init(LabelButton::BoxedDeepCeruleanWithCuriousBlue, tr("CHANGE")); ui->containerFile->installEventFilter(this); - ui->cancel->init( LabelButton::BoxedMojo, tr("CANCEL"), Actions::ContainerCancel ); - ui->convert->init( LabelButton::BoxedDeepCerulean, tr("ENCRYPT"), Actions::ContainerConvert ); - ui->saveAs->init( LabelButton::BoxedDeepCerulean, tr("SAVE AS"), Actions::ContainerSaveAs ); - ui->email->init( LabelButton::BoxedDeepCerulean, tr("SEND WITH E-MAIL"), Actions::ContainerEmail ); - ui->summary->init( LabelButton::BoxedDeepCerulean, tr("PRINT SUMMARY"), Actions::ContainerSummary ); - ui->save->init( LabelButton::BoxedDeepCerulean, tr("SAVE WITHOUT SIGNING"), Actions::ContainerSave ); + ui->cancel->init(LabelButton::BoxedMojo, tr("CANCEL")); + ui->convert->init(LabelButton::BoxedDeepCerulean, tr("ENCRYPT")); + ui->saveAs->init(LabelButton::BoxedDeepCerulean, tr("SAVE AS")); + ui->email->init(LabelButton::BoxedDeepCerulean, tr("SEND WITH E-MAIL")); + ui->summary->init(LabelButton::BoxedDeepCerulean, tr("PRINT SUMMARY")); + ui->save->init(LabelButton::BoxedDeepCerulean, tr("SAVE WITHOUT SIGNING")); mobileCode = Settings::MOBILEID_CODE; + auto connectCode = [this](QToolButton *btn, int code) { + connect(btn, &QToolButton::clicked, this, [this,code] { emit forward(code); }); + }; + connect(this, &ContainerPage::moved,this, &ContainerPage::setHeader); - connect(ui->changeLocation, &LabelButton::clicked, this, &ContainerPage::forward); - connect(ui->cancel, &LabelButton::clicked, this, &ContainerPage::forward); - connect(ui->save, &LabelButton::clicked, this, &ContainerPage::forward); + connectCode(ui->changeLocation, Actions::ContainerLocation); + connectCode(ui->cancel, Actions::ContainerCancel); + connectCode(ui->convert, Actions::ContainerConvert); + connectCode(ui->saveAs, Actions::ContainerSaveAs); + connectCode(ui->email, Actions::ContainerEmail); + connectCode(ui->summary, Actions::ContainerSummary); + connectCode(ui->save, Actions::ContainerSave); connect(ui->leftPane, &FileList::addFiles, this, &ContainerPage::addFiles); connect(ui->leftPane, &ItemList::removed, this, &ContainerPage::fileRemoved); connect(ui->leftPane, &ItemList::addItem, this, &ContainerPage::forward); connect(ui->rightPane, &ItemList::addItem, this, &ContainerPage::forward); connect(ui->rightPane, &ItemList::addressSearch, this, &ContainerPage::addressSearch); connect(ui->rightPane, &ItemList::removed, this, &ContainerPage::removed); - connect(ui->email, &LabelButton::clicked, this, &ContainerPage::forward); - connect(ui->summary, &LabelButton::clicked, this, &ContainerPage::forward); - connect(ui->saveAs, &LabelButton::clicked, this, &ContainerPage::forward); - connect(ui->convert, &LabelButton::clicked, this, &ContainerPage::forward); connect(ui->containerFile, &QLabel::linkActivated, this, [this](const QString &link) { emit action(Actions::ContainerNavigate, link); }); @@ -186,7 +190,7 @@ void ContainerPage::forward(int code) if(QString newCode = Settings::MOBILEID_CODE; newCode != mobileCode) { - mobileCode = newCode; + mobileCode = std::move(newCode); cardChanged(cardInReader); } break; @@ -201,7 +205,7 @@ void ContainerPage::forward(int code) if(QString newCode = Settings::SMARTID_CODE; newCode != mobileCode) { - mobileCode = newCode; + mobileCode = std::move(newCode); cardChanged(cardInReader); } break; diff --git a/client/widgets/LabelButton.cpp b/client/widgets/LabelButton.cpp index a1ce47447..72d9cd29f 100644 --- a/client/widgets/LabelButton.cpp +++ b/client/widgets/LabelButton.cpp @@ -21,21 +21,19 @@ #include "Colors.h" #include "Styles.h" -#include +#include using namespace ria::qdigidoc4::colors; LabelButton::LabelButton( QWidget *parent ): QToolButton(parent) {} -void LabelButton::init( Style style, const QString &label, int code ) +void LabelButton::init(Style style, const QString &label) { setText(label); setFont(Styles::font(Styles::Condensed, 12)); if(!label.isEmpty()) setAccessibleName(label.toLower()); - disconnect(connection); - connection = connect(this, &QToolButton::clicked, this, [this, code]{ emit clicked(code); }); static const QString borderRadius = QStringLiteral(" border-radius: 2px;"); static const QString none = QStringLiteral("none"); static const QString solid = QStringLiteral("1px solid %1"); diff --git a/client/widgets/LabelButton.h b/client/widgets/LabelButton.h index b17c9d641..f89dffde8 100644 --- a/client/widgets/LabelButton.h +++ b/client/widgets/LabelButton.h @@ -39,15 +39,11 @@ class LabelButton : public QToolButton explicit LabelButton(QWidget *parent = nullptr); - void init(Style style, const QString &label = {}, int code = 0); + void init(Style style, const QString &label = {}); void setIcons(const QString &normalIcon, const QString &hoverIcon, const QString &pressedIcon, int w, int h); -signals: - void clicked(int code); - private: bool event(QEvent *e) override; QString normal, hover, pressed; - QMetaObject::Connection connection; }; diff --git a/client/widgets/MainAction.cpp b/client/widgets/MainAction.cpp index 9a3fe55d4..3635e24e0 100644 --- a/client/widgets/MainAction.cpp +++ b/client/widgets/MainAction.cpp @@ -157,7 +157,7 @@ void MainAction::showActions(const QList &actions) { std::reverse(order.begin(), order.end()); } - ui->actions = order; + ui->actions = std::move(order); update(); ui->otherCards->setVisible(ui->actions.size() > 1); show(); diff --git a/common b/common index 2842d66ce..8cf8b7c3b 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 2842d66ced0f8760514b0d8780084840a974c5ac +Subproject commit 8cf8b7c3bc178c29bbaa33f37aad7dfd4970630e