aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2025-01-26 19:39:51 +0000
committersaturneric <[email protected]>2025-01-26 19:39:51 +0000
commit2572aba1def45730f79d1646db8e07993bccb7a7 (patch)
tree1b754d23e61609dde926bc33bf5e16a415da7ba9
parentfeat: add ui ability to switch batch mode (diff)
downloadGpgFrontend-2572aba1def45730f79d1646db8e07993bccb7a7.tar.gz
GpgFrontend-2572aba1def45730f79d1646db8e07993bccb7a7.zip
feat: users can choose which crypto tool bar buttons are displayed
-rw-r--r--gpgfrontend.qrc4
-rw-r--r--resource/lfs/icons/decr-verify.pngbin0 -> 7058 bytes
-rw-r--r--resource/lfs/icons/encr-sign.pngbin0 -> 8084 bytes
-rw-r--r--resource/lfs/icons/file-operator.pngbin6401 -> 4887 bytes
-rw-r--r--src/core/typedef/GpgTypedef.h13
-rw-r--r--src/ui/dialog/settings/SettingsAppearance.cpp27
-rw-r--r--src/ui/main_window/MainWindow.cpp38
-rw-r--r--src/ui/main_window/MainWindowSlotUI.cpp10
-rw-r--r--src/ui/main_window/MainWindowUI.cpp13
-rw-r--r--src/ui/struct/settings_object/AppearanceSO.h9
-rw-r--r--ui/AppearanceSettings.ui71
11 files changed, 158 insertions, 27 deletions
diff --git a/gpgfrontend.qrc b/gpgfrontend.qrc
index d82a47fa..49a26dec 100644
--- a/gpgfrontend.qrc
+++ b/gpgfrontend.qrc
@@ -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>
diff --git a/resource/lfs/icons/decr-verify.png b/resource/lfs/icons/decr-verify.png
new file mode 100644
index 00000000..0385cabf
--- /dev/null
+++ b/resource/lfs/icons/decr-verify.png
Binary files differ
diff --git a/resource/lfs/icons/encr-sign.png b/resource/lfs/icons/encr-sign.png
new file mode 100644
index 00000000..25275481
--- /dev/null
+++ b/resource/lfs/icons/encr-sign.png
Binary files differ
diff --git a/resource/lfs/icons/file-operator.png b/resource/lfs/icons/file-operator.png
index cab57a98..e547d886 100644
--- a/resource/lfs/icons/file-operator.png
+++ b/resource/lfs/icons/file-operator.png
Binary files differ
diff --git a/src/core/typedef/GpgTypedef.h b/src/core/typedef/GpgTypedef.h
index c052b6a2..fffc5cf4 100644
--- a/src/core/typedef/GpgTypedef.h
+++ b/src/core/typedef/GpgTypedef.h
@@ -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 \ No newline at end of file
diff --git a/src/ui/dialog/settings/SettingsAppearance.cpp b/src/ui/dialog/settings/SettingsAppearance.cpp
index d2648498..6c0d18c7 100644
--- a/src/ui/dialog/settings/SettingsAppearance.cpp
+++ b/src/ui/dialog/settings/SettingsAppearance.cpp
@@ -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();
diff --git a/src/ui/main_window/MainWindow.cpp b/src/ui/main_window/MainWindow.cpp
index f9d5d8be..4817cbcd 100644
--- a/src/ui/main_window/MainWindow.cpp
+++ b/src/ui/main_window/MainWindow.cpp
@@ -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);
}
+ 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_);
- prohibit_update_checking_ =
- settings.value("network/prohibit_update_check").toBool();
+ // 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() {
diff --git a/src/ui/main_window/MainWindowSlotUI.cpp b/src/ui/main_window/MainWindowSlotUI.cpp
index 40df7dbc..dc282c64 100644
--- a/src/ui/main_window/MainWindowSlotUI.cpp
+++ b/src/ui/main_window/MainWindowSlotUI.cpp
@@ -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()) {
diff --git a/src/ui/main_window/MainWindowUI.cpp b/src/ui/main_window/MainWindowUI.cpp
index 59ad8401..16b4eed6 100644
--- a/src/ui/main_window/MainWindowUI.cpp
+++ b/src/ui/main_window/MainWindowUI.cpp
@@ -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"));
diff --git a/src/ui/struct/settings_object/AppearanceSO.h b/src/ui/struct/settings_object/AppearanceSO.h
index 4722ebd3..5f20d1fe 100644
--- a/src/ui/struct/settings_object/AppearanceSO.h
+++ b/src/ui/struct/settings_object/AppearanceSO.h
@@ -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;
diff --git a/ui/AppearanceSettings.ui b/ui/AppearanceSettings.ui
index aed30461..ed6acea6 100644
--- a/ui/AppearanceSettings.ui
+++ b/ui/AppearanceSettings.ui
@@ -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>