summary refs log tree commit diff
path: root/include
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-12-30 17:29:57 +0200
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-12-30 17:29:57 +0200
commit208f9579118307d7749de9bf9be537bf1a1d2b27 (patch)
tree2f27f4bcfab73a996a46964da9a256e4377af322 /include
parentUse qobject_cast on TimelineItem (diff)
downloadnheko-208f9579118307d7749de9bf9be537bf1a1d2b27.tar.xz
Re-order room list based on activity
fixes #2
Diffstat (limited to 'include')
-rw-r--r--include/ChatPage.h8
-rw-r--r--include/RoomInfoListItem.h1
-rw-r--r--include/RoomList.h12
-rw-r--r--include/UserSettingsPage.h16
4 files changed, 34 insertions, 3 deletions
diff --git a/include/ChatPage.h b/include/ChatPage.h

index 14d44ff3..24fc6a25 100644 --- a/include/ChatPage.h +++ b/include/ChatPage.h
@@ -40,6 +40,7 @@ class TimelineViewManager; class TopRoomBar; class TypingDisplay; class UserInfoWidget; +class UserSettings; constexpr int CONSENSUS_TIMEOUT = 1000; constexpr int SHOW_CONTENT_TIMEOUT = 3000; @@ -50,7 +51,9 @@ class ChatPage : public QWidget Q_OBJECT public: - ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent = 0); + ChatPage(QSharedPointer<MatrixClient> client, + QSharedPointer<UserSettings> userSettings, + QWidget *parent = 0); ~ChatPage(); // Initialize all the components of the UI. @@ -150,6 +153,9 @@ private: // Matrix Client API provider. QSharedPointer<MatrixClient> client_; + // Global user settings. + QSharedPointer<UserSettings> userSettings_; + // LMDB wrapper. QSharedPointer<Cache> cache_; diff --git a/include/RoomInfoListItem.h b/include/RoomInfoListItem.h
index bb8e0f1a..799e95bb 100644 --- a/include/RoomInfoListItem.h +++ b/include/RoomInfoListItem.h
@@ -79,6 +79,7 @@ public: void setAvatar(const QImage &avatar_image); void setDescriptionMessage(const DescInfo &info); + DescInfo lastMessageInfo() const { return lastMsgInfo_; } QColor highlightedBackgroundColor() const { return highlightedBackgroundColor_; } QColor hoverBackgroundColor() const { return hoverBackgroundColor_; } diff --git a/include/RoomList.h b/include/RoomList.h
index ed05e0be..6b2151a2 100644 --- a/include/RoomList.h +++ b/include/RoomList.h
@@ -36,6 +36,7 @@ class RoomInfoListItem; class RoomSettings; class RoomState; class Sync; +class UserSettings; struct DescInfo; class RoomList : public QWidget @@ -43,7 +44,9 @@ class RoomList : public QWidget Q_OBJECT public: - RoomList(QSharedPointer<MatrixClient> client, QWidget *parent = 0); + RoomList(QSharedPointer<MatrixClient> client, + QSharedPointer<UserSettings> userSettings, + QWidget *parent = 0); ~RoomList(); void setCache(QSharedPointer<Cache> cache) { cache_ = cache; } @@ -81,6 +84,10 @@ public slots: protected: void paintEvent(QPaintEvent *event) override; + void leaveEvent(QEvent *event) override; + +private slots: + void sortRoomsByLastMessage(); private: void calculateUnreadMessageCount(); @@ -101,4 +108,7 @@ private: QSharedPointer<MatrixClient> client_; QSharedPointer<Cache> cache_; + QSharedPointer<UserSettings> userSettings_; + + bool isSortPending_ = false; }; diff --git a/include/UserSettingsPage.h b/include/UserSettingsPage.h
index 99a149c6..adaa3956 100644 --- a/include/UserSettingsPage.h +++ b/include/UserSettingsPage.h
@@ -38,14 +38,26 @@ public: void load(); void applyTheme(); void setTheme(QString theme); - void setTray(bool state); + void setTray(bool state) + { + isTrayEnabled_ = state; + save(); + }; + + void setRoomOrdering(bool state) + { + isOrderingEnabled_ = state; + save(); + }; QString theme() const { return !theme_.isEmpty() ? theme_ : "light"; } bool isTrayEnabled() const { return isTrayEnabled_; } + bool isOrderingEnabled() const { return isOrderingEnabled_; } private: QString theme_; bool isTrayEnabled_; + bool isOrderingEnabled_; }; class HorizontalLine : public QFrame @@ -84,6 +96,8 @@ private: QSharedPointer<UserSettings> settings_; Toggle *trayToggle_; + Toggle *roomOrderToggle_; + QComboBox *themeCombo_; int sideMargin_ = 0;