1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2014 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#include "musescore.h"
#include "logindialog.h"
#include "network/loginmanager.h"
#include "kQOAuth/kqoauthrequest_xauth.h"
namespace Ms {
//---------------------------------------------------------
// showLoginDialog
//---------------------------------------------------------
void MuseScore::showLoginDialog()
{
if (loginDialog == nullptr) {
loginDialog = new LoginDialog(loginManager());
}
loginDialog->setVisible(true);
}
//---------------------------------------------------------
// LoginDialog
//---------------------------------------------------------
LoginDialog::LoginDialog(LoginManager* loginManager)
: QDialog(0)
{
setObjectName("LoginDialog");
setupUi(this);
setStyleSheet("QLineEdit { "
"padding: 8px 8px;"
"}");
setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), SLOT(buttonBoxClicked(QAbstractButton*)));
_loginManager = loginManager;
createAccountLabel->setText(tr("%1Create an account%2")
.arg("<a href=\"https://musescore.com/user/register\">")
.arg("</a>"));
forgotPasswordLabel->setText(tr("%1Forgot password?%2")
.arg("<a href=\"https://musescore.com/user/password\">")
.arg("</a>"));
connect(_loginManager, SIGNAL(loginSuccess()), this, SLOT(onLoginSuccess()));
connect(_loginManager, SIGNAL(loginError(const QString&)), this, SLOT(onLoginError(const QString&)));
MuseScore::restoreGeometry(this);
}
//---------------------------------------------------------
// buttonBoxClicked
//---------------------------------------------------------
void LoginDialog::buttonBoxClicked(QAbstractButton* button)
{
QDialogButtonBox::StandardButton sb = buttonBox->standardButton(button);
if (sb == QDialogButtonBox::Ok) {
if (usernameEdit->text().trimmed().isEmpty() || passwordEdit->text().trimmed().isEmpty())
QMessageBox::critical(this, tr("Login error"), tr("Please fill in your username and password"));
login();
}
else
setVisible(false);
}
//---------------------------------------------------------
// login
//---------------------------------------------------------
void LoginDialog::login()
{
_loginManager->login(usernameEdit->text(), passwordEdit->text());
}
//---------------------------------------------------------
// onLoginError
//---------------------------------------------------------
void LoginDialog::onLoginError(const QString& error)
{
QMessageBox::critical(this, tr("Login error"), error);
}
//---------------------------------------------------------
// onLoginSuccess
//---------------------------------------------------------
void LoginDialog::onLoginSuccess()
{
emit loginSuccessful();
setVisible(false);
}
//---------------------------------------------------------
// hideEvent
//---------------------------------------------------------
void LoginDialog::hideEvent(QHideEvent* event)
{
MuseScore::saveGeometry(this);
QDialog::hideEvent(event);
}
}
|