2015-06-04 01:04:28 +08:00
|
|
|
#include "loginscreen.h"
|
|
|
|
#include "ui_loginscreen.h"
|
2015-06-04 05:20:47 +08:00
|
|
|
#include "src/profile.h"
|
2015-06-04 01:04:28 +08:00
|
|
|
|
|
|
|
LoginScreen::LoginScreen(QWidget *parent) :
|
|
|
|
QWidget(parent),
|
|
|
|
ui(new Ui::LoginScreen)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2015-06-04 01:28:16 +08:00
|
|
|
|
|
|
|
connect(ui->newProfilePgbtn, &QPushButton::clicked, this, &LoginScreen::onNewProfilePageClicked);
|
|
|
|
connect(ui->loginPgbtn, &QPushButton::clicked, this, &LoginScreen::onLoginPageClicked);
|
|
|
|
connect(ui->createAccountButton, &QPushButton::clicked, this, &LoginScreen::onCreateNewProfile);
|
|
|
|
connect(ui->loginButton, &QPushButton::clicked, this, &LoginScreen::onLogin);
|
2015-06-04 07:30:17 +08:00
|
|
|
connect(ui->loginUsernames, &QComboBox::currentTextChanged, this, &LoginScreen::onLoginUsernameSelected);
|
2015-06-04 05:20:47 +08:00
|
|
|
|
2015-06-04 07:30:17 +08:00
|
|
|
reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
LoginScreen::~LoginScreen()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoginScreen::reset()
|
|
|
|
{
|
|
|
|
ui->newUsername->clear();
|
|
|
|
ui->newPass->clear();
|
|
|
|
ui->loginPassword->clear();
|
|
|
|
|
|
|
|
ui->loginUsernames->clear();
|
|
|
|
Profile::scanProfiles();
|
2015-06-04 05:20:47 +08:00
|
|
|
QVector<QString> profiles = Profile::getProfiles();
|
|
|
|
for (QString profile : profiles)
|
|
|
|
ui->loginUsernames->addItem(profile);
|
|
|
|
|
|
|
|
if (profiles.isEmpty())
|
|
|
|
ui->stackedWidget->setCurrentIndex(0);
|
|
|
|
else
|
|
|
|
ui->stackedWidget->setCurrentIndex(1);
|
2015-06-04 01:04:28 +08:00
|
|
|
}
|
|
|
|
|
2015-06-04 01:28:16 +08:00
|
|
|
void LoginScreen::onNewProfilePageClicked()
|
|
|
|
{
|
|
|
|
ui->stackedWidget->setCurrentIndex(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoginScreen::onLoginPageClicked()
|
|
|
|
{
|
|
|
|
ui->stackedWidget->setCurrentIndex(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoginScreen::onCreateNewProfile()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-06-04 07:30:17 +08:00
|
|
|
void LoginScreen::onLoginUsernameSelected(const QString &name)
|
|
|
|
{
|
|
|
|
if (name.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (Profile::isProfileEncrypted(name))
|
|
|
|
{
|
|
|
|
ui->loginPasswordLabel->show();
|
|
|
|
ui->loginPassword->show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->loginPasswordLabel->hide();
|
|
|
|
ui->loginPassword->hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-04 01:28:16 +08:00
|
|
|
void LoginScreen::onLogin()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|