Re-order room list based on activity

fixes #2
This commit is contained in:
Konstantinos Sideris 2017-12-30 17:29:57 +02:00
parent d1d8b92b37
commit 208f957911
8 changed files with 125 additions and 16 deletions

View file

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

View file

@ -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_; }

View file

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

View file

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