mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-01 23:35:55 +00:00
Store all files in the current directory for portable installations. Fixes #43
This commit is contained in:
parent
345e800abd
commit
38ff2bf5cb
@ -88,7 +88,8 @@ SOURCES += \
|
|||||||
gui/computermodel.cpp \
|
gui/computermodel.cpp \
|
||||||
gui/appmodel.cpp \
|
gui/appmodel.cpp \
|
||||||
streaming/streamutils.cpp \
|
streaming/streamutils.cpp \
|
||||||
backend/autoupdatechecker.cpp
|
backend/autoupdatechecker.cpp \
|
||||||
|
path.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
utils.h \
|
utils.h \
|
||||||
@ -104,7 +105,8 @@ HEADERS += \
|
|||||||
gui/appmodel.h \
|
gui/appmodel.h \
|
||||||
streaming/video/decoder.h \
|
streaming/video/decoder.h \
|
||||||
streaming/streamutils.h \
|
streaming/streamutils.h \
|
||||||
backend/autoupdatechecker.h
|
backend/autoupdatechecker.h \
|
||||||
|
path.h
|
||||||
|
|
||||||
# Platform-specific renderers and decoders
|
# Platform-specific renderers and decoders
|
||||||
ffmpeg {
|
ffmpeg {
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
#include "boxartmanager.h"
|
#include "boxartmanager.h"
|
||||||
|
#include "../path.h"
|
||||||
|
|
||||||
#include <QStandardPaths>
|
|
||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
#include <QImageWriter>
|
#include <QImageWriter>
|
||||||
|
|
||||||
BoxArtManager::BoxArtManager(QObject *parent) :
|
BoxArtManager::BoxArtManager(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_BoxArtDir(
|
m_BoxArtDir(Path::getBoxArtCacheDir())
|
||||||
QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/boxart")
|
|
||||||
{
|
{
|
||||||
if (!m_BoxArtDir.exists()) {
|
if (!m_BoxArtDir.exists()) {
|
||||||
m_BoxArtDir.mkpath(".");
|
m_BoxArtDir.mkpath(".");
|
||||||
|
23
app/main.cpp
23
app/main.cpp
@ -11,6 +11,7 @@
|
|||||||
#define SDL_MAIN_HANDLED
|
#define SDL_MAIN_HANDLED
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
|
#include "path.h"
|
||||||
#include "gui/computermodel.h"
|
#include "gui/computermodel.h"
|
||||||
#include "gui/appmodel.h"
|
#include "gui/appmodel.h"
|
||||||
#include "backend/autoupdatechecker.h"
|
#include "backend/autoupdatechecker.h"
|
||||||
@ -130,15 +131,23 @@ void qtLogToDiskHandler(QtMsgType type, const QMessageLogContext&, const QString
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
if (QFile(QDir::currentPath() + "/portable.dat").exists()) {
|
||||||
|
qInfo() << "Running in portable mode from:" << QDir::currentPath();
|
||||||
|
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||||
|
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, QDir::currentPath());
|
||||||
|
QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, QDir::currentPath());
|
||||||
|
|
||||||
|
// Initialize paths for portable mode
|
||||||
|
Path::initialize(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Initialize paths for standard installation
|
||||||
|
Path::initialize(false);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_CUSTOM_LOGGER
|
#ifdef USE_CUSTOM_LOGGER
|
||||||
#ifdef LOG_TO_FILE
|
#ifdef LOG_TO_FILE
|
||||||
#ifdef Q_OS_DARWIN
|
QDir tempDir(Path::getLogDir());
|
||||||
// On macOS, $TMPDIR is some random folder under /var/folders/ that nobody can
|
|
||||||
// easily find, so use the system's global tmp directory instead.
|
|
||||||
QDir tempDir("/tmp");
|
|
||||||
#else
|
|
||||||
QDir tempDir(QDir::tempPath());
|
|
||||||
#endif
|
|
||||||
s_LoggerFile = new QFile(tempDir.filePath(QString("Moonlight-%1.log").arg(QDateTime::currentSecsSinceEpoch())));
|
s_LoggerFile = new QFile(tempDir.filePath(QString("Moonlight-%1.log").arg(QDateTime::currentSecsSinceEpoch())));
|
||||||
if (s_LoggerFile->open(QIODevice::WriteOnly)) {
|
if (s_LoggerFile->open(QIODevice::WriteOnly)) {
|
||||||
qInfo() << "Redirecting log output to " << s_LoggerFile->fileName();
|
qInfo() << "Redirecting log output to " << s_LoggerFile->fileName();
|
||||||
|
39
app/path.cpp
Normal file
39
app/path.cpp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#include "path.h"
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
|
QString Path::s_LogDir;
|
||||||
|
QString Path::s_BoxArtCacheDir;
|
||||||
|
|
||||||
|
QString Path::getLogDir()
|
||||||
|
{
|
||||||
|
Q_ASSERT(!s_LogDir.isEmpty());
|
||||||
|
return s_LogDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Path::getBoxArtCacheDir()
|
||||||
|
{
|
||||||
|
Q_ASSERT(!s_BoxArtCacheDir.isEmpty());
|
||||||
|
return s_BoxArtCacheDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Path::initialize(bool portable)
|
||||||
|
{
|
||||||
|
if (portable) {
|
||||||
|
s_LogDir = QDir::currentPath();
|
||||||
|
s_BoxArtCacheDir = QDir::currentPath() + "/boxart";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#ifdef Q_OS_DARWIN
|
||||||
|
// On macOS, $TMPDIR is some random folder under /var/folders/ that nobody can
|
||||||
|
// easily find, so use the system's global tmp directory instead.
|
||||||
|
s_LogDir = "/tmp";
|
||||||
|
#else
|
||||||
|
s_LogDir = QDir::tempPath();
|
||||||
|
#endif
|
||||||
|
s_BoxArtCacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/boxart";
|
||||||
|
}
|
||||||
|
}
|
16
app/path.h
Normal file
16
app/path.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
class Path
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static QString getLogDir();
|
||||||
|
|
||||||
|
static QString getBoxArtCacheDir();
|
||||||
|
|
||||||
|
static void initialize(bool portable);
|
||||||
|
|
||||||
|
static QString s_LogDir;
|
||||||
|
static QString s_BoxArtCacheDir;
|
||||||
|
};
|
@ -120,6 +120,8 @@ echo Building portable package
|
|||||||
rem This must be done after WiX harvesting and signing, since the VCRT dlls are MS signed
|
rem This must be done after WiX harvesting and signing, since the VCRT dlls are MS signed
|
||||||
rem and should not be harvested for inclusion in the full installer
|
rem and should not be harvested for inclusion in the full installer
|
||||||
copy "%VCREDIST_PATH%\%ARCH%\Microsoft.VC141.CRT\*.dll" %DEPLOY_FOLDER%
|
copy "%VCREDIST_PATH%\%ARCH%\Microsoft.VC141.CRT\*.dll" %DEPLOY_FOLDER%
|
||||||
|
rem This file tells Moonlight that it's a portable installation
|
||||||
|
echo. > %DEPLOY_FOLDER%\portable.dat
|
||||||
if !ERRORLEVEL! NEQ 0 goto Error
|
if !ERRORLEVEL! NEQ 0 goto Error
|
||||||
7z a %INSTALLER_FOLDER%\MoonlightPortable.zip %DEPLOY_FOLDER%\*
|
7z a %INSTALLER_FOLDER%\MoonlightPortable.zip %DEPLOY_FOLDER%\*
|
||||||
if !ERRORLEVEL! NEQ 0 goto Error
|
if !ERRORLEVEL! NEQ 0 goto Error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user