aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2022-01-02 07:07:19 +0000
committerSaturneric <[email protected]>2022-01-02 07:07:19 +0000
commit0f464081971569d9ec6f621cfecdb39a5b8ee2b9 (patch)
tree74ee8b9e83cb599b8b16cadb72ef9621bfc37814
parent<refactor, fixed, test>(core, ui): add & modify core and ui (diff)
downloadGpgFrontend-0f464081971569d9ec6f621cfecdb39a5b8ee2b9.tar.gz
GpgFrontend-0f464081971569d9ec6f621cfecdb39a5b8ee2b9.zip
<feat, refactor, fixed>(core, ui): add & modify file operations
1. add non ascii mode for file operations. 2. the suffix of normalized file encryption. 3. refactor general settings.
-rw-r--r--src/CMakeLists.txt68
-rw-r--r--src/gpg/GpgContext.cpp4
-rw-r--r--src/gpg/function/BasicOperator.cpp3
-rw-r--r--src/gpg/function/GpgFileOpera.cpp94
-rw-r--r--src/gpg/function/GpgFileOpera.h29
-rw-r--r--src/gpg/function/GpgKeyOpera.cpp5
-rw-r--r--src/ui/MainWindow.cpp12
-rw-r--r--src/ui/keypair_details/KeyPairDetailTab.cpp15
-rw-r--r--src/ui/keypair_details/KeyPairSubkeyTab.cpp2
-rw-r--r--src/ui/main_window/MainWindowFileSlotFunction.cpp245
-rw-r--r--src/ui/main_window/MainWindowSlotFunction.cpp8
-rw-r--r--src/ui/settings/SettingsGeneral.cpp396
-rw-r--r--src/ui/settings/SettingsGeneral.h23
-rw-r--r--src/ui/widgets/FilePage.cpp131
-rw-r--r--src/ui/widgets/FilePage.h11
-rw-r--r--src/ui/widgets/InfoBoardWidget.cpp3
-rw-r--r--src/ui/widgets/KeyList.cpp3
-rw-r--r--ui/FilePage.ui55
-rw-r--r--ui/GeneralSettings.ui145
-rw-r--r--ui/InfoBoard.ui15
-rw-r--r--ui/KeyList.ui65
21 files changed, 651 insertions, 681 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3810a6e8..50897ac5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -31,13 +31,13 @@ if (APPLICATION_BUILD)
set(APP_ICON_RESOURCE_WINDOWS "${CMAKE_SOURCE_DIR}/gpgfrontend.rc")
set_property(SOURCE gpgfrontend.rc APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_SOURCE_DIR}/gpgfrontend.ico)
- if(NOT XCODE_BUILD)
+ if (NOT XCODE_BUILD)
# Set Binary Output Path
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/release)
- else()
- # Set Binary Output Path
- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
- endif()
+ else ()
+ # Set Binary Output Path
+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
+ endif ()
message(STATUS "CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
endif ()
@@ -119,9 +119,9 @@ if (APPLICATION_BUILD)
file(COPY ${CMAKE_SOURCE_DIR}/resource/css DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
file(COPY ${CMAKE_SOURCE_DIR}/resource/icons DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
file(COPY ${CMAKE_SOURCE_DIR}/TRANSLATORS DESTINATION ${RESOURCE_OUTPUT_DIRECTORY} FOLLOW_SYMLINK_CHAIN)
- if(GPG_STANDALONE_MODE)
+ if (GPG_STANDALONE_MODE)
file(COPY ${CMAKE_SOURCE_DIR}/resource/gpg1.4 DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
- endif()
+ endif ()
endif ()
if (APPLICATION_BUILD)
@@ -194,36 +194,36 @@ if (APPLICATION_BUILD)
elseif (APPLE AND XCODE_BUILD)
add_executable(${AppName} MACOSX_BUNDLE ${ICON_RESOURCE} ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
set_target_properties(${AppName} PROPERTIES
- BUNDLE True
- MACOSX_BUNDLE_GUI_IDENTIFIER pub.gpgfrontend.gpgfrontend
- MACOSX_BUNDLE_BUNDLE_NAME ${AppName}
- MACOSX_BUNDLE_LONG_VERSION_STRING ${BUILD_VERSION}
- MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION}
- MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
- MACOSX_BUNDLE_COPYRIGHT "GPL-3.0"
- MACOSX_BUNDLE_INFO_STRING "An OpenPGP Crypto Tool"
- MACOSX_BUNDLE_ICON_FILE "gpgfrontend.icns"
- MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/resource/plist/MacOSXBundleInfo.plist.in
- )
+ BUNDLE True
+ MACOSX_BUNDLE_GUI_IDENTIFIER pub.gpgfrontend.gpgfrontend
+ MACOSX_BUNDLE_BUNDLE_NAME ${AppName}
+ MACOSX_BUNDLE_LONG_VERSION_STRING ${BUILD_VERSION}
+ MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION}
+ MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
+ MACOSX_BUNDLE_COPYRIGHT "GPL-3.0"
+ MACOSX_BUNDLE_INFO_STRING "An OpenPGP Crypto Tool"
+ MACOSX_BUNDLE_ICON_FILE "gpgfrontend.icns"
+ MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/resource/plist/MacOSXBundleInfo.plist.in
+ )
add_custom_command(TARGET ${AppName} POST_BUILD
- COMMAND /bin/rm -rf ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${AppName}.app/Contents/Resources
- WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
- COMMENT "Deleting Resources in App Bundle")
+ COMMAND /bin/rm -rf ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${AppName}.app/Contents/Resources
+ WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
+ COMMENT "Deleting Resources in App Bundle")
add_custom_command(TARGET ${AppName} POST_BUILD
- COMMAND /bin/cp -rf ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Resources ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/${AppName}.app/Contents/
- WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
- COMMENT "Copying Resources into App Bundle Resource")
+ COMMAND /bin/cp -rf ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Resources ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/${AppName}.app/Contents/
+ WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
+ COMMENT "Copying Resources into App Bundle Resource")
add_custom_command(TARGET ${AppName} POST_BUILD
- COMMAND macdeployqt ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/${AppName}.app
- WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
- COMMENT "Resolving Qt Dependency")
+ COMMAND macdeployqt ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/${AppName}.app
+ WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
+ COMMENT "Resolving Qt Dependency")
set_target_properties(${AppName} PROPERTIES
- XCODE_ATTRIBUTE_INSTALL_PATH "$(LOCAL_APPS_DIR)"
- XCODE_ATTRIBUTE_SKIP_INSTALL "No"
- XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "--deep --entitlements ${CMAKE_SOURCE_DIR}/resource/plist/entitlement.plist"
- XCODE_ATTRIBUTE_ENABLE_APP_SANDBOX "Yes"
- )
- else()
+ XCODE_ATTRIBUTE_INSTALL_PATH "$(LOCAL_APPS_DIR)"
+ XCODE_ATTRIBUTE_SKIP_INSTALL "No"
+ XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "--deep --entitlements ${CMAKE_SOURCE_DIR}/resource/plist/entitlement.plist"
+ XCODE_ATTRIBUTE_ENABLE_APP_SANDBOX "Yes"
+ )
+ else ()
add_executable(${AppName} ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
endif ()
else ()
@@ -314,7 +314,7 @@ if (LINUX_INSTALL_SOFTWARE)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_PACKAGE_CONTACT "[email protected]")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Saturneric")
- set(CPACK_DEBIAN_PACKAGE_DEPENDS "gpg (>= 2.2), libqt5core5a (>= 5.9), libqt5gui5 (>= 5.9), libqt5widgets5 (>= 5.9), libqt5network5 (>= 5.9), libqt5printsupport5 (>= 5.9)")
+ set(CPACK_DEBIAN_PACKAGE_DEPENDS "gpg (>= 2.2), libqt5core5a (>= 5.9), libqt5gui5 (>= 5.9), libqt5widgets5 (>= 5.9), libqt5network5 (>= 5.9), libqt5printsupport5 (>= 5.9), libconfig++-dev (>=1.5)")
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
diff --git a/src/gpg/GpgContext.cpp b/src/gpg/GpgContext.cpp
index 8ecb7b87..c885ac94 100644
--- a/src/gpg/GpgContext.cpp
+++ b/src/gpg/GpgContext.cpp
@@ -152,6 +152,10 @@ void GpgContext::init_ctx() {
/** Setting the output type must be done at the beginning */
/** think this means ascii-armor --> ? */
gpgme_set_armor(*this, 1);
+ } else {
+ /** Setting the output type must be done at the beginning */
+ /** think this means ascii-armor --> ? */
+ gpgme_set_armor(*this, 0);
}
// Speed up loading process
diff --git a/src/gpg/function/BasicOperator.cpp b/src/gpg/function/BasicOperator.cpp
index e52c091c..0383f8ab 100644
--- a/src/gpg/function/BasicOperator.cpp
+++ b/src/gpg/function/BasicOperator.cpp
@@ -75,8 +75,7 @@ GpgFrontend::GpgError GpgFrontend::BasicOperator::Verify(
BypeArrayRef& in_buffer, ByteArrayPtr& sig_buffer,
GpgVerifyResult& result) const {
gpgme_error_t err;
-
- LOG(INFO) << "in buffer size" << in_buffer.size();
+
GpgData data_in(in_buffer.data(), in_buffer.size());
GpgData data_out;
diff --git a/src/gpg/function/GpgFileOpera.cpp b/src/gpg/function/GpgFileOpera.cpp
index 42b37c71..b5c907a2 100644
--- a/src/gpg/function/GpgFileOpera.cpp
+++ b/src/gpg/function/GpgFileOpera.cpp
@@ -30,15 +30,16 @@
#include "gpg/function/BasicOperator.h"
GpgFrontend::GpgError GpgFrontend::GpgFileOpera::EncryptFile(
- KeyListPtr keys, const std::string& path, GpgEncrResult& result) {
- std::string in_buffer = read_all_data_in_file(path);
+ KeyListPtr keys, const std::string& in_path, const std::string& out_path,
+ GpgEncrResult& result, int _channel) {
+ std::string in_buffer = read_all_data_in_file(in_path);
std::unique_ptr<std::string> out_buffer;
- auto err = BasicOperator::GetInstance().Encrypt(std::move(keys), in_buffer,
- out_buffer, result);
+ auto err = BasicOperator::GetInstance(_channel).Encrypt(
+ std::move(keys), in_buffer, out_buffer, result);
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR)
- if (!write_buffer_to_file(path + ".asc", *out_buffer)) {
+ if (!write_buffer_to_file(out_path, *out_buffer)) {
throw std::runtime_error("write_buffer_to_file error");
};
@@ -46,8 +47,9 @@ GpgFrontend::GpgError GpgFrontend::GpgFileOpera::EncryptFile(
}
GpgFrontend::GpgError GpgFrontend::GpgFileOpera::DecryptFile(
- const std::string& path, GpgDecrResult& result) {
- std::string in_buffer = read_all_data_in_file(path);
+ const std::string& in_path, const std::string& out_path,
+ GpgDecrResult& result) {
+ std::string in_buffer = read_all_data_in_file(in_path);
std::unique_ptr<std::string> out_buffer;
auto err =
@@ -55,14 +57,8 @@ GpgFrontend::GpgError GpgFrontend::GpgFileOpera::DecryptFile(
assert(check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR);
- std::string out_file_name = get_only_file_name_with_path(path),
- file_extension = get_file_extension(path);
-
- if (!(file_extension == ".asc" || file_extension == ".gpg"))
- out_file_name += ".out";
-
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR)
- if (!write_buffer_to_file(out_file_name, *out_buffer)) {
+ if (!write_buffer_to_file(out_path, *out_buffer)) {
throw std::runtime_error("write_buffer_to_file error");
};
@@ -70,58 +66,49 @@ GpgFrontend::GpgError GpgFrontend::GpgFileOpera::DecryptFile(
}
gpgme_error_t GpgFrontend::GpgFileOpera::SignFile(KeyListPtr keys,
- const std::string& path,
- GpgSignResult& result) {
- auto in_buffer = read_all_data_in_file(path);
+ const std::string& in_path,
+ const std::string& out_path,
+ GpgSignResult& result,
+ int _channel) {
+ auto in_buffer = read_all_data_in_file(in_path);
std::unique_ptr<std::string> out_buffer;
- auto err = BasicOperator::GetInstance().Sign(
+ auto err = BasicOperator::GetInstance(_channel).Sign(
std::move(keys), in_buffer, out_buffer, GPGME_SIG_MODE_DETACH, result);
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR)
- if (!write_buffer_to_file(path + ".sig", *out_buffer)) {
+ if (!write_buffer_to_file(out_path, *out_buffer)) {
throw std::runtime_error("write_buffer_to_file error");
};
return err;
}
-gpgme_error_t GpgFrontend::GpgFileOpera::VerifyFile(const std::string& path,
- GpgVerifyResult& result) {
- auto in_buffer = read_all_data_in_file(path);
+gpgme_error_t GpgFrontend::GpgFileOpera::VerifyFile(
+ const std::string& data_path, const std::string& sign_path,
+ GpgVerifyResult& result, int _channel) {
+ auto in_buffer = read_all_data_in_file(data_path);
std::unique_ptr<std::string> sign_buffer = nullptr;
-
- if (get_file_extension(path) == ".gpg") {
- auto err =
- BasicOperator::GetInstance().Verify(in_buffer, sign_buffer, result);
- return err;
- } else {
+ if (!sign_path.empty()) {
sign_buffer =
- std::make_unique<std::string>(read_all_data_in_file(path + ".sig"));
-
- auto err =
- BasicOperator::GetInstance().Verify(in_buffer, sign_buffer, result);
- return err;
+ std::make_unique<std::string>(read_all_data_in_file(sign_path));
}
+ auto err = BasicOperator::GetInstance(_channel).Verify(in_buffer, sign_buffer,
+ result);
+ return err;
}
-// TODO
-
gpg_error_t GpgFrontend::GpgFileOpera::EncryptSignFile(
- KeyListPtr keys, KeyListPtr signer_keys, const std::string& path,
- GpgEncrResult& encr_res, GpgSignResult& sign_res) {
- auto in_buffer = read_all_data_in_file(path);
+ KeyListPtr keys, KeyListPtr signer_keys, const std::string& in_path,
+ const std::string& out_path, GpgEncrResult& encr_res,
+ GpgSignResult& sign_res, int _channel) {
+ auto in_buffer = read_all_data_in_file(in_path);
std::unique_ptr<std::string> out_buffer = nullptr;
- // TODO dealing with signer keys
- auto err = BasicOperator::GetInstance().EncryptSign(
+ auto err = BasicOperator::GetInstance(_channel).EncryptSign(
std::move(keys), std::move(signer_keys), in_buffer, out_buffer, encr_res,
sign_res);
- auto out_path = path + ".gpg";
- LOG(INFO) << "EncryptSignFile out_path" << out_path;
- LOG(INFO) << "EncryptSignFile out_buffer size" << out_buffer->size();
-
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR)
if (!write_buffer_to_file(out_path, *out_buffer)) {
throw std::runtime_error("write_buffer_to_file error");
@@ -131,28 +118,17 @@ gpg_error_t GpgFrontend::GpgFileOpera::EncryptSignFile(
}
gpg_error_t GpgFrontend::GpgFileOpera::DecryptVerifyFile(
- const std::string& path, GpgDecrResult& decr_res,
- GpgVerifyResult& verify_res) {
- LOG(INFO) << "GpgFrontend::GpgFileOpera::DecryptVerifyFile Called";
-
- auto in_buffer = read_all_data_in_file(path);
+ const std::string& in_path, const std::string& out_path,
+ GpgDecrResult& decr_res, GpgVerifyResult& verify_res) {
+ auto in_buffer = read_all_data_in_file(in_path);
- LOG(INFO) << "GpgFrontend::GpgFileOpera::DecryptVerifyFile in_buffer"
- << in_buffer.size();
std::unique_ptr<std::string> out_buffer = nullptr;
auto err = BasicOperator::GetInstance().DecryptVerify(in_buffer, out_buffer,
decr_res, verify_res);
- std::string out_file_name = get_only_file_name_with_path(path),
- file_extension = get_file_extension(path);
-
- if (!(file_extension == ".asc" || file_extension == ".gpg"))
- out_file_name = path + ".out";
- LOG(INFO) << "out_file_name" << out_file_name;
-
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR)
- if (!write_buffer_to_file(out_file_name, *out_buffer)) {
+ if (!write_buffer_to_file(out_path, *out_buffer)) {
throw std::runtime_error("write_buffer_to_file error");
};
diff --git a/src/gpg/function/GpgFileOpera.h b/src/gpg/function/GpgFileOpera.h
index b7848440..6447e43b 100644
--- a/src/gpg/function/GpgFileOpera.h
+++ b/src/gpg/function/GpgFileOpera.h
@@ -37,22 +37,33 @@ class GpgFileOpera : public SingletonFunctionObject<GpgFileOpera> {
int channel = SingletonFunctionObject::GetDefaultChannel())
: SingletonFunctionObject<GpgFileOpera>(channel) {}
- static GpgError EncryptFile(KeyListPtr keys, const std::string& path,
- GpgEncrResult& result);
+ static unsigned int EncryptFile(KeyListPtr keys, const std::string& in_path,
+ const std::string& out_path,
+ GpgEncrResult& result,
+ int _channel = GPGFRONTEND_DEFAULT_CHANNEL);
- static GpgError DecryptFile(const std::string& path, GpgDecrResult& result);
+ static GpgError DecryptFile(const std::string& in_path,
+ const std::string& out_path,
+ GpgDecrResult& result);
- static GpgError SignFile(KeyListPtr keys, const std::string& path,
- GpgSignResult& result);
+ static GpgError SignFile(KeyListPtr keys, const std::string& in_path,
+ const std::string& out_path, GpgSignResult& result,
+ int _channel = GPGFRONTEND_DEFAULT_CHANNEL);
- static GpgError VerifyFile(const std::string& path, GpgVerifyResult& result);
+ static GpgError VerifyFile(const std::string& data_path,
+ const std::string& sign_path,
+ GpgVerifyResult& result,
+ int _channel = GPGFRONTEND_DEFAULT_CHANNEL);
static GpgError EncryptSignFile(KeyListPtr keys, KeyListPtr signer_keys,
- const std::string& path,
+ const std::string& in_path,
+ const std::string& out_path,
GpgEncrResult& encr_res,
- GpgSignResult& sign_res);
+ GpgSignResult& sign_res,
+ int _channel = GPGFRONTEND_DEFAULT_CHANNEL);
- static GpgError DecryptVerifyFile(const std::string& path,
+ static GpgError DecryptVerifyFile(const std::string& in_path,
+ const std::string& out_path,
GpgDecrResult& decr_res,
GpgVerifyResult& verify_res);
};
diff --git a/src/gpg/function/GpgKeyOpera.cpp b/src/gpg/function/GpgKeyOpera.cpp
index df89c6f5..e9fcbc1d 100644
--- a/src/gpg/function/GpgKeyOpera.cpp
+++ b/src/gpg/function/GpgKeyOpera.cpp
@@ -58,9 +58,10 @@ void GpgFrontend::GpgKeyOpera::DeleteKeys(
}
/**
- * Set the expire date and time of a key pair(actually the master key) or subkey
+ * Set the expire date and time of a key pair(actually the primary key) or
+ * subkey
* @param key target key pair
- * @param subkey null if master key
+ * @param subkey null if primary key
* @param expires date and time
* @return if successful
*/
diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp
index 8e6b6f81..0411be81 100644
--- a/src/ui/MainWindow.cpp
+++ b/src/ui/MainWindow.cpp
@@ -274,6 +274,11 @@ void MainWindow::restoreSettings() {
general.add("save_key_checked", libconfig::Setting::TypeBoolean) = true;
}
+ if (!general.exists("non_ascii_when_export")) {
+ general.add("non_ascii_when_export", libconfig::Setting::TypeBoolean) =
+ true;
+ }
+
bool save_key_checked = true;
general.lookupValue("save_key_checked", save_key_checked);
@@ -293,6 +298,13 @@ void MainWindow::restoreSettings() {
}
mKeyList->setChecked(key_ids_ptr);
}
+
+ auto& smtp = settings["smtp"];
+
+ if (!smtp.exists("enable")) {
+ smtp.add("enable", libconfig::Setting::TypeBoolean) = true;
+ }
+
} catch (...) {
LOG(ERROR) << "cannot resolve settings";
}
diff --git a/src/ui/keypair_details/KeyPairDetailTab.cpp b/src/ui/keypair_details/KeyPairDetailTab.cpp
index 7f48b3f8..54b845ab 100644
--- a/src/ui/keypair_details/KeyPairDetailTab.cpp
+++ b/src/ui/keypair_details/KeyPairDetailTab.cpp
@@ -30,12 +30,13 @@
#include "ui/SignalStation.h"
#include "ui/UserInterfaceUtils.h"
#include "ui/WaitingDialog.h"
+#include "ui/settings/GlobalSettingStation.h"
namespace GpgFrontend::UI {
KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent)
: QWidget(parent), mKey(GpgKeyGetter::GetInstance().GetKey(key_id)) {
ownerBox = new QGroupBox(_("Owner"));
- keyBox = new QGroupBox(_("Master Key"));
+ keyBox = new QGroupBox(_("Primary Key"));
fingerprintBox = new QGroupBox(_("Fingerprint"));
additionalUidBox = new QGroupBox(_("Additional UIDs"));
@@ -81,7 +82,7 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent)
0);
vboxKD->addWidget(new QLabel(QString(_("Last Update (Local Time)")) + ": "),
7, 0);
- vboxKD->addWidget(new QLabel(QString(_("Master Key Existence")) + ": "), 8,
+ vboxKD->addWidget(new QLabel(QString(_("Primary Key Existence")) + ": "), 8,
0);
keyidVarLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
@@ -155,7 +156,7 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent)
if (mKey.has_master_key()) {
auto* edit_expires_button =
- new QPushButton(_("Modify Expiration Datetime (Master Key)"));
+ new QPushButton(_("Modify Expiration Datetime (Primary Key)"));
connect(edit_expires_button, SIGNAL(clicked()), this,
SLOT(slotModifyEditDatetime()));
auto* edit_password_button = new QPushButton(_("Modify Password"));
@@ -338,7 +339,7 @@ void KeyPairDetailTab::slotModifyEditDatetime() {
}
void KeyPairDetailTab::slotRefreshKeyInfo() {
- // Show the situation that master key not exists.
+ // Show the situation that primary key not exists.
masterKeyExistVarLabel->setText(mKey.has_master_key() ? _("Exists")
: _("Not Exists"));
if (!mKey.has_master_key()) {
@@ -420,12 +421,12 @@ void KeyPairDetailTab::slotRefreshKeyInfo() {
if (mKey.expired()) {
iconLabel->show();
expLabel->show();
- expLabel->setText(_("Warning: The Master Key has expired."));
+ expLabel->setText(_("Warning: The primary key has expired."));
}
if (mKey.revoked()) {
iconLabel->show();
expLabel->show();
- expLabel->setText(_("Warning: The Master Key has been revoked."));
+ expLabel->setText(_("Warning: The primary key has been revoked."));
}
}
@@ -442,7 +443,7 @@ void KeyPairDetailTab::createOperaMenu() {
connect(updateKeyPair, SIGNAL(triggered()), this,
SLOT(slotUpdateKeyFromServer()));
- // when a key has master key, it should always upload to keyserver.
+ // when a key has primary key, it should always upload to keyserver.
if (mKey.has_master_key()) {
updateKeyPair->setDisabled(true);
}
diff --git a/src/ui/keypair_details/KeyPairSubkeyTab.cpp b/src/ui/keypair_details/KeyPairSubkeyTab.cpp
index 8068d9a8..928baae9 100644
--- a/src/ui/keypair_details/KeyPairSubkeyTab.cpp
+++ b/src/ui/keypair_details/KeyPairSubkeyTab.cpp
@@ -248,7 +248,7 @@ void KeyPairSubkeyTab::slotRefreshSubkeyDetail() {
usageVarLabel->setText(usage_steam.str().c_str());
- // Show the situation that master key not exists.
+ // Show the situation that primary key not exists.
masterKeyExistVarLabel->setText(subkey.secret() ? _("Exists")
: _("Not Exists"));
if (!subkey.secret()) {
diff --git a/src/ui/main_window/MainWindowFileSlotFunction.cpp b/src/ui/main_window/MainWindowFileSlotFunction.cpp
index 2a2c9be9..dc31462a 100644
--- a/src/ui/main_window/MainWindowFileSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowFileSlotFunction.cpp
@@ -26,6 +26,7 @@
#include "gpg/function/GpgFileOpera.h"
#include "gpg/function/GpgKeyGetter.h"
#include "ui/UserInterfaceUtils.h"
+#include "ui/settings/GlobalSettingStation.h"
#include "ui/widgets/SignersPicker.h"
namespace GpgFrontend::UI {
@@ -57,42 +58,65 @@ void MainWindow::slotFileEncrypt() {
if (!file_pre_check(this, path)) return;
- if (QFile::exists(path + ".asc")) {
- auto ret = QMessageBox::warning(
- this, _("Warning"),
- _("The target file already exists, do you need to overwrite it?"),
- QMessageBox::Ok | QMessageBox::Cancel);
-
- if (ret == QMessageBox::Cancel) return;
- }
-
+ // check selected keys
auto key_ids = mKeyList->getChecked();
- auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids);
- if (keys->empty()) {
- QMessageBox::critical(this, _("No Key Selected"), _("No Key Selected"));
+ auto p_keys = GpgKeyGetter::GetInstance().GetKeys(key_ids);
+
+ if (p_keys->empty()) {
+ QMessageBox::critical(
+ this, _("No Key Selected"),
+ _("Please select the key in the key toolbox on the right."));
return;
}
- for (const auto& key : *keys) {
- if (!key.CanEncrActual()) {
- QMessageBox::information(
- this, _("Invalid Operation"),
- QString(
- _("The selected key contains a key that does not actually have a "
- "encrypt usage.")) +
+ // check key abilities
+ for (const auto& key : *p_keys) {
+ bool key_can_encrypt = key.CanEncrActual();
+
+ if (!key_can_encrypt) {
+ QMessageBox::critical(
+ nullptr, _("Invalid KeyPair"),
+ QString(_("The selected keypair cannot be used for encryption.")) +
"<br/><br/>" + _("For example the Following Key:") + " <br/>" +
QString::fromStdString(key.uids()->front().uid()));
return;
}
}
+ // Detect ascii mode
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ bool non_ascii_when_export = true;
+ try {
+ non_ascii_when_export = settings.lookup("general.non_ascii_when_export");
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error") << _("non_ascii_when_export");
+ }
+
+ auto _channel = GPGFRONTEND_DEFAULT_CHANNEL;
+ auto _extension = ".asc";
+ if (non_ascii_when_export) {
+ _channel = GPGFRONTEND_NON_ASCII_CHANNEL;
+ _extension = ".gpg";
+ }
+
+ auto out_path = path + _extension;
+ if (QFile::exists(out_path)) {
+ auto ret = QMessageBox::warning(
+ this, _("Warning"),
+ _("The target file already exists, do you need to overwrite it?"),
+ QMessageBox::Ok | QMessageBox::Cancel);
+
+ if (ret == QMessageBox::Cancel) return;
+ }
+
GpgEncrResult result = nullptr;
GpgError error;
bool if_error = false;
process_operation(this, _("Encrypting"), [&]() {
try {
- error = GpgFileOpera::EncryptFile(std::move(keys), path.toStdString(),
- result);
+ error =
+ GpgFileOpera::EncryptFile(std::move(p_keys), path.toStdString(),
+ out_path.toStdString(), result, _channel);
} catch (const std::runtime_error& e) {
if_error = true;
}
@@ -116,16 +140,15 @@ void MainWindow::slotFileDecrypt() {
if (!file_pre_check(this, path)) return;
- QString outFileName, fileExtension = QFileInfo(path).suffix();
+ boost::filesystem::path out_path = path.toStdString();
- if (fileExtension == "asc" || fileExtension == "gpg") {
- int pos = path.lastIndexOf(QChar('.'));
- outFileName = path.left(pos);
+ if (out_path.extension() == ".asc" || out_path.extension() == ".gpg") {
+ out_path = out_path.parent_path() / out_path.stem();
} else {
- outFileName = path + ".out";
+ out_path += ".out";
}
- if (QFile::exists(outFileName)) {
+ if (exists(out_path)) {
auto ret = QMessageBox::warning(
this, _("Warning"),
_("The target file already exists, do you need to overwrite it?"),
@@ -139,7 +162,8 @@ void MainWindow::slotFileDecrypt() {
bool if_error = false;
process_operation(this, _("Decrypting"), [&]() {
try {
- error = GpgFileOpera::DecryptFile(path.toStdString(), result);
+ error = GpgFileOpera::DecryptFile(path.toStdString(), out_path.string(),
+ result);
} catch (const std::runtime_error& e) {
if_error = true;
}
@@ -168,7 +192,9 @@ void MainWindow::slotFileSign() {
auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids);
if (keys->empty()) {
- QMessageBox::critical(this, _("No Key Selected"), _("No Key Selected"));
+ QMessageBox::critical(
+ this, _("No Key Selected"),
+ _("Please select the key in the key toolbox on the right."));
return;
}
@@ -184,8 +210,26 @@ void MainWindow::slotFileSign() {
}
}
- auto sig_file_path = boost::filesystem::path(path.toStdString() + ".sig");
- if (QFile::exists(sig_file_path.string().c_str())) {
+ // Detect ascii mode
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ bool non_ascii_when_export = true;
+ try {
+ non_ascii_when_export = settings.lookup("general.non_ascii_when_export");
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error") << _("non_ascii_when_export");
+ }
+
+ auto _channel = GPGFRONTEND_DEFAULT_CHANNEL;
+ auto _extension = ".asc";
+ if (non_ascii_when_export) {
+ _channel = GPGFRONTEND_NON_ASCII_CHANNEL;
+ _extension = ".sig";
+ }
+
+ boost::filesystem::path in_path = path.toStdString();
+ auto sig_file_path = in_path;
+ sig_file_path += _extension;
+ if (exists(sig_file_path)) {
auto ret = QMessageBox::warning(
this, _("Warning"),
QString(_("The signature file \"%1\" exists, "
@@ -202,8 +246,8 @@ void MainWindow::slotFileSign() {
process_operation(this, _("Signing"), [&]() {
try {
- error =
- GpgFileOpera::SignFile(std::move(keys), path.toStdString(), result);
+ error = GpgFileOpera::SignFile(std::move(keys), in_path.string(),
+ sig_file_path.string(), result, _channel);
} catch (const std::runtime_error& e) {
if_error = true;
}
@@ -229,60 +273,62 @@ void MainWindow::slotFileVerify() {
auto fileTreeView = edit->slotCurPageFileTreeView();
auto path = fileTreeView->getSelected();
- QFileInfo fileInfo(path);
+ boost::filesystem::path in_path = path.toStdString();
+ boost::filesystem::path sign_file_path = in_path, data_file_path;
+
+ // Detect ascii mode
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ bool non_ascii_when_export = true;
+ try {
+ non_ascii_when_export = settings.lookup("general.non_ascii_when_export");
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error") << _("non_ascii_when_export");
+ }
- QString signFilePath, dataFilePath;
+ auto _channel = GPGFRONTEND_DEFAULT_CHANNEL;
+ if (non_ascii_when_export) {
+ _channel = GPGFRONTEND_NON_ASCII_CHANNEL;
+ }
- if (fileInfo.suffix() == "gpg") {
- dataFilePath = path;
- signFilePath = path;
- } else if (fileInfo.suffix() == "sig") {
- int pos = path.lastIndexOf(QChar('.'));
- dataFilePath = path.left(pos);
- signFilePath = path;
- } else {
- dataFilePath = path;
- signFilePath = path + ".sig";
+ if (in_path.extension() == ".gpg") {
+ swap(data_file_path, sign_file_path);
+ } else if (in_path.extension() == ".sig" || in_path.extension() == ".asc") {
+ data_file_path = sign_file_path.parent_path() / sign_file_path.stem();
}
- if (fileInfo.suffix() != "gpg") {
+ LOG(INFO) << "sign_file_path" << sign_file_path << sign_file_path.extension();
+
+ if (in_path.extension() != ".gpg") {
bool ok;
- QString text =
- QInputDialog::getText(this, _("Origin file to verify"), _("Filepath"),
- QLineEdit::Normal, dataFilePath, &ok);
+ QString text = QInputDialog::getText(this, _("Origin file to verify"),
+ _("Filepath"), QLineEdit::Normal,
+ data_file_path.string().c_str(), &ok);
if (ok && !text.isEmpty()) {
- dataFilePath = text;
+ data_file_path = text.toStdString();
} else {
return;
}
}
- QFileInfo dataFileInfo(dataFilePath), signFileInfo(signFilePath);
-
- if (!dataFileInfo.isFile() || !signFileInfo.isFile()) {
+ if (!is_regular_file(data_file_path) ||
+ (!sign_file_path.empty() && !is_regular_file(sign_file_path))) {
QMessageBox::critical(
this, _("Error"),
_("Please select the appropriate origin file or signature file. "
"Ensure that both are in this directory."));
return;
}
- if (!dataFileInfo.isReadable()) {
- QMessageBox::critical(this, _("Error"),
- _("No permission to read target file."));
- return;
- }
- if (!fileInfo.isReadable()) {
- QMessageBox::critical(this, _("Error"),
- _("No permission to read signature file."));
- return;
- }
+
+ DLOG(INFO) << "data path" << data_file_path;
+ DLOG(INFO) << "sign path" << sign_file_path;
GpgVerifyResult result = nullptr;
gpgme_error_t error;
bool if_error = false;
process_operation(this, _("Verifying"), [&]() {
try {
- error = GpgFileOpera::VerifyFile(dataFilePath.toStdString(), result);
+ error = GpgFileOpera::VerifyFile(
+ data_file_path.string(), sign_file_path.string(), result, _channel);
} catch (const std::runtime_error& e) {
if_error = true;
}
@@ -313,23 +359,18 @@ void MainWindow::slotFileEncryptSign() {
if (!file_pre_check(this, path)) return;
- if (QFile::exists(path + ".gpg")) {
- auto ret = QMessageBox::warning(
- this, _("Warning"),
- _("The target file already exists, do you need to overwrite it?"),
- QMessageBox::Ok | QMessageBox::Cancel);
-
- if (ret == QMessageBox::Cancel) return;
- }
-
+ // check selected keys
auto key_ids = mKeyList->getChecked();
auto p_keys = GpgKeyGetter::GetInstance().GetKeys(key_ids);
if (p_keys->empty()) {
- QMessageBox::critical(this, _("No Key Selected"), _("No Key Selected"));
+ QMessageBox::critical(
+ this, _("No Key Selected"),
+ _("Please select the key in the key toolbox on the right."));
return;
}
+ // check key abilities
for (const auto& key : *p_keys) {
bool key_can_encrypt = key.CanEncrActual();
@@ -343,6 +384,33 @@ void MainWindow::slotFileEncryptSign() {
}
}
+ // Detect ascii mode
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ bool non_ascii_when_export = true;
+ try {
+ non_ascii_when_export = settings.lookup("general.non_ascii_when_export");
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error") << _("non_ascii_when_export");
+ }
+
+ auto _channel = GPGFRONTEND_DEFAULT_CHANNEL;
+ auto _extension = ".asc";
+ if (non_ascii_when_export) {
+ _channel = GPGFRONTEND_NON_ASCII_CHANNEL;
+ _extension = ".gpg";
+ }
+
+ boost::filesystem::path out_path = path.toStdString() + _extension;
+
+ if (exists(out_path)) {
+ auto ret = QMessageBox::warning(
+ this, _("Warning"),
+ _("The target file already exists, do you need to overwrite it?"),
+ QMessageBox::Ok | QMessageBox::Cancel);
+
+ if (ret == QMessageBox::Cancel) return;
+ }
+
auto signersPicker = new SignersPicker(this);
QEventLoop loop;
connect(signersPicker, SIGNAL(finished(int)), &loop, SLOT(quit()));
@@ -351,14 +419,6 @@ void MainWindow::slotFileEncryptSign() {
auto signer_key_ids = signersPicker->getCheckedSigners();
auto p_signer_keys = GpgKeyGetter::GetInstance().GetKeys(signer_key_ids);
- for (const auto& key : *p_keys) {
- LOG(INFO) << "Keys " << key.email();
- }
-
- for (const auto& signer : *p_signer_keys) {
- LOG(INFO) << "Signers " << signer.email();
- }
-
GpgEncrResult encr_result = nullptr;
GpgSignResult sign_result = nullptr;
@@ -369,18 +429,18 @@ void MainWindow::slotFileEncryptSign() {
try {
error = GpgFileOpera::EncryptSignFile(
std::move(p_keys), std::move(p_signer_keys), path.toStdString(),
- encr_result, sign_result);
+ out_path.string(), encr_result, sign_result, _channel);
} catch (const std::runtime_error& e) {
if_error = true;
}
});
if (!if_error) {
- auto encrypt_res = EncryptResultAnalyse(error, std::move(encr_result));
+ auto encrypt_result = EncryptResultAnalyse(error, std::move(encr_result));
auto sign_res = SignResultAnalyse(error, std::move(sign_result));
- encrypt_res.analyse();
+ encrypt_result.analyse();
sign_res.analyse();
- process_result_analyse(edit, infoBoard, encrypt_res, sign_res);
+ process_result_analyse(edit, infoBoard, encrypt_result, sign_res);
fileTreeView->update();
@@ -397,11 +457,12 @@ void MainWindow::slotFileDecryptVerify() {
if (!file_pre_check(this, path)) return;
- boost::filesystem::path out_path(path.toStdString());
- if (out_path.extension() == ".asc" || out_path.extension() == ".gpg") {
- out_path = out_path.parent_path() / out_path.filename();
+ boost::filesystem::path in_path(path.toStdString());
+ boost::filesystem::path out_path = in_path;
+ if (in_path.extension() == ".asc" || in_path.extension() == ".gpg") {
+ out_path = in_path.parent_path() / out_path.stem();
} else {
- out_path = out_path.replace_extension(".out").string();
+ out_path += ".out";
}
LOG(INFO) << "out path" << out_path;
@@ -422,8 +483,8 @@ void MainWindow::slotFileDecryptVerify() {
bool if_error = false;
process_operation(this, _("Decrypting and Verifying"), [&]() {
try {
- error = GpgFileOpera::DecryptVerifyFile(path.toStdString(), d_result,
- v_result);
+ error = GpgFileOpera::DecryptVerifyFile(
+ path.toStdString(), out_path.string(), d_result, v_result);
} catch (const std::runtime_error& e) {
if_error = true;
}
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp
index 9dd3e5cf..67ade3ae 100644
--- a/src/ui/main_window/MainWindowSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowSlotFunction.cpp
@@ -129,7 +129,9 @@ void MainWindow::slotSign() {
auto key_ids = mKeyList->getPrivateChecked();
if (key_ids->empty()) {
- QMessageBox::critical(this, _("No Key Selected"), _("No Key Selected"));
+ QMessageBox::critical(
+ this, _("No Key Selected"),
+ _("Please select the key in the key toolbox on the right."));
return;
}
@@ -270,7 +272,9 @@ void MainWindow::slotEncryptSign() {
auto key_ids = mKeyList->getChecked();
if (key_ids->empty()) {
- QMessageBox::critical(nullptr, _("No Key Selected"), _("No Key Selected"));
+ QMessageBox::critical(
+ nullptr, _("No Key Selected"),
+ _("Please select the key in the key toolbox on the right."));
return;
}
diff --git a/src/ui/settings/SettingsGeneral.cpp b/src/ui/settings/SettingsGeneral.cpp
index 6b6568a4..4f8ef544 100644
--- a/src/ui/settings/SettingsGeneral.cpp
+++ b/src/ui/settings/SettingsGeneral.cpp
@@ -24,157 +24,49 @@
#include "SettingsGeneral.h"
-#ifdef SERVER_SUPPORT
-#include "server/ComUtils.h"
-#endif
-
#ifdef MULTI_LANG_SUPPORT
#include "SettingsDialog.h"
#endif
#include "GlobalSettingStation.h"
-#include "gpg/function/GpgKeyGetter.h"
-#include "ui/widgets/KeyList.h"
+#include "ui_GeneralSettings.h"
namespace GpgFrontend::UI {
-GeneralTab::GeneralTab(QWidget* parent) : QWidget(parent) {
-#ifdef SERVER_SUPPORT
- /*****************************************
- * GpgFrontend Server
- *****************************************/
- auto* serverBox = new QGroupBox(_("GpgFrontend Server"));
- auto* serverBoxLayout = new QVBoxLayout();
- serverSelectBox = new QComboBox();
- serverBoxLayout->addWidget(serverSelectBox);
- serverBoxLayout->addWidget(new QLabel(
- _("Server that provides short key and key exchange services")));
-
- serverBox->setLayout(serverBoxLayout);
-#endif
-
- /*****************************************
- * Save-Checked-Keys-Box
- *****************************************/
- auto* saveCheckedKeysBox = new QGroupBox(_("Save Checked Keys"));
- auto* saveCheckedKeysBoxLayout = new QHBoxLayout();
- saveCheckedKeysCheckBox = new QCheckBox(
- _("Save checked private keys on exit and restore them on next start."),
- this);
- saveCheckedKeysBoxLayout->addWidget(saveCheckedKeysCheckBox);
- saveCheckedKeysBox->setLayout(saveCheckedKeysBoxLayout);
-
- /*****************************************
- * Longer-Expire-Date-Box
- *****************************************/
- auto* longerKeyExpirationDateBox =
- new QGroupBox(_("Longer Key Expiration Date"));
- auto* longerKeyExpirationDateBoxLayout = new QHBoxLayout();
- longerKeyExpirationDateCheckBox = new QCheckBox(
- _("Unlock key expiration date setting up to 30 years."), this);
- longerKeyExpirationDateBoxLayout->addWidget(longerKeyExpirationDateCheckBox);
- longerKeyExpirationDateBox->setLayout(longerKeyExpirationDateBoxLayout);
-
- /*****************************************
- * Key-Impport-Confirmation Box
- *****************************************/
- auto* importConfirmationBox =
- new QGroupBox(_("Confirm drag'n'drop key import"));
- auto* importConfirmationBoxLayout = new QHBoxLayout();
- importConfirmationCheckBox = new QCheckBox(
- _("Import files dropped on the Key List without confirmation."), this);
- importConfirmationBoxLayout->addWidget(importConfirmationCheckBox);
- importConfirmationBox->setLayout(importConfirmationBoxLayout);
+GeneralTab::GeneralTab(QWidget* parent)
+ : QWidget(parent), ui(std::make_shared<Ui_GeneralSettings>()) {
+ ui->setupUi(this);
+
+ ui->saveCheckedKeysBox->setTitle(_("Save Checked Keys"));
+ ui->saveCheckedKeysCheckBox->setText(
+ _("Save checked private keys on exit and restore them on next start."));
+ ui->longerKeyExpirationDateBox->setTitle(_("Longer Key Expiration Date"));
+ ui->longerKeyExpirationDateCheckBox->setText(
+ _("Unlock key expiration date setting up to 30 years."));
+ ui->importConfirmationBox->setTitle(_("Confirm drag'n'drop key import"));
+ ui->importConfirmationCheckBox->setText(
+ _("Import files dropped on the Key List without confirmation."));
+
+ ui->asciiModeBox->setTitle(_("ASCII Mode"));
+ ui->asciiModeCheckBox->setText(
+ _("ASCII encoding is not used when file encrypting and "
+ "signing."));
+
+ ui->langBox->setTitle(_("Language"));
+ ui->langNoteLabel->setText(
+ "<b>" + QString(_("NOTE")) + _(": ") + "</b>" +
+ _("GpgFrontend will restart automatically if you change the language!"));
#ifdef MULTI_LANG_SUPPORT
- /*****************************************
- * Language Select Box
- *****************************************/
- auto* langBox = new QGroupBox(_("Language"));
- auto* langBoxLayout = new QVBoxLayout();
- langSelectBox = new QComboBox();
- langSelectBox->setMaxVisibleItems(8);
- langSelectBox->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
lang = SettingsDialog::listLanguages();
-
for (const auto& l : lang) {
- langSelectBox->addItem(l);
+ ui->langSelectBox->addItem(l);
}
- langSelectBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
-
- langBoxLayout->addWidget(langSelectBox);
- langBoxLayout->addWidget(new QLabel(
- "<b>" + QString(_("NOTE")) + _(": ") + "</b>" +
- _("GpgFrontend will restart automatically if you change the language!")));
- langBox->setLayout(langBoxLayout);
- connect(langSelectBox, SIGNAL(currentIndexChanged(int)), this,
+ connect(ui->langSelectBox, SIGNAL(currentIndexChanged(int)), this,
SLOT(slotLanguageChanged()));
#endif
-#ifdef SERVER_SUPPORT
- /*****************************************
- * Own Key Select Box
- *****************************************/
- auto* ownKeyBox = new QGroupBox(_("Own key"));
- auto* ownKeyBoxLayout = new QVBoxLayout();
- auto* ownKeyServiceTokenLayout = new QHBoxLayout();
- ownKeySelectBox = new QComboBox;
- getServiceTokenButton = new QPushButton(_("Get Service Token"));
- serviceTokenLabel = new QLabel(_("No Service Token Found"));
- serviceTokenLabel->setAlignment(Qt::AlignCenter);
-
- ownKeyBox->setLayout(ownKeyBoxLayout);
-
- mKeyList = new KeyList();
-
- // Fill the keyid hashmap
- keyIds.insert({QString(), "<none>"});
-
- auto private_keys = mKeyList->getAllPrivateKeys();
-
- for (const auto& keyid : *private_keys) {
- auto key = GpgKeyGetter::GetInstance().GetKey(keyid);
- if (!key.good()) continue;
- keyIds.insert({key.id(), key.uids()->front().uid()});
- }
- for (const auto& k : keyIds) {
- ownKeySelectBox->addItem(QString::fromStdString(k.second));
- keyIdsList.push_back(k.first);
- }
- connect(ownKeySelectBox, SIGNAL(currentIndexChanged(int)), this,
- SLOT(slotOwnKeyIdChanged()));
- connect(getServiceTokenButton, SIGNAL(clicked(bool)), this,
- SLOT(slotGetServiceToken()));
-
- ownKeyBoxLayout->addWidget(new QLabel(
- _("Key pair for synchronization and identity authentication")));
- ownKeyBoxLayout->addWidget(ownKeySelectBox);
- ownKeyBoxLayout->addLayout(ownKeyServiceTokenLayout);
- ownKeyServiceTokenLayout->addWidget(getServiceTokenButton);
- ownKeyServiceTokenLayout->addWidget(serviceTokenLabel);
- ownKeyServiceTokenLayout->stretch(0);
-#endif
-
- /*****************************************
- * Mainlayout
- *****************************************/
- auto* mainLayout = new QVBoxLayout;
-#ifdef SERVER_SUPPORT
- mainLayout->addWidget(serverBox);
-#endif
- mainLayout->addWidget(longerKeyExpirationDateBox);
- mainLayout->addWidget(saveCheckedKeysBox);
- mainLayout->addWidget(importConfirmationBox);
-#ifdef MULTI_LANG_SUPPORT
- mainLayout->addWidget(langBox);
-#endif
-#ifdef SERVER_SUPPORT
- mainLayout->addWidget(ownKeyBox);
-#endif
-
setSettings();
- mainLayout->addStretch(1);
- setLayout(mainLayout);
}
/**********************************
@@ -186,7 +78,8 @@ void GeneralTab::setSettings() {
auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
try {
bool save_key_checked = settings.lookup("general.save_key_checked");
- if (save_key_checked) saveCheckedKeysCheckBox->setCheckState(Qt::Checked);
+ if (save_key_checked)
+ ui->saveCheckedKeysCheckBox->setCheckState(Qt::Checked);
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("save_key_checked");
}
@@ -196,73 +89,45 @@ void GeneralTab::setSettings() {
settings.lookup("general.longer_expiration_date");
LOG(INFO) << "longer_expiration_date" << longer_expiration_date;
if (longer_expiration_date)
- longerKeyExpirationDateCheckBox->setCheckState(Qt::Checked);
+ ui->longerKeyExpirationDateCheckBox->setCheckState(Qt::Checked);
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("longer_expiration_date");
}
-#ifdef SERVER_SUPPORT
- auto serverList =
- settings.value("general/gpgfrontendServerList").toStringList();
- if (serverList.empty()) {
- serverList.append("service.gpgfrontend.pub");
- serverList.append("localhost");
- }
- for (const auto& s : serverList) serverSelectBox->addItem(s);
-
- qDebug() << "Current Gpgfrontend Server"
- << settings.value("general/currentGpgfrontendServer").toString();
- serverSelectBox->setCurrentText(
- settings
- .value("general/currentGpgfrontendServer", "service.gpgfrontend.pub")
- .toString());
-
- connect(serverSelectBox,
- QOverload<const QString&>::of(&QComboBox::currentTextChanged), this,
- [&](const QString& current) -> void {
- settings.setValue("general/currentGpgfrontendServer", current);
- });
-#endif
-
#ifdef MULTI_LANG_SUPPORT
try {
std::string lang_key = settings.lookup("general.lang");
QString lang_value = lang.value(lang_key.c_str());
LOG(INFO) << "lang settings current" << lang_value.toStdString();
if (!lang.empty()) {
- langSelectBox->setCurrentIndex(langSelectBox->findText(lang_value));
+ ui->langSelectBox->setCurrentIndex(
+ ui->langSelectBox->findText(lang_value));
} else {
- langSelectBox->setCurrentIndex(0);
+ ui->langSelectBox->setCurrentIndex(0);
}
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("lang");
}
#endif
-#ifdef SERVER_SUPPORT
- auto own_key_id = settings.value("general/ownKeyId").toString().toStdString();
- if (own_key_id.empty()) {
- ownKeySelectBox->setCurrentText("<none>");
- } else {
- const auto uid = keyIds.find(own_key_id)->second;
- ownKeySelectBox->setCurrentText(QString::fromStdString(uid));
- }
-
- serviceToken =
- settings.value("general/serviceToken").toString().toStdString();
- if (!serviceToken.empty()) {
- serviceTokenLabel->setText(QString::fromStdString(serviceToken));
- }
-#endif
-
try {
bool confirm_import_keys = settings.lookup("general.confirm_import_keys");
LOG(INFO) << "confirm_import_keys" << confirm_import_keys;
if (confirm_import_keys)
- importConfirmationCheckBox->setCheckState(Qt::Checked);
+ ui->importConfirmationCheckBox->setCheckState(Qt::Checked);
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("confirm_import_keys");
}
+
+ try {
+ bool non_ascii_when_export =
+ settings.lookup("general.non_ascii_when_export");
+ LOG(INFO) << "non_ascii_when_export" << non_ascii_when_export;
+ if (non_ascii_when_export)
+ ui->asciiModeCheckBox->setCheckState(Qt::Checked);
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error") << _("non_ascii_when_export");
+ }
}
/***********************************
@@ -281,54 +146,41 @@ void GeneralTab::applySettings() {
if (!general.exists("longer_expiration_date"))
general.add("longer_expiration_date", libconfig::Setting::TypeBoolean) =
- longerKeyExpirationDateCheckBox->isChecked();
+ ui->longerKeyExpirationDateCheckBox->isChecked();
else {
general["longer_expiration_date"] =
- longerKeyExpirationDateCheckBox->isChecked();
+ ui->longerKeyExpirationDateCheckBox->isChecked();
}
if (!general.exists("save_key_checked"))
general.add("save_key_checked", libconfig::Setting::TypeBoolean) =
- saveCheckedKeysCheckBox->isChecked();
+ ui->saveCheckedKeysCheckBox->isChecked();
else {
- general["save_key_checked"] = saveCheckedKeysCheckBox->isChecked();
+ general["save_key_checked"] = ui->saveCheckedKeysCheckBox->isChecked();
}
-#ifdef SERVER_SUPPORT
- qDebug() << "serverSelectBox currentText" << serverSelectBox->currentText();
- settings.setValue("general/currentGpgfrontendServer",
- serverSelectBox->currentText());
-
- auto* serverList = new QStringList();
- for (int i = 0; i < serverSelectBox->count(); i++)
- serverList->append(serverSelectBox->itemText(i));
- settings.setValue("general/gpgfrontendServerList", *serverList);
- delete serverList;
-#endif
+ if (!general.exists("non_ascii_when_export"))
+ general.add("non_ascii_when_export", libconfig::Setting::TypeBoolean) =
+ ui->asciiModeCheckBox->isChecked();
+ else {
+ general["non_ascii_when_export"] = ui->asciiModeCheckBox->isChecked();
+ }
#ifdef MULTI_LANG_SUPPORT
if (!general.exists("lang"))
general.add("lang", libconfig::Setting::TypeBoolean) =
- lang.key(langSelectBox->currentText()).toStdString();
+ lang.key(ui->langSelectBox->currentText()).toStdString();
else {
- general["lang"] = lang.key(langSelectBox->currentText()).toStdString();
+ general["lang"] = lang.key(ui->langSelectBox->currentText()).toStdString();
}
#endif
-#ifdef SERVER_SUPPORT
- settings.setValue(
- "general/ownKeyId",
- QString::fromStdString(keyIdsList[ownKeySelectBox->currentIndex()]));
-
- settings.setValue("general/serviceToken",
- QString::fromStdString(serviceToken));
-#endif
-
if (!general.exists("confirm_import_keys"))
general.add("confirm_import_keys", libconfig::Setting::TypeBoolean) =
- importConfirmationCheckBox->isChecked();
+ ui->importConfirmationCheckBox->isChecked();
else {
- general["confirm_import_keys"] = importConfirmationCheckBox->isChecked();
+ general["confirm_import_keys"] =
+ ui->importConfirmationCheckBox->isChecked();
}
}
@@ -336,136 +188,4 @@ void GeneralTab::applySettings() {
void GeneralTab::slotLanguageChanged() { emit signalRestartNeeded(true); }
#endif
-#ifdef SERVER_SUPPORT
-void GeneralTab::slotOwnKeyIdChanged() {
- // Set ownKeyId to currently selected
- this->serviceTokenLabel->setText(_("No Service Token Found"));
- serviceToken.clear();
-}
-#endif
-
-#ifdef SERVER_SUPPORT
-void GeneralTab::slotGetServiceToken() {
- auto utils = new ComUtils(this);
-
- QUrl reqUrl(utils->getUrl(ComUtils::GetServiceToken));
- QNetworkRequest request(reqUrl);
- request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
-
- const auto keyId = keyIdsList[ownKeySelectBox->currentIndex()];
-
- qDebug() << "KeyId" << keyIdsList[ownKeySelectBox->currentIndex()];
-
- if (keyId.isEmpty()) {
- QMessageBox::critical(
- this, _("Invalid Operation"),
- _("Own Key can not be None while getting service token."));
- return;
- }
-
- QStringList selectedKeyIds(keyIdsList[ownKeySelectBox->currentIndex()]);
-
- QByteArray keyDataBuf;
- mCtx->exportKeys(&selectedKeyIds, &keyDataBuf);
-
- GpgKey key = mCtx->getKeyRefById(keyId);
-
- if (!key.good) {
- QMessageBox::critical(this, _("Error"), _("Key Not Exists"));
- return;
- }
-
- qDebug() << "keyDataBuf" << keyDataBuf;
-
- /**
- * {
- * "publicKey" : ...
- * "sha": ...
- * "signedFpr": ...
- * "version": ...
- * }
- */
-
- QCryptographicHash shaGen(QCryptographicHash::Sha256);
- shaGen.addData(keyDataBuf);
-
- auto shaStr = shaGen.result().toHex();
-
- auto signFprStr = ComUtils::getSignStringBase64(mCtx, key.fpr, key);
-
- rapidjson::Value pubkey, ver, sha, signFpr;
-
- rapidjson::Document doc;
- doc.SetObject();
-
- pubkey.SetString(keyDataBuf.constData(), keyDataBuf.count());
-
- auto version = qApp->applicationVersion();
- ver.SetString(version.toUtf8().constData(),
- qApp->applicationVersion().count());
-
- sha.SetString(shaStr.constData(), shaStr.count());
- signFpr.SetString(signFprStr.constData(), signFprStr.count());
-
- rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();
-
- doc.AddMember("publicKey", pubkey, allocator);
- doc.AddMember("sha", sha, allocator);
- doc.AddMember("signedFpr", signFpr, allocator);
- doc.AddMember("version", ver, allocator);
-
- rapidjson::StringBuffer sb;
- rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(sb);
- doc.Accept(writer);
-
- QByteArray postData(sb.GetString());
-
- QNetworkReply* reply = utils->getNetworkManager().post(request, postData);
-
- // Show Waiting Dailog
- auto dialog = new WaitingDialog("Getting Token From Server", this);
- dialog->show();
-
- while (reply->isRunning()) {
- QApplication::processEvents();
- }
-
- dialog->close();
-
- if (utils->checkServerReply(reply->readAll().constData())) {
- /**
- * {
- * "serviceToken" : ...
- * "fpr": ...
- * }
- */
-
- if (!utils->checkDataValueStr("serviceToken") ||
- !utils->checkDataValueStr("fpr")) {
- QMessageBox::critical(this, _("Error"),
- _("The communication content with the server does "
- "not meet the requirements"));
- return;
- }
-
- QString serviceTokenTemp = utils->getDataValueStr("serviceToken");
- QString fpr = utils->getDataValueStr("fpr");
- auto key = mCtx->getKeyRefByFpr(fpr);
- if (utils->checkServiceTokenFormat(serviceTokenTemp) && key.good) {
- serviceToken = serviceTokenTemp;
- qDebug() << "Get Service Token" << serviceToken;
- // Auto update settings
- settings.setValue("general/serviceToken", serviceToken);
- serviceTokenLabel->setText(serviceToken);
- QMessageBox::information(this, _("Notice"),
- _("Succeed in getting service token"));
- } else {
- QMessageBox::critical(
- this, _("Error"),
- _("There is a problem with the communication with the server"));
- }
- }
-}
-#endif
-
} // namespace GpgFrontend::UI
diff --git a/src/ui/settings/SettingsGeneral.h b/src/ui/settings/SettingsGeneral.h
index bebe7609..a5e2b8d0 100644
--- a/src/ui/settings/SettingsGeneral.h
+++ b/src/ui/settings/SettingsGeneral.h
@@ -27,6 +27,8 @@
#include "ui/GpgFrontendUI.h"
+class Ui_GeneralSettings;
+
namespace GpgFrontend::UI {
class KeyList;
@@ -41,24 +43,12 @@ class GeneralTab : public QWidget {
void applySettings();
private:
- QCheckBox* saveCheckedKeysCheckBox;
- QCheckBox* importConfirmationCheckBox;
- QCheckBox* longerKeyExpirationDateCheckBox;
+ std::shared_ptr<Ui_GeneralSettings> ui;
#ifdef MULTI_LANG_SUPPORT
- QComboBox* langSelectBox;
QHash<QString, QString> lang;
#endif
-#ifdef SERVER_SUPPORT
- QComboBox* serverSelectBox;
- QComboBox* ownKeySelectBox;
- QPushButton* getServiceTokenButton;
- QLabel* serviceTokenLabel;
- std::string serviceToken;
- std::unordered_map<std::string, std::string> keyIds;
-#endif
-
std::vector<std::string> keyIdsList;
KeyList* mKeyList{};
@@ -70,13 +60,6 @@ class GeneralTab : public QWidget {
void slotLanguageChanged();
#endif
-
-#ifdef SERVER_SUPPORT
-
- void slotOwnKeyIdChanged();
-
-#endif
-
signals:
void signalRestartNeeded(bool needed);
diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp
index ca6dedc1..3e140bd4 100644
--- a/src/ui/widgets/FilePage.cpp
+++ b/src/ui/widgets/FilePage.cpp
@@ -156,48 +156,57 @@ void FilePage::slotGoPath() {
void FilePage::createPopupMenu() {
popUpMenu = new QMenu();
- openItemAct = new QAction(_("Open"), this);
- connect(openItemAct, &QAction::triggered, this, &FilePage::slotOpenItem);
- renameItemAct = new QAction(_("Rename"), this);
- connect(renameItemAct, &QAction::triggered, this, &FilePage::slotRenameItem);
- deleteItemAct = new QAction(_("Delete"), this);
- connect(deleteItemAct, &QAction::triggered, this, &FilePage::slotDeleteItem);
- encryptItemAct = new QAction(_("Encrypt Sign"), this);
- connect(encryptItemAct, &QAction::triggered, this,
+ ui->actionOpenFile->setText(_("Open"));
+ connect(ui->actionOpenFile, &QAction::triggered, this,
+ &FilePage::slotOpenItem);
+ ui->actionRenameFile->setText(_("Rename"));
+ connect(ui->actionRenameFile, &QAction::triggered, this,
+ &FilePage::slotRenameItem);
+ ui->actionDeleteFile->setText(_("Delete"));
+ connect(ui->actionDeleteFile, &QAction::triggered, this,
+ &FilePage::slotDeleteItem);
+
+ ui->actionEncrypt->setText(_("Encrypt"));
+ connect(ui->actionEncrypt, &QAction::triggered, this,
&FilePage::slotEncryptItem);
- decryptItemAct =
- new QAction(QString(_("Decrypt Verify")) + " " + _("(.gpg .asc)"), this);
- connect(decryptItemAct, &QAction::triggered, this,
+ ui->actionEncryptSign->setText(_("Encrypt Sign"));
+ connect(ui->actionEncryptSign, &QAction::triggered, this,
+ &FilePage::slotEncryptSignItem);
+ ui->actionDecrypt->setText(QString(_("Decrypt Verify")) + " " +
+ _("(.gpg .asc)"));
+ connect(ui->actionDecrypt, &QAction::triggered, this,
&FilePage::slotDecryptItem);
- signItemAct = new QAction(_("Sign"), this);
- connect(signItemAct, &QAction::triggered, this, &FilePage::slotSignItem);
- verifyItemAct =
- new QAction(QString(_("Verify")) + " " + _("(.sig .gpg .asc)"), this);
- connect(verifyItemAct, &QAction::triggered, this, &FilePage::slotVerifyItem);
-
- hashCalculateAct = new QAction(_("Calculate Hash"), this);
- connect(hashCalculateAct, &QAction::triggered, this,
+ ui->actionSign->setText(_("Sign"));
+ connect(ui->actionSign, &QAction::triggered, this, &FilePage::slotSignItem);
+ ui->actionVerify->setText(QString(_("Verify")) + " " + _("(.sig .gpg .asc)"));
+ connect(ui->actionVerify, &QAction::triggered, this,
+ &FilePage::slotVerifyItem);
+
+ ui->actionCalculateHash->setText(_("Calculate Hash"));
+ connect(ui->actionCalculateHash, &QAction::triggered, this,
&FilePage::slotCalculateHash);
- mkdirAct = new QAction(_("Make New Directory"), this);
- connect(mkdirAct, &QAction::triggered, this, &FilePage::slotMkdir);
+ ui->actionMakeDirectory->setText(_("Make New Directory"));
+ connect(ui->actionMakeDirectory, &QAction::triggered, this,
+ &FilePage::slotMkdir);
- createEmptyFileAct = new QAction(_("Create Empty File"), this);
- connect(createEmptyFileAct, &QAction::triggered, this,
+ ui->actionCreateEmptyFile->setText(_("Create Empty File"));
+ connect(ui->actionCreateEmptyFile, &QAction::triggered, this,
&FilePage::slotCreateEmptyFile);
- popUpMenu->addAction(openItemAct);
- popUpMenu->addAction(renameItemAct);
- popUpMenu->addAction(deleteItemAct);
+ popUpMenu->addAction(ui->actionOpenFile);
+ popUpMenu->addAction(ui->actionRenameFile);
+ popUpMenu->addAction(ui->actionDeleteFile);
popUpMenu->addSeparator();
- popUpMenu->addAction(encryptItemAct);
- popUpMenu->addAction(decryptItemAct);
- popUpMenu->addAction(signItemAct);
- popUpMenu->addAction(verifyItemAct);
+ popUpMenu->addAction(ui->actionEncrypt);
+ popUpMenu->addAction(ui->actionEncryptSign);
+ popUpMenu->addAction(ui->actionDecrypt);
+ popUpMenu->addAction(ui->actionSign);
+ popUpMenu->addAction(ui->actionVerify);
popUpMenu->addSeparator();
- popUpMenu->addAction(mkdirAct);
- popUpMenu->addAction(createEmptyFileAct);
- popUpMenu->addAction(hashCalculateAct);
+ popUpMenu->addAction(ui->actionMakeDirectory);
+ popUpMenu->addAction(ui->actionCreateEmptyFile);
+ popUpMenu->addAction(ui->actionCalculateHash);
optionPopUpMenu = new QMenu();
@@ -232,32 +241,37 @@ void FilePage::onCustomContextMenu(const QPoint& point) {
dirModel->fileInfo(index).absoluteFilePath().toStdString());
LOG(INFO) << "right click" << selectedPath;
if (index.isValid()) {
- openItemAct->setEnabled(true);
- renameItemAct->setEnabled(true);
- deleteItemAct->setEnabled(true);
+ ui->actionOpenFile->setEnabled(true);
+ ui->actionRenameFile->setEnabled(true);
+ ui->actionDeleteFile->setEnabled(true);
QFileInfo info(QString::fromStdString(selectedPath.string()));
- encryptItemAct->setEnabled(
- info.isFile() && (info.suffix() != "gpg" && info.suffix() != "sig"));
- encryptItemAct->setEnabled(
- info.isFile() && (info.suffix() != "gpg" && info.suffix() != "sig"));
- decryptItemAct->setEnabled(info.isFile() && info.suffix() == "gpg");
- signItemAct->setEnabled(info.isFile() &&
- (info.suffix() != "gpg" && info.suffix() != "sig"));
- verifyItemAct->setEnabled(
- info.isFile() && (info.suffix() == "sig" || info.suffix() == "gpg"));
- hashCalculateAct->setEnabled(info.isFile() && info.isReadable());
+ ui->actionEncrypt->setEnabled(info.isFile() && (info.suffix() != "gpg" &&
+ info.suffix() != "sig" &&
+ info.suffix() != "asc"));
+ ui->actionEncryptSign->setEnabled(
+ info.isFile() && (info.suffix() != "gpg" && info.suffix() != "sig" &&
+ info.suffix() != "asc"));
+ ui->actionDecrypt->setEnabled(
+ info.isFile() && (info.suffix() == "gpg" || info.suffix() == "asc"));
+ ui->actionSign->setEnabled(info.isFile() && (info.suffix() != "gpg" &&
+ info.suffix() != "sig" &&
+ info.suffix() != "asc"));
+ ui->actionVerify->setEnabled(info.isFile() && (info.suffix() == "sig" ||
+ info.suffix() == "gpg" ||
+ info.suffix() == "asc"));
+ ui->actionCalculateHash->setEnabled(info.isFile() && info.isReadable());
} else {
- openItemAct->setEnabled(false);
- renameItemAct->setEnabled(false);
- deleteItemAct->setEnabled(false);
-
- encryptItemAct->setEnabled(false);
- encryptItemAct->setEnabled(false);
- decryptItemAct->setEnabled(false);
- signItemAct->setEnabled(false);
- verifyItemAct->setEnabled(false);
- hashCalculateAct->setEnabled(false);
+ ui->actionOpenFile->setEnabled(false);
+ ui->actionRenameFile->setEnabled(false);
+ ui->actionDeleteFile->setEnabled(false);
+
+ ui->actionEncrypt->setEnabled(false);
+ ui->actionEncryptSign->setEnabled(false);
+ ui->actionDecrypt->setEnabled(false);
+ ui->actionSign->setEnabled(false);
+ ui->actionVerify->setEnabled(false);
+ ui->actionCalculateHash->setEnabled(false);
}
popUpMenu->exec(ui->fileTreeView->viewport()->mapToGlobal(point));
}
@@ -331,6 +345,11 @@ void FilePage::slotDeleteItem() {
void FilePage::slotEncryptItem() {
auto mainWindow = qobject_cast<MainWindow*>(firstParent);
+ if (mainWindow != nullptr) mainWindow->slotFileEncrypt();
+}
+
+void FilePage::slotEncryptSignItem() {
+ auto mainWindow = qobject_cast<MainWindow*>(firstParent);
if (mainWindow != nullptr) mainWindow->slotFileEncryptSign();
}
diff --git a/src/ui/widgets/FilePage.h b/src/ui/widgets/FilePage.h
index 03caf36b..1f2b51f8 100644
--- a/src/ui/widgets/FilePage.h
+++ b/src/ui/widgets/FilePage.h
@@ -61,6 +61,7 @@ class FilePage : public QWidget {
void slotRenameItem();
void slotDeleteItem();
void slotEncryptItem();
+ void slotEncryptSignItem();
void slotDecryptItem();
void slotSignItem();
void slotVerifyItem();
@@ -88,16 +89,6 @@ class FilePage : public QWidget {
QMenu* popUpMenu{};
QMenu* optionPopUpMenu{};
- QAction* encryptItemAct{};
- QAction* decryptItemAct{};
- QAction* signItemAct{};
- QAction* verifyItemAct{};
- QAction* hashCalculateAct{};
- QAction* mkdirAct{};
- QAction* openItemAct{};
- QAction* renameItemAct{};
- QAction* deleteItemAct{};
- QAction* createEmptyFileAct{};
QWidget* firstParent;
};
diff --git a/src/ui/widgets/InfoBoardWidget.cpp b/src/ui/widgets/InfoBoardWidget.cpp
index d46d5f92..7718cba3 100644
--- a/src/ui/widgets/InfoBoardWidget.cpp
+++ b/src/ui/widgets/InfoBoardWidget.cpp
@@ -35,7 +35,6 @@ InfoBoardWidget::InfoBoardWidget(QWidget* parent)
ui->setupUi(this);
ui->actionButtonLayout->addStretch();
- ui->actionLabel->setText(_("InfoBoard's Actions Menu"));
ui->copyButton->setText(_("Copy"));
ui->saveButton->setText(_("Save File"));
ui->clearButton->setText(_("Clear"));
@@ -163,7 +162,7 @@ void InfoBoardWidget::slotSave() {
auto file_path = QFileDialog::getSaveFileName(
this, _("Save Information Board's Content"), {}, tr("Text (*.txt)"));
LOG(INFO) << "file path" << file_path.toStdString();
- if(file_path.isEmpty()) return;
+ if (file_path.isEmpty()) return;
QFile file(file_path);
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp
index 3b13196f..fb715b2b 100644
--- a/src/ui/widgets/KeyList.cpp
+++ b/src/ui/widgets/KeyList.cpp
@@ -79,8 +79,7 @@ void KeyList::init() {
&SignalStation::signalRefreshStatusBar);
setAcceptDrops(true);
-
- ui->keyListOperationsLabel->setText(_("Key List Menu: "));
+
ui->refreshKeyListButton->setText(_("Refresh"));
ui->syncButton->setText(_("Sync Public Key"));
ui->syncButton->setToolTip(_("Sync public key with your default keyserver"));
diff --git a/ui/FilePage.ui b/ui/FilePage.ui
index 6d7f7d7a..cb4517b1 100644
--- a/ui/FilePage.ui
+++ b/ui/FilePage.ui
@@ -143,6 +143,61 @@
</layout>
</item>
</layout>
+ <action name="actionEncrypt">
+ <property name="text">
+ <string>Encrypt</string>
+ </property>
+ </action>
+ <action name="actionEncryptSign">
+ <property name="text">
+ <string>EncryptSign</string>
+ </property>
+ </action>
+ <action name="actionDecrypt">
+ <property name="text">
+ <string>Decrypt</string>
+ </property>
+ </action>
+ <action name="actionSign">
+ <property name="text">
+ <string>Sign</string>
+ </property>
+ </action>
+ <action name="actionVerify">
+ <property name="text">
+ <string>Verify</string>
+ </property>
+ </action>
+ <action name="actionOpenFile">
+ <property name="text">
+ <string>OpenFile</string>
+ </property>
+ </action>
+ <action name="actionRenameFile">
+ <property name="text">
+ <string>RenameFile</string>
+ </property>
+ </action>
+ <action name="actionDeleteFile">
+ <property name="text">
+ <string>DeleteFile</string>
+ </property>
+ </action>
+ <action name="actionCalculateHash">
+ <property name="text">
+ <string>CalculateHash</string>
+ </property>
+ </action>
+ <action name="actionMakeDirectory">
+ <property name="text">
+ <string>MakeDirectory</string>
+ </property>
+ </action>
+ <action name="actionCreateEmptyFile">
+ <property name="text">
+ <string>CreateEmptyFile</string>
+ </property>
+ </action>
</widget>
<resources>
<include location="../gpgfrontend.qrc"/>
diff --git a/ui/GeneralSettings.ui b/ui/GeneralSettings.ui
new file mode 100644
index 00000000..4bfb5f43
--- /dev/null
+++ b/ui/GeneralSettings.ui
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>GeneralSettings</class>
+ <widget class="QWidget" name="GeneralSettings">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>643</width>
+ <height>656</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="longerKeyExpirationDateBox">
+ <property name="title">
+ <string>Longer Key Expiration Date</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QCheckBox" name="longerKeyExpirationDateCheckBox">
+ <property name="text">
+ <string>Unlock key expiration date setting up to 30 years.</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="saveCheckedKeysBox">
+ <property name="title">
+ <string>Save Checked Keys</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QCheckBox" name="saveCheckedKeysCheckBox">
+ <property name="text">
+ <string>Save checked private keys on exit and restore them on next start.</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="importConfirmationBox">
+ <property name="title">
+ <string>Confirm drag'n'drop key import</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="0" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <item>
+ <widget class="QCheckBox" name="importConfirmationCheckBox">
+ <property name="text">
+ <string>Import files dropped on the Key List without confirmation.</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="asciiModeBox">
+ <property name="title">
+ <string>ASCII Mode</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_6">
+ <item row="0" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout_6">
+ <item>
+ <widget class="QCheckBox" name="asciiModeCheckBox">
+ <property name="text">
+ <string>ASCII encoding is not used when file encrypting and signing.</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="langBox">
+ <property name="title">
+ <string>Language</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_5">
+ <item row="0" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout_5">
+ <item>
+ <widget class="QComboBox" name="langSelectBox">
+ <property name="sizeAdjustPolicy">
+ <enum>QComboBox::AdjustToContents</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="langNoteLabel">
+ <property name="text">
+ <string>NOTE: GpgFrontend will restart automatically if you change the language!</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/ui/InfoBoard.ui b/ui/InfoBoard.ui
index 1aac29aa..1c87974b 100644
--- a/ui/InfoBoard.ui
+++ b/ui/InfoBoard.ui
@@ -32,6 +32,9 @@
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
+ <property name="leftMargin">
+ <number>6</number>
+ </property>
<item alignment="Qt::AlignLeft">
<widget class="QWidget" name="horizontalWidget" native="true">
<property name="sizePolicy">
@@ -59,16 +62,6 @@
<property name="bottomMargin">
<number>0</number>
</property>
- <item alignment="Qt::AlignLeft">
- <widget class="QLabel" name="actionLabel">
- <property name="text">
- <string>Actions</string>
- </property>
- <property name="scaledContents">
- <bool>false</bool>
- </property>
- </widget>
- </item>
<item alignment="Qt::AlignRight">
<widget class="QPushButton" name="copyButton">
<property name="text">
@@ -83,7 +76,7 @@
</property>
</widget>
</item>
- <item alignment="Qt::AlignRight|Qt::AlignBottom">
+ <item>
<widget class="QPushButton" name="clearButton">
<property name="text">
<string>Clear</string>
diff --git a/ui/KeyList.ui b/ui/KeyList.ui
index 99932453..9e41a0d1 100644
--- a/ui/KeyList.ui
+++ b/ui/KeyList.ui
@@ -18,9 +18,9 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="menuWidget" native="true">
- <layout class="QHBoxLayout" name="menu">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
- <number>0</number>
+ <number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
@@ -35,38 +35,35 @@
<number>0</number>
</property>
<item>
- <widget class="QLabel" name="keyListOperationsLabel">
- <property name="text">
- <string>Key List Menu: </string>
- </property>
- </widget>
- </item>
- <item alignment="Qt::AlignLeft">
- <widget class="QPushButton" name="refreshKeyListButton">
- <property name="text">
- <string>Refresh</string>
- </property>
- </widget>
- </item>
- <item alignment="Qt::AlignLeft">
- <widget class="QPushButton" name="syncButton">
- <property name="text">
- <string>Sync With Key Server</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="refreshKeyListButton">
+ <property name="text">
+ <string>Refresh</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="syncButton">
+ <property name="text">
+ <string>Sync With Key Server</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
</item>
</layout>
</widget>