From 2aae65d6f6c1ab3309e54437a339d1644088c5c8 Mon Sep 17 00:00:00 2001
From: Tannin
Date: Sun, 10 Jan 2016 20:19:56 +0100
Subject: made instance-switching usable
this includes tons and tons of changes to how paths are determined.
the profiles-dir can now also be configured
---
src/instancemanager.cpp | 206 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 206 insertions(+)
create mode 100644 src/instancemanager.cpp
(limited to 'src/instancemanager.cpp')
diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp
new file mode 100644
index 00000000..48c12d42
--- /dev/null
+++ b/src/instancemanager.cpp
@@ -0,0 +1,206 @@
+/*
+Copyright (C) 2016 Sebastian Herbord. All rights reserved.
+
+This file is part of Mod Organizer.
+
+Mod Organizer is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Mod Organizer is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mod Organizer. If not, see .
+*/
+
+
+#include "instancemanager.h"
+#include "selectiondialog.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+static const char COMPANY_NAME[] = "Tannin";
+static const char APPLICATION_NAME[] = "Mod Organizer";
+static const char INSTANCE_KEY[] = "CurrentInstance";
+
+
+
+InstanceManager::InstanceManager()
+ : m_AppSettings(COMPANY_NAME, APPLICATION_NAME)
+{
+}
+
+
+QString InstanceManager::currentInstance() const
+{
+ return m_AppSettings.value(INSTANCE_KEY, "").toString();
+}
+
+void InstanceManager::clearCurrentInstance()
+{
+ setCurrentInstance("");
+}
+
+void InstanceManager::setCurrentInstance(const QString &name)
+{
+ m_AppSettings.setValue(INSTANCE_KEY, name);
+}
+
+
+QString InstanceManager::queryInstanceName() const
+{
+ QString instanceId;
+ while (instanceId.isEmpty()) {
+ QInputDialog dialog;
+ // would be neat if we could take the names from the game plugins but
+ // the required initialization order requires the ini file to be
+ // available *before* we load plugins
+ dialog.setComboBoxItems({ "Oblivion", "Skyrim", "Fallout 3",
+ "Fallout NV", "Fallout 4" });
+ dialog.setComboBoxEditable(true);
+ dialog.setWindowTitle(QObject::tr("Enter Instance Name"));
+ dialog.setLabelText(QObject::tr("Name"));
+ if (dialog.exec() == QDialog::Rejected) {
+ throw MOBase::MyException(QObject::tr("Canceled"));
+ }
+ instanceId = dialog.textValue().replace(QRegExp("[^0-9a-zA-Z ]"), "");
+ }
+ return instanceId;
+}
+
+
+QString InstanceManager::chooseInstance(const QStringList &instanceList) const
+{
+ SelectionDialog selection(QObject::tr("Choose Instance"), nullptr);
+ selection.disableCancel();
+ for (const QString &instance : instanceList) {
+ selection.addChoice(instance, "", instance);
+ }
+
+ selection.addChoice(QObject::tr("New"),
+ QObject::tr("Create a new instance."),
+ "");
+ if (selection.exec() == QDialog::Rejected) {
+ qDebug("rejected");
+ throw MOBase::MyException(QObject::tr("Canceled"));
+ }
+
+ QString choice = selection.getChoiceData().toString();
+
+ if (choice.isEmpty()) {
+ return queryInstanceName();
+ } else {
+ return choice;
+ }
+}
+
+
+QString InstanceManager::instancePath() const
+{
+ return QDir::fromNativeSeparators(
+ QStandardPaths::writableLocation(QStandardPaths::DataLocation));
+}
+
+
+QStringList InstanceManager::instances() const
+{
+ return QDir(instancePath()).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
+}
+
+
+bool InstanceManager::portableInstall() const
+{
+ return QFile::exists(qApp->applicationDirPath() + "/" +
+ QString::fromStdWString(AppConfig::iniFileName()));
+}
+
+
+InstanceManager::InstallationMode InstanceManager::queryInstallMode() const
+{
+ SelectionDialog selection(QObject::tr("Installation Mode"), nullptr);
+ selection.disableCancel();
+ selection.addChoice(QObject::tr("Portable"),
+ QObject::tr("Everything in one directory, only one game per installation."),
+ 0);
+ selection.addChoice(QObject::tr("Regular"),
+ QObject::tr("Data in separate directory, multiple games supported."),
+ 1);
+ if (selection.exec() == QDialog::Rejected) {
+ throw MOBase::MyException(QObject::tr("Canceled"));
+ }
+
+ switch (selection.getChoiceData().toInt()) {
+ case 0: return InstallationMode::PORTABLE;
+ default: return InstallationMode::REGULAR;
+ }
+}
+
+
+void InstanceManager::createDataPath(const QString &dataPath) const
+{
+ if (!QDir(dataPath).exists()) {
+ if (!QDir().mkpath(dataPath)) {
+ throw MOBase::MyException(
+ QObject::tr("failed to create %1").arg(dataPath));
+ } else {
+ QMessageBox::information(
+ nullptr, QObject::tr("Data directory created"),
+ QObject::tr("New data directory created at %1. If you don't want to "
+ "store a lot of data there, reconfigure the storage "
+ "directories via settings.").arg(dataPath));
+ }
+ }
+}
+
+
+QString InstanceManager::determineDataPath()
+{
+ QString instanceId = currentInstance();
+
+ if (instanceId.isEmpty() && !portableInstall()) {
+ // no portable install and no selected instance
+
+ QStringList instanceList = instances();
+
+ qDebug("%d - %s", instanceList.size(), qPrintable(instanceList.join(";")));
+
+ if (instanceList.size() == 0) {
+ switch (queryInstallMode()) {
+ case InstallationMode::PORTABLE: {
+ instanceId = QString();
+ } break;
+ case InstallationMode::REGULAR: {
+ instanceId = queryInstanceName();
+ } break;
+ }
+ } else {
+ instanceId = chooseInstance(instanceList);
+ }
+ }
+
+ if (instanceId.isEmpty()) {
+ qDebug("portable mode");
+ return qApp->applicationDirPath();
+ } else {
+ setCurrentInstance(instanceId);
+
+ QString dataPath = QDir::fromNativeSeparators(
+ QStandardPaths::writableLocation(QStandardPaths::DataLocation)
+ + "/" + instanceId);
+
+ createDataPath(dataPath);
+
+ return dataPath;
+ }
+}
+
--
cgit v1.3.1
From 63eaf453e0de2087ce7d2a3c26edc7eac4bd1882 Mon Sep 17 00:00:00 2001
From: Tannin
Date: Tue, 9 Feb 2016 20:05:41 +0100
Subject: portable setup is no longer offered if the directory isn't writable
---
CMakeLists.txt | 3 ++-
src/CMakeLists.txt | 2 --
src/instancemanager.cpp | 21 ++++++++++++---------
3 files changed, 14 insertions(+), 12 deletions(-)
(limited to 'src/instancemanager.cpp')
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e255f2b8..0146edd5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(organizer)
+
SET(DEPENDENCIES_DIR CACHE PATH "")
# hint to find qt in dependencies path
LIST(APPEND CMAKE_PREFIX_PATH ${DEPENDENCIES_DIR}/qt5/lib/cmake)
@@ -11,4 +12,4 @@ GET_FILENAME_COMPONENT(BOOST_ROOT ${BOOST_ROOT} DIRECTORY)
SET(ZLIB_ROOT ${DEPENDENCIES_DIR}/zlib)
-ADD_SUBDIRECTORY(src)
\ No newline at end of file
+ADD_SUBDIRECTORY(src)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fda85b76..a6434acf 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -297,8 +297,6 @@ INCLUDE_DIRECTORIES(${project_path}/uibase/src
${project_path}/game_gamebryo/src
${project_path}/game_features/src)
-MESSAGE(STATUS ${project_path}/gameGamebryo/src)
-
INCLUDE_DIRECTORIES(shared ${ZLIB_INCLUDE_DIRS})
LINK_DIRECTORIES(${lib_path}
diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp
index 48c12d42..d48d02d2 100644
--- a/src/instancemanager.cpp
+++ b/src/instancemanager.cpp
@@ -172,18 +172,21 @@ QString InstanceManager::determineDataPath()
QStringList instanceList = instances();
- qDebug("%d - %s", instanceList.size(), qPrintable(instanceList.join(";")));
-
if (instanceList.size() == 0) {
- switch (queryInstallMode()) {
- case InstallationMode::PORTABLE: {
- instanceId = QString();
- } break;
- case InstallationMode::REGULAR: {
- instanceId = queryInstanceName();
- } break;
+ if (QFileInfo(qApp->applicationDirPath()).isWritable()) {
+ switch (queryInstallMode()) {
+ case InstallationMode::PORTABLE: {
+ instanceId = QString();
+ } break;
+ case InstallationMode::REGULAR: {
+ instanceId = queryInstanceName();
+ } break;
+ }
+ } else {
+ instanceId = queryInstanceName();
}
} else {
+ // don't offer portable instance if we can't set one up.
instanceId = chooseInstance(instanceList);
}
}
--
cgit v1.3.1
From 45a182a381a197b2e62eaf9f87ad15f84250c1e7 Mon Sep 17 00:00:00 2001
From: Tannin
Date: Thu, 19 May 2016 19:15:19 +0200
Subject: bugfix: initial setup didn't offer a portable install even if the
global install dir is gone
---
src/instancemanager.cpp | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
(limited to 'src/instancemanager.cpp')
diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp
index d48d02d2..c74f3c1a 100644
--- a/src/instancemanager.cpp
+++ b/src/instancemanager.cpp
@@ -166,8 +166,11 @@ void InstanceManager::createDataPath(const QString &dataPath) const
QString InstanceManager::determineDataPath()
{
QString instanceId = currentInstance();
+ QString dataPath = QDir::fromNativeSeparators(
+ QStandardPaths::writableLocation(QStandardPaths::DataLocation)
+ + "/" + instanceId);
- if (instanceId.isEmpty() && !portableInstall()) {
+ if ((instanceId.isEmpty() || !QFileInfo::exists(dataPath)) && !portableInstall()) {
// no portable install and no selected instance
QStringList instanceList = instances();
@@ -191,16 +194,11 @@ QString InstanceManager::determineDataPath()
}
}
- if (instanceId.isEmpty()) {
- qDebug("portable mode");
+ if (instanceId.isEmpty() || !QFileInfo::exists(dataPath)) {
return qApp->applicationDirPath();
} else {
setCurrentInstance(instanceId);
- QString dataPath = QDir::fromNativeSeparators(
- QStandardPaths::writableLocation(QStandardPaths::DataLocation)
- + "/" + instanceId);
-
createDataPath(dataPath);
return dataPath;
--
cgit v1.3.1
From bfbb19099839019c785dc81c83b07dadbd394168 Mon Sep 17 00:00:00 2001
From: Tannin
Date: Fri, 27 May 2016 14:04:00 +0200
Subject: moved button to switch instance (and to portable mode) to the main
window
---
src/instancemanager.cpp | 100 +++++++++++++++++++++++-----------------------
src/instancemanager.h | 15 +++----
src/main.cpp | 4 +-
src/mainwindow.cpp | 12 ++++++
src/mainwindow.h | 3 ++
src/mainwindow.ui | 13 ++++++
src/nxmaccessmanager.cpp | 2 -
src/resources.qrc | 3 +-
src/resources/mo_icon.png | Bin 0 -> 1011 bytes
src/resources/package.png | Bin 0 -> 1067 bytes
src/settingsdialog.cpp | 12 ------
src/settingsdialog.h | 23 ++++-------
src/settingsdialog.ui | 52 ++++++------------------
13 files changed, 109 insertions(+), 130 deletions(-)
create mode 100644 src/resources/mo_icon.png
create mode 100644 src/resources/package.png
(limited to 'src/instancemanager.cpp')
diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp
index c74f3c1a..f7b953ad 100644
--- a/src/instancemanager.cpp
+++ b/src/instancemanager.cpp
@@ -27,6 +27,7 @@ along with Mod Organizer. If not, see .
#include
#include
#include
+#include
static const char COMPANY_NAME[] = "Tannin";
@@ -40,6 +41,11 @@ InstanceManager::InstanceManager()
{
}
+InstanceManager &InstanceManager::instance()
+{
+ static InstanceManager s_Instance;
+ return s_Instance;
+}
QString InstanceManager::currentInstance() const
{
@@ -49,6 +55,7 @@ QString InstanceManager::currentInstance() const
void InstanceManager::clearCurrentInstance()
{
setCurrentInstance("");
+ m_Reset = true;
}
void InstanceManager::setCurrentInstance(const QString &name)
@@ -81,26 +88,51 @@ QString InstanceManager::queryInstanceName() const
QString InstanceManager::chooseInstance(const QStringList &instanceList) const
{
- SelectionDialog selection(QObject::tr("Choose Instance"), nullptr);
+ enum class Special : uint8_t {
+ NewInstance,
+ Portable
+ };
+
+ SelectionDialog selection(
+ QString("%1
%2")
+ .arg(QObject::tr("Choose Instance"))
+ .arg(QObject::tr(
+ "Each Instance is a full set of MO data files (mods, "
+ "downloads, profiles, configuration, ...). Use multiple "
+ "instances for different games. If your MO folder is "
+ "writable, you can also store a single instance locally (called "
+ "a portable install).")),
+ nullptr);
selection.disableCancel();
for (const QString &instance : instanceList) {
selection.addChoice(instance, "", instance);
}
- selection.addChoice(QObject::tr("New"),
+ selection.addChoice(QIcon(":/MO/gui/add"), QObject::tr("New"),
QObject::tr("Create a new instance."),
- "");
+ static_cast(Special::NewInstance));
+
+ if (QFileInfo(qApp->applicationDirPath()).isWritable()) {
+ selection.addChoice(QIcon(":/MO/gui/package"), QObject::tr("Portable"),
+ QObject::tr("Use MO folder for data."),
+ static_cast(Special::Portable));
+ }
+
if (selection.exec() == QDialog::Rejected) {
qDebug("rejected");
throw MOBase::MyException(QObject::tr("Canceled"));
}
- QString choice = selection.getChoiceData().toString();
+ QVariant choice = selection.getChoiceData();
- if (choice.isEmpty()) {
- return queryInstanceName();
+ if (choice.type() == QVariant::String) {
+ return choice.toString();
} else {
- return choice;
+ switch (choice.value()) {
+ case Special::NewInstance: return queryInstanceName();
+ case Special::Portable: return QString();
+ default: throw std::runtime_error("invalid selection");
+ }
}
}
@@ -125,27 +157,6 @@ bool InstanceManager::portableInstall() const
}
-InstanceManager::InstallationMode InstanceManager::queryInstallMode() const
-{
- SelectionDialog selection(QObject::tr("Installation Mode"), nullptr);
- selection.disableCancel();
- selection.addChoice(QObject::tr("Portable"),
- QObject::tr("Everything in one directory, only one game per installation."),
- 0);
- selection.addChoice(QObject::tr("Regular"),
- QObject::tr("Data in separate directory, multiple games supported."),
- 1);
- if (selection.exec() == QDialog::Rejected) {
- throw MOBase::MyException(QObject::tr("Canceled"));
- }
-
- switch (selection.getChoiceData().toInt()) {
- case 0: return InstallationMode::PORTABLE;
- default: return InstallationMode::REGULAR;
- }
-}
-
-
void InstanceManager::createDataPath(const QString &dataPath) const
{
if (!QDir(dataPath).exists()) {
@@ -166,31 +177,22 @@ void InstanceManager::createDataPath(const QString &dataPath) const
QString InstanceManager::determineDataPath()
{
QString instanceId = currentInstance();
+ if (instanceId.isEmpty() && portableInstall() && !m_Reset) {
+ // startup, apparently using portable mode before
+ return qApp->applicationDirPath();
+ }
+
QString dataPath = QDir::fromNativeSeparators(
QStandardPaths::writableLocation(QStandardPaths::DataLocation)
+ "/" + instanceId);
- if ((instanceId.isEmpty() || !QFileInfo::exists(dataPath)) && !portableInstall()) {
- // no portable install and no selected instance
-
- QStringList instanceList = instances();
-
- if (instanceList.size() == 0) {
- if (QFileInfo(qApp->applicationDirPath()).isWritable()) {
- switch (queryInstallMode()) {
- case InstallationMode::PORTABLE: {
- instanceId = QString();
- } break;
- case InstallationMode::REGULAR: {
- instanceId = queryInstanceName();
- } break;
- }
- } else {
- instanceId = queryInstanceName();
- }
- } else {
- // don't offer portable instance if we can't set one up.
- instanceId = chooseInstance(instanceList);
+
+ if (instanceId.isEmpty() || !QFileInfo::exists(dataPath)) {
+ instanceId = chooseInstance(instances());
+ if (!instanceId.isEmpty()) {
+ dataPath = QDir::fromNativeSeparators(
+ QStandardPaths::writableLocation(QStandardPaths::DataLocation)
+ + "/" + instanceId);
}
}
diff --git a/src/instancemanager.h b/src/instancemanager.h
index 2e17d1c0..a0a5df09 100644
--- a/src/instancemanager.h
+++ b/src/instancemanager.h
@@ -27,25 +27,21 @@ along with Mod Organizer. If not, see .
class InstanceManager {
- enum class InstallationMode {
- PORTABLE,
- REGULAR
- };
-
public:
- InstanceManager();
+ static InstanceManager &instance();
QString determineDataPath();
- QStringList instances() const;
void clearCurrentInstance();
private:
+ InstanceManager();
+
QString currentInstance() const;
QString instancePath() const;
- bool portableInstall() const;
+ QStringList instances() const;
void setCurrentInstance(const QString &name);
@@ -53,10 +49,11 @@ private:
QString chooseInstance(const QStringList &instanceList) const;
void createDataPath(const QString &dataPath) const;
- InstallationMode queryInstallMode() const;
+ bool portableInstall() const;
private:
QSettings m_AppSettings;
+ bool m_Reset {false};
};
diff --git a/src/main.cpp b/src/main.cpp
index 6940e288..e289453c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -630,13 +630,12 @@ int main(int argc, char *argv[])
QString dataPath;
try {
- dataPath = InstanceManager().determineDataPath();
+ dataPath = InstanceManager::instance().determineDataPath();
} catch (const std::exception &e) {
QMessageBox::critical(nullptr, QObject::tr("Failed to set up instance"),
e.what());
return 1;
}
-
application.setProperty("dataPath", dataPath);
LogBuffer::init(100, QtDebugMsg, qApp->property("dataPath").toString() + "/logs/mo_interface.log");
@@ -647,7 +646,6 @@ int main(int argc, char *argv[])
}
int result = runApplication(application, instance, splash);
-
if (result != INT_MAX) {
return result;
}
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index dcff139a..66c2b557 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -37,6 +37,7 @@ along with Mod Organizer. If not, see .
#include "savegameinfo.h"
#include "spawn.h"
#include "versioninfo.h"
+#include "instancemanager.h"
#include "report.h"
#include "modlist.h"
@@ -3883,6 +3884,17 @@ void MainWindow::on_actionProblems_triggered()
}
}
+void MainWindow::on_actionChange_Game_triggered()
+{
+ if (QMessageBox::question(this, tr("Are you sure?"),
+ tr("This will restart MO, continue?"),
+ QMessageBox::Yes | QMessageBox::Cancel)
+ == QMessageBox::Yes) {
+ InstanceManager::instance().clearCurrentInstance();
+ qApp->exit(INT_MAX);
+ }
+}
+
void MainWindow::setCategoryListVisible(bool visible)
{
if (visible) {
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 43b2bede..3364bb37 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -183,6 +183,9 @@ protected:
virtual void dragEnterEvent(QDragEnterEvent *event);
virtual void dropEvent(QDropEvent *event);
+private slots:
+ void on_actionChange_Game_triggered();
+
private slots:
void on_clickBlankButton_clicked();
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
index f504994a..e30a165d 100644
--- a/src/mainwindow.ui
+++ b/src/mainwindow.ui
@@ -1197,6 +1197,7 @@ p, li { white-space: pre-wrap; }
false
+
@@ -1383,6 +1384,18 @@ Right now this has very limited functionality
Ctrl+C
+
+
+
+ :/MO/gui/app_icon:/MO/gui/app_icon
+
+
+ Change Game
+
+
+ Open the game selection dialog
+
+
diff --git a/src/nxmaccessmanager.cpp b/src/nxmaccessmanager.cpp
index 3f90647b..17c50e35 100644
--- a/src/nxmaccessmanager.cpp
+++ b/src/nxmaccessmanager.cpp
@@ -215,7 +215,6 @@ void NXMAccessManager::login(const QString &username, const QString &password)
emit loginSuccessful(false);
return;
}
-
m_Username = username;
m_Password = password;
pageLogin();
@@ -237,7 +236,6 @@ QString NXMAccessManager::userAgent(const QString &subModule) const
void NXMAccessManager::pageLogin()
{
qDebug("logging %s in on Nexus", qPrintable(m_Username));
-
QString requestString = (Nexus_Management_URL + "/Sessions/?Login&uri=%1")
.arg(QString(QUrl::toPercentEncoding(Nexus_Management_URL)));
diff --git a/src/resources.qrc b/src/resources.qrc
index 8434b367..d357801c 100644
--- a/src/resources.qrc
+++ b/src/resources.qrc
@@ -26,7 +26,6 @@
resources/software-update-available.png
resources/emblem-important.png
resources/check.png
- mo_icon.ico
resources/dialog-warning.png
resources/symbol-backup.png
resources/applications-accessories.png
@@ -68,6 +67,8 @@
resources/status_active.png
resources/status_awaiting.png
resources/status_inactive.png
+ resources/mo_icon.png
+ resources/package.png
resources/contents/jigsaw-piece.png
diff --git a/src/resources/mo_icon.png b/src/resources/mo_icon.png
new file mode 100644
index 00000000..c926d722
Binary files /dev/null and b/src/resources/mo_icon.png differ
diff --git a/src/resources/package.png b/src/resources/package.png
new file mode 100644
index 00000000..4b55b504
Binary files /dev/null and b/src/resources/package.png differ
diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp
index c66cc243..0d86018c 100644
--- a/src/settingsdialog.cpp
+++ b/src/settingsdialog.cpp
@@ -217,18 +217,6 @@ void SettingsDialog::on_associateButton_clicked()
Settings::instance().registerAsNXMHandler(true);
}
-void SettingsDialog::on_changeInstanceButton_clicked()
-{
- if (QMessageBox::question(this, tr("Are you sure?"),
- tr("This will restart MO, continue?"),
- QMessageBox::Yes | QMessageBox::Cancel)
- == QMessageBox::Yes) {
- InstanceManager().clearCurrentInstance();
- this->reject();
- qApp->exit(INT_MAX);
- }
-}
-
void SettingsDialog::on_clearCacheButton_clicked()
{
QDir(Settings::instance().getCacheDirectory()).removeRecursively();
diff --git a/src/settingsdialog.h b/src/settingsdialog.h
index 1ae21015..658fbce4 100644
--- a/src/settingsdialog.h
+++ b/src/settingsdialog.h
@@ -52,21 +52,6 @@ signals:
void resetDialogs();
-private slots:
- void on_clearCacheButton_clicked();
-
-private slots:
- void on_browseBaseDirBtn_clicked();
-
-private slots:
- void on_browseOverwriteDirBtn_clicked();
-
-private slots:
- void on_browseProfilesDirBtn_clicked();
-
-private slots:
- void on_changeInstanceButton_clicked();
-
private:
void storeSettings(QListWidgetItem *pluginItem);
@@ -92,6 +77,14 @@ private slots:
void on_associateButton_clicked();
+ void on_clearCacheButton_clicked();
+
+ void on_browseBaseDirBtn_clicked();
+
+ void on_browseOverwriteDirBtn_clicked();
+
+ void on_browseProfilesDirBtn_clicked();
+
private:
Ui::SettingsDialog *ui;
};
diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui
index 9ebed3b8..1f751da8 100644
--- a/src/settingsdialog.ui
+++ b/src/settingsdialog.ui
@@ -124,19 +124,6 @@ If you use pre-releases, never contact me directly by e-mail or via private mess
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
@@ -182,6 +169,19 @@ If you use pre-releases, never contact me directly by e-mail or via private mess
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
-
@@ -198,32 +198,6 @@ If you use pre-releases, never contact me directly by e-mail or via private mess
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- Restart MO and choose a different set of data paths.
-
-
- This will restart MO and give you opportunity to switch to a different set of data paths.
-
-
- Change Instance
-
-
-
--
cgit v1.3.1
From fcebf21c446500af79bf58486db503257bb4bc30 Mon Sep 17 00:00:00 2001
From: Tannin
Date: Sun, 5 Jun 2016 14:16:55 +0200
Subject: fixed startup errors
---
src/instancemanager.cpp | 2 +-
src/main.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'src/instancemanager.cpp')
diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp
index f7b953ad..a9182d52 100644
--- a/src/instancemanager.cpp
+++ b/src/instancemanager.cpp
@@ -196,7 +196,7 @@ QString InstanceManager::determineDataPath()
}
}
- if (instanceId.isEmpty() || !QFileInfo::exists(dataPath)) {
+ if (instanceId.isEmpty()) {
return qApp->applicationDirPath();
} else {
setCurrentInstance(instanceId);
diff --git a/src/main.cpp b/src/main.cpp
index e289453c..6b585b5c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -533,13 +533,13 @@ int runApplication(MOApplication &application, SingleInstance &instance,
// pass the remaining parameters to the binary
try {
organizer.startApplication(exeName, arguments, QString(), QString());
+ return 0;
} catch (const std::exception &e) {
reportError(
QObject::tr("failed to start application: %1").arg(e.what()));
return 1;
}
}
- return 0;
}
NexusInterface::instance()->getAccessManager()->startLoginCheck();
--
cgit v1.3.1
From afa0cb94461ce5a4f9e63af6aaee42105b66a898 Mon Sep 17 00:00:00 2001
From: LePresidente
Date: Mon, 12 Dec 2016 05:12:20 -0800
Subject: Version Bump, Basic SkyrimSE changes
---
src/gameinfoimpl.cpp | 1 +
src/instancemanager.cpp | 2 +-
src/version.rc | 4 ++--
3 files changed, 4 insertions(+), 3 deletions(-)
(limited to 'src/instancemanager.cpp')
diff --git a/src/gameinfoimpl.cpp b/src/gameinfoimpl.cpp
index 333fd029..61a4c523 100644
--- a/src/gameinfoimpl.cpp
+++ b/src/gameinfoimpl.cpp
@@ -39,6 +39,7 @@ IGameInfo::Type GameInfoImpl::type() const
case GameInfo::TYPE_FALLOUT4: return IGameInfo::TYPE_FALLOUT4;
case GameInfo::TYPE_FALLOUTNV: return IGameInfo::TYPE_FALLOUTNV;
case GameInfo::TYPE_SKYRIM: return IGameInfo::TYPE_SKYRIM;
+ case GameInfo::TYPE_SKYRIMSE: return IGameInfo::TYPE_SKYRIMSE;
default: throw MyException(QObject::tr("invalid game type %1").arg(GameInfo::instance().getType()));
}
}
diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp
index a9182d52..1b0d0e5b 100644
--- a/src/instancemanager.cpp
+++ b/src/instancemanager.cpp
@@ -72,7 +72,7 @@ QString InstanceManager::queryInstanceName() const
// would be neat if we could take the names from the game plugins but
// the required initialization order requires the ini file to be
// available *before* we load plugins
- dialog.setComboBoxItems({ "Oblivion", "Skyrim", "Fallout 3",
+ dialog.setComboBoxItems({ "Oblivion", "Skyrim", "SkyrimSE", "Fallout 3",
"Fallout NV", "Fallout 4" });
dialog.setComboBoxEditable(true);
dialog.setWindowTitle(QObject::tr("Enter Instance Name"));
diff --git a/src/version.rc b/src/version.rc
index 34f9b7dd..bc5ba58e 100644
--- a/src/version.rc
+++ b/src/version.rc
@@ -1,7 +1,7 @@
#include "Winver.h"
-#define VER_FILEVERSION 2,0,7
-#define VER_FILEVERSION_STR "2.0.7beta\0"
+#define VER_FILEVERSION 2,0,8
+#define VER_FILEVERSION_STR "2.0.8beta\0"
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
--
cgit v1.3.1
From 302a9b744d1f8edbae5cad910b0153f3c717bd2b Mon Sep 17 00:00:00 2001
From: Eran Mizrahi
Date: Mon, 18 Dec 2017 01:47:03 +0200
Subject: Ensure clearing currentInstance reg key when selecting portable
install
---
src/instancemanager.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
(limited to 'src/instancemanager.cpp')
diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp
index 1b0d0e5b..b1b85cc6 100644
--- a/src/instancemanager.cpp
+++ b/src/instancemanager.cpp
@@ -189,6 +189,7 @@ QString InstanceManager::determineDataPath()
if (instanceId.isEmpty() || !QFileInfo::exists(dataPath)) {
instanceId = chooseInstance(instances());
+ setCurrentInstance(instanceId);
if (!instanceId.isEmpty()) {
dataPath = QDir::fromNativeSeparators(
QStandardPaths::writableLocation(QStandardPaths::DataLocation)
@@ -199,8 +200,6 @@ QString InstanceManager::determineDataPath()
if (instanceId.isEmpty()) {
return qApp->applicationDirPath();
} else {
- setCurrentInstance(instanceId);
-
createDataPath(dataPath);
return dataPath;
--
cgit v1.3.1
From cb1c9f5e83e98039d38f548c80d4b95442163cf2 Mon Sep 17 00:00:00 2001
From: Eran Mizrahi
Date: Tue, 19 Dec 2017 00:44:18 +0200
Subject: Tie moshortcuts to a specific instance
---
src/CMakeLists.txt | 2 ++
src/executableslist.cpp | 2 +-
src/instancemanager.cpp | 17 ++++++++++++++---
src/instancemanager.h | 8 ++++++--
src/main.cpp | 16 +++++++++++-----
src/mainwindow.cpp | 3 ++-
src/moshortcut.cpp | 39 +++++++++++++++++++++++++++++++++++++++
src/moshortcut.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++
src/organizercore.cpp | 15 +++++++++++----
src/organizercore.h | 6 ++----
10 files changed, 134 insertions(+), 20 deletions(-)
create mode 100644 src/moshortcut.cpp
create mode 100644 src/moshortcut.h
(limited to 'src/instancemanager.cpp')
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 914bdd12..0c70fe57 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -88,6 +88,7 @@ SET(organizer_SRCS
instancemanager.cpp
usvfsconnector.cpp
eventfilter.cpp
+ moshortcut.cpp
shared/windows_error.cpp
shared/error_report.cpp
@@ -179,6 +180,7 @@ SET(organizer_HDRS
usvfsconnector.h
eventfilter.h
descriptionpage.h
+ moshortcut.h
shared/windows_error.h
shared/error_report.h
diff --git a/src/executableslist.cpp b/src/executableslist.cpp
index b1890ac9..21cb6ed4 100644
--- a/src/executableslist.cpp
+++ b/src/executableslist.cpp
@@ -86,7 +86,7 @@ Executable &ExecutablesList::find(const QString &title)
return exe;
}
}
- throw std::runtime_error(QString("invalid name %1").arg(title).toLocal8Bit().constData());
+ throw std::runtime_error(QString("invalid executable name %1").arg(title).toLocal8Bit().constData());
}
diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp
index b1b85cc6..34e23d7b 100644
--- a/src/instancemanager.cpp
+++ b/src/instancemanager.cpp
@@ -47,9 +47,19 @@ InstanceManager &InstanceManager::instance()
return s_Instance;
}
+void InstanceManager::overrideInstance(const QString& instanceName)
+{
+ m_overrideInstanceName = instanceName;
+ m_overrideInstance = true;
+}
+
+
QString InstanceManager::currentInstance() const
{
- return m_AppSettings.value(INSTANCE_KEY, "").toString();
+ if (m_overrideInstance)
+ return m_overrideInstanceName;
+ else
+ return m_AppSettings.value(INSTANCE_KEY, "").toString();
}
void InstanceManager::clearCurrentInstance()
@@ -177,7 +187,8 @@ void InstanceManager::createDataPath(const QString &dataPath) const
QString InstanceManager::determineDataPath()
{
QString instanceId = currentInstance();
- if (instanceId.isEmpty() && portableInstall() && !m_Reset) {
+ if (instanceId.isEmpty() && !m_Reset && (m_overrideInstance || portableInstall()))
+ {
// startup, apparently using portable mode before
return qApp->applicationDirPath();
}
@@ -187,7 +198,7 @@ QString InstanceManager::determineDataPath()
+ "/" + instanceId);
- if (instanceId.isEmpty() || !QFileInfo::exists(dataPath)) {
+ if (!m_overrideInstance && (instanceId.isEmpty() || !QFileInfo::exists(dataPath))) {
instanceId = chooseInstance(instances());
setCurrentInstance(instanceId);
if (!instanceId.isEmpty()) {
diff --git a/src/instancemanager.h b/src/instancemanager.h
index a0a5df09..2782c71d 100644
--- a/src/instancemanager.h
+++ b/src/instancemanager.h
@@ -34,11 +34,14 @@ public:
QString determineDataPath();
void clearCurrentInstance();
+ void overrideInstance(const QString& instanceName);
+
+ QString currentInstance() const;
+
private:
InstanceManager();
- QString currentInstance() const;
QString instancePath() const;
QStringList instances() const;
@@ -55,5 +58,6 @@ private:
QSettings m_AppSettings;
bool m_Reset {false};
-
+ bool m_overrideInstance{false};
+ QString m_overrideInstanceName;
};
diff --git a/src/main.cpp b/src/main.cpp
index 4cf47a3c..3d315f1d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -45,6 +45,7 @@ along with Mod Organizer. If not, see .
#include "tutorialmanager.h"
#include "nxmaccessmanager.h"
#include "instancemanager.h"
+#include "moshortcut.h"
#include
#include
@@ -450,9 +451,9 @@ int runApplication(MOApplication &application, SingleInstance &instance,
// if we have a command line parameter, it is either a nxm link or
// a binary to start
if (arguments.size() > 1) {
- if (OrganizerCore::isMoShortcut(arguments.at(1))) {
+ if (MOShortcut shortcut{ arguments.at(1) }) {
try {
- organizer.runShortcut(OrganizerCore::moShortcutName(arguments.at(1)));
+ organizer.runShortcut(shortcut);
return 0;
} catch (const std::exception &e) {
reportError(
@@ -552,10 +553,12 @@ int main(int argc, char *argv[])
forcePrimary = true;
}
+ MOShortcut moshortcut{ arguments.size() > 1 ? arguments.at(1) : "" };
+
SingleInstance instance(forcePrimary);
if (!instance.primaryInstance()) {
- if ((arguments.size() == 2)
- && (OrganizerCore::isMoShortcut(arguments.at(1)) || OrganizerCore::isNxmLink(arguments.at(1))))
+ if (moshortcut ||
+ arguments.size() > 1 && OrganizerCore::isNxmLink(arguments.at(1)))
{
qDebug("not primary instance, sending shortcut/download message");
instance.sendMessage(arguments.at(1));
@@ -572,7 +575,10 @@ int main(int argc, char *argv[])
QString dataPath;
try {
- dataPath = InstanceManager::instance().determineDataPath();
+ InstanceManager& instanceManager = InstanceManager::instance();
+ if (moshortcut && moshortcut.hasInstance())
+ instanceManager.overrideInstance(moshortcut.instance());
+ dataPath = instanceManager.determineDataPath();
} catch (const std::exception &e) {
if (strcmp(e.what(),"Canceled"))
QMessageBox::critical(nullptr, QObject::tr("Failed to set up instance"), e.what());
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 6f156269..1c5e321d 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -3331,7 +3331,8 @@ void MainWindow::addWindowsLink(const ShortcutType mapping)
QString executable = QDir::toNativeSeparators(selectedExecutable.m_BinaryInfo.absoluteFilePath());
std::wstring targetFile = ToWString(exeInfo.absoluteFilePath());
- std::wstring parameter = ToWString(QString("\"moshortcut://%1\"").arg(selectedExecutable.m_Title));
+ std::wstring parameter = ToWString(
+ QString("\"moshortcut://%1:%2\"").arg(InstanceManager::instance().currentInstance(),selectedExecutable.m_Title));
std::wstring description = ToWString(QString("Run %1 with ModOrganizer").arg(selectedExecutable.m_Title));
std::wstring iconFile = ToWString(executable);
std::wstring currentDirectory = ToWString(QDir::toNativeSeparators(qApp->applicationDirPath()));
diff --git a/src/moshortcut.cpp b/src/moshortcut.cpp
new file mode 100644
index 00000000..c8c2ef6f
--- /dev/null
+++ b/src/moshortcut.cpp
@@ -0,0 +1,39 @@
+/*
+Copyright (C) 2016 Sebastian Herbord. All rights reserved.
+
+This file is part of Mod Organizer.
+
+Mod Organizer is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Mod Organizer is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mod Organizer. If not, see .
+*/
+
+
+#include "moshortcut.h"
+
+
+MOShortcut::MOShortcut(const QString& link)
+ : m_valid(link.startsWith("moshortcut://"))
+ , m_hasInstance(false)
+{
+ if (m_valid) {
+ int start = (int)strlen("moshortcut://");
+ int sep = link.indexOf(':', start);
+ if (sep >= 0) {
+ m_hasInstance = true;
+ m_instance = link.mid(start, sep - start);
+ m_executable = link.mid(sep + 1);
+ }
+ else
+ m_executable = link.mid(start);
+ }
+}
diff --git a/src/moshortcut.h b/src/moshortcut.h
new file mode 100644
index 00000000..7b7574b9
--- /dev/null
+++ b/src/moshortcut.h
@@ -0,0 +1,46 @@
+/*
+Copyright (C) 2016 Sebastian Herbord. All rights reserved.
+
+This file is part of Mod Organizer.
+
+Mod Organizer is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Mod Organizer is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mod Organizer. If not, see .
+*/
+
+
+#pragma once
+
+
+#include
+
+
+class MOShortcut {
+
+public:
+ MOShortcut(const QString& link);
+
+ /// true iff intialized using a valid moshortcut link
+ operator bool() const { return m_valid; }
+
+ bool hasInstance() const { return m_hasInstance; }
+
+ const QString& instance() const { return m_instance; }
+
+ const QString& executable() const { return m_executable; }
+
+private:
+ QString m_instance;
+ QString m_executable;
+ bool m_valid;
+ bool m_hasInstance;
+};
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index 3be9559a..7668485c 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -32,6 +32,7 @@
#include
#include
#include "lockeddialog.h"
+#include "instancemanager.h"
#include
#include
@@ -578,8 +579,8 @@ void OrganizerCore::downloadRequestedNXM(const QString &url)
void OrganizerCore::externalMessage(const QString &message)
{
- if (isMoShortcut(message)) {
- runShortcut(moShortcutName(message));
+ if (MOShortcut moshortcut{ message }) {
+ runShortcut(moshortcut);
}
else if (isNxmLink(message)) {
MessageDialog::showMessage(tr("Download started"), qApp->activeWindow());
@@ -1228,9 +1229,15 @@ HANDLE OrganizerCore::spawnBinaryProcess(const QFileInfo &binary,
}
}
-HANDLE OrganizerCore::runShortcut(const QString &title)
+HANDLE OrganizerCore::runShortcut(const MOShortcut& shortcut)
{
- Executable& exe = m_ExecutablesList.find(title);
+ if (shortcut.hasInstance() && shortcut.instance() != InstanceManager::instance().currentInstance())
+ throw std::runtime_error(
+ QString("Refusing to run executable from different instance %1:%2")
+ .arg(shortcut.instance(),shortcut.executable())
+ .toLocal8Bit().constData());
+
+ Executable& exe = m_ExecutablesList.find(shortcut.executable());
return spawnBinaryDirect(
exe.m_BinaryInfo, exe.m_Arguments,
diff --git a/src/organizercore.h b/src/organizercore.h
index decb3d01..f98e9d0a 100644
--- a/src/organizercore.h
+++ b/src/organizercore.h
@@ -13,6 +13,7 @@
#include "downloadmanager.h"
#include "executableslist.h"
#include "usvfsconnector.h"
+#include "moshortcut.h"
#include
#include
#include
@@ -86,9 +87,6 @@ private:
public:
static bool isNxmLink(const QString &link) { return link.startsWith("nxm://", Qt::CaseInsensitive); }
- static bool isMoShortcut(const QString &link) { return link.startsWith("moshortcut://", Qt::CaseInsensitive); }
- static QString moShortcutName(const QString &link) { return link.mid(strlen("moshortcut://")); }
-
OrganizerCore(const QSettings &initSettings);
@@ -203,7 +201,7 @@ public:
DownloadManager *downloadManager();
PluginList *pluginList();
ModList *modList();
- HANDLE runShortcut(const QString &title);
+ HANDLE runShortcut(const MOShortcut& shortcut);
HANDLE startApplication(const QString &executable, const QStringList &args, const QString &cwd, const QString &profile);
bool waitForApplication(HANDLE processHandle, LPDWORD exitCode = nullptr);
HANDLE findAndOpenAUSVFSProcess();
--
cgit v1.3.1
From 7dbb4cedda27bc5e24050c0d4a822fbe9f7eec95 Mon Sep 17 00:00:00 2001
From: Al12rs
Date: Thu, 18 Jan 2018 19:57:52 +0100
Subject: Added message when creating a new instance with an already existing
name, Aldded manageInstances dialog to allow users to delete local instances,
Added a number of confirmation messageboxes.
---
src/instancemanager.cpp | 93 +++++++++++++++++++++++++++++++++++++++++++++----
src/instancemanager.h | 6 +++-
2 files changed, 91 insertions(+), 8 deletions(-)
(limited to 'src/instancemanager.cpp')
diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp
index 34e23d7b..f8721132 100644
--- a/src/instancemanager.cpp
+++ b/src/instancemanager.cpp
@@ -73,24 +73,94 @@ void InstanceManager::setCurrentInstance(const QString &name)
m_AppSettings.setValue(INSTANCE_KEY, name);
}
+bool InstanceManager::deleteLocalInstance(const QString &instanceId) const
+{
+ bool result = true;
+ QString instancePath = QDir::fromNativeSeparators(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + instanceId);
+
+ if (QMessageBox::warning(nullptr, QObject::tr("Deleting folder"),
+ QObject::tr("I'm about to delete the following folder: \"%1\". Proceed?").arg(instancePath), QMessageBox::No | QMessageBox::Yes, QMessageBox::No) == QMessageBox::No ){
+ return false;
+ }
+
+ if (!MOBase::shellDelete(QStringList(instancePath),true))
+ {
+ qWarning("Failed to shell-delete \"%s\" (errorcode %lu), trying regular delete", qPrintable(instancePath), ::GetLastError());
+ if (!MOBase::removeDir(instancePath))
+ {
+ qWarning("regular delete failed too");
+ result = false;
+ }
+ }
+
+ return result;
+}
-QString InstanceManager::queryInstanceName() const
+QString InstanceManager::manageInstances(const QStringList &instanceList) const
+{
+ SelectionDialog selection(
+ QString("%1
%2")
+ .arg(QObject::tr("Choose Instance to Delete"))
+ .arg(QObject::tr("Be Carefull! Deleting an Instance will remove all your files for that Instance (mods, downloads, profiles, configuration, ...). Custom paths outside of the instance folder for downloads, mods, etc. will be left untoched.")),
+ nullptr);
+ for (const QString &instance : instanceList)
+ {
+ selection.addChoice(instance, "", instance);
+ }
+
+ if (selection.exec() == QDialog::Rejected) {
+ return(chooseInstance(instances()));
+ }
+ else {
+ QString choice = selection.getChoiceData().toString();
+ {
+ if (QMessageBox::warning(nullptr, QObject::tr("Are you sure?"),
+ QObject::tr("Are you really sure you want to delete the Instance \"%1\" with all its files?").arg(choice), QMessageBox::No | QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
+ {
+ if (!deleteLocalInstance(choice))
+ {
+ QMessageBox::warning(nullptr, QObject::tr("Failed to delete Instance"),
+ QObject::tr("Could not delete Instance \"%1\"").arg(choice), QMessageBox::Ok);
+ }
+ }
+ }
+ }
+ return(manageInstances(instances()));
+}
+
+QString InstanceManager::queryInstanceName(const QStringList &instanceList) const
{
QString instanceId;
while (instanceId.isEmpty()) {
QInputDialog dialog;
+
+ dialog.setWindowTitle(QObject::tr("Enter a Name for the new Instance"));
+ dialog.setLabelText(QObject::tr("Enter a new name or select one from the sugested list (only letters and numbers allowed):"));
// would be neat if we could take the names from the game plugins but
// the required initialization order requires the ini file to be
// available *before* we load plugins
- dialog.setComboBoxItems({ "Oblivion", "Skyrim", "SkyrimSE", "Fallout 3",
- "Fallout NV", "Fallout 4" });
+ dialog.setComboBoxItems({ "NewName", "Fallout 4", "SkyrimSE", "Skyrim", "Fallout 3",
+ "Fallout NV", "FO4VR", "Oblivion" });
dialog.setComboBoxEditable(true);
- dialog.setWindowTitle(QObject::tr("Enter Instance Name"));
- dialog.setLabelText(QObject::tr("Name"));
+
if (dialog.exec() == QDialog::Rejected) {
throw MOBase::MyException(QObject::tr("Canceled"));
}
instanceId = dialog.textValue().replace(QRegExp("[^0-9a-zA-Z ]"), "");
+
+ bool alreadyExists=false;
+ for (const QString &instance : instanceList) {
+ if(instanceId==instance)
+ alreadyExists=true;
+ }
+ if(alreadyExists)
+ {
+ QMessageBox msgBox;
+ msgBox.setText( QObject::tr("The instance \"%1\" already exists.").arg(instanceId) );
+ msgBox.setInformativeText(QObject::tr("Please choose a different instance name, like: \"%1\1\" .").arg(instanceId));
+ msgBox.exec();
+ instanceId="";
+ }
}
return instanceId;
}
@@ -100,7 +170,8 @@ QString InstanceManager::chooseInstance(const QStringList &instanceList) const
{
enum class Special : uint8_t {
NewInstance,
- Portable
+ Portable,
+ Manage
};
SelectionDialog selection(
@@ -128,6 +199,10 @@ QString InstanceManager::chooseInstance(const QStringList &instanceList) const
static_cast(Special::Portable));
}
+ selection.addChoice(QIcon(":/MO/gui/remove"), QObject::tr("Manage Instances"),
+ QObject::tr("Delete an Instance."),
+ static_cast(Special::Manage));
+
if (selection.exec() == QDialog::Rejected) {
qDebug("rejected");
throw MOBase::MyException(QObject::tr("Canceled"));
@@ -139,8 +214,12 @@ QString InstanceManager::chooseInstance(const QStringList &instanceList) const
return choice.toString();
} else {
switch (choice.value()) {
- case Special::NewInstance: return queryInstanceName();
+ case Special::NewInstance: return queryInstanceName(instanceList);
case Special::Portable: return QString();
+ case Special::Manage: {
+
+ return(manageInstances(instances()));
+ }
default: throw std::runtime_error("invalid selection");
}
}
diff --git a/src/instancemanager.h b/src/instancemanager.h
index 2782c71d..adedd78f 100644
--- a/src/instancemanager.h
+++ b/src/instancemanager.h
@@ -46,9 +46,13 @@ private:
QStringList instances() const;
+ bool deleteLocalInstance(const QString &instanceId) const;
+
+ QString manageInstances(const QStringList &instanceList) const;
+
void setCurrentInstance(const QString &name);
- QString queryInstanceName() const;
+ QString queryInstanceName(const QStringList &instanceList) const;
QString chooseInstance(const QStringList &instanceList) const;
void createDataPath(const QString &dataPath) const;
--
cgit v1.3.1
From 45b3614fbcd992b7b505a423cd0970ac8c777a4f Mon Sep 17 00:00:00 2001
From: Al12rs
Date: Fri, 19 Jan 2018 01:13:45 +0100
Subject: fixed a typo in the label text
---
src/instancemanager.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/instancemanager.cpp')
diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp
index f8721132..4d8ff509 100644
--- a/src/instancemanager.cpp
+++ b/src/instancemanager.cpp
@@ -157,7 +157,7 @@ QString InstanceManager::queryInstanceName(const QStringList &instanceList) cons
{
QMessageBox msgBox;
msgBox.setText( QObject::tr("The instance \"%1\" already exists.").arg(instanceId) );
- msgBox.setInformativeText(QObject::tr("Please choose a different instance name, like: \"%1\1\" .").arg(instanceId));
+ msgBox.setInformativeText(QObject::tr("Please choose a different instance name, like: \"%1 1\" .").arg(instanceId));
msgBox.exec();
instanceId="";
}
--
cgit v1.3.1
From 95b258c0df3425632bd48105793aa38a273f4dae Mon Sep 17 00:00:00 2001
From: Al12rs
Date: Fri, 19 Jan 2018 11:53:47 +0100
Subject: Updated InstanceSelection dialog to be slighly more clear.
---
src/instancemanager.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'src/instancemanager.cpp')
diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp
index 4d8ff509..29068c5b 100644
--- a/src/instancemanager.cpp
+++ b/src/instancemanager.cpp
@@ -179,10 +179,10 @@ QString InstanceManager::chooseInstance(const QStringList &instanceList) const
.arg(QObject::tr("Choose Instance"))
.arg(QObject::tr(
"Each Instance is a full set of MO data files (mods, "
- "downloads, profiles, configuration, ...). Use multiple "
- "instances for different games. If your MO folder is "
- "writable, you can also store a single instance locally (called "
- "a portable install).")),
+ "downloads, profiles, configuration, ...). You can use multiple "
+ "instances for different games. Instances are stored in Appdata and can be accessed by all MO installations. "
+ "If your MO folder is writable, you can also store a single instance locally (called "
+ "a Portable install, and all the MO data files will be inside the installation folder).")),
nullptr);
selection.disableCancel();
for (const QString &instance : instanceList) {
--
cgit v1.3.1
From 5e5c9c07291f6b09623d31c92b1fb61c4ede576e Mon Sep 17 00:00:00 2001
From: Sandro Jäckel
Date: Thu, 22 Feb 2018 16:54:34 +0100
Subject: Applied clang-format on source
---
.clang-format | 11 +
src/aboutdialog.cpp | 95 +-
src/aboutdialog.h | 44 +-
src/activatemodsdialog.cpp | 99 +-
src/activatemodsdialog.h | 58 +-
src/bbcode.cpp | 415 +-
src/bbcode.h | 7 +-
src/browserdialog.cpp | 370 +-
src/browserdialog.h | 110 +-
src/browserview.cpp | 77 +-
src/browserview.h | 67 +-
src/categories.cpp | 516 ++-
src/categories.h | 306 +-
src/categoriesdialog.cpp | 320 +-
src/categoriesdialog.h | 46 +-
src/credentialsdialog.cpp | 32 +-
src/credentialsdialog.h | 21 +-
src/csvbuilder.cpp | 345 +-
src/csvbuilder.h | 99 +-
src/descriptionpage.h | 14 +-
src/directoryrefresher.cpp | 203 +-
src/directoryrefresher.h | 200 +-
src/downloadlist.cpp | 123 +-
src/downloadlist.h | 96 +-
src/downloadlistsortproxy.cpp | 71 +-
src/downloadlistsortproxy.h | 27 +-
src/downloadlistwidget.cpp | 482 +--
src/downloadlistwidget.h | 103 +-
src/downloadlistwidgetcompact.cpp | 455 +--
src/downloadlistwidgetcompact.h | 114 +-
src/downloadmanager.cpp | 2325 +++++------
src/downloadmanager.h | 837 ++--
src/editexecutablesdialog.cpp | 459 +--
src/editexecutablesdialog.h | 91 +-
src/eventfilter.cpp | 14 +-
src/eventfilter.h | 16 +-
src/executableslist.cpp | 253 +-
src/executableslist.h | 273 +-
src/filedialogmemory.cpp | 106 +-
src/filedialogmemory.h | 37 +-
src/gameinfoimpl.cpp | 49 +-
src/genericicondelegate.cpp | 44 +-
src/genericicondelegate.h | 45 +-
src/helper.cpp | 90 +-
src/helper.h | 13 +-
src/icondelegate.cpp | 71 +-
src/icondelegate.h | 22 +-
src/ilockedwaitingforprocess.h | 7 +-
src/installationmanager.cpp | 1334 +++---
src/installationmanager.h | 303 +-
src/instancemanager.cpp | 410 +-
src/instancemanager.h | 46 +-
src/iuserinterface.h | 35 +-
src/json.cpp | 823 ++--
src/json.h | 105 +-
src/loadmechanism.cpp | 454 +--
src/loadmechanism.h | 119 +-
src/lockeddialog.cpp | 64 +-
src/lockeddialog.h | 21 +-
src/lockeddialogbase.cpp | 65 +-
src/lockeddialogbase.h | 32 +-
src/logbuffer.cpp | 337 +-
src/logbuffer.h | 78 +-
src/loghighlighter.cpp | 47 +-
src/loghighlighter.h | 9 +-
src/main.cpp | 1052 +++--
src/mainwindow.cpp | 8136 ++++++++++++++++++-------------------
src/mainwindow.h | 691 ++--
src/messagedialog.cpp | 107 +-
src/messagedialog.h | 46 +-
src/moapplication.cpp | 175 +-
src/moapplication.h | 19 +-
src/modeltest.cpp | 496 ++-
src/modeltest.h | 62 +-
src/modflagicondelegate.cpp | 142 +-
src/modflagicondelegate.h | 17 +-
src/modinfo.cpp | 512 ++-
src/modinfo.h | 1111 +++--
src/modinfobackup.cpp | 22 +-
src/modinfobackup.h | 49 +-
src/modinfodialog.cpp | 1832 ++++-----
src/modinfodialog.h | 313 +-
src/modinfoforeign.cpp | 76 +-
src/modinfoforeign.h | 100 +-
src/modinfooverwrite.cpp | 75 +-
src/modinfooverwrite.h | 82 +-
src/modinforegular.cpp | 878 ++--
src/modinforegular.h | 622 ++-
src/modinfowithconflictinfo.cpp | 184 +-
src/modinfowithconflictinfo.h | 62 +-
src/modlist.cpp | 1891 +++++----
src/modlist.h | 432 +-
src/modlistsortproxy.cpp | 646 ++-
src/modlistsortproxy.h | 134 +-
src/modlistview.cpp | 67 +-
src/modlistview.h | 22 +-
src/moshortcut.cpp | 26 +-
src/moshortcut.h | 23 +-
src/motddialog.cpp | 27 +-
src/motddialog.h | 19 +-
src/nexusinterface.cpp | 943 ++---
src/nexusinterface.h | 700 ++--
src/noeditdelegate.cpp | 9 +-
src/noeditdelegate.h | 6 +-
src/nxmaccessmanager.cpp | 478 +--
src/nxmaccessmanager.h | 131 +-
src/organizercore.cpp | 3491 ++++++++--------
src/organizercore.h | 408 +-
src/organizerproxy.cpp | 187 +-
src/organizerproxy.h | 93 +-
src/overwriteinfodialog.cpp | 340 +-
src/overwriteinfodialog.h | 53 +-
src/persistentcookiejar.cpp | 96 +-
src/persistentcookiejar.h | 19 +-
src/plugincontainer.cpp | 502 ++-
src/plugincontainer.h | 115 +-
src/pluginlist.cpp | 1866 ++++-----
src/pluginlist.h | 501 ++-
src/pluginlistsortproxy.cpp | 137 +-
src/pluginlistsortproxy.h | 44 +-
src/pluginlistview.cpp | 66 +-
src/pluginlistview.h | 22 +-
src/previewdialog.cpp | 66 +-
src/previewdialog.h | 24 +-
src/previewgenerator.cpp | 40 +-
src/previewgenerator.h | 24 +-
src/problemsdialog.cpp | 104 +-
src/problemsdialog.h | 30 +-
src/profile.cpp | 1180 +++---
src/profile.h | 569 ++-
src/profileinputdialog.cpp | 28 +-
src/profileinputdialog.h | 19 +-
src/profilesdialog.cpp | 460 +--
src/profilesdialog.h | 81 +-
src/qtgroupingproxy.cpp | 1651 ++++----
src/qtgroupingproxy.h | 235 +-
src/queryoverwritedialog.cpp | 51 +-
src/queryoverwritedialog.h | 39 +-
src/savetextasdialog.cpp | 54 +-
src/savetextasdialog.h | 21 +-
src/selectiondialog.cpp | 107 +-
src/selectiondialog.h | 54 +-
src/selfupdater.cpp | 412 +-
src/selfupdater.h | 142 +-
src/serverinfo.h | 13 +-
src/settings.cpp | 1491 ++++---
src/settings.h | 846 ++--
src/settingsdialog.cpp | 319 +-
src/settingsdialog.h | 53 +-
src/shared/appconfig.cpp | 4 +-
src/shared/appconfig.h | 4 +-
src/shared/directoryentry.cpp | 1332 +++---
src/shared/directoryentry.h | 405 +-
src/shared/error_report.cpp | 98 +-
src/shared/leaktrace.cpp | 70 +-
src/shared/leaktrace.h | 7 +-
src/shared/stackdata.cpp | 219 +-
src/shared/stackdata.h | 43 +-
src/shared/util.cpp | 209 +-
src/shared/util.h | 23 +-
src/shared/windows_error.cpp | 43 +-
src/shared/windows_error.h | 14 +-
src/singleinstance.cpp | 125 +-
src/singleinstance.h | 79 +-
src/spawn.cpp | 244 +-
src/spawn.h | 12 +-
src/syncoverwritedialog.cpp | 215 +-
src/syncoverwritedialog.h | 31 +-
src/transfersavesdialog.cpp | 464 +--
src/transfersavesdialog.h | 81 +-
src/usvfsconnector.cpp | 251 +-
src/usvfsconnector.h | 50 +-
src/viewmarkingscrollbar.cpp | 54 +-
src/viewmarkingscrollbar.h | 20 +-
src/waitingonclosedialog.cpp | 61 +-
src/waitingonclosedialog.h | 23 +-
176 files changed, 26451 insertions(+), 30158 deletions(-)
create mode 100644 .clang-format
(limited to 'src/instancemanager.cpp')
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00000000..6e34f96b
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,11 @@
+---
+Language: Cpp
+BasedOnStyle: LLVM
+
+AccessModifierOffset: -4
+AlwaysBreakTemplateDeclarations: true
+ColumnLimit: 120
+DerivePointerAlignment: false
+IndentWidth: 4
+PointerAlignment: Left
+SortUsingDeclarations: true
\ No newline at end of file
diff --git a/src/aboutdialog.cpp b/src/aboutdialog.cpp
index ed57a217..e79109ad 100644
--- a/src/aboutdialog.cpp
+++ b/src/aboutdialog.cpp
@@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License
along with Mod Organizer. If not, see .
*/
-
#include "aboutdialog.h"
#include "ui_aboutdialog.h"
#include
@@ -30,65 +29,55 @@ along with Mod Organizer. If not, see .
#include
#include
-
-AboutDialog::AboutDialog(const QString &version, QWidget *parent)
- : QDialog(parent)
- , ui(new Ui::AboutDialog)
-{
- ui->setupUi(this);
-
- m_LicenseFiles[LICENSE_LGPL3] = "lgpl-3.0.txt";
- m_LicenseFiles[LICENSE_GPL3] = "gpl-3.0.txt";
- m_LicenseFiles[LICENSE_BSD3] = "bsd3.txt";
- m_LicenseFiles[LICENSE_BOOST] = "boost.txt";
- m_LicenseFiles[LICENSE_CCBY3] = "by-sa3.txt";
- m_LicenseFiles[LICENSE_ZLIB] = "zlib.txt";
- m_LicenseFiles[LICENSE_APACHE2] = "apache-license-2.0.txt";
-
- addLicense("Qt", LICENSE_LGPL3);
- addLicense("Qt Json", LICENSE_GPL3);
- addLicense("Boost Library", LICENSE_BOOST);
- addLicense("7-zip", LICENSE_LGPL3);
- addLicense("ZLib", LICENSE_ZLIB);
- addLicense("Tango Icon Theme", LICENSE_NONE);
- addLicense("RRZE Icon Set", LICENSE_CCBY3);
- addLicense("Icons by Lorc, Delapouite and sbed available on http://game-icons.net", LICENSE_CCBY3);
- addLicense("Castle Core", LICENSE_APACHE2);
- addLicense("LOOT", LICENSE_GPL3);
-
- ui->nameLabel->setText(QString("%1 %2").arg(ui->nameLabel->text()).arg(version));
+AboutDialog::AboutDialog(const QString& version, QWidget* parent) : QDialog(parent), ui(new Ui::AboutDialog) {
+ ui->setupUi(this);
+
+ m_LicenseFiles[LICENSE_LGPL3] = "lgpl-3.0.txt";
+ m_LicenseFiles[LICENSE_GPL3] = "gpl-3.0.txt";
+ m_LicenseFiles[LICENSE_BSD3] = "bsd3.txt";
+ m_LicenseFiles[LICENSE_BOOST] = "boost.txt";
+ m_LicenseFiles[LICENSE_CCBY3] = "by-sa3.txt";
+ m_LicenseFiles[LICENSE_ZLIB] = "zlib.txt";
+ m_LicenseFiles[LICENSE_APACHE2] = "apache-license-2.0.txt";
+
+ addLicense("Qt", LICENSE_LGPL3);
+ addLicense("Qt Json", LICENSE_GPL3);
+ addLicense("Boost Library", LICENSE_BOOST);
+ addLicense("7-zip", LICENSE_LGPL3);
+ addLicense("ZLib", LICENSE_ZLIB);
+ addLicense("Tango Icon Theme", LICENSE_NONE);
+ addLicense("RRZE Icon Set", LICENSE_CCBY3);
+ addLicense("Icons by Lorc, Delapouite and sbed available on http://game-icons.net", LICENSE_CCBY3);
+ addLicense("Castle Core", LICENSE_APACHE2);
+ addLicense("LOOT", LICENSE_GPL3);
+
+ ui->nameLabel->setText(QString("%1 %2")
+ .arg(ui->nameLabel->text())
+ .arg(version));
#if defined(HGID)
- ui->revisionLabel->setText(ui->revisionLabel->text() + " " + HGID);
+ ui->revisionLabel->setText(ui->revisionLabel->text() + " " + HGID);
#elif defined(GITID)
- ui->revisionLabel->setText(ui->revisionLabel->text() + " " + GITID);
+ ui->revisionLabel->setText(ui->revisionLabel->text() + " " + GITID);
#else
- ui->revisionLabel->setText(ui->revisionLabel->text() + " unknown");
+ ui->revisionLabel->setText(ui->revisionLabel->text() + " unknown");
#endif
}
+AboutDialog::~AboutDialog() { delete ui; }
-AboutDialog::~AboutDialog()
-{
- delete ui;
+void AboutDialog::addLicense(const QString& name, Licenses license) {
+ QListWidgetItem* item = new QListWidgetItem(name);
+ item->setData(Qt::UserRole, license);
+ ui->creditsList->addItem(item);
}
-
-void AboutDialog::addLicense(const QString &name, Licenses license)
-{
- QListWidgetItem *item = new QListWidgetItem(name);
- item->setData(Qt::UserRole, license);
- ui->creditsList->addItem(item);
-}
-
-
-void AboutDialog::on_creditsList_currentItemChanged(QListWidgetItem *current, QListWidgetItem*)
-{
- auto iter = m_LicenseFiles.find(current->data(Qt::UserRole).toInt());
- if (iter != m_LicenseFiles.end()) {
- QString filePath = qApp->applicationDirPath() + "/license/" + iter->second;
- QString text = MOBase::readFileText(filePath);
- ui->licenseText->setText(text);
- } else {
- ui->licenseText->setText(tr("No license"));
- }
+void AboutDialog::on_creditsList_currentItemChanged(QListWidgetItem* current, QListWidgetItem*) {
+ auto iter = m_LicenseFiles.find(current->data(Qt::UserRole).toInt());
+ if (iter != m_LicenseFiles.end()) {
+ QString filePath = qApp->applicationDirPath() + "/license/" + iter->second;
+ QString text = MOBase::readFileText(filePath);
+ ui->licenseText->setText(text);
+ } else {
+ ui->licenseText->setText(tr("No license"));
+ }
}
diff --git a/src/aboutdialog.h b/src/aboutdialog.h
index 103a0d2f..a5c93834 100644
--- a/src/aboutdialog.h
+++ b/src/aboutdialog.h
@@ -18,7 +18,6 @@ You should have received a copy of the GNU General Public License
along with Mod Organizer. If not, see .
*/
-
#define ABOUTDIALOG_H
#include
@@ -29,43 +28,38 @@ class QListWidgetItem;
#include
");
- m_TagMap["code"] = std::make_pair(QRegExp("\\[code\\](.*)\\[/code\\]"),
- "\\1
");
- m_TagMap["heading"]= std::make_pair(QRegExp("\\[heading\\](.*)\\[/heading\\]"),
- "\\1
");
- m_TagMap["line"] = std::make_pair(QRegExp("\\[line\\]"),
- "
");
-
- // lists
- m_TagMap["list"] = std::make_pair(QRegExp("\\[list\\](.*)\\[/list\\]"),
- "");
- m_TagMap["list="] = std::make_pair(QRegExp("\\[list.*\\](.*)\\[/list\\]"),
- "\\1
");
- m_TagMap["ul"] = std::make_pair(QRegExp("\\[ul\\](.*)\\[/ul\\]"),
- "");
- m_TagMap["ol"] = std::make_pair(QRegExp("\\[ol\\](.*)\\[/ol\\]"),
- "\\1
");
- m_TagMap["li"] = std::make_pair(QRegExp("\\[li\\](.*)\\[/li\\]"),
- "\\1");
-
- // tables
- m_TagMap["table"] = std::make_pair(QRegExp("\\[table\\](.*)\\[/table\\]"),
- "");
- m_TagMap["tr"] = std::make_pair(QRegExp("\\[tr\\](.*)\\[/tr\\]"),
- "\\1
");
- m_TagMap["th"] = std::make_pair(QRegExp("\\[th\\](.*)\\[/th\\]"),
- "\\1 | ");
- m_TagMap["td"] = std::make_pair(QRegExp("\\[td\\](.*)\\[/td\\]"),
- "\\1 | ");
-
- // web content
- m_TagMap["url"] = std::make_pair(QRegExp("\\[url\\](.*)\\[/url\\]"),
- "\\1");
- m_TagMap["url="] = std::make_pair(QRegExp("\\[url=([^\\]]*)\\](.*)\\[/url\\]"),
- "\\2");
- m_TagMap["img"] = std::make_pair(QRegExp("\\[img\\](.*)\\[/img\\]"),
- "
");
- m_TagMap["img="] = std::make_pair(QRegExp("\\[img=([^\\]]*)\\](.*)\\[/img\\]"),
- "
");
- m_TagMap["email="] = std::make_pair(QRegExp("\\[email=\"?([^\\]]*)\"?\\](.*)\\[/email\\]"),
- "\\2");
- m_TagMap["youtube"] = std::make_pair(QRegExp("\\[youtube\\](.*)\\[/youtube\\]"),
- "http://www.youtube.com/v/\\1");
-
+ BBCodeMap() : m_TagNameExp("^[a-zA-Z*]*=?") {
+ m_TagMap["b"] = std::make_pair(QRegExp("\\[b\\](.*)\\[/b\\]"), "\\1");
+ m_TagMap["i"] = std::make_pair(QRegExp("\\[i\\](.*)\\[/i\\]"), "\\1");
+ m_TagMap["u"] = std::make_pair(QRegExp("\\[u\\](.*)\\[/u\\]"), "\\1");
+ m_TagMap["s"] = std::make_pair(QRegExp("\\[s\\](.*)\\[/s\\]"), "\\1");
+ m_TagMap["sub"] = std::make_pair(QRegExp("\\[sub\\](.*)\\[/sub\\]"), "\\1");
+ m_TagMap["sup"] = std::make_pair(QRegExp("\\[sup\\](.*)\\[/sup\\]"), "\\1");
+ m_TagMap["size="] =
+ std::make_pair(QRegExp("\\[size=([^\\]]*)\\](.*)\\[/size\\]"), "\\2");
+ m_TagMap["color="] = std::make_pair(QRegExp("\\[color=([^\\]]*)\\](.*)\\[/color\\]"), "");
+ m_TagMap["font="] = std::make_pair(QRegExp("\\[font=([^\\]]*)\\](.*)\\[/font\\]"),
+ "\\2");
+ m_TagMap["center"] =
+ std::make_pair(QRegExp("\\[center\\](.*)\\[/center\\]"), "\\1
");
+ m_TagMap["quote"] = std::make_pair(QRegExp("\\[quote\\](.*)\\[/quote\\]"), "\"\\1\"
");
+ m_TagMap["quote="] = std::make_pair(QRegExp("\\[quote=([^\\]]*)\\](.*)\\[/quote\\]"),
+ "\"\\2\"
--\\1
");
+ m_TagMap["code"] = std::make_pair(QRegExp("\\[code\\](.*)\\[/code\\]"), "\\1
");
+ m_TagMap["heading"] =
+ std::make_pair(QRegExp("\\[heading\\](.*)\\[/heading\\]"), "\\1
");
+ m_TagMap["line"] = std::make_pair(QRegExp("\\[line\\]"), "
");
+
+ // lists
+ m_TagMap["list"] = std::make_pair(QRegExp("\\[list\\](.*)\\[/list\\]"), "");
+ m_TagMap["list="] = std::make_pair(QRegExp("\\[list.*\\](.*)\\[/list\\]"), "\\1
");
+ m_TagMap["ul"] = std::make_pair(QRegExp("\\[ul\\](.*)\\[/ul\\]"), "");
+ m_TagMap["ol"] = std::make_pair(QRegExp("\\[ol\\](.*)\\[/ol\\]"), "\\1
");
+ m_TagMap["li"] = std::make_pair(QRegExp("\\[li\\](.*)\\[/li\\]"), "\\1");
+
+ // tables
+ m_TagMap["table"] = std::make_pair(QRegExp("\\[table\\](.*)\\[/table\\]"), "");
+ m_TagMap["tr"] = std::make_pair(QRegExp("\\[tr\\](.*)\\[/tr\\]"), "\\1
");
+ m_TagMap["th"] = std::make_pair(QRegExp("\\[th\\](.*)\\[/th\\]"), "\\1 | ");
+ m_TagMap["td"] = std::make_pair(QRegExp("\\[td\\](.*)\\[/td\\]"), "\\1 | ");
+
+ // web content
+ m_TagMap["url"] = std::make_pair(QRegExp("\\[url\\](.*)\\[/url\\]"), "\\1");
+ m_TagMap["url="] = std::make_pair(QRegExp("\\[url=([^\\]]*)\\](.*)\\[/url\\]"), "\\2");
+ m_TagMap["img"] = std::make_pair(QRegExp("\\[img\\](.*)\\[/img\\]"), "
");
+ m_TagMap["img="] =
+ std::make_pair(QRegExp("\\[img=([^\\]]*)\\](.*)\\[/img\\]"), "
");
+ m_TagMap["email="] =
+ std::make_pair(QRegExp("\\[email=\"?([^\\]]*)\"?\\](.*)\\[/email\\]"), "\\2");
+ m_TagMap["youtube"] =
+ std::make_pair(QRegExp("\\[youtube\\](.*)\\[/youtube\\]"),
+ "http://www.youtube.com/v/\\1");
+
+ // make all patterns non-greedy and case-insensitive
+ for (TagMap::iterator iter = m_TagMap.begin(); iter != m_TagMap.end(); ++iter) {
+ iter->second.first.setCaseSensitivity(Qt::CaseInsensitive);
+ iter->second.first.setMinimal(true);
+ }
- // make all patterns non-greedy and case-insensitive
- for (TagMap::iterator iter = m_TagMap.begin(); iter != m_TagMap.end(); ++iter) {
- iter->second.first.setCaseSensitivity(Qt::CaseInsensitive);
- iter->second.first.setMinimal(true);
+ // this tag is in fact greedy
+ m_TagMap["*"] = std::make_pair(QRegExp("\\[\\*\\](.*)"), "\\1");
+
+ m_ColorMap.insert(std::make_pair("red", "FF0000"));
+ m_ColorMap.insert(std::make_pair("green", "00FF00"));
+ m_ColorMap.insert(std::make_pair("blue", "0000FF"));
+ m_ColorMap.insert(std::make_pair("black", "000000"));
+ m_ColorMap.insert(std::make_pair("gray", "7F7F7F"));
+ m_ColorMap.insert(std::make_pair("white", "FFFFFF"));
+ m_ColorMap.insert(std::make_pair("yellow", "FFFF00"));
+ m_ColorMap.insert(std::make_pair("cyan", "00FFFF"));
+ m_ColorMap.insert(std::make_pair("magenta", "FF00FF"));
+ m_ColorMap.insert(std::make_pair("brown", "A52A2A"));
+ m_ColorMap.insert(std::make_pair("orange", "FFA500"));
+ m_ColorMap.insert(std::make_pair("gold", "FFD700"));
+ m_ColorMap.insert(std::make_pair("deepskyblue", "00BFFF"));
+ m_ColorMap.insert(std::make_pair("salmon", "FA8072"));
+ m_ColorMap.insert(std::make_pair("dodgerblue", "1E90FF"));
+ m_ColorMap.insert(std::make_pair("greenyellow", "ADFF2F"));
+ m_ColorMap.insert(std::make_pair("peru", "CD853F"));
}
- // this tag is in fact greedy
- m_TagMap["*"] = std::make_pair(QRegExp("\\[\\*\\](.*)"),
- "\\1");
-
- m_ColorMap.insert(std::make_pair("red", "FF0000"));
- m_ColorMap.insert(std::make_pair("green", "00FF00"));
- m_ColorMap.insert(std::make_pair("blue", "0000FF"));
- m_ColorMap.insert(std::make_pair("black", "000000"));
- m_ColorMap.insert(std::make_pair("gray", "7F7F7F"));
- m_ColorMap.insert(std::make_pair("white", "FFFFFF"));
- m_ColorMap.insert(std::make_pair("yellow", "FFFF00"));
- m_ColorMap.insert(std::make_pair("cyan", "00FFFF"));
- m_ColorMap.insert(std::make_pair("magenta", "FF00FF"));
- m_ColorMap.insert(std::make_pair("brown", "A52A2A"));
- m_ColorMap.insert(std::make_pair("orange", "FFA500"));
- m_ColorMap.insert(std::make_pair("gold", "FFD700"));
- m_ColorMap.insert(std::make_pair("deepskyblue", "00BFFF"));
- m_ColorMap.insert(std::make_pair("salmon", "FA8072"));
- m_ColorMap.insert(std::make_pair("dodgerblue", "1E90FF"));
- m_ColorMap.insert(std::make_pair("greenyellow", "ADFF2F"));
- m_ColorMap.insert(std::make_pair("peru", "CD853F"));
- }
-
private:
-
- QRegExp m_TagNameExp;
- TagMap m_TagMap;
- std::map m_ColorMap;
+ QRegExp m_TagNameExp;
+ TagMap m_TagMap;
+ std::map m_ColorMap;
};
-
-QString convertToHTML(const QString &inputParam)
-{
- // this code goes over the input string once and replaces all bbtags
- // it encounters. This function is called recursively for every replaced
- // string to convert nested tags.
- //
- // This could be implemented simpler by applying a set of regular expressions
- // for each recognized bb-tag one after the other but that would probably be
- // very inefficient (O(n^2)).
-
- QString input = inputParam.mid(0).replace("\r\n", "
");
- input.replace("\\\"", "\"").replace("\\'", "'");
- QString result;
- int lastBlock = 0;
- int pos = 0;
-
- // iterate over the input buffer
- while ((pos = input.indexOf('[', lastBlock)) != -1) {
- // append everything between the previous tag-block and the current one
- result.append(input.midRef(lastBlock, pos - lastBlock));
-
- if ((pos < (input.size() - 1)) && (input.at(pos + 1) == '/')) {
- // skip invalid end tag
- int tagEnd = input.indexOf(']', pos) + 1;
- pos = tagEnd;
- } else {
- // convert the tag and content if necessary
- int length = -1;
- QString replacement = BBCodeMap::instance().convertTag(input.mid(pos), length);
- if (length != 0) {
- result.append(convertToHTML(replacement));
- // length contains the number of characters in the original tag
- pos += length;
- } else {
- // nothing replaced
- result.append('[');
- ++pos;
- }
+QString convertToHTML(const QString& inputParam) {
+ // this code goes over the input string once and replaces all bbtags
+ // it encounters. This function is called recursively for every replaced
+ // string to convert nested tags.
+ //
+ // This could be implemented simpler by applying a set of regular expressions
+ // for each recognized bb-tag one after the other but that would probably be
+ // very inefficient (O(n^2)).
+
+ QString input = inputParam.mid(0).replace("\r\n", "
");
+ input.replace("\\\"", "\"").replace("\\'", "'");
+ QString result;
+ int lastBlock = 0;
+ int pos = 0;
+
+ // iterate over the input buffer
+ while ((pos = input.indexOf('[', lastBlock)) != -1) {
+ // append everything between the previous tag-block and the current one
+ result.append(input.midRef(lastBlock, pos - lastBlock));
+
+ if ((pos < (input.size() - 1)) && (input.at(pos + 1) == '/')) {
+ // skip invalid end tag
+ int tagEnd = input.indexOf(']', pos) + 1;
+ pos = tagEnd;
+ } else {
+ // convert the tag and content if necessary
+ int length = -1;
+ QString replacement = BBCodeMap::instance().convertTag(input.mid(pos), length);
+ if (length != 0) {
+ result.append(convertToHTML(replacement));
+ // length contains the number of characters in the original tag
+ pos += length;
+ } else {
+ // nothing replaced
+ result.append('[');
+ ++pos;
+ }
+ }
+ lastBlock = pos;
}
- lastBlock = pos;
- }
- // append the remainder (everything after the last tag)
- result.append(input.midRef(lastBlock));
- return result;
+ // append the remainder (everything after the last tag)
+ result.append(input.midRef(lastBlock));
+ return result;
}
} // namespace BBCode
-
diff --git a/src/bbcode.h b/src/bbcode.h
index 708dfe71..d8a10337 100644
--- a/src/bbcode.h
+++ b/src/bbcode.h
@@ -20,10 +20,8 @@ along with Mod Organizer. If not, see .
#ifndef BBCODE_H
#define BBCODE_H
-
#include
-
namespace BBCode {
/**
@@ -32,9 +30,8 @@ namespace BBCode {
* @param replaceOccured if not nullptr, this parameter will be set to true if any bb tags were replaced
* @return the same string in html representation
**/
-QString convertToHTML(const QString &input);
-
-}
+QString convertToHTML(const QString& input);
+} // namespace BBCode
#endif // BBCODE_H
diff --git a/src/browserdialog.cpp b/src/browserdialog.cpp
index c2c65acc..d5a43332 100644
--- a/src/browserdialog.cpp
+++ b/src/browserdialog.cpp
@@ -19,276 +19,228 @@ along with Mod Organizer. If not, see .
#include "browserdialog.h"
-#include "ui_browserdialog.h"
#include "browserview.h"
#include "messagedialog.h"
-#include "report.h"
#include "persistentcookiejar.h"
+#include "report.h"
+#include "ui_browserdialog.h"
-#include
#include "settings.h"
+#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
#include
+#include
+#include
#include
+#include
+#include
+#include
+#include
+#include
+BrowserDialog::BrowserDialog(QWidget* parent)
+ : QDialog(parent), ui(new Ui::BrowserDialog), m_AccessManager(new QNetworkAccessManager(this)) {
+ ui->setupUi(this);
+ m_AccessManager->setCookieJar(
+ new PersistentCookieJar(QDir::fromNativeSeparators(Settings::instance().getCacheDirectory() + "/cookies.dat")));
-BrowserDialog::BrowserDialog(QWidget *parent)
- : QDialog(parent)
- , ui(new Ui::BrowserDialog)
- , m_AccessManager(new QNetworkAccessManager(this))
-{
- ui->setupUi(this);
-
- m_AccessManager->setCookieJar(new PersistentCookieJar(
- QDir::fromNativeSeparators(Settings::instance().getCacheDirectory() + "/cookies.dat")));
-
- Qt::WindowFlags flags = windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint;
- Qt::WindowFlags helpFlag = Qt::WindowContextHelpButtonHint;
- flags = flags & (~helpFlag);
- setWindowFlags(flags);
+ Qt::WindowFlags flags = windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint;
+ Qt::WindowFlags helpFlag = Qt::WindowContextHelpButtonHint;
+ flags = flags & (~helpFlag);
+ setWindowFlags(flags);
- m_Tabs = this->findChild("browserTabWidget");
+ m_Tabs = this->findChild("browserTabWidget");
- installEventFilter(this);
+ installEventFilter(this);
- connect(m_Tabs, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested(int)));
+ connect(m_Tabs, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested(int)));
- ui->urlEdit->setVisible(false);
+ ui->urlEdit->setVisible(false);
}
-BrowserDialog::~BrowserDialog()
-{
- delete ui;
-}
+BrowserDialog::~BrowserDialog() { delete ui; }
-void BrowserDialog::closeEvent(QCloseEvent *event)
-{
-// m_AccessManager->showCookies();
- QDialog::closeEvent(event);
+void BrowserDialog::closeEvent(QCloseEvent* event) {
+ // m_AccessManager->showCookies();
+ QDialog::closeEvent(event);
}
-void BrowserDialog::initTab(BrowserView *newView)
-{
- //newView->page()->setNetworkAccessManager(m_AccessManager);
- //newView->page()->setForwardUnsupportedContent(true);
-
- connect(newView, SIGNAL(loadProgress(int)), this, SLOT(progress(int)));
- connect(newView, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged(QString)));
- connect(newView, SIGNAL(initTab(BrowserView*)), this, SLOT(initTab(BrowserView*)));
- connect(newView, SIGNAL(startFind()), this, SLOT(startSearch()));
- connect(newView, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl)));
- connect(newView, SIGNAL(openUrlInNewTab(QUrl)), this, SLOT(openInNewTab(QUrl)));
- connect(newView, SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadRequested(QNetworkRequest)));
- connect(newView, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(unsupportedContent(QNetworkReply*)));
-
- ui->backBtn->setEnabled(false);
- ui->fwdBtn->setEnabled(false);
- m_Tabs->addTab(newView, tr("new"));
- newView->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
- newView->settings()->setAttribute(QWebEngineSettings::AutoLoadImages, true);
-}
+void BrowserDialog::initTab(BrowserView* newView) {
+ // newView->page()->setNetworkAccessManager(m_AccessManager);
+ // newView->page()->setForwardUnsupportedContent(true);
+ connect(newView, SIGNAL(loadProgress(int)), this, SLOT(progress(int)));
+ connect(newView, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged(QString)));
+ connect(newView, SIGNAL(initTab(BrowserView*)), this, SLOT(initTab(BrowserView*)));
+ connect(newView, SIGNAL(startFind()), this, SLOT(startSearch()));
+ connect(newView, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl)));
+ connect(newView, SIGNAL(openUrlInNewTab(QUrl)), this, SLOT(openInNewTab(QUrl)));
+ connect(newView, SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadRequested(QNetworkRequest)));
+ connect(newView, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(unsupportedContent(QNetworkReply*)));
-void BrowserDialog::openInNewTab(const QUrl &url)
-{
- BrowserView *newView = new BrowserView(this);
- initTab(newView);
- newView->setUrl(url);
+ ui->backBtn->setEnabled(false);
+ ui->fwdBtn->setEnabled(false);
+ m_Tabs->addTab(newView, tr("new"));
+ newView->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
+ newView->settings()->setAttribute(QWebEngineSettings::AutoLoadImages, true);
}
-
-BrowserView *BrowserDialog::getCurrentView()
-{
- return qobject_cast(m_Tabs->currentWidget());
+void BrowserDialog::openInNewTab(const QUrl& url) {
+ BrowserView* newView = new BrowserView(this);
+ initTab(newView);
+ newView->setUrl(url);
}
+BrowserView* BrowserDialog::getCurrentView() { return qobject_cast(m_Tabs->currentWidget()); }
-void BrowserDialog::urlChanged(const QUrl &url)
-{
- BrowserView *currentView = getCurrentView();
- if (currentView != nullptr) {
- ui->backBtn->setEnabled(currentView->history()->canGoBack());
- ui->fwdBtn->setEnabled(currentView->history()->canGoForward());
- }
- ui->urlEdit->setText(url.toString());
+void BrowserDialog::urlChanged(const QUrl& url) {
+ BrowserView* currentView = getCurrentView();
+ if (currentView != nullptr) {
+ ui->backBtn->setEnabled(currentView->history()->canGoBack());
+ ui->fwdBtn->setEnabled(currentView->history()->canGoForward());
+ }
+ ui->urlEdit->setText(url.toString());
}
-
-void BrowserDialog::openUrl(const QUrl &url)
-{
- if (isHidden()) {
- show();
- }
- openInNewTab(url);
+void BrowserDialog::openUrl(const QUrl& url) {
+ if (isHidden()) {
+ show();
+ }
+ openInNewTab(url);
}
+void BrowserDialog::maximizeWidth() {
+ int viewportWidth = getCurrentView()->page()->contentsSize().width();
+ int frameWidth = width() - viewportWidth;
-void BrowserDialog::maximizeWidth()
-{
- int viewportWidth = getCurrentView()->page()->contentsSize ().width();
- int frameWidth = width() - viewportWidth;
-
- int contentWidth = getCurrentView()->page()->contentsSize().width();
-
- QDesktopWidget screen;
- int currentScreen = screen.screenNumber(this);
- int screenWidth = screen.screenGeometry(currentScreen).size().width();
-
- int targetWidth = std::min(std::max(viewportWidth, contentWidth) + frameWidth, screenWidth);
- this->resize(targetWidth, height());
-}
+ int contentWidth = getCurrentView()->page()->contentsSize().width();
+ QDesktopWidget screen;
+ int currentScreen = screen.screenNumber(this);
+ int screenWidth = screen.screenGeometry(currentScreen).size().width();
-void BrowserDialog::progress(int value)
-{
- ui->loadProgress->setValue(value);
- if (value == 100) {
- maximizeWidth();
- ui->loadProgress->setVisible(false);
- } else {
- ui->loadProgress->setVisible(true);
- }
+ int targetWidth = std::min(std::max(viewportWidth, contentWidth) + frameWidth, screenWidth);
+ this->resize(targetWidth, height());
}
-
-void BrowserDialog::titleChanged(const QString &title)
-{
- BrowserView *view = qobject_cast(sender());
- for (int i = 0; i < m_Tabs->count(); ++i) {
- if (m_Tabs->widget(i) == view) {
- m_Tabs->setTabText(i, title.mid(0, 15));
- m_Tabs->setTabToolTip(i, title);
+void BrowserDialog::progress(int value) {
+ ui->loadProgress->setValue(value);
+ if (value == 100) {
+ maximizeWidth();
+ ui->loadProgress->setVisible(false);
+ } else {
+ ui->loadProgress->setVisible(true);
}
- }
}
-
-QString BrowserDialog::guessFileName(const QString &url)
-{
- QRegExp uploadsExp(QString("http://.+/uploads/([^/]+)$"));
- if (uploadsExp.indexIn(url) != -1) {
- // these seem to be premium downloads
- return uploadsExp.cap(1);
- }
-
- QRegExp filesExp(QString("http://.+\\?file=([^&]+)"));
- if (filesExp.indexIn(url) != -1) {
- // a regular manual download?
- return filesExp.cap(1);
- }
- return "unknown";
+void BrowserDialog::titleChanged(const QString& title) {
+ BrowserView* view = qobject_cast(sender());
+ for (int i = 0; i < m_Tabs->count(); ++i) {
+ if (m_Tabs->widget(i) == view) {
+ m_Tabs->setTabText(i, title.mid(0, 15));
+ m_Tabs->setTabToolTip(i, title);
+ }
+ }
}
-void BrowserDialog::unsupportedContent(QNetworkReply *reply)
-{
- try {
- QWebEnginePage *page = qobject_cast(sender());
- if (page == nullptr) {
- qCritical("sender not a page");
- return;
- }
- BrowserView *view = qobject_cast(page->view());
- if (view == nullptr) {
- qCritical("no view?");
- return;
+QString BrowserDialog::guessFileName(const QString& url) {
+ QRegExp uploadsExp(QString("http://.+/uploads/([^/]+)$"));
+ if (uploadsExp.indexIn(url) != -1) {
+ // these seem to be premium downloads
+ return uploadsExp.cap(1);
}
- emit requestDownload(view->url(), reply);
- } catch (const std::exception &e) {
- if (isVisible()) {
- MessageDialog::showMessage(tr("failed to start download"), this);
+ QRegExp filesExp(QString("http://.+\\?file=([^&]+)"));
+ if (filesExp.indexIn(url) != -1) {
+ // a regular manual download?
+ return filesExp.cap(1);
+ }
+ return "unknown";
+}
+
+void BrowserDialog::unsupportedContent(QNetworkReply* reply) {
+ try {
+ QWebEnginePage* page = qobject_cast(sender());
+ if (page == nullptr) {
+ qCritical("sender not a page");
+ return;
+ }
+ BrowserView* view = qobject_cast(page->view());
+ if (view == nullptr) {
+ qCritical("no view?");
+ return;
+ }
+
+ emit requestDownload(view->url(), reply);
+ } catch (const std::exception& e) {
+ if (isVisible()) {
+ MessageDialog::showMessage(tr("failed to start download"), this);
+ }
+ qCritical("exception downloading unsupported content: %s", e.what());
}
- qCritical("exception downloading unsupported content: %s", e.what());
- }
-}
-
-
-void BrowserDialog::downloadRequested(const QNetworkRequest &request)
-{
- qCritical("download request %s ignored", request.url().toString().toUtf8().constData());
}
-
-void BrowserDialog::tabCloseRequested(int index)
-{
- if (m_Tabs->count() == 1) {
- this->close();
- } else {
- m_Tabs->widget(index)->deleteLater();
- m_Tabs->removeTab(index);
- }
+void BrowserDialog::downloadRequested(const QNetworkRequest& request) {
+ qCritical("download request %s ignored", request.url().toString().toUtf8().constData());
}
-void BrowserDialog::on_backBtn_clicked()
-{
- BrowserView *currentView = getCurrentView();
- if (currentView != nullptr) {
- currentView->back();
- }
+void BrowserDialog::tabCloseRequested(int index) {
+ if (m_Tabs->count() == 1) {
+ this->close();
+ } else {
+ m_Tabs->widget(index)->deleteLater();
+ m_Tabs->removeTab(index);
+ }
}
-void BrowserDialog::on_fwdBtn_clicked()
-{
- BrowserView *currentView = getCurrentView();
- if (currentView != nullptr) {
- currentView->forward();
- }
+void BrowserDialog::on_backBtn_clicked() {
+ BrowserView* currentView = getCurrentView();
+ if (currentView != nullptr) {
+ currentView->back();
+ }
}
-
-void BrowserDialog::startSearch()
-{
- ui->searchEdit->setFocus();
+void BrowserDialog::on_fwdBtn_clicked() {
+ BrowserView* currentView = getCurrentView();
+ if (currentView != nullptr) {
+ currentView->forward();
+ }
}
+void BrowserDialog::startSearch() { ui->searchEdit->setFocus(); }
-void BrowserDialog::on_searchEdit_returnPressed()
-{
-// BrowserView *currentView = getCurrentView();
-// if (currentView != nullptr) {
-// currentView->findText(ui->searchEdit->text(), QWebEnginePage::FindWrapsAroundDocument);
-// }
+void BrowserDialog::on_searchEdit_returnPressed() {
+ // BrowserView *currentView = getCurrentView();
+ // if (currentView != nullptr) {
+ // currentView->findText(ui->searchEdit->text(), QWebEnginePage::FindWrapsAroundDocument);
+ // }
}
-void BrowserDialog::on_refreshBtn_clicked()
-{
- getCurrentView()->reload();
-}
+void BrowserDialog::on_refreshBtn_clicked() { getCurrentView()->reload(); }
-void BrowserDialog::on_browserTabWidget_currentChanged(int index)
-{
- BrowserView *currentView = qobject_cast(ui->browserTabWidget->widget(index));
- if (currentView != nullptr) {
- ui->backBtn->setEnabled(currentView->history()->canGoBack());
- ui->fwdBtn->setEnabled(currentView->history()->canGoForward());
- }
+void BrowserDialog::on_browserTabWidget_currentChanged(int index) {
+ BrowserView* currentView = qobject_cast(ui->browserTabWidget->widget(index));
+ if (currentView != nullptr) {
+ ui->backBtn->setEnabled(currentView->history()->canGoBack());
+ ui->fwdBtn->setEnabled(currentView->history()->canGoForward());
+ }
}
-void BrowserDialog::on_urlEdit_returnPressed()
-{
- QWebEngineView *currentView = getCurrentView();
- if (currentView != nullptr) {
- currentView->setUrl(QUrl(ui->urlEdit->text()));
- }
+void BrowserDialog::on_urlEdit_returnPressed() {
+ QWebEngineView* currentView = getCurrentView();
+ if (currentView != nullptr) {
+ currentView->setUrl(QUrl(ui->urlEdit->text()));
+ }
}
-bool BrowserDialog::eventFilter(QObject *object, QEvent *event)
-{
- if (event->type() == QEvent::KeyPress) {
- QKeyEvent *keyEvent = reinterpret_cast(event);
- if ((keyEvent->modifiers() & Qt::ControlModifier)
- && (keyEvent->key() == Qt::Key_U)) {
- ui->urlEdit->setVisible(!ui->urlEdit->isVisible());
- return true;
+bool BrowserDialog::eventFilter(QObject* object, QEvent* event) {
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent* keyEvent = reinterpret_cast(event);
+ if ((keyEvent->modifiers() & Qt::ControlModifier) && (keyEvent->key() == Qt::Key_U)) {
+ ui->urlEdit->setVisible(!ui->urlEdit->isVisible());
+ return true;
+ }
}
- }
- return QDialog::eventFilter(object, event);
+ return QDialog::eventFilter(object, event);
}
diff --git a/src/browserdialog.h b/src/browserdialog.h
index 354a377b..6947cc43 100644
--- a/src/browserdialog.h
+++ b/src/browserdialog.h
@@ -20,18 +20,17 @@ along with Mod Organizer. If not, see .
#ifndef BROWSERDIALOG_H
#define BROWSERDIALOG_H
+#include
#include
-#include
#include
-#include
-#include
+#include
#include
#include
-#include
-
+#include
+#include
namespace Ui {
- class BrowserDialog;
+class BrowserDialog;
}
class BrowserView;
@@ -39,88 +38,81 @@ class BrowserView;
/**
* @brief a dialog containing a webbrowser that is intended to browse the nexus network
**/
-class BrowserDialog : public QDialog
-{
+class BrowserDialog : public QDialog {
Q_OBJECT
public:
-
- /**
- * @brief constructor
- *
- * @param accessManager the access manager to use for network requests
- * @param parent parent widget
- **/
- explicit BrowserDialog(QWidget *parent = 0);
- ~BrowserDialog();
-
- /**
- * @brief set the url to open. If automatic login is enabled, the url is opened after login
- *
- * @param url the url to open
- **/
- void openUrl(const QUrl &url);
-
- virtual bool eventFilter(QObject *object, QEvent *event);
+ /**
+ * @brief constructor
+ *
+ * @param accessManager the access manager to use for network requests
+ * @param parent parent widget
+ **/
+ explicit BrowserDialog(QWidget* parent = 0);
+ ~BrowserDialog();
+
+ /**
+ * @brief set the url to open. If automatic login is enabled, the url is opened after login
+ *
+ * @param url the url to open
+ **/
+ void openUrl(const QUrl& url);
+
+ virtual bool eventFilter(QObject* object, QEvent* event);
signals:
- /**
- * @brief emitted when the user starts a download
- * @param pageUrl url of the current web site from which the download was started
- * @param reply network reply of the started download
- */
- void requestDownload(const QUrl &pageUrl, QNetworkReply *reply);
+ /**
+ * @brief emitted when the user starts a download
+ * @param pageUrl url of the current web site from which the download was started
+ * @param reply network reply of the started download
+ */
+ void requestDownload(const QUrl& pageUrl, QNetworkReply* reply);
protected:
-
- virtual void closeEvent(QCloseEvent *);
+ virtual void closeEvent(QCloseEvent*);
private slots:
- void initTab(BrowserView *newView);
- void openInNewTab(const QUrl &url);
+ void initTab(BrowserView* newView);
+ void openInNewTab(const QUrl& url);
- void progress(int value);
+ void progress(int value);
- void titleChanged(const QString &title);
- void unsupportedContent(QNetworkReply *reply);
- void downloadRequested(const QNetworkRequest &request);
+ void titleChanged(const QString& title);
+ void unsupportedContent(QNetworkReply* reply);
+ void downloadRequested(const QNetworkRequest& request);
- void tabCloseRequested(int index);
+ void tabCloseRequested(int index);
- void urlChanged(const QUrl &url);
+ void urlChanged(const QUrl& url);
- void on_backBtn_clicked();
+ void on_backBtn_clicked();
- void on_fwdBtn_clicked();
+ void on_fwdBtn_clicked();
- void on_searchEdit_returnPressed();
+ void on_searchEdit_returnPressed();
- void startSearch();
+ void startSearch();
- void on_refreshBtn_clicked();
+ void on_refreshBtn_clicked();
- void on_browserTabWidget_currentChanged(int index);
+ void on_browserTabWidget_currentChanged(int index);
- void on_urlEdit_returnPressed();
+ void on_urlEdit_returnPressed();
private:
+ QString guessFileName(const QString& url);
- QString guessFileName(const QString &url);
-
- BrowserView *getCurrentView();
+ BrowserView* getCurrentView();
- void maximizeWidth();
+ void maximizeWidth();
private:
+ Ui::BrowserDialog* ui;
- Ui::BrowserDialog *ui;
-
- QNetworkAccessManager *m_AccessManager;
-
- QTabWidget *m_Tabs;
-
+ QNetworkAccessManager* m_AccessManager;
+ QTabWidget* m_Tabs;
};
#endif // BROWSERDIALOG_H
diff --git a/src/browserview.cpp b/src/browserview.cpp
index 0b871e23..a44792b2 100644
--- a/src/browserview.cpp
+++ b/src/browserview.cpp
@@ -19,58 +19,53 @@ along with Mod Organizer. If not, see .
#include "browserview.h"
+#include "utility.h"
#include
#include
+#include
#include
#include
#include
-#include
#include
-#include "utility.h"
-
-BrowserView::BrowserView(QWidget *parent)
- : QWebEngineView(parent)
-{
- installEventFilter(this);
+BrowserView::BrowserView(QWidget* parent) : QWebEngineView(parent) {
+ installEventFilter(this);
- //page()->settings()->setMaximumPagesInCache(10);
+ // page()->settings()->setMaximumPagesInCache(10);
}
-QWebEngineView *BrowserView::createWindow(QWebEnginePage::WebWindowType)
-{
- BrowserView *newView = new BrowserView(parentWidget());
- emit initTab(newView);
- return newView;
+QWebEngineView* BrowserView::createWindow(QWebEnginePage::WebWindowType) {
+ BrowserView* newView = new BrowserView(parentWidget());
+ emit initTab(newView);
+ return newView;
}
-bool BrowserView::eventFilter(QObject *obj, QEvent *event)
-{
- if (event->type() == QEvent::ShortcutOverride) {
- QKeyEvent *keyEvent = static_cast(event);
- if (keyEvent->matches(QKeySequence::Find)) {
- emit startFind();
- } else if (keyEvent->matches(QKeySequence::FindNext)) {
- emit findAgain();
- }
- } else if (event->type() == QEvent::MouseButtonPress) {
- QMouseEvent *mouseEvent = static_cast(event);
- if (mouseEvent->button() == Qt::MidButton) {
- mouseEvent->ignore();
- return true;
+bool BrowserView::eventFilter(QObject* obj, QEvent* event) {
+ if (event->type() == QEvent::ShortcutOverride) {
+ QKeyEvent* keyEvent = static_cast(event);
+ if (keyEvent->matches(QKeySequence::Find)) {
+ emit startFind();
+ } else if (keyEvent->matches(QKeySequence::FindNext)) {
+ emit findAgain();
+ }
+ } else if (event->type() == QEvent::MouseButtonPress) {
+ QMouseEvent* mouseEvent = static_cast(event);
+ if (mouseEvent->button() == Qt::MidButton) {
+ mouseEvent->ignore();
+ return true;
+ }
+ // TODO This is due to that QTWebEnginePage doesn't support QWebFrame anymore
+ // } else if (event->type() == QEvent::MouseButtonRelease) {
+ // QMouseEvent *mouseEvent = static_cast(event);
+ // if (mouseEvent->button() == Qt::MidButton) {
+ // QWebEngineContextMenuData hitTest = page()->hitTestContent(mouseEvent->pos());
+ // if (hitTest.linkUrl().isValid()) {
+ // emit openUrlInNewTab(hitTest.linkUrl());
+ // }
+ // mouseEvent->ignore();
+ //
+ // return true;
+ // }
}
-// TODO This is due to that QTWebEnginePage doesn't support QWebFrame anymore
-// } else if (event->type() == QEvent::MouseButtonRelease) {
-// QMouseEvent *mouseEvent = static_cast(event);
-// if (mouseEvent->button() == Qt::MidButton) {
-// QWebEngineContextMenuData hitTest = page()->hitTestContent(mouseEvent->pos());
-// if (hitTest.linkUrl().isValid()) {
-// emit openUrlInNewTab(hitTest.linkUrl());
-// }
-// mouseEvent->ignore();
-//
-// return true;
-// }
- }
- return QWebEngineView::eventFilter(obj, event);
+ return QWebEngineView::eventFilter(obj, event);
}
diff --git a/src/browserview.h b/src/browserview.h
index 24be21c1..b390ed4e 100644
--- a/src/browserview.h
+++ b/src/browserview.h
@@ -20,62 +20,55 @@ along with Mod Organizer. If not, see .
#ifndef NEXUSVIEW_H
#define NEXUSVIEW_H
-
class QEvent;
class QUrl;
class QWidget;
-#include
#include
+#include
/**
* @brief web view used to display a nexus page
**/
-class BrowserView : public QWebEngineView
-{
+class BrowserView : public QWebEngineView {
Q_OBJECT
public:
-
- explicit BrowserView(QWidget *parent = 0);
+ explicit BrowserView(QWidget* parent = 0);
signals:
- /**
- * @brief emitted when the user opens a new window to be displayed in another tab
- *
- * @param newView the view for the newly opened window
- **/
- void initTab(BrowserView *newView);
-
- /**
- * @brief emitted when the user requests a link to be opened in a new tab by middle-clicking
- *
- * @param url the url to open
- */
- void openUrlInNewTab(const QUrl &url);
-
- /**
- * @brief Ctrl-f was clicked. The containing dialog should activate its find-facility
- */
- void startFind();
-
- /**
- * @brief F3 was pressed. The containing dialog should search again
- */
- void findAgain();
+ /**
+ * @brief emitted when the user opens a new window to be displayed in another tab
+ *
+ * @param newView the view for the newly opened window
+ **/
+ void initTab(BrowserView* newView);
+
+ /**
+ * @brief emitted when the user requests a link to be opened in a new tab by middle-clicking
+ *
+ * @param url the url to open
+ */
+ void openUrlInNewTab(const QUrl& url);
+
+ /**
+ * @brief Ctrl-f was clicked. The containing dialog should activate its find-facility
+ */
+ void startFind();
+
+ /**
+ * @brief F3 was pressed. The containing dialog should search again
+ */
+ void findAgain();
protected:
+ virtual QWebEngineView* createWindow(QWebEnginePage::WebWindowType type);
- virtual QWebEngineView *createWindow(QWebEnginePage::WebWindowType type);
-
- virtual bool eventFilter(QObject *obj, QEvent *event);
-
+ virtual bool eventFilter(QObject* obj, QEvent* event);
private:
-
- QString m_FindPattern;
- bool m_MiddleClick;
-
+ QString m_FindPattern;
+ bool m_MiddleClick;
};
#endif // NEXUSVIEW_H
diff --git a/src/categories.cpp b/src/categories.cpp
index d8cd49fb..c88227e6 100644
--- a/src/categories.cpp
+++ b/src/categories.cpp
@@ -19,350 +19,302 @@ along with Mod Organizer. If not, see .
#include "categories.h"
-#include
#include
+#include
-#include
-#include
+#include
#include
+#include
#include
-#include
-
+#include
using namespace MOBase;
-
CategoryFactory* CategoryFactory::s_Instance = nullptr;
+QString CategoryFactory::categoriesFilePath() { return qApp->property("dataPath").toString() + "/categories.dat"; }
-QString CategoryFactory::categoriesFilePath()
-{
- return qApp->property("dataPath").toString() + "/categories.dat";
-}
+CategoryFactory::CategoryFactory() { atexit(&cleanup); }
+void CategoryFactory::loadCategories() {
+ reset();
-CategoryFactory::CategoryFactory()
-{
- atexit(&cleanup);
-}
+ QFile categoryFile(categoriesFilePath());
-void CategoryFactory::loadCategories()
-{
- reset();
-
- QFile categoryFile(categoriesFilePath());
-
- if (!categoryFile.open(QIODevice::ReadOnly)) {
- loadDefaultCategories();
- } else {
- int lineNum = 0;
- while (!categoryFile.atEnd()) {
- QByteArray line = categoryFile.readLine();
- ++lineNum;
- QList cells = line.split('|');
- if (cells.count() != 4) {
- qCritical("invalid category line %d: %s (%d cells)",
- lineNum, line.constData(), cells.count());
- } else {
- std::vector nexusIDs;
- if (cells[2].length() > 0) {
- QList nexusIDStrings = cells[2].split(',');
- for (QList::iterator iter = nexusIDStrings.begin();
- iter != nexusIDStrings.end(); ++iter) {
- bool ok = false;
- int temp = iter->toInt(&ok);
- if (!ok) {
- qCritical("invalid id %s", iter->constData());
+ if (!categoryFile.open(QIODevice::ReadOnly)) {
+ loadDefaultCategories();
+ } else {
+ int lineNum = 0;
+ while (!categoryFile.atEnd()) {
+ QByteArray line = categoryFile.readLine();
+ ++lineNum;
+ QList cells = line.split('|');
+ if (cells.count() != 4) {
+ qCritical("invalid category line %d: %s (%d cells)", lineNum, line.constData(), cells.count());
+ } else {
+ std::vector nexusIDs;
+ if (cells[2].length() > 0) {
+ QList nexusIDStrings = cells[2].split(',');
+ for (QList::iterator iter = nexusIDStrings.begin(); iter != nexusIDStrings.end();
+ ++iter) {
+ bool ok = false;
+ int temp = iter->toInt(&ok);
+ if (!ok) {
+ qCritical("invalid id %s", iter->constData());
+ }
+ nexusIDs.push_back(temp);
+ }
+ }
+ bool cell0Ok = true;
+ bool cell3Ok = true;
+ int id = cells[0].toInt(&cell0Ok);
+ int parentID = cells[3].trimmed().toInt(&cell3Ok);
+ if (!cell0Ok || !cell3Ok) {
+ qCritical("invalid category line %d: %s", lineNum, line.constData());
+ }
+ addCategory(id, QString::fromUtf8(cells[1].constData()), nexusIDs, parentID);
}
- nexusIDs.push_back(temp);
- }
- }
- bool cell0Ok = true;
- bool cell3Ok = true;
- int id = cells[0].toInt(&cell0Ok);
- int parentID = cells[3].trimmed().toInt(&cell3Ok);
- if (!cell0Ok || !cell3Ok) {
- qCritical("invalid category line %d: %s",
- lineNum, line.constData());
}
- addCategory(id, QString::fromUtf8(cells[1].constData()), nexusIDs, parentID);
- }
+ categoryFile.close();
}
- categoryFile.close();
- }
- std::sort(m_Categories.begin(), m_Categories.end());
- setParents();
+ std::sort(m_Categories.begin(), m_Categories.end());
+ setParents();
}
-
-CategoryFactory &CategoryFactory::instance()
-{
- if (s_Instance == nullptr) {
- s_Instance = new CategoryFactory;
- }
- return *s_Instance;
+CategoryFactory& CategoryFactory::instance() {
+ if (s_Instance == nullptr) {
+ s_Instance = new CategoryFactory;
+ }
+ return *s_Instance;
}
-
-void CategoryFactory::reset()
-{
- m_Categories.clear();
- m_IDMap.clear();
- // 28 =
- // 43 = Savegames (makes no sense to install them through MO)
- // 45 = Videos and trailers
- // 87 = Miscelanous
- addCategory(0, "None", MakeVector(4, 28, 43, 45, 87), 0);
+void CategoryFactory::reset() {
+ m_Categories.clear();
+ m_IDMap.clear();
+ // 28 =
+ // 43 = Savegames (makes no sense to install them through MO)
+ // 45 = Videos and trailers
+ // 87 = Miscelanous
+ addCategory(0, "None", MakeVector(4, 28, 43, 45, 87), 0);
}
+void CategoryFactory::setParents() {
+ for (std::vector::iterator iter = m_Categories.begin(); iter != m_Categories.end(); ++iter) {
+ iter->m_HasChildren = false;
+ }
-void CategoryFactory::setParents()
-{
- for (std::vector::iterator iter = m_Categories.begin();
- iter != m_Categories.end(); ++iter) {
- iter->m_HasChildren = false;
- }
-
- for (std::vector::const_iterator categoryIter = m_Categories.begin();
- categoryIter != m_Categories.end(); ++categoryIter) {
- if (categoryIter->m_ParentID != 0) {
- std::map::const_iterator iter = m_IDMap.find(categoryIter->m_ParentID);
- if (iter != m_IDMap.end()) {
- m_Categories[iter->second].m_HasChildren = true;
- }
+ for (std::vector::const_iterator categoryIter = m_Categories.begin(); categoryIter != m_Categories.end();
+ ++categoryIter) {
+ if (categoryIter->m_ParentID != 0) {
+ std::map::const_iterator iter = m_IDMap.find(categoryIter->m_ParentID);
+ if (iter != m_IDMap.end()) {
+ m_Categories[iter->second].m_HasChildren = true;
+ }
+ }
}
- }
}
-void CategoryFactory::cleanup()
-{
- delete s_Instance;
- s_Instance = nullptr;
+void CategoryFactory::cleanup() {
+ delete s_Instance;
+ s_Instance = nullptr;
}
+void CategoryFactory::saveCategories() {
+ QFile categoryFile(categoriesFilePath());
-void CategoryFactory::saveCategories()
-{
- QFile categoryFile(categoriesFilePath());
-
- if (!categoryFile.open(QIODevice::WriteOnly)) {
- reportError(QObject::tr("Failed to save custom categories"));
- return;
- }
+ if (!categoryFile.open(QIODevice::WriteOnly)) {
+ reportError(QObject::tr("Failed to save custom categories"));
+ return;
+ }
- categoryFile.resize(0);
- for (std::vector::const_iterator iter = m_Categories.begin();
- iter != m_Categories.end(); ++iter) {
- if (iter->m_ID == 0) {
- continue;
+ categoryFile.resize(0);
+ for (std::vector::const_iterator iter = m_Categories.begin(); iter != m_Categories.end(); ++iter) {
+ if (iter->m_ID == 0) {
+ continue;
+ }
+ QByteArray line;
+ line.append(QByteArray::number(iter->m_ID))
+ .append("|")
+ .append(iter->m_Name.toUtf8())
+ .append("|")
+ .append(VectorJoin(iter->m_NexusIDs, ","))
+ .append("|")
+ .append(QByteArray::number(iter->m_ParentID))
+ .append("\n");
+ categoryFile.write(line);
}
- QByteArray line;
- line.append(QByteArray::number(iter->m_ID)).append("|")
- .append(iter->m_Name.toUtf8()).append("|")
- .append(VectorJoin(iter->m_NexusIDs, ",")).append("|")
- .append(QByteArray::number(iter->m_ParentID)).append("\n");
- categoryFile.write(line);
- }
- categoryFile.close();
+ categoryFile.close();
}
-
-unsigned int CategoryFactory::countCategories(std::tr1::function filter)
-{
- unsigned int result = 0;
- for (const Category &cat : m_Categories) {
- if (filter(cat)) {
- ++result;
+unsigned int CategoryFactory::countCategories(std::tr1::function filter) {
+ unsigned int result = 0;
+ for (const Category& cat : m_Categories) {
+ if (filter(cat)) {
+ ++result;
+ }
}
- }
- return result;
+ return result;
}
-int CategoryFactory::addCategory(const QString &name, const std::vector &nexusIDs, int parentID)
-{
- int id = 1;
- while (m_IDMap.find(id) != m_IDMap.end()) {
- ++id;
- }
- addCategory(id, name, nexusIDs, parentID);
-
- saveCategories();
- return id;
-}
+int CategoryFactory::addCategory(const QString& name, const std::vector& nexusIDs, int parentID) {
+ int id = 1;
+ while (m_IDMap.find(id) != m_IDMap.end()) {
+ ++id;
+ }
+ addCategory(id, name, nexusIDs, parentID);
-void CategoryFactory::addCategory(int id, const QString &name, const std::vector &nexusIDs, int parentID)
-{
- int index = static_cast(m_Categories.size());
- m_Categories.push_back(Category(index, id, name, nexusIDs, parentID));
- for (int nexusID : nexusIDs) {
- m_NexusMap[nexusID] = index;
- }
- m_IDMap[id] = index;
+ saveCategories();
+ return id;
}
-
-void CategoryFactory::loadDefaultCategories()
-{
- // the order here is relevant as it defines the order in which the
- // mods appear in the combo box
- addCategory(1, "Animations", MakeVector(2, 4, 51), 0);
- addCategory(52, "Poses", MakeVector(1, 29), 1);
- addCategory(2, "Armour", MakeVector(2, 5, 54), 0);
- addCategory(53, "Power Armor", MakeVector(1, 53), 2);
- addCategory(3, "Audio", MakeVector(3, 33, 35, 106), 0);
- addCategory(38, "Music", MakeVector(2, 34, 61), 0);
- addCategory(39, "Voice", MakeVector(2, 36, 107), 0);
- addCategory(5, "Clothing", MakeVector(2, 9, 60), 0);
- addCategory(41, "Jewelry", MakeVector(1, 102), 5);
- addCategory(42, "Backpacks", MakeVector(1, 49), 5);
- addCategory(6, "Collectables", MakeVector(2, 10, 92), 0);
- addCategory(28, "Companions", MakeVector(3, 11, 66, 96), 0);
- addCategory(7, "Creatures, Mounts, & Vehicles", MakeVector(4, 12, 65, 83, 101), 0);
- addCategory(8, "Factions", MakeVector(2, 16, 25), 0);
- addCategory(9, "Gameplay", MakeVector(2, 15, 24), 0);
- addCategory(27, "Combat", MakeVector(1, 77), 9);
- addCategory(43, "Crafting", MakeVector(2, 50, 100), 9);
- addCategory(48, "Overhauls", MakeVector(2, 24, 79), 9);
- addCategory(49, "Perks", MakeVector(1, 27), 9);
- addCategory(54, "Radio", MakeVector(1, 31), 9);
- addCategory(55, "Shouts", MakeVector(1, 104), 9);
- addCategory(22, "Skills & Levelling", MakeVector(2, 46, 73), 9);
- addCategory(58, "Weather & Lighting", MakeVector(1, 56), 9);
- addCategory(44, "Equipment", MakeVector(1, 44), 43);
- addCategory(45, "Home/Settlement", MakeVector(1, 45), 43);
- addCategory(10, "Body, Face, & Hair", MakeVector(2, 17, 26), 0);
- addCategory(39, "Tattoos", MakeVector(1, 57), 10);
- addCategory(40, "Character Presets", MakeVector(1, 58), 0);
- addCategory(11, "Items", MakeVector(2, 27, 85), 0);
- addCategory(32, "Mercantile", MakeVector(2, 23, 69), 0);
- addCategory(37, "Ammo", MakeVector(1, 3), 11);
- addCategory(19, "Weapons", MakeVector(2, 41, 55), 11);
- addCategory(36, "Weapon & Armour Sets", MakeVector(1, 42), 11);
- addCategory(23, "Player Homes", MakeVector(2, 28, 67), 0);
- addCategory(25, "Castles & Mansions", MakeVector(1, 68), 23);
- addCategory(51, "Settlements", MakeVector(1, 48), 23);
- addCategory(12, "Locations", MakeVector(10, 20, 21, 22, 30, 47, 70, 88, 89, 90, 91), 0);
- addCategory(4, "Cities", MakeVector(1, 53), 12);
- addCategory(31, "Landscape Changes", MakeVector(1, 58), 0);
- addCategory(29, "Environment", MakeVector(2, 14, 74), 0);
- addCategory(30, "Immersion", MakeVector(2, 51, 78), 0);
- addCategory(20, "Magic", MakeVector(3, 75, 93, 94), 0);
- addCategory(21, "Models & Textures", MakeVector(2, 19, 29), 0);
- addCategory(33, "Modders resources", MakeVector(2, 18, 82), 0);
- addCategory(13, "NPCs", MakeVector(3, 22, 33, 99), 0);
- addCategory(24, "Bugfixes", MakeVector(2, 6, 95), 0);
- addCategory(14, "Patches", MakeVector(2, 25, 84), 24);
- addCategory(35, "Utilities", MakeVector(2, 38, 39), 0);
- addCategory(26, "Cheats", MakeVector(1, 8), 0);
- addCategory(15, "Quests", MakeVector(2, 30, 35), 0);
- addCategory(16, "Races & Classes", MakeVector(1, 34), 0);
- addCategory(34, "Stealth", MakeVector(1, 76), 0);
- addCategory(17, "UI", MakeVector(2, 37, 42), 0);
- addCategory(18, "Visuals", MakeVector(2, 40, 62), 0);
- addCategory(50, "Pip-Boy", MakeVector(1, 52), 18);
- addCategory(46, "Shader Presets", MakeVector(3, 13, 97, 105), 0);
- addCategory(47, "Miscellaneous", MakeVector(2, 2, 28), 0);
+void CategoryFactory::addCategory(int id, const QString& name, const std::vector& nexusIDs, int parentID) {
+ int index = static_cast(m_Categories.size());
+ m_Categories.push_back(Category(index, id, name, nexusIDs, parentID));
+ for (int nexusID : nexusIDs) {
+ m_NexusMap[nexusID] = index;
+ }
+ m_IDMap[id] = index;
}
-
-int CategoryFactory::getParentID(unsigned int index) const
-{
- if (index >= m_Categories.size()) {
- throw MyException(QObject::tr("invalid index %1").arg(index));
- }
-
- return m_Categories[index].m_ParentID;
+void CategoryFactory::loadDefaultCategories() {
+ // the order here is relevant as it defines the order in which the
+ // mods appear in the combo box
+ addCategory(1, "Animations", MakeVector(2, 4, 51), 0);
+ addCategory(52, "Poses", MakeVector(1, 29), 1);
+ addCategory(2, "Armour", MakeVector(2, 5, 54), 0);
+ addCategory(53, "Power Armor", MakeVector(1, 53), 2);
+ addCategory(3, "Audio", MakeVector(3, 33, 35, 106), 0);
+ addCategory(38, "Music", MakeVector(2, 34, 61), 0);
+ addCategory(39, "Voice", MakeVector(2, 36, 107), 0);
+ addCategory(5, "Clothing", MakeVector(2, 9, 60), 0);
+ addCategory(41, "Jewelry", MakeVector(1, 102), 5);
+ addCategory(42, "Backpacks", MakeVector(1, 49), 5);
+ addCategory(6, "Collectables", MakeVector(2, 10, 92), 0);
+ addCategory(28, "Companions", MakeVector(3, 11, 66, 96), 0);
+ addCategory(7, "Creatures, Mounts, & Vehicles", MakeVector(4, 12, 65, 83, 101), 0);
+ addCategory(8, "Factions", MakeVector(2, 16, 25), 0);
+ addCategory(9, "Gameplay", MakeVector(2, 15, 24), 0);
+ addCategory(27, "Combat", MakeVector(1, 77), 9);
+ addCategory(43, "Crafting", MakeVector(2, 50, 100), 9);
+ addCategory(48, "Overhauls", MakeVector(2, 24, 79), 9);
+ addCategory(49, "Perks", MakeVector(1, 27), 9);
+ addCategory(54, "Radio", MakeVector(1, 31), 9);
+ addCategory(55, "Shouts", MakeVector(1, 104), 9);
+ addCategory(22, "Skills & Levelling", MakeVector(2, 46, 73), 9);
+ addCategory(58, "Weather & Lighting", MakeVector(1, 56), 9);
+ addCategory(44, "Equipment", MakeVector(1, 44), 43);
+ addCategory(45, "Home/Settlement", MakeVector(1, 45), 43);
+ addCategory(10, "Body, Face, & Hair", MakeVector(2, 17, 26), 0);
+ addCategory(39, "Tattoos", MakeVector(1, 57), 10);
+ addCategory(40, "Character Presets", MakeVector(1, 58), 0);
+ addCategory(11, "Items", MakeVector(2, 27, 85), 0);
+ addCategory(32, "Mercantile", MakeVector(2, 23, 69), 0);
+ addCategory(37, "Ammo", MakeVector(1, 3), 11);
+ addCategory(19, "Weapons", MakeVector(2, 41, 55), 11);
+ addCategory(36, "Weapon & Armour Sets", MakeVector(1, 42), 11);
+ addCategory(23, "Player Homes", MakeVector(2, 28, 67), 0);
+ addCategory(25, "Castles & Mansions", MakeVector(1, 68), 23);
+ addCategory(51, "Settlements", MakeVector(1, 48), 23);
+ addCategory(12, "Locations", MakeVector(10, 20, 21, 22, 30, 47, 70, 88, 89, 90, 91), 0);
+ addCategory(4, "Cities", MakeVector(1, 53), 12);
+ addCategory(31, "Landscape Changes", MakeVector(1, 58), 0);
+ addCategory(29, "Environment", MakeVector(2, 14, 74), 0);
+ addCategory(30, "Immersion", MakeVector(2, 51, 78), 0);
+ addCategory(20, "Magic", MakeVector(3, 75, 93, 94), 0);
+ addCategory(21, "Models & Textures", MakeVector(2, 19, 29), 0);
+ addCategory(33, "Modders resources", MakeVector(2, 18, 82), 0);
+ addCategory(13, "NPCs", MakeVector(3, 22, 33, 99), 0);
+ addCategory(24, "Bugfixes", MakeVector(2, 6, 95), 0);
+ addCategory(14, "Patches", MakeVector(2, 25, 84), 24);
+ addCategory(35, "Utilities", MakeVector(2, 38, 39), 0);
+ addCategory(26, "Cheats", MakeVector(1, 8), 0);
+ addCategory(15, "Quests", MakeVector(2, 30, 35), 0);
+ addCategory(16, "Races & Classes", MakeVector(1, 34), 0);
+ addCategory(34, "Stealth", MakeVector(1, 76), 0);
+ addCategory(17, "UI", MakeVector(2, 37, 42), 0);
+ addCategory(18, "Visuals", MakeVector(2, 40, 62), 0);
+ addCategory(50, "Pip-Boy", MakeVector(1, 52), 18);
+ addCategory(46, "Shader Presets", MakeVector(3, 13, 97, 105), 0);
+ addCategory(47, "Miscellaneous", MakeVector(2, 2, 28), 0);
}
+int CategoryFactory::getParentID(unsigned int index) const {
+ if (index >= m_Categories.size()) {
+ throw MyException(QObject::tr("invalid index %1").arg(index));
+ }
-bool CategoryFactory::categoryExists(int id) const
-{
- return m_IDMap.find(id) != m_IDMap.end();
+ return m_Categories[index].m_ParentID;
}
-
-bool CategoryFactory::isDecendantOf(int id, int parentID) const
-{
- std::map