aboutsummaryrefslogtreecommitdiff
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/widgets/MainWindow.cpp2
-rw-r--r--src/widgets/WebViewStack.cpp20
-rw-r--r--src/widgets/WebViewStack.hpp8
3 files changed, 17 insertions, 13 deletions
diff --git a/src/widgets/MainWindow.cpp b/src/widgets/MainWindow.cpp
index ca572e7..ce03bce 100644
--- a/src/widgets/MainWindow.cpp
+++ b/src/widgets/MainWindow.cpp
@@ -73,7 +73,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event) {
}
}
-bool MainWindow::eventFilter(QObject *object, QEvent *event) {
+bool MainWindow::eventFilter(QObject *, QEvent *event) {
if (event->type() != QEvent::KeyPress)
return false;
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);
}
diff --git a/src/widgets/WebViewStack.hpp b/src/widgets/WebViewStack.hpp
index e5b7ecc..473f699 100644
--- a/src/widgets/WebViewStack.hpp
+++ b/src/widgets/WebViewStack.hpp
@@ -2,7 +2,7 @@
#include <QStackedLayout>
#include <QWebEngineProfile>
-#include <sys/types.h>
+#include <vector>
#include "Configuration.hpp"
#include "widgets/WebView.hpp"
@@ -33,11 +33,11 @@ public:
u_int32_t count();
QUrl currentUrl();
- void focusWebView(long index);
+ void focusWebView(int32_t index);
void next();
void previous();
- void close(long index);
+ void close(int32_t index);
void closeCurrent();
private:
@@ -45,7 +45,7 @@ private:
WebView *createNewWebView(QUrl url, bool focus = false);
private slots:
- void onNewWebViewRequest(QWebEngineNewWindowRequest &request);
+ void onNewWebViewRequest(const QWebEngineNewWindowRequest &request);
private:
const Configuration *configuration;