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

View File

@ -90,7 +90,6 @@ signals:
void notificationsRetrieved(const mtx::responses::Notifications &); void notificationsRetrieved(const mtx::responses::Notifications &);
void highlightedNotifsRetrieved(const mtx::responses::Notifications &); void highlightedNotifsRetrieved(const mtx::responses::Notifications &);
void uploadFailed(const QString &msg); void uploadFailed(const QString &msg);
void imageUploaded(const QString &roomid, void imageUploaded(const QString &roomid,
const QString &filename, const QString &filename,
@ -209,7 +208,6 @@ private:
void showNotificationsDialog(const mtx::responses::Notifications &); void showNotificationsDialog(const mtx::responses::Notifications &);
QStringList generateTypingUsers(const QString &room_id, QStringList generateTypingUsers(const QString &room_id,
const std::vector<std::string> &typing_users); 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; const int msgStampWidth = QFontMetrics(tsFont).horizontalAdvance("timestamp") + 4;
#endif #endif
// We use the full width of the widget if there is no unread msg bubble. // 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. // Name line.
QFontMetrics fontNameMetrics(headingFont); QFontMetrics fontNameMetrics(headingFont);
@ -229,7 +229,8 @@ UserMentionsWidget::paintEvent(QPaintEvent *event)
// timestamp. // timestamp.
int usernameLimit = int usernameLimit =
std::max(0, width() - 3 * wm.padding - msgStampWidth - wm.iconSize - 20); 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.setFont(QFont{});
p.drawText(QPoint(2 * wm.padding + wm.iconSize, bottom_y), userName); p.drawText(QPoint(2 * wm.padding + wm.iconSize, bottom_y), userName);

View File

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

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
#include <QWidget>
#include <QVBoxLayout>
#include <QScrollArea> #include <QScrollArea>
#include <QScrollBar> #include <QScrollBar>
#include <QVBoxLayout>
#include <QWidget>
namespace dialogs { namespace dialogs {
@ -12,15 +12,17 @@ class UserMentions : public QWidget
Q_OBJECT Q_OBJECT
public: public:
UserMentions(QWidget *parent = nullptr); 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: private:
QVBoxLayout *top_layout_; QVBoxLayout *top_layout_;
QVBoxLayout *scroll_layout_; QVBoxLayout *scroll_layout_;
QScrollArea *scroll_area_; QScrollArea *scroll_area_;
QWidget *scroll_widget_; QWidget *scroll_widget_;
}; };
} }