diff --git a/RedPandaIDE/compiler/executablerunner.cpp b/RedPandaIDE/compiler/executablerunner.cpp
index 5c3a839f..7a4ecec4 100644
--- a/RedPandaIDE/compiler/executablerunner.cpp
+++ b/RedPandaIDE/compiler/executablerunner.cpp
@@ -71,7 +71,7 @@ void ExecutableRunner::run()
pathAdded.append(dir);
}
}
- pathAdded.append(pSettings->dirs().app());
+ pathAdded.append(pSettings->dirs().appDir());
if (!path.isEmpty()) {
path+= PATH_SEPARATOR + pathAdded.join(PATH_SEPARATOR);
} else {
diff --git a/RedPandaIDE/compiler/ojproblemcasesrunner.cpp b/RedPandaIDE/compiler/ojproblemcasesrunner.cpp
index 9c59c1bd..f1b378ac 100644
--- a/RedPandaIDE/compiler/ojproblemcasesrunner.cpp
+++ b/RedPandaIDE/compiler/ojproblemcasesrunner.cpp
@@ -40,7 +40,7 @@ void OJProblemCasesRunner::runCase(int index,POJProblemCase problemCase)
pathAdded.append(dir);
}
}
- pathAdded.append(pSettings->dirs().app());
+ pathAdded.append(pSettings->dirs().appDir());
if (!path.isEmpty()) {
path+= PATH_SEPARATOR + pathAdded.join(PATH_SEPARATOR);
} else {
diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp
index 8c41500b..9a1a18cb 100644
--- a/RedPandaIDE/editor.cpp
+++ b/RedPandaIDE/editor.cpp
@@ -3853,7 +3853,7 @@ void Editor::reformat()
QByteArray content = text().toUtf8();
QStringList args = pSettings->codeFormatter().getArguments();
QByteArray newContent = runAndGetOutput("astyle.exe",
- pSettings->dirs().app(),
+ pSettings->dirs().appDir(),
args,
content);
int oldTopLine = topLine();
diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp
index 774bb584..338b7d8b 100644
--- a/RedPandaIDE/mainwindow.cpp
+++ b/RedPandaIDE/mainwindow.cpp
@@ -2018,7 +2018,7 @@ void MainWindow::updateTools()
file.close();
if (item->pauseAfterExit) {
executeFile(
- includeTrailingPathDelimiter(pSettings->dirs().app())+"ConsolePauser.exe",
+ includeTrailingPathDelimiter(pSettings->dirs().appDir())+"ConsolePauser.exe",
" 1 \""+localizePath(file.fileName())+"\" ",
workDir, file.fileName());
} else {
@@ -2031,7 +2031,7 @@ void MainWindow::updateTools()
} else {
if (item->pauseAfterExit) {
executeFile(
- includeTrailingPathDelimiter(pSettings->dirs().app())+"ConsolePauser.exe",
+ includeTrailingPathDelimiter(pSettings->dirs().appDir())+"ConsolePauser.exe",
" 1 \""+program+"\" "+params,
workDir, "");
} else {
@@ -2696,7 +2696,7 @@ void MainWindow::openShell(const QString &folder, const QString &shellCommand)
pathAdded.append(dir);
}
}
- pathAdded.append(pSettings->dirs().app());
+ pathAdded.append(pSettings->dirs().appDir());
if (!path.isEmpty()) {
path= pathAdded.join(PATH_SEPARATOR) + PATH_SEPARATOR + path;
} else {
@@ -5574,7 +5574,7 @@ void MainWindow::on_actionMove_To_Other_View_triggered()
void MainWindow::on_actionC_C_Reference_triggered()
{
if (pSettings->environment().language()=="zh_CN") {
- QFileInfo fileInfo(includeTrailingPathDelimiter(pSettings->dirs().app())+"cppreference-zh.chm");
+ QFileInfo fileInfo(includeTrailingPathDelimiter(pSettings->dirs().appDir())+"cppreference-zh.chm");
if (fileInfo.exists()) {
QDesktopServices::openUrl(QUrl::fromLocalFile(fileInfo.absoluteFilePath()));
} else {
diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp
index 29031f40..cfb0d7de 100644
--- a/RedPandaIDE/settings.cpp
+++ b/RedPandaIDE/settings.cpp
@@ -151,14 +151,26 @@ Settings::Dirs::Dirs(Settings *settings):
{
}
-QString Settings::Dirs::app() const
+QString Settings::Dirs::appDir() const
{
return QApplication::instance()->applicationDirPath();
}
+QString Settings::Dirs::appLibDir() const
+{
+#ifdef Q_OS_WIN
+ return appDir();
+#elif defined(Q_OS_LINUX)
+ if (isGreenEdition()) {
+ return app();
+ }
+ return includeTrailingPathDelimiter(PREFIX)+"lib";
+#endif
+}
+
QString Settings::Dirs::templateDir() const
{
- return includeTrailingPathDelimiter(app()) + "templates";
+ return includeTrailingPathDelimiter(appDir()) + "templates";
}
QString Settings::Dirs::projectDir() const
@@ -169,7 +181,7 @@ QString Settings::Dirs::projectDir() const
QString Settings::Dirs::data(Settings::Dirs::DataType dataType) const
{
using DataType = Settings::Dirs::DataType;
- QString dataDir = includeTrailingPathDelimiter(app())+"data";
+ QString dataDir = includeTrailingPathDelimiter(appDir())+"data";
switch (dataType) {
case DataType::None:
return dataDir;
@@ -209,7 +221,7 @@ void Settings::Dirs::doLoad()
{
QString defaultProjectDir;
if (isGreenEdition()) {
- defaultProjectDir = includeTrailingPathDelimiter(app()) + "projects";
+ defaultProjectDir = includeTrailingPathDelimiter(appDir()) + "projects";
} else {
defaultProjectDir = includeTrailingPathDelimiter(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0])
+ "projects";
@@ -2468,8 +2480,8 @@ void Settings::CompilerSets::clearSets()
void Settings::CompilerSets::findSets()
{
clearSets();
- addSets(includeTrailingPathDelimiter(mSettings->dirs().app())+"MinGW32"+QDir::separator()+"bin");
- addSets(includeTrailingPathDelimiter(mSettings->dirs().app())+"MinGW64"+QDir::separator()+"bin");
+ addSets(includeTrailingPathDelimiter(mSettings->dirs().appDir())+"MinGW32"+QDir::separator()+"bin");
+ addSets(includeTrailingPathDelimiter(mSettings->dirs().appDir())+"MinGW64"+QDir::separator()+"bin");
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString path = env.value("PATH");
@@ -2551,8 +2563,8 @@ void Settings::CompilerSets::loadSets()
QObject::tr("Compiler set not configuared.")
+"
"
+QObject::tr("Would you like Red Panda C++ to search for compilers in the following locations:
'%1'
'%2'? ")
- .arg(includeTrailingPathDelimiter(pSettings->dirs().app()) + "MinGW32")
- .arg(includeTrailingPathDelimiter(pSettings->dirs().app()) + "MinGW64"),
+ .arg(includeTrailingPathDelimiter(pSettings->dirs().appDir()) + "MinGW32")
+ .arg(includeTrailingPathDelimiter(pSettings->dirs().appDir()) + "MinGW64"),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
return;
}
@@ -2629,8 +2641,8 @@ Settings::PCompilerSet Settings::CompilerSets::getSet(int index)
void Settings::CompilerSets::savePath(const QString& name, const QString& path) {
QString s;
- QString prefix1 = excludeTrailingPathDelimiter(mSettings->mDirs.app()) + "/";
- QString prefix2 = excludeTrailingPathDelimiter(mSettings->mDirs.app()) + QDir::separator();
+ QString prefix1 = excludeTrailingPathDelimiter(mSettings->mDirs.appDir()) + "/";
+ QString prefix2 = excludeTrailingPathDelimiter(mSettings->mDirs.appDir()) + QDir::separator();
if (path.startsWith(prefix1, PATH_SENSITIVITY)) {
s = "%AppPath%/"+ path.mid(prefix1.length());
} else if (path.startsWith(prefix2, PATH_SENSITIVITY)) {
@@ -2645,8 +2657,8 @@ void Settings::CompilerSets::savePathList(const QString& name, const QStringList
QStringList sl;
for (const QString& path: pathList) {
QString s;
- QString prefix1 = excludeTrailingPathDelimiter(mSettings->mDirs.app()) + "/";
- QString prefix2 = excludeTrailingPathDelimiter(mSettings->mDirs.app()) + QDir::separator();
+ QString prefix1 = excludeTrailingPathDelimiter(mSettings->mDirs.appDir()) + "/";
+ QString prefix2 = excludeTrailingPathDelimiter(mSettings->mDirs.appDir()) + QDir::separator();
if (path.startsWith(prefix1, PATH_SENSITIVITY)) {
s = "%AppPath%/"+ path.mid(prefix1.length());
} else if (path.startsWith(prefix2, PATH_SENSITIVITY)) {
@@ -2706,7 +2718,7 @@ QString Settings::CompilerSets::loadPath(const QString &name)
QString s = mSettings->mSettings.value(name).toString();
QString prefix = "%AppPath%/";
if (s.startsWith(prefix)) {
- s = includeTrailingPathDelimiter(mSettings->mDirs.app()) + s.mid(prefix.length());
+ s = includeTrailingPathDelimiter(mSettings->mDirs.appDir()) + s.mid(prefix.length());
}
return QFileInfo(s).absoluteFilePath();
}
@@ -2718,7 +2730,7 @@ void Settings::CompilerSets::loadPathList(const QString &name, QStringList& list
QString prefix = "%AppPath%/";
for (QString& s:sl) {
if (s.startsWith(prefix)) {
- s = includeTrailingPathDelimiter(mSettings->mDirs.app()) + s.mid(prefix.length());
+ s = includeTrailingPathDelimiter(mSettings->mDirs.appDir()) + s.mid(prefix.length());
}
list.append(QFileInfo(s).absoluteFilePath());
}
diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h
index be4cd9ef..2a89c327 100644
--- a/RedPandaIDE/settings.h
+++ b/RedPandaIDE/settings.h
@@ -89,7 +89,8 @@ public:
ColorSheme
};
explicit Dirs(Settings * settings);
- QString app() const;
+ QString appDir() const;
+ QString appLibDir() const;
QString templateDir() const;
QString projectDir() const;
QString data(DataType dataType = DataType::None) const;
diff --git a/RedPandaIDE/settingsdialog/compilersetoptionwidget.cpp b/RedPandaIDE/settingsdialog/compilersetoptionwidget.cpp
index 74baad4b..69326b33 100644
--- a/RedPandaIDE/settingsdialog/compilersetoptionwidget.cpp
+++ b/RedPandaIDE/settingsdialog/compilersetoptionwidget.cpp
@@ -221,8 +221,8 @@ void CompilerSetOptionWidget::on_btnFindCompilers_pressed()
if (QMessageBox::warning(this,tr("Confirm"),
tr("Red Panda C++ will clear current compiler list and search"
" for compilers in the following locations:\n '%1'\n'%2'\nAre you really want to continue?")
- .arg(includeTrailingPathDelimiter(pSettings->dirs().app()) + "MinGW32")
- .arg(includeTrailingPathDelimiter(pSettings->dirs().app()) + "MinGW64"),
+ .arg(includeTrailingPathDelimiter(pSettings->dirs().appDir()) + "MinGW32")
+ .arg(includeTrailingPathDelimiter(pSettings->dirs().appDir()) + "MinGW64"),
QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok )
return;
pSettings->compilerSets().clearSets();
diff --git a/RedPandaIDE/settingsdialog/formattergeneralwidget.cpp b/RedPandaIDE/settingsdialog/formattergeneralwidget.cpp
index be2fc025..c1298f2e 100644
--- a/RedPandaIDE/settingsdialog/formattergeneralwidget.cpp
+++ b/RedPandaIDE/settingsdialog/formattergeneralwidget.cpp
@@ -306,7 +306,7 @@ void FormatterGeneralWidget::updateDemo()
updateCodeFormatter(formatter);
QByteArray newContent = runAndGetOutput("astyle.exe",
- pSettings->dirs().app(),
+ pSettings->dirs().appDir(),
formatter.getArguments(),
content);
ui->editDemo->lines()->setText(newContent);
diff --git a/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp b/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp
index fd538adc..d247d4ec 100644
--- a/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp
+++ b/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp
@@ -113,7 +113,7 @@ void ProjectGeneralWidget::on_btnBrowse_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this,
tr("Select icon file"),
- pSettings->dirs().app(),
+ pSettings->dirs().appDir(),
tr("Icon Files (*.ico)"));
if (!fileName.isEmpty()) {
mIconPath = fileName;
diff --git a/RedPandaIDE/settingsdialog/toolsgeneralwidget.cpp b/RedPandaIDE/settingsdialog/toolsgeneralwidget.cpp
index 6bc7f92a..66ff9816 100644
--- a/RedPandaIDE/settingsdialog/toolsgeneralwidget.cpp
+++ b/RedPandaIDE/settingsdialog/toolsgeneralwidget.cpp
@@ -228,7 +228,7 @@ void ToolsGeneralWidget::on_btnBrowseProgram_clicked()
QString fileName = QFileDialog::getOpenFileName(
this,
tr("Select program"),
- pSettings->dirs().app(),
+ pSettings->dirs().appDir(),
tr("Executable files (*.exe)"));
if (!fileName.isEmpty() ) {
ui->txtProgram->setText(fileName);
diff --git a/RedPandaIDE/systemconsts.h b/RedPandaIDE/systemconsts.h
index c327470a..f69fd15d 100644
--- a/RedPandaIDE/systemconsts.h
+++ b/RedPandaIDE/systemconsts.h
@@ -3,6 +3,10 @@
#include
+#ifndef PREFIX
+#define PREFIX "/usr/local"
+#endif
+
#define APP_SETTSINGS_FILENAME "redpandacpp.ini"
#ifdef Q_OS_WIN
#define GCC_PROGRAM "gcc.exe"
diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp
index 417ee18c..5ac0420a 100644
--- a/RedPandaIDE/utils.cpp
+++ b/RedPandaIDE/utils.cpp
@@ -781,7 +781,7 @@ QString parseMacros(const QString &s)
result.replace("", localizePath(QDir::currentPath()));
result.replace("", localizePath(pSettings->dirs().executable()));
result.replace("", DEVCPP_VERSION);
- result.replace("", localizePath(pSettings->dirs().app()));
+ result.replace("", localizePath(pSettings->dirs().appDir()));
QDate today = QDate::currentDate();
QDateTime now = QDateTime::currentDateTime();