mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +00:00
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
This commit is contained in:
parent
2ad91b4534
commit
57e3503e2f
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue