Skip to content

Commit c3f1469

Browse files
committed
Anton: change autotools stuff
1 parent 4e1060f commit c3f1469

File tree

11 files changed

+40
-143
lines changed

11 files changed

+40
-143
lines changed

Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ ACLOCAL_AMFLAGS = -I m4
33
AM_CXXFLAGS = -fPIC -Wall -Wextra -std=c++11
44
SUBDIRS = src doc man examples
55

6-
EXTRA_DIST = autogen.sh src/qt/*.ui
6+
EXTRA_DIST = autogen.sh

src/Makefile.am

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
AUTOMAKE_OPTIONS = subdir-objects
22
ACLOCAL_AMFLAGS = $(ACLOCAL_FLAGS)
33

4+
$(shell ./scripts/db.sh)
5+
46
bin_PROGRAMS = ProTest
57

68
ProTest_SOURCES = main.cpp
9+
710
if HAVE_QT
811
ProTest_CPPFLAGS = $(CXXFLAGS) $(QT_CXXFLAGS) -Wall -Wextra -std=c++11
912
ProTest_LDADD = libmainmenu.la libqt_cpp.la libdatabse.la libteacher.la libstudent.la
@@ -16,8 +19,9 @@ endif
1619

1720
include_HEADERS = headers/tests_main_header.h headers/database.h headers/main_menu.h headers/sqlite3.h qt/dialog1.h \
1821
qt/mainwindow.h qt/mainwindow_teach.h build-qt-Desktop-Debug/ui_dialog1.h build-qt-Desktop-Debug/ui_mainwindow.h \
19-
build-qt-Desktop-Debug/ui_mainwindow_teach.h libs/libcrypt/include/tomcrypt_prng.h libs/libcrypt/include/tomcrypt_pkcs.h \
20-
build-qt-Desktop-Debug/moc_predefs.h headers/teacher_menu.h headers/student_menu.h headers/config.h
22+
build-qt-Desktop-Debug/ui_mainwindow_teach.h build-qt-Desktop-Debug/moc_predefs.h headers/teacher_menu.h \
23+
headers/student_menu.h headers/config.h qt/dialog2.h qt/dialog3.h qt/mainwindow_stud.h headers/sha256.h \
24+
build-qt-Desktop-Debug/ui_dialog2.h build-qt-Desktop-Debug/ui_dialog3.h build-qt-Desktop-Debug/ui_mainwindow_stud.h
2125

2226
if HAVE_QT
2327
lib_LTLIBRARIES = libmainmenu.la libqt_cpp.la libdatabse.la libteacher.la libstudent.la
@@ -34,13 +38,16 @@ libmainmenu_la_CPPFLAGS = $(ProTest_CPPFLAGS)
3438
if HAVE_QT
3539
libqt_cpp_la_LDFLAGS = -version-info 0:0:0 $(QT_LIBS)
3640
libqt_cpp_la_SOURCES = qt/dialog1.cpp qt/mainwindow.cpp qt/mainwindow_teach.cpp qt/qt_main.cpp build-qt-Desktop-Debug/moc_dialog1.cpp \
37-
build-qt-Desktop-Debug/moc_mainwindow.cpp build-qt-Desktop-Debug/moc_mainwindow_teach.cpp
41+
build-qt-Desktop-Debug/moc_mainwindow.cpp build-qt-Desktop-Debug/moc_mainwindow_teach.cpp qt/dialog2.cpp qt/dialog3.cpp \
42+
qt/mainwindow_stud.cpp build-qt-Desktop-Debug/moc_dialog2.cpp build-qt-Desktop-Debug/moc_dialog3.cpp \
43+
build-qt-Desktop-Debug/moc_mainwindow_stud.cpp \
44+
qt/dialog1.ui qt/dialog2.ui qt/dialog3.ui qt/mainwindow.ui qt/mainwindow_teach.ui qt/mainwindow_stud.ui
3845
libqt_cpp_la_CPPFLAGS = $(ProTest_CPPFLAGS)
3946
endif
4047

4148
# libdatabse.la
4249
libdatabse_la_LDFLAGS = -version-info 0:0:0
43-
libdatabse_la_SOURCES = libs/db/database.cpp libs/db/sqlite3.c
50+
libdatabse_la_SOURCES = libs/db/database.cpp libs/db/sqlite3.c libs/db/sha256.cpp
4451
libdatabse_la_CPPFLAGS = $(ProTest_CPPFLAGS)
4552

4653
# libteacher.la

src/build-qt-Desktop-Debug/ui_dialog1_copy.h

-132
This file was deleted.

src/headers/tests_main_header.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ along with ProTest. If not, see <https://www.gnu.org/licenses/>.
2222
#define MAIN_HEADER_TEST
2323

2424
/* Macros */
25-
#define QT_CREATOR (1)
25+
#define QT_CREATOR (0)
2626
#if (QT_CREATOR == 1)
2727
#define PATH_TO_DB ("../db/data.sqlite")
2828
#else
29-
#define PATH_TO_DB ("db/data.sqlite")
29+
#define PATH_TO_DB ("/.local/share/ProTest/data.sqlite")
3030
#endif
3131

3232
/* Types */

src/libs/main_menu.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ int main_menu(void) {
128128

129129
/* Initializing variables */
130130
int func, junk, n = 0;
131+
char *path;
131132

132133
/* I/O flow */
133134
while (1) {
@@ -154,7 +155,9 @@ int main_menu(void) {
154155
continue;
155156
}
156157

157-
if (db_open(PATH_TO_DB) == -1) {
158+
path = secure_getenv("HOME");
159+
strcat(path, PATH_TO_DB);
160+
if (db_open(path) == -1) {
158161
printf("| Error! Couldn't open database |\n");
159162
continue;
160163
}

src/qt/dialog2.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "dialog2.h"
2-
#include "ui_dialog2.h"
2+
#include "../build-qt-Desktop-Debug/ui_dialog2.h"
33
#include "../headers/tests_main_header.h"
44

55
Dialog2::Dialog2(QWidget *parent) :

src/qt/dialog3.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "dialog3.h"
2-
#include "ui_dialog3.h"
2+
#include "../build-qt-Desktop-Debug/ui_dialog3.h"
33
#include "mainwindow_stud.h"
44

55
int tt = 0;

src/qt/mainwindow.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ MainWindow::MainWindow(QWidget *parent) :
3333
/* Initializing variables */
3434
FILE *fp;
3535
QString login, pass;
36+
char *path;
3637

3738
/* I/O flow */
3839
if ((fp = fopen("remember.lp", "rb")) != nullptr) {
@@ -50,9 +51,17 @@ MainWindow::MainWindow(QWidget *parent) :
5051
}
5152

5253
/* Database */
54+
#if (QT_CREATOR == 0)
55+
path = secure_getenv("HOME");
56+
strcat(path, PATH_TO_DB);
57+
if (db_open(path) == -1) {
58+
QMessageBox::critical(this, "Error!", "Couldn't open database. Program won't work!");
59+
}
60+
#elif (QT_CREATOR == 1)
5361
if (db_open(PATH_TO_DB) == -1) {
5462
QMessageBox::critical(this, "Error!", "Couldn't open database. Program won't work!");
5563
}
64+
#endif
5665
}
5766

5867
MainWindow::~MainWindow()

src/qt/mainwindow_stud.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "mainwindow_stud.h"
2-
#include "ui_mainwindow_stud.h"
2+
#include "../build-qt-Desktop-Debug/ui_mainwindow_stud.h"
33
#include "../headers/tests_main_header.h"
44
#include "mainwindow.h"
55

@@ -599,3 +599,10 @@ void MainWindow_stud::on_MainWindow_stud_destroyed()
599599
/* Main part */
600600
db_close();
601601
}
602+
603+
void MainWindow_stud::on_actionFinal_test_triggered()
604+
{
605+
606+
/* Main part */
607+
final_test();
608+
}

src/qt/mainwindow_stud.h

+2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ private slots:
9898

9999
void on_MainWindow_stud_destroyed();
100100

101+
void on_actionFinal_test_triggered();
102+
101103
private:
102104
Ui::MainWindow_stud *ui;
103105
Dialog3 *dialog3;

src/scripts/db.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mkdir -p ${HOME}/.local/share/ProTest/ && cp -f ./db/data.sqlite ${HOME}/.local/share/ProTest/data.sqlite

0 commit comments

Comments
 (0)