summaryrefslogtreecommitdiff
path: root/src/profilesdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/profilesdialog.cpp')
-rw-r--r--src/profilesdialog.cpp47
1 files changed, 28 insertions, 19 deletions
diff --git a/src/profilesdialog.cpp b/src/profilesdialog.cpp
index ef9b607b..44ee96e9 100644
--- a/src/profilesdialog.cpp
+++ b/src/profilesdialog.cpp
@@ -24,7 +24,10 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "transfersavesdialog.h"
#include "profileinputdialog.h"
#include "mainwindow.h"
-#include <gameinfo.h>
+#include "aboutdialog.h"
+#include <iplugingame.h>
+#include <bsainvalidation.h>
+#include <appconfig.h>
#include <QListWidgetItem>
#include <QInputDialog>
#include <QLineEdit>
@@ -40,11 +43,14 @@ Q_DECLARE_METATYPE(Profile::Ptr)
ProfilesDialog::ProfilesDialog(const QString &gamePath, QWidget *parent)
- : TutorableDialog("Profiles", parent), ui(new Ui::ProfilesDialog), m_GamePath(gamePath), m_FailState(false)
+ : TutorableDialog("Profiles", parent)
+ , ui(new Ui::ProfilesDialog)
+ , m_GamePath(gamePath)
+ , m_FailState(false)
{
ui->setupUi(this);
- QDir profilesDir(QDir::fromNativeSeparators(ToQString(GameInfo::instance().getProfilesDir())));
+ QDir profilesDir(qApp->property("dataPath").toString() + "/" + QString::fromStdWString(AppConfig::profilesPath()));
profilesDir.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot);
m_ProfilesList = findChild<QListWidget*>("profilesList");
@@ -56,7 +62,11 @@ ProfilesDialog::ProfilesDialog(const QString &gamePath, QWidget *parent)
}
QCheckBox *invalidationBox = findChild<QCheckBox*>("invalidationBox");
- if (!GameInfo::instance().requiresBSAInvalidation()) {
+
+ IPluginGame *game = qApp->property("managed_game").value<IPluginGame*>();
+ BSAInvalidation *invalidation = game->feature<BSAInvalidation>();
+
+ if (invalidation == nullptr) {
invalidationBox->setToolTip(tr("Archive invalidation isn't required for this game."));
invalidationBox->setEnabled(false);
}
@@ -92,20 +102,19 @@ void ProfilesDialog::addItem(const QString &name)
QDir profileDir(name);
QListWidgetItem *newItem = new QListWidgetItem(profileDir.dirName(), m_ProfilesList);
try {
- newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(new Profile(profileDir))));
+ newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(new Profile(profileDir, qApp->property("managed_game").value<IPluginGame*>()))));
m_FailState = false;
} catch (const std::exception& e) {
reportError(tr("failed to create profile: %1").arg(e.what()));
}
}
-
void ProfilesDialog::createProfile(const QString &name, bool useDefaultSettings)
{
try {
QListWidget *profilesList = findChild<QListWidget*>("profilesList");
QListWidgetItem *newItem = new QListWidgetItem(name, profilesList);
- newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(new Profile(name, useDefaultSettings))));
+ newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(new Profile(name, qApp->property("managed_game").value<IPluginGame*>(), useDefaultSettings))));
profilesList->addItem(newItem);
m_FailState = false;
} catch (const std::exception&) {
@@ -114,13 +123,12 @@ void ProfilesDialog::createProfile(const QString &name, bool useDefaultSettings)
}
}
-
void ProfilesDialog::createProfile(const QString &name, const Profile &reference)
{
try {
QListWidget *profilesList = findChild<QListWidget*>("profilesList");
QListWidgetItem *newItem = new QListWidgetItem(name, profilesList);
- newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(Profile::createPtrFrom(name, reference))));
+ newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(Profile::createPtrFrom(name, reference, qApp->property("managed_game").value<IPluginGame*>()))));
profilesList->addItem(newItem);
m_FailState = false;
} catch (const std::exception&) {
@@ -129,7 +137,6 @@ void ProfilesDialog::createProfile(const QString &name, const Profile &reference
}
}
-
void ProfilesDialog::on_addProfileButton_clicked()
{
ProfileInputDialog dialog(this);
@@ -176,8 +183,10 @@ void ProfilesDialog::on_removeProfileButton_clicked()
Profile::Ptr currentProfile = profilesList->currentItem()->data(Qt::UserRole).value<Profile::Ptr>();
QString profilePath;
- if (currentProfile.get() == NULL) {
- profilePath = QDir::fromNativeSeparators(ToQString(GameInfo::instance().getProfilesDir())) + "/" + profilesList->currentItem()->text();
+ if (currentProfile.get() == nullptr) {
+ profilePath = qApp->property("dataPath").toString()
+ + "/" + QString::fromStdWString(AppConfig::profilesPath())
+ + "/" + profilesList->currentItem()->text();
if (QMessageBox::question(this, tr("Profile broken"),
tr("This profile you're about to delete seems to be broken or the path is invalid. "
"I'm about to delete the following folder: \"%1\". Proceed?").arg(profilePath), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
@@ -186,10 +195,10 @@ void ProfilesDialog::on_removeProfileButton_clicked()
} else {
// on destruction, the profile object would write the profile.ini file again, so
// we have to get rid of the it before deleting the directory
- profilePath = currentProfile->getPath();
+ profilePath = currentProfile->absolutePath();
}
QListWidgetItem* item = profilesList->takeItem(profilesList->currentRow());
- if (item != NULL) {
+ if (item != nullptr) {
delete item;
}
if (!shellDelete(QStringList(profilePath))) {
@@ -212,7 +221,7 @@ void ProfilesDialog::on_renameButton_clicked()
while (!valid) {
bool ok = false;
name = QInputDialog::getText(this, tr("Rename Profile"), tr("New Name"),
- QLineEdit::Normal, currentProfile->getName(),
+ QLineEdit::Normal, currentProfile->name(),
&ok);
valid = fixDirectoryName(name);
if (!ok) {
@@ -230,7 +239,7 @@ void ProfilesDialog::on_invalidationBox_stateChanged(int state)
QListWidget *profilesList = findChild<QListWidget*>("profilesList");
QListWidgetItem *currentItem = profilesList->currentItem();
- if (currentItem == NULL) {
+ if (currentItem == nullptr) {
return;
}
if (!ui->invalidationBox->isEnabled()) {
@@ -245,7 +254,7 @@ void ProfilesDialog::on_invalidationBox_stateChanged(int state)
if (state == Qt::Unchecked) {
currentProfile->deactivateInvalidation();
} else {
- currentProfile->activateInvalidation(m_GamePath + "/data");
+ currentProfile->activateInvalidation();
}
} catch (const std::exception &e) {
reportError(tr("failed to change archive invalidation state: %1").arg(e.what()));
@@ -262,7 +271,7 @@ void ProfilesDialog::on_profilesList_currentItemChanged(QListWidgetItem *current
QPushButton *transferButton = findChild<QPushButton*>("transferButton");
QPushButton *renameButton = findChild<QPushButton*>("renameButton");
- if (current != NULL) {
+ if (current != nullptr) {
if (!current->data(Qt::UserRole).isValid()) return;
const Profile::Ptr currentProfile = current->data(Qt::UserRole).value<Profile::Ptr>();
@@ -314,6 +323,6 @@ void ProfilesDialog::on_localSavesBox_stateChanged(int state)
void ProfilesDialog::on_transferButton_clicked()
{
const Profile::Ptr currentProfile = m_ProfilesList->currentItem()->data(Qt::UserRole).value<Profile::Ptr>();
- TransferSavesDialog transferDialog(*currentProfile, this);
+ TransferSavesDialog transferDialog(*currentProfile, qApp->property("managed_game").value<IPluginGame*>(), this);
transferDialog.exec();
}