2021-04-06 23:10:57 +08:00
|
|
|
#include "mainwindow.h"
|
2021-04-08 10:29:21 +08:00
|
|
|
#include "settings.h"
|
2021-04-11 21:33:08 +08:00
|
|
|
#include "systemconsts.h"
|
2021-04-13 22:17:18 +08:00
|
|
|
#include "utils.h"
|
2021-04-06 23:10:57 +08:00
|
|
|
#include <QApplication>
|
2021-04-12 00:00:29 +08:00
|
|
|
#include <QDir>
|
|
|
|
#include <QTranslator>
|
|
|
|
#include <QDebug>
|
2021-04-13 22:17:18 +08:00
|
|
|
#include <QStandardPaths>
|
|
|
|
#include <QMessageBox>
|
2021-04-15 11:18:14 +08:00
|
|
|
#include <QStringList>
|
2021-04-24 15:57:45 +08:00
|
|
|
#include "common.h"
|
2021-04-13 22:17:18 +08:00
|
|
|
|
|
|
|
Settings* createAppSettings(const QString& filepath = QString()) {
|
2021-04-15 11:18:14 +08:00
|
|
|
QString filename;
|
|
|
|
if (filepath.isEmpty()) {
|
|
|
|
if (isGreenEdition()) {
|
2021-04-20 22:24:33 +08:00
|
|
|
filename = includeTrailingPathDelimiter(QApplication::applicationDirPath()) +
|
|
|
|
"config/" + APP_SETTSINGS_FILENAME;
|
2021-04-15 11:18:14 +08:00
|
|
|
} else {
|
2021-04-20 22:24:33 +08:00
|
|
|
filename =includeTrailingPathDelimiter(QStandardPaths::standardLocations(QStandardPaths::AppDataLocation)[0])
|
|
|
|
+ APP_SETTSINGS_FILENAME;
|
2021-04-15 11:18:14 +08:00
|
|
|
}
|
2021-04-13 22:17:18 +08:00
|
|
|
} else {
|
|
|
|
filename = filepath;
|
|
|
|
}
|
|
|
|
|
2021-04-15 11:18:14 +08:00
|
|
|
QFileInfo fileInfo(filename);
|
|
|
|
QDir dir(fileInfo.absoluteDir());
|
2021-04-13 22:17:18 +08:00
|
|
|
if (!dir.exists()) {
|
|
|
|
if (!dir.mkpath(dir.absolutePath())) {
|
|
|
|
QMessageBox::information(nullptr, QObject::tr("Error"),
|
|
|
|
QString(QObject::tr("Can't create configuration folder %1")).arg(dir.absolutePath()));
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fileInfo.exists() && !fileInfo.isWritable()) {
|
2021-04-15 11:18:14 +08:00
|
|
|
QMessageBox::information(nullptr, QObject::tr("Error"),
|
|
|
|
QString(QObject::tr("Can't write to configuration file %1")).arg(filename));
|
|
|
|
|
2021-04-13 22:17:18 +08:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return new Settings(filename);
|
|
|
|
}
|
2021-04-06 23:10:57 +08:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2021-04-11 21:33:08 +08:00
|
|
|
QApplication app(argc, argv);
|
2021-04-13 22:17:18 +08:00
|
|
|
|
2021-04-24 15:57:45 +08:00
|
|
|
qRegisterMetaType<PCompileIssue>("PCompileIssue");
|
|
|
|
qRegisterMetaType<PCompileIssue>("PCompileIssue&");
|
|
|
|
|
2021-04-13 22:17:18 +08:00
|
|
|
//load translations
|
2021-04-12 00:00:29 +08:00
|
|
|
QTranslator trans;
|
|
|
|
trans.load(("RedPandaIDE_zh_CN"));
|
|
|
|
app.installTranslator(&trans);
|
2021-04-13 22:17:18 +08:00
|
|
|
|
2021-04-11 21:33:08 +08:00
|
|
|
SystemConsts systemConsts;
|
|
|
|
pSystemConsts = &systemConsts;
|
2021-04-13 22:17:18 +08:00
|
|
|
|
|
|
|
pSettings = createAppSettings();
|
|
|
|
if (pSettings == nullptr) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
auto settings = std::unique_ptr<Settings>(pSettings);
|
2021-06-13 23:22:26 +08:00
|
|
|
settings->compilerSets().loadSets();
|
|
|
|
settings->editor().load();
|
2021-04-13 22:17:18 +08:00
|
|
|
|
2021-04-15 21:32:45 +08:00
|
|
|
//settings->compilerSets().addSets("e:/workspace/contributes/Dev-CPP/MinGW32_GCC92");
|
2021-04-17 14:52:47 +08:00
|
|
|
// settings->compilerSets().findSets();
|
|
|
|
// settings->compilerSets().saveSets();
|
|
|
|
// qDebug() << settings->compilerSets().defaultSet()->binDirs();
|
|
|
|
// settings->compilerSets().loadSets();
|
|
|
|
// qDebug() << settings->compilerSets().defaultSet()->defines();
|
|
|
|
// qDebug() << settings->compilerSets().defaultSet()->CCompiler();
|
2021-04-15 21:32:45 +08:00
|
|
|
// qDebug()<<settings->compilerSets().size();
|
|
|
|
// qDebug()<<settings->compilerSets().list().at(0)->binDirs();
|
2021-06-05 23:43:45 +08:00
|
|
|
|
|
|
|
// load theme
|
|
|
|
// QFile cssFile("dracula.css");
|
|
|
|
// if (cssFile.open(QFile::ReadOnly)) {
|
|
|
|
// QString qss = QLatin1String(cssFile.readAll());
|
|
|
|
// app.setStyleSheet(qss);
|
|
|
|
// }
|
2021-04-11 21:33:08 +08:00
|
|
|
MainWindow mainWindow;
|
|
|
|
pMainWindow = &mainWindow;
|
|
|
|
mainWindow.show();
|
2021-04-15 21:32:45 +08:00
|
|
|
int retCode = app.exec();
|
|
|
|
// save settings
|
2021-04-17 14:52:47 +08:00
|
|
|
// settings->compilerSets().saveSets();
|
2021-04-15 21:32:45 +08:00
|
|
|
return retCode;
|
2021-04-06 23:10:57 +08:00
|
|
|
}
|