aboutsummaryrefslogtreecommitdiff
path: root/src/settingsdialog.cpp
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2020-06-16 00:41:57 +0200
committerFelix (xq) Queißner <git@mq32.de>2020-06-16 00:41:57 +0200
commit33c91102a58e2fbcf9d7a66e33b41a65fa3f0e0c (patch)
treea724f0c3dcc48c8ce1f78c2665fe8ef170acb379 /src/settingsdialog.cpp
parent5bb3f3f92e62a0af02fe475943759b8c25cd4592 (diff)
downloadkristall-33c91102a58e2fbcf9d7a66e33b41a65fa3f0e0c.tar.gz
Adds improved client certificate management, adds server certificate management.
Diffstat (limited to 'src/settingsdialog.cpp')
-rw-r--r--src/settingsdialog.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp
index 3581f03..7ef05fb 100644
--- a/src/settingsdialog.cpp
+++ b/src/settingsdialog.cpp
@@ -7,6 +7,7 @@
#include <QInputDialog>
#include <QFileDialog>
#include <QMessageBox>
+#include <QDebug>
#include "kristall.hpp"
@@ -85,6 +86,22 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
this->on_presets_currentIndexChanged(-1);
}
+ this->ui->trust_level->clear();
+ this->ui->trust_level->addItem("Trust on first encounter", QVariant::fromValue<int>(SslTrust::TrustOnFirstUse));
+ this->ui->trust_level->addItem("Trust everything", QVariant::fromValue<int>(SslTrust::TrustEverything));
+ this->ui->trust_level->addItem("Manually verify fingerprints", QVariant::fromValue<int>(SslTrust::TrustNoOne));
+
+ this->ui->trusted_hosts->setModel(&this->current_trust.trusted_hosts);
+
+ this->ui->trusted_hosts->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
+ this->ui->trusted_hosts->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
+ this->ui->trusted_hosts->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
+
+ connect(
+ this->ui->trusted_hosts->selectionModel(),
+ &QItemSelectionModel::currentChanged,
+ this,
+ &SettingsDialog::on_trusted_server_selection);
}
SettingsDialog::~SettingsDialog()
@@ -201,6 +218,27 @@ void SettingsDialog::setUiTheme(const QString &theme)
}
+SslTrust SettingsDialog::sslTrust() const
+{
+ return this->current_trust;
+}
+
+void SettingsDialog::setSslTrust(const SslTrust &trust)
+{
+ this->current_trust = trust;
+
+ this->ui->trust_level->setCurrentIndex(
+ this->ui->trust_level->findData(QVariant::fromValue<int>(trust.trust_level))
+ );
+
+ if(trust.enable_ca)
+ this->ui->trust_enable_ca->setChecked(true);
+ else
+ this->ui->trust_disable__ca->setChecked(true);
+
+ this->ui->trusted_hosts->resizeColumnsToContents();
+}
+
void SettingsDialog::reloadStylePreview()
{
auto const document = R"gemini(# H1 Header
@@ -295,6 +333,15 @@ void SettingsDialog::updateColor(QColor &input)
}
}
+void SettingsDialog::on_trusted_server_selection(const QModelIndex &current, const QModelIndex &previous)
+{
+ if(auto host = this->current_trust.trusted_hosts.get(current); host) {
+ this->ui->trust_revoke_selected->setEnabled(true);
+ } else {
+ this->ui->trust_revoke_selected->setEnabled(false);
+ }
+}
+
void SettingsDialog::on_std_change_color_clicked()
{
updateColor(current_style.standard_color);
@@ -531,3 +578,23 @@ void SettingsDialog::on_preset_export_clicked()
this->predefined_styles.value(name).save(export_settings);
export_settings.sync();
}
+
+void SettingsDialog::on_trust_enable_ca_clicked()
+{
+ this->current_trust.enable_ca = true;
+}
+
+void SettingsDialog::on_trust_disable__ca_clicked()
+{
+ this->current_trust.enable_ca = false;
+}
+
+void SettingsDialog::on_trust_level_currentIndexChanged(int index)
+{
+ this->current_trust.trust_level = SslTrust::TrustLevel(this->ui->trust_level->itemData(index).toInt());
+}
+
+void SettingsDialog::on_trust_revoke_selected_clicked()
+{
+ this->current_trust.trusted_hosts.remove(this->ui->trusted_hosts->currentIndex());
+}