You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
894 B

#include <QApplication>
#include <QFile>
#include <QDir>
#include <QSettings>
#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();
}