2018-04-30 21:41:47 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QFrame>
|
|
|
|
#include <QImage>
|
|
|
|
|
|
|
|
#include "Cache.h"
|
|
|
|
|
2018-06-12 09:45:26 +03:00
|
|
|
class Avatar;
|
2018-04-30 21:41:47 +03:00
|
|
|
class FlatButton;
|
2018-06-12 09:45:26 +03:00
|
|
|
class QComboBox;
|
2018-05-16 23:30:50 +03:00
|
|
|
class QHBoxLayout;
|
2018-04-30 21:41:47 +03:00
|
|
|
class QLabel;
|
2018-05-16 20:40:42 +03:00
|
|
|
class QLabel;
|
2018-06-12 09:45:26 +03:00
|
|
|
class QLayout;
|
|
|
|
class QPixmap;
|
|
|
|
class TextField;
|
|
|
|
class TextField;
|
|
|
|
class Toggle;
|
2018-04-30 21:41:47 +03:00
|
|
|
|
|
|
|
template<class T>
|
|
|
|
class QSharedPointer;
|
|
|
|
|
2018-05-16 20:40:42 +03:00
|
|
|
class EditModal : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
EditModal(const QString &roomId, QWidget *parent = nullptr);
|
|
|
|
|
|
|
|
void setFields(const QString &roomName, const QString &roomTopic);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void nameChanged(const QString &roomName);
|
2018-06-09 16:03:14 +03:00
|
|
|
void nameEventSentCb(const QString &newName);
|
|
|
|
void topicEventSentCb();
|
|
|
|
void stateEventErrorCb(const QString &msg);
|
2018-05-16 20:40:42 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
QString roomId_;
|
|
|
|
QString initialName_;
|
|
|
|
QString initialTopic_;
|
|
|
|
|
|
|
|
QLabel *errorField_;
|
|
|
|
|
|
|
|
TextField *nameInput_;
|
|
|
|
TextField *topicInput_;
|
|
|
|
|
|
|
|
FlatButton *applyBtn_;
|
|
|
|
FlatButton *cancelBtn_;
|
|
|
|
};
|
|
|
|
|
2018-04-30 21:41:47 +03:00
|
|
|
namespace dialogs {
|
|
|
|
|
|
|
|
class RoomSettings : public QFrame
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-05-08 20:30:09 +03:00
|
|
|
RoomSettings(const QString &room_id, QWidget *parent = nullptr);
|
2018-04-30 21:41:47 +03:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void closing();
|
2018-06-12 09:45:26 +03:00
|
|
|
void enableEncryptionError(const QString &msg);
|
2018-04-30 21:41:47 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *event) override;
|
|
|
|
|
2018-05-13 01:31:58 +03:00
|
|
|
private slots:
|
2018-05-16 20:40:42 +03:00
|
|
|
void saveSettings();
|
2018-05-13 01:31:58 +03:00
|
|
|
|
2018-04-30 21:41:47 +03:00
|
|
|
private:
|
|
|
|
static constexpr int AvatarSize = 64;
|
|
|
|
|
|
|
|
void setAvatar(const QImage &img) { avatarImg_ = img; }
|
2018-05-16 23:30:50 +03:00
|
|
|
void setupEditButton();
|
2018-05-18 21:43:58 +03:00
|
|
|
//! Retrieve the current room information from cache.
|
|
|
|
void retrieveRoomInfo();
|
2018-06-12 09:45:26 +03:00
|
|
|
void enableEncryption();
|
2018-05-16 23:30:50 +03:00
|
|
|
|
2018-07-22 15:41:06 +03:00
|
|
|
Avatar *avatar_;
|
|
|
|
|
2018-05-16 23:30:50 +03:00
|
|
|
//! Whether the user would be able to change the name or the topic of the room.
|
2018-06-12 09:45:26 +03:00
|
|
|
bool hasEditRights_ = true;
|
|
|
|
bool usesEncryption_ = false;
|
2018-07-22 15:41:06 +03:00
|
|
|
QHBoxLayout *btnLayout_;
|
2018-04-30 21:41:47 +03:00
|
|
|
|
2018-05-16 20:40:42 +03:00
|
|
|
FlatButton *editFieldsBtn_;
|
|
|
|
|
2018-04-30 21:41:47 +03:00
|
|
|
RoomInfo info_;
|
|
|
|
QString room_id_;
|
|
|
|
QImage avatarImg_;
|
2018-05-13 01:31:58 +03:00
|
|
|
|
|
|
|
QComboBox *accessCombo;
|
2018-06-12 09:45:26 +03:00
|
|
|
Toggle *encryptionToggle_;
|
2018-07-22 16:36:25 +03:00
|
|
|
Toggle *keyRequestsToggle_;
|
2018-04-30 21:41:47 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // dialogs
|