#include #include #include #include #include "mainwindow.h" #include "../db/db_manager.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setApplicationName("Chat"); app.setQuitOnLastWindowClosed(false); QString cfgPath = QCoreApplication::applicationDirPath() + "/chatgui.cfg"; QString dbPath = "chats.db"; if (QFile::exists(cfgPath)) { QSettings cfg(cfgPath, QSettings::IniFormat); dbPath = cfg.value("db_path", "chats.db").toString(); } else { QSettings cfg(cfgPath, QSettings::IniFormat); cfg.setValue("db_path", "chats.db"); cfg.sync(); } if (!QDir::isAbsolutePath(dbPath)) dbPath = QCoreApplication::applicationDirPath() + "/" + dbPath; DbManager db(dbPath); MainWindow w(nullptr, &db); w.show(); return app.exec(); }