aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-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
11 files changed, 319 insertions, 530 deletions
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"));