Skip to content

Commit d22c788

Browse files
authored
Update ContainerWidget to new UI guidlines (#1312)
IB-7969 Signed-off-by: Raul Metsma <raul@metsma.ee>
1 parent b648255 commit d22c788

File tree

15 files changed

+231
-675
lines changed

15 files changed

+231
-675
lines changed

client/MainWindow.cpp

Lines changed: 17 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ MainWindow::MainWindow( QWidget *parent )
103103
separator->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
104104
separator->setStyleSheet(QStringLiteral("background-color: #D9D9D9;"));
105105
separator->resize(8000, 1);
106-
separator->move(110, 0);
106+
separator->move(mapToGlobal(ui->topBar->pos()));
107107
separator->show();
108108
#endif
109109

@@ -119,8 +119,6 @@ MainWindow::MainWindow( QWidget *parent )
119119
updateSelectorData(token);
120120
updateMyEID(token);
121121
ui->cryptoContainerPage->cardChanged(token.cert());
122-
if(cryptoDoc)
123-
ui->cryptoContainerPage->update(cryptoDoc, token.cert());
124122
});
125123
QPCSC::instance().start();
126124

@@ -146,8 +144,6 @@ MainWindow::MainWindow( QWidget *parent )
146144
connect(ui->cryptoContainerPage, &ContainerPage::action, this, &MainWindow::onCryptoAction);
147145
connect(ui->cryptoContainerPage, &ContainerPage::addFiles, this, [this](const QStringList &files) { openFiles(files, true); } );
148146
connect(ui->cryptoContainerPage, &ContainerPage::fileRemoved, this, &MainWindow::removeCryptoFile);
149-
connect(ui->cryptoContainerPage, &ContainerPage::keysSelected, this, &MainWindow::updateKeys);
150-
connect(ui->cryptoContainerPage, &ContainerPage::removed, this, &MainWindow::removeAddress);
151147
connect(ui->cryptoContainerPage, &ContainerPage::warning, this, [this](WarningText warningText) {
152148
ui->warnings->showWarning(warningText);
153149
ui->crypto->warningIcon(true);
@@ -334,19 +330,15 @@ void MainWindow::navigateToPage( Pages page, const QStringList &files, bool crea
334330
if(!filename.isNull())
335331
{
336332
signatureContainer->create(filename);
337-
bool filesAdded = false;
338333
for(const auto &file: files)
339334
{
340335
if(signatureContainer->documentModel()->addFile(file))
341-
filesAdded = true;
336+
navigate = true;
342337
}
343-
navigate = filesAdded;
344338
}
345339
}
346-
else if(signatureContainer->open(files[0]))
347-
{
348-
navigate = true;
349-
}
340+
else
341+
navigate = signatureContainer->open(files[0]);
350342
if(navigate)
351343
{
352344
resetDigiDoc(signatureContainer.release());
@@ -356,31 +348,27 @@ void MainWindow::navigateToPage( Pages page, const QStringList &files, bool crea
356348
else if(page == CryptoDetails)
357349
{
358350
navigate = false;
359-
std::unique_ptr<CryptoDoc> cryptoContainer(new CryptoDoc(this));
351+
auto cryptoContainer = std::make_unique<CryptoDoc>(this);
360352

361353
if(create)
362354
{
363355
QString filename = FileDialog::createNewFileName(files[0], false, this);
364356
if(!filename.isNull())
365357
{
366358
cryptoContainer->clear(filename);
367-
bool filesAdded = false;
368359
for(const auto &file: files)
369360
{
370361
if(cryptoContainer->documentModel()->addFile(file))
371-
filesAdded = true;
362+
navigate = true;
372363
}
373-
navigate = filesAdded;
374364
}
375365
}
376-
else if(cryptoContainer->open(files[0]))
377-
{
378-
navigate = true;
379-
}
366+
else
367+
navigate = cryptoContainer->open(files[0]);
380368
if(navigate)
381369
{
382-
resetCryptoDoc(cryptoContainer.release());
383-
ui->cryptoContainerPage->transition(cryptoDoc, qApp->signer()->tokenauth().cert());
370+
resetCryptoDoc(std::move(cryptoContainer));
371+
ui->cryptoContainerPage->transition(cryptoDoc.get(), qApp->signer()->tokenauth().cert());
384372
}
385373
}
386374

@@ -464,7 +452,7 @@ void MainWindow::convertToCDoc()
464452
if(filename.isNull())
465453
return;
466454

467-
std::unique_ptr<CryptoDoc> cryptoContainer(new CryptoDoc(this));
455+
auto cryptoContainer = std::make_unique<CryptoDoc>(this);
468456
cryptoContainer->clear(filename);
469457

470458
// If signed, add whole signed document to cryptocontainer; otherwise content only
@@ -477,9 +465,9 @@ void MainWindow::convertToCDoc()
477465
if(!cardData.cert().isNull())
478466
cryptoContainer->addKey(CKey(cardData.cert()));
479467

480-
resetCryptoDoc(cryptoContainer.release());
468+
resetCryptoDoc(std::move(cryptoContainer));
481469
resetDigiDoc(nullptr, false);
482-
ui->cryptoContainerPage->transition(cryptoDoc, qApp->signer()->tokenauth().cert());
470+
ui->cryptoContainerPage->transition(cryptoDoc.get(), qApp->signer()->tokenauth().cert());
483471
selectPage(CryptoDetails);
484472

485473
FadeInNotification::success(ui->topBar, tr("Converted to crypto container!"));
@@ -515,14 +503,14 @@ void MainWindow::onCryptoAction(int action, const QString &/*id*/, const QString
515503
case DecryptToken:
516504
if(decrypt())
517505
{
518-
ui->cryptoContainerPage->transition(cryptoDoc, qApp->signer()->tokenauth().cert());
506+
ui->cryptoContainerPage->transition(cryptoDoc.get(), qApp->signer()->tokenauth().cert());
519507
FadeInNotification::success(ui->topBar, tr("Decryption succeeded!"));
520508
}
521509
break;
522510
case EncryptContainer:
523511
if(encrypt())
524512
{
525-
ui->cryptoContainerPage->transition(cryptoDoc, qApp->signer()->tokenauth().cert());
513+
ui->cryptoContainerPage->transition(cryptoDoc.get(), qApp->signer()->tokenauth().cert());
526514
FadeInNotification::success(ui->topBar, tr("Encryption succeeded!"));
527515
}
528516
break;
@@ -683,12 +671,10 @@ void MainWindow::openContainer(bool signature)
683671
openFiles(files);
684672
}
685673

686-
void MainWindow::resetCryptoDoc(CryptoDoc *doc)
674+
void MainWindow::resetCryptoDoc(std::unique_ptr<CryptoDoc> &&doc)
687675
{
688676
ui->crypto->warningIcon(false);
689-
ui->cryptoContainerPage->clear();
690-
delete cryptoDoc;
691-
cryptoDoc = doc;
677+
cryptoDoc = std::move(doc);
692678
}
693679

694680
void MainWindow::resetDigiDoc(DigiDoc *doc, bool warnOnChange)
@@ -881,15 +867,6 @@ void MainWindow::sign(F &&sign)
881867
adjustDrops();
882868
}
883869

884-
void MainWindow::removeAddress(int index)
885-
{
886-
if(cryptoDoc)
887-
{
888-
cryptoDoc->removeKey(index);
889-
ui->cryptoContainerPage->update(cryptoDoc, qApp->signer()->tokenauth().cert());
890-
}
891-
}
892-
893870
void MainWindow::removeCryptoFile(int index)
894871
{
895872
if(!cryptoDoc)
@@ -1072,18 +1049,6 @@ void MainWindow::updateSelectorData(TokenData data)
10721049
showCardMenu(false);
10731050
}
10741051

1075-
void MainWindow::updateKeys(const QList<CKey> &keys)
1076-
{
1077-
if(!cryptoDoc)
1078-
return;
1079-
1080-
for(auto i = cryptoDoc->keys().size() - 1; i >= 0; i--)
1081-
cryptoDoc->removeKey(i);
1082-
for(const auto &key: keys)
1083-
cryptoDoc->addKey(key);
1084-
ui->cryptoContainerPage->update(cryptoDoc, qApp->signer()->tokenauth().cert());
1085-
}
1086-
10871052
void MainWindow::containerSummary()
10881053
{
10891054
#ifdef Q_OS_WIN

client/MainWindow.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,8 @@ private Q_SLOTS:
8383
void openFiles(const QStringList &files, bool addFile = false, bool forceCreate = false);
8484
void pinUnblock(QSmartCardData::PinType type, bool isForgotPin);
8585
void pinPukChange( QSmartCardData::PinType type );
86-
void resetCryptoDoc(CryptoDoc *doc = nullptr);
86+
void resetCryptoDoc(std::unique_ptr<CryptoDoc> &&doc = {});
8787
void resetDigiDoc(DigiDoc *doc = nullptr, bool warnOnChange = true);
88-
void removeAddress(int index);
8988
void removeCryptoFile(int index);
9089
bool removeFile(DocumentModel *model, int index);
9190
void removeSignature(int index);
@@ -102,7 +101,6 @@ private Q_SLOTS:
102101
void showPinBlockedWarning(const QSmartCardData& t);
103102
void updateSelector();
104103
void updateSelectorData(TokenData data);
105-
void updateKeys(const QList<CKey> &keys);
106104
void updateMyEID(const TokenData &t);
107105
void updateMyEid(const QSmartCardData &data);
108106
bool wrap(const QString& wrappedFile, bool enclose);
@@ -113,7 +111,7 @@ private Q_SLOTS:
113111
static void containerToEmail(const QString &fileName);
114112
static QStringList dropEventFiles(QDropEvent *event);
115113

116-
CryptoDoc* cryptoDoc = nullptr;
114+
std::unique_ptr<CryptoDoc> cryptoDoc;
117115
DigiDoc* digiDoc = nullptr;
118116
Ui::MainWindow *ui;
119117
};

client/images/icon_Edit.svg

Lines changed: 2 additions & 15 deletions
Loading

client/images/icon_Edit_hover.svg

Lines changed: 0 additions & 16 deletions
This file was deleted.

client/images/icon_Edit_pressed.svg

Lines changed: 0 additions & 16 deletions
This file was deleted.

client/images/icon_arrow_left.svg

Lines changed: 3 additions & 0 deletions
Loading

client/images/images.qrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<file>icon_Allkiri_hover.svg</file>
2020
<file>icon_Allkiri_small.svg</file>
2121
<file>icon_Allkiri.svg</file>
22+
<file>icon_arrow_left.svg</file>
2223
<file>icon_check.svg</file>
2324
<file>icon_checkbox.svg</file>
2425
<file>icon_checkbox_active.svg</file>
@@ -30,8 +31,6 @@
3031
<file>icon_checkbox_check_hover.svg</file>
3132
<file>icon_digitempel.svg</file>
3233
<file>icon_download.svg</file>
33-
<file>icon_Edit_hover.svg</file>
34-
<file>icon_Edit_pressed.svg</file>
3534
<file>icon_Edit.svg</file>
3635
<file>icon_help.svg</file>
3736
<file>icon_IDkaart_disabled.svg</file>

client/translations/en.ts

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -500,42 +500,6 @@
500500
<source>Container:</source>
501501
<translation>Container:</translation>
502502
</message>
503-
<message>
504-
<source>CHANGE</source>
505-
<translation>CHANGE</translation>
506-
</message>
507-
<message>
508-
<source>CANCEL</source>
509-
<translation>← CANCEL</translation>
510-
</message>
511-
<message>
512-
<source>SEND WITH E-MAIL</source>
513-
<translation>SEND WITH E-MAIL</translation>
514-
</message>
515-
<message>
516-
<source>PRINT SUMMARY</source>
517-
<translation>PRINT SUMMARY</translation>
518-
</message>
519-
<message>
520-
<source>ENCRYPT</source>
521-
<translation>ENCRYPT</translation>
522-
</message>
523-
<message>
524-
<source>SIGN</source>
525-
<translation>SIGN</translation>
526-
</message>
527-
<message>
528-
<source>SAVE AS</source>
529-
<translation>SAVE AS</translation>
530-
</message>
531-
<message>
532-
<source>SAVE WITHOUT SIGNING</source>
533-
<translation>SAVE WITHOUT SIGNING</translation>
534-
</message>
535-
<message>
536-
<source>STARTING</source>
537-
<translation>← START</translation>
538-
</message>
539503
<message>
540504
<source>The document has already been signed by you.</source>
541505
<translation>The document has already been signed by you.</translation>
@@ -550,39 +514,40 @@
550514
</message>
551515
<message>
552516
<source>Change</source>
553-
<extracomment>accessible</extracomment>
554517
<translation>Change</translation>
555518
</message>
556519
<message>
557520
<source>Cancel</source>
558-
<extracomment>accessible</extracomment>
559521
<translation>Cancel</translation>
560522
</message>
561523
<message>
562524
<source>Encrypt</source>
563-
<extracomment>accessible</extracomment>
564525
<translation>Encrypt</translation>
565526
</message>
566527
<message>
567528
<source>Save as</source>
568-
<extracomment>accessible</extracomment>
569529
<translation>Save as</translation>
570530
</message>
571531
<message>
572532
<source>Send with e-mail</source>
573-
<extracomment>accessible</extracomment>
574533
<translation>Send with e-mail</translation>
575534
</message>
576535
<message>
577536
<source>Print summary</source>
578-
<extracomment>accessible</extracomment>
579537
<translation>Print summary</translation>
580538
</message>
581539
<message>
582540
<source>Save without signing</source>
583-
<extracomment>accessible</extracomment>
584541
<translation>Save without signing</translation>
585542
</message>
543+
<message>
544+
<source>Start</source>
545+
<translation>Start</translation>
546+
</message>
547+
<message>
548+
<source>Sign</source>
549+
<translation>Sign</translation>
550+
</message>
586551
</context>
587552
<context>
588553
<name>CryptoDoc</name>

0 commit comments

Comments
 (0)