mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Close dialogs on confirmation
This commit is contained in:
parent
d4ce7a9dda
commit
ecc346a6da
8 changed files with 31 additions and 38 deletions
|
@ -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();
|
||||
|
|
|
@ -105,6 +105,7 @@ CreateRoom::CreateRoom(QWidget *parent)
|
|||
emit createRoom(request_);
|
||||
|
||||
clearFields();
|
||||
emit close();
|
||||
});
|
||||
|
||||
connect(cancelBtn_, &QPushButton::clicked, this, [this]() {
|
||||
|
|
|
@ -69,6 +69,8 @@ InviteUsers::InviteUsers(QWidget *parent)
|
|||
inviteeInput_->clear();
|
||||
inviteeList_->clear();
|
||||
errorLabel_->hide();
|
||||
|
||||
emit close();
|
||||
});
|
||||
|
||||
connect(cancelBtn_, &QPushButton::clicked, [this]() {
|
||||
|
|
|
@ -58,6 +58,8 @@ JoinRoom::handleInput()
|
|||
// TODO: input validation with error messages.
|
||||
emit joinRoom(roomInput_->text());
|
||||
roomInput_->clear();
|
||||
|
||||
emit close();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue