diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-11-13 13:04:22 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-11-13 13:04:22 +0100 |
| commit | fe6654f89220c6739405ff7d9a54bc49f92a4c5b (patch) | |
| tree | bfc18e3f4e5c9eb82ce80788810d169ce95bad96 /src | |
| parent | 5384fb1cf6c2b1377a35dbef17166d6907b74652 (diff) | |
Better 'Browse Mod Page' menu.
Diffstat (limited to 'src')
| -rw-r--r-- | src/mainwindow.cpp | 56 | ||||
| -rw-r--r-- | src/mainwindow.h | 4 | ||||
| -rw-r--r-- | src/mainwindow.ui | 22 |
3 files changed, 44 insertions, 38 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); } diff --git a/src/mainwindow.h b/src/mainwindow.h index d4aa0bc2..78ffec47 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -156,8 +156,6 @@ public slots: void directory_refreshed(); - void modPagePluginInvoke(); - signals: /** @@ -325,8 +323,6 @@ private: QTreeWidgetItem *m_ContextItem; QAction *m_ContextAction; - QAction* m_browseModPage; - CategoryFactory &m_CategoryFactory; QTimer m_CheckBSATimer; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index ace0dfeb..dbc6013d 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1411,6 +1411,7 @@ p, li { white-space: pre-wrap; } <addaction name="actionChange_Game"/> <addaction name="actionInstallMod"/> <addaction name="actionNexus"/> + <addaction name="actionModPage"/> <addaction name="actionAdd_Profile"/> <addaction name="actionModify_Executables"/> <addaction name="actionTool"/> @@ -1684,6 +1685,27 @@ p, li { white-space: pre-wrap; } <string>Ctrl+N</string> </property> </action> + <action name="actionModPage"> + <property name="icon"> + <iconset resource="resources.qrc"> + <normaloff>:/MO/gui/resources/internet-web-browser.png</normaloff>:/MO/gui/resources/internet-web-browser.png</iconset> + </property> + <property name="text"> + <string>Browse Mod Page</string> + </property> + <property name="iconText"> + <string>Browse Mod Page</string> + </property> + <property name="toolTip"> + <string>Browse Mod Page</string> + </property> + <property name="statusTip"> + <string>Browse Mod Page</string> + </property> + <property name="visible"> + <bool>false</bool> + </property> + </action> <action name="actionUpdate"> <property name="enabled"> <bool>false</bool> |
