diff options
| author | Mikaƫl Capelle <capelle.mikael@gmail.com> | 2020-10-26 21:39:13 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-26 21:39:13 +0100 |
| commit | 61308ae2a6ed1123d3043659e72e300dc5c68cca (patch) | |
| tree | 69976cb8870e1bffda3d149627123e1ecf24c654 /src | |
| parent | 0ca5d2843e48169e58978439f9f6bc60c579efce (diff) | |
| parent | d42399e419fa6b769e343b8cf77480b6ac172b0f (diff) | |
Merge branch 'master' into imodlist-updates
Diffstat (limited to 'src')
| -rw-r--r-- | src/mainwindow.cpp | 6 | ||||
| -rw-r--r-- | src/organizercore.cpp | 32 | ||||
| -rw-r--r-- | src/organizercore.h | 13 | ||||
| -rw-r--r-- | src/organizerproxy.cpp | 15 | ||||
| -rw-r--r-- | src/organizerproxy.h | 13 | ||||
| -rw-r--r-- | src/profilesdialog.cpp | 27 | ||||
| -rw-r--r-- | src/profilesdialog.h | 21 |
7 files changed, 112 insertions, 15 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 85aa0df1..65c1d65c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1765,9 +1765,9 @@ void MainWindow::on_profileBox_currentIndexChanged(int index) if (ui->profileBox->currentIndex() == 0) { ui->profileBox->setCurrentIndex(previousIndex); - ProfilesDialog(ui->profileBox->currentText(), m_OrganizerCore.managedGame(), this).exec(); + ProfilesDialog(ui->profileBox->currentText(), m_OrganizerCore, this).exec(); while (!refreshProfiles()) { - ProfilesDialog(ui->profileBox->currentText(), m_OrganizerCore.managedGame(), this).exec(); + ProfilesDialog(ui->profileBox->currentText(), m_OrganizerCore, this).exec(); } } else { activateSelectedProfile(); @@ -2432,7 +2432,7 @@ void MainWindow::on_actionAdd_Profile_triggered() { for (;;) { ProfilesDialog profilesDialog(m_OrganizerCore.currentProfile()->name(), - m_OrganizerCore.managedGame(), + m_OrganizerCore, this); // workaround: need to disable monitoring of the saves directory, otherwise the active diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 82305c1a..b39d3ec0 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -377,6 +377,22 @@ void OrganizerCore::userInterfaceInitialized() m_UserInterfaceInitialized(m_UserInterface->mainWindow()); } +void OrganizerCore::profileCreated(MOBase::IProfile* profile) +{ + m_ProfileCreated(profile); +} + +void OrganizerCore::profileRenamed(MOBase::IProfile* profile, QString const& oldName, QString const& newName) +{ + m_ProfileRenamed(profile, oldName, newName); +} + +void OrganizerCore::profileRemoved(QString const& profileName) +{ + m_ProfileRemoved(profileName); +} + + void OrganizerCore::externalMessage(const QString &message) { if (MOShortcut moshortcut{ message } ) { @@ -469,6 +485,7 @@ void OrganizerCore::createDefaultProfile() if (QDir(profilesPath).entryList(QDir::AllDirs | QDir::NoDotAndDotDot).size() == 0) { Profile newProf("Default", managedGame(), false); + m_ProfileCreated(&newProf); } } @@ -1120,6 +1137,21 @@ bool OrganizerCore::onUserInterfaceInitialized(std::function<void(QMainWindow*)> return m_UserInterfaceInitialized.connect(func).connected(); } +bool OrganizerCore::onProfileCreated(std::function<void(MOBase::IProfile*)> const& func) +{ + return m_ProfileCreated.connect(func).connected(); +} + +bool OrganizerCore::onProfileRenamed(std::function<void(MOBase::IProfile*, QString const&, QString const&)> const& func) +{ + return m_ProfileRenamed.connect(func).connected(); +} + +bool OrganizerCore::onProfileRemoved(std::function<void(QString const&)> const& func) +{ + return m_ProfileRemoved.connect(func).connected(); +} + bool OrganizerCore::onProfileChanged(std::function<void(IProfile*, IProfile*)> const& func) { return m_ProfileChanged.connect(func).connected(); diff --git a/src/organizercore.h b/src/organizercore.h index 61caeed0..70ce94f5 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -81,6 +81,9 @@ private: using SignalAboutToRunApplication = boost::signals2::signal<bool (const QString&), SignalCombinerAnd>;
using SignalFinishedRunApplication = boost::signals2::signal<void (const QString&, unsigned int)>;
using SignalUserInterfaceInitialized = boost::signals2::signal<void (QMainWindow*)>;
+ using SignalProfileCreated = boost::signals2::signal<void(MOBase::IProfile*)>;
+ using SignalProfileRenamed = boost::signals2::signal<void(MOBase::IProfile*, QString const&, QString const&)>;
+ using SignalProfileRemoved = boost::signals2::signal<void(QString const&)>;
using SignalProfileChanged = boost::signals2::signal<void (MOBase::IProfile *, MOBase::IProfile *)>;
using SignalPluginSettingChanged = boost::signals2::signal<void (QString const&, const QString& key, const QVariant&, const QVariant&)>;
@@ -329,6 +332,9 @@ public: bool onAboutToRun(const std::function<bool(const QString&)>& func);
bool onFinishedRun(const std::function<void(const QString&, unsigned int)>& func);
bool onUserInterfaceInitialized(std::function<void(QMainWindow*)> const& func);
+ bool onProfileCreated(std::function<void(MOBase::IProfile*)> const& func);
+ bool onProfileRenamed(std::function<void(MOBase::IProfile*, QString const&, QString const&)> const& func);
+ bool onProfileRemoved(std::function<void(QString const&)> const& func);
bool onProfileChanged(std::function<void(MOBase::IProfile*, MOBase::IProfile*)> const& func);
bool onPluginSettingChanged(std::function<void(QString const&, const QString& key, const QVariant&, const QVariant&)> const& func);
@@ -370,6 +376,10 @@ public slots: void userInterfaceInitialized();
+ void profileCreated(MOBase::IProfile* profile);
+ void profileRenamed(MOBase::IProfile* profile, QString const& oldName, QString const& newName);
+ void profileRemoved(QString const& profileName);
+
bool nexusApi(bool retry = false);
signals:
@@ -444,6 +454,9 @@ private: SignalAboutToRunApplication m_AboutToRun;
SignalFinishedRunApplication m_FinishedRun;
SignalUserInterfaceInitialized m_UserInterfaceInitialized;
+ SignalProfileCreated m_ProfileCreated;
+ SignalProfileRenamed m_ProfileRenamed;
+ SignalProfileRemoved m_ProfileRemoved;
SignalProfileChanged m_ProfileChanged;
SignalPluginSettingChanged m_PluginSettingChanged;
diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index 56e40ae5..45efc00c 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -262,6 +262,21 @@ bool OrganizerProxy::onUserInterfaceInitialized(std::function<void(QMainWindow*) return m_Proxied->onUserInterfaceInitialized(func);
}
+bool OrganizerProxy::onProfileCreated(std::function<void(IProfile*)> const& func)
+{
+ return m_Proxied->onProfileCreated(MOShared::callIfPluginActive(this, func));
+}
+
+bool OrganizerProxy::onProfileRenamed(std::function<void(IProfile*, QString const&, QString const&)> const& func)
+{
+ return m_Proxied->onProfileRenamed(MOShared::callIfPluginActive(this, func));
+}
+
+bool OrganizerProxy::onProfileRemoved(std::function<void(QString const&)> const& func)
+{
+ return m_Proxied->onProfileRemoved(MOShared::callIfPluginActive(this, func));
+}
+
bool OrganizerProxy::onProfileChanged(std::function<void(MOBase::IProfile*, MOBase::IProfile*)> const& func)
{
return m_Proxied->onProfileChanged(MOShared::callIfPluginActive(this, func));
diff --git a/src/organizerproxy.h b/src/organizerproxy.h index 6cf9de77..6690d612 100644 --- a/src/organizerproxy.h +++ b/src/organizerproxy.h @@ -57,11 +57,14 @@ public: virtual bool waitForApplication(HANDLE handle, LPDWORD exitCode = nullptr) const;
virtual void refresh(bool saveChanges);
- virtual bool onAboutToRun(const std::function<bool(const QString&)> &func);
- virtual bool onFinishedRun(const std::function<void (const QString&, unsigned int)> &func);
- virtual bool onUserInterfaceInitialized(std::function<void(QMainWindow*)> const& func);
- virtual bool onProfileChanged(std::function<void(MOBase::IProfile*, MOBase::IProfile*)> const& func);
- virtual bool onPluginSettingChanged(std::function<void(QString const&, const QString& key, const QVariant&, const QVariant&)> const& func);
+ virtual bool onAboutToRun(const std::function<bool(const QString&)> &func) override;
+ virtual bool onFinishedRun(const std::function<void (const QString&, unsigned int)> &func) override;
+ virtual bool onUserInterfaceInitialized(std::function<void(QMainWindow*)> const& func) override;
+ virtual bool onProfileCreated(std::function<void(MOBase::IProfile*)> const& func) override;
+ virtual bool onProfileRenamed(std::function<void(MOBase::IProfile*, QString const&, QString const&)> const& func) override;
+ virtual bool onProfileRemoved(std::function<void(QString const&)> const& func) override;
+ virtual bool onProfileChanged(std::function<void(MOBase::IProfile*, MOBase::IProfile*)> const& func) override;
+ virtual bool onPluginSettingChanged(std::function<void(QString const&, const QString& key, const QVariant&, const QVariant&)> const& func) override;
virtual MOBase::IPluginGame const *managedGame() const;
diff --git a/src/profilesdialog.cpp b/src/profilesdialog.cpp index bf6a1d5e..14bf0da5 100644 --- a/src/profilesdialog.cpp +++ b/src/profilesdialog.cpp @@ -23,6 +23,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include "shared/appconfig.h"
#include "bsainvalidation.h"
#include "iplugingame.h"
+#include "organizercore.h"
#include "profile.h"
#include "profileinputdialog.h"
#include "report.h"
@@ -49,11 +50,11 @@ using namespace MOShared; Q_DECLARE_METATYPE(Profile::Ptr)
-ProfilesDialog::ProfilesDialog(const QString &profileName, MOBase::IPluginGame const *game, QWidget *parent)
+ProfilesDialog::ProfilesDialog(const QString &profileName, OrganizerCore &organizer, QWidget *parent)
: TutorableDialog("Profiles", parent)
, ui(new Ui::ProfilesDialog)
, m_FailState(false)
- , m_Game(game)
+ , m_Game(organizer.managedGame())
, m_ActiveProfileName("")
{
ui->setupUi(this);
@@ -72,17 +73,21 @@ ProfilesDialog::ProfilesDialog(const QString &profileName, MOBase::IPluginGame c }
}
- BSAInvalidation *invalidation = game->feature<BSAInvalidation>();
+ BSAInvalidation *invalidation = m_Game->feature<BSAInvalidation>();
if (invalidation == nullptr) {
ui->invalidationBox->setToolTip(tr("Archive invalidation isn't required for this game."));
ui->invalidationBox->setEnabled(false);
}
- if (!game->feature<LocalSavegames>()) {
+ if (!m_Game->feature<LocalSavegames>()) {
ui->localSavesBox->setToolTip(tr("This game does not support profile-specific game saves."));
ui->localSavesBox->setEnabled(false);
}
+
+ connect(this, &ProfilesDialog::profileCreated, &organizer, &OrganizerCore::profileCreated);
+ connect(this, &ProfilesDialog::profileRenamed, &organizer, &OrganizerCore::profileRenamed);
+ connect(this, &ProfilesDialog::profileRemoved, &organizer, &OrganizerCore::profileRemoved);
}
ProfilesDialog::~ProfilesDialog()
@@ -133,9 +138,11 @@ void ProfilesDialog::createProfile(const QString &name, bool useDefaultSettings) {
try {
QListWidgetItem *newItem = new QListWidgetItem(name, ui->profilesList);
- newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(new Profile(name, m_Game, useDefaultSettings))));
+ auto profile = Profile::Ptr(new Profile(name, m_Game, useDefaultSettings));
+ newItem->setData(Qt::UserRole, QVariant::fromValue(profile));
ui->profilesList->addItem(newItem);
m_FailState = false;
+ emit profileCreated(profile.get());
} catch (const std::exception&) {
m_FailState = true;
throw;
@@ -146,9 +153,11 @@ void ProfilesDialog::createProfile(const QString &name, const Profile &reference {
try {
QListWidgetItem *newItem = new QListWidgetItem(name, ui->profilesList);
- newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(Profile::createPtrFrom(name, reference, m_Game))));
+ auto profile = Profile::Ptr(Profile::createPtrFrom(name, reference, m_Game));
+ newItem->setData(Qt::UserRole, QVariant::fromValue(profile));
ui->profilesList->addItem(newItem);
m_FailState = false;
+ emit profileCreated(profile.get());
} catch (const std::exception&) {
m_FailState = true;
throw;
@@ -231,6 +240,8 @@ void ProfilesDialog::on_removeProfileButton_clicked() log::warn("regular delete failed too");
}
}
+
+ emit profileRemoved(profileToDelete->name());
}
}
@@ -254,7 +265,11 @@ void ProfilesDialog::on_renameButton_clicked() }
ui->profilesList->currentItem()->setText(name);
+
+ QString oldName = currentProfile->name();
currentProfile->rename(name);
+
+ emit profileRenamed(currentProfile.get(), oldName, name);
}
diff --git a/src/profilesdialog.h b/src/profilesdialog.h index a47367be..08298d0e 100644 --- a/src/profilesdialog.h +++ b/src/profilesdialog.h @@ -22,6 +22,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include "tutorabledialog.h"
class Profile;
+class OrganizerCore;
class QListWidget;
class QListWidgetItem;
@@ -46,9 +47,10 @@ public: * @brief constructor
*
* @param profileName currently enabled profile
+ * @param organizer
* @param parent parent widget
**/
- explicit ProfilesDialog(const QString &profileName, MOBase::IPluginGame const *game, QWidget *parent = 0);
+ explicit ProfilesDialog(const QString &profileName, OrganizerCore &organizer, QWidget *parent = 0);
~ProfilesDialog();
// also saves and restores geometry
@@ -61,6 +63,23 @@ public: **/
bool failed() const { return m_FailState; }
+signals:
+
+ /**
+ * @brief Signal emitted when a profile is created.
+ */
+ void profileCreated(Profile* profile);
+
+ /**
+ * @brief Signal emitted when a profile is renamed.
+ */
+ void profileRenamed(Profile* profile, QString const& oldName, QString const& newName);
+
+ /**
+ * @brief Signal emitted when a profile has been removed.
+ */
+ void profileRemoved(QString const& profileName);
+
protected:
virtual void showEvent(QShowEvent *event);
|
