diff options
author | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-09-20 09:59:14 +0300 |
---|---|---|
committer | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-09-20 09:59:14 +0300 |
commit | ecc346a6dad163986cdb7a1a5a6aa873e20519da (patch) | |
tree | 75663330208063522165d8e14941cc2aabdca2c0 | |
parent | Use confirm as the default button (diff) | |
download | nheko-ecc346a6dad163986cdb7a1a5a6aa873e20519da.tar.xz |
Close dialogs on confirmation
-rw-r--r-- | src/RegisterPage.cpp | 2 | ||||
-rw-r--r-- | src/dialogs/CreateRoom.cpp | 1 | ||||
-rw-r--r-- | src/dialogs/InviteUsers.cpp | 2 | ||||
-rw-r--r-- | src/dialogs/JoinRoom.cpp | 2 | ||||
-rw-r--r-- | src/dialogs/LeaveRoom.cpp | 5 | ||||
-rw-r--r-- | src/dialogs/Logout.cpp | 5 | ||||
-rw-r--r-- | src/dialogs/ReCaptcha.cpp | 38 | ||||
-rw-r--r-- | src/dialogs/ReCaptcha.h | 14 |
8 files changed, 31 insertions, 38 deletions
diff --git a/src/RegisterPage.cpp b/src/RegisterPage.cpp index dcf60dee..0bfaa82d 100644 --- a/src/RegisterPage.cpp +++ b/src/RegisterPage.cpp @@ -138,7 +138,7 @@ RegisterPage::RegisterPage(QWidget *parent) new dialogs::ReCaptcha(QString::fromStdString(session), this); connect(captchaDialog, - &dialogs::ReCaptcha::closing, + &dialogs::ReCaptcha::confirmation, this, [this, user, pass, session, captchaDialog]() { captchaDialog->close(); diff --git a/src/dialogs/CreateRoom.cpp b/src/dialogs/CreateRoom.cpp index c03c9ca6..7fddc3a5 100644 --- a/src/dialogs/CreateRoom.cpp +++ b/src/dialogs/CreateRoom.cpp @@ -105,6 +105,7 @@ CreateRoom::CreateRoom(QWidget *parent) emit createRoom(request_); clearFields(); + emit close(); }); connect(cancelBtn_, &QPushButton::clicked, this, [this]() { diff --git a/src/dialogs/InviteUsers.cpp b/src/dialogs/InviteUsers.cpp index b8178ed8..ab523a56 100644 --- a/src/dialogs/InviteUsers.cpp +++ b/src/dialogs/InviteUsers.cpp @@ -69,6 +69,8 @@ InviteUsers::InviteUsers(QWidget *parent) inviteeInput_->clear(); inviteeList_->clear(); errorLabel_->hide(); + + emit close(); }); connect(cancelBtn_, &QPushButton::clicked, [this]() { diff --git a/src/dialogs/JoinRoom.cpp b/src/dialogs/JoinRoom.cpp index ea569823..284897dd 100644 --- a/src/dialogs/JoinRoom.cpp +++ b/src/dialogs/JoinRoom.cpp @@ -58,6 +58,8 @@ JoinRoom::handleInput() // TODO: input validation with error messages. emit joinRoom(roomInput_->text()); roomInput_->clear(); + + emit close(); } void diff --git a/src/dialogs/LeaveRoom.cpp b/src/dialogs/LeaveRoom.cpp index 5ac62615..283c9025 100644 --- a/src/dialogs/LeaveRoom.cpp +++ b/src/dialogs/LeaveRoom.cpp @@ -43,6 +43,9 @@ LeaveRoom::LeaveRoom(QWidget *parent) layout->addWidget(label); layout->addLayout(buttonLayout); - connect(confirmBtn_, &QPushButton::clicked, this, &LeaveRoom::leaving); + connect(confirmBtn_, &QPushButton::clicked, this, [this]() { + emit leaving(); + emit close(); + }); connect(cancelBtn_, &QPushButton::clicked, this, &LeaveRoom::close); } diff --git a/src/dialogs/Logout.cpp b/src/dialogs/Logout.cpp index 882ef915..cf4d5587 100644 --- a/src/dialogs/Logout.cpp +++ b/src/dialogs/Logout.cpp @@ -63,6 +63,9 @@ Logout::Logout(QWidget *parent) layout->addLayout(buttonLayout); layout->addStretch(1); - connect(confirmBtn_, &QPushButton::clicked, this, &Logout::loggingOut); + connect(confirmBtn_, &QPushButton::clicked, this, [this]() { + emit loggingOut(); + emit close(); + }); connect(cancelBtn_, &QPushButton::clicked, this, &Logout::close); } diff --git a/src/dialogs/ReCaptcha.cpp b/src/dialogs/ReCaptcha.cpp index 0995e955..4aaa58a3 100644 --- a/src/dialogs/ReCaptcha.cpp +++ b/src/dialogs/ReCaptcha.cpp @@ -1,15 +1,13 @@ #include <QDesktopServices> #include <QLabel> -#include <QPaintEvent> -#include <QStyleOption> +#include <QPushButton> +#include <QUrl> #include <QVBoxLayout> #include "dialogs/ReCaptcha.h" #include "Config.h" #include "MatrixClient.h" -#include "ui/FlatButton.h" -#include "ui/RaisedButton.h" #include "ui/Theme.h" using namespace dialogs; @@ -20,6 +18,7 @@ ReCaptcha::ReCaptcha(const QString &session, QWidget *parent) setAutoFillBackground(true); setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint); setWindowModality(Qt::WindowModal); + setAttribute(Qt::WA_DeleteOnClose, true); auto layout = new QVBoxLayout(this); layout->setSpacing(conf::modals::WIDGET_SPACING); @@ -29,22 +28,15 @@ ReCaptcha::ReCaptcha(const QString &session, QWidget *parent) buttonLayout->setSpacing(8); buttonLayout->setMargin(0); - QFont buttonFont; - buttonFont.setPointSizeF(buttonFont.pointSizeF() * conf::modals::BUTTON_TEXT_SIZE_RATIO); - - openCaptchaBtn_ = new FlatButton("OPEN reCAPTCHA", this); - openCaptchaBtn_->setFont(buttonFont); - - confirmBtn_ = new RaisedButton(tr("CONFIRM"), this); - confirmBtn_->setFont(buttonFont); - - cancelBtn_ = new RaisedButton(tr("CANCEL"), this); - cancelBtn_->setFont(buttonFont); + openCaptchaBtn_ = new QPushButton("Open reCAPTCHA", this); + cancelBtn_ = new QPushButton(tr("Cancel"), this); + confirmBtn_ = new QPushButton(tr("Confirm"), this); + confirmBtn_->setDefault(true); buttonLayout->addStretch(1); buttonLayout->addWidget(openCaptchaBtn_); - buttonLayout->addWidget(confirmBtn_); buttonLayout->addWidget(cancelBtn_); + buttonLayout->addWidget(confirmBtn_); QFont font; font.setPointSizeF(font.pointSizeF() * conf::modals::LABEL_MEDIUM_SIZE_RATIO); @@ -65,15 +57,9 @@ ReCaptcha::ReCaptcha(const QString &session, QWidget *parent) QDesktopServices::openUrl(url); }); - connect(confirmBtn_, &QPushButton::clicked, this, &dialogs::ReCaptcha::closing); + connect(confirmBtn_, &QPushButton::clicked, this, [this]() { + emit confirmation(); + emit close(); + }); connect(cancelBtn_, &QPushButton::clicked, this, &dialogs::ReCaptcha::close); } - -void -ReCaptcha::paintEvent(QPaintEvent *) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); -} diff --git a/src/dialogs/ReCaptcha.h b/src/dialogs/ReCaptcha.h index 5f47b0eb..f8407640 100644 --- a/src/dialogs/ReCaptcha.h +++ b/src/dialogs/ReCaptcha.h @@ -2,8 +2,7 @@ #include <QWidget> -class FlatButton; -class RaisedButton; +class QPushButton; namespace dialogs { @@ -14,15 +13,12 @@ class ReCaptcha : public QWidget public: ReCaptcha(const QString &session, QWidget *parent = nullptr); -protected: - void paintEvent(QPaintEvent *event) override; - signals: - void closing(); + void confirmation(); private: - FlatButton *openCaptchaBtn_; - RaisedButton *confirmBtn_; - RaisedButton *cancelBtn_; + QPushButton *openCaptchaBtn_; + QPushButton *confirmBtn_; + QPushButton *cancelBtn_; }; } // dialogs |