aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-11-23 00:14:36 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-11-23 00:14:36 +0100
commit7a3b8bb16c90265b26907c90a04da79d3c694f0e (patch)
tree288d1684b404279cb86d208433e9167c78414b86 /src
parentAdd library check for Plasma and Breakpad configuration toggles (diff)
downloadsmolbote-7a3b8bb16c90265b26907c90a04da79d3c694f0e.tar.xz
Add About and Run actions to plugin submenu
- Remove plugin list from About dialog
Diffstat (limited to 'src')
-rw-r--r--src/browser.cpp44
-rw-r--r--src/browser.h9
-rw-r--r--src/main.cpp3
-rw-r--r--src/mainwindow/mainwindow.cpp20
-rw-r--r--src/mainwindow/mainwindow.h1
-rw-r--r--src/mainwindow/mainwindow.ui19
6 files changed, 40 insertions, 56 deletions
diff --git a/src/browser.cpp b/src/browser.cpp
index 0bd3d06..cc5d565 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -54,10 +54,6 @@ Browser::~Browser()
void Browser::about()
{
auto *dlg = new AboutDialog;
- for(const QPluginLoader *loader : qAsConst(m_plugins)) {
- const auto meta = loader->metaData().value("MetaData").toObject();
- dlg->addPlugin(meta.value("name").toString(), meta.value("author").toString(), meta.value("shortcut").toString());
- }
dlg->exec();
}
@@ -224,21 +220,8 @@ MainWindow *Browser::createWindow()
connect(window->addressBar, &AddressBar::complete, m_bookmarks.get(), &BookmarksWidget::search);
connect(window, &MainWindow::createBookmark, m_bookmarks.get(), &BookmarksWidget::addBookmark);
- connect(window->ui->menuTools, &QMenu::aboutToShow, this, [this, window]() {
- window->ui->menuPlugins->clear();
-
- for(const QPluginLoader *l : m_plugins) {
- auto *action = window->ui->menuPlugins->addAction(l->metaData()[QLatin1String("MetaData")].toObject()[QLatin1String("name")].toString());
- connect(action, &QAction::triggered, this, [l, window]() {
- auto *dlg = new AboutPluginDialog(l, window);
- dlg->exec();
- });
- }
- });
-
- auto *bookmarksAction = new QAction(tr("Bookmarks"), window);
- m_config->setShortcut(bookmarksAction, "bookmarks.shortcut");
- connect(bookmarksAction, &QAction::triggered, window, [this, window]() {
+ m_config->setShortcut(window->ui->actionBookmarks, "bookmarks.shortcut");
+ connect(window->ui->actionBookmarks, &QAction::triggered, window, [this, window]() {
bool wasVisible = m_bookmarks->isVisible();
for(MainWindow *w : qAsConst(m_windows)) {
w->removeDockWidget(m_bookmarks.get());
@@ -247,11 +230,9 @@ MainWindow *Browser::createWindow()
window->addDockWidget(Qt::RightDockWidgetArea, m_bookmarks.get());
}
});
- window->addAction(MainWindow::ToolsMenu, bookmarksAction);
- auto *downloadsAction = new QAction(tr("Downloads"), window);
- m_config->setShortcut(downloadsAction, "downloads.shortcut");
- connect(downloadsAction, &QAction::triggered, window, [this, window]() {
+ m_config->setShortcut(window->ui->actionDownloads, "downloads.shortcut");
+ connect(window->ui->actionDownloads, &QAction::triggered, window, [this, window]() {
bool wasVisible = m_downloads->isVisible();
for(MainWindow *w : qAsConst(m_windows)) {
w->removeDockWidget(m_downloads.get());
@@ -260,18 +241,25 @@ MainWindow *Browser::createWindow()
window->addDockWidget(Qt::RightDockWidgetArea, m_downloads.get());
}
});
- window->addAction(MainWindow::ToolsMenu, downloadsAction);
for(QPluginLoader *loader : qAsConst(m_plugins)) {
const auto *plugin = qobject_cast<PluginInterface *>(loader->instance());
Q_CHECK_PTR(plugin);
- auto *pluginAction = new QAction(loader->metaData().value("MetaData").toObject().value("name").toString(), window);
- pluginAction->setShortcut(QKeySequence::fromString(loader->metaData().value("MetaData").toObject().value("shortcut").toString()));
- connect(pluginAction, &QAction::triggered, window, [=]() {
+ auto *pluginMenu = window->ui->menuTools->addMenu(loader->metaData().value("MetaData").toObject().value("name").toString());
+
+ auto *aboutAction = pluginMenu->addAction(tr("About"));
+ connect(aboutAction, &QAction::triggered, this, [loader, window]() {
+ auto *dlg = new AboutPluginDialog(loader, window);
+ dlg->exec();
+ });
+
+ auto *runAction = pluginMenu->addAction(tr("Run"));
+ runAction->setShortcut(QKeySequence::fromString(loader->metaData().value("MetaData").toObject().value("shortcut").toString()));
+
+ connect(runAction, &QAction::triggered, window, [=]() {
plugin->createWidget(window)->exec();
});
- window->addAction(MainWindow::ToolsMenu, pluginAction);
}
m_windows.append(window);
diff --git a/src/browser.h b/src/browser.h
index 35b4149..e871202 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -9,13 +9,13 @@
#ifndef SMOLBOTE_BROWSER_H
#define SMOLBOTE_BROWSER_H
-#include <singleapplication.h>
-#include <browserinterface.h>
+#include "session.h"
#include <QJsonObject>
#include <QVector>
+#include <browserinterface.h>
#include <functional>
#include <memory>
-#include "session.h"
+#include <singleapplication.h>
class Configuration;
class BookmarksWidget;
@@ -51,7 +51,8 @@ public:
void setup(QVector<QPluginLoader *> plugins);
- QJsonObject session() const {
+ QJsonObject session() const
+ {
return Session::session(m_windows);
}
diff --git a/src/main.cpp b/src/main.cpp
index c4e5d3f..3eb6dac 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -117,6 +117,7 @@ int main(int argc, char **argv)
QVector<QPluginLoader *> plugins;
CommandHash_t pluginCommands;
+ // Load plugins
for(const QString &path : Util::files(config->value<QString>("plugins.path").value())) {
QPluginLoader *loader = new QPluginLoader(path);
const bool loaded = loader->load();
@@ -124,7 +125,7 @@ int main(int argc, char **argv)
qDebug("Loading plugin %s %s", qUtf8Printable(path), loaded ? "[ok]" : "[failed]");
#endif
- if(loader->load()) {
+ if(loaded) {
plugins.append(loader);
auto *plugin = qobject_cast<PluginInterface *>(loader->instance());
pluginCommands.unite(plugin->commands());
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index e465a4f..8f635c9 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -9,10 +9,14 @@
#include "mainwindow.h"
#include "addressbar.h"
#include "browser.h"
+#include "config.h"
+#include "configuration.h"
+#include "profilemanager.h"
#include "session.h"
#include "subwindow/subwindow.h"
#include "ui_mainwindow.h"
#include "webengine/webview.h"
+#include "webprofile.h"
#include "widgets/dockwidget.h"
#include "widgets/navigationbar.h"
#include "widgets/searchform.h"
@@ -34,10 +38,6 @@
#include <QToolBar>
#include <QUrl>
#include <QVBoxLayout>
-#include "configuration.h"
-#include "profilemanager.h"
-#include "webprofile.h"
-#include "config.h"
#ifdef CONFIG_PLASMA_BLUR
#include <KWindowEffects>
#endif
@@ -285,18 +285,6 @@ MainWindow::~MainWindow()
disconnect(addressBar);
}
-void MainWindow::addAction(ActionLocation where, QAction *action)
-{
- switch(where) {
- case ToolsMenu:
- ui->menuTools->addAction(action);
- break;
- default:
- QMainWindow::addAction(action);
- break;
- }
-}
-
void MainWindow::addDockWidget(Qt::DockWidgetArea area, QWidget *widget)
{
QDockWidget *lastDock = nullptr;
diff --git a/src/mainwindow/mainwindow.h b/src/mainwindow/mainwindow.h
index 6ce61b5..296a73e 100644
--- a/src/mainwindow/mainwindow.h
+++ b/src/mainwindow/mainwindow.h
@@ -43,7 +43,6 @@ public:
Q_DISABLE_COPY(MainWindow)
~MainWindow() override;
- void addAction(ActionLocation where, QAction *action);
void addDockWidget(Qt::DockWidgetArea area, QWidget *widget);
void removeDockWidget(QWidget *widget);
diff --git a/src/mainwindow/mainwindow.ui b/src/mainwindow/mainwindow.ui
index ad213c6..587b4fd 100644
--- a/src/mainwindow/mainwindow.ui
+++ b/src/mainwindow/mainwindow.ui
@@ -55,12 +55,9 @@
<property name="title">
<string>Too&amp;ls</string>
</property>
- <widget class="QMenu" name="menuPlugins">
- <property name="title">
- <string>&amp;Plugins</string>
- </property>
- </widget>
- <addaction name="menuPlugins"/>
+ <addaction name="actionBookmarks"/>
+ <addaction name="actionDownloads"/>
+ <addaction name="separator"/>
</widget>
<widget class="QMenu" name="menuPage">
<property name="title">
@@ -155,6 +152,16 @@
<string>&amp;Developer Tools</string>
</property>
</action>
+ <action name="actionBookmarks">
+ <property name="text">
+ <string>Bookmarks</string>
+ </property>
+ </action>
+ <action name="actionDownloads">
+ <property name="text">
+ <string>Downloads</string>
+ </property>
+ </action>
</widget>
<resources/>
<connections/>