mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-29 15:55:04 +00:00
Added function to load cutterrc from all standard paths along with home (#2109)
* added function to load cutterrc from all standard paths along with home
This commit is contained in:
parent
3f4edfb3a0
commit
b06a6d0da8
@ -3,6 +3,9 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QDir>
|
||||
#include <QCoreApplication>
|
||||
#include <QVector>
|
||||
#include <QStringList>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
@ -226,20 +229,32 @@ RCoreLocked CutterCore::core()
|
||||
return RCoreLocked(this);
|
||||
}
|
||||
|
||||
QVector<QDir> CutterCore::getCutterRCDirectories() const
|
||||
{
|
||||
QVector<QDir> result;
|
||||
result.push_back(QDir::home());
|
||||
QStringList locations = QStandardPaths::standardLocations(QStandardPaths::AppConfigLocation);
|
||||
for (auto &location : locations) {
|
||||
result.push_back(QDir(location));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CutterCore::loadCutterRC()
|
||||
{
|
||||
CORE_LOCK();
|
||||
auto home = QDir::home();
|
||||
if (!home.exists()) {
|
||||
return;
|
||||
|
||||
const auto result = getCutterRCDirectories();
|
||||
for(auto &dir : result){
|
||||
if(!dir.exists())continue;
|
||||
auto cutterRCFileInfo = QFileInfo(dir, ".cutterrc");
|
||||
auto path = cutterRCFileInfo.absoluteFilePath();
|
||||
if (!cutterRCFileInfo.isFile()) {
|
||||
continue;
|
||||
}
|
||||
qInfo() << "Loading initialization file from" << path;
|
||||
r_core_cmd_file(core, path.toUtf8().constData());
|
||||
}
|
||||
auto cutterRCFileInfo = QFileInfo(home, ".cutterrc");
|
||||
if (!cutterRCFileInfo.isFile()) {
|
||||
return;
|
||||
}
|
||||
auto path = cutterRCFileInfo.absoluteFilePath();
|
||||
qInfo() << "Loading" << path;
|
||||
r_core_cmd_file(core, path.toUtf8().constData());
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QErrorMessage>
|
||||
#include <QMutex>
|
||||
#include <QDir>
|
||||
|
||||
class AsyncTaskManager;
|
||||
class BasicInstructionHighlighter;
|
||||
@ -706,6 +707,8 @@ private:
|
||||
|
||||
QSharedPointer<R2Task> debugTask;
|
||||
R2TaskDialog *debugTaskDialog;
|
||||
|
||||
QVector<QDir> getCutterRCDirectories() const;
|
||||
};
|
||||
|
||||
class RCoreLocked
|
||||
|
Loading…
Reference in New Issue
Block a user