diff --git a/src/ChatPage.cc b/src/ChatPage.cc
index d318d086..2b92ac7d 100644
--- a/src/ChatPage.cc
+++ b/src/ChatPage.cc
@@ -127,10 +127,16 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent)
connect(room_list_, &RoomList::roomChanged, this, &ChatPage::changeTopRoomInfo);
connect(room_list_, &RoomList::roomChanged, view_manager_, &TimelineViewManager::setHistoryView);
- connect(view_manager_,
- SIGNAL(unreadMessages(const QString &, int)),
- room_list_,
- SLOT(updateUnreadMessageCount(const QString &, int)));
+ connect(view_manager_, &TimelineViewManager::unreadMessages, this, [=](const QString &roomid, int count) {
+ if (!settingsManager_.contains(roomid)) {
+ qWarning() << "RoomId does not have settings" << roomid;
+ room_list_->updateUnreadMessageCount(roomid, count);
+ return;
+ }
+
+ if (settingsManager_[roomid]->isNotificationsEnabled())
+ room_list_->updateUnreadMessageCount(roomid, count);
+ });
connect(room_list_,
SIGNAL(totalUnreadMessageCountUpdated(int)),
@@ -173,11 +179,17 @@ void ChatPage::logout()
{
sync_timer_->stop();
+ // Delete all config parameters.
QSettings settings;
- settings.remove("auth/access_token");
- settings.remove("auth/home_server");
- settings.remove("auth/user_id");
- settings.remove("client/transaction_id");
+ settings.beginGroup("auth");
+ settings.remove("");
+ settings.endGroup();
+ settings.beginGroup("client");
+ settings.remove("");
+ settings.endGroup();
+ settings.beginGroup("notifications");
+ settings.remove("");
+ settings.endGroup();
// Clear the environment.
room_list_->clear();
@@ -188,6 +200,7 @@ void ChatPage::logout()
client_->reset();
state_manager_.clear();
+ settingsManager_.clear();
room_avatars_.clear();
emit close();
@@ -286,6 +299,7 @@ void ChatPage::initialSyncCompleted(const SyncResponse &response)
updateDisplayNames(room_state);
state_manager_.insert(it.key(), room_state);
+ settingsManager_.insert(it.key(), QSharedPointer<RoomSettings>(new RoomSettings(it.key())));
}
view_manager_->initialize(response.rooms());
@@ -325,6 +339,7 @@ void ChatPage::changeTopRoomInfo(const QString &room_id)
top_bar_->updateRoomName(state.getName());
top_bar_->updateRoomTopic(state.getTopic());
+ top_bar_->setRoomSettings(settingsManager_[room_id]);
if (room_avatars_.contains(room_id))
top_bar_->updateRoomAvatar(room_avatars_.value(room_id).toImage());
diff --git a/src/EmojiPanel.cc b/src/EmojiPanel.cc
index dde44369..53b3f8d1 100644
--- a/src/EmojiPanel.cc
+++ b/src/EmojiPanel.cc
@@ -28,7 +28,7 @@
EmojiPanel::EmojiPanel(QWidget *parent)
: QWidget(parent)
- , shadowMargin_{3}
+ , shadowMargin_{2}
, width_{370}
, height_{350}
, animationDuration_{100}
diff --git a/src/TopRoomBar.cc b/src/TopRoomBar.cc
index b35291cb..ce0693f2 100644
--- a/src/TopRoomBar.cc
+++ b/src/TopRoomBar.cc
@@ -21,6 +21,7 @@
TopRoomBar::TopRoomBar(QWidget *parent)
: QWidget(parent)
+ , buttonSize_{32}
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setMinimumSize(QSize(0, 65));
@@ -28,7 +29,7 @@ TopRoomBar::TopRoomBar(QWidget *parent)
top_layout_ = new QHBoxLayout();
top_layout_->setSpacing(10);
- top_layout_->setContentsMargins(10, 10, 0, 10);
+ top_layout_->setMargin(10);
avatar_ = new Avatar(this);
avatar_->setLetter(QChar('?'));
@@ -49,31 +50,42 @@ TopRoomBar::TopRoomBar(QWidget *parent)
text_layout_->addWidget(name_label_);
text_layout_->addWidget(topic_label_);
- settings_button_ = new FlatButton(this);
- settings_button_->setForegroundColor(QColor("#acc7dc"));
- settings_button_->setCursor(QCursor(Qt::PointingHandCursor));
- settings_button_->setStyleSheet("width: 30px; height: 30px;");
+ settingsBtn_ = new FlatButton(this);
+ settingsBtn_->setForegroundColor(QColor("#acc7dc"));
+ settingsBtn_->setCursor(QCursor(Qt::PointingHandCursor));
+ settingsBtn_->setFixedSize(buttonSize_, buttonSize_);
+ settingsBtn_->setCornerRadius(buttonSize_ / 2);
QIcon settings_icon;
- settings_icon.addFile(":/icons/icons/cog.png", QSize(), QIcon::Normal, QIcon::Off);
- settings_button_->setIcon(settings_icon);
- settings_button_->setIconSize(QSize(16, 16));
-
- search_button_ = new FlatButton(this);
- search_button_->setForegroundColor(QColor("#acc7dc"));
- search_button_->setCursor(QCursor(Qt::PointingHandCursor));
- search_button_->setStyleSheet("width: 30px; height: 30px;");
-
- QIcon search_icon;
- search_icon.addFile(":/icons/icons/search.png", QSize(), QIcon::Normal, QIcon::Off);
- search_button_->setIcon(search_icon);
- search_button_->setIconSize(QSize(16, 16));
+ settings_icon.addFile(":/icons/icons/vertical-ellipsis.png", QSize(), QIcon::Normal, QIcon::Off);
+ settingsBtn_->setIcon(settings_icon);
+ settingsBtn_->setIconSize(QSize(buttonSize_ / 2, buttonSize_ / 2));
top_layout_->addWidget(avatar_);
top_layout_->addLayout(text_layout_);
top_layout_->addStretch(1);
- top_layout_->addWidget(search_button_);
- top_layout_->addWidget(settings_button_);
+ top_layout_->addWidget(settingsBtn_);
+
+ menu_ = new Menu(this);
+
+ toggleNotifications_ = new QAction(tr("Disable notifications"), this);
+ connect(toggleNotifications_, &QAction::triggered, this, [=]() {
+ roomSettings_->toggleNotifications();
+
+ if (roomSettings_->isNotificationsEnabled())
+ toggleNotifications_->setText("Disable notifications");
+ else
+ toggleNotifications_->setText("Enable notifications");
+
+ });
+
+ menu_->addAction(toggleNotifications_);
+
+ connect(settingsBtn_, &QPushButton::clicked, this, [=]() {
+ auto pos = mapToGlobal(settingsBtn_->pos());
+ menu_->popup(QPoint(pos.x() + buttonSize_ - menu_->sizeHint().width(),
+ pos.y() + buttonSize_));
+ });
setLayout(top_layout_);
}
@@ -106,6 +118,16 @@ void TopRoomBar::paintEvent(QPaintEvent *event)
style()->drawPrimitive(QStyle::PE_Widget, &option, &painter, this);
}
+void TopRoomBar::setRoomSettings(QSharedPointer<RoomSettings> settings)
+{
+ roomSettings_ = settings;
+
+ if (roomSettings_->isNotificationsEnabled())
+ toggleNotifications_->setText("Disable notifications");
+ else
+ toggleNotifications_->setText("Enable notifications");
+}
+
TopRoomBar::~TopRoomBar()
{
}
|