mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 03:22:33 +01:00
Move Window and widget location setup into settings
This commit is contained in:
parent
89170d3698
commit
5c530f5e13
@ -50,6 +50,7 @@ int main(int argc, char* argv[])
|
|||||||
// This gives us nice clickable output in QtCreator
|
// This gives us nice clickable output in QtCreator
|
||||||
qSetMessagePattern("%{if-category}%{category}: %{endif}%{message}\n Loc: [%{file}:%{line}]");
|
qSetMessagePattern("%{if-category}%{category}: %{endif}%{message}\n Loc: [%{file}:%{line}]");
|
||||||
|
|
||||||
|
// Qt < 6.0 needs this init QtWebEngine
|
||||||
QtWebEngine::initialize();
|
QtWebEngine::initialize();
|
||||||
|
|
||||||
QFontDatabase::addApplicationFont(":/assets/fonts/LibreBaskerville-Italic.ttf");
|
QFontDatabase::addApplicationFont(":/assets/fonts/LibreBaskerville-Italic.ttf");
|
||||||
@ -73,67 +74,12 @@ int main(int argc, char* argv[])
|
|||||||
ScreenPlay screenPlay(&installedListModel, &settings, &monitorListModel, &app, &sdkConnector);
|
ScreenPlay screenPlay(&installedListModel, &settings, &monitorListModel, &app, &sdkConnector);
|
||||||
Create create(&settings, &qmlUtil);
|
Create create(&settings, &qmlUtil);
|
||||||
|
|
||||||
QDir SPWorkingDir(QDir::currentPath());
|
|
||||||
QDir SPBaseDir(QDir::currentPath());
|
|
||||||
|
|
||||||
#ifdef QT_DEBUG
|
|
||||||
qDebug() << "Starting in Debug mode!";
|
|
||||||
|
|
||||||
if (SPWorkingDir.cdUp()) {
|
|
||||||
#ifdef Q_OS_OSX
|
|
||||||
settings.setScreenPlayWindowPath(QUrl::fromUserInput(SPWorkingDir.path() + "/../../../ScreenPlayWindow/ScreenPlayWindow.app/Contents/MacOS/ScreenPlayWindow").toLocalFile());
|
|
||||||
settings.setScreenPlayWidgetPath(QUrl::fromUserInput(SPWorkingDir.path() + "/../../../ScreenPlayWidget/ScreenPlayWidget.app/Contents/MacOS/ScreenPlayWidget").toLocalFile());
|
|
||||||
qDebug() << "Setting ScreenPlayWindow Path to " << settings.getScreenPlayWindowPath();
|
|
||||||
qDebug() << "Setting ScreenPlayWdiget Path to " << settings.getScreenPlayWidgetPath();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
settings.setScreenPlayWindowPath(QUrl(SPWorkingDir.path() + "/ScreenPlayWindow/debug/ScreenPlayWindow.exe"));
|
|
||||||
settings.setScreenPlayWidgetPath(QUrl(SPWorkingDir.path() + "/ScreenPlayWidget/debug/ScreenPlayWidget.exe"));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// We need to detect the right base path so we can copy later the example projects
|
|
||||||
SPBaseDir.cdUp();
|
|
||||||
SPBaseDir.cdUp();
|
|
||||||
SPBaseDir.cd("ScreenPlay");
|
|
||||||
SPBaseDir.cd("ScreenPlay");
|
|
||||||
settings.setScreenPlayBasePath(QUrl(SPBaseDir.path()));
|
|
||||||
#endif
|
|
||||||
#ifdef QT_NO_DEBUG
|
|
||||||
qDebug() << "Starting in Release mode!";
|
|
||||||
settings.setScreenPlayBasePath(QUrl(SPWorkingDir.path()));
|
|
||||||
|
|
||||||
// If we build in the release version we must be cautious!
|
|
||||||
// The working dir in steam is the ScreenPlay.exe location
|
|
||||||
// In QtCreator is the dir above ScreenPlay.exe (!)
|
|
||||||
|
|
||||||
SPWorkingDir.cdUp();
|
|
||||||
SPWorkingDir.cd("ScreenPlayWindow");
|
|
||||||
|
|
||||||
if (QDir(SPWorkingDir.path() + "/release").exists()) {
|
|
||||||
// If started by QtCreator
|
|
||||||
SPWorkingDir.cd("release");
|
|
||||||
settings.setScreenPlayWindowPath(QUrl(SPWorkingDir.path() + "/ScreenPlayWindow.exe"));
|
|
||||||
SPWorkingDir.cdUp();
|
|
||||||
SPWorkingDir.cdUp();
|
|
||||||
SPWorkingDir.cd("ScreenPlayWidget");
|
|
||||||
SPWorkingDir.cd("release");
|
|
||||||
settings.setScreenPlayWidgetPath(QUrl(SPWorkingDir.path() + "/ScreenPlayWidget.exe"));
|
|
||||||
} else {
|
|
||||||
// If started by Steam
|
|
||||||
settings.setScreenPlayWindowPath(QUrl("ScreenPlayWindow.exe"));
|
|
||||||
settings.setScreenPlayWidgetPath(QUrl("ScreenPlayWidget.exe"));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// All the list need the default path from the settings
|
// All the list need the default path from the settings
|
||||||
// to know where to look for the files
|
// to know where to look for the files
|
||||||
profileListModel.loadProfiles();
|
profileListModel.loadProfiles();
|
||||||
settings.loadActiveProfiles();
|
settings.loadActiveProfiles();
|
||||||
|
|
||||||
QQmlApplicationEngine mainWindowEngine;
|
QQmlApplicationEngine mainWindowEngine;
|
||||||
|
|
||||||
mainWindowEngine.rootContext()->setContextProperty("screenPlay", &screenPlay);
|
mainWindowEngine.rootContext()->setContextProperty("screenPlay", &screenPlay);
|
||||||
mainWindowEngine.rootContext()->setContextProperty("screenPlayCreate", &create);
|
mainWindowEngine.rootContext()->setContextProperty("screenPlayCreate", &create);
|
||||||
mainWindowEngine.rootContext()->setContextProperty("utility", &qmlUtil);
|
mainWindowEngine.rootContext()->setContextProperty("utility", &qmlUtil);
|
||||||
@ -142,8 +88,8 @@ int main(int argc, char* argv[])
|
|||||||
mainWindowEngine.rootContext()->setContextProperty("installedListModel", &installedListModel);
|
mainWindowEngine.rootContext()->setContextProperty("installedListModel", &installedListModel);
|
||||||
mainWindowEngine.rootContext()->setContextProperty("profileListModel", &profileListModel);
|
mainWindowEngine.rootContext()->setContextProperty("profileListModel", &profileListModel);
|
||||||
mainWindowEngine.rootContext()->setContextProperty("screenPlaySettings", &settings);
|
mainWindowEngine.rootContext()->setContextProperty("screenPlaySettings", &settings);
|
||||||
|
|
||||||
mainWindowEngine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
mainWindowEngine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||||
|
|
||||||
installedListFilter.sortByRoleType("All");
|
installedListFilter.sortByRoleType("All");
|
||||||
installedListModel.loadScreens();
|
installedListModel.loadScreens();
|
||||||
|
|
||||||
|
@ -113,6 +113,8 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo
|
|||||||
m_checkForOtherFullscreenApplicationTimer = new QTimer(this);
|
m_checkForOtherFullscreenApplicationTimer = new QTimer(this);
|
||||||
connect(m_checkForOtherFullscreenApplicationTimer, &QTimer::timeout, this, &Settings::checkForOtherFullscreenApplication);
|
connect(m_checkForOtherFullscreenApplicationTimer, &QTimer::timeout, this, &Settings::checkForOtherFullscreenApplication);
|
||||||
m_checkForOtherFullscreenApplicationTimer->start(1500);
|
m_checkForOtherFullscreenApplicationTimer->start(1500);
|
||||||
|
|
||||||
|
setupWidgetAndWindowPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::~Settings()
|
Settings::~Settings()
|
||||||
@ -319,6 +321,63 @@ void Settings::createDefaultConfig()
|
|||||||
defaultSettings.close();
|
defaultSettings.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::setupWidgetAndWindowPaths()
|
||||||
|
{
|
||||||
|
QDir SPWorkingDir(QDir::currentPath());
|
||||||
|
QDir SPBaseDir(QDir::currentPath());
|
||||||
|
|
||||||
|
#ifdef QT_DEBUG
|
||||||
|
qDebug() << "Starting in Debug mode!";
|
||||||
|
|
||||||
|
if (SPWorkingDir.cdUp()) {
|
||||||
|
#ifdef Q_OS_OSX
|
||||||
|
setScreenPlayWindowPath(QUrl::fromUserInput(SPWorkingDir.path() + "/../../../ScreenPlayWindow/ScreenPlayWindow.app/Contents/MacOS/ScreenPlayWindow").toLocalFile());
|
||||||
|
setScreenPlayWidgetPath(QUrl::fromUserInput(SPWorkingDir.path() + "/../../../ScreenPlayWidget/ScreenPlayWidget.app/Contents/MacOS/ScreenPlayWidget").toLocalFile());
|
||||||
|
qDebug() << "Setting ScreenPlayWindow Path to " << settings.getScreenPlayWindowPath();
|
||||||
|
qDebug() << "Setting ScreenPlayWdiget Path to " << settings.getScreenPlayWidgetPath();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
setScreenPlayWindowPath(QUrl(SPWorkingDir.path() + "/ScreenPlayWindow/debug/ScreenPlayWindow.exe"));
|
||||||
|
setScreenPlayWidgetPath(QUrl(SPWorkingDir.path() + "/ScreenPlayWidget/debug/ScreenPlayWidget.exe"));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// We need to detect the right base path so we can copy later the example projects
|
||||||
|
SPBaseDir.cdUp();
|
||||||
|
SPBaseDir.cdUp();
|
||||||
|
SPBaseDir.cd("ScreenPlay");
|
||||||
|
SPBaseDir.cd("ScreenPlay");
|
||||||
|
setScreenPlayBasePath(QUrl(SPBaseDir.path()));
|
||||||
|
#endif
|
||||||
|
#ifdef QT_NO_DEBUG
|
||||||
|
qDebug() << "Starting in Release mode!";
|
||||||
|
setScreenPlayBasePath(QUrl(SPWorkingDir.path()));
|
||||||
|
|
||||||
|
// If we build in the release version we must be cautious!
|
||||||
|
// The working dir in steam is the ScreenPlay.exe location
|
||||||
|
// In QtCreator is the dir above ScreenPlay.exe (!)
|
||||||
|
|
||||||
|
SPWorkingDir.cdUp();
|
||||||
|
SPWorkingDir.cd("ScreenPlayWindow");
|
||||||
|
|
||||||
|
if (QDir(SPWorkingDir.path() + "/release").exists()) {
|
||||||
|
// If started by QtCreator
|
||||||
|
SPWorkingDir.cd("release");
|
||||||
|
settings.setScreenPlayWindowPath(QUrl(SPWorkingDir.path() + "/ScreenPlayWindow.exe"));
|
||||||
|
SPWorkingDir.cdUp();
|
||||||
|
SPWorkingDir.cdUp();
|
||||||
|
SPWorkingDir.cd("ScreenPlayWidget");
|
||||||
|
SPWorkingDir.cd("release");
|
||||||
|
setScreenPlayWidgetPath(QUrl(SPWorkingDir.path() + "/ScreenPlayWidget.exe"));
|
||||||
|
} else {
|
||||||
|
// If started by Steam
|
||||||
|
setScreenPlayWindowPath(QUrl("ScreenPlayWindow.exe"));
|
||||||
|
setScreenPlayWidgetPath(QUrl("ScreenPlayWidget.exe"));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool Settings::getOfflineMode() const
|
bool Settings::getOfflineMode() const
|
||||||
{
|
{
|
||||||
return m_offlineMode;
|
return m_offlineMode;
|
||||||
|
@ -293,6 +293,7 @@ public slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void createDefaultConfig();
|
void createDefaultConfig();
|
||||||
|
void setupWidgetAndWindowPaths();
|
||||||
|
|
||||||
QVersionNumber m_version;
|
QVersionNumber m_version;
|
||||||
QSettings m_qSettings;
|
QSettings m_qSettings;
|
||||||
|
Loading…
Reference in New Issue
Block a user