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