blob: 6667b68b931b3895b6752c0815b2ee3e45c4ac43 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
#pragma once
#include <QEvent>
#include <QFrame>
#include <QImage>
#include <QLabel>
#include "Cache.h"
class Avatar;
class FlatButton;
class QPushButton;
class QComboBox;
class QHBoxLayout;
class QShowEvent;
class LoadingIndicator;
class QLayout;
class QPixmap;
class TextField;
class TextField;
class Toggle;
class ClickableFilter : public QObject
{
Q_OBJECT
public:
explicit ClickableFilter(QWidget *parent)
: QObject(parent)
{}
signals:
void clicked();
protected:
bool eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::MouseButtonRelease) {
emit clicked();
return true;
}
return QObject::eventFilter(obj, event);
}
};
/// Convenience class which connects events emmited from threads
/// outside of main with the UI code.
class ThreadProxy : public QObject
{
Q_OBJECT
signals:
void error(const QString &msg);
void avatarChanged(const QImage &img);
void nameEventSent(const QString &);
void topicEventSent();
};
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);
private slots:
void topicEventSent()
{
errorField_->hide();
close();
}
void nameEventSent(const QString &name)
{
errorField_->hide();
emit nameChanged(name);
close();
}
void error(const QString &msg)
{
errorField_->setText(msg);
errorField_->show();
}
void applyClicked();
private:
QString roomId_;
QString initialName_;
QString initialTopic_;
QLabel *errorField_;
TextField *nameInput_;
TextField *topicInput_;
QPushButton *applyBtn_;
QPushButton *cancelBtn_;
};
namespace dialogs {
class RoomSettings : public QFrame
{
Q_OBJECT
public:
RoomSettings(const QString &room_id, QWidget *parent = nullptr);
signals:
void enableEncryptionError(const QString &msg);
void showErrorMessage(const QString &msg);
void accessRulesUpdated();
protected:
void showEvent(QShowEvent *event) override;
private slots:
//! The file dialog opens so the user can select and upload a new room avatar.
void updateAvatar();
private:
//! Whether the user has enough power level to send m.room.join_rules events.
bool canChangeJoinRules(const std::string &room_id, const std::string &user_id) const;
//! Whether the user has enough power level to send m.room.name & m.room.topic events.
bool canChangeNameAndTopic(const std::string &room_id, const std::string &user_id) const;
//! Whether the user has enough power level to send m.room.avatar event.
bool canChangeAvatar(const std::string &room_id, const std::string &user_id) const;
void updateAccessRules(const std::string &room_id,
const mtx::events::state::JoinRules &,
const mtx::events::state::GuestAccess &);
void stopLoadingSpinner();
void startLoadingSpinner();
void resetErrorLabel();
void displayErrorMessage(const QString &msg);
void setAvatar(const QImage &img);
void setupEditButton();
//! Retrieve the current room information from cache.
void retrieveRoomInfo();
void enableEncryption();
Avatar *avatar_ = nullptr;
bool usesEncryption_ = false;
QHBoxLayout *btnLayout_;
FlatButton *editFieldsBtn_ = nullptr;
RoomInfo info_;
QString room_id_;
QImage avatarImg_;
QLabel *roomNameLabel_ = nullptr;
QLabel *errorLabel_ = nullptr;
LoadingIndicator *spinner_ = nullptr;
QComboBox *accessCombo = nullptr;
Toggle *encryptionToggle_ = nullptr;
Toggle *keyRequestsToggle_ = nullptr;
};
} // dialogs
|