diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/BrowserManager.hpp | 39 | ||||
| -rw-r--r-- | include/MainWindow.hpp | 6 |
2 files changed, 43 insertions, 2 deletions
diff --git a/include/BrowserManager.hpp b/include/BrowserManager.hpp new file mode 100644 index 0000000..84d6f6a --- /dev/null +++ b/include/BrowserManager.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include <QStackedLayout> +#include <QWebEngineProfile> +#include <QWebEngineView> +#include <sys/types.h> + +class BrowserManager : public QWidget { + Q_OBJECT + +public: + inline static const QUrl NewtabURL = QUrl("about:blank"); + +public: + BrowserManager(QWebEngineProfile *profile = new QWebEngineProfile); + + QUrl currentUrl(); + void setCurrentUrl(QUrl url); + + QWebEngineView *createNewWebView(QUrl url = BrowserManager::NewtabURL, + bool focus = false); + + std::vector<QUrl> webViewUrls(); + u_int32_t currentWebViewIndex(); + u_int32_t webViewCount(); + void focusWebView(long index); + void nextWebView(); + void previousWebView(); + + void closeWebView(long index); + void closeCurrentWebView(); + + void onNewWebViewRequest(QWebEngineNewWindowRequest &request); + +private: + QWebEngineProfile *profile; + QStackedLayout *layout; + QList<QWebEngineView *> webViewList; +}; diff --git a/include/MainWindow.hpp b/include/MainWindow.hpp index 552aa25..fde3178 100644 --- a/include/MainWindow.hpp +++ b/include/MainWindow.hpp @@ -4,6 +4,7 @@ #include <QObject> #include <QWebEngineView> +#include "BrowserManager.hpp" #include "CommandInput.hpp" class MainWindow : public QMainWindow { @@ -14,9 +15,10 @@ protected: void keyPressEvent(QKeyEvent *event) override; void toggleURLInput(); void evaluateCommand(QString command); - void hideInput(); + void hideURLInput(); + void showURLInput(); private: - QWebEngineView *web; + BrowserManager *browserManager; CommandInput *commandInput; }; |
