diff --git a/CMakeLists.txt b/CMakeLists.txt index 48bb8e6..cce18c9 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 + src/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 resources/Utilities src/Utilities) 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/src/MainWindow.cpp b/src/MainWindow.cpp index babde77..65539cc 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -3,6 +3,7 @@ #include "ui_MainWindow.h" #include "MainWindow.hpp" #include "Downloader.hpp" +#include "Utilities/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 AcademicConfig.json")); + connect(checkConfigAction, &QAction::triggered, this, [=]() { + ConfigChecker *checker = new ConfigChecker(this); + checker->scanAndNotify(); + checker->deleteLater(); + }); } MainWindow::~MainWindow() { diff --git a/src/Utilities/ConfigChecker.hpp b/src/Utilities/ConfigChecker.hpp new file mode 100644 index 0000000..fc5e745 --- /dev/null +++ b/src/Utilities/ConfigChecker.hpp @@ -0,0 +1,32 @@ +// Author: Vagellis Sotiropoulos 2026 +#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/main.cpp b/src/main.cpp index bbe88b3..e77497a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,7 @@ // Author: Apostolos Chalis 2026 #include #include "MainWindow.hpp" +#include "Utilities/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(); + MainWindow main_window; main_window.show();