┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2008-05-11 20:14:50 +0000
committerPeter Penz <[email protected]>2008-05-11 20:14:50 +0000
commit57e3503e2f7dc2528d7935226d1cd283d8278807 (patch)
treef5b6d8bdbe7402e719391c2595fd43deb5451bfa /src
parent2ad91b45342ddd49854ae2b31a9c6cada1ad1c4e (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/dolphinfileplacesview.cpp16
-rw-r--r--src/dolphinfileplacesview.h10
-rw-r--r--src/dolphinmainwindow.cpp14
-rw-r--r--src/dolphinmainwindow.h7
4 files changed, 44 insertions, 3 deletions
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 <konq_operations.h>
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();