summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChatPage.cpp2
-rw-r--r--src/ChatPage.h2
-rw-r--r--src/MainWindow.cpp16
-rw-r--r--src/MainWindow.h4
-rw-r--r--src/UserSettingsPage.cpp12
-rw-r--r--src/timeline/TimelineViewManager.h14
6 files changed, 42 insertions, 8 deletions
diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp

index 0377ce30..5bbfa351 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp
@@ -312,6 +312,8 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent) &ChatPage::initializeMentions, user_mentions_popup_, &popups::UserMentions::initializeMentions); + connect( + this, &ChatPage::chatFocusChanged, view_manager_, &TimelineViewManager::chatFocusChanged); connect(this, &ChatPage::syncUI, this, [this](const mtx::responses::Rooms &rooms) { try { room_list_->cleanupInvites(cache::invites()); diff --git a/src/ChatPage.h b/src/ChatPage.h
index 0516f87d..917bd785 100644 --- a/src/ChatPage.h +++ b/src/ChatPage.h
@@ -127,7 +127,6 @@ public slots: void receivedSessionKey(const std::string &room_id, const std::string &session_id); void decryptDownloadedSecrets(mtx::secret_storage::AesHmacSha2KeyDescription keyDesc, const SecretsToDecrypt &secrets); - signals: void connectionLost(); void connectionRestored(); @@ -176,6 +175,7 @@ signals: void retrievedPresence(const QString &statusMsg, mtx::presence::PresenceState state); void themeChanged(); void decryptSidebarChanged(); + void chatFocusChanged(const bool focused); //! Signals for device verificaiton void receivedDeviceVerificationAccept( diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 77269008..8fd5c7e2 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp
@@ -130,6 +130,9 @@ MainWindow::MainWindow(QWidget *parent) SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); connect(chat_page_, SIGNAL(contentLoaded()), this, SLOT(removeOverlayProgressBar())); + + connect(this, &MainWindow::focusChanged, chat_page_, &ChatPage::chatFocusChanged); + connect( chat_page_, &ChatPage::showUserSettingsPage, this, &MainWindow::showUserSettingsPage); @@ -204,6 +207,19 @@ MainWindow::resizeEvent(QResizeEvent *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 MainWindow::adjustSideBars() { diff --git a/src/MainWindow.h b/src/MainWindow.h
index 0915a849..4560ec65 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h
@@ -88,6 +88,7 @@ protected: void closeEvent(QCloseEvent *event) override; void resizeEvent(QResizeEvent *event) override; void showEvent(QShowEvent *event) override; + bool event(QEvent *event) override; private slots: //! Show or hide the sidebars based on window's size. @@ -115,6 +116,9 @@ private slots: virtual void setWindowTitle(int notificationCount); +signals: + void focusChanged(const bool focused); + private: bool loadJdenticonPlugin(); diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp
index a8558e95..c26bf2e9 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp
@@ -836,13 +836,15 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge decryptSidebar_, tr("Decrypt the messages shown in the sidebar.\nOnly affects messages in " "encrypted chats.")); - boxWrap(tr("Encrypted chat privacy screen"), + boxWrap(tr("Privacy Screen"), privacyScreen_, tr("When the window loses focus, the timeline will\nbe blurred.")); - boxWrap(tr("Privacy screen timeout"), - privacyScreenTimeout_, - tr("Set timeout for how long after window loses\nfocus before the screen" - " will be blurred.\nSet to 0 to blur immediately after focus loss.")); + boxWrap( + tr("Privacy screen timeout"), + 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"), timelineButtonsToggle_, tr("Show buttons to quickly reply, react or access additional options next to each " diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h
index 23a960b8..74128865 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h
@@ -36,6 +36,8 @@ class TimelineViewManager : public QObject bool isInitialSync MEMBER isInitialSync_ READ isInitialSync NOTIFY initialSyncChanged) Q_PROPERTY( bool isNarrowView MEMBER isNarrowView_ READ isNarrowView NOTIFY narrowViewChanged) + Q_PROPERTY( + bool isWindowFocused MEMBER isWindowFocused_ READ isWindowFocused NOTIFY focusChanged) public: TimelineViewManager(CallManager *callManager, ChatPage *parent = nullptr); @@ -54,6 +56,7 @@ public: Q_INVOKABLE TimelineModel *activeTimeline() const { return timeline_; } Q_INVOKABLE bool isInitialSync() const { return isInitialSync_; } bool isNarrowView() const { return isNarrowView_; } + bool isWindowFocused() const { return isWindowFocused_; } Q_INVOKABLE void openImageOverlay(QString mxcUrl, QString eventId) const; Q_INVOKABLE QColor userColor(QString id, QColor background); Q_INVOKABLE QString escapeEmoji(QString str) const; @@ -83,11 +86,17 @@ signals: void inviteUsers(QStringList users); void showRoomList(); void narrowViewChanged(); + void focusChanged(); public slots: 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 initWithMessages(const std::vector<QString> &roomIds); + void chatFocusChanged(bool focused) + { + isWindowFocused_ = focused; + emit focusChanged(); + } void setHistoryView(const QString &room_id); TimelineModel *getHistoryView(const QString &room_id) @@ -145,8 +154,9 @@ private: TimelineModel *timeline_ = nullptr; CallManager *callManager_ = nullptr; - bool isInitialSync_ = true; - bool isNarrowView_ = false; + bool isInitialSync_ = true; + bool isNarrowView_ = false; + bool isWindowFocused_ = false; QHash<QString, QColor> userColors;