Add prototype room settings menu
This commit is contained in:
parent
21c68c5824
commit
3097037c3d
14 changed files with 309 additions and 12 deletions
|
|
@ -64,6 +64,8 @@ struct RoomInfo
|
|||
std::string avatar_url;
|
||||
//! Whether or not the room is an invite.
|
||||
bool is_invite = false;
|
||||
//! Total number of members in the room.
|
||||
int16_t member_count = 0;
|
||||
};
|
||||
|
||||
inline void
|
||||
|
|
@ -73,6 +75,9 @@ to_json(json &j, const RoomInfo &info)
|
|||
j["topic"] = info.topic;
|
||||
j["avatar_url"] = info.avatar_url;
|
||||
j["is_invite"] = info.is_invite;
|
||||
|
||||
if (info.member_count != 0)
|
||||
j["member_count"] = info.member_count;
|
||||
}
|
||||
|
||||
inline void
|
||||
|
|
@ -82,6 +87,9 @@ from_json(const json &j, RoomInfo &info)
|
|||
info.topic = j.at("topic");
|
||||
info.avatar_url = j.at("avatar_url");
|
||||
info.is_invite = j.at("is_invite");
|
||||
|
||||
if (j.count("member_count"))
|
||||
info.member_count = j.at("member_count");
|
||||
}
|
||||
|
||||
//! Basic information per member;
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ public:
|
|||
}
|
||||
|
||||
QSharedPointer<UserSettings> userSettings() { return userSettings_; }
|
||||
QSharedPointer<Cache> cache() { return cache_; }
|
||||
|
||||
signals:
|
||||
void contentLoaded();
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ class JoinRoom;
|
|||
class LeaveRoom;
|
||||
class Logout;
|
||||
class ReCaptcha;
|
||||
class RoomSettings;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
|
|
@ -68,6 +69,7 @@ public:
|
|||
std::function<void(const mtx::requests::CreateRoom &request)> callback);
|
||||
void openJoinRoomDialog(std::function<void(const QString &room_id)> callback);
|
||||
void openLogoutDialog(std::function<void()> callback);
|
||||
void openRoomSettings(const QString &room_id = "");
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
|
@ -147,4 +149,8 @@ private:
|
|||
QSharedPointer<OverlayModal> logoutModal_;
|
||||
//! Logout dialog.
|
||||
QSharedPointer<dialogs::Logout> logoutDialog_;
|
||||
//! Room settings modal.
|
||||
QSharedPointer<OverlayModal> roomSettingsModal_;
|
||||
//! Room settings dialog.
|
||||
QSharedPointer<dialogs::RoomSettings> roomSettingsDialog_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
#include <QIcon>
|
||||
#include <QImage>
|
||||
#include <QLabel>
|
||||
#include <QMenu>
|
||||
#include <QPaintEvent>
|
||||
#include <QSharedPointer>
|
||||
#include <QVBoxLayout>
|
||||
|
|
@ -66,8 +65,9 @@ private:
|
|||
QLabel *nameLabel_;
|
||||
Label *topicLabel_;
|
||||
|
||||
QMenu *menu_;
|
||||
Menu *menu_;
|
||||
QAction *leaveRoom_;
|
||||
QAction *roomSettings_;
|
||||
QAction *inviteUsers_;
|
||||
|
||||
FlatButton *settingsBtn_;
|
||||
|
|
|
|||
88
include/dialogs/RoomSettings.hpp
Normal file
88
include/dialogs/RoomSettings.hpp
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
#include <QImage>
|
||||
|
||||
#include "Cache.h"
|
||||
|
||||
class FlatButton;
|
||||
class TextField;
|
||||
class Avatar;
|
||||
class QPixmap;
|
||||
class QLayout;
|
||||
class QLabel;
|
||||
|
||||
template<class T>
|
||||
class QSharedPointer;
|
||||
|
||||
class TopSection : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor)
|
||||
|
||||
public:
|
||||
TopSection(const RoomInfo &info, const QImage &img, QWidget *parent = nullptr)
|
||||
: QWidget{parent}
|
||||
, info_{std::move(info)}
|
||||
{
|
||||
textColor_ = palette().color(QPalette::Text);
|
||||
avatar_ = QPixmap::fromImage(img.scaled(
|
||||
AvatarSize, AvatarSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||
}
|
||||
|
||||
QSize sizeHint() const override
|
||||
{
|
||||
QFont font;
|
||||
font.setPixelSize(18);
|
||||
return QSize(200, AvatarSize + QFontMetrics(font).ascent() + 6 * Padding);
|
||||
}
|
||||
|
||||
QColor textColor() const { return textColor_; }
|
||||
void setTextColor(QColor &color) { textColor_ = color; }
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
static constexpr int AvatarSize = 72;
|
||||
static constexpr int Padding = 5;
|
||||
|
||||
RoomInfo info_;
|
||||
QPixmap avatar_;
|
||||
QColor textColor_;
|
||||
};
|
||||
|
||||
namespace dialogs {
|
||||
|
||||
class RoomSettings : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RoomSettings(const QString &room_id,
|
||||
QSharedPointer<Cache> cache,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void closing();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
static constexpr int AvatarSize = 64;
|
||||
|
||||
void setAvatar(const QImage &img) { avatarImg_ = img; }
|
||||
|
||||
QSharedPointer<Cache> cache_;
|
||||
|
||||
// Button section
|
||||
FlatButton *saveBtn_;
|
||||
FlatButton *cancelBtn_;
|
||||
|
||||
RoomInfo info_;
|
||||
QString room_id_;
|
||||
QImage avatarImg_;
|
||||
};
|
||||
|
||||
} // dialogs
|
||||
|
|
@ -103,7 +103,7 @@ public:
|
|||
drawPixmap(region, pix);
|
||||
}
|
||||
|
||||
void drawLetterAvatar(const QChar &c,
|
||||
void drawLetterAvatar(const QString &c,
|
||||
const QColor &penColor,
|
||||
const QColor &brushColor,
|
||||
int w,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue