2018-01-09 16:07:32 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QSharedPointer>
|
|
|
|
#include <QWidget>
|
|
|
|
|
2021-01-23 02:30:45 +03:00
|
|
|
#include <set>
|
|
|
|
|
2018-04-28 15:27:12 +03:00
|
|
|
#include "Config.h"
|
2018-01-09 16:07:32 +03:00
|
|
|
#include "ui/Theme.h"
|
|
|
|
|
2018-04-28 15:27:12 +03:00
|
|
|
class RippleOverlay;
|
2020-01-31 08:12:02 +03:00
|
|
|
class QMouseEvent;
|
2021-01-23 02:30:45 +03:00
|
|
|
class QMenu;
|
2018-04-28 15:27:12 +03:00
|
|
|
|
2018-01-09 16:07:32 +03:00
|
|
|
class CommunitiesListItem : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QColor highlightedBackgroundColor READ highlightedBackgroundColor WRITE
|
|
|
|
setHighlightedBackgroundColor)
|
2021-01-23 02:30:45 +03:00
|
|
|
Q_PROPERTY(QColor disabledBackgroundColor READ disabledBackgroundColor WRITE
|
|
|
|
setDisabledBackgroundColor)
|
2018-01-09 16:07:32 +03:00
|
|
|
Q_PROPERTY(
|
|
|
|
QColor hoverBackgroundColor READ hoverBackgroundColor WRITE setHoverBackgroundColor)
|
|
|
|
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
|
|
|
|
|
2018-04-28 15:27:12 +03:00
|
|
|
Q_PROPERTY(QColor avatarFgColor READ avatarFgColor WRITE setAvatarFgColor)
|
|
|
|
Q_PROPERTY(QColor avatarBgColor READ avatarBgColor WRITE setAvatarBgColor)
|
|
|
|
|
2018-01-09 16:07:32 +03:00
|
|
|
public:
|
2018-07-14 12:08:16 +03:00
|
|
|
CommunitiesListItem(QString group_id, QWidget *parent = nullptr);
|
2018-01-09 16:07:32 +03:00
|
|
|
|
2018-09-28 15:40:51 +03:00
|
|
|
void setName(QString name);
|
2018-04-28 15:27:12 +03:00
|
|
|
bool isPressed() const { return isPressed_; }
|
2021-01-23 02:30:45 +03:00
|
|
|
bool isDisabled() const { return isDisabled_; }
|
2018-04-28 15:27:12 +03:00
|
|
|
void setAvatar(const QImage &img);
|
2018-01-09 16:07:32 +03:00
|
|
|
|
2021-01-23 02:30:45 +03:00
|
|
|
void setRooms(std::set<QString> room_ids) { room_ids_ = std::move(room_ids); }
|
|
|
|
void addRoom(const QString &id) { room_ids_.insert(id); }
|
2018-09-28 15:40:51 +03:00
|
|
|
void delRoom(const QString &id) { room_ids_.erase(id); }
|
2021-01-23 02:30:45 +03:00
|
|
|
std::set<QString> rooms() const { return room_ids_; }
|
2018-07-14 12:08:16 +03:00
|
|
|
|
2018-09-28 15:40:51 +03:00
|
|
|
bool is_tag() const { return groupId_.startsWith("tag:"); }
|
|
|
|
|
2018-01-09 16:07:32 +03:00
|
|
|
QColor highlightedBackgroundColor() const { return highlightedBackgroundColor_; }
|
2021-01-23 02:30:45 +03:00
|
|
|
QColor disabledBackgroundColor() const { return disabledBackgroundColor_; }
|
2018-01-09 16:07:32 +03:00
|
|
|
QColor hoverBackgroundColor() const { return hoverBackgroundColor_; }
|
|
|
|
QColor backgroundColor() const { return backgroundColor_; }
|
|
|
|
|
2018-04-28 15:27:12 +03:00
|
|
|
QColor avatarFgColor() const { return avatarFgColor_; }
|
|
|
|
QColor avatarBgColor() const { return avatarBgColor_; }
|
|
|
|
|
2018-01-09 16:07:32 +03:00
|
|
|
void setHighlightedBackgroundColor(QColor &color) { highlightedBackgroundColor_ = color; }
|
2021-01-23 02:30:45 +03:00
|
|
|
void setDisabledBackgroundColor(QColor &color) { disabledBackgroundColor_ = color; }
|
2018-01-09 16:07:32 +03:00
|
|
|
void setHoverBackgroundColor(QColor &color) { hoverBackgroundColor_ = color; }
|
|
|
|
void setBackgroundColor(QColor &color) { backgroundColor_ = color; }
|
|
|
|
|
2018-04-28 15:27:12 +03:00
|
|
|
void setAvatarFgColor(QColor &color) { avatarFgColor_ = color; }
|
|
|
|
void setAvatarBgColor(QColor &color) { avatarBgColor_ = color; }
|
|
|
|
|
|
|
|
QSize sizeHint() const override
|
|
|
|
{
|
|
|
|
return QSize(IconSize + IconSize / 3, IconSize + IconSize / 3);
|
|
|
|
}
|
2018-01-09 16:07:32 +03:00
|
|
|
|
|
|
|
signals:
|
2018-07-14 12:08:16 +03:00
|
|
|
void clicked(const QString &group_id);
|
2021-01-23 02:30:45 +03:00
|
|
|
void isDisabledChanged();
|
2018-01-09 16:07:32 +03:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void setPressedState(bool state);
|
2021-01-23 02:30:45 +03:00
|
|
|
void setDisabled(bool state);
|
2018-01-09 16:07:32 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
|
|
void paintEvent(QPaintEvent *event) override;
|
2021-01-23 02:30:45 +03:00
|
|
|
void contextMenuEvent(QContextMenuEvent *event) override;
|
2018-01-09 16:07:32 +03:00
|
|
|
|
|
|
|
private:
|
2018-04-28 15:27:12 +03:00
|
|
|
const int IconSize = 36;
|
2018-01-09 16:07:32 +03:00
|
|
|
|
2018-07-14 12:08:16 +03:00
|
|
|
QString resolveName() const;
|
2018-09-28 15:40:51 +03:00
|
|
|
void updateTooltip();
|
2018-07-14 12:08:16 +03:00
|
|
|
|
2021-01-23 02:30:45 +03:00
|
|
|
std::set<QString> room_ids_;
|
2018-01-09 16:07:32 +03:00
|
|
|
|
2018-07-14 12:08:16 +03:00
|
|
|
QString name_;
|
|
|
|
QString groupId_;
|
|
|
|
QPixmap avatar_;
|
2018-01-09 16:07:32 +03:00
|
|
|
|
2018-04-28 15:27:12 +03:00
|
|
|
QColor highlightedBackgroundColor_;
|
2021-01-23 02:30:45 +03:00
|
|
|
QColor disabledBackgroundColor_;
|
2018-04-28 15:27:12 +03:00
|
|
|
QColor hoverBackgroundColor_;
|
|
|
|
QColor backgroundColor_;
|
|
|
|
|
|
|
|
QColor avatarFgColor_;
|
|
|
|
QColor avatarBgColor_;
|
|
|
|
|
2021-01-23 02:30:45 +03:00
|
|
|
bool isPressed_ = false;
|
|
|
|
bool isDisabled_ = false;
|
2018-01-09 16:07:32 +03:00
|
|
|
|
2018-04-28 15:27:12 +03:00
|
|
|
RippleOverlay *rippleOverlay_;
|
2021-01-23 02:30:45 +03:00
|
|
|
QMenu *menu_;
|
|
|
|
QAction *hideRoomsWithTagAction_;
|
2018-04-28 15:27:12 +03:00
|
|
|
};
|