2018-04-30 21:41:47 +03:00
|
|
|
#pragma once
|
|
|
|
|
2018-08-29 16:00:07 +03:00
|
|
|
#include <QEvent>
|
2018-04-30 21:41:47 +03:00
|
|
|
#include <QFrame>
|
|
|
|
#include <QImage>
|
2018-09-08 12:29:49 +03:00
|
|
|
#include <QLabel>
|
2018-04-30 21:41:47 +03:00
|
|
|
|
|
|
|
#include "Cache.h"
|
|
|
|
|
2018-06-12 09:45:26 +03:00
|
|
|
class Avatar;
|
2018-04-30 21:41:47 +03:00
|
|
|
class FlatButton;
|
2018-09-19 22:42:26 +03:00
|
|
|
class QPushButton;
|
2018-06-12 09:45:26 +03:00
|
|
|
class QComboBox;
|
2018-05-16 23:30:50 +03:00
|
|
|
class QHBoxLayout;
|
2018-08-09 16:38:11 +03:00
|
|
|
class QShowEvent;
|
|
|
|
class LoadingIndicator;
|
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
|
|
|
|
2018-08-29 16:00:07 +03:00
|
|
|
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);
|
2018-09-07 12:24:09 +03:00
|
|
|
void nameEventSent(const QString &);
|
|
|
|
void topicEventSent();
|
2018-08-29 16:00:07 +03:00
|
|
|
};
|
|
|
|
|
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-09-08 12:29:49 +03:00
|
|
|
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();
|
|
|
|
|
2018-05-16 20:40:42 +03:00
|
|
|
private:
|
|
|
|
QString roomId_;
|
|
|
|
QString initialName_;
|
|
|
|
QString initialTopic_;
|
|
|
|
|
|
|
|
QLabel *errorField_;
|
|
|
|
|
|
|
|
TextField *nameInput_;
|
|
|
|
TextField *topicInput_;
|
|
|
|
|
2018-09-19 22:42:26 +03:00
|
|
|
QPushButton *applyBtn_;
|
|
|
|
QPushButton *cancelBtn_;
|
2018-05-16 20:40:42 +03:00
|
|
|
};
|
|
|
|
|
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:
|
2018-06-12 09:45:26 +03:00
|
|
|
void enableEncryptionError(const QString &msg);
|
2018-08-09 16:38:11 +03:00
|
|
|
void showErrorMessage(const QString &msg);
|
|
|
|
void accessRulesUpdated();
|
2018-04-30 21:41:47 +03:00
|
|
|
|
|
|
|
protected:
|
2018-08-09 16:38:11 +03:00
|
|
|
void showEvent(QShowEvent *event) override;
|
2018-05-13 01:31:58 +03:00
|
|
|
|
2018-08-29 16:15:31 +03:00
|
|
|
private slots:
|
|
|
|
//! The file dialog opens so the user can select and upload a new room avatar.
|
|
|
|
void updateAvatar();
|
|
|
|
|
2018-04-30 21:41:47 +03:00
|
|
|
private:
|
2018-08-09 16:38:11 +03:00
|
|
|
//! 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;
|
2018-08-29 16:00:07 +03:00
|
|
|
//! 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;
|
2018-08-09 16:38:11 +03:00
|
|
|
void updateAccessRules(const std::string &room_id,
|
|
|
|
const mtx::events::state::JoinRules &,
|
|
|
|
const mtx::events::state::GuestAccess &);
|
|
|
|
void stopLoadingSpinner();
|
|
|
|
void startLoadingSpinner();
|
|
|
|
void resetErrorLabel();
|
2018-08-29 16:00:07 +03:00
|
|
|
void displayErrorMessage(const QString &msg);
|
2018-04-30 21:41:47 +03:00
|
|
|
|
2018-08-29 16:00:07 +03:00
|
|
|
void setAvatar(const QImage &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-08-29 16:00:07 +03:00
|
|
|
Avatar *avatar_ = nullptr;
|
2018-07-22 15:41:06 +03:00
|
|
|
|
2018-06-12 09:45:26 +03:00
|
|
|
bool usesEncryption_ = false;
|
2018-07-22 15:41:06 +03:00
|
|
|
QHBoxLayout *btnLayout_;
|
2018-04-30 21:41:47 +03:00
|
|
|
|
2018-08-29 16:00:07 +03:00
|
|
|
FlatButton *editFieldsBtn_ = nullptr;
|
2018-05-16 20:40:42 +03:00
|
|
|
|
2018-04-30 21:41:47 +03:00
|
|
|
RoomInfo info_;
|
|
|
|
QString room_id_;
|
|
|
|
QImage avatarImg_;
|
2018-05-13 01:31:58 +03:00
|
|
|
|
2018-09-07 12:24:09 +03:00
|
|
|
QLabel *roomNameLabel_ = nullptr;
|
2018-08-29 16:00:07 +03:00
|
|
|
QLabel *errorLabel_ = nullptr;
|
|
|
|
LoadingIndicator *spinner_ = nullptr;
|
2018-08-09 16:38:11 +03:00
|
|
|
|
2018-08-29 16:00:07 +03:00
|
|
|
QComboBox *accessCombo = nullptr;
|
|
|
|
Toggle *encryptionToggle_ = nullptr;
|
|
|
|
Toggle *keyRequestsToggle_ = nullptr;
|
2018-04-30 21:41:47 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // dialogs
|