Skip to content

Commit

Permalink
Add initial signoff and gpg-signing support
Browse files Browse the repository at this point in the history
Added UI checkboxes to graphically manage global config options regarding automatically signing-off on commits and gpg-enabled signing

Signed-off-by: Odin Vex <[email protected]>
  • Loading branch information
OdinVex committed Dec 22, 2022
1 parent 8569757 commit 021813c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
41 changes: 41 additions & 0 deletions src/dialogs/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ 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("<a href='view'>View privacy policy</a>"));
connect(privacy, &QLabel::linkActivated,
[] { AboutDialog::openSharedInstance(AboutDialog::Privacy); });
Expand All @@ -125,6 +134,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)
Expand Down Expand Up @@ -184,6 +197,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);
Expand Down Expand Up @@ -213,6 +246,10 @@ class GeneralPanel : public QWidget {
settings->value(Setting::Id::DontTranslate).toBool());
mStoreCredentials->setChecked(
settings->value(Setting::Id::StoreCredentials).toBool());
mAutoSignoffCommits->setChecked(config.value<bool>("format.signOff"));
mGpgSignCommits->setChecked(config.value<bool>("commit.gpgSign"));
mGpgSignPushes->setChecked(config.value<bool>("push.gpgSign"));
mGpgSignTags->setChecked(config.value<bool>("tag.gpgSign"));

mSingleInstance->setChecked(
settings->value(Setting::Id::AllowSingleInstanceOnly).toBool());
Expand All @@ -229,6 +266,10 @@ class GeneralPanel : public QWidget {
QCheckBox *mAutoPrune;
QCheckBox *mNoTranslation;
QCheckBox *mStoreCredentials;
QCheckBox *mAutoSignoffCommits;
QCheckBox *mGpgSignCommits;
QCheckBox *mGpgSignPushes;
QCheckBox *mGpgSignTags;
QCheckBox *mSingleInstance;
};

Expand Down
4 changes: 3 additions & 1 deletion test/Setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ private slots:

template <class T, typename TId> QStringList settingsKeys() {
QStringList settingsKeys;
foreach (const TId id, ids<TId>()) { settingsKeys.append(T::key(id)); }
foreach (const TId id, ids<TId>()) {
settingsKeys.append(T::key(id));
}
return settingsKeys;
}

Expand Down

0 comments on commit 021813c

Please sign in to comment.