From: Peter Penz Date: Sun, 11 May 2008 20:14:50 +0000 (+0000) Subject: If the middle mouse button is pressed above an item of the places panel, open the... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/57e3503e2f7dc2528d7935226d1cd283d8278807?ds=inline If the middle mouse button is pressed above an item of the places panel, open the URL inside a new tab. svn path=/trunk/KDE/kdebase/apps/; revision=806606 --- diff --git a/src/dolphinfileplacesview.cpp b/src/dolphinfileplacesview.cpp index a4f801c3a..4165b9049 100644 --- a/src/dolphinfileplacesview.cpp +++ b/src/dolphinfileplacesview.cpp @@ -22,17 +22,26 @@ #include DolphinFilePlacesView::DolphinFilePlacesView(QWidget* parent) : - KFilePlacesView(parent) + KFilePlacesView(parent), + m_mouseButtons(Qt::NoButton) { setDropOnPlaceEnabled(true); connect(this, SIGNAL(urlsDropped(const KUrl&, QDropEvent*, QWidget*)), this, SLOT(slotUrlsDropped(const KUrl&, QDropEvent*, QWidget*))); + connect(this, SIGNAL(urlChanged(const KUrl&)), + this, SLOT(emitExtendedUrlChangedSignal(const KUrl&))); } DolphinFilePlacesView::~DolphinFilePlacesView() { } +void DolphinFilePlacesView::mousePressEvent(QMouseEvent* event) +{ + m_mouseButtons = event->buttons(); + KFilePlacesView::mousePressEvent(event); +} + void DolphinFilePlacesView::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent) { const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); @@ -44,4 +53,9 @@ void DolphinFilePlacesView::slotUrlsDropped(const KUrl& dest, QDropEvent* event, dropController.dropUrls(urls, dest); } +void DolphinFilePlacesView::emitExtendedUrlChangedSignal(const KUrl& url) +{ + emit urlChanged(url, m_mouseButtons); +} + #include "dolphinfileplacesview.moc" diff --git a/src/dolphinfileplacesview.h b/src/dolphinfileplacesview.h index 8bad0fa5f..46d574606 100644 --- a/src/dolphinfileplacesview.h +++ b/src/dolphinfileplacesview.h @@ -34,8 +34,18 @@ public: DolphinFilePlacesView(QWidget* parent); virtual ~DolphinFilePlacesView(); +signals: + void urlChanged(const KUrl& url, Qt::MouseButtons buttons); + +protected: + virtual void mousePressEvent(QMouseEvent* event); + private slots: void slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent); + void emitExtendedUrlChangedSignal(const KUrl& url); + +private: + Qt::MouseButtons m_mouseButtons; }; #endif // DOLPHINFILEPLACESVIEW_H diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index afa6ea43f..149f58b0f 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -763,6 +763,16 @@ void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos) } } +void DolphinMainWindow::handlePlacesClick(const KUrl& url, Qt::MouseButtons buttons) +{ + if (buttons & Qt::MidButton) { + openNewTab(url); + m_tabBar->setCurrentIndex(m_viewTab.count() - 1); + } else { + changeUrl(url); + } +} + void DolphinMainWindow::init() { DolphinSettings& settings = DolphinSettings::instance(); @@ -1084,8 +1094,8 @@ void DolphinMainWindow::setupDockWidgets() actionCollection()->addAction("show_places_panel", placesDock->toggleViewAction()); addDockWidget(Qt::LeftDockWidgetArea, placesDock); - connect(placesView, SIGNAL(urlChanged(KUrl)), - this, SLOT(changeUrl(KUrl))); + connect(placesView, SIGNAL(urlChanged(KUrl, Qt::MouseButtons)), + this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons))); connect(this, SIGNAL(urlChanged(KUrl)), placesView, SLOT(setUrl(KUrl))); } diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index c03e2404d..71d7b52d1 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -339,6 +339,13 @@ private slots: */ void openTabContextMenu(int index, const QPoint& pos); + /** + * Handles a click on a places item: if the middle mouse button is + * clicked, a new tab is opened for \a url, otherwise the current + * view is replaced by \a url. + */ + void handlePlacesClick(const KUrl& url, Qt::MouseButtons buttons); + private: DolphinMainWindow(int id); void init();