1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

AddTab button: Middle click opens tab with text/url from X11 clipboard

This commit is contained in:
nowrep 2012-05-27 12:44:56 +02:00
parent 033bfa246b
commit 07e4b7d559
4 changed files with 25 additions and 2 deletions

View File

@ -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);

View File

@ -36,6 +36,7 @@
#include <QMenu>
#include <QStackedWidget>
#include <QWebHistory>
#include <QClipboard>
#include <QFile>
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();

View File

@ -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);

View File

@ -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);
}