+
+
diff --git a/src/plugins/VerticalTabs/verticaltabs.qrc b/src/plugins/VerticalTabs/verticaltabs.qrc
index 31e557f4d..42fecc7ed 100644
--- a/src/plugins/VerticalTabs/verticaltabs.qrc
+++ b/src/plugins/VerticalTabs/verticaltabs.qrc
@@ -1,6 +1,9 @@
data/icon.svg
+ data/group.svg
+ data/index.html
+ data/group.htmldata/themes/default.cssdata/themes/windows.cssdata/themes/windows-tab-close.svg
diff --git a/src/plugins/VerticalTabs/verticaltabsplugin.cpp b/src/plugins/VerticalTabs/verticaltabsplugin.cpp
index af4b455ae..9adb18d3d 100644
--- a/src/plugins/VerticalTabs/verticaltabsplugin.cpp
+++ b/src/plugins/VerticalTabs/verticaltabsplugin.cpp
@@ -18,6 +18,7 @@
#include "verticaltabsplugin.h"
#include "verticaltabssettings.h"
#include "verticaltabscontroller.h"
+#include "verticaltabsschemehandler.h"
#include "browserwindow.h"
#include "pluginproxy.h"
@@ -25,6 +26,7 @@
#include "tabwidget.h"
#include "tabbar.h"
#include "sidebar.h"
+#include "networkmanager.h"
#include "../config.h"
#include
@@ -64,6 +66,7 @@ void VerticalTabsPlugin::init(InitState state, const QString &settingsPath)
SideBarManager::addSidebar(QSL("VerticalTabs"), m_controller);
QZ_REGISTER_EVENT_HANDLER(PluginProxy::KeyPressHandler);
+ mApp->networkManager()->registerExtensionSchemeHandler(QSL("verticaltabs"), new VerticalTabsSchemeHandler);
setWebTabBehavior(m_addChildBehavior);
loadStyleSheet(m_theme);
@@ -85,6 +88,8 @@ void VerticalTabsPlugin::unload()
SideBarManager::removeSidebar(QSL("VerticalTabs"));
delete m_controller;
m_controller = nullptr;
+
+ mApp->networkManager()->unregisterExtensionSchemeHandler(QSL("verticaltabs"));
}
bool VerticalTabsPlugin::testPlugin()
diff --git a/src/plugins/VerticalTabs/verticaltabsschemehandler.cpp b/src/plugins/VerticalTabs/verticaltabsschemehandler.cpp
new file mode 100644
index 000000000..dc3520386
--- /dev/null
+++ b/src/plugins/VerticalTabs/verticaltabsschemehandler.cpp
@@ -0,0 +1,60 @@
+/* ============================================================
+* VerticalTabs plugin for Falkon
+* Copyright (C) 2018 David Rosca
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+* ============================================================ */
+#include "verticaltabsschemehandler.h"
+
+#include "qztools.h"
+
+#include
+#include
+#include
+
+VerticalTabsSchemeHandler::VerticalTabsSchemeHandler(QObject *parent)
+ : ExtensionSchemeHandler(parent)
+{
+}
+
+void VerticalTabsSchemeHandler::requestStarted(QWebEngineUrlRequestJob *job)
+{
+ const auto parts = job->requestUrl().path().split(QL1C('/'), QString::SkipEmptyParts);
+ if (!parts.isEmpty()) {
+ if (parts.at(0) == QL1S("group")) {
+ setReply(job, QByteArrayLiteral("text/html"), groupPage());
+ return;
+ }
+ }
+ setReply(job, QByteArrayLiteral("text/html"), indexPage());
+}
+
+QByteArray VerticalTabsSchemeHandler::indexPage() const
+{
+ QString page = QzTools::readAllFileContents(QSL(":verticaltabs/data/index.html"));
+
+ page.replace(QSL("%NAME%"), tr("Vertical Tabs"));
+
+ return page.toUtf8();
+}
+
+QByteArray VerticalTabsSchemeHandler::groupPage() const
+{
+ QString page = QzTools::readAllFileContents(QSL(":verticaltabs/data/group.html"));
+
+ page.replace(QSL("%FAVICON%"), QzTools::pixmapToDataUrl(QIcon(QSL(":verticaltabs/data/group.svg")).pixmap(16)).toString());
+ page.replace(QSL("%NEW-GROUP%"), tr("New Group"));
+
+ return page.toUtf8();
+}
diff --git a/src/plugins/VerticalTabs/verticaltabsschemehandler.h b/src/plugins/VerticalTabs/verticaltabsschemehandler.h
new file mode 100644
index 000000000..562f192f5
--- /dev/null
+++ b/src/plugins/VerticalTabs/verticaltabsschemehandler.h
@@ -0,0 +1,32 @@
+/* ============================================================
+* VerticalTabs plugin for Falkon
+* Copyright (C) 2018 David Rosca
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+* ============================================================ */
+#pragma once
+
+#include "schemehandlers/extensionschemehandler.h"
+
+class VerticalTabsSchemeHandler : public ExtensionSchemeHandler
+{
+public:
+ explicit VerticalTabsSchemeHandler(QObject *parent = nullptr);
+
+ void requestStarted(QWebEngineUrlRequestJob *job) override;
+
+private:
+ QByteArray indexPage() const;
+ QByteArray groupPage() const;
+};
diff --git a/src/plugins/VerticalTabs/verticaltabswidget.cpp b/src/plugins/VerticalTabs/verticaltabswidget.cpp
index b9d5f0a78..9396808bd 100644
--- a/src/plugins/VerticalTabs/verticaltabswidget.cpp
+++ b/src/plugins/VerticalTabs/verticaltabswidget.cpp
@@ -60,6 +60,10 @@ VerticalTabsWidget::VerticalTabsWidget(BrowserWindow *window)
buttonAddTab->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
connect(buttonAddTab, SIGNAL(clicked()), m_window, SLOT(addTab()));
+ m_groupMenu = new QMenu(this);
+ buttonAddTab->setMenu(m_groupMenu);
+ connect(m_groupMenu, &QMenu::aboutToShow, this, &VerticalTabsWidget::updateGroupMenu);
+
layout->addWidget(m_pinnedView);
layout->addWidget(m_normalView);
layout->addWidget(buttonAddTab);
@@ -175,3 +179,23 @@ void VerticalTabsWidget::wheelEvent(QWheelEvent *event)
}
event->accept();
}
+
+void VerticalTabsWidget::updateGroupMenu()
+{
+ m_groupMenu->clear();
+
+ for (int i = 0; i < m_window->tabWidget()->count(); ++i) {
+ WebTab *tab = m_window->tabWidget()->webTab(i);
+ if (tab->url().toString(QUrl::RemoveFragment) == QL1S("extension://verticaltabs/group")) {
+ m_groupMenu->addAction(tab->url().fragment(), this, [=]() {
+ QMetaObject::invokeMethod(m_window, "addTab");
+ m_window->tabWidget()->webTab()->setParentTab(tab);
+ });
+ }
+ }
+
+ m_groupMenu->addSeparator();
+ m_groupMenu->addAction(tr("Add New Group..."), this, [this]() {
+ m_window->tabWidget()->addView(QUrl(QSL("extension://verticaltabs/group")), Qz::NT_SelectedTab);
+ });
+}
diff --git a/src/plugins/VerticalTabs/verticaltabswidget.h b/src/plugins/VerticalTabs/verticaltabswidget.h
index dad653e28..c6ed5864b 100644
--- a/src/plugins/VerticalTabs/verticaltabswidget.h
+++ b/src/plugins/VerticalTabs/verticaltabswidget.h
@@ -23,6 +23,8 @@
#include "verticaltabsplugin.h"
+class QMenu;
+
class WebTab;
class BrowserWindow;
class TabTreeModel;
@@ -42,14 +44,16 @@ public:
void switchToPreviousTab();
private:
- void wheelEvent(QWheelEvent *event) override;
-
WebTab *nextTab() const;
WebTab *previousTab() const;
+ void wheelEvent(QWheelEvent *event) override;
+ void updateGroupMenu();
+
BrowserWindow *m_window;
TabListView *m_pinnedView;
TabTreeView *m_normalView;
TabTreeModel *m_treeModel = nullptr;
WheelHelper m_wheelHelper;
+ QMenu *m_groupMenu;
};