From 037b039bfbfeda2e9b7ebef7e38616575411c876 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 14 Jan 2018 20:34:50 +0100 Subject: Initial plugins testing --- src/mainwindow.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f57cab9..913885d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include MainWindow::MainWindow(std::shared_ptr config, QWidget *parent) @@ -308,3 +307,25 @@ void MainWindow::handleTitleUpdated(const QString &title) setWindowTitle(t); //setWindowTitle(browser->settings()->value("window.title").toString().replace("title", title).replace("profile", tabBar->profile()->name())); } + +void MainWindow::addPlugins(QVector &plugins) { + for(PluginInterface *plugin : plugins) { + ProfileInterface *profilePlugin = dynamic_cast(plugin); + QWidget *w = profilePlugin->createWidget(m_profile.get(), this); + + QAction *profileAction = new QAction(this); + profileAction->setText("Profile Action"); + ui->navigationToolBar->addAction(profileAction); + connect(profileAction, &QAction::triggered, this, [this, w]() { + w->setVisible(!w->isVisible()); + if(w->isVisible()) { + w->adjustSize(); + QPoint pos = ui->navigationToolBar->pos(); + pos.setX(pos.x() + ui->navigationToolBar->width() - w->width()); + pos.setY(pos.y() + ui->navigationToolBar->height()); + w->move(mapToGlobal(pos)); + w->show(); + } + }); + } +} -- cgit v1.2.1