From f66cf4ad99219716e221f2a6717b910e531bc7d3 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Mon, 15 Jun 2020 22:47:21 +0200 Subject: Update for new organizer callbacks. --- src/organizercore.h | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src/organizercore.h') diff --git a/src/organizercore.h b/src/organizercore.h index 81119866..ae4a34c4 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -78,9 +78,12 @@ private: private: - typedef boost::signals2::signal SignalAboutToRunApplication; - typedef boost::signals2::signal SignalFinishedRunApplication; - typedef boost::signals2::signal SignalModInstalled; + using SignalAboutToRunApplication = boost::signals2::signal; + using SignalFinishedRunApplication = boost::signals2::signal; + using SignalModInstalled = boost::signals2::signal; + using SignalUserInterfaceInitialized = boost::signals2::signal; + using SignalProfileChanged = boost::signals2::signal; + using SignalPluginSettingChanged = boost::signals2::signal; public: @@ -215,7 +218,7 @@ public: m_ExecutablesList = executablesList; } - Profile *currentProfile() const { return m_CurrentProfile; } + Profile *currentProfile() const { return m_CurrentProfile.get(); } void setCurrentProfile(const QString &profileName); std::vector enabledArchives(); @@ -315,12 +318,17 @@ public: DownloadManager *downloadManager(); PluginList *pluginList(); ModList *modList(); - bool onModInstalled(const std::function &func); - bool onAboutToRun(const std::function &func); - bool onFinishedRun(const std::function &func); void refreshModList(bool saveChanges = true); QStringList modsSortedByProfilePriority() const; + + bool onModInstalled(const std::function& func); + bool onAboutToRun(const std::function& func); + bool onFinishedRun(const std::function& func); + bool onUserInterfaceInitialized(std::function const& func); + bool onProfileChanged(std::function const& func); + bool onPluginSettingChanged(std::function const& func); + bool getArchiveParsing() const { return m_ArchiveParsing; @@ -357,6 +365,8 @@ public slots: void requestDownload(const QUrl &url, QNetworkReply *reply); void downloadRequestedNXM(const QString &url); + void userInterfaceInitialized(QMainWindow *); + bool nexusApi(bool retry = false); signals: @@ -422,7 +432,7 @@ private: MOBase::IPluginGame *m_GamePlugin; ModDataContentHolder m_Contents; - Profile *m_CurrentProfile; + std::unique_ptr m_CurrentProfile; Settings& m_Settings; @@ -431,6 +441,9 @@ private: SignalAboutToRunApplication m_AboutToRun; SignalFinishedRunApplication m_FinishedRun; SignalModInstalled m_ModInstalled; + SignalUserInterfaceInitialized m_UserInterfaceInitialized; + SignalProfileChanged m_ProfileChanged; + SignalPluginSettingChanged m_PluginSettingChanged; ModList m_ModList; PluginList m_PluginList; -- cgit v1.3.1 From 8c410aff33395daf607ae8a1c62b8be70943ba4d Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Tue, 16 Jun 2020 21:30:24 +0200 Subject: Clean notification of userInterfaceInitialized between MainWindow and OrganizerCore. --- src/iuserinterface.h | 3 ++- src/mainwindow.cpp | 5 +++-- src/mainwindow.h | 7 ++++++- src/organizercore.cpp | 8 ++++---- src/organizercore.h | 2 +- src/processrunner.cpp | 4 ++-- 6 files changed, 18 insertions(+), 11 deletions(-) (limited to 'src/organizercore.h') diff --git a/src/iuserinterface.h b/src/iuserinterface.h index aa48194f..cce89070 100644 --- a/src/iuserinterface.h +++ b/src/iuserinterface.h @@ -7,6 +7,7 @@ #include #include #include +#include class IUserInterface @@ -30,7 +31,7 @@ public: virtual MOBase::DelayedFileWriterBase &archivesWriter() = 0; - virtual QWidget* qtWidget() = 0; + virtual QMainWindow* mainWindow() = 0; }; #endif // IUSERINTERFACE_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b3e78121..91c906a1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -502,6 +502,7 @@ MainWindow::MainWindow(Settings &settings m_Tutorial.expose("espList", m_OrganizerCore.pluginList()); m_OrganizerCore.setUserInterface(this); + connect(this, &MainWindow::userInterfaceInitialized, &m_OrganizerCore, &OrganizerCore::userInterfaceInitialized); for (const QString &fileName : m_PluginContainer.pluginFileNames()) { installTranslator(QFileInfo(fileName).baseName()); } @@ -1384,7 +1385,7 @@ void MainWindow::showEvent(QShowEvent *event) updateProblemsButton(); // Notify plugin that the UI is initialized: - m_OrganizerCore.userInterfaceInitialized(this); + emit userInterfaceInitialized(); } } @@ -2267,7 +2268,7 @@ void MainWindow::storeSettings() s.interface().setFilterOptions(FilterWidget::options()); } -QWidget* MainWindow::qtWidget() +QMainWindow* MainWindow::mainWindow() { return this; } diff --git a/src/mainwindow.h b/src/mainwindow.h index 94626ff3..60f22770 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -118,7 +118,7 @@ public: void processUpdates(); - QWidget* qtWidget() override; + QMainWindow* mainWindow() override; bool addProfile(); void updateBSAList(const QStringList &defaultArchives, const QStringList &activeArchives); @@ -175,6 +175,11 @@ signals: */ void styleChanged(const QString &styleFile); + /** + * @brief emitted when the user interface has been completely initialized + */ + void userInterfaceInitialized(); + void modListDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 45207910..062369d6 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -233,7 +233,7 @@ void OrganizerCore::setUserInterface(IUserInterface* ui) QWidget* w = nullptr; if (m_UserInterface) { - w = m_UserInterface->qtWidget(); + w = m_UserInterface->mainWindow(); } if (w) { @@ -371,9 +371,9 @@ void OrganizerCore::downloadRequestedNXM(const QString &url) } } -void OrganizerCore::userInterfaceInitialized(QMainWindow* mainWindow) +void OrganizerCore::userInterfaceInitialized() { - m_UserInterfaceInitialized(mainWindow); + m_UserInterfaceInitialized(m_UserInterface->mainWindow()); } void OrganizerCore::externalMessage(const QString &message) @@ -1834,7 +1834,7 @@ bool OrganizerCore::beforeRun( { QWidget* w = nullptr; if (m_UserInterface) { - w = m_UserInterface->qtWidget(); + w = m_UserInterface->mainWindow(); } QMessageBox::warning(w, tr("Error"), e.what()); return false; diff --git a/src/organizercore.h b/src/organizercore.h index ae4a34c4..2588d332 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -365,7 +365,7 @@ public slots: void requestDownload(const QUrl &url, QNetworkReply *reply); void downloadRequestedNXM(const QString &url); - void userInterfaceInitialized(QMainWindow *); + void userInterfaceInitialized(); bool nexusApi(bool retry = false); diff --git a/src/processrunner.cpp b/src/processrunner.cpp index 91443750..3ea40da2 100644 --- a/src/processrunner.cpp +++ b/src/processrunner.cpp @@ -520,7 +520,7 @@ ProcessRunner& ProcessRunner::setFromFile( QWidget* parent, const QFileInfo& targetInfo) { if (!parent && m_ui) { - parent = m_ui->qtWidget(); + parent = m_ui->mainWindow(); } // if the file is a .exe, start it directly; if it's anything else, ask the @@ -767,7 +767,7 @@ std::optional ProcessRunner::runBinary() } // parent widget used for any dialog popped up while checking for things - QWidget* parent = (m_ui ? m_ui->qtWidget() : nullptr); + QWidget* parent = (m_ui ? m_ui->mainWindow() : nullptr); const auto* game = m_core.managedGame(); auto& settings = m_core.settings(); -- cgit v1.3.1