summary refs log tree commit diff
path: root/src/UserSettingsPage.cpp
diff options
context:
space:
mode:
authorRudi Floren <rudi.floren@gmail.com>2018-08-21 08:22:51 +0200
committermujx <mujx@users.noreply.github.com>2018-08-21 06:22:51 +0000
commitc8a59f2d6ec401bf758db1d62210a33aeea9764b (patch)
tree7d59fcefe549d75612a65fad41e20c3aa7e30f25 /src/UserSettingsPage.cpp
parentRemove pixel ratio from image scaling (diff)
downloadnheko-c8a59f2d6ec401bf758db1d62210a33aeea9764b.tar.xz
Add device ID and device fingerprint to settings page like in Riot. (#407)
Diffstat (limited to 'src/UserSettingsPage.cpp')
-rw-r--r--src/UserSettingsPage.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp
index b41de3a9..3b14088e 100644
--- a/src/UserSettingsPage.cpp
+++ b/src/UserSettingsPage.cpp
@@ -24,6 +24,8 @@
 #include <QSettings>
 
 #include "Config.h"
+#include "MatrixClient.h"
+#include "Olm.h"
 #include "UserSettingsPage.h"
 #include "Utils.h"
 #include "ui/FlatButton.h"
@@ -229,7 +231,46 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
         themeOptionLayout_->addWidget(themeLabel_);
         themeOptionLayout_->addWidget(themeCombo_, 0, Qt::AlignBottom | Qt::AlignRight);
 
+        auto encryptionLayout_ = new QVBoxLayout;
+        encryptionLayout_->setContentsMargins(0, OptionMargin, 0, OptionMargin);
+
+        QFont monospaceFont = QFont(font);
+        monospaceFont.setFamily("Courier New");
+        monospaceFont.setStyleHint(QFont::Courier);
+        monospaceFont.setPointSizeF(monospaceFont.pointSizeF() * 0.9);
+
+        auto deviceIdWidget = new QHBoxLayout;
+        deviceIdWidget->setContentsMargins(0, OptionMargin, 0, OptionMargin);
+
+        auto deviceIdLabel = new QLabel(tr("Device ID"), this);
+        deviceIdLabel->setFont(font);
+        deviceIdValue_ = new QLabel();
+        deviceIdValue_->setTextInteractionFlags(Qt::TextSelectableByMouse);
+        deviceIdValue_->setFont(monospaceFont);
+        deviceIdWidget->addWidget(deviceIdLabel, 1);
+        deviceIdWidget->addWidget(deviceIdValue_);
+
+        auto deviceFingerprintWidget = new QHBoxLayout;
+        deviceFingerprintWidget->setContentsMargins(0, OptionMargin, 0, OptionMargin);
+
+        auto deviceFingerprintLabel = new QLabel(tr("Device Fingerprint"), this);
+        deviceFingerprintLabel->setFont(font);
+        deviceFingerprintValue_ = new QLabel();
+        deviceFingerprintValue_->setTextInteractionFlags(Qt::TextSelectableByMouse);
+        deviceFingerprintValue_->setFont(monospaceFont);
+        deviceFingerprintWidget->addWidget(deviceFingerprintLabel, 1);
+        deviceFingerprintWidget->addWidget(deviceFingerprintValue_);
+
+        encryptionLayout_->addLayout(deviceIdWidget);
+        encryptionLayout_->addLayout(deviceFingerprintWidget);
+
         font.setWeight(65);
+
+        auto encryptionLabel_ = new QLabel(tr("ENCRYPTION"), this);
+        encryptionLabel_->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
+        encryptionLabel_->setFont(font);
+        // encryptionLabel_->setContentsMargins(0, 50, 0, 0);
+
         auto general_ = new QLabel(tr("GENERAL"), this);
         general_->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
         general_->setFont(font);
@@ -263,6 +304,12 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
 
         mainLayout_->addLayout(themeOptionLayout_);
         mainLayout_->addWidget(new HorizontalLine(this));
+
+        mainLayout_->addSpacing(50);
+
+        mainLayout_->addWidget(encryptionLabel_, 1, Qt::AlignLeft | Qt::AlignBottom);
+        mainLayout_->addWidget(new HorizontalLine(this));
+        mainLayout_->addLayout(encryptionLayout_);
         mainLayout_->addStretch(1);
 
         auto scrollArea_ = new QScrollArea(this);
@@ -343,6 +390,10 @@ UserSettingsPage::showEvent(QShowEvent *)
         typingNotifications_->setState(!settings_->isTypingNotificationsEnabled());
         readReceipts_->setState(!settings_->isReadReceiptsEnabled());
         desktopNotifications_->setState(!settings_->hasDesktopNotifications());
+        deviceIdValue_->setText(QString::fromStdString(http::client()->device_id()));
+
+        deviceFingerprintValue_->setText(
+          utils::humanReadableFingerprint(olm::client()->identity_keys().ed25519));
 }
 
 void