From 2f4d0567f0d2cb1110ba704d4a3634d7ca3620d8 Mon Sep 17 00:00:00 2001 From: VaggelisSotiropoulos Date: Sat, 19 Sep 2026 17:18:54 +0300 Subject: [PATCH 1/2] Added Utilities folder in resource , added 2 new files ConfigChecker.hpp/.cpp that checks if the file exists . Edited main.cpp for startup function .Edited MainWindow.cpp and added button for testing (felt cute might delete later hihi) --- CMakeLists.txt | 4 ++- resources/Utilities/ConfigChecker.cpp | 42 +++++++++++++++++++++++++++ resources/Utilities/ConfigChecker.hpp | 32 ++++++++++++++++++++ src/MainWindow.cpp | 9 ++++++ src/main.cpp | 5 +++- 5 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 resources/Utilities/ConfigChecker.cpp create mode 100644 resources/Utilities/ConfigChecker.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 48bb8e6..483c3dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,10 +17,12 @@ qt_add_executable(unibackpack src/main.cpp src/Downloader.cpp src/MainWindow.cpp + resources/Utilities/ConfigChecker.cpp # Header files include/MainWindow.hpp include/Downloader.hpp + resources/Utilities/ConfigChecker.hpp # UI ui/MainWindow.ui @@ -29,7 +31,7 @@ qt_add_executable(unibackpack resources/resources.qrc ) -target_include_directories(unibackpack PRIVATE include) +target_include_directories(unibackpack PRIVATE include resource/) target_link_libraries(unibackpack PRIVATE Qt6::Core diff --git a/resources/Utilities/ConfigChecker.cpp b/resources/Utilities/ConfigChecker.cpp new file mode 100644 index 0000000..09a70d3 --- /dev/null +++ b/resources/Utilities/ConfigChecker.cpp @@ -0,0 +1,42 @@ +// Author: +#include "ConfigChecker.hpp" + +#include +#include +#include +#include +#include + +ConfigChecker::ConfigChecker(QObject *parent) : QObject(parent) {} + +QString ConfigChecker::expectedConfigPath() { + return QDir::homePath() + "/.unios/academicConfig.json"; +} + +bool ConfigChecker::findConfigFile() const { + QFileInfo candidate(expectedConfigPath()); + return candidate.exists() && candidate.isFile(); +} + +void ConfigChecker::scanAndNotify() { + const QString path = expectedConfigPath(); + const bool found = findConfigFile(); + + const QString title = tr("UniBackpack"); + const QString message = found + ? tr("academicConfig.json was detected at:\n%1").arg(path) + : tr("Paixtike malakia na kses \n%1").arg(path); + + if (QSystemTrayIcon::isSystemTrayAvailable()) { + static QSystemTrayIcon trayIcon; + trayIcon.setIcon(QIcon(":/icons/unibackpack.png")); + trayIcon.show(); + trayIcon.showMessage(title, message, + found ? QSystemTrayIcon::Information : QSystemTrayIcon::Warning, 5000); + } else { + // No tray support on this desktop environment - fall back to the console. + qInfo().noquote() << title << ":" << message; + } + + emit scanFinished(found, path); +} diff --git a/resources/Utilities/ConfigChecker.hpp b/resources/Utilities/ConfigChecker.hpp new file mode 100644 index 0000000..1445e25 --- /dev/null +++ b/resources/Utilities/ConfigChecker.hpp @@ -0,0 +1,32 @@ +// Author: +#ifndef CONFIGCHECKER_HPP +#define CONFIGCHECKER_HPP + +#include +#include +#include + +//edw na kses psaxnei kai an ta vrei to leei ksa mou +class ConfigChecker : public QObject +{ + Q_OBJECT + + public: + explicit ConfigChecker(QObject *parent = nullptr); + + // Absolute path to the expected config file: ~/.unios/academicConfig.json + static QString expectedConfigPath(); + + // Checks for the file and shows a system notification reporting + // whether it was found. Emits scanFinished() afterwards. + void scanAndNotify(); + + // Performs the check only, with no UI side effects. Returns true + // if the file exists at expectedConfigPath(). + bool findConfigFile() const; + + signals: + void scanFinished(bool found, const QString &path); +}; + +#endif // CONFIGCHECKER_HPP diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index babde77..ba963a5 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -3,6 +3,7 @@ #include "ui_MainWindow.h" #include "MainWindow.hpp" #include "Downloader.hpp" +#include "ConfigChecker.hpp" #include #include @@ -88,6 +89,14 @@ MainWindow::MainWindow(QWidget *parent) }); retranslate(); + + QMenu *toolsMenu = menuBar()->addMenu(tr("Tools")); + QAction *checkConfigAction = toolsMenu->addAction(tr("Check for config.json")); + connect(checkConfigAction, &QAction::triggered, this, [=]() { + ConfigChecker *checker = new ConfigChecker(this); + checker->scanAndNotify("config.json"); + checker->deleteLater(); + }); } MainWindow::~MainWindow() { diff --git a/src/main.cpp b/src/main.cpp index bbe88b3..30dd713 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,7 @@ // Author: Apostolos Chalis 2026 #include #include "MainWindow.hpp" +#include "ConfigChecker.hpp" #include #include #include @@ -18,7 +19,9 @@ int main(int argc, char *argv[]){ QString lang = settings.value("language", QLocale::system().name()).toString(); applyTranslator(lang); - + ConfigChecker *startupConfigChecker = new ConfigChecker(&uni_backpack_app); + startupConfigChecker->scanAndNotify("&uni_backpack_app"); + MainWindow main_window; main_window.show(); From d28d5012f61686882c33c3a392a5e63d2305ec7e Mon Sep 17 00:00:00 2001 From: VaggelisSotiropoulos Date: Mon, 21 Sep 2026 04:53:14 +0300 Subject: [PATCH 2/2] Moved ConfigChecker.hpp to /src/Utilities ,fixied issues in main.cpp and MainWindow.cpp, added include directories for ConfigChecker.hpp/.cpp --- CMakeLists.txt | 4 ++-- src/MainWindow.cpp | 6 +++--- {resources => src}/Utilities/ConfigChecker.hpp | 2 +- src/main.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) rename {resources => src}/Utilities/ConfigChecker.hpp (91%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 483c3dd..cce18c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ qt_add_executable(unibackpack # Header files include/MainWindow.hpp include/Downloader.hpp - resources/Utilities/ConfigChecker.hpp + src/Utilities/ConfigChecker.hpp # UI ui/MainWindow.ui @@ -31,7 +31,7 @@ qt_add_executable(unibackpack resources/resources.qrc ) -target_include_directories(unibackpack PRIVATE include resource/) +target_include_directories(unibackpack PRIVATE include resources/Utilities src/Utilities) target_link_libraries(unibackpack PRIVATE Qt6::Core diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index ba963a5..65539cc 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -3,7 +3,7 @@ #include "ui_MainWindow.h" #include "MainWindow.hpp" #include "Downloader.hpp" -#include "ConfigChecker.hpp" +#include "Utilities/ConfigChecker.hpp" #include #include @@ -91,10 +91,10 @@ MainWindow::MainWindow(QWidget *parent) retranslate(); QMenu *toolsMenu = menuBar()->addMenu(tr("Tools")); - QAction *checkConfigAction = toolsMenu->addAction(tr("Check for config.json")); + QAction *checkConfigAction = toolsMenu->addAction(tr("Check for AcademicConfig.json")); connect(checkConfigAction, &QAction::triggered, this, [=]() { ConfigChecker *checker = new ConfigChecker(this); - checker->scanAndNotify("config.json"); + checker->scanAndNotify(); checker->deleteLater(); }); } diff --git a/resources/Utilities/ConfigChecker.hpp b/src/Utilities/ConfigChecker.hpp similarity index 91% rename from resources/Utilities/ConfigChecker.hpp rename to src/Utilities/ConfigChecker.hpp index 1445e25..fc5e745 100644 --- a/resources/Utilities/ConfigChecker.hpp +++ b/src/Utilities/ConfigChecker.hpp @@ -1,4 +1,4 @@ -// Author: +// Author: Vagellis Sotiropoulos 2026 #ifndef CONFIGCHECKER_HPP #define CONFIGCHECKER_HPP diff --git a/src/main.cpp b/src/main.cpp index 30dd713..e77497a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,7 @@ // Author: Apostolos Chalis 2026 #include #include "MainWindow.hpp" -#include "ConfigChecker.hpp" +#include "Utilities/ConfigChecker.hpp" #include #include #include @@ -20,7 +20,7 @@ int main(int argc, char *argv[]){ applyTranslator(lang); ConfigChecker *startupConfigChecker = new ConfigChecker(&uni_backpack_app); - startupConfigChecker->scanAndNotify("&uni_backpack_app"); + startupConfigChecker->scanAndNotify(); MainWindow main_window; main_window.show();