forked from mirror/nheko
React to externally left and joined rooms, and add "leave room" button in room menu (#75)
* Initial "join room" feature. * React correctly to remotely joined rooms. * Leaving rooms implemented both locally using the room menu in nheko, and reacting properly when leaving a room remotely from another client.remotes/origin/HEAD
parent
ea296321c9
commit
7ad45d8d64
@ -0,0 +1,22 @@ |
||||
#pragma once |
||||
|
||||
#include <QFrame> |
||||
#include <QLineEdit> |
||||
|
||||
#include "FlatButton.h" |
||||
|
||||
class JoinRoomDialog : public QFrame |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
JoinRoomDialog(QWidget *parent = nullptr); |
||||
|
||||
signals: |
||||
void closing(bool isJoining, QString roomAlias); |
||||
|
||||
private: |
||||
FlatButton *confirmBtn_; |
||||
FlatButton *cancelBtn_; |
||||
|
||||
QLineEdit *roomAliasEdit_; |
||||
}; |
@ -0,0 +1,19 @@ |
||||
#pragma once |
||||
|
||||
#include <QFrame> |
||||
|
||||
#include "FlatButton.h" |
||||
|
||||
class LeaveRoomDialog : public QFrame |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
explicit LeaveRoomDialog(QWidget *parent = nullptr); |
||||
|
||||
signals: |
||||
void closing(bool isLeaving); |
||||
|
||||
private: |
||||
FlatButton *confirmBtn_; |
||||
FlatButton *cancelBtn_; |
||||
}; |
@ -0,0 +1,49 @@ |
||||
#include <QLabel> |
||||
#include <QVBoxLayout> |
||||
|
||||
#include "Config.h" |
||||
#include "JoinRoomDialog.h" |
||||
#include "Theme.h" |
||||
|
||||
JoinRoomDialog::JoinRoomDialog(QWidget *parent) |
||||
: QFrame(parent) |
||||
{ |
||||
setMaximumSize(400, 400); |
||||
setStyleSheet("background-color: #fff"); |
||||
|
||||
auto layout = new QVBoxLayout(this); |
||||
layout->setSpacing(30); |
||||
layout->setMargin(20); |
||||
|
||||
auto buttonLayout = new QHBoxLayout(); |
||||
buttonLayout->setSpacing(0); |
||||
buttonLayout->setMargin(0); |
||||
|
||||
confirmBtn_ = new FlatButton("JOIN", this); |
||||
confirmBtn_->setFontSize(conf::btn::fontSize); |
||||
|
||||
cancelBtn_ = new FlatButton(tr("CANCEL"), this); |
||||
cancelBtn_->setFontSize(conf::btn::fontSize); |
||||
|
||||
buttonLayout->addStretch(1); |
||||
buttonLayout->addWidget(confirmBtn_); |
||||
buttonLayout->addWidget(cancelBtn_); |
||||
|
||||
QFont font; |
||||
font.setPixelSize(conf::headerFontSize); |
||||
|
||||
auto label = new QLabel(tr("Room alias to join:"), this); |
||||
label->setFont(font); |
||||
label->setStyleSheet("color: #333333"); |
||||
|
||||
roomAliasEdit_ = new QLineEdit(this); |
||||
|
||||
layout->addWidget(label); |
||||
layout->addWidget(roomAliasEdit_); |
||||
layout->addLayout(buttonLayout); |
||||
|
||||
connect(confirmBtn_, &QPushButton::clicked, [=]() { |
||||
emit closing(true, roomAliasEdit_->text()); |
||||
}); |
||||
connect(cancelBtn_, &QPushButton::clicked, [=]() { emit closing(false, nullptr); }); |
||||
} |
@ -0,0 +1,44 @@ |
||||
#include <QLabel> |
||||
#include <QVBoxLayout> |
||||
|
||||
#include "Config.h" |
||||
#include "LeaveRoomDialog.h" |
||||
#include "Theme.h" |
||||
|
||||
LeaveRoomDialog::LeaveRoomDialog(QWidget *parent) |
||||
: QFrame(parent) |
||||
{ |
||||
setMaximumSize(400, 400); |
||||
setStyleSheet("background-color: #fff"); |
||||
|
||||
auto layout = new QVBoxLayout(this); |
||||
layout->setSpacing(30); |
||||
layout->setMargin(20); |
||||
|
||||
auto buttonLayout = new QHBoxLayout(); |
||||
buttonLayout->setSpacing(0); |
||||
buttonLayout->setMargin(0); |
||||
|
||||
confirmBtn_ = new FlatButton("LEAVE", this); |
||||
confirmBtn_->setFontSize(conf::btn::fontSize); |
||||
|
||||
cancelBtn_ = new FlatButton(tr("CANCEL"), this); |
||||
cancelBtn_->setFontSize(conf::btn::fontSize); |
||||
|
||||
buttonLayout->addStretch(1); |
||||
buttonLayout->addWidget(confirmBtn_); |
||||
buttonLayout->addWidget(cancelBtn_); |
||||
|
||||
QFont font; |
||||
font.setPixelSize(conf::headerFontSize); |
||||
|
||||
auto label = new QLabel(tr("Are you sure you want to leave?"), this); |
||||
label->setFont(font); |
||||
label->setStyleSheet("color: #333333"); |
||||
|
||||
layout->addWidget(label); |
||||
layout->addLayout(buttonLayout); |
||||
|
||||
connect(confirmBtn_, &QPushButton::clicked, [=]() { emit closing(true); }); |
||||
connect(cancelBtn_, &QPushButton::clicked, [=]() { emit closing(false); }); |
||||
} |
Loading…
Reference in new issue