diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-03-22 17:17:15 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-03-22 18:26:37 +0530 |
| commit | 0d728071e3287a71ce7928640e63c19f4d0ab00f (patch) | |
| tree | d6e9fc90331e690dbc439e7ab8b9983df2d796a6 /src/widgets/WebViewStack.cpp | |
| parent | f09f1aa704f06472ec134b40e2f69bf3279c3f06 (diff) | |
| download | null-browser-0d728071e3287a71ce7928640e63c19f4d0ab00f.tar.gz null-browser-0d728071e3287a71ce7928640e63c19f4d0ab00f.zip | |
Build fixes + formatting
Diffstat (limited to '')
| -rw-r--r-- | src/widgets/WebViewStack.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/widgets/WebViewStack.cpp b/src/widgets/WebViewStack.cpp index f915d9e..fa5d3ab 100644 --- a/src/widgets/WebViewStack.cpp +++ b/src/widgets/WebViewStack.cpp @@ -1,11 +1,13 @@ #include <QStackedLayout> #include <QWebEngineNewWindowRequest> +#include <algorithm> +#include <vector> #include "widgets/WebViewStack.hpp" WebViewStack::WebViewStack(const Configuration *configuration, QWebEngineProfile *profile, QWidget *parent) - : QWidget(parent), profile(profile), configuration(configuration) { + : QWidget(parent), configuration(configuration), profile(profile) { layout = new QStackedLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->setStackingMode(QStackedLayout::StackOne); @@ -48,11 +50,12 @@ WebView *WebViewStack::createNewWebView(QUrl url, bool focus) { QList<Tab> WebViewStack::getTabList() { QList<Tab> urls; for (auto &view : webViewList) - urls.append((Tab){.url = view->url().toString(), .title = view->title()}); + urls.append(Tab{.url = view->url().toString(), .title = view->title()}); return urls; } -void WebViewStack::onNewWebViewRequest(QWebEngineNewWindowRequest &request) { +void WebViewStack::onNewWebViewRequest( + const QWebEngineNewWindowRequest &request) { switch (request.destination()) { case QWebEngineNewWindowRequest::InNewTab: createNewWebView(request.requestedUrl(), true); @@ -83,15 +86,15 @@ void WebViewStack::next() { void WebViewStack::previous() { if (webViewList.isEmpty()) return; - auto index = currentWebViewIndex() - 1; - auto total = webViewList.length(); + int index = ((int)currentWebViewIndex()) - 1; + qsizetype total = webViewList.length(); index = index < 0 ? total + index : index; focusWebView(index); } void WebViewStack::closeCurrent() { close(currentWebViewIndex()); } -void WebViewStack::close(long index) { +void WebViewStack::close(int32_t index) { if (index < 0 || index >= webViewList.length()) return; @@ -119,11 +122,12 @@ u_int32_t WebViewStack::currentWebViewIndex() { return layout->currentIndex(); } u_int32_t WebViewStack::count() { return webViewList.length(); } -void WebViewStack::focusWebView(long index) { +void WebViewStack::focusWebView(int32_t index) { if (webViewList.isEmpty()) return; - index = std::max((long)0, std::min(index, (long)webViewList.length() - 1)); + index = std::max((long long)0, + std::min((long long)index, webViewList.length() - 1)); layout->setCurrentIndex(index); } |
