lint
This commit is contained in:
parent
4040fd3901
commit
0f76f0115e
@ -1,13 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
#include "MatrixClient.h"
|
|
||||||
#include "CommunitiesListItem.h"
|
#include "CommunitiesListItem.h"
|
||||||
#include "Community.h"
|
#include "Community.h"
|
||||||
|
#include "MatrixClient.h"
|
||||||
#include "ui/Theme.h"
|
#include "ui/Theme.h"
|
||||||
|
|
||||||
class CommunitiesList : public QWidget
|
class CommunitiesList : public QWidget
|
||||||
@ -21,15 +21,13 @@ public:
|
|||||||
void setCommunities(const QMap<QString, QSharedPointer<Community>> &communities);
|
void setCommunities(const QMap<QString, QSharedPointer<Community>> &communities);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void addCommunity(QSharedPointer<Community> community,
|
void addCommunity(QSharedPointer<Community> community, const QString &community_id);
|
||||||
const QString &community_id);
|
|
||||||
void removeCommunity(const QString &community_id);
|
void removeCommunity(const QString &community_id);
|
||||||
signals:
|
signals:
|
||||||
void communityChanged(const QString &community_id);
|
void communityChanged(const QString &community_id);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateCommunityAvatar(const QString &community_id,
|
void updateCommunityAvatar(const QString &community_id, const QPixmap &img);
|
||||||
const QPixmap &img);
|
|
||||||
void highlightSelectedCommunity(const QString &community_id);
|
void highlightSelectedCommunity(const QString &community_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QDebug>
|
||||||
#include <QSharedPointer>
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QDebug>
|
#include <QSharedPointer>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
#include "ui/Theme.h"
|
|
||||||
#include "Menu.h"
|
|
||||||
#include "Community.h"
|
#include "Community.h"
|
||||||
|
#include "Menu.h"
|
||||||
|
#include "ui/Theme.h"
|
||||||
|
|
||||||
class CommunitiesListItem : public QWidget
|
class CommunitiesListItem : public QWidget
|
||||||
{
|
{
|
||||||
@ -61,10 +61,7 @@ inline void
|
|||||||
CommunitiesListItem::setAvatar(const QImage &avatar_image)
|
CommunitiesListItem::setAvatar(const QImage &avatar_image)
|
||||||
{
|
{
|
||||||
communityAvatar_ = QPixmap::fromImage(
|
communityAvatar_ = QPixmap::fromImage(
|
||||||
avatar_image.scaled(IconSize,
|
avatar_image.scaled(IconSize, IconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||||
IconSize,
|
|
||||||
Qt::IgnoreAspectRatio,
|
|
||||||
Qt::SmoothTransformation));
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +75,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *event) override;
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const int IconSize = 55;
|
const int IconSize = 55;
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QUrl>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
class Community : public QObject
|
class Community : public QObject
|
||||||
{
|
{
|
||||||
@ -55,7 +55,6 @@ Community::getLongDescription() const
|
|||||||
return long_description_;
|
return long_description_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const QList<QString>
|
inline const QList<QString>
|
||||||
Community::getRoomList() const
|
Community::getRoomList() const
|
||||||
{
|
{
|
||||||
|
@ -256,11 +256,15 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent)
|
|||||||
SIGNAL(getOwnCommunitiesResponse(QList<QString>)),
|
SIGNAL(getOwnCommunitiesResponse(QList<QString>)),
|
||||||
this,
|
this,
|
||||||
SLOT(updateOwnCommunitiesInfo(QList<QString>)));
|
SLOT(updateOwnCommunitiesInfo(QList<QString>)));
|
||||||
connect(client_.data(), &MatrixClient::communityProfileRetrieved, this,
|
connect(client_.data(),
|
||||||
|
&MatrixClient::communityProfileRetrieved,
|
||||||
|
this,
|
||||||
[=](QString communityId, QJsonObject profile) {
|
[=](QString communityId, QJsonObject profile) {
|
||||||
communityManager_[communityId]->parseProfile(profile);
|
communityManager_[communityId]->parseProfile(profile);
|
||||||
});
|
});
|
||||||
connect(client_.data(), &MatrixClient::communityRoomsRetrieved, this,
|
connect(client_.data(),
|
||||||
|
&MatrixClient::communityRoomsRetrieved,
|
||||||
|
this,
|
||||||
[=](QString communityId, QJsonObject rooms) {
|
[=](QString communityId, QJsonObject rooms) {
|
||||||
communityManager_[communityId]->parseRooms(rooms);
|
communityManager_[communityId]->parseRooms(rooms);
|
||||||
|
|
||||||
@ -268,7 +272,8 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent)
|
|||||||
if (communityId == "world") {
|
if (communityId == "world") {
|
||||||
room_list_->setFilterRooms(false);
|
room_list_->setFilterRooms(false);
|
||||||
} else {
|
} else {
|
||||||
room_list_->setRoomFilter(communityManager_[communityId]->getRoomList());
|
room_list_->setRoomFilter(
|
||||||
|
communityManager_[communityId]->getRoomList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -301,12 +306,16 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(communitiesList_, &CommunitiesList::communityChanged, this, [=](const QString &communityId) {
|
connect(communitiesList_,
|
||||||
|
&CommunitiesList::communityChanged,
|
||||||
|
this,
|
||||||
|
[=](const QString &communityId) {
|
||||||
current_community_ = communityId;
|
current_community_ = communityId;
|
||||||
if (communityId == "world") {
|
if (communityId == "world") {
|
||||||
room_list_->setFilterRooms(false);
|
room_list_->setFilterRooms(false);
|
||||||
} else {
|
} else {
|
||||||
room_list_->setRoomFilter(communityManager_[communityId]->getRoomList());
|
room_list_->setRoomFilter(
|
||||||
|
communityManager_[communityId]->getRoomList());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -35,16 +35,21 @@ CommunitiesList::CommunitiesList(QSharedPointer<MatrixClient> client, QWidget *p
|
|||||||
WorldCommunityListItem *world_list_item = new WorldCommunityListItem();
|
WorldCommunityListItem *world_list_item = new WorldCommunityListItem();
|
||||||
contentsLayout_->addWidget(world_list_item);
|
contentsLayout_->addWidget(world_list_item);
|
||||||
communities_.insert("world", QSharedPointer<CommunitiesListItem>(world_list_item));
|
communities_.insert("world", QSharedPointer<CommunitiesListItem>(world_list_item));
|
||||||
connect(world_list_item, &WorldCommunityListItem::clicked,
|
connect(world_list_item,
|
||||||
this, &CommunitiesList::highlightSelectedCommunity);
|
&WorldCommunityListItem::clicked,
|
||||||
|
this,
|
||||||
|
&CommunitiesList::highlightSelectedCommunity);
|
||||||
contentsLayout_->addStretch(1);
|
contentsLayout_->addStretch(1);
|
||||||
|
|
||||||
scrollArea_->setWidget(scrollAreaContents_);
|
scrollArea_->setWidget(scrollAreaContents_);
|
||||||
topLayout_->addWidget(scrollArea_);
|
topLayout_->addWidget(scrollArea_);
|
||||||
|
|
||||||
connect(client_.data(), &MatrixClient::communityProfileRetrieved, this,
|
connect(client_.data(),
|
||||||
|
&MatrixClient::communityProfileRetrieved,
|
||||||
|
this,
|
||||||
[=](QString communityId, QJsonObject profile) {
|
[=](QString communityId, QJsonObject profile) {
|
||||||
client_->fetchCommunityAvatar(communityId, QUrl(profile["avatar_url"].toString()));
|
client_->fetchCommunityAvatar(communityId,
|
||||||
|
QUrl(profile["avatar_url"].toString()));
|
||||||
});
|
});
|
||||||
connect(client_.data(),
|
connect(client_.data(),
|
||||||
SIGNAL(communityAvatarRetrieved(const QString &, const QPixmap &)),
|
SIGNAL(communityAvatarRetrieved(const QString &, const QPixmap &)),
|
||||||
@ -62,8 +67,10 @@ CommunitiesList::setCommunities(const QMap<QString, QSharedPointer<Community>> &
|
|||||||
// TODO: still not sure how to handle the "world" special-case
|
// TODO: still not sure how to handle the "world" special-case
|
||||||
WorldCommunityListItem *world_list_item = new WorldCommunityListItem();
|
WorldCommunityListItem *world_list_item = new WorldCommunityListItem();
|
||||||
communities_.insert("world", QSharedPointer<CommunitiesListItem>(world_list_item));
|
communities_.insert("world", QSharedPointer<CommunitiesListItem>(world_list_item));
|
||||||
connect(world_list_item, &WorldCommunityListItem::clicked,
|
connect(world_list_item,
|
||||||
this, &CommunitiesList::highlightSelectedCommunity);
|
&WorldCommunityListItem::clicked,
|
||||||
|
this,
|
||||||
|
&CommunitiesList::highlightSelectedCommunity);
|
||||||
contentsLayout_->insertWidget(0, world_list_item);
|
contentsLayout_->insertWidget(0, world_list_item);
|
||||||
|
|
||||||
for (auto it = communities.constBegin(); it != communities.constEnd(); it++) {
|
for (auto it = communities.constBegin(); it != communities.constEnd(); it++) {
|
||||||
@ -89,9 +96,8 @@ CommunitiesList::clear()
|
|||||||
void
|
void
|
||||||
CommunitiesList::addCommunity(QSharedPointer<Community> community, const QString &community_id)
|
CommunitiesList::addCommunity(QSharedPointer<Community> community, const QString &community_id)
|
||||||
{
|
{
|
||||||
CommunitiesListItem *list_item = new CommunitiesListItem(community,
|
CommunitiesListItem *list_item =
|
||||||
community_id,
|
new CommunitiesListItem(community, community_id, scrollArea_);
|
||||||
scrollArea_);
|
|
||||||
|
|
||||||
communities_.insert(community_id, QSharedPointer<CommunitiesListItem>(list_item));
|
communities_.insert(community_id, QSharedPointer<CommunitiesListItem>(list_item));
|
||||||
|
|
||||||
@ -99,8 +105,10 @@ CommunitiesList::addCommunity(QSharedPointer<Community> community, const QString
|
|||||||
|
|
||||||
contentsLayout_->insertWidget(contentsLayout_->count() - 1, list_item);
|
contentsLayout_->insertWidget(contentsLayout_->count() - 1, list_item);
|
||||||
|
|
||||||
connect(list_item, &CommunitiesListItem::clicked,
|
connect(list_item,
|
||||||
this, &CommunitiesList::highlightSelectedCommunity);
|
&CommunitiesListItem::clicked,
|
||||||
|
this,
|
||||||
|
&CommunitiesList::highlightSelectedCommunity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -118,7 +126,6 @@ CommunitiesList::updateCommunityAvatar(const QString &community_id, const QPixma
|
|||||||
}
|
}
|
||||||
|
|
||||||
communities_.value(community_id)->setAvatar(img.toImage());
|
communities_.value(community_id)->setAvatar(img.toImage());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -31,7 +31,8 @@ CommunitiesListItem::setPressedState(bool state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CommunitiesListItem::mousePressEvent(QMouseEvent *event) {
|
CommunitiesListItem::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
if (event->buttons() == Qt::RightButton) {
|
if (event->buttons() == Qt::RightButton) {
|
||||||
QWidget::mousePressEvent(event);
|
QWidget::mousePressEvent(event);
|
||||||
return;
|
return;
|
||||||
@ -47,7 +48,6 @@ CommunitiesListItem::paintEvent(QPaintEvent *event)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
|
|
||||||
|
|
||||||
QPainter p(this);
|
QPainter p(this);
|
||||||
p.setRenderHint(QPainter::TextAntialiasing);
|
p.setRenderHint(QPainter::TextAntialiasing);
|
||||||
p.setRenderHint(QPainter::SmoothPixmapTransform);
|
p.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
@ -91,7 +91,8 @@ CommunitiesListItem::paintEvent(QPaintEvent *event)
|
|||||||
p.save();
|
p.save();
|
||||||
|
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.addEllipse((width()-IconSize)/2, (height()-IconSize)/2, IconSize, IconSize);
|
path.addEllipse(
|
||||||
|
(width() - IconSize) / 2, (height() - IconSize) / 2, IconSize, IconSize);
|
||||||
p.setClipPath(path);
|
p.setClipPath(path);
|
||||||
|
|
||||||
p.drawPixmap(avatarRegion, communityAvatar_);
|
p.drawPixmap(avatarRegion, communityAvatar_);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "include/Community.h"
|
#include "include/Community.h"
|
||||||
|
|
||||||
#include <QJsonValue>
|
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
#include <QJsonValue>
|
||||||
|
|
||||||
void
|
void
|
||||||
Community::parseProfile(const QJsonObject &profile)
|
Community::parseProfile(const QJsonObject &profile)
|
||||||
@ -29,7 +29,6 @@ Community::parseProfile(const QJsonObject &profile)
|
|||||||
} else {
|
} else {
|
||||||
long_description_ = "";
|
long_description_ = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -490,7 +490,9 @@ MatrixClient::getOwnCommunities() noexcept
|
|||||||
auto json = QJsonDocument::fromJson(data);
|
auto json = QJsonDocument::fromJson(data);
|
||||||
try {
|
try {
|
||||||
QList<QString> response;
|
QList<QString> response;
|
||||||
for (auto it = json["groups"].toArray().constBegin(); it != json["groups"].toArray().constEnd(); it++) {
|
for (auto it = json["groups"].toArray().constBegin();
|
||||||
|
it != json["groups"].toArray().constEnd();
|
||||||
|
it++) {
|
||||||
response.append(it->toString());
|
response.append(it->toString());
|
||||||
}
|
}
|
||||||
emit getOwnCommunitiesResponse(response);
|
emit getOwnCommunitiesResponse(response);
|
||||||
|
@ -297,10 +297,10 @@ RoomList::setFilterRooms(bool filterRooms)
|
|||||||
filterRooms_ = filterRooms;
|
filterRooms_ = filterRooms;
|
||||||
|
|
||||||
for (int i = 0; i < contentsLayout_->count(); i++) {
|
for (int i = 0; i < contentsLayout_->count(); i++) {
|
||||||
|
|
||||||
// If roomFilter_ contains the room for the current RoomInfoListItem,
|
// If roomFilter_ contains the room for the current RoomInfoListItem,
|
||||||
// show the list item, otherwise hide it
|
// show the list item, otherwise hide it
|
||||||
RoomInfoListItem *listitem = (RoomInfoListItem *) contentsLayout_->itemAt(i)->widget();
|
RoomInfoListItem *listitem =
|
||||||
|
(RoomInfoListItem *)contentsLayout_->itemAt(i)->widget();
|
||||||
|
|
||||||
if (listitem != nullptr) {
|
if (listitem != nullptr) {
|
||||||
if (!filterRooms) {
|
if (!filterRooms) {
|
||||||
|
Loading…
Reference in New Issue
Block a user