aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--lib/webengine/CMakeLists.txt (renamed from src/webengine/CMakeLists.txt)10
-rw-r--r--lib/webengine/test/form.html (renamed from src/webengine/test/form.html)0
-rw-r--r--lib/webengine/test/icon.svg (renamed from src/webengine/test/icon.svg)0
-rw-r--r--lib/webengine/test/profile.cpp (renamed from src/webengine/test/profile.cpp)0
-rw-r--r--lib/webengine/test/profilemanager.cpp (renamed from src/webengine/test/profilemanager.cpp)0
-rw-r--r--lib/webengine/test/sample.html (renamed from src/webengine/test/sample.html)0
-rw-r--r--lib/webengine/test/testing.profile (renamed from src/webengine/test/testing.profile)0
-rw-r--r--lib/webengine/test/view.cpp (renamed from src/webengine/test/view.cpp)0
-rw-r--r--lib/webengine/urlinterceptor.cpp (renamed from src/webengine/urlinterceptor.cpp)0
-rw-r--r--lib/webengine/urlinterceptor.h (renamed from src/webengine/urlinterceptor.h)0
-rw-r--r--lib/webengine/webpage.cpp (renamed from src/webengine/webpage.cpp)0
-rw-r--r--lib/webengine/webpage.h (renamed from src/webengine/webpage.h)0
-rw-r--r--lib/webengine/webprofile.cpp (renamed from src/webengine/webprofile.cpp)0
-rw-r--r--lib/webengine/webprofile.h (renamed from src/webengine/webprofile.h)0
-rw-r--r--lib/webengine/webprofilemanager.cpp (renamed from src/webengine/webprofilemanager.cpp)0
-rw-r--r--lib/webengine/webprofilemanager.h (renamed from src/webengine/webprofilemanager.h)0
-rw-r--r--lib/webengine/webview.cpp (renamed from src/webengine/webview.cpp)0
-rw-r--r--lib/webengine/webview.h (renamed from src/webengine/webview.h)0
-rw-r--r--lib/webengine/webviewcontextmenu.cpp (renamed from src/webengine/webviewcontextmenu.cpp)0
-rw-r--r--lib/webengine/webviewcontextmenu.h (renamed from src/webengine/webviewcontextmenu.h)0
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/bookmarks/bookmarkswidget.cpp4
-rw-r--r--src/browser.cpp3
-rw-r--r--src/browser.h2
-rw-r--r--src/mainwindow/addressbar.cpp4
-rw-r--r--src/mainwindow/mainwindow.cpp6
-rw-r--r--src/mainwindow/menubar.cpp4
-rw-r--r--src/mainwindow/widgets/navigationbar.cpp4
-rw-r--r--src/session/savesessiondialog.cpp4
-rw-r--r--src/subwindow/subwindow.cpp6
-rw-r--r--src/subwindow/subwindow.h4
-rw-r--r--src/subwindow/tabwidget.cpp49
-rw-r--r--src/subwindow/tabwidget.h53
34 files changed, 82 insertions, 73 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c7147c4..4320962 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -56,6 +56,7 @@ add_subdirectory(lib/downloads)
add_subdirectory(lib/pluginloader)
add_subdirectory(lib/session_formats)
add_subdirectory(lib/smolblok)
+add_subdirectory(lib/webengine)
add_subdirectory(src)
add_subdirectory(plugins/HostlistFilter)
diff --git a/src/webengine/CMakeLists.txt b/lib/webengine/CMakeLists.txt
index 156c64a..ba3017f 100644
--- a/src/webengine/CMakeLists.txt
+++ b/lib/webengine/CMakeLists.txt
@@ -1,11 +1,11 @@
-add_library(webengine INTERFACE)
-target_sources(webengine INTERFACE
+add_library(webengine STATIC
webprofile.h webprofile.cpp webprofilemanager.h webprofilemanager.cpp
webpage.h webpage.cpp
webview.h webview.cpp webviewcontextmenu.h webviewcontextmenu.cpp
urlinterceptor.h urlinterceptor.cpp)
-target_include_directories(webengine INTERFACE ${CMAKE_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR})
-target_link_libraries(webengine INTERFACE Qt5::WebEngineWidgets autogen fmt)
+target_include_directories(webengine PUBLIC ${CMAKE_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR})
+# autogen: required for context menu icons; TODO: move context menu to src/
+target_link_libraries(webengine PUBLIC Qt5::WebEngineWidgets autogen fmt)
# tests
add_executable(profile_test test/profile.cpp)
@@ -19,4 +19,4 @@ target_link_libraries(profilemanager_test PRIVATE webengine Catch2::Catch2)
add_test(NAME webengine_profile COMMAND profile_test)
add_test(NAME webengine_profilemanager COMMAND profilemanager_test)
set_tests_properties(webengine_profile webengine_profilemanager PROPERTIES
- ENVIRONMENT "PROFILE=${CMAKE_CURRENT_SOURCE_DIR}/test/testing.profile") \ No newline at end of file
+ ENVIRONMENT "PROFILE=${CMAKE_CURRENT_SOURCE_DIR}/test/testing.profile")
diff --git a/src/webengine/test/form.html b/lib/webengine/test/form.html
index 9d8b19e..9d8b19e 100644
--- a/src/webengine/test/form.html
+++ b/lib/webengine/test/form.html
diff --git a/src/webengine/test/icon.svg b/lib/webengine/test/icon.svg
index a348cab..a348cab 100644
--- a/src/webengine/test/icon.svg
+++ b/lib/webengine/test/icon.svg
diff --git a/src/webengine/test/profile.cpp b/lib/webengine/test/profile.cpp
index ae3a4e3..ae3a4e3 100644
--- a/src/webengine/test/profile.cpp
+++ b/lib/webengine/test/profile.cpp
diff --git a/src/webengine/test/profilemanager.cpp b/lib/webengine/test/profilemanager.cpp
index 8f6a34f..8f6a34f 100644
--- a/src/webengine/test/profilemanager.cpp
+++ b/lib/webengine/test/profilemanager.cpp
diff --git a/src/webengine/test/sample.html b/lib/webengine/test/sample.html
index 54746d5..54746d5 100644
--- a/src/webengine/test/sample.html
+++ b/lib/webengine/test/sample.html
diff --git a/src/webengine/test/testing.profile b/lib/webengine/test/testing.profile
index e345a3e..e345a3e 100644
--- a/src/webengine/test/testing.profile
+++ b/lib/webengine/test/testing.profile
diff --git a/src/webengine/test/view.cpp b/lib/webengine/test/view.cpp
index 8aa639a..8aa639a 100644
--- a/src/webengine/test/view.cpp
+++ b/lib/webengine/test/view.cpp
diff --git a/src/webengine/urlinterceptor.cpp b/lib/webengine/urlinterceptor.cpp
index 047cad4..047cad4 100644
--- a/src/webengine/urlinterceptor.cpp
+++ b/lib/webengine/urlinterceptor.cpp
diff --git a/src/webengine/urlinterceptor.h b/lib/webengine/urlinterceptor.h
index eb3ce67..eb3ce67 100644
--- a/src/webengine/urlinterceptor.h
+++ b/lib/webengine/urlinterceptor.h
diff --git a/src/webengine/webpage.cpp b/lib/webengine/webpage.cpp
index b2b19b5..b2b19b5 100644
--- a/src/webengine/webpage.cpp
+++ b/lib/webengine/webpage.cpp
diff --git a/src/webengine/webpage.h b/lib/webengine/webpage.h
index 91ae4f3..91ae4f3 100644
--- a/src/webengine/webpage.h
+++ b/lib/webengine/webpage.h
diff --git a/src/webengine/webprofile.cpp b/lib/webengine/webprofile.cpp
index f1e71fb..f1e71fb 100644
--- a/src/webengine/webprofile.cpp
+++ b/lib/webengine/webprofile.cpp
diff --git a/src/webengine/webprofile.h b/lib/webengine/webprofile.h
index 894463f..894463f 100644
--- a/src/webengine/webprofile.h
+++ b/lib/webengine/webprofile.h
diff --git a/src/webengine/webprofilemanager.cpp b/lib/webengine/webprofilemanager.cpp
index 5cc83f8..5cc83f8 100644
--- a/src/webengine/webprofilemanager.cpp
+++ b/lib/webengine/webprofilemanager.cpp
diff --git a/src/webengine/webprofilemanager.h b/lib/webengine/webprofilemanager.h
index e5df6d5..e5df6d5 100644
--- a/src/webengine/webprofilemanager.h
+++ b/lib/webengine/webprofilemanager.h
diff --git a/src/webengine/webview.cpp b/lib/webengine/webview.cpp
index bc52102..bc52102 100644
--- a/src/webengine/webview.cpp
+++ b/lib/webengine/webview.cpp
diff --git a/src/webengine/webview.h b/lib/webengine/webview.h
index 538ffa9..538ffa9 100644
--- a/src/webengine/webview.h
+++ b/lib/webengine/webview.h
diff --git a/src/webengine/webviewcontextmenu.cpp b/lib/webengine/webviewcontextmenu.cpp
index c9d809f..c9d809f 100644
--- a/src/webengine/webviewcontextmenu.cpp
+++ b/lib/webengine/webviewcontextmenu.cpp
diff --git a/src/webengine/webviewcontextmenu.h b/lib/webengine/webviewcontextmenu.h
index 881670a..881670a 100644
--- a/src/webengine/webviewcontextmenu.h
+++ b/lib/webengine/webviewcontextmenu.h
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 902fe6f..865c3f7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,7 +1,6 @@
add_subdirectory(autogen)
add_subdirectory(about)
add_subdirectory(cmd)
-add_subdirectory(webengine)
add_executable(poi
bookmarks/builtin.cpp
diff --git a/src/bookmarks/bookmarkswidget.cpp b/src/bookmarks/bookmarkswidget.cpp
index c7bc5f0..969f19e 100644
--- a/src/bookmarks/bookmarkswidget.cpp
+++ b/src/bookmarks/bookmarkswidget.cpp
@@ -12,8 +12,8 @@
#include "mainwindow/mainwindow.h"
#include "subwindow/subwindow.h"
#include "ui_bookmarksform.h"
-#include "webengine/webprofilemanager.h"
-#include "webengine/webview.h"
+#include "webprofilemanager.h"
+#include "webview.h"
#include <QFileDialog>
#include <QMenu>
#include <QTreeView>
diff --git a/src/browser.cpp b/src/browser.cpp
index de5cdcf..000fd3a 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -17,8 +17,7 @@
#include "session_json.hpp"
#include "settings.h"
#include "util.h"
-#include "webengine/webprofile.h"
-#include "webengine/webprofilemanager.h"
+#include "webprofile.h"
#include <QAction>
#include <QLibraryInfo>
#include <QPluginLoader>
diff --git a/src/browser.h b/src/browser.h
index 63b280b..6a92d8b 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -11,7 +11,7 @@
#include "smolblok.hpp"
#include "smolbote/session.hpp"
-#include "webengine/webprofilemanager.h"
+#include "webprofilemanager.h"
#include <QJsonObject>
#include <QMenu>
#include <QPluginLoader>
diff --git a/src/mainwindow/addressbar.cpp b/src/mainwindow/addressbar.cpp
index d37a6a7..6b2cfd8 100644
--- a/src/mainwindow/addressbar.cpp
+++ b/src/mainwindow/addressbar.cpp
@@ -7,10 +7,10 @@
*/
#include "addressbar.h"
+#include "configuration.h"
#include "ui_addressbar.h"
+#include "webview.h"
#include <QShortcut>
-#include "configuration.h"
-#include "webengine/webview.h"
AddressBar::AddressBar(QWidget *parent)
: QWidget(parent)
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index 64c149c..0d4a978 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -13,9 +13,9 @@
#include "browser.h"
#include "configuration.h"
#include "menubar.h"
-#include "webengine/webprofile.h"
-#include "webengine/webprofilemanager.h"
-#include "webengine/webview.h"
+#include "webprofile.h"
+#include "webprofilemanager.h"
+#include "webview.h"
#include "widgets/dockwidget.h"
#include "widgets/navigationbar.h"
#include "widgets/searchform.h"
diff --git a/src/mainwindow/menubar.cpp b/src/mainwindow/menubar.cpp
index 5fc039a..80cb3ea 100644
--- a/src/mainwindow/menubar.cpp
+++ b/src/mainwindow/menubar.cpp
@@ -13,8 +13,8 @@
#include "downloadswidget.h"
#include "mainwindow.h"
#include "subwindow/subwindow.h"
-#include "webengine/webprofilemanager.h"
-#include "webengine/webview.h"
+#include "webprofilemanager.h"
+#include "webview.h"
#include "widgets/menusearch.h"
#include <QDir>
#include <QFileDialog>
diff --git a/src/mainwindow/widgets/navigationbar.cpp b/src/mainwindow/widgets/navigationbar.cpp
index 0338bb7..dcb845c 100644
--- a/src/mainwindow/widgets/navigationbar.cpp
+++ b/src/mainwindow/widgets/navigationbar.cpp
@@ -10,8 +10,8 @@
#include "configuration.h"
#include "urllineedit.h"
#include "util.h"
-#include "webengine/webprofile.h"
-#include "webengine/webview.h"
+#include "webprofile.h"
+#include "webview.h"
#include <QHBoxLayout>
#include <QMenu>
#include <QShortcut>
diff --git a/src/session/savesessiondialog.cpp b/src/session/savesessiondialog.cpp
index e22ce3a..3bc4150 100644
--- a/src/session/savesessiondialog.cpp
+++ b/src/session/savesessiondialog.cpp
@@ -12,8 +12,8 @@
#include "session_json.hpp"
#include "subwindow/subwindow.h"
#include "ui_savesessiondialog.h"
-#include "webengine/webprofile.h"
-#include "webengine/webview.h"
+#include "webprofile.h"
+#include "webview.h"
#include <QFileDialog>
#include <QPointer>
#include <QTreeWidgetItem>
diff --git a/src/subwindow/subwindow.cpp b/src/subwindow/subwindow.cpp
index a2d6138..60ea633 100644
--- a/src/subwindow/subwindow.cpp
+++ b/src/subwindow/subwindow.cpp
@@ -9,9 +9,9 @@
#include "subwindow.h"
#include "browser.h"
#include "configuration.h"
-#include "webengine/webprofile.h"
-#include "webengine/webprofilemanager.h"
-#include "webengine/webview.h"
+#include "webprofile.h"
+#include "webprofilemanager.h"
+#include "webview.h"
#include <QAction>
#include <QCloseEvent>
#include <QHideEvent>
diff --git a/src/subwindow/subwindow.h b/src/subwindow/subwindow.h
index 80e8520..a7b4564 100644
--- a/src/subwindow/subwindow.h
+++ b/src/subwindow/subwindow.h
@@ -11,7 +11,7 @@
#include "smolbote/session.hpp"
#include "tabwidget.h"
-#include "webengine/webview.h"
+#include "webview.h"
#include <QMenu>
#include <QUrl>
#include <QWidget>
@@ -29,7 +29,7 @@ public:
explicit SubWindow(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
explicit SubWindow(const Session::SubWindow &tab_data, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
- ~SubWindow() = default;
+ ~SubWindow() override = default;
[[nodiscard]] Session::SubWindow serialize() const;
[[nodiscard]] int currentTabIndex() const
diff --git a/src/subwindow/tabwidget.cpp b/src/subwindow/tabwidget.cpp
index 69f3b8a..1e1d939 100644
--- a/src/subwindow/tabwidget.cpp
+++ b/src/subwindow/tabwidget.cpp
@@ -8,29 +8,22 @@
#include "tabwidget.h"
#include "browser.h"
-#include "webengine/webview.h"
+#include "subwindow.h"
+#include "webprofile.h"
+#include "webview.h"
#include <QAction>
#include <QContextMenuEvent>
#include <QMenu>
#include <QTabBar>
-#include "webengine/webprofile.h"
#include <QWebEngineHistory>
-#include "subwindow.h"
-inline WebView *createViewFromInfo(TabWidget::TabInformation &tab, SubWindow *parent)
-{
- auto *view = new WebView(tab.profile, std::bind(&SubWindow::createView, parent, std::placeholders::_1), parent);
- QDataStream stream(&tab.historyBuffer, QIODevice::ReadOnly);
- stream >> *view->history();
- view->history()->goToItem(view->history()->itemAt(tab.historyIndex));
- return view;
-}
+const QLatin1String stylesheet("QTabBar::tab { width: 200px; }");
TabWidget::TabWidget(SubWindow *parent)
: QTabWidget(parent)
, m_parent(parent)
{
- setStyleSheet("QTabBar::tab { width: 200px; }");
+ setStyleSheet(stylesheet);
setTabsClosable(true);
setTabBarAutoHide(true);
@@ -80,29 +73,6 @@ TabWidget::~TabWidget()
}
}
-int TabWidget::addTab(WebView *view)
-{
- if(view == nullptr) {
- return -1;
- }
-
- const int idx = QTabWidget::addTab(view, view->title());
- connect(view, &WebView::titleChanged, [this, view](const QString &title) {
- const int current_idx = indexOf(view);
- if(current_idx != -1) {
- setTabText(current_idx, title);
- }
- });
- connect(view, &WebView::iconChanged, [this, view](const QIcon &icon) {
- const int current_idx = indexOf(view);
- if(current_idx != -1) {
- setTabIcon(current_idx, icon);
- }
- });
- tabBar()->setTabData(idx, QVariant::fromValue<SubWindow::TabData>(SubWindow::TabData{}));
- return idx;
-}
-
void TabWidget::removeTab(int index)
{
// deleting the widget automatically removes the tab?
@@ -180,3 +150,12 @@ void TabWidget::mousePressEvent(QMouseEvent *event)
QTabWidget::mousePressEvent(event);
}
+
+WebView *TabWidget::createViewFromInfo(TabWidget::TabInformation &tab, SubWindow *parent)
+{
+ auto *view = new WebView(tab.profile, std::bind(&SubWindow::createView, parent, std::placeholders::_1), parent);
+ QDataStream stream(&tab.historyBuffer, QIODevice::ReadOnly);
+ stream >> *view->history();
+ view->history()->goToItem(view->history()->itemAt(tab.historyIndex));
+ return view;
+}
diff --git a/src/subwindow/tabwidget.h b/src/subwindow/tabwidget.h
index de5e6fb..2a5f360 100644
--- a/src/subwindow/tabwidget.h
+++ b/src/subwindow/tabwidget.h
@@ -9,9 +9,17 @@
#ifndef SMOLBOTE_TABWIDGET_H
#define SMOLBOTE_TABWIDGET_H
-#include <QTabWidget>
-#include <QQueue>
#include <QBuffer>
+#include <QQueue>
+#include <QTabWidget>
+
+template <typename T>
+concept c_WebView = requires(T *a)
+{
+ a->title();
+ a->titleChanged(QString());
+ a->iconChanged(QIcon());
+};
class QAction;
class QMenu;
@@ -24,19 +32,34 @@ class TabWidget : public QTabWidget
Q_OBJECT
public:
- struct TabInformation
- {
- WebProfile *profile;
- QString title;
- int historyIndex;
- QByteArray historyBuffer;
- };
-
explicit TabWidget(SubWindow *parent = nullptr);
~TabWidget() override;
+ template <c_WebView T>
+ int addTab(T *view)
+ {
+ if(view == nullptr) {
+ return -1;
+ }
+
+ const int idx = QTabWidget::addTab(view, view->title());
+ connect(view, &T::titleChanged, [this, view](const QString &title) {
+ const int current_idx = indexOf(view);
+ if(current_idx != -1) {
+ setTabText(current_idx, title);
+ }
+ });
+ connect(view, &T::iconChanged, [this, view](const QIcon &icon) {
+ const int current_idx = indexOf(view);
+ if(current_idx != -1) {
+ setTabIcon(current_idx, icon);
+ }
+ });
+ //tabBar()->setTabData(idx, QVariant::fromValue<SubWindow::TabData>(SubWindow::TabData{}));
+ return idx;
+ }
+
public slots:
- int addTab(WebView *view);
void removeTab(int index);
int restoreLastTab();
@@ -47,6 +70,14 @@ protected:
void mousePressEvent(QMouseEvent *event) override;
private:
+ struct TabInformation {
+ WebProfile *profile;
+ QString title;
+ int historyIndex;
+ QByteArray historyBuffer;
+ };
+ [[nodiscard]] WebView *createViewFromInfo(TabInformation &tab, SubWindow *parent);
+
SubWindow *m_parent;
int current = -1;
int previous = -1;