1
0

feat: users can choose which crypto tool bar buttons are displayed
Some checks failed
Develop CI Qt5 / build (push) Failing after 1m54s
Develop CI Qt6 / build (push) Has been cancelled

This commit is contained in:
saturneric 2025-01-26 20:39:51 +01:00
parent 3aa7e32214
commit 2572aba1de
11 changed files with 159 additions and 28 deletions

View File

@ -108,7 +108,9 @@
<file alias="export-email.png">resource/lfs/icons/export-email.png</file>
<file alias="warning-filling.png">resource/lfs/icons/warning-filling.png</file>
<file alias="upgrade.png">resource/lfs/icons/upgrade.png</file>
<file alias="batch.png">resource/lfs/icons/batch.png</file>
<file alias="batch.png">resource/lfs/icons/batch.png</file>
<file alias="encr-sign.png">resource/lfs/icons/encr-sign.png</file>
<file alias="decr-verify.png">resource/lfs/icons/decr-verify.png</file>
</qresource>
<qresource prefix="/test/key">
<file alias="pv1.key">resource/lfs/test/data/pv1.key</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@ -62,11 +62,12 @@ using GpgOperationCallback = std::function<void(GpgError, DataObjectPtr)>;
using GpgOperationFuture = std::future<std::tuple<GpgError, DataObjectPtr>>;
enum GpgOperation {
kENCRYPT,
kDECRYPT,
kSIGN,
kVERIFY,
kENCRYPT_SIGN,
kDECRYPT_VERIFY
kNONE = 0,
kENCRYPT = 1 << 0,
kDECRYPT = 1 << 1,
kSIGN = 1 << 2,
kVERIFY = 1 << 3,
kENCRYPT_SIGN = 1 << 4,
kDECRYPT_VERIFY = 1 << 5,
};
} // namespace GpgFrontend

View File

@ -150,6 +150,19 @@ void AppearanceTab::SetSettings() {
} else {
ui_->themeComboBox->setCurrentIndex(target_theme_index);
}
ui_->encrCheckBox->setChecked(
(appearance.tool_bar_crypto_operas_type & GpgOperation::kENCRYPT) != 0);
ui_->decrCheckBox->setChecked(
(appearance.tool_bar_crypto_operas_type & GpgOperation::kDECRYPT) != 0);
ui_->signCheckBox->setChecked(
(appearance.tool_bar_crypto_operas_type & GpgOperation::kSIGN) != 0);
ui_->verifyCheckBox->setChecked(
(appearance.tool_bar_crypto_operas_type & GpgOperation::kVERIFY) != 0);
ui_->encrSignCheckBox->setChecked((appearance.tool_bar_crypto_operas_type &
GpgOperation::kENCRYPT_SIGN) != 0);
ui_->decrVerifyCheckBox->setChecked((appearance.tool_bar_crypto_operas_type &
GpgOperation::kDECRYPT_VERIFY) != 0);
}
void AppearanceTab::ApplySettings() {
@ -195,6 +208,20 @@ void AppearanceTab::ApplySettings() {
appearance.text_editor_font_size =
ui_->fontSizeTextEditorLabelSpinBox->value();
appearance.tool_bar_crypto_operas_type = 0;
appearance.tool_bar_crypto_operas_type |=
ui_->encrCheckBox->isChecked() ? kENCRYPT : kNONE;
appearance.tool_bar_crypto_operas_type |=
ui_->decrCheckBox->isChecked() ? kDECRYPT : kNONE;
appearance.tool_bar_crypto_operas_type |=
ui_->signCheckBox->isChecked() ? kSIGN : kNONE;
appearance.tool_bar_crypto_operas_type |=
ui_->verifyCheckBox->isChecked() ? kVERIFY : kNONE;
appearance.tool_bar_crypto_operas_type |=
ui_->encrSignCheckBox->isChecked() ? kENCRYPT_SIGN : kNONE;
appearance.tool_bar_crypto_operas_type |=
ui_->decrVerifyCheckBox->isChecked() ? kDECRYPT_VERIFY : kNONE;
general_settings_state.Store(appearance.ToJson());
auto settings = GlobalSettingStation::GetInstance().GetSettings();

View File

@ -32,6 +32,7 @@
#include "core/function/GlobalSettingStation.h"
#include "core/model/SettingsObject.h"
#include "core/module/ModuleManager.h"
#include "struct/settings_object/AppearanceSO.h"
#include "ui/UISignalStation.h"
#include "ui/main_window/GeneralMainWindow.h"
#include "ui/struct/settings_object/KeyServerSO.h"
@ -178,11 +179,44 @@ void MainWindow::restore_settings() {
settings.setValue("gnupg/non_ascii_at_file_operation", true);
}
// set appearance
import_button_->setToolButtonStyle(icon_style_);
prohibit_update_checking_ =
settings.value("network/prohibit_update_check").toBool();
// set appearance
AppearanceSO const appearance(SettingsObject("general_settings_state"));
crypt_tool_bar_->clear();
if ((appearance.tool_bar_crypto_operas_type & GpgOperation::kENCRYPT) != 0) {
crypt_tool_bar_->addAction(encrypt_act_);
}
if ((appearance.tool_bar_crypto_operas_type & GpgOperation::kDECRYPT) != 0) {
crypt_tool_bar_->addAction(decrypt_act_);
}
if ((appearance.tool_bar_crypto_operas_type & GpgOperation::kSIGN) != 0) {
crypt_tool_bar_->addAction(sign_act_);
}
if ((appearance.tool_bar_crypto_operas_type & GpgOperation::kVERIFY) != 0) {
crypt_tool_bar_->addAction(verify_act_);
}
if ((appearance.tool_bar_crypto_operas_type & GpgOperation::kENCRYPT_SIGN) !=
0) {
crypt_tool_bar_->addAction(encrypt_sign_act_);
}
if ((appearance.tool_bar_crypto_operas_type &
GpgOperation::kDECRYPT_VERIFY) != 0) {
crypt_tool_bar_->addAction(decrypt_verify_act_);
}
icon_style_ = appearance.tool_bar_button_style;
import_button_->setToolButtonStyle(icon_style_);
this->setToolButtonStyle(icon_style_);
// icons ize
this->setIconSize(
QSize(appearance.tool_bar_icon_width, appearance.tool_bar_icon_height));
import_button_->setIconSize(
QSize(appearance.tool_bar_icon_width, appearance.tool_bar_icon_height));
}
void MainWindow::recover_editor_unsaved_pages_from_cache() {

View File

@ -103,15 +103,7 @@ void MainWindow::slot_open_settings_dialog() {
connect(dialog, &SettingsDialog::finished, this, [&]() -> void {
AppearanceSO appearance(SettingsObject("general_settings_state"));
this->setToolButtonStyle(appearance.tool_bar_button_style);
import_button_->setToolButtonStyle(appearance.tool_bar_button_style);
// icons ize
this->setIconSize(
QSize(appearance.tool_bar_icon_width, appearance.tool_bar_icon_height));
import_button_->setIconSize(
QSize(appearance.tool_bar_icon_width, appearance.tool_bar_icon_height));
restore_settings();
// restart main window if necessary
if (restart_mode_ != kNonRestartCode) {
if (edit_->MaybeSaveAnyTab()) {

View File

@ -28,8 +28,10 @@
#include "MainWindow.h"
#include "core/function/GlobalSettingStation.h"
#include "core/model/SettingsObject.h"
#include "core/module/ModuleManager.h"
#include "dialog/controller/ModuleControllerDialog.h"
#include "struct/settings_object/AppearanceSO.h"
#include "ui/UserInterfaceUtils.h"
#include "ui/dialog/controller/GnuPGControllerDialog.h"
#include "ui/dialog/help/AboutDialog.h"
@ -148,7 +150,7 @@ void MainWindow::create_actions() {
&MainWindow::SlotGeneralEncrypt);
encrypt_sign_act_ =
create_action("encrypt_sign", tr("Encrypt Sign"), ":/icons/compress.png",
create_action("encrypt_sign", tr("Encrypt Sign"), ":/icons/encr-sign.png",
tr("Encrypt and Sign Message"),
{QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_E)});
connect(encrypt_sign_act_, &QAction::triggered, this,
@ -162,7 +164,7 @@ void MainWindow::create_actions() {
decrypt_verify_act_ =
create_action("decrypt_verify", tr("Decrypt Verify"),
":/icons/expand.png", tr("Decrypt and Verify Message"),
":/icons/decr-verify.png", tr("Decrypt and Verify Message"),
{QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_D)});
connect(decrypt_verify_act_, &QAction::triggered, this,
&MainWindow::SlotGeneralDecryptVerify);
@ -498,12 +500,7 @@ void MainWindow::create_tool_bars() {
crypt_tool_bar_ = addToolBar(tr("Operations"));
crypt_tool_bar_->setObjectName("cryptToolBar");
crypt_tool_bar_->addAction(encrypt_act_);
// crypt_tool_bar_->addAction(encrypt_sign_act_);
crypt_tool_bar_->addAction(decrypt_act_);
// crypt_tool_bar_->addAction(decrypt_verify_act_);
crypt_tool_bar_->addAction(sign_act_);
crypt_tool_bar_->addAction(verify_act_);
view_menu_->addAction(crypt_tool_bar_->toggleViewAction());
key_tool_bar_ = addToolBar(tr("Key"));

View File

@ -28,6 +28,8 @@
#pragma once
#include "core/typedef/GpgTypedef.h"
namespace GpgFrontend::UI {
struct AppearanceSO {
@ -36,6 +38,9 @@ struct AppearanceSO {
int tool_bar_icon_width = 24;
int tool_bar_icon_height = 24;
Qt::ToolButtonStyle tool_bar_button_style = Qt::ToolButtonTextUnderIcon;
int tool_bar_crypto_operas_type = GpgOperation::kENCRYPT |
GpgOperation::kDECRYPT |
GpgOperation::kSIGN | GpgOperation::kVERIFY;
bool save_window_state;
@ -55,6 +60,9 @@ struct AppearanceSO {
if (const auto v = j["tool_bar_button_style"]; v.isDouble()) {
tool_bar_button_style = static_cast<Qt::ToolButtonStyle>(v.toInt());
}
if (const auto v = j["tool_bar_crypto_operas_type"]; v.isDouble()) {
tool_bar_crypto_operas_type = static_cast<int>(v.toInt());
}
if (const auto v = j["save_window_state"]; v.isBool()) {
save_window_state = v.toBool();
@ -68,6 +76,7 @@ struct AppearanceSO {
j["tool_bar_icon_width"] = tool_bar_icon_width;
j["tool_bar_icon_height"] = tool_bar_icon_height;
j["tool_bar_button_style"] = tool_bar_button_style;
j["tool_bar_crypto_operas_type"] = tool_bar_crypto_operas_type;
j["save_window_state"] = save_window_state;
return j;

View File

@ -173,13 +173,82 @@
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Crypto Operations</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_3" rowstretch="0,0,0,0,0,0,0" columnstretch="0,0" rowminimumheight="0,0,0,0,0,0,0">
<property name="sizeConstraint">
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
</property>
<item row="3" column="1">
<widget class="QCheckBox" name="verifyCheckBox">
<property name="text">
<string>Verify</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="decrVerifyCheckBox">
<property name="text">
<string>Decrypt Verify</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="encrSignCheckBox">
<property name="text">
<string>Encrypt Sign</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="encrCheckBox">
<property name="text">
<string>Encrypt</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="signCheckBox">
<property name="text">
<string>Sign</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="decrCheckBox">
<property name="text">
<string>Decrypt</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>