summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2020-11-13 13:04:22 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2020-11-13 13:04:22 +0100
commitfe6654f89220c6739405ff7d9a54bc49f92a4c5b (patch)
treebfc18e3f4e5c9eb82ce80788810d169ce95bad96 /src/mainwindow.cpp
parent5384fb1cf6c2b1377a35dbef17166d6907b74652 (diff)
Better 'Browse Mod Page' menu.
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp56
1 files changed, 22 insertions, 34 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index b5a6382f..d20fd3ba 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -260,7 +260,6 @@ MainWindow::MainWindow(Settings &settings
, m_ContextItem(nullptr)
, m_ContextAction(nullptr)
, m_ContextRow(-1)
- , m_browseModPage(nullptr)
, m_CurrentSaveView(nullptr)
, m_OrganizerCore(organizerCore)
, m_PluginContainer(pluginContainer)
@@ -811,6 +810,7 @@ static QModelIndex mapToModel(const QAbstractItemModel *targetModel, QModelIndex
void MainWindow::setupToolbar()
{
+ setupActionMenu(ui->actionModPage);
setupActionMenu(ui->actionTool);
setupActionMenu(ui->actionHelp);
setupActionMenu(ui->actionEndorseMO);
@@ -1596,29 +1596,6 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
return false;
}
-void MainWindow::modPagePluginInvoke()
-{
- QAction *triggeredAction = qobject_cast<QAction*>(sender());
- IPluginModPage *plugin = qobject_cast<IPluginModPage*>(triggeredAction->data().value<QObject*>());
- if (plugin != nullptr) {
- if (plugin->useIntegratedBrowser()) {
-
- if (!m_IntegratedBrowser) {
- m_IntegratedBrowser.reset(new BrowserDialog);
-
- connect(
- m_IntegratedBrowser.get(), SIGNAL(requestDownload(QUrl,QNetworkReply*)),
- &m_OrganizerCore, SLOT(requestDownload(QUrl,QNetworkReply*)));
- }
-
- m_IntegratedBrowser->setWindowTitle(plugin->displayName());
- m_IntegratedBrowser->openUrl(plugin->pageURL());
- } else {
- QDesktopServices::openUrl(QUrl(plugin->pageURL()));
- }
- }
-}
-
void MainWindow::registerPluginTool(IPluginTool *tool, QString name, QMenu *menu)
{
if (!menu) {
@@ -1694,23 +1671,34 @@ void MainWindow::updateToolMenu()
void MainWindow::registerModPage(IPluginModPage *modPage)
{
// turn the browser action into a drop-down menu if necessary
- if (!m_browseModPage) {
- m_browseModPage = new QAction(ui->actionNexus->icon(), tr("Browse Mod Page"), this);
- setupActionMenu(m_browseModPage);
-
- m_browseModPage->menu()->addAction(ui->actionNexus);
-
- ui->toolBar->insertAction(ui->actionNexus, m_browseModPage);
+ if (!ui->actionModPage->isVisible()) {
ui->toolBar->removeAction(ui->actionNexus);
+ ui->actionModPage->menu()->addAction(ui->actionNexus);
+ ui->actionModPage->setVisible(true);
}
QAction *action = new QAction(modPage->icon(), modPage->displayName(), this);
modPage->setParentWidget(this);
- action->setData(QVariant::fromValue(reinterpret_cast<QObject*>(modPage)));
+ connect(action, &QAction::triggered, this, [this, modPage]() {
+ if (modPage->useIntegratedBrowser()) {
+
+ if (!m_IntegratedBrowser) {
+ m_IntegratedBrowser.reset(new BrowserDialog);
+
+ connect(
+ m_IntegratedBrowser.get(), SIGNAL(requestDownload(QUrl, QNetworkReply*)),
+ &m_OrganizerCore, SLOT(requestDownload(QUrl, QNetworkReply*)));
+ }
- connect(action, SIGNAL(triggered()), this, SLOT(modPagePluginInvoke()), Qt::QueuedConnection);
+ m_IntegratedBrowser->setWindowTitle(modPage->displayName());
+ m_IntegratedBrowser->openUrl(modPage->pageURL());
+ }
+ else {
+ QDesktopServices::openUrl(QUrl(modPage->pageURL()));
+ }
+ }, Qt::QueuedConnection);
- m_browseModPage->menu()->addAction(action);
+ ui->actionModPage->menu()->addAction(action);
}