mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Add device ID and device fingerprint to settings page like in Riot. (#407)
This commit is contained in:
parent
6d1f2ea9b3
commit
c8a59f2d6e
4 changed files with 77 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <QComboBox>
|
||||
#include <QFrame>
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
#include <QSharedPointer>
|
||||
#include <QWidget>
|
||||
|
@ -151,6 +152,8 @@ private:
|
|||
Toggle *typingNotifications_;
|
||||
Toggle *readReceipts_;
|
||||
Toggle *desktopNotifications_;
|
||||
QLabel *deviceFingerprintValue_;
|
||||
QLabel *deviceIdValue_;
|
||||
|
||||
QComboBox *themeCombo_;
|
||||
QComboBox *scaleFactorCombo_;
|
||||
|
|
|
@ -263,3 +263,18 @@ utils::mxcToHttp(const QUrl &url, const QString &server, int port)
|
|||
.arg(QString::fromStdString(mxcParts.server))
|
||||
.arg(QString::fromStdString(mxcParts.media_id));
|
||||
}
|
||||
|
||||
QString
|
||||
utils::humanReadableFingerprint(const std::string &ed25519)
|
||||
{
|
||||
return humanReadableFingerprint(QString::fromStdString(ed25519));
|
||||
}
|
||||
QString
|
||||
utils::humanReadableFingerprint(const QString &ed25519)
|
||||
{
|
||||
QStringList fingerprintList;
|
||||
for (int i = 0; i < ed25519.length(); i = i + 4) {
|
||||
fingerprintList << ed25519.mid(i, 4);
|
||||
}
|
||||
return fingerprintList.join(" ");
|
||||
}
|
|
@ -185,4 +185,11 @@ scaleImageToPixmap(const QImage &img, int size);
|
|||
//! Convert a Content Matrix URI to an HTTP link.
|
||||
QString
|
||||
mxcToHttp(const QUrl &url, const QString &server, int port);
|
||||
}
|
||||
|
||||
//! Convert a ed25519 fingerprint into a human readable form
|
||||
QString
|
||||
humanReadableFingerprint(const std::string &ed25519);
|
||||
|
||||
QString
|
||||
humanReadableFingerprint(const QString &ed25519);
|
||||
}
|
Loading…
Reference in a new issue