-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
860 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#include "authorization.h" | ||
#include "ui_authorization.h" | ||
#include "registration.h" | ||
#include "widget.h" | ||
#include <QFile> | ||
#include <QDebug> | ||
#include <QJsonArray> | ||
#include <QJsonObject> | ||
#include <QJsonDocument> | ||
|
||
Authorization::Authorization(QWidget *parent) : | ||
QWidget(parent), | ||
ui(new Ui::Authorization) | ||
{ | ||
ui->setupUi(this); | ||
QRegExp exp("[a-zA-Z]{3,15}[0-9]{0,15}[.,_]{0,5}"); | ||
ui->login->setValidator(new QRegExpValidator(exp, this)); | ||
ui->password->setValidator(new QRegExpValidator(exp, this)); | ||
connect(ui->login, SIGNAL(textChanged(QString)),this, SLOT(VhodEnabled())); | ||
connect(ui->password, SIGNAL(textChanged(QString)),this, SLOT(VhodEnabled())); | ||
} | ||
|
||
Authorization::~Authorization() | ||
{ | ||
delete ui; | ||
} | ||
|
||
bool Authorization::CheckValid(){ | ||
if (ui->login->hasAcceptableInput() && ui->password->hasAcceptableInput()){ | ||
return true; | ||
} else return false; | ||
} | ||
|
||
void Authorization::VhodEnabled(){ | ||
ui->buttonEnt->setEnabled(CheckValid()); | ||
} | ||
|
||
void Authorization::on_buttonEnt_clicked() | ||
{ | ||
QFile f("./pasw_log.txt"); | ||
if (!f.exists()){ | ||
f.open(QFile::WriteOnly); | ||
} | ||
f.close(); | ||
QFile mFile ("./pasw_log.txt"); | ||
if(!mFile.open(QFile::ReadOnly | QFile::Text)){ | ||
ui->info->setText("<font color=red>Ошибка регистрации.</font>"); | ||
return; | ||
} | ||
QString val = mFile.readAll(); | ||
QJsonDocument doc = QJsonDocument::fromJson(val.toUtf8()); | ||
QJsonArray JSArray(doc.array()); | ||
mFile.close(); | ||
foreach (auto now, JSArray) { | ||
if (now.toObject()["Login"].toString() == ui->login->text() | ||
&& now.toObject()["Password"].toString() == ui->password->text()){ | ||
int scores = now.toObject()["Scores"].toString().toInt(); | ||
Widget * w = new Widget(now.toObject()["Login"].toString(), scores, 0); | ||
w->show(); | ||
this->close(); | ||
} | ||
} | ||
ui->info->setText("<font color=red>Incorrect login or password.</font>"); | ||
} | ||
|
||
void Authorization::on_buttonReg_clicked() | ||
{ | ||
Registration w; | ||
w.show(); | ||
w.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef AUTHORIZATION_H | ||
#define AUTHORIZATION_H | ||
|
||
#include <QWidget> | ||
|
||
namespace Ui { | ||
class Authorization; | ||
} | ||
|
||
class Authorization : public QWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit Authorization(QWidget *parent = 0); | ||
~Authorization(); | ||
bool CheckValid(); | ||
|
||
private slots: | ||
void VhodEnabled(); | ||
|
||
void on_buttonEnt_clicked(); | ||
|
||
void on_buttonReg_clicked(); | ||
|
||
private: | ||
Ui::Authorization *ui; | ||
}; | ||
|
||
#endif // AUTHORIZATION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>Authorization</class> | ||
<widget class="QWidget" name="Authorization"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>260</width> | ||
<height>182</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Form</string> | ||
</property> | ||
<layout class="QGridLayout" name="gridLayout_6"> | ||
<item row="0" column="0"> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<widget class="QGroupBox" name="groupBox_3"> | ||
<property name="title"> | ||
<string>Authorization</string> | ||
</property> | ||
<layout class="QGridLayout" name="gridLayout_5"> | ||
<item row="0" column="0"> | ||
<layout class="QGridLayout" name="gridLayout_3"> | ||
<item row="0" column="0" colspan="2"> | ||
<layout class="QGridLayout" name="gridLayout_2"> | ||
<item row="0" column="0" colspan="2"> | ||
<layout class="QGridLayout" name="gridLayout"> | ||
<item row="0" column="0"> | ||
<widget class="QLabel" name="label_3"> | ||
<property name="text"> | ||
<string>Username</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="0" column="1"> | ||
<widget class="QLineEdit" name="login"/> | ||
</item> | ||
<item row="1" column="0"> | ||
<widget class="QLabel" name="label_4"> | ||
<property name="text"> | ||
<string>Password</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="1"> | ||
<widget class="QLineEdit" name="password"> | ||
<property name="cursor"> | ||
<cursorShape>IBeamCursor</cursorShape> | ||
</property> | ||
<property name="echoMode"> | ||
<enum>QLineEdit::Normal</enum> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
<item row="1" column="0"> | ||
<spacer name="horizontalSpacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>40</width> | ||
<height>20</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
<item row="1" column="1"> | ||
<widget class="QPushButton" name="buttonEnt"> | ||
<property name="text"> | ||
<string>Enter</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
<item row="1" column="0"> | ||
<spacer name="horizontalSpacer_3"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>46</width> | ||
<height>13</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
<item row="1" column="1"> | ||
<widget class="QLabel" name="info"> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="buttonReg"> | ||
<property name="text"> | ||
<string>Registration</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "objvec.h" | ||
|
||
|
Oops, something went wrong.