From 97d13004e4f1cb33941a9be57c7e7662e223890b Mon Sep 17 00:00:00 2001 From: Saturneric Date: Mon, 6 Dec 2021 23:58:23 +0800 Subject: Improve UI & Functions --- src/ui/keypair_details/KeyPairUIDTab.cpp | 82 ++++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 19 deletions(-) (limited to 'src/ui/keypair_details/KeyPairUIDTab.cpp') diff --git a/src/ui/keypair_details/KeyPairUIDTab.cpp b/src/ui/keypair_details/KeyPairUIDTab.cpp index 3d56699a..11055df3 100644 --- a/src/ui/keypair_details/KeyPairUIDTab.cpp +++ b/src/ui/keypair_details/KeyPairUIDTab.cpp @@ -28,6 +28,7 @@ #include "gpg/function/GpgKeyManager.h" #include "gpg/function/UidOperator.h" #include "ui/SignalStation.h" +#include "ui/widgets/TOFUInfoPage.h" namespace GpgFrontend::UI { @@ -53,30 +54,46 @@ KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent) uidButtonsLayout->addWidget(addUIDButton, 0, 1); uidButtonsLayout->addWidget(manageUIDButton, 0, 2); - auto gridLayout = new QGridLayout(); + auto grid_layout = new QGridLayout(); - gridLayout->addWidget(uidList, 0, 0); - gridLayout->addLayout(uidButtonsLayout, 1, 0); - gridLayout->setContentsMargins(0, 10, 0, 0); + grid_layout->addWidget(uidList, 0, 0); + grid_layout->addLayout(uidButtonsLayout, 1, 0); + grid_layout->setContentsMargins(0, 10, 0, 0); - auto uidGroupBox = new QGroupBox(); - uidGroupBox->setLayout(gridLayout); - uidGroupBox->setTitle(_("UIDs")); + auto uid_group_box = new QGroupBox(); + uid_group_box->setLayout(grid_layout); + uid_group_box->setTitle(_("UIDs")); - auto signGridLayout = new QGridLayout(); - signGridLayout->addWidget(sigList, 0, 0); - signGridLayout->setContentsMargins(0, 10, 0, 0); + auto tofu_group_box = new QGroupBox(); + auto tofu_vbox_layout = new QVBoxLayout(); + tofu_group_box->setLayout(tofu_vbox_layout); + tofu_group_box->setTitle(_("TOFU")); +#if !defined(RELEASE) + tofuTabs = new QTabWidget(this); + tofu_vbox_layout->addWidget(tofuTabs); +#endif - auto signGroupBox = new QGroupBox(); - signGroupBox->setLayout(signGridLayout); - signGroupBox->setTitle(_("Signature of Selected UID")); + auto sign_grid_layout = new QGridLayout(); + sign_grid_layout->addWidget(sigList, 0, 0); + sign_grid_layout->setContentsMargins(0, 10, 0, 0); + + auto sign_group_box = new QGroupBox(); + sign_group_box->setLayout(sign_grid_layout); + sign_group_box->setTitle(_("Signature of Selected UID")); auto vboxLayout = new QVBoxLayout(); - vboxLayout->addWidget(uidGroupBox); - vboxLayout->addWidget(signGroupBox); + vboxLayout->addWidget(uid_group_box); +#if !defined(RELEASE) + // Function needed testing + vboxLayout->addWidget(tofu_group_box); +#endif + vboxLayout->addWidget(sign_group_box); + vboxLayout->setContentsMargins(0, 0, 0, 0); connect(addUIDButton, SIGNAL(clicked(bool)), this, SLOT(slotAddUID())); + connect(uidList, SIGNAL(itemSelectionChanged()), this, + SLOT(slotRefreshTOFUInfo())); connect(uidList, SIGNAL(itemSelectionChanged()), this, SLOT(slotRefreshSigList())); @@ -189,6 +206,32 @@ void KeyPairUIDTab::slotRefreshUIDList() { } slotRefreshSigList(); + slotRefreshTOFUInfo(); +} + +void KeyPairUIDTab::slotRefreshTOFUInfo() { + if (this->tofuTabs == nullptr) return; + + int uidRow = 0; + tofuTabs->clear(); + for (const auto& uid : buffered_uids) { + // Only Show Selected UID Signatures + if (!uidList->item(uidRow++, 0)->isSelected()) { + continue; + } + auto tofu_infos = uid.tofu_infos(); + LOG(INFO) << "tofu info size" << tofu_infos->size(); + if (tofu_infos->empty()) { + tofuTabs->hide(); + } else { + tofuTabs->show(); + } + int index = 1; + for (const auto& tofu_info : *tofu_infos) { + tofuTabs->addTab(new TOFUInfoPage(tofu_info, this), + QString(_("TOFU %1")).arg(index++)); + } + } } void KeyPairUIDTab::slotRefreshSigList() { @@ -329,7 +372,7 @@ void KeyPairUIDTab::slotDelUID() { "

" + keynames + +"
" + _("The action can not be undone."), QMessageBox::No | QMessageBox::Yes); - + if (ret == QMessageBox::Yes) { for (const auto& uid : *selected_uids) { LOG(INFO) << "KeyPairUIDTab::slotDelUID UID" << uid; @@ -423,9 +466,9 @@ void KeyPairUIDTab::contextMenuEvent(QContextMenuEvent* event) { uidPopupMenu->exec(event->globalPos()); } - if (!sigList->selectedItems().isEmpty()) { - signPopupMenu->exec(event->globalPos()); - } + // if (!sigList->selectedItems().isEmpty()) { + // signPopupMenu->exec(event->globalPos()); + // } } void KeyPairUIDTab::slotAddSignSingle() { @@ -528,6 +571,7 @@ void KeyPairUIDTab::slotDelSign() { void KeyPairUIDTab::slotRefreshKey() { this->mKey = GpgKeyGetter::GetInstance().GetKey(this->mKey.id()); this->slotRefreshUIDList(); + this->slotRefreshTOFUInfo(); this->slotRefreshSigList(); } -- cgit v1.2.3 From 4f9ee73ffdda5a495d25ebf4f769a4c43aa78295 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Tue, 7 Dec 2021 04:38:05 +0800 Subject: Test & Improve UI --- src/ui/keypair_details/KeyPairUIDTab.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/ui/keypair_details/KeyPairUIDTab.cpp') diff --git a/src/ui/keypair_details/KeyPairUIDTab.cpp b/src/ui/keypair_details/KeyPairUIDTab.cpp index 11055df3..8a58b270 100644 --- a/src/ui/keypair_details/KeyPairUIDTab.cpp +++ b/src/ui/keypair_details/KeyPairUIDTab.cpp @@ -24,6 +24,8 @@ #include "ui/keypair_details/KeyPairUIDTab.h" +#include + #include "gpg/function/GpgKeyGetter.h" #include "gpg/function/GpgKeyManager.h" #include "gpg/function/UidOperator.h" @@ -271,16 +273,19 @@ void KeyPairUIDTab::slotRefreshSigList() { sigList->setItem(sigRow, 2, tmp3); } - auto* tmp4 = new QTableWidgetItem(QString::fromStdString( - boost::gregorian::to_iso_string(sig.create_time()))); + std::stringstream ss; + ss << boost::locale::as::datetime << sig.create_time(); + auto* tmp4 = new QTableWidgetItem(ss.str().c_str()); sigList->setItem(sigRow, 3, tmp4); + ss.str(std::string()); + ss << boost::locale::as::datetime << sig.expire_time(); + auto* tmp5 = new QTableWidgetItem( boost::posix_time::to_time_t( boost::posix_time::ptime(sig.expire_time())) == 0 ? _("Never Expires") - : QString::fromStdString( - boost::gregorian::to_iso_string(sig.expire_time()))); + : ss.str().c_str()); tmp5->setTextAlignment(Qt::AlignCenter); sigList->setItem(sigRow, 4, tmp5); -- cgit v1.2.3 From 49556f2d87a72f888512552f446665e01e6c1abd Mon Sep 17 00:00:00 2001 From: Saturneric Date: Tue, 7 Dec 2021 14:23:58 +0800 Subject: Support Windows Build --- src/ui/keypair_details/KeyPairUIDTab.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src/ui/keypair_details/KeyPairUIDTab.cpp') diff --git a/src/ui/keypair_details/KeyPairUIDTab.cpp b/src/ui/keypair_details/KeyPairUIDTab.cpp index 8a58b270..b2aa8861 100644 --- a/src/ui/keypair_details/KeyPairUIDTab.cpp +++ b/src/ui/keypair_details/KeyPairUIDTab.cpp @@ -24,8 +24,6 @@ #include "ui/keypair_details/KeyPairUIDTab.h" -#include - #include "gpg/function/GpgKeyGetter.h" #include "gpg/function/GpgKeyManager.h" #include "gpg/function/UidOperator.h" @@ -273,19 +271,16 @@ void KeyPairUIDTab::slotRefreshSigList() { sigList->setItem(sigRow, 2, tmp3); } - std::stringstream ss; - ss << boost::locale::as::datetime << sig.create_time(); - auto* tmp4 = new QTableWidgetItem(ss.str().c_str()); + auto* tmp4 = new QTableWidgetItem(QLocale::system().toString( + QDateTime::fromTime_t(to_time_t(sig.create_time())))); sigList->setItem(sigRow, 3, tmp4); - ss.str(std::string()); - ss << boost::locale::as::datetime << sig.expire_time(); - auto* tmp5 = new QTableWidgetItem( boost::posix_time::to_time_t( boost::posix_time::ptime(sig.expire_time())) == 0 ? _("Never Expires") - : ss.str().c_str()); + : QLocale::system().toString( + QDateTime::fromTime_t(to_time_t(sig.expire_time())))); tmp5->setTextAlignment(Qt::AlignCenter); sigList->setItem(sigRow, 4, tmp5); -- cgit v1.2.3