refactor: CoreTool use arch classes directly
This commit is contained in:
parent
946a2b778e
commit
ce784ab383
2 changed files with 26 additions and 21 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
* Deskflow -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2024 Chris Rizzitello <sithlord48@gmail.com>
|
||||||
* Copyright (C) 2015 Symless Ltd.
|
* Copyright (C) 2015 Symless Ltd.
|
||||||
*
|
*
|
||||||
* This package is free software; you can redistribute it and/or
|
* This package is free software; you can redistribute it and/or
|
||||||
|
|
@ -17,37 +18,42 @@
|
||||||
|
|
||||||
#include "gui/core/CoreTool.h"
|
#include "gui/core/CoreTool.h"
|
||||||
|
|
||||||
#include "CommandProcess.h"
|
#if defined(Q_OS_UNIX)
|
||||||
|
#include "arch/unix/ArchFileUnix.h"
|
||||||
|
#include "arch/unix/ArchSystemUnix.h"
|
||||||
|
#elif defined(Q_OS_WIN)
|
||||||
|
#include "arch/win32/ArchFileWindows.h"
|
||||||
|
#include "arch/win32/ArchSystemWindows.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QProcess>
|
|
||||||
#include <QtGlobal>
|
|
||||||
|
|
||||||
static const char kCoreBinary[] = LEGACY_BINARY_NAME;
|
|
||||||
|
|
||||||
QString CoreTool::getProfileDir() const
|
QString CoreTool::getProfileDir() const
|
||||||
{
|
{
|
||||||
QStringList args("--get-profile-dir");
|
#if defined Q_OS_UNIX
|
||||||
return QDir::cleanPath(run(args));
|
ArchFileUnix sysInfo;
|
||||||
|
#elif defined Q_OS_WIN
|
||||||
|
ArchFileWindows sysInfo;
|
||||||
|
#endif
|
||||||
|
return QDir::cleanPath(QString::fromUtf8(sysInfo.getProfileDirectory()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CoreTool::getInstalledDir() const
|
QString CoreTool::getInstalledDir() const
|
||||||
{
|
{
|
||||||
QStringList args("--get-installed-dir");
|
#if defined Q_OS_UNIX
|
||||||
return QDir::cleanPath(run(args));
|
ArchFileUnix sysInfo;
|
||||||
|
#elif defined Q_OS_WIN
|
||||||
|
ArchFileWindows sysInfo;
|
||||||
|
#endif
|
||||||
|
return QDir::cleanPath(QString::fromUtf8(sysInfo.getInstalledDirectory()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CoreTool::getArch() const
|
QString CoreTool::getArch() const
|
||||||
{
|
{
|
||||||
QStringList args("--get-arch");
|
#if defined Q_OS_UNIX
|
||||||
return run(args);
|
ArchSystemUnix sysInfo;
|
||||||
}
|
#elif defined Q_OS_WIN
|
||||||
|
ArchSystemWindows sysInfo;
|
||||||
QString CoreTool::run(const QStringList &args, const QString &input) const
|
#endif
|
||||||
{
|
return QString::fromUtf8(sysInfo.getPlatformName());
|
||||||
QString program(QCoreApplication::applicationDirPath() + "/" + kCoreBinary);
|
|
||||||
|
|
||||||
CommandProcess commandProcess(program, args, input);
|
|
||||||
return commandProcess.run();
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,5 +25,4 @@ public:
|
||||||
QString getProfileDir() const;
|
QString getProfileDir() const;
|
||||||
QString getInstalledDir() const;
|
QString getInstalledDir() const;
|
||||||
QString getArch() const;
|
QString getArch() const;
|
||||||
QString run(const QStringList &args, const QString &input = "") const;
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue