mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 14:18:49 +03:00
parent
47c31b9a18
commit
b15a04b00a
8 changed files with 165 additions and 118 deletions
|
@ -35,8 +35,18 @@ class SnackBar;
|
||||||
class TrayIcon;
|
class TrayIcon;
|
||||||
class UserSettings;
|
class UserSettings;
|
||||||
|
|
||||||
|
namespace mtx {
|
||||||
|
namespace requests {
|
||||||
|
struct CreateRoom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace dialogs {
|
namespace dialogs {
|
||||||
|
class CreateRoom;
|
||||||
|
class InviteUsers;
|
||||||
|
class JoinRoom;
|
||||||
class LeaveRoom;
|
class LeaveRoom;
|
||||||
|
class Logout;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
|
@ -50,6 +60,11 @@ public:
|
||||||
void saveCurrentWindowSize();
|
void saveCurrentWindowSize();
|
||||||
|
|
||||||
void openLeaveRoomDialog(const QString &room_id = "");
|
void openLeaveRoomDialog(const QString &room_id = "");
|
||||||
|
void openInviteUsersDialog(std::function<void(const QStringList &invitees)> callback);
|
||||||
|
void openCreateRoomDialog(
|
||||||
|
std::function<void(const mtx::requests::CreateRoom &request)> callback);
|
||||||
|
void openJoinRoomDialog(std::function<void(const QString &room_id)> callback);
|
||||||
|
void openLogoutDialog(std::function<void()> callback);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
@ -113,4 +128,20 @@ private:
|
||||||
QSharedPointer<OverlayModal> leaveRoomModal_;
|
QSharedPointer<OverlayModal> leaveRoomModal_;
|
||||||
//! Leave room dialog.
|
//! Leave room dialog.
|
||||||
QSharedPointer<dialogs::LeaveRoom> leaveRoomDialog_;
|
QSharedPointer<dialogs::LeaveRoom> leaveRoomDialog_;
|
||||||
|
//! Invite users modal.
|
||||||
|
QSharedPointer<OverlayModal> inviteUsersModal_;
|
||||||
|
//! Invite users dialog.
|
||||||
|
QSharedPointer<dialogs::InviteUsers> inviteUsersDialog_;
|
||||||
|
//! Join room modal.
|
||||||
|
QSharedPointer<OverlayModal> joinRoomModal_;
|
||||||
|
//! Join room dialog.
|
||||||
|
QSharedPointer<dialogs::JoinRoom> joinRoomDialog_;
|
||||||
|
//! Create room modal.
|
||||||
|
QSharedPointer<OverlayModal> createRoomModal_;
|
||||||
|
//! Create room dialog.
|
||||||
|
QSharedPointer<dialogs::CreateRoom> createRoomDialog_;
|
||||||
|
//! Logout modal.
|
||||||
|
QSharedPointer<OverlayModal> logoutModal_;
|
||||||
|
//! Logout dialog.
|
||||||
|
QSharedPointer<dialogs::Logout> logoutDialog_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,10 +8,11 @@
|
||||||
#include "FlatButton.h"
|
#include "FlatButton.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
|
|
||||||
#include "dialogs/CreateRoom.h"
|
namespace mtx {
|
||||||
#include "dialogs/JoinRoom.h"
|
namespace requests {
|
||||||
|
struct CreateRoom;
|
||||||
class OverlayModal;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class SideBarActions : public QWidget
|
class SideBarActions : public QWidget
|
||||||
{
|
{
|
||||||
|
@ -36,12 +37,6 @@ private:
|
||||||
QAction *createRoomAction_;
|
QAction *createRoomAction_;
|
||||||
QAction *joinRoomAction_;
|
QAction *joinRoomAction_;
|
||||||
|
|
||||||
QSharedPointer<OverlayModal> joinRoomModal_;
|
|
||||||
QSharedPointer<dialogs::JoinRoom> joinRoomDialog_;
|
|
||||||
|
|
||||||
QSharedPointer<OverlayModal> createRoomModal_;
|
|
||||||
QSharedPointer<dialogs::CreateRoom> createRoomDialog_;
|
|
||||||
|
|
||||||
FlatButton *settingsBtn_;
|
FlatButton *settingsBtn_;
|
||||||
FlatButton *createRoomBtn_;
|
FlatButton *createRoomBtn_;
|
||||||
FlatButton *joinRoomBtn_;
|
FlatButton *joinRoomBtn_;
|
||||||
|
|
|
@ -26,9 +26,6 @@
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include "dialogs/InviteUsers.h"
|
|
||||||
#include "dialogs/LeaveRoom.h"
|
|
||||||
|
|
||||||
class Avatar;
|
class Avatar;
|
||||||
class FlatButton;
|
class FlatButton;
|
||||||
class Label;
|
class Label;
|
||||||
|
@ -74,9 +71,6 @@ private:
|
||||||
|
|
||||||
FlatButton *settingsBtn_;
|
FlatButton *settingsBtn_;
|
||||||
|
|
||||||
QSharedPointer<OverlayModal> inviteUsersModal_;
|
|
||||||
QSharedPointer<dialogs::InviteUsers> inviteUsersDialog_;
|
|
||||||
|
|
||||||
Avatar *avatar_;
|
Avatar *avatar_;
|
||||||
|
|
||||||
int buttonSize_;
|
int buttonSize_;
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
|
|
||||||
#include "dialogs/Logout.h"
|
|
||||||
|
|
||||||
class Avatar;
|
class Avatar;
|
||||||
class FlatButton;
|
class FlatButton;
|
||||||
class OverlayModal;
|
class OverlayModal;
|
||||||
|
@ -46,9 +44,6 @@ protected:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
|
|
||||||
private slots:
|
|
||||||
void closeLogoutDialog(bool isLoggingOut);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Avatar *userAvatar_;
|
Avatar *userAvatar_;
|
||||||
|
|
||||||
|
@ -67,8 +62,5 @@ private:
|
||||||
|
|
||||||
QImage avatar_image_;
|
QImage avatar_image_;
|
||||||
|
|
||||||
QSharedPointer<OverlayModal> logoutModal_;
|
|
||||||
QSharedPointer<dialogs::Logout> logoutDialog_;
|
|
||||||
|
|
||||||
int logoutButtonSize_;
|
int logoutButtonSize_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
|
||||||
|
#include <mtx/requests.hpp>
|
||||||
|
|
||||||
#include "ChatPage.h"
|
#include "ChatPage.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "LoadingIndicator.h"
|
#include "LoadingIndicator.h"
|
||||||
|
@ -33,7 +35,12 @@
|
||||||
#include "TrayIcon.h"
|
#include "TrayIcon.h"
|
||||||
#include "UserSettingsPage.h"
|
#include "UserSettingsPage.h"
|
||||||
#include "WelcomePage.h"
|
#include "WelcomePage.h"
|
||||||
|
|
||||||
|
#include "dialogs/CreateRoom.h"
|
||||||
|
#include "dialogs/InviteUsers.h"
|
||||||
|
#include "dialogs/JoinRoom.h"
|
||||||
#include "dialogs/LeaveRoom.h"
|
#include "dialogs/LeaveRoom.h"
|
||||||
|
#include "dialogs/Logout.h"
|
||||||
|
|
||||||
MainWindow *MainWindow::instance_ = nullptr;
|
MainWindow *MainWindow::instance_ = nullptr;
|
||||||
|
|
||||||
|
@ -255,7 +262,7 @@ MainWindow::openLeaveRoomDialog(const QString &room_id)
|
||||||
connect(leaveRoomDialog_.data(),
|
connect(leaveRoomDialog_.data(),
|
||||||
&dialogs::LeaveRoom::closing,
|
&dialogs::LeaveRoom::closing,
|
||||||
this,
|
this,
|
||||||
[this, &roomToLeave](bool leaving) {
|
[this, roomToLeave](bool leaving) {
|
||||||
leaveRoomModal_->hide();
|
leaveRoomModal_->hide();
|
||||||
|
|
||||||
if (leaving)
|
if (leaving)
|
||||||
|
@ -291,9 +298,120 @@ MainWindow::showOverlayProgressBar()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MainWindow::openInviteUsersDialog(std::function<void(const QStringList &invitees)> callback)
|
||||||
|
{
|
||||||
|
if (inviteUsersDialog_.isNull()) {
|
||||||
|
inviteUsersDialog_ =
|
||||||
|
QSharedPointer<dialogs::InviteUsers>(new dialogs::InviteUsers(this));
|
||||||
|
|
||||||
|
connect(inviteUsersDialog_.data(),
|
||||||
|
&dialogs::InviteUsers::closing,
|
||||||
|
this,
|
||||||
|
[this, callback](bool isSending, QStringList invitees) {
|
||||||
|
inviteUsersModal_->hide();
|
||||||
|
|
||||||
|
if (isSending && !invitees.isEmpty())
|
||||||
|
callback(invitees);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inviteUsersModal_.isNull()) {
|
||||||
|
inviteUsersModal_ = QSharedPointer<OverlayModal>(
|
||||||
|
new OverlayModal(MainWindow::instance(), inviteUsersDialog_.data()));
|
||||||
|
inviteUsersModal_->setColor(QColor(30, 30, 30, 170));
|
||||||
|
}
|
||||||
|
|
||||||
|
inviteUsersModal_->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MainWindow::openJoinRoomDialog(std::function<void(const QString &room_id)> callback)
|
||||||
|
{
|
||||||
|
if (joinRoomDialog_.isNull()) {
|
||||||
|
joinRoomDialog_ = QSharedPointer<dialogs::JoinRoom>(new dialogs::JoinRoom(this));
|
||||||
|
|
||||||
|
connect(joinRoomDialog_.data(),
|
||||||
|
&dialogs::JoinRoom::closing,
|
||||||
|
this,
|
||||||
|
[this, callback](bool isJoining, const QString &room) {
|
||||||
|
joinRoomModal_->hide();
|
||||||
|
|
||||||
|
if (isJoining && !room.isEmpty())
|
||||||
|
callback(room);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (joinRoomModal_.isNull()) {
|
||||||
|
joinRoomModal_ = QSharedPointer<OverlayModal>(
|
||||||
|
new OverlayModal(MainWindow::instance(), joinRoomDialog_.data()));
|
||||||
|
joinRoomModal_->setColor(QColor(30, 30, 30, 170));
|
||||||
|
}
|
||||||
|
|
||||||
|
joinRoomModal_->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MainWindow::openCreateRoomDialog(
|
||||||
|
std::function<void(const mtx::requests::CreateRoom &request)> callback)
|
||||||
|
{
|
||||||
|
if (createRoomDialog_.isNull()) {
|
||||||
|
createRoomDialog_ =
|
||||||
|
QSharedPointer<dialogs::CreateRoom>(new dialogs::CreateRoom(this));
|
||||||
|
|
||||||
|
connect(
|
||||||
|
createRoomDialog_.data(),
|
||||||
|
&dialogs::CreateRoom::closing,
|
||||||
|
this,
|
||||||
|
[this, callback](bool isCreating, const mtx::requests::CreateRoom &request) {
|
||||||
|
createRoomModal_->hide();
|
||||||
|
|
||||||
|
if (isCreating)
|
||||||
|
callback(request);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (createRoomModal_.isNull()) {
|
||||||
|
createRoomModal_ = QSharedPointer<OverlayModal>(
|
||||||
|
new OverlayModal(MainWindow::instance(), createRoomDialog_.data()));
|
||||||
|
createRoomModal_->setColor(QColor(30, 30, 30, 170));
|
||||||
|
}
|
||||||
|
|
||||||
|
createRoomModal_->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MainWindow::openLogoutDialog(std::function<void()> callback)
|
||||||
|
{
|
||||||
|
if (logoutDialog_.isNull()) {
|
||||||
|
logoutDialog_ = QSharedPointer<dialogs::Logout>(new dialogs::Logout(this));
|
||||||
|
connect(logoutDialog_.data(),
|
||||||
|
&dialogs::Logout::closing,
|
||||||
|
this,
|
||||||
|
[this, callback](bool logging_out) {
|
||||||
|
logoutModal_->hide();
|
||||||
|
|
||||||
|
if (logging_out)
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (logoutModal_.isNull()) {
|
||||||
|
logoutModal_ = QSharedPointer<OverlayModal>(
|
||||||
|
new OverlayModal(MainWindow::instance(), logoutDialog_.data()));
|
||||||
|
logoutModal_->setColor(QColor(30, 30, 30, 170));
|
||||||
|
}
|
||||||
|
|
||||||
|
logoutModal_->show();
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MainWindow::hasActiveDialogs() const
|
MainWindow::hasActiveDialogs() const
|
||||||
{
|
{
|
||||||
return (!leaveRoomModal_.isNull() && leaveRoomModal_->isVisible()) ||
|
return (!leaveRoomModal_.isNull() && leaveRoomModal_->isVisible()) ||
|
||||||
(!progressModal_.isNull() && progressModal_->isVisible());
|
(!progressModal_.isNull() && progressModal_->isVisible()) ||
|
||||||
|
(!inviteUsersModal_.isNull() && inviteUsersModal_->isVisible()) ||
|
||||||
|
(!joinRoomModal_.isNull() && joinRoomModal_->isVisible()) ||
|
||||||
|
(!createRoomModal_.isNull() && createRoomModal_->isVisible()) ||
|
||||||
|
(!logoutModal_.isNull() && logoutModal_->isVisible());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
|
#include <mtx/requests.hpp>
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "OverlayModal.h"
|
#include "OverlayModal.h"
|
||||||
|
@ -35,53 +37,13 @@ SideBarActions::SideBarActions(QWidget *parent)
|
||||||
joinRoomAction_ = new QAction(tr("Join a room"), this);
|
joinRoomAction_ = new QAction(tr("Join a room"), this);
|
||||||
|
|
||||||
connect(joinRoomAction_, &QAction::triggered, this, [this]() {
|
connect(joinRoomAction_, &QAction::triggered, this, [this]() {
|
||||||
if (joinRoomDialog_.isNull()) {
|
MainWindow::instance()->openJoinRoomDialog(
|
||||||
joinRoomDialog_ =
|
[this](const QString &room_id) { emit joinRoom(room_id); });
|
||||||
QSharedPointer<dialogs::JoinRoom>(new dialogs::JoinRoom(this));
|
|
||||||
|
|
||||||
connect(joinRoomDialog_.data(),
|
|
||||||
&dialogs::JoinRoom::closing,
|
|
||||||
this,
|
|
||||||
[this](bool isJoining, const QString &room) {
|
|
||||||
joinRoomModal_->hide();
|
|
||||||
|
|
||||||
if (isJoining && !room.isEmpty())
|
|
||||||
emit joinRoom(room);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (joinRoomModal_.isNull()) {
|
|
||||||
joinRoomModal_ = QSharedPointer<OverlayModal>(
|
|
||||||
new OverlayModal(MainWindow::instance(), joinRoomDialog_.data()));
|
|
||||||
joinRoomModal_->setColor(QColor(30, 30, 30, 170));
|
|
||||||
}
|
|
||||||
|
|
||||||
joinRoomModal_->show();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(createRoomAction_, &QAction::triggered, this, [this]() {
|
connect(createRoomAction_, &QAction::triggered, this, [this]() {
|
||||||
if (createRoomDialog_.isNull()) {
|
MainWindow::instance()->openCreateRoomDialog(
|
||||||
createRoomDialog_ =
|
[this](const mtx::requests::CreateRoom &req) { emit createRoom(req); });
|
||||||
QSharedPointer<dialogs::CreateRoom>(new dialogs::CreateRoom(this));
|
|
||||||
|
|
||||||
connect(createRoomDialog_.data(),
|
|
||||||
&dialogs::CreateRoom::closing,
|
|
||||||
this,
|
|
||||||
[this](bool isCreating, const mtx::requests::CreateRoom &request) {
|
|
||||||
createRoomModal_->hide();
|
|
||||||
|
|
||||||
if (isCreating)
|
|
||||||
emit createRoom(request);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (createRoomModal_.isNull()) {
|
|
||||||
createRoomModal_ = QSharedPointer<OverlayModal>(
|
|
||||||
new OverlayModal(MainWindow::instance(), createRoomDialog_.data()));
|
|
||||||
createRoomModal_->setColor(QColor(30, 30, 30, 170));
|
|
||||||
}
|
|
||||||
|
|
||||||
createRoomModal_->show();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
addMenu_->addAction(createRoomAction_);
|
addMenu_->addAction(createRoomAction_);
|
||||||
|
|
|
@ -92,28 +92,8 @@ TopRoomBar::TopRoomBar(QWidget *parent)
|
||||||
|
|
||||||
inviteUsers_ = new QAction(tr("Invite users"), this);
|
inviteUsers_ = new QAction(tr("Invite users"), this);
|
||||||
connect(inviteUsers_, &QAction::triggered, this, [this]() {
|
connect(inviteUsers_, &QAction::triggered, this, [this]() {
|
||||||
if (inviteUsersDialog_.isNull()) {
|
MainWindow::instance()->openInviteUsersDialog(
|
||||||
inviteUsersDialog_ =
|
[this](const QStringList &invitees) { emit inviteUsers(invitees); });
|
||||||
QSharedPointer<dialogs::InviteUsers>(new dialogs::InviteUsers(this));
|
|
||||||
|
|
||||||
connect(inviteUsersDialog_.data(),
|
|
||||||
&dialogs::InviteUsers::closing,
|
|
||||||
this,
|
|
||||||
[this](bool isSending, QStringList invitees) {
|
|
||||||
inviteUsersModal_->hide();
|
|
||||||
|
|
||||||
if (isSending && !invitees.isEmpty())
|
|
||||||
emit inviteUsers(invitees);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inviteUsersModal_.isNull()) {
|
|
||||||
inviteUsersModal_ = QSharedPointer<OverlayModal>(
|
|
||||||
new OverlayModal(MainWindow::instance(), inviteUsersDialog_.data()));
|
|
||||||
inviteUsersModal_->setColor(QColor(30, 30, 30, 170));
|
|
||||||
}
|
|
||||||
|
|
||||||
inviteUsersModal_->show();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
leaveRoom_ = new QAction(tr("Leave room"), this);
|
leaveRoom_ = new QAction(tr("Leave room"), this);
|
||||||
|
|
|
@ -28,8 +28,6 @@ UserInfoWidget::UserInfoWidget(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, display_name_("User")
|
, display_name_("User")
|
||||||
, user_id_("@user:homeserver.org")
|
, user_id_("@user:homeserver.org")
|
||||||
, logoutModal_{nullptr}
|
|
||||||
, logoutDialog_{nullptr}
|
|
||||||
, logoutButtonSize_{20}
|
, logoutButtonSize_{20}
|
||||||
{
|
{
|
||||||
setFixedHeight(65);
|
setFixedHeight(65);
|
||||||
|
@ -91,33 +89,10 @@ UserInfoWidget::UserInfoWidget(QWidget *parent)
|
||||||
|
|
||||||
// Show the confirmation dialog.
|
// Show the confirmation dialog.
|
||||||
connect(logoutButton_, &QPushButton::clicked, this, [this]() {
|
connect(logoutButton_, &QPushButton::clicked, this, [this]() {
|
||||||
if (logoutDialog_.isNull()) {
|
MainWindow::instance()->openLogoutDialog([this]() { emit logout(); });
|
||||||
logoutDialog_ = QSharedPointer<dialogs::Logout>(new dialogs::Logout(this));
|
|
||||||
connect(logoutDialog_.data(),
|
|
||||||
SIGNAL(closing(bool)),
|
|
||||||
this,
|
|
||||||
SLOT(closeLogoutDialog(bool)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (logoutModal_.isNull()) {
|
|
||||||
logoutModal_ = QSharedPointer<OverlayModal>(
|
|
||||||
new OverlayModal(MainWindow::instance(), logoutDialog_.data()));
|
|
||||||
logoutModal_->setColor(QColor(30, 30, 30, 170));
|
|
||||||
}
|
|
||||||
|
|
||||||
logoutModal_->show();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
UserInfoWidget::closeLogoutDialog(bool isLoggingOut)
|
|
||||||
{
|
|
||||||
logoutModal_->hide();
|
|
||||||
|
|
||||||
if (isLoggingOut)
|
|
||||||
emit logout();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
UserInfoWidget::resizeEvent(QResizeEvent *event)
|
UserInfoWidget::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue