diff --git a/src/lib/webview/tabbar.h b/src/lib/webview/tabbar.h index 0e9553c6d..c03baecb4 100644 --- a/src/lib/webview/tabbar.h +++ b/src/lib/webview/tabbar.h @@ -47,6 +47,8 @@ public: void disconnectObjects(); + void wheelEvent(QWheelEvent* event); + signals: void reloadTab(int index); void stopTab(int index); @@ -82,7 +84,6 @@ private: void mousePressEvent(QMouseEvent* event); void mouseMoveEvent(QMouseEvent* event); void mouseReleaseEvent(QMouseEvent* event); - void wheelEvent(QWheelEvent* event); bool event(QEvent* event); void dragEnterEvent(QDragEnterEvent* event); diff --git a/src/lib/webview/tabwidget.cpp b/src/lib/webview/tabwidget.cpp index 89d0ebe35..254fb9cb6 100644 --- a/src/lib/webview/tabwidget.cpp +++ b/src/lib/webview/tabwidget.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include AddTabButton::AddTabButton(TabWidget* tabWidget, TabBar* tabBar) @@ -50,6 +51,25 @@ AddTabButton::AddTabButton(TabWidget* tabWidget, TabBar* tabBar) setToolTip(TabWidget::tr("New Tab")); } +void AddTabButton::wheelEvent(QWheelEvent* event) +{ + m_tabBar->wheelEvent(event); +} + +void AddTabButton::mouseReleaseEvent(QMouseEvent* event) +{ + if (event->button() == Qt::MiddleButton && rect().contains(event->pos())) { + QString selectionClipboard = QApplication::clipboard()->text(QClipboard::Selection); + QUrl guessedUrl = WebView::guessUrlFromString(selectionClipboard); + + if (!guessedUrl.isEmpty()) { + m_tabWidget->addView(guessedUrl, Qz::NT_SelectedTabAtTheEnd); + } + } + + ToolButton::mouseReleaseEvent(event); +} + void AddTabButton::dragEnterEvent(QDragEnterEvent* event) { const QMimeData* mime = event->mimeData(); diff --git a/src/lib/webview/tabwidget.h b/src/lib/webview/tabwidget.h index ee5edf566..339aa3edb 100644 --- a/src/lib/webview/tabwidget.h +++ b/src/lib/webview/tabwidget.h @@ -41,6 +41,8 @@ public: explicit AddTabButton(TabWidget* tabWidget, TabBar* tabBar); private: + void wheelEvent(QWheelEvent* event); + void mouseReleaseEvent(QMouseEvent* event); void dragEnterEvent(QDragEnterEvent* event); void dropEvent(QDropEvent* event); diff --git a/src/lib/webview/webpage.cpp b/src/lib/webview/webpage.cpp index 2ab06caed..9d5b3352f 100644 --- a/src/lib/webview/webpage.cpp +++ b/src/lib/webview/webpage.cpp @@ -384,7 +384,7 @@ bool WebPage::event(QEvent* event) // Left on left mousePos = QPoint(-1, cursorPos.y()); } - else if(cursorPos.y() > view()->height()) { + else if (cursorPos.y() > view()->height()) { // Left on bottom mousePos = QPoint(cursorPos.x(), view()->height() + 1); }