From d4af3290d4f535d7e8e94af88e006dd1af7bb682 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Tue, 10 Oct 2023 11:40:52 +0300 Subject: [PATCH] Dbg --- client/widgets/AddressItem.cpp | 2 +- client/widgets/ContainerPage.cpp | 37 +++++++++++++++++++------------- client/widgets/FileItem.cpp | 4 ++-- client/widgets/FileList.cpp | 2 +- client/widgets/ItemList.cpp | 2 +- client/widgets/LabelButton.cpp | 6 ++---- client/widgets/LabelButton.h | 7 +----- client/widgets/SignatureItem.cpp | 2 +- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/client/widgets/AddressItem.cpp b/client/widgets/AddressItem.cpp index 08d231d3e..b472cbe1a 100644 --- a/client/widgets/AddressItem.cpp +++ b/client/widgets/AddressItem.cpp @@ -53,7 +53,7 @@ AddressItem::AddressItem(CKey k, QWidget *parent, bool showIcon) ui->remove->setIcons(QStringLiteral("/images/icon_remove.svg"), QStringLiteral("/images/icon_remove_hover.svg"), QStringLiteral("/images/icon_remove_pressed.svg"), 17, 17); - ui->remove->init(LabelButton::White, {}, 0); + ui->remove->init(LabelButton::White); connect(ui->add, &QToolButton::clicked, this, [this]{ emit add(this);}); connect(ui->remove, &LabelButton::clicked, this, [this]{ emit remove(this);}); diff --git a/client/widgets/ContainerPage.cpp b/client/widgets/ContainerPage.cpp index 272c0aed9..90ef1e094 100644 --- a/client/widgets/ContainerPage.cpp +++ b/client/widgets/ContainerPage.cpp @@ -34,6 +34,7 @@ #include "widgets/SignatureItem.h" #include "widgets/WarningItem.h" +#include #include #include #include @@ -51,33 +52,38 @@ ContainerPage::ContainerPage(QWidget *parent) ui->container->setFont(Styles::font(Styles::Regular, 14)); ui->containerFile->setFont(Styles::font(Styles::Regular, 14)); + ui->containerFile->installEventFilter(this); 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->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->changeLocation->init(LabelButton::BoxedDeepCeruleanWithCuriousBlue, tr("CHANGE")); + 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, btn, [btn] { qDebug() << btn->objectName() << "::clicked"; }); + 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); }); @@ -174,6 +180,7 @@ bool ContainerPage::eventFilter(QObject *o, QEvent *e) void ContainerPage::forward(int code) { + qDebug() << objectName() << "::forward " << code; switch (code) { case SignatureMobile: diff --git a/client/widgets/FileItem.cpp b/client/widgets/FileItem.cpp index f29694ee4..0b1a5473d 100644 --- a/client/widgets/FileItem.cpp +++ b/client/widgets/FileItem.cpp @@ -31,9 +31,9 @@ FileItem::FileItem(QString file, ContainerState state, QWidget *parent) ui->setupUi(this); ui->fileName->setFont(Styles::font(Styles::Regular, 14)); ui->download->setIcons(QStringLiteral("/images/icon_download.svg"), QStringLiteral("/images/icon_download_hover.svg"), QStringLiteral("/images/icon_download_pressed.svg"), 17, 17); - ui->download->init(LabelButton::White, {}, 0); + ui->download->init(LabelButton::White); ui->remove->setIcons(QStringLiteral("/images/icon_remove.svg"), QStringLiteral("/images/icon_remove_hover.svg"), QStringLiteral("/images/icon_remove_pressed.svg"), 17, 17); - ui->remove->init(LabelButton::White, {}, 0); + ui->remove->init(LabelButton::White); stateChange(state); diff --git a/client/widgets/FileList.cpp b/client/widgets/FileList.cpp index a1cc5c7aa..0fd246a80 100644 --- a/client/widgets/FileList.cpp +++ b/client/widgets/FileList.cpp @@ -41,7 +41,7 @@ FileList::FileList(QWidget *parent) { ui->download->setIcons(QStringLiteral("/images/icon_download.svg"), QStringLiteral("/images/icon_download_hover.svg"), QStringLiteral("/images/icon_download_pressed.svg"), 17, 17); - ui->download->init(LabelButton::White, QString(), 0); + ui->download->init(LabelButton::White); ui->download->installEventFilter( new ButtonHoverFilter(QStringLiteral(":/images/icon_download.svg"), QStringLiteral(":/images/icon_download_hover.svg"), this)); connect(ui->add, &LabelButton::clicked, this, &FileList::selectFile); diff --git a/client/widgets/ItemList.cpp b/client/widgets/ItemList.cpp index f99528d05..0252cf891 100644 --- a/client/widgets/ItemList.cpp +++ b/client/widgets/ItemList.cpp @@ -203,7 +203,7 @@ void ItemList::init(ItemType item, const char *header) } else { - ui->add->init(LabelButton::DeepCeruleanWithLochmara, addLabel(), itemType == ItemFile ? FileAdd : AddressAdd); + ui->add->init(LabelButton::DeepCeruleanWithLochmara, addLabel()); ui->add->setFont(Styles::font(Styles::Condensed, 12)); } 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 59da02a6b..38b179a6e 100644 --- a/client/widgets/LabelButton.h +++ b/client/widgets/LabelButton.h @@ -34,20 +34,15 @@ class LabelButton : public QToolButton BoxedDeepCeruleanWithCuriousBlue, // Edit DeepCeruleanWithLochmara, // Add files White, - None }; explicit LabelButton(QWidget *parent = nullptr); - void init( Style style, const QString &label, int code ); + 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/SignatureItem.cpp b/client/widgets/SignatureItem.cpp index 1efe064ec..c8b3ddd98 100644 --- a/client/widgets/SignatureItem.cpp +++ b/client/widgets/SignatureItem.cpp @@ -62,7 +62,7 @@ SignatureItem::SignatureItem(DigiDocSignature s, ContainerState /*state*/, QWidg ui->role->installEventFilter(this); ui->remove->setIcons(QStringLiteral("/images/icon_remove.svg"), QStringLiteral("/images/icon_remove_hover.svg"), QStringLiteral("/images/icon_remove_pressed.svg"), 17, 17); - ui->remove->init(LabelButton::White, {}, 0); + ui->remove->init(LabelButton::White); ui->remove->setVisible(ui->signature.parent()->isSupported()); connect(ui->remove, &LabelButton::clicked, this, &SignatureItem::removeSignature); init();