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;
|