mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Show confirmation dialog on logout
Minor stylistic refactoring closes #29
This commit is contained in:
parent
5c283a5cda
commit
b8c8fed655
13 changed files with 155 additions and 15 deletions
|
@ -94,6 +94,7 @@ set(SRC_FILES
|
|||
src/Login.cc
|
||||
src/LoginPage.cc
|
||||
src/LoginSettings.cc
|
||||
src/LogoutDialog.cc
|
||||
src/MainWindow.cc
|
||||
src/MatrixClient.cc
|
||||
src/Profile.cc
|
||||
|
@ -171,6 +172,7 @@ qt5_wrap_cpp(MOC_HEADERS
|
|||
include/TimelineViewManager.h
|
||||
include/LoginPage.h
|
||||
include/LoginSettings.h
|
||||
include/LogoutDialog.h
|
||||
include/MainWindow.h
|
||||
include/MatrixClient.h
|
||||
include/RegisterPage.h
|
||||
|
|
36
include/LogoutDialog.h
Normal file
36
include/LogoutDialog.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
#include "FlatButton.h"
|
||||
|
||||
class LogoutDialog : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LogoutDialog(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void closing(bool isLoggingOut);
|
||||
|
||||
private:
|
||||
FlatButton *confirmBtn_;
|
||||
FlatButton *cancelBtn_;
|
||||
};
|
|
@ -38,6 +38,8 @@ public:
|
|||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
static MainWindow *instance();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
|
@ -62,6 +64,8 @@ private slots:
|
|||
private:
|
||||
bool hasActiveUser();
|
||||
|
||||
static MainWindow *instance_;
|
||||
|
||||
// The initial welcome screen.
|
||||
WelcomePage *welcome_page_;
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include "Avatar.h"
|
||||
#include "FlatButton.h"
|
||||
#include "LogoutDialog.h"
|
||||
#include "OverlayModal.h"
|
||||
|
||||
class UserInfoWidget : public QWidget
|
||||
{
|
||||
|
@ -45,6 +47,9 @@ signals:
|
|||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void closeLogoutDialog(bool isLoggingOut);
|
||||
|
||||
private:
|
||||
Avatar *userAvatar_;
|
||||
|
||||
|
@ -62,4 +67,9 @@ private:
|
|||
QString user_id_;
|
||||
|
||||
QImage avatar_image_;
|
||||
|
||||
OverlayModal *logoutModal_;
|
||||
LogoutDialog *logoutDialog_;
|
||||
|
||||
int logoutButtonSize_;
|
||||
};
|
||||
|
|
|
@ -37,12 +37,10 @@ LoginPage::LoginPage(QSharedPointer<MatrixClient> client, QWidget *parent)
|
|||
back_button_ = new FlatButton(this);
|
||||
back_button_->setMinimumSize(QSize(30, 30));
|
||||
back_button_->setForegroundColor("#333333");
|
||||
back_button_->setCursor(QCursor(Qt::PointingHandCursor));
|
||||
|
||||
advanced_settings_button_ = new FlatButton(this);
|
||||
advanced_settings_button_->setMinimumSize(QSize(30, 30));
|
||||
advanced_settings_button_->setForegroundColor("#333333");
|
||||
advanced_settings_button_->setCursor(QCursor(Qt::PointingHandCursor));
|
||||
|
||||
QIcon icon;
|
||||
icon.addFile(":/icons/icons/left-angle.png", QSize(), QIcon::Normal, QIcon::Off);
|
||||
|
@ -105,7 +103,6 @@ LoginPage::LoginPage(QSharedPointer<MatrixClient> client, QWidget *parent)
|
|||
login_button_->setBackgroundColor(QColor("#333333"));
|
||||
login_button_->setForegroundColor(QColor("white"));
|
||||
login_button_->setMinimumSize(350, 65);
|
||||
login_button_->setCursor(QCursor(Qt::PointingHandCursor));
|
||||
login_button_->setFontSize(17);
|
||||
login_button_->setCornerRadius(3);
|
||||
|
||||
|
|
57
src/LogoutDialog.cc
Normal file
57
src/LogoutDialog.cc
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "LogoutDialog.h"
|
||||
#include "Theme.h"
|
||||
|
||||
LogoutDialog::LogoutDialog(QWidget *parent)
|
||||
: QFrame(parent)
|
||||
{
|
||||
setMaximumSize(400, 400);
|
||||
setStyleSheet("background-color: #f9f9f9");
|
||||
|
||||
auto layout = new QVBoxLayout(this);
|
||||
layout->setSpacing(30);
|
||||
layout->setMargin(20);
|
||||
|
||||
auto buttonLayout = new QHBoxLayout();
|
||||
buttonLayout->setSpacing(0);
|
||||
buttonLayout->setMargin(0);
|
||||
|
||||
confirmBtn_ = new FlatButton("OK", this);
|
||||
confirmBtn_->setFontSize(12);
|
||||
|
||||
cancelBtn_ = new FlatButton(tr("CANCEL"), this);
|
||||
cancelBtn_->setFontSize(12);
|
||||
|
||||
buttonLayout->addStretch(1);
|
||||
buttonLayout->addWidget(confirmBtn_);
|
||||
buttonLayout->addWidget(cancelBtn_);
|
||||
|
||||
auto label = new QLabel(tr("Logout. Are you sure?"), this);
|
||||
label->setFont(QFont("Open Sans", 14));
|
||||
label->setStyleSheet("color: #333333");
|
||||
|
||||
layout->addWidget(label);
|
||||
layout->addLayout(buttonLayout);
|
||||
|
||||
connect(confirmBtn_, &QPushButton::clicked, [=]() { emit closing(true); });
|
||||
connect(cancelBtn_, &QPushButton::clicked, [=]() { emit closing(false); });
|
||||
}
|
|
@ -22,6 +22,8 @@
|
|||
#include <QSettings>
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
MainWindow *MainWindow::instance_ = nullptr;
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, progress_modal_{nullptr}
|
||||
|
@ -148,6 +150,8 @@ void MainWindow::showChatPage(QString userid, QString homeserver, QString token)
|
|||
|
||||
login_page_->reset();
|
||||
chat_page_->bootstrap(userid, homeserver, token);
|
||||
|
||||
instance_ = this;
|
||||
}
|
||||
|
||||
void MainWindow::showWelcomePage()
|
||||
|
@ -204,6 +208,11 @@ bool MainWindow::hasActiveUser()
|
|||
settings.contains("auth/user_id");
|
||||
}
|
||||
|
||||
MainWindow *MainWindow::instance()
|
||||
{
|
||||
return instance_;
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ RegisterPage::RegisterPage(QSharedPointer<MatrixClient> client, QWidget *parent)
|
|||
|
||||
back_button_ = new FlatButton(this);
|
||||
back_button_->setMinimumSize(QSize(30, 30));
|
||||
back_button_->setCursor(QCursor(Qt::PointingHandCursor));
|
||||
|
||||
QIcon icon;
|
||||
icon.addFile(":/icons/icons/left-angle.png", QSize(), QIcon::Normal, QIcon::Off);
|
||||
|
@ -109,7 +108,6 @@ RegisterPage::RegisterPage(QSharedPointer<MatrixClient> client, QWidget *parent)
|
|||
register_button_->setBackgroundColor(QColor("#333333"));
|
||||
register_button_->setForegroundColor(QColor("white"));
|
||||
register_button_->setMinimumSize(350, 65);
|
||||
register_button_->setCursor(QCursor(Qt::PointingHandCursor));
|
||||
register_button_->setFontSize(17);
|
||||
register_button_->setCornerRadius(3);
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@ TextInputWidget::TextInputWidget(QWidget *parent)
|
|||
top_layout_->setMargin(0);
|
||||
|
||||
send_file_button_ = new FlatButton(this);
|
||||
send_file_button_->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
QIcon send_file_icon;
|
||||
send_file_icon.addFile(":/icons/icons/clip-dark.png", QSize(), QIcon::Normal, QIcon::Off);
|
||||
|
@ -64,7 +63,6 @@ TextInputWidget::TextInputWidget(QWidget *parent)
|
|||
input_->setStyleSheet("color: #333333; font-size: 13px; border-radius: 0; padding-top: 10px;");
|
||||
|
||||
send_message_button_ = new FlatButton(this);
|
||||
send_message_button_->setCursor(Qt::PointingHandCursor);
|
||||
send_message_button_->setForegroundColor(QColor("#acc7dc"));
|
||||
|
||||
QIcon send_message_icon;
|
||||
|
@ -73,7 +71,6 @@ TextInputWidget::TextInputWidget(QWidget *parent)
|
|||
send_message_button_->setIconSize(QSize(24, 24));
|
||||
|
||||
emoji_button_ = new EmojiPickButton(this);
|
||||
emoji_button_->setCursor(Qt::PointingHandCursor);
|
||||
emoji_button_->setForegroundColor(QColor("#acc7dc"));
|
||||
|
||||
QIcon emoji_icon;
|
||||
|
|
|
@ -52,7 +52,6 @@ TopRoomBar::TopRoomBar(QWidget *parent)
|
|||
|
||||
settingsBtn_ = new FlatButton(this);
|
||||
settingsBtn_->setForegroundColor(QColor("#acc7dc"));
|
||||
settingsBtn_->setCursor(QCursor(Qt::PointingHandCursor));
|
||||
settingsBtn_->setFixedSize(buttonSize_, buttonSize_);
|
||||
settingsBtn_->setCornerRadius(buttonSize_ / 2);
|
||||
|
||||
|
|
|
@ -16,14 +16,19 @@
|
|||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
|
||||
#include "FlatButton.h"
|
||||
#include "MainWindow.h"
|
||||
#include "UserInfoWidget.h"
|
||||
|
||||
UserInfoWidget::UserInfoWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, display_name_("User")
|
||||
, user_id_("@user:homeserver.org")
|
||||
, logoutModal_{nullptr}
|
||||
, logoutDialog_{nullptr}
|
||||
, logoutButtonSize_{32}
|
||||
{
|
||||
QSizePolicy sizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
setSizePolicy(sizePolicy);
|
||||
|
@ -72,19 +77,46 @@ UserInfoWidget::UserInfoWidget(QWidget *parent)
|
|||
|
||||
logoutButton_ = new FlatButton(this);
|
||||
logoutButton_->setForegroundColor(QColor("#555459"));
|
||||
logoutButton_->setCursor(QCursor(Qt::PointingHandCursor));
|
||||
logoutButton_->setFixedSize(logoutButtonSize_, logoutButtonSize_);
|
||||
logoutButton_->setCornerRadius(logoutButtonSize_ / 2);
|
||||
|
||||
QIcon icon;
|
||||
icon.addFile(":/icons/icons/power-button-off.png", QSize(), QIcon::Normal, QIcon::Off);
|
||||
|
||||
logoutButton_->setIcon(icon);
|
||||
logoutButton_->setIconSize(QSize(16, 16));
|
||||
logoutButton_->setIconSize(QSize(logoutButtonSize_ / 2, logoutButtonSize_ / 2));
|
||||
|
||||
buttonLayout_->addWidget(logoutButton_);
|
||||
|
||||
topLayout_->addLayout(buttonLayout_);
|
||||
|
||||
connect(logoutButton_, SIGNAL(clicked()), this, SIGNAL(logout()));
|
||||
// Show the confirmation dialog.
|
||||
connect(logoutButton_, &QPushButton::clicked, this, [=]() {
|
||||
if (logoutDialog_ == nullptr) {
|
||||
logoutDialog_ = new LogoutDialog(this);
|
||||
connect(logoutDialog_, SIGNAL(closing(bool)), this, SLOT(closeLogoutDialog(bool)));
|
||||
}
|
||||
|
||||
if (logoutModal_ == nullptr) {
|
||||
logoutModal_ = new OverlayModal(MainWindow::instance(), logoutDialog_);
|
||||
logoutModal_->setDuration(100);
|
||||
logoutModal_->setColor(QColor(55, 55, 55, 170));
|
||||
}
|
||||
|
||||
logoutModal_->fadeIn();
|
||||
});
|
||||
}
|
||||
|
||||
void UserInfoWidget::closeLogoutDialog(bool isLoggingOut)
|
||||
{
|
||||
logoutModal_->fadeOut();
|
||||
|
||||
if (isLoggingOut) {
|
||||
// Waiting for the modal to fade out.
|
||||
QTimer::singleShot(100, this, [=]() {
|
||||
emit logout();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
UserInfoWidget::~UserInfoWidget()
|
||||
|
|
|
@ -61,7 +61,6 @@ WelcomePage::WelcomePage(QWidget *parent)
|
|||
register_button_->setBackgroundColor(QColor("#333333"));
|
||||
register_button_->setForegroundColor(QColor("white"));
|
||||
register_button_->setMinimumSize(240, 60);
|
||||
register_button_->setCursor(QCursor(Qt::PointingHandCursor));
|
||||
register_button_->setFontSize(14);
|
||||
register_button_->setCornerRadius(3);
|
||||
|
||||
|
@ -69,7 +68,6 @@ WelcomePage::WelcomePage(QWidget *parent)
|
|||
login_button_->setBackgroundColor(QColor("#333333"));
|
||||
login_button_->setForegroundColor(QColor("white"));
|
||||
login_button_->setMinimumSize(240, 60);
|
||||
login_button_->setCursor(QCursor(Qt::PointingHandCursor));
|
||||
login_button_->setFontSize(14);
|
||||
login_button_->setCornerRadius(3);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ void FlatButton::init()
|
|||
setStyle(&ThemeManager::instance());
|
||||
setAttribute(Qt::WA_Hover);
|
||||
setMouseTracking(true);
|
||||
setCursor(QCursor(Qt::PointingHandCursor));
|
||||
|
||||
QPainterPath path;
|
||||
path.addRoundedRect(rect(), corner_radius_, corner_radius_);
|
||||
|
@ -336,7 +337,7 @@ void FlatButton::mousePressEvent(QMouseEvent *event)
|
|||
ripple->setOpacityStartValue(0.35);
|
||||
ripple->setColor(foregroundColor());
|
||||
ripple->radiusAnimation()->setDuration(250);
|
||||
ripple->opacityAnimation()->setDuration(400);
|
||||
ripple->opacityAnimation()->setDuration(250);
|
||||
|
||||
ripple_overlay_->addRipple(ripple);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue