Skip to content

Commit

Permalink
minor refactoring, firebase test integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikeost committed Mar 14, 2024
1 parent 92b677a commit a512b5d
Show file tree
Hide file tree
Showing 78 changed files with 1,946 additions and 2,287 deletions.
31 changes: 31 additions & 0 deletions src/DatabaseHandler/databasehandler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "databasehandler.h"
#include <QEventLoop>
#include <QDebug>
#include <QNetworkRequest>

DatabaseHandler::DatabaseHandler(QObject *parent)
: QObject{parent}
{
networkManager = new QNetworkAccessManager(this);
}

DatabaseHandler::~DatabaseHandler()
{
networkManager->deleteLater();
}

void DatabaseHandler::replyNetworkReadyRead()
{
qDebug() << QString(networkReply->readAll());
}

QByteArray DatabaseHandler::getReply(const QString &url)
{
QNetworkReply *reply = networkManager->get(QNetworkRequest(QUrl(url)));
QEventLoop loop;
connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
loop.exec();
QByteArray data = reply->readAll();
reply->deleteLater();
return data;
}
26 changes: 26 additions & 0 deletions src/DatabaseHandler/databasehandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef DATABASEHANDLER_H
#define DATABASEHANDLER_H

#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>

class DatabaseHandler : public QObject
{
Q_OBJECT
public:
explicit DatabaseHandler(QObject *parent = nullptr);
~DatabaseHandler();

signals:

private:
QNetworkAccessManager *networkManager;
QNetworkReply *networkReply;

public slots:
void replyNetworkReadyRead();
QByteArray getReply(const QString &url);
};

#endif // DATABASEHANDLER_H
36 changes: 20 additions & 16 deletions src/Gradify.pro
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
QT += core gui sql printsupport charts
QT += core gui printsupport charts network sql

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++17 app_bundle

QMAKE_CXXFLAGS += -pedantic -Wextra -Wall

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
aboutapp.cpp \
appsetting.cpp \
authorizationform.cpp \
DatabaseHandler/databasehandler.cpp \
aboutappwindow.cpp \
appsettingswindow.cpp \
customWidgets/qlineeditwithbutton.cpp \
customWidgets/qsearchbar.cpp \
filterform.cpp \
filterwindow.cpp \
loginwindow.cpp \
main.cpp \
mainwindow.cpp \
preloader.cpp \
queryform.cpp \
querywindow.cpp \
recordsForms/gradewindow.cpp \
recordsForms/groupwindow.cpp \
recordsForms/studentwindow.cpp \
Expand All @@ -31,15 +34,16 @@ SOURCES += \
statisticsForms/teacherstatistics.cpp

HEADERS += \
aboutapp.h \
appsetting.h \
authorizationform.h \
DatabaseHandler/databasehandler.h \
aboutappwindow.h \
appsettingswindow.h \
customWidgets/qlineeditwithbutton.h \
customWidgets/qsearchbar.h \
filterform.h \
filterwindow.h \
loginwindow.h \
mainwindow.h \
preloader.h \
queryform.h \
querywindow.h \
recordsForms/gradewindow.h \
recordsForms/groupwindow.h \
recordsForms/studentwindow.h \
Expand All @@ -52,13 +56,13 @@ HEADERS += \
statisticsForms/teacherstatistics.h

FORMS += \
aboutapp.ui \
appsetting.ui \
authorizationform.ui \
filterform.ui \
aboutappwindow.ui \
appsettingswindow.ui \
filterwindow.ui \
loginwindow.ui \
mainwindow.ui \
preloader.ui \
queryform.ui \
querywindow.ui \
recordsForms/gradewindow.ui \
recordsForms/groupwindow.ui \
recordsForms/studentwindow.ui \
Expand Down
85 changes: 0 additions & 85 deletions src/aboutapp.cpp

This file was deleted.

72 changes: 72 additions & 0 deletions src/aboutappwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include "aboutappwindow.h"
#include "ui_aboutappwindow.h"

#include <QFile>
#include <QPalette>

AboutAppWindow::AboutAppWindow(QWidget *parent)
: QWidget(parent)
, ui(new Ui::aboutApp)
{
ui->setupUi(this);
setWindowTitle("Про Gradify");
setFixedSize(width(), height());
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
}

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

void AboutAppWindow::changeEvent(QEvent *event)
{
QWidget::changeEvent(event);
if (event->type() == QEvent::ActivationChange) {
if (not isActiveWindow()) {
close();
}
}
}

void AboutAppWindow::setBlackUI()
{
QFile file(":/styles/black/aboutApp/aboutApp.qss");
file.open(QFile::ReadOnly);
setStyleSheet(QLatin1String(file.readAll()));
file.close();
}

void AboutAppWindow::setWhiteUI()
{
QFile file(":/styles/white/aboutApp/aboutApp.qss");
file.open(QFile::ReadOnly);
setStyleSheet(QLatin1String(file.readAll()));
file.close();
}

void AboutAppWindow::setSystemUI()
{
QPalette basePalette;
QColor baseColor = basePalette.base().color();
QColor newBase = QColor::fromRgbF(1 - baseColor.redF(),
1 - baseColor.greenF(),
1 - baseColor.blueF());

if (newBase.name() == "#000000") {
setWhiteUI();
} else {
setBlackUI();
}
}

void AboutAppWindow::setTheme(const QString &style)
{
if (style == "black") {
setBlackUI();
} else if (style == "white") {
setWhiteUI();
} else {
setSystemUI();
}
}
13 changes: 6 additions & 7 deletions src/aboutapp.h → src/aboutappwindow.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#ifndef ABOUTAPP_H
#define ABOUTAPP_H
#ifndef ABOUTAPPWINDOW_H
#define ABOUTAPPWINDOW_H

#include <QWidget>

namespace Ui {
class aboutApp;
}

class aboutApp : public QWidget
class AboutAppWindow : public QWidget
{
Q_OBJECT

public:
explicit aboutApp(QWidget *parent = nullptr);
~aboutApp();
explicit AboutAppWindow(QWidget *parent = nullptr);
~AboutAppWindow();
void changeEvent(QEvent *event) override;

private slots:
Expand All @@ -26,7 +26,6 @@ private slots:

public slots:
void setTheme(const QString &style);

};

#endif // ABOUTAPP_H
#endif // ABOUTAPPWINDOW_H
8 changes: 5 additions & 3 deletions src/aboutapp.ui → src/aboutappwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap>:/img/iconSets/icon_256x256.png</pixmap>
<pixmap resource="recources.qrc">:/img/iconSets/icon_256x256.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
Expand Down Expand Up @@ -61,7 +61,7 @@
</rect>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Простота та зручність&lt;br/&gt;використання баз даних&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Простота та зручність&lt;br/&gt;в навчанні&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
Expand Down Expand Up @@ -100,6 +100,8 @@
</property>
</widget>
</widget>
<resources/>
<resources>
<include location="recources.qrc"/>
</resources>
<connections/>
</ui>
Loading

0 comments on commit a512b5d

Please sign in to comment.