From: Peter Penz Date: Sun, 18 Dec 2011 19:28:47 +0000 (+0100) Subject: Hide tooltips when dragging items X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/023ab306c78f305866932e6e9cbb8e96acb69493?ds=inline Hide tooltips when dragging items --- diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index 2ff8068ab..79dffd41b 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -361,6 +361,9 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const m_pressedMousePos = transform.map(event->pos()); m_pressedIndex = m_view->itemAt(m_pressedMousePos); + if (m_pressedIndex >= 0) { + emit itemPressed(m_pressedIndex, event->button()); + } if (m_view->isAboveExpansionToggle(m_pressedIndex, m_pressedMousePos)) { m_selectionManager->setCurrentItem(m_pressedIndex); @@ -527,6 +530,10 @@ bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, con return false; } + if (m_pressedIndex >= 0) { + emit itemReleased(m_pressedIndex, event->button()); + } + const bool isAboveSelectionToggle = m_view->isAboveSelectionToggle(m_pressedIndex, m_pressedMousePos); if (isAboveSelectionToggle) { m_selectionTogglePressed = false; diff --git a/src/kitemviews/kitemlistcontroller.h b/src/kitemviews/kitemlistcontroller.h index 29ab6be63..e0e8b0a9b 100644 --- a/src/kitemviews/kitemlistcontroller.h +++ b/src/kitemviews/kitemlistcontroller.h @@ -166,6 +166,17 @@ signals: */ void itemUnhovered(int index); + /** + * Is emitted if a mouse-button has been pressed above an item. + */ + void itemPressed(int index, Qt::MouseButton button); + + /** + * Is emitted if a mouse-button has been released above an item. + * It is assured that the signal itemPressed() has been emitted before. + */ + void itemReleased(int index, Qt::MouseButton button); + void itemExpansionToggleClicked(int index); /** diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index b728397f3..0edcb2894 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -146,6 +146,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : connect(controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF))); connect(controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF))); connect(controller, SIGNAL(headerContextMenuRequested(QPointF)), this, SLOT(slotHeaderContextMenuRequested(QPointF))); + connect(controller, SIGNAL(itemPressed(int,Qt::MouseButton)), this, SLOT(hideToolTip())); connect(controller, SIGNAL(itemHovered(int)), this, SLOT(slotItemHovered(int))); connect(controller, SIGNAL(itemUnhovered(int)), this, SLOT(slotItemUnhovered(int))); connect(controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*))); @@ -553,9 +554,7 @@ void DolphinView::setUrl(const KUrl& url) emit urlAboutToBeChanged(url); m_url = url; - if (GeneralSettings::showToolTips()) { - m_toolTipManager->hideToolTip(); - } + hideToolTip(); // It is important to clear the items from the model before // applying the view properties, otherwise expensive operations @@ -733,18 +732,12 @@ void DolphinView::slotItemMiddleClicked(int index) void DolphinView::slotItemContextMenuRequested(int index, const QPointF& pos) { - if (GeneralSettings::showToolTips()) { - m_toolTipManager->hideToolTip(); - } const KFileItem item = fileItemModel()->fileItem(index); emit requestContextMenu(pos.toPoint(), item, url(), QList()); } void DolphinView::slotViewContextMenuRequested(const QPointF& pos) { - if (GeneralSettings::showToolTips()) { - m_toolTipManager->hideToolTip(); - } emit requestContextMenu(pos.toPoint(), KFileItem(), url(), QList()); } @@ -802,7 +795,7 @@ void DolphinView::slotItemHovered(int index) { const KFileItem item = fileItemModel()->fileItem(index); - if (GeneralSettings::showToolTips()) { + if (GeneralSettings::showToolTips() && QApplication::mouseButtons() == Qt::NoButton) { QRectF itemRect = m_container->controller()->view()->itemContextRect(index); const QPoint pos = m_container->mapToGlobal(itemRect.topLeft().toPoint()); itemRect.moveTo(pos); @@ -816,9 +809,7 @@ void DolphinView::slotItemHovered(int index) void DolphinView::slotItemUnhovered(int index) { Q_UNUSED(index); - if (GeneralSettings::showToolTips()) { - m_toolTipManager->hideToolTip(); - } + hideToolTip(); emit requestItemInfo(KFileItem()); } @@ -1050,7 +1041,6 @@ void DolphinView::updateViewState() } } - void DolphinView::hideToolTip() { if (GeneralSettings::showToolTips()) {