Add gui option for joining rooms (#25)
This commit is contained in:
parent
bba3bba55a
commit
19bae2a2e6
@ -1,10 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <QAction>
|
||||
#include <QHBoxLayout>
|
||||
#include <QResizeEvent>
|
||||
#include <QWidget>
|
||||
|
||||
#include "FlatButton.h"
|
||||
#include "Menu.h"
|
||||
|
||||
#include "dialogs/JoinRoom.h"
|
||||
|
||||
class OverlayModal;
|
||||
|
||||
class SideBarActions : public QWidget
|
||||
{
|
||||
@ -16,6 +22,7 @@ public:
|
||||
|
||||
signals:
|
||||
void showSettings();
|
||||
void joinRoom(const QString &room);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
@ -23,6 +30,13 @@ protected:
|
||||
private:
|
||||
QHBoxLayout *layout_;
|
||||
|
||||
Menu *addMenu_;
|
||||
QAction *createRoomAction_;
|
||||
QAction *joinRoomAction_;
|
||||
|
||||
QSharedPointer<OverlayModal> joinRoomModal_;
|
||||
QSharedPointer<dialogs::JoinRoom> joinRoomDialog_;
|
||||
|
||||
FlatButton *settingsBtn_;
|
||||
FlatButton *createRoomBtn_;
|
||||
FlatButton *joinRoomBtn_;
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
#include <QLineEdit>
|
||||
|
||||
class FlatButton;
|
||||
class TextField;
|
||||
|
||||
namespace dialogs {
|
||||
|
||||
@ -14,13 +14,16 @@ public:
|
||||
JoinRoom(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void closing(bool isJoining, QString roomAlias);
|
||||
void closing(bool isJoining, const QString &room);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
FlatButton *confirmBtn_;
|
||||
FlatButton *cancelBtn_;
|
||||
|
||||
QLineEdit *roomAliasEdit_;
|
||||
TextField *roomInput_;
|
||||
};
|
||||
|
||||
} // dialogs
|
||||
|
@ -17,6 +17,7 @@ class TextField : public QLineEdit
|
||||
|
||||
Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor)
|
||||
Q_PROPERTY(QColor inkColor WRITE setInkColor READ inkColor)
|
||||
Q_PROPERTY(QColor labelColor WRITE setLabelColor READ labelColor)
|
||||
Q_PROPERTY(QColor underlineColor WRITE setUnderlineColor READ underlineColor)
|
||||
Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor)
|
||||
|
||||
|
@ -78,7 +78,8 @@ Avatar {
|
||||
}
|
||||
|
||||
dialogs--Logout,
|
||||
dialogs--LeaveRoom {
|
||||
dialogs--LeaveRoom,
|
||||
dialogs--JoinRoom {
|
||||
background-color: #383c4a;
|
||||
color: #caccd1;
|
||||
}
|
||||
@ -110,6 +111,7 @@ FloatingButton {
|
||||
TextField {
|
||||
qproperty-backgroundColor: #383c4e;
|
||||
qproperty-inkColor: #caccd1;
|
||||
qproperty-labelColor: #caccd1;
|
||||
}
|
||||
|
||||
QLineEdit,
|
||||
|
@ -80,7 +80,8 @@ Avatar {
|
||||
}
|
||||
|
||||
dialogs--Logout,
|
||||
dialogs--LeaveRoom {
|
||||
dialogs--LeaveRoom,
|
||||
dialogs--JoinRoom {
|
||||
background-color: white;
|
||||
color: #333;
|
||||
}
|
||||
@ -109,6 +110,12 @@ FloatingButton {
|
||||
qproperty-foregroundColor: black;
|
||||
}
|
||||
|
||||
TextField {
|
||||
qproperty-backgroundColor: white;
|
||||
qproperty-inkColor: #333;
|
||||
qproperty-labelColor: #333;
|
||||
}
|
||||
|
||||
ScrollBar {
|
||||
qproperty-handleColor: #ccc;
|
||||
qproperty-backgroundColor: #efefef;
|
||||
|
@ -68,6 +68,8 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent)
|
||||
sidebarActions_ = new SideBarActions(this);
|
||||
connect(
|
||||
sidebarActions_, &SideBarActions::showSettings, this, &ChatPage::showUserSettingsPage);
|
||||
connect(
|
||||
sidebarActions_, &SideBarActions::joinRoom, client_.data(), &MatrixClient::joinRoom);
|
||||
|
||||
user_info_widget_ = new UserInfoWidget(sideBar_);
|
||||
room_list_ = new RoomList(client, sideBar_);
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include <QIcon>
|
||||
|
||||
#include "Config.h"
|
||||
#include "MainWindow.h"
|
||||
#include "OverlayModal.h"
|
||||
#include "SideBarActions.h"
|
||||
#include "Theme.h"
|
||||
|
||||
@ -27,12 +29,53 @@ SideBarActions::SideBarActions(QWidget *parent)
|
||||
settingsBtn_->setIconSize(
|
||||
QSize(conf::sidebarActions::iconSize, conf::sidebarActions::iconSize));
|
||||
|
||||
addMenu_ = new Menu(this);
|
||||
createRoomAction_ = new QAction(tr("Create new room"), this);
|
||||
joinRoomAction_ = new QAction(tr("Join a room"), this);
|
||||
|
||||
connect(joinRoomAction_, &QAction::triggered, this, [=]() {
|
||||
if (joinRoomDialog_.isNull()) {
|
||||
joinRoomDialog_ =
|
||||
QSharedPointer<dialogs::JoinRoom>(new dialogs::JoinRoom(this));
|
||||
|
||||
connect(joinRoomDialog_.data(),
|
||||
&dialogs::JoinRoom::closing,
|
||||
this,
|
||||
[=](bool isJoining, const QString &room) {
|
||||
joinRoomModal_->fadeOut();
|
||||
|
||||
if (isJoining && !room.isEmpty())
|
||||
emit joinRoom(room);
|
||||
});
|
||||
}
|
||||
|
||||
if (joinRoomModal_.isNull()) {
|
||||
joinRoomModal_ = QSharedPointer<OverlayModal>(
|
||||
new OverlayModal(MainWindow::instance(), joinRoomDialog_.data()));
|
||||
joinRoomModal_->setDuration(0);
|
||||
joinRoomModal_->setColor(QColor(30, 30, 30, 170));
|
||||
}
|
||||
|
||||
joinRoomModal_->fadeIn();
|
||||
});
|
||||
|
||||
addMenu_->addAction(createRoomAction_);
|
||||
addMenu_->addAction(joinRoomAction_);
|
||||
|
||||
createRoomBtn_ = new FlatButton(this);
|
||||
createRoomBtn_->setIcon(createRoomIcon);
|
||||
createRoomBtn_->setCornerRadius(conf::sidebarActions::iconSize / 2);
|
||||
createRoomBtn_->setIconSize(
|
||||
QSize(conf::sidebarActions::iconSize, conf::sidebarActions::iconSize));
|
||||
|
||||
connect(createRoomBtn_, &QPushButton::clicked, this, [=]() {
|
||||
auto pos = mapToGlobal(createRoomBtn_->pos());
|
||||
auto padding = conf::sidebarActions::iconSize / 2;
|
||||
|
||||
addMenu_->popup(
|
||||
QPoint(pos.x() + padding, pos.y() - padding - addMenu_->sizeHint().height()));
|
||||
});
|
||||
|
||||
joinRoomBtn_ = new FlatButton(this);
|
||||
joinRoomBtn_->setIcon(joinRoomIcon);
|
||||
joinRoomBtn_->setCornerRadius(conf::sidebarActions::iconSize / 2);
|
||||
|
@ -1,8 +1,10 @@
|
||||
#include <QLabel>
|
||||
#include <QStyleOption>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "Config.h"
|
||||
#include "FlatButton.h"
|
||||
#include "TextField.h"
|
||||
#include "Theme.h"
|
||||
|
||||
#include "dialogs/JoinRoom.h"
|
||||
@ -35,17 +37,25 @@ JoinRoom::JoinRoom(QWidget *parent)
|
||||
QFont font;
|
||||
font.setPixelSize(conf::headerFontSize);
|
||||
|
||||
auto label = new QLabel(tr("Room alias to join:"), this);
|
||||
label->setFont(font);
|
||||
roomInput_ = new TextField(this);
|
||||
roomInput_->setLabel(tr("Room ID or alias"));
|
||||
|
||||
roomAliasEdit_ = new QLineEdit(this);
|
||||
|
||||
layout->addWidget(label);
|
||||
layout->addWidget(roomAliasEdit_);
|
||||
layout->addWidget(roomInput_);
|
||||
layout->addLayout(buttonLayout);
|
||||
|
||||
// TODO: input validation with error messages.
|
||||
connect(confirmBtn_, &QPushButton::clicked, [=]() {
|
||||
emit closing(true, roomAliasEdit_->text());
|
||||
emit closing(true, roomInput_->text());
|
||||
roomInput_->clear();
|
||||
});
|
||||
connect(cancelBtn_, &QPushButton::clicked, [=]() { emit closing(false, nullptr); });
|
||||
connect(cancelBtn_, &QPushButton::clicked, [=]() { emit closing(false, ""); });
|
||||
}
|
||||
|
||||
void
|
||||
JoinRoom::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
}
|
||||
|
@ -127,6 +127,7 @@ void
|
||||
TextField::setLabelColor(const QColor &color)
|
||||
{
|
||||
label_color_ = color;
|
||||
update();
|
||||
}
|
||||
|
||||
QColor
|
||||
@ -143,6 +144,7 @@ void
|
||||
TextField::setInkColor(const QColor &color)
|
||||
{
|
||||
ink_color_ = color;
|
||||
update();
|
||||
}
|
||||
|
||||
QColor
|
||||
@ -159,6 +161,7 @@ void
|
||||
TextField::setUnderlineColor(const QColor &color)
|
||||
{
|
||||
underline_color_ = color;
|
||||
update();
|
||||
}
|
||||
|
||||
QColor
|
||||
|
Loading…
Reference in New Issue
Block a user