mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
jump to the URL of the clipboard content if a middle click on an empty area inside the view is done
svn path=/trunk/KDE/kdebase/apps/; revision=816421
This commit is contained in:
parent
ae0829d3b8
commit
834082a16c
|
@ -337,7 +337,11 @@ void DolphinColumnWidget::paintEvent(QPaintEvent* event)
|
|||
void DolphinColumnWidget::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
requestActivation();
|
||||
if (indexAt(event->pos()).isValid() && (event->button() == Qt::LeftButton)) {
|
||||
if (!indexAt(event->pos()).isValid()) {
|
||||
if (QApplication::mouseButtons() & Qt::MidButton) {
|
||||
m_view->m_controller->replaceUrlByClipboard();
|
||||
}
|
||||
} else if (event->button() == Qt::LeftButton) {
|
||||
// TODO: see comment in DolphinIconsView::mousePressEvent()
|
||||
setState(QAbstractItemView::DraggingState);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <kdirmodel.h>
|
||||
#include <QAbstractProxyModel>
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
|
||||
DolphinController::DolphinController(DolphinView* dolphinView) :
|
||||
QObject(dolphinView),
|
||||
|
@ -133,6 +134,16 @@ void DolphinController::handleKeyPressEvent(QKeyEvent* event)
|
|||
}
|
||||
}
|
||||
|
||||
void DolphinController::replaceUrlByClipboard()
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
const QMimeData* mimeData = clipboard->mimeData();
|
||||
if (mimeData->hasText()) {
|
||||
const QString text = mimeData->text();
|
||||
m_dolphinView->setUrl(KUrl(text));
|
||||
}
|
||||
}
|
||||
|
||||
KFileItem DolphinController::itemForIndex(const QModelIndex& index) const
|
||||
{
|
||||
Q_ASSERT(m_itemView != 0);
|
||||
|
|
|
@ -65,6 +65,7 @@ class QWidget;
|
|||
* - handleKeyPressEvent()
|
||||
* - emitItemEntered()
|
||||
* - emitViewportEntered()
|
||||
* - replaceUrlByClipboard()
|
||||
*
|
||||
* The communication of the abstract view to the view implementations is done by:
|
||||
* - setUrl()
|
||||
|
@ -212,6 +213,13 @@ public:
|
|||
*/
|
||||
void handleKeyPressEvent(QKeyEvent* event);
|
||||
|
||||
/**
|
||||
* Replaces the URL of the abstract Dolphin view with the content
|
||||
* of the clipboard as URL. If the clipboard contains no text,
|
||||
* nothing will be done.
|
||||
*/
|
||||
void replaceUrlByClipboard();
|
||||
|
||||
/**
|
||||
* Returns the file item for the proxy index \a index of the view \a view.
|
||||
*/
|
||||
|
|
|
@ -206,6 +206,10 @@ void DolphinDetailsView::mousePressEvent(QMouseEvent* event)
|
|||
}
|
||||
|
||||
if (!index.isValid() || (index.column() != DolphinModel::Name)) {
|
||||
if (QApplication::mouseButtons() & Qt::MidButton) {
|
||||
m_controller->replaceUrlByClipboard();
|
||||
}
|
||||
|
||||
const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
|
||||
if (!(modifier & Qt::ShiftModifier) && !(modifier & Qt::ControlModifier)) {
|
||||
clearSelection();
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
|
||||
#include <QAbstractProxyModel>
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
#include <QPoint>
|
||||
#include <QScrollBar>
|
||||
|
||||
DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controller) :
|
||||
|
@ -192,6 +190,9 @@ void DolphinIconsView::mousePressEvent(QMouseEvent* event)
|
|||
}
|
||||
|
||||
if (!index.isValid()) {
|
||||
if (QApplication::mouseButtons() & Qt::MidButton) {
|
||||
m_controller->replaceUrlByClipboard();
|
||||
}
|
||||
const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
|
||||
if (!(modifier & Qt::ShiftModifier) && !(modifier & Qt::ControlModifier)) {
|
||||
clearSelection();
|
||||
|
|
Loading…
Reference in a new issue