From 28f3cb3524670c43ed5102cff40fe26d279486d1 Mon Sep 17 00:00:00 2001
From: Odin Vex <44311901+OdinVex@users.noreply.github.com>
Date: Wed, 21 Dec 2022 23:31:08 -0500
Subject: [PATCH] Add initial signoff and gpg-signing support Added UI
checkboxes to graphically manage global config options regarding
automatically signing-off on commits and gpg-enabled signing
Signed-off-by: Odin Vex <44311901+OdinVex@users.noreply.github.com>
---
src/dialogs/SettingsDialog.cpp | 48 ++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/src/dialogs/SettingsDialog.cpp b/src/dialogs/SettingsDialog.cpp
index 6fe3eb8fc2..78840c9eaa 100644
--- a/src/dialogs/SettingsDialog.cpp
+++ b/src/dialogs/SettingsDialog.cpp
@@ -109,6 +109,18 @@ class GeneralPanel : public QWidget {
mStoreCredentials =
new QCheckBox(tr("Store credentials in secure storage"), this);
+ mAutoSignoffCommits =
+ new QCheckBox(tr("Automatically signoff on commits"), this);
+
+ mGpgSignCommits =
+ new QCheckBox(tr("Sign all commits"), this);
+
+ mGpgSignPushes =
+ new QCheckBox(tr("Sign all pushes"), this);
+
+ mGpgSignTags =
+ new QCheckBox(tr("Sign all tags"), this);
+
QLabel *privacy = new QLabel(tr("View privacy policy"));
connect(privacy, &QLabel::linkActivated,
[] { AboutDialog::openSharedInstance(AboutDialog::Privacy); });
@@ -125,6 +137,10 @@ class GeneralPanel : public QWidget {
form->addRow(QString(), mAutoPrune);
form->addRow(tr("Language:"), mNoTranslation);
form->addRow(tr("Credentials:"), mStoreCredentials);
+ form->addRow(tr("Auto Signoff:"), mAutoSignoffCommits);
+ form->addRow(tr("Sign Commits:"), mGpgSignCommits);
+ form->addRow(tr("Sign Pushes:"), mGpgSignPushes);
+ form->addRow(tr("Sign Tags:"), mGpgSignTags);
form->addRow(QString(), privacy);
#if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
@@ -184,6 +200,26 @@ class GeneralPanel : public QWidget {
delete CredentialHelper::instance();
});
+ connect(mAutoSignoffCommits, &QCheckBox::toggled, [](bool checked) {
+ git::Config config = git::Config::global();
+ config.setValue("format.signOff", checked);
+ });
+
+ connect(mGpgSignCommits, &QCheckBox::toggled, [](bool checked) {
+ git::Config config = git::Config::global();
+ config.setValue("commit.gpgSign", checked);
+ });
+
+ connect(mGpgSignPushes, &QCheckBox::toggled, [](bool checked) {
+ git::Config config = git::Config::global();
+ config.setValue("push.gpgSign", checked);
+ });
+
+ connect(mGpgSignTags, &QCheckBox::toggled, [](bool checked) {
+ git::Config config = git::Config::global();
+ config.setValue("tag.gpgSign", checked);
+ });
+
connect(mSingleInstance, &QCheckBox::toggled, [](bool checked) {
Settings::instance()->setValue(Setting::Id::AllowSingleInstanceOnly,
checked);
@@ -213,6 +249,14 @@ class GeneralPanel : public QWidget {
settings->value(Setting::Id::DontTranslate).toBool());
mStoreCredentials->setChecked(
settings->value(Setting::Id::StoreCredentials).toBool());
+ mAutoSignoffCommits->setChecked(
+ config.value("format.signOff"));
+ mGpgSignCommits->setChecked(
+ config.value("commit.gpgSign"));
+ mGpgSignPushes->setChecked(
+ config.value("push.gpgSign"));
+ mGpgSignTags->setChecked(
+ config.value("tag.gpgSign"));
mSingleInstance->setChecked(
settings->value(Setting::Id::AllowSingleInstanceOnly).toBool());
@@ -229,6 +273,10 @@ class GeneralPanel : public QWidget {
QCheckBox *mAutoPrune;
QCheckBox *mNoTranslation;
QCheckBox *mStoreCredentials;
+ QCheckBox *mAutoSignoffCommits;
+ QCheckBox *mGpgSignCommits;
+ QCheckBox *mGpgSignPushes;
+ QCheckBox *mGpgSignTags;
QCheckBox *mSingleInstance;
};