Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/handlerstorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
static const QRegularExpression invalid_arguments("\"?%[0-9]+\"?");

HandlerStorage::HandlerStorage(const QString& storagePath, QObject* parent)
: QObject(parent), m_SettingsPath(storagePath + "/nxmhandler.ini")
: QObject(parent), m_SettingsPath(storagePath + "/downloadhandler.ini")
{
loadStore();
}
Expand Down
21 changes: 15 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ HandlerStorage* registerSchemaExecutable(const QDir& storagePath,
return storage;
}

QSettings resolveSettings(QDir baseDir)
{
if (!baseDir.exists("downloadhandler.ini") && baseDir.exists("nxmhandler.ini")) {
QFile oldSettings(baseDir.absoluteFilePath("nxmhandler.ini"));
oldSettings.copy(baseDir.absoluteFilePath("downloadhandler.ini"));
}
return QSettings(baseDir.absoluteFilePath("downloadhandler.ini"));
Comment thread
Silarn marked this conversation as resolved.
Outdated
}

HandlerStorage* registerHandler(HandlerStorage* storage, const QString& schema,
bool forceReg)
{
Expand All @@ -125,21 +134,21 @@ HandlerStorage* registerHandler(HandlerStorage* storage, const QString& schema,

QDir handlerBaseDir = QFileInfo(handlerPath).absoluteDir();

QSettings settings(baseDir.absoluteFilePath("nxmhandler.ini"), QSettings::IniFormat);
bool noRegister = settings.value("noregister", false).toBool();
if (globalStorage.exists("nxmhandler.ini") &&
QSettings settings = resolveSettings(baseDir);
bool noRegister = settings.value("noregister", false).toBool();
if (globalStorage.exists("downloadhandler.ini") &&
handlerPath.endsWith("nxmhandler.exe", Qt::CaseInsensitive) &&
QFile::exists(handlerPath)) {
// global configuration avaible - use it
// global configuration available - use it
if (storage == nullptr)
storage = new HandlerStorage(globalStorage.path());
} else if (handlerBaseDir.exists("nxmhandler.ini") &&
} else if (handlerBaseDir.exists("downloadhandler.ini") &&
handlerPath.endsWith("nxmhandler.exe", Qt::CaseInsensitive) &&
QFile::exists(handlerPath)) {
// a portable installation is registered to handle links, use its
// configuration
if (storage == nullptr)
storage = new HandlerStorage(globalStorage.path());
storage = new HandlerStorage(handlerBaseDir.path());
if (forceReg && (QString::compare(QDir::toNativeSeparators(
QCoreApplication::applicationFilePath()),
handlerPath, Qt::CaseInsensitive))) {
Expand Down
Loading