summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commandline.cpp3
-rw-r--r--src/main.cpp71
-rw-r--r--src/moapplication.cpp73
-rw-r--r--src/moapplication.h19
-rw-r--r--src/settings.h18
5 files changed, 115 insertions, 69 deletions
diff --git a/src/commandline.cpp b/src/commandline.cpp
index ff1be764..dc8cf53f 100644
--- a/src/commandline.cpp
+++ b/src/commandline.cpp
@@ -592,6 +592,8 @@ std::optional<int> ExeCommand::doRun()
const auto args = vm()["arguments"].as<std::string>();
const auto cwd = vm()["cwd"].as<std::string>();
+ std::cout << "not implemented\n";
+
return 0;
}
@@ -608,6 +610,7 @@ Command::Meta RunCommand::meta() const
std::optional<int> RunCommand::doRun()
{
+ std::cout << "not implemented\n";
return {};
}
diff --git a/src/main.cpp b/src/main.cpp
index a2653685..9d6ed7b0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -160,69 +160,6 @@ void addDllsToPath()
env::prependToPath(dllsPath);
}
-QString getSplashPath(
- const Settings& settings, const QString& dataPath,
- const MOBase::IPluginGame* game)
-{
- if (!settings.useSplash()) {
- return {};
- }
-
- // try splash from instance directory
- const QString splashPath = dataPath + "/splash.png";
- if (QFile::exists(dataPath + "/splash.png")) {
- QImage image(splashPath);
- if (!image.isNull()) {
- return splashPath;
- }
- }
-
- // try splash from plugin
- QString pluginSplash = QString(":/%1/splash").arg(game->gameShortName());
- if (QFile::exists(pluginSplash)) {
- QImage image(pluginSplash);
- if (!image.isNull()) {
- image.save(splashPath);
- return pluginSplash;
- }
- }
-
- // try default splash from resource
- QString defaultSplash = ":/MO/gui/splash";
- if (QFile::exists(defaultSplash)) {
- QImage image(defaultSplash);
- if (!image.isNull()) {
- return defaultSplash;
- }
- }
-
- return splashPath;
-}
-
-std::unique_ptr<QSplashScreen> createSplash(
- const Settings& settings, const QString& dataPath,
- const MOBase::IPluginGame* game)
-{
- const auto splashPath = getSplashPath(settings, dataPath, game);
- if (splashPath.isEmpty()) {
- return {};
- }
-
- QPixmap image(splashPath);
- if (image.isNull()) {
- log::error("failed to load splash from {}", splashPath);
- return {};
- }
-
- auto splash = std::make_unique<QSplashScreen>(image);
- settings.geometry().centerOnMainWindowMonitor(splash.get());
-
- splash->show();
- splash->activateWindow();
-
- return splash;
-}
-
std::optional<int> handleCommandLine(
const cl::CommandLine& cl, OrganizerCore& organizer)
{
@@ -554,7 +491,7 @@ int runApplication(
return *r;
}
- auto splash = createSplash(settings, dataPath, currentInstance.gamePlugin());
+ MOSplash splash(settings, dataPath, currentInstance.gamePlugin());
QString apiKey;
if (GlobalSettings::nexusApiKey(apiKey)) {
@@ -589,11 +526,7 @@ int runApplication(
mainWindow.show();
mainWindow.activateWindow();
- if (splash) {
- // don't pass mainwindow as it just waits half a second for it
- // instead of proceding
- splash->finish(nullptr);
- }
+ splash.close();
tt.stop();
diff --git a/src/moapplication.cpp b/src/moapplication.cpp
index 290666af..659b5a12 100644
--- a/src/moapplication.cpp
+++ b/src/moapplication.cpp
@@ -18,6 +18,8 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
*/
#include "moapplication.h"
+#include "settings.h"
+#include <iplugingame.h>
#include <report.h>
#include <utility.h>
#include <log.h>
@@ -147,3 +149,74 @@ void MOApplication::updateStyle(const QString& fileName)
}
}
}
+
+
+MOSplash::MOSplash(
+ const Settings& settings, const QString& dataPath,
+ const MOBase::IPluginGame* game)
+{
+ const auto splashPath = getSplashPath(settings, dataPath, game);
+ if (splashPath.isEmpty()) {
+ return;
+ }
+
+ QPixmap image(splashPath);
+ if (image.isNull()) {
+ log::error("failed to load splash from {}", splashPath);
+ return;
+ }
+
+ ss_.reset(new QSplashScreen(image));
+ settings.geometry().centerOnMainWindowMonitor(ss_.get());
+
+ ss_->show();
+ ss_->activateWindow();
+}
+
+void MOSplash::close()
+{
+ if (ss_) {
+ // don't pass mainwindow as it just waits half a second for it
+ // instead of proceding
+ ss_->finish(nullptr);
+ }
+}
+
+QString MOSplash::getSplashPath(
+ const Settings& settings, const QString& dataPath,
+ const MOBase::IPluginGame* game) const
+{
+ if (!settings.useSplash()) {
+ return {};
+ }
+
+ // try splash from instance directory
+ const QString splashPath = dataPath + "/splash.png";
+ if (QFile::exists(dataPath + "/splash.png")) {
+ QImage image(splashPath);
+ if (!image.isNull()) {
+ return splashPath;
+ }
+ }
+
+ // try splash from plugin
+ QString pluginSplash = QString(":/%1/splash").arg(game->gameShortName());
+ if (QFile::exists(pluginSplash)) {
+ QImage image(pluginSplash);
+ if (!image.isNull()) {
+ image.save(splashPath);
+ return pluginSplash;
+ }
+ }
+
+ // try default splash from resource
+ QString defaultSplash = ":/MO/gui/splash";
+ if (QFile::exists(defaultSplash)) {
+ QImage image(defaultSplash);
+ if (!image.isNull()) {
+ return defaultSplash;
+ }
+ }
+
+ return splashPath;
+}
diff --git a/src/moapplication.h b/src/moapplication.h
index c67c4622..0ee04492 100644
--- a/src/moapplication.h
+++ b/src/moapplication.h
@@ -23,6 +23,8 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <QApplication>
#include <QFileSystemWatcher>
+class Settings;
+namespace MOBase { class IPluginGame; }
class MOApplication : public QApplication
{
@@ -46,4 +48,21 @@ private:
};
+class MOSplash
+{
+public:
+ MOSplash(
+ const Settings& settings, const QString& dataPath,
+ const MOBase::IPluginGame* game);
+
+ void close();
+
+private:
+ std::unique_ptr<QSplashScreen> ss_;
+
+ QString getSplashPath(
+ const Settings& settings, const QString& dataPath,
+ const MOBase::IPluginGame* game) const;
+};
+
#endif // MOAPPLICATION_H
diff --git a/src/settings.h b/src/settings.h
index c8325ba2..fc7789f0 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -195,6 +195,10 @@ private:
class WidgetSettings
{
public:
+ // globalInstance is forwarded from the Settings constructor; WidgetSettings
+ // has the callbacks used by QuestionBoxMemory and those are global, so they
+ // should only be set by the global instance
+ //
WidgetSettings(QSettings& s, bool globalInstance);
// selected index for a combobox
@@ -671,6 +675,20 @@ class Settings : public QObject
Q_OBJECT;
public:
+ // there is one Settings global object for MO when an instance is loaded, but
+ // other Settings objects are required in several places, such as in the
+ // Instance class, the instance dialogs, etc.
+ //
+ // any Settings object created with globalInstance==false won't set the
+ // singleton
+ //
+ // only WidgetSettings need to know whether it created from a globalInstance,
+ // see its constructor
+ //
+ // @param path path to an ini file
+ // @param globalInsance whether this is the global instance; creates the
+ // singleton and asserts if it already exists
+ //
Settings(const QString& path, bool globalInstance=false);
~Settings();