Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tombracho committed May 15, 2017
0 parents commit 50b29f0
Show file tree
Hide file tree
Showing 34 changed files with 51,811 additions and 0 deletions.
2,476 changes: 2,476 additions & 0 deletions HSE.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ICON.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions Project.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#-------------------------------------------------
#
# Project created by QtCreator 2017-05-14T12:53:20
#
#-------------------------------------------------

QT += core gui svg xml

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Project
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0


SOURCES += main.cpp \
authorization.cpp \
graphics_view_zoom.cpp \
mainwindow.cpp \
registration.cpp \
roomlabel.cpp \
svgreader.cpp

HEADERS += \
authorization.h \
graphics_view_zoom.h \
mainwindow.h \
registration.h \
roomlabel.h \
svgreader.h

FORMS += \
authorization.ui \
mainwindow.ui \
registration.ui

RESOURCES += \
sources.qrc
318 changes: 318 additions & 0 deletions Project.pro.user

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# CoursWork
73 changes: 73 additions & 0 deletions authorization.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include "authorization.h"
#include "ui_authorization.h"
#include "mainwindow.h"
#include <QString>
#include <QFile>
#include <QDebug>

Authorization::Authorization(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Authorization)
{
ui->setupUi(this);
setWindowIcon(QIcon(":/fill/ICON.png"));

ui->buttonEnt->setEnabled(false);
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()));
setWindowTitle("DUBKI");
}

bool Authorization::CheckValid(){
if (ui->login->hasAcceptableInput() && ui->password->hasAcceptableInput()){
return true;
} else return false;
}

Authorization::~Authorization()
{
delete ui;
}

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>Error, try again later.</font>");
return;
}
while (!mFile.atEnd()){
QString s = mFile.readLine();
if (s.contains(':' + ui->login->text()) && s.contains('*' + ui->password->text())){
mFile.close();
QString student = s.split(" ").at(1).trimmed() + " " + s.split(" ").at(2).trimmed();
qDebug() << student;
window = new MainWindow(student);
window->show();
this->close();
return;
}
}
ui->info->setText("<font color=red>Incorrect login or password.</font>");
mFile.close();
return;
}

void Authorization::VhodEnabled(){
ui->buttonEnt->setEnabled(CheckValid());
}

void Authorization::on_buttonReg_clicked()
{
Registration w;
w.show();
w.exec();
}
33 changes: 33 additions & 0 deletions authorization.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef AUTHORIZATION_H
#define AUTHORIZATION_H

#include <QMainWindow>
#include "registration.h"
#include "mainwindow.h"
namespace Ui {
class Authorization;
}

class Authorization : public QMainWindow
{
Q_OBJECT

public:
explicit Authorization(QWidget *parent = 0);
~Authorization();
bool CheckValid();

private slots:
void on_buttonEnt_clicked();

void on_buttonReg_clicked();

void VhodEnabled();

private:
Ui::Authorization *ui;
MainWindow * window;

};

#endif // AUTHORIZATION_H
106 changes: 106 additions & 0 deletions authorization.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Authorization</class>
<widget class="QMainWindow" name="Authorization">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>250</width>
<height>195</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout_3">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Authorization</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<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" rowspan="2">
<widget class="QLineEdit" name="login"/>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="password"/>
</item>
<item row="3" 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="0" rowspan="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item row="4" 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="3" column="1">
<widget class="QPushButton" name="buttonEnt">
<property name="text">
<string>Enter</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="buttonReg">
<property name="text">
<string>Registration</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="info">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
Loading

0 comments on commit 50b29f0

Please sign in to comment.