Merge branch 'privacy_screen' into 'master'

Chat Privacy screen

See merge request nheko-reborn/nheko!6
This commit is contained in:
Nicolas Werner 2021-02-02 14:10:34 -05:00
commit f73418f368
14 changed files with 306 additions and 26 deletions

View file

@ -14,4 +14,17 @@ do
clang-format -i "$f" clang-format -i "$f"
done; done;
QMLFORMAT_PATH=$(command -v qmlformat || true)
if [ -n "$QMLFORMAT_PATH" ]; then
QML_FILES=$(find resources -type f -iname "*.qml")
for f in $QML_FILES
do
$QMLFORMAT_PATH -i "$f"
done;
else
echo "qmlformat not found; skipping qml formatting"
fi
git diff --exit-code git diff --exit-code

View file

@ -0,0 +1,151 @@
import QtGraphicalEffects 1.0
import QtQuick 2.12
import im.nheko 1.0
Item {
id: privacyScreen
property var timelineRoot
property var imageSource: ""
property int screenTimeout
anchors.fill: parent
Connections {
target: TimelineManager
onFocusChanged: {
if (TimelineManager.isWindowFocused) {
screenSaverTimer.stop();
screenSaver.state = "Invisible";
} else {
if (timelineRoot.visible)
screenSaverTimer.start();
}
}
}
Timer {
id: screenSaverTimer
interval: screenTimeout * 1000
running: true
onTriggered: {
if (MainWindow.visible)
timelineRoot.grabToImage(function(result) {
screenSaver.state = "Visible";
imageSource = result.url;
}, Qt.size(width, height));
}
}
Rectangle {
id: screenSaver
state: "Invisible"
anchors.fill: parent
visible: false
color: "transparent"
states: [
State {
name: "Visible"
PropertyChanges {
target: screenSaver
visible: true
}
PropertyChanges {
target: screenSaver
opacity: 1
}
},
State {
name: "Invisible"
PropertyChanges {
target: screenSaver
opacity: 0
}
PropertyChanges {
target: screenSaver
visible: false
}
}
]
transitions: [
Transition {
from: "Visible"
to: "Invisible"
SequentialAnimation {
NumberAnimation {
target: screenSaver
property: "opacity"
duration: 250
easing.type: Easing.InQuad
}
NumberAnimation {
target: screenSaver
property: "visible"
duration: 0
}
}
},
Transition {
from: "Invisible"
to: "Visible"
SequentialAnimation {
NumberAnimation {
target: screenSaver
property: "visible"
duration: 0
}
NumberAnimation {
target: screenSaver
property: "opacity"
duration: 500
easing.type: Easing.InQuad
}
}
}
]
Image {
id: image
cache: false
anchors.fill: parent
source: imageSource
}
ShaderEffectSource {
id: effectSource
sourceItem: image
anchors.fill: image
sourceRect: Qt.rect(0, 0, width, height)
}
FastBlur {
id: blur
anchors.fill: effectSource
source: effectSource
radius: 50
}
}
}

View file

@ -28,7 +28,7 @@ Item {
if (mouse.button === Qt.RightButton) if (mouse.button === Qt.RightButton)
messageContextMenu.show(model.id, model.type, model.isEncrypted, row); messageContextMenu.show(model.id, model.type, model.isEncrypted, row);
else else
event.accepted = false; mouse.accepted = false;
} }
onPressAndHold: { onPressAndHold: {
messageContextMenu.show(model.id, model.type, model.isEncrypted, row, mapToItem(timelineRoot, mouse.x, mouse.y)); messageContextMenu.show(model.id, model.type, model.isEncrypted, row, mapToItem(timelineRoot, mouse.x, mouse.y));

View file

@ -194,6 +194,8 @@ Page {
} }
ColumnLayout { ColumnLayout {
id: timelineLayout
visible: TimelineManager.timeline != null visible: TimelineManager.timeline != null
anchors.fill: parent anchors.fill: parent
spacing: 0 spacing: 0
@ -281,6 +283,13 @@ Page {
roomid: TimelineManager.timeline ? TimelineManager.timeline.roomId() : "" roomid: TimelineManager.timeline ? TimelineManager.timeline.roomId() : ""
} }
} }
PrivacyScreen {
visible: Settings.privacyScreen
screenTimeout: Settings.privacyScreenTimeout
timelineRoot: timelineRoot
}
} }
systemInactive: SystemPalette { systemInactive: SystemPalette {

View file

@ -53,10 +53,9 @@ ApplicationWindow {
font.bold: true font.bold: true
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
selectByMouse: true selectByMouse: true
onAccepted: { onAccepted: {
profile.changeUsername(displayUsername.text) profile.changeUsername(displayUsername.text);
displayUsername.isUsernameEditingAllowed = false displayUsername.isUsernameEditingAllowed = false;
} }
ImageButton { ImageButton {
@ -65,18 +64,18 @@ ApplicationWindow {
anchors.left: displayUsername.right anchors.left: displayUsername.right
anchors.verticalCenter: displayUsername.verticalCenter anchors.verticalCenter: displayUsername.verticalCenter
image: displayUsername.isUsernameEditingAllowed ? ":/icons/icons/ui/checkmark.png" : ":/icons/icons/ui/edit.png" image: displayUsername.isUsernameEditingAllowed ? ":/icons/icons/ui/checkmark.png" : ":/icons/icons/ui/edit.png"
onClicked: { onClicked: {
if (displayUsername.isUsernameEditingAllowed) { if (displayUsername.isUsernameEditingAllowed) {
profile.changeUsername(displayUsername.text) profile.changeUsername(displayUsername.text);
displayUsername.isUsernameEditingAllowed = false displayUsername.isUsernameEditingAllowed = false;
} else { } else {
displayUsername.isUsernameEditingAllowed = true displayUsername.isUsernameEditingAllowed = true;
displayUsername.focus = true displayUsername.focus = true;
displayUsername.selectAll() displayUsername.selectAll();
} }
} }
} }
} }
MatrixText { MatrixText {

View file

@ -131,6 +131,7 @@
<file>qml/MessageInput.qml</file> <file>qml/MessageInput.qml</file>
<file>qml/MessageView.qml</file> <file>qml/MessageView.qml</file>
<file>qml/NhekoBusyIndicator.qml</file> <file>qml/NhekoBusyIndicator.qml</file>
<file>qml/PrivacyScreen.qml</file>
<file>qml/Reactions.qml</file> <file>qml/Reactions.qml</file>
<file>qml/ReplyPopup.qml</file> <file>qml/ReplyPopup.qml</file>
<file>qml/ScrollHelper.qml</file> <file>qml/ScrollHelper.qml</file>

View file

@ -333,6 +333,8 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
&ChatPage::initializeMentions, &ChatPage::initializeMentions,
user_mentions_popup_, user_mentions_popup_,
&popups::UserMentions::initializeMentions); &popups::UserMentions::initializeMentions);
connect(
this, &ChatPage::chatFocusChanged, view_manager_, &TimelineViewManager::chatFocusChanged);
connect(this, &ChatPage::syncUI, this, [this](const mtx::responses::Rooms &rooms) { connect(this, &ChatPage::syncUI, this, [this](const mtx::responses::Rooms &rooms) {
try { try {
room_list_->cleanupInvites(cache::invites()); room_list_->cleanupInvites(cache::invites());

View file

@ -127,7 +127,6 @@ public slots:
void receivedSessionKey(const std::string &room_id, const std::string &session_id); void receivedSessionKey(const std::string &room_id, const std::string &session_id);
void decryptDownloadedSecrets(mtx::secret_storage::AesHmacSha2KeyDescription keyDesc, void decryptDownloadedSecrets(mtx::secret_storage::AesHmacSha2KeyDescription keyDesc,
const SecretsToDecrypt &secrets); const SecretsToDecrypt &secrets);
signals: signals:
void connectionLost(); void connectionLost();
void connectionRestored(); void connectionRestored();
@ -176,6 +175,7 @@ signals:
void retrievedPresence(const QString &statusMsg, mtx::presence::PresenceState state); void retrievedPresence(const QString &statusMsg, mtx::presence::PresenceState state);
void themeChanged(); void themeChanged();
void decryptSidebarChanged(); void decryptSidebarChanged();
void chatFocusChanged(const bool focused);
//! Signals for device verificaiton //! Signals for device verificaiton
void receivedDeviceVerificationAccept( void receivedDeviceVerificationAccept(

View file

@ -59,6 +59,8 @@ MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
, userSettings_{UserSettings::instance()} , userSettings_{UserSettings::instance()}
{ {
instance_ = this;
setWindowTitle(0); setWindowTitle(0);
setObjectName("MainWindow"); setObjectName("MainWindow");
@ -130,6 +132,9 @@ MainWindow::MainWindow(QWidget *parent)
SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
connect(chat_page_, SIGNAL(contentLoaded()), this, SLOT(removeOverlayProgressBar())); connect(chat_page_, SIGNAL(contentLoaded()), this, SLOT(removeOverlayProgressBar()));
connect(this, &MainWindow::focusChanged, chat_page_, &ChatPage::chatFocusChanged);
connect( connect(
chat_page_, &ChatPage::showUserSettingsPage, this, &MainWindow::showUserSettingsPage); chat_page_, &ChatPage::showUserSettingsPage, this, &MainWindow::showUserSettingsPage);
@ -204,6 +209,19 @@ MainWindow::resizeEvent(QResizeEvent *event)
QMainWindow::resizeEvent(event); QMainWindow::resizeEvent(event);
} }
bool
MainWindow::event(QEvent *event)
{
auto type = event->type();
if (type == QEvent::WindowActivate) {
emit focusChanged(true);
} else if (type == QEvent::WindowDeactivate) {
emit focusChanged(false);
}
return QMainWindow::event(event);
}
void void
MainWindow::adjustSideBars() MainWindow::adjustSideBars()
{ {
@ -296,8 +314,6 @@ MainWindow::showChatPage()
&Cache::secretChanged, &Cache::secretChanged,
userSettingsPage_, userSettingsPage_,
&UserSettingsPage::updateSecretStatus); &UserSettingsPage::updateSecretStatus);
instance_ = this;
} }
void void

View file

@ -93,6 +93,7 @@ protected:
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
void resizeEvent(QResizeEvent *event) override; void resizeEvent(QResizeEvent *event) override;
void showEvent(QShowEvent *event) override; void showEvent(QShowEvent *event) override;
bool event(QEvent *event) override;
private slots: private slots:
//! Show or hide the sidebars based on window's size. //! Show or hide the sidebars based on window's size.
@ -120,6 +121,9 @@ private slots:
virtual void setWindowTitle(int notificationCount); virtual void setWindowTitle(int notificationCount);
signals:
void focusChanged(const bool focused);
private: private:
bool loadJdenticonPlugin(); bool loadJdenticonPlugin();

View file

@ -88,14 +88,16 @@ UserSettings::load(std::optional<QString> profile)
settings.value("user/timeline/message_hover_highlight", false).toBool(); settings.value("user/timeline/message_hover_highlight", false).toBool();
enlargeEmojiOnlyMessages_ = enlargeEmojiOnlyMessages_ =
settings.value("user/timeline/enlarge_emoji_only_msg", false).toBool(); settings.value("user/timeline/enlarge_emoji_only_msg", false).toBool();
markdown_ = settings.value("user/markdown_enabled", true).toBool(); markdown_ = settings.value("user/markdown_enabled", true).toBool();
typingNotifications_ = settings.value("user/typing_notifications", true).toBool(); typingNotifications_ = settings.value("user/typing_notifications", true).toBool();
sortByImportance_ = settings.value("user/sort_by_unread", true).toBool(); sortByImportance_ = settings.value("user/sort_by_unread", true).toBool();
readReceipts_ = settings.value("user/read_receipts", true).toBool(); readReceipts_ = settings.value("user/read_receipts", true).toBool();
theme_ = settings.value("user/theme", defaultTheme_).toString(); theme_ = settings.value("user/theme", defaultTheme_).toString();
font_ = settings.value("user/font_family", "default").toString(); font_ = settings.value("user/font_family", "default").toString();
avatarCircles_ = settings.value("user/avatar_circles", true).toBool(); avatarCircles_ = settings.value("user/avatar_circles", true).toBool();
decryptSidebar_ = settings.value("user/decrypt_sidebar", true).toBool(); decryptSidebar_ = settings.value("user/decrypt_sidebar", true).toBool();
privacyScreen_ = settings.value("user/privacy_screen", false).toBool();
privacyScreenTimeout_ = settings.value("user/privacy_screen_timeout", 0).toInt();
shareKeysWithTrustedUsers_ = shareKeysWithTrustedUsers_ =
settings.value("user/share_keys_with_trusted_users", true).toBool(); settings.value("user/share_keys_with_trusted_users", true).toBool();
mobileMode_ = settings.value("user/mobile_mode", false).toBool(); mobileMode_ = settings.value("user/mobile_mode", false).toBool();
@ -292,6 +294,28 @@ UserSettings::setDecryptSidebar(bool state)
save(); save();
} }
void
UserSettings::setPrivacyScreen(bool state)
{
if (state == privacyScreen_) {
return;
}
privacyScreen_ = state;
emit privacyScreenChanged(state);
save();
}
void
UserSettings::setPrivacyScreenTimeout(int state)
{
if (state == privacyScreenTimeout_) {
return;
}
privacyScreenTimeout_ = state;
emit privacyScreenTimeoutChanged(state);
save();
}
void void
UserSettings::setFontSize(double size) UserSettings::setFontSize(double size)
{ {
@ -539,6 +563,8 @@ UserSettings::save()
settings.setValue("avatar_circles", avatarCircles_); settings.setValue("avatar_circles", avatarCircles_);
settings.setValue("decrypt_sidebar", decryptSidebar_); settings.setValue("decrypt_sidebar", decryptSidebar_);
settings.setValue("privacy_screen", privacyScreen_);
settings.setValue("privacy_screen_timeout", privacyScreenTimeout_);
settings.setValue("share_keys_with_trusted_users", shareKeysWithTrustedUsers_); settings.setValue("share_keys_with_trusted_users", shareKeysWithTrustedUsers_);
settings.setValue("mobile_mode", mobileMode_); settings.setValue("mobile_mode", mobileMode_);
settings.setValue("font_size", baseFontSize_); settings.setValue("font_size", baseFontSize_);
@ -628,6 +654,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
startInTrayToggle_ = new Toggle{this}; startInTrayToggle_ = new Toggle{this};
avatarCircles_ = new Toggle{this}; avatarCircles_ = new Toggle{this};
decryptSidebar_ = new Toggle(this); decryptSidebar_ = new Toggle(this);
privacyScreen_ = new Toggle{this};
shareKeysWithTrustedUsers_ = new Toggle(this); shareKeysWithTrustedUsers_ = new Toggle(this);
groupViewToggle_ = new Toggle{this}; groupViewToggle_ = new Toggle{this};
timelineButtonsToggle_ = new Toggle{this}; timelineButtonsToggle_ = new Toggle{this};
@ -651,11 +678,13 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
cameraResolutionCombo_ = new QComboBox{this}; cameraResolutionCombo_ = new QComboBox{this};
cameraFrameRateCombo_ = new QComboBox{this}; cameraFrameRateCombo_ = new QComboBox{this};
timelineMaxWidthSpin_ = new QSpinBox{this}; timelineMaxWidthSpin_ = new QSpinBox{this};
privacyScreenTimeout_ = new QSpinBox{this};
trayToggle_->setChecked(settings_->tray()); trayToggle_->setChecked(settings_->tray());
startInTrayToggle_->setChecked(settings_->startInTray()); startInTrayToggle_->setChecked(settings_->startInTray());
avatarCircles_->setChecked(settings_->avatarCircles()); avatarCircles_->setChecked(settings_->avatarCircles());
decryptSidebar_->setChecked(settings_->decryptSidebar()); decryptSidebar_->setChecked(settings_->decryptSidebar());
privacyScreen_->setChecked(settings_->privacyScreen());
shareKeysWithTrustedUsers_->setChecked(settings_->shareKeysWithTrustedUsers()); shareKeysWithTrustedUsers_->setChecked(settings_->shareKeysWithTrustedUsers());
groupViewToggle_->setChecked(settings_->groupView()); groupViewToggle_->setChecked(settings_->groupView());
timelineButtonsToggle_->setChecked(settings_->buttonsInTimeline()); timelineButtonsToggle_->setChecked(settings_->buttonsInTimeline());
@ -675,6 +704,10 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
startInTrayToggle_->setDisabled(true); startInTrayToggle_->setDisabled(true);
} }
if (!settings_->privacyScreen()) {
privacyScreenTimeout_->setDisabled(true);
}
avatarCircles_->setFixedSize(64, 48); avatarCircles_->setFixedSize(64, 48);
auto uiLabel_ = new QLabel{tr("INTERFACE"), this}; auto uiLabel_ = new QLabel{tr("INTERFACE"), this};
@ -715,6 +748,10 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
timelineMaxWidthSpin_->setMaximum(100'000'000); timelineMaxWidthSpin_->setMaximum(100'000'000);
timelineMaxWidthSpin_->setSingleStep(10); timelineMaxWidthSpin_->setSingleStep(10);
privacyScreenTimeout_->setMinimum(0);
privacyScreenTimeout_->setMaximum(3600);
privacyScreenTimeout_->setSingleStep(10);
auto callsLabel = new QLabel{tr("CALLS"), this}; auto callsLabel = new QLabel{tr("CALLS"), this};
callsLabel->setFixedHeight(callsLabel->minimumHeight() + LayoutTopMargin); callsLabel->setFixedHeight(callsLabel->minimumHeight() + LayoutTopMargin);
callsLabel->setAlignment(Qt::AlignBottom); callsLabel->setAlignment(Qt::AlignBottom);
@ -808,6 +845,15 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
decryptSidebar_, decryptSidebar_,
tr("Decrypt the messages shown in the sidebar.\nOnly affects messages in " tr("Decrypt the messages shown in the sidebar.\nOnly affects messages in "
"encrypted chats.")); "encrypted chats."));
boxWrap(tr("Privacy Screen"),
privacyScreen_,
tr("When the window loses focus, the timeline will\nbe blurred."));
boxWrap(
tr("Privacy screen timeout (in seconds [0 - 3600])"),
privacyScreenTimeout_,
tr("Set timeout (in seconds) for how long after window loses\nfocus before the screen"
" will be blurred.\nSet to 0 to blur immediately after focus loss. Max value of 1 "
"hour (3600 seconds)"));
boxWrap(tr("Show buttons in timeline"), boxWrap(tr("Show buttons in timeline"),
timelineButtonsToggle_, timelineButtonsToggle_,
tr("Show buttons to quickly reply, react or access additional options next to each " tr("Show buttons to quickly reply, react or access additional options next to each "
@ -1066,7 +1112,15 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
connect(decryptSidebar_, &Toggle::toggled, this, [this](bool enabled) { connect(decryptSidebar_, &Toggle::toggled, this, [this](bool enabled) {
settings_->setDecryptSidebar(enabled); settings_->setDecryptSidebar(enabled);
emit decryptSidebarChanged(); });
connect(privacyScreen_, &Toggle::toggled, this, [this](bool enabled) {
settings_->setPrivacyScreen(enabled);
if (enabled) {
privacyScreenTimeout_->setEnabled(true);
} else {
privacyScreenTimeout_->setDisabled(true);
}
}); });
connect(shareKeysWithTrustedUsers_, &Toggle::toggled, this, [this](bool enabled) { connect(shareKeysWithTrustedUsers_, &Toggle::toggled, this, [this](bool enabled) {
@ -1122,6 +1176,11 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
this, this,
[this](int newValue) { settings_->setTimelineMaxWidth(newValue); }); [this](int newValue) { settings_->setTimelineMaxWidth(newValue); });
connect(privacyScreenTimeout_,
qOverload<int>(&QSpinBox::valueChanged),
this,
[this](int newValue) { settings_->setPrivacyScreenTimeout(newValue); });
connect( connect(
sessionKeysImportBtn, &QPushButton::clicked, this, &UserSettingsPage::importSessionKeys); sessionKeysImportBtn, &QPushButton::clicked, this, &UserSettingsPage::importSessionKeys);
@ -1155,6 +1214,7 @@ UserSettingsPage::showEvent(QShowEvent *)
startInTrayToggle_->setState(settings_->startInTray()); startInTrayToggle_->setState(settings_->startInTray());
groupViewToggle_->setState(settings_->groupView()); groupViewToggle_->setState(settings_->groupView());
decryptSidebar_->setState(settings_->decryptSidebar()); decryptSidebar_->setState(settings_->decryptSidebar());
privacyScreen_->setState(settings_->privacyScreen());
shareKeysWithTrustedUsers_->setState(settings_->shareKeysWithTrustedUsers()); shareKeysWithTrustedUsers_->setState(settings_->shareKeysWithTrustedUsers());
avatarCircles_->setState(settings_->avatarCircles()); avatarCircles_->setState(settings_->avatarCircles());
typingNotifications_->setState(settings_->typingNotifications()); typingNotifications_->setState(settings_->typingNotifications());
@ -1169,6 +1229,7 @@ UserSettingsPage::showEvent(QShowEvent *)
enlargeEmojiOnlyMessages_->setState(settings_->enlargeEmojiOnlyMessages()); enlargeEmojiOnlyMessages_->setState(settings_->enlargeEmojiOnlyMessages());
deviceIdValue_->setText(QString::fromStdString(http::client()->device_id())); deviceIdValue_->setText(QString::fromStdString(http::client()->device_id()));
timelineMaxWidthSpin_->setValue(settings_->timelineMaxWidth()); timelineMaxWidthSpin_->setValue(settings_->timelineMaxWidth());
privacyScreenTimeout_->setValue(settings_->privacyScreenTimeout());
WebRTCSession::instance().refreshDevices(); WebRTCSession::instance().refreshDevices();
auto mics = auto mics =

View file

@ -67,6 +67,10 @@ class UserSettings : public QObject
bool avatarCircles READ avatarCircles WRITE setAvatarCircles NOTIFY avatarCirclesChanged) bool avatarCircles READ avatarCircles WRITE setAvatarCircles NOTIFY avatarCirclesChanged)
Q_PROPERTY(bool decryptSidebar READ decryptSidebar WRITE setDecryptSidebar NOTIFY Q_PROPERTY(bool decryptSidebar READ decryptSidebar WRITE setDecryptSidebar NOTIFY
decryptSidebarChanged) decryptSidebarChanged)
Q_PROPERTY(
bool privacyScreen READ privacyScreen WRITE setPrivacyScreen NOTIFY privacyScreenChanged)
Q_PROPERTY(int privacyScreenTimeout READ privacyScreenTimeout WRITE setPrivacyScreenTimeout
NOTIFY privacyScreenTimeoutChanged)
Q_PROPERTY(int timelineMaxWidth READ timelineMaxWidth WRITE setTimelineMaxWidth NOTIFY Q_PROPERTY(int timelineMaxWidth READ timelineMaxWidth WRITE setTimelineMaxWidth NOTIFY
timelineMaxWidthChanged) timelineMaxWidthChanged)
Q_PROPERTY(bool mobileMode READ mobileMode WRITE setMobileMode NOTIFY mobileModeChanged) Q_PROPERTY(bool mobileMode READ mobileMode WRITE setMobileMode NOTIFY mobileModeChanged)
@ -131,6 +135,8 @@ public:
void setAlertOnNotification(bool state); void setAlertOnNotification(bool state);
void setAvatarCircles(bool state); void setAvatarCircles(bool state);
void setDecryptSidebar(bool state); void setDecryptSidebar(bool state);
void setPrivacyScreen(bool state);
void setPrivacyScreenTimeout(int state);
void setPresence(Presence state); void setPresence(Presence state);
void setRingtone(QString ringtone); void setRingtone(QString ringtone);
void setMicrophone(QString microphone); void setMicrophone(QString microphone);
@ -154,6 +160,8 @@ public:
bool groupView() const { return groupView_; } bool groupView() const { return groupView_; }
bool avatarCircles() const { return avatarCircles_; } bool avatarCircles() const { return avatarCircles_; }
bool decryptSidebar() const { return decryptSidebar_; } bool decryptSidebar() const { return decryptSidebar_; }
bool privacyScreen() const { return privacyScreen_; }
int privacyScreenTimeout() const { return privacyScreenTimeout_; }
bool markdown() const { return markdown_; } bool markdown() const { return markdown_; }
bool typingNotifications() const { return typingNotifications_; } bool typingNotifications() const { return typingNotifications_; }
bool sortByImportance() const { return sortByImportance_; } bool sortByImportance() const { return sortByImportance_; }
@ -201,6 +209,8 @@ signals:
void alertOnNotificationChanged(bool state); void alertOnNotificationChanged(bool state);
void avatarCirclesChanged(bool state); void avatarCirclesChanged(bool state);
void decryptSidebarChanged(bool state); void decryptSidebarChanged(bool state);
void privacyScreenChanged(bool state);
void privacyScreenTimeoutChanged(int state);
void timelineMaxWidthChanged(int state); void timelineMaxWidthChanged(int state);
void mobileModeChanged(bool mode); void mobileModeChanged(bool mode);
void fontSizeChanged(double state); void fontSizeChanged(double state);
@ -241,6 +251,8 @@ private:
bool hasAlertOnNotification_; bool hasAlertOnNotification_;
bool avatarCircles_; bool avatarCircles_;
bool decryptSidebar_; bool decryptSidebar_;
bool privacyScreen_;
int privacyScreenTimeout_;
bool shareKeysWithTrustedUsers_; bool shareKeysWithTrustedUsers_;
bool mobileMode_; bool mobileMode_;
int timelineMaxWidth_; int timelineMaxWidth_;
@ -320,6 +332,8 @@ private:
Toggle *avatarCircles_; Toggle *avatarCircles_;
Toggle *useStunServer_; Toggle *useStunServer_;
Toggle *decryptSidebar_; Toggle *decryptSidebar_;
Toggle *privacyScreen_;
QSpinBox *privacyScreenTimeout_;
Toggle *shareKeysWithTrustedUsers_; Toggle *shareKeysWithTrustedUsers_;
Toggle *mobileMode_; Toggle *mobileMode_;
QLabel *deviceFingerprintValue_; QLabel *deviceFingerprintValue_;

View file

@ -36,6 +36,8 @@ class TimelineViewManager : public QObject
bool isInitialSync MEMBER isInitialSync_ READ isInitialSync NOTIFY initialSyncChanged) bool isInitialSync MEMBER isInitialSync_ READ isInitialSync NOTIFY initialSyncChanged)
Q_PROPERTY( Q_PROPERTY(
bool isNarrowView MEMBER isNarrowView_ READ isNarrowView NOTIFY narrowViewChanged) bool isNarrowView MEMBER isNarrowView_ READ isNarrowView NOTIFY narrowViewChanged)
Q_PROPERTY(
bool isWindowFocused MEMBER isWindowFocused_ READ isWindowFocused NOTIFY focusChanged)
public: public:
TimelineViewManager(CallManager *callManager, ChatPage *parent = nullptr); TimelineViewManager(CallManager *callManager, ChatPage *parent = nullptr);
@ -54,6 +56,7 @@ public:
Q_INVOKABLE TimelineModel *activeTimeline() const { return timeline_; } Q_INVOKABLE TimelineModel *activeTimeline() const { return timeline_; }
Q_INVOKABLE bool isInitialSync() const { return isInitialSync_; } Q_INVOKABLE bool isInitialSync() const { return isInitialSync_; }
bool isNarrowView() const { return isNarrowView_; } bool isNarrowView() const { return isNarrowView_; }
bool isWindowFocused() const { return isWindowFocused_; }
Q_INVOKABLE void openImageOverlay(QString mxcUrl, QString eventId) const; Q_INVOKABLE void openImageOverlay(QString mxcUrl, QString eventId) const;
Q_INVOKABLE QColor userColor(QString id, QColor background); Q_INVOKABLE QColor userColor(QString id, QColor background);
Q_INVOKABLE QString escapeEmoji(QString str) const; Q_INVOKABLE QString escapeEmoji(QString str) const;
@ -83,11 +86,17 @@ signals:
void inviteUsers(QStringList users); void inviteUsers(QStringList users);
void showRoomList(); void showRoomList();
void narrowViewChanged(); void narrowViewChanged();
void focusChanged();
public slots: public slots:
void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids); void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids);
void receivedSessionKey(const std::string &room_id, const std::string &session_id); void receivedSessionKey(const std::string &room_id, const std::string &session_id);
void initWithMessages(const std::vector<QString> &roomIds); void initWithMessages(const std::vector<QString> &roomIds);
void chatFocusChanged(bool focused)
{
isWindowFocused_ = focused;
emit focusChanged();
}
void setHistoryView(const QString &room_id); void setHistoryView(const QString &room_id);
TimelineModel *getHistoryView(const QString &room_id) TimelineModel *getHistoryView(const QString &room_id)
@ -145,8 +154,9 @@ private:
TimelineModel *timeline_ = nullptr; TimelineModel *timeline_ = nullptr;
CallManager *callManager_ = nullptr; CallManager *callManager_ = nullptr;
bool isInitialSync_ = true; bool isInitialSync_ = true;
bool isNarrowView_ = false; bool isNarrowView_ = false;
bool isWindowFocused_ = false;
QHash<QString, QColor> userColors; QHash<QString, QColor> userColors;

View file

@ -244,7 +244,7 @@ UserProfile::changeUsername(QString username)
if (isGlobalUserProfile()) { if (isGlobalUserProfile()) {
// change global // change global
http::client()->set_displayname( http::client()->set_displayname(
username.toStdString(), [this](mtx::http::RequestErr err) { username.toStdString(), [](mtx::http::RequestErr err) {
if (err) { if (err) {
nhlog::net()->warn("could not change username"); nhlog::net()->warn("could not change username");
return; return;
@ -293,4 +293,4 @@ UserProfile::setGlobalUsername(const QString &globalUser)
{ {
globalUsername = globalUser; globalUsername = globalUser;
emit displayNameChanged(); emit displayNameChanged();
} }