Fix linting issues

This commit is contained in:
Joseph Donofry 2019-07-16 22:50:23 -04:00
parent 579bf23460
commit d2af827194
No known key found for this signature in database
GPG key ID: E8A1D78EF044B0CB
5 changed files with 45 additions and 46 deletions

View file

@ -90,9 +90,9 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
connect(sidebarActions_, &SideBarActions::joinRoom, this, &ChatPage::joinRoom);
connect(sidebarActions_, &SideBarActions::createRoom, this, &ChatPage::createRoom);
user_info_widget_ = new UserInfoWidget(sideBar_);
user_info_widget_ = new UserInfoWidget(sideBar_);
user_mentions_widget_ = new UserMentionsWidget(sideBar_);
room_list_ = new RoomList(sideBar_);
room_list_ = new RoomList(sideBar_);
connect(room_list_, &RoomList::joinRoom, this, &ChatPage::joinRoom);
sideBarLayout_->addWidget(user_info_widget_);
@ -155,22 +155,20 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
});
connect(user_mentions_widget_, &UserMentionsWidget::clicked, this, [this]() {
http::client()->notifications(
1000,
"",
"highlight",
[this](const mtx::responses::Notifications &res,
mtx::http::RequestErr err) {
if (err) {
nhlog::net()->warn(
"failed to retrieve notifications: {} ({})",
err->matrix_error.error,
static_cast<int>(err->status_code));
return;
}
http::client()->notifications(
1000,
"",
"highlight",
[this](const mtx::responses::Notifications &res, mtx::http::RequestErr err) {
if (err) {
nhlog::net()->warn("failed to retrieve notifications: {} ({})",
err->matrix_error.error,
static_cast<int>(err->status_code));
return;
}
emit highlightedNotifsRetrieved(std::move(res));
});
emit highlightedNotifsRetrieved(std::move(res));
});
});
connectivityTimer_.setInterval(CHECK_CONNECTIVITY_INTERVAL);
@ -520,7 +518,8 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
connect(this, &ChatPage::leftRoom, this, &ChatPage::removeRoom);
connect(this, &ChatPage::notificationsRetrieved, this, &ChatPage::sendDesktopNotifications);
connect(this, &ChatPage::highlightedNotifsRetrieved, this, &ChatPage::showNotificationsDialog);
connect(
this, &ChatPage::highlightedNotifsRetrieved, this, &ChatPage::showNotificationsDialog);
connect(communitiesList_,
&CommunitiesList::communityChanged,
@ -998,7 +997,7 @@ ChatPage::showNotificationsDialog(const mtx::responses::Notifications &res)
try {
const auto room_id = QString::fromStdString(item.room_id);
const auto user_id = utils::event_sender(item.event);
const auto body = utils::event_body(item.event);
const auto body = utils::event_body(item.event);
notifDialog->pushItem(event_id, user_id, body, room_id);

View file

@ -90,7 +90,6 @@ signals:
void notificationsRetrieved(const mtx::responses::Notifications &);
void highlightedNotifsRetrieved(const mtx::responses::Notifications &);
void uploadFailed(const QString &msg);
void imageUploaded(const QString &roomid,
const QString &filename,
@ -209,7 +208,6 @@ private:
void showNotificationsDialog(const mtx::responses::Notifications &);
QStringList generateTypingUsers(const QString &room_id,
const std::vector<std::string> &typing_users);

View file

@ -210,7 +210,7 @@ UserMentionsWidget::paintEvent(QPaintEvent *event)
const int msgStampWidth = QFontMetrics(tsFont).horizontalAdvance("timestamp") + 4;
#endif
// We use the full width of the widget if there is no unread msg bubble.
//const int bottomLineWidthLimit = (unreadMsgCount_ > 0) ? msgStampWidth : 0;
// const int bottomLineWidthLimit = (unreadMsgCount_ > 0) ? msgStampWidth : 0;
// Name line.
QFontMetrics fontNameMetrics(headingFont);
@ -229,7 +229,8 @@ UserMentionsWidget::paintEvent(QPaintEvent *event)
// timestamp.
int usernameLimit =
std::max(0, width() - 3 * wm.padding - msgStampWidth - wm.iconSize - 20);
auto userName = metrics.elidedText("Show Mentioned Messages", Qt::ElideRight, usernameLimit);
auto userName =
metrics.elidedText("Show Mentioned Messages", Qt::ElideRight, usernameLimit);
p.setFont(QFont{});
p.drawText(QPoint(2 * wm.padding + wm.iconSize, bottom_y), userName);

View file

@ -6,7 +6,7 @@
using namespace dialogs;
UserMentions::UserMentions(QWidget *parent)
: QWidget{parent}
: QWidget{parent}
{
top_layout_ = new QVBoxLayout(this);
top_layout_->setSpacing(0);
@ -38,22 +38,21 @@ UserMentions::UserMentions(QWidget *parent)
}
void
UserMentions::pushItem(const QString &event_id, const QString &user_id, const QString &body, const QString &room_id) {
TimelineItem *view_item =
new TimelineItem(mtx::events::MessageType::Text,
user_id,
body,
true,
room_id,
scroll_widget_);
view_item->setEventId(event_id);
setUpdatesEnabled(false);
view_item->hide();
UserMentions::pushItem(const QString &event_id,
const QString &user_id,
const QString &body,
const QString &room_id)
{
TimelineItem *view_item = new TimelineItem(
mtx::events::MessageType::Text, user_id, body, true, room_id, scroll_widget_);
view_item->setEventId(event_id);
setUpdatesEnabled(false);
view_item->hide();
scroll_layout_->addWidget(view_item);
QTimer::singleShot(0, this, [view_item, this]() {
view_item->show();
view_item->adjustSize();
setUpdatesEnabled(true);
});
scroll_layout_->addWidget(view_item);
QTimer::singleShot(0, this, [view_item, this]() {
view_item->show();
view_item->adjustSize();
setUpdatesEnabled(true);
});
}

View file

@ -1,9 +1,9 @@
#pragma once
#include <QWidget>
#include <QVBoxLayout>
#include <QScrollArea>
#include <QScrollBar>
#include <QVBoxLayout>
#include <QWidget>
namespace dialogs {
@ -12,15 +12,17 @@ class UserMentions : public QWidget
Q_OBJECT
public:
UserMentions(QWidget *parent = nullptr);
void pushItem(const QString &event_id, const QString &user_id, const QString &body, const QString &room_id);
void pushItem(const QString &event_id,
const QString &user_id,
const QString &body,
const QString &room_id);
private:
QVBoxLayout *top_layout_;
QVBoxLayout *scroll_layout_;
QScrollArea *scroll_area_;
QWidget *scroll_widget_;
};
}