mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Hide tooltips when dragging items
This commit is contained in:
parent
eef0b72aff
commit
21c21ce1b6
3 changed files with 22 additions and 14 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<QAction*>());
|
||||
}
|
||||
|
||||
void DolphinView::slotViewContextMenuRequested(const QPointF& pos)
|
||||
{
|
||||
if (GeneralSettings::showToolTips()) {
|
||||
m_toolTipManager->hideToolTip();
|
||||
}
|
||||
emit requestContextMenu(pos.toPoint(), KFileItem(), url(), QList<QAction*>());
|
||||
}
|
||||
|
||||
|
@ -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()) {
|
||||
|
|
Loading…
Reference in a new issue