feat: let user select keys to sync from key server
This commit is contained in:
parent
50c8b159eb
commit
a236f22b15
@ -78,7 +78,7 @@ SignersPicker::SignersPicker(QWidget* parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto SignersPicker::GetCheckedSigners() -> GpgFrontend::KeyIdArgsListPtr {
|
auto SignersPicker::GetCheckedSigners() -> GpgFrontend::KeyIdArgsListPtr {
|
||||||
return key_list_->GetPrivateChecked();
|
return key_list_->GetCheckedPrivateKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto SignersPicker::GetStatus() const -> bool { return this->accepted_; }
|
auto SignersPicker::GetStatus() const -> bool { return this->accepted_; }
|
||||||
|
@ -141,7 +141,7 @@ void MainWindow::SlotEncrypt() {
|
|||||||
void MainWindow::SlotSign() {
|
void MainWindow::SlotSign() {
|
||||||
if (edit_->SlotCurPageTextEdit() == nullptr) return;
|
if (edit_->SlotCurPageTextEdit() == nullptr) return;
|
||||||
|
|
||||||
auto key_ids = m_key_list_->GetPrivateChecked();
|
auto key_ids = m_key_list_->GetCheckedPrivateKey();
|
||||||
if (key_ids->empty()) {
|
if (key_ids->empty()) {
|
||||||
QMessageBox::critical(
|
QMessageBox::critical(
|
||||||
this, tr("No Key Checked"),
|
this, tr("No Key Checked"),
|
||||||
|
@ -231,7 +231,7 @@ auto KeyList::GetAllPrivateKeys() -> KeyIdArgsListPtr {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto KeyList::GetPrivateChecked() -> KeyIdArgsListPtr {
|
auto KeyList::GetCheckedPrivateKey() -> KeyIdArgsListPtr {
|
||||||
auto ret = std::make_unique<KeyIdArgsList>();
|
auto ret = std::make_unique<KeyIdArgsList>();
|
||||||
if (ui_->keyGroupTab->size().isEmpty()) return ret;
|
if (ui_->keyGroupTab->size().isEmpty()) return ret;
|
||||||
|
|
||||||
@ -242,7 +242,27 @@ auto KeyList::GetPrivateChecked() -> KeyIdArgsListPtr {
|
|||||||
|
|
||||||
for (int i = 0; i < key_list->rowCount(); i++) {
|
for (int i = 0; i < key_list->rowCount(); i++) {
|
||||||
if ((key_list->item(i, 0)->checkState() == Qt::Checked) &&
|
if ((key_list->item(i, 0)->checkState() == Qt::Checked) &&
|
||||||
((key_list->item(i, 1)) != nullptr)) {
|
((key_list->item(i, 1)) != nullptr) &&
|
||||||
|
buffered_keys[i].IsPrivateKey()) {
|
||||||
|
ret->push_back(buffered_keys[i].GetId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto KeyList::GetCheckedPublicKey() -> KeyIdArgsListPtr {
|
||||||
|
auto ret = std::make_unique<KeyIdArgsList>();
|
||||||
|
if (ui_->keyGroupTab->size().isEmpty()) return ret;
|
||||||
|
|
||||||
|
auto* key_list =
|
||||||
|
qobject_cast<QTableWidget*>(ui_->keyGroupTab->currentWidget());
|
||||||
|
const auto& buffered_keys =
|
||||||
|
m_key_tables_[ui_->keyGroupTab->currentIndex()].buffered_keys_;
|
||||||
|
|
||||||
|
for (int i = 0; i < key_list->rowCount(); i++) {
|
||||||
|
if ((key_list->item(i, 0)->checkState() == Qt::Checked) &&
|
||||||
|
((key_list->item(i, 1)) != nullptr) &&
|
||||||
|
!buffered_keys[i].IsPrivateKey()) {
|
||||||
ret->push_back(buffered_keys[i].GetId());
|
ret->push_back(buffered_keys[i].GetId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -458,14 +478,28 @@ void KeyList::slot_refresh_ui() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void KeyList::slot_sync_with_key_server() {
|
void KeyList::slot_sync_with_key_server() {
|
||||||
|
auto checked_public_keys = GetCheckedPublicKey();
|
||||||
|
|
||||||
KeyIdArgsList key_ids;
|
KeyIdArgsList key_ids;
|
||||||
{
|
if (checked_public_keys->empty()) {
|
||||||
std::lock_guard<std::mutex> guard(buffered_key_list_mutex_);
|
QMessageBox::StandardButton const reply = QMessageBox::question(
|
||||||
for (const auto& key : *buffered_keys_list_) {
|
this, QCoreApplication::tr("Sync All Public Key"),
|
||||||
if (!(key.IsPrivateKey() && key.IsHasMasterKey())) {
|
QCoreApplication::tr("You have not checked any public keys that you "
|
||||||
key_ids.push_back(key.GetId());
|
"want to synchronize, do you want to synchronize "
|
||||||
|
"all public keys from the key server?"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
|
||||||
|
if (reply == QMessageBox::No) return;
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> guard(buffered_key_list_mutex_);
|
||||||
|
for (const auto& key : *buffered_keys_list_) {
|
||||||
|
if (!(key.IsPrivateKey() && key.IsHasMasterKey())) {
|
||||||
|
key_ids.push_back(key.GetId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
key_ids = *checked_public_keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key_ids.empty()) return;
|
if (key_ids.empty()) return;
|
||||||
|
@ -188,7 +188,7 @@ class KeyList : public QWidget {
|
|||||||
const QString& name, const QString& id,
|
const QString& name, const QString& id,
|
||||||
KeyListRow::KeyType selectType = KeyListRow::SECRET_OR_PUBLIC_KEY,
|
KeyListRow::KeyType selectType = KeyListRow::SECRET_OR_PUBLIC_KEY,
|
||||||
KeyListColumn::InfoType infoType = KeyListColumn::ALL,
|
KeyListColumn::InfoType infoType = KeyListColumn::ALL,
|
||||||
const KeyTable::KeyTableFilter filter =
|
KeyTable::KeyTableFilter filter =
|
||||||
[](const GpgKey&, const KeyTable&) -> bool { return true; });
|
[](const GpgKey&, const KeyTable&) -> bool { return true; });
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -225,7 +225,7 @@ class KeyList : public QWidget {
|
|||||||
*
|
*
|
||||||
* @return KeyIdArgsListPtr
|
* @return KeyIdArgsListPtr
|
||||||
*/
|
*/
|
||||||
KeyIdArgsListPtr GetChecked();
|
auto GetChecked() -> KeyIdArgsListPtr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the Checked object
|
* @brief Get the Checked object
|
||||||
@ -233,21 +233,28 @@ class KeyList : public QWidget {
|
|||||||
* @param key_table
|
* @param key_table
|
||||||
* @return KeyIdArgsListPtr
|
* @return KeyIdArgsListPtr
|
||||||
*/
|
*/
|
||||||
static KeyIdArgsListPtr GetChecked(const KeyTable& key_table);
|
static auto GetChecked(const KeyTable& key_table) -> KeyIdArgsListPtr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the Private Checked object
|
* @brief Get the Private Checked object
|
||||||
*
|
*
|
||||||
* @return KeyIdArgsListPtr
|
* @return KeyIdArgsListPtr
|
||||||
*/
|
*/
|
||||||
KeyIdArgsListPtr GetPrivateChecked();
|
auto GetCheckedPrivateKey() -> KeyIdArgsListPtr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
*
|
||||||
|
* @return KeyIdArgsListPtr
|
||||||
|
*/
|
||||||
|
auto GetCheckedPublicKey() -> KeyIdArgsListPtr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the All Private Keys object
|
* @brief Get the All Private Keys object
|
||||||
*
|
*
|
||||||
* @return KeyIdArgsListPtr
|
* @return KeyIdArgsListPtr
|
||||||
*/
|
*/
|
||||||
KeyIdArgsListPtr GetAllPrivateKeys();
|
auto GetAllPrivateKeys() -> KeyIdArgsListPtr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the Checked object
|
* @brief Set the Checked object
|
||||||
@ -270,14 +277,14 @@ class KeyList : public QWidget {
|
|||||||
*
|
*
|
||||||
* @return KeyIdArgsListPtr
|
* @return KeyIdArgsListPtr
|
||||||
*/
|
*/
|
||||||
KeyIdArgsListPtr GetSelected();
|
auto GetSelected() -> KeyIdArgsListPtr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the Selected Key object
|
* @brief Get the Selected Key object
|
||||||
*
|
*
|
||||||
* @return QString
|
* @return QString
|
||||||
*/
|
*/
|
||||||
QString GetSelectedKey();
|
auto GetSelectedKey() -> QString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
@ -285,7 +292,7 @@ class KeyList : public QWidget {
|
|||||||
* @return true
|
* @return true
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
[[maybe_unused]] bool ContainsPrivateKeys();
|
[[maybe_unused]] auto ContainsPrivateKeys() -> bool;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user