mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-02 14:45:04 +00:00
Start autoActivationTimer only if hovering over a directory
Before starting autoActivationTimer, check that we're hovering the item on top of a directory. If we don't check for it, the the autoActivationTimer will try to open the hovered item in it's default application, which can be distracting and break the actual action the user was trying to do, like moving the file to a directory. BUG:479960
This commit is contained in:
parent
599ddb3c0d
commit
803bbd1ae1
|
@ -352,6 +352,17 @@ bool KFileItemModel::supportsDropping(int index) const
|
||||||
return !item.isNull() && DragAndDropHelper::supportsDropping(item);
|
return !item.isNull() && DragAndDropHelper::supportsDropping(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool KFileItemModel::canEnterOnHover(int index) const
|
||||||
|
{
|
||||||
|
KFileItem item;
|
||||||
|
if (index == -1) {
|
||||||
|
item = rootItem();
|
||||||
|
} else {
|
||||||
|
item = fileItem(index);
|
||||||
|
}
|
||||||
|
return !item.isNull() && (item.isDir() || item.isDesktopFile());
|
||||||
|
}
|
||||||
|
|
||||||
QString KFileItemModel::roleDescription(const QByteArray &role) const
|
QString KFileItemModel::roleDescription(const QByteArray &role) const
|
||||||
{
|
{
|
||||||
static QHash<QByteArray, QString> description;
|
static QHash<QByteArray, QString> description;
|
||||||
|
|
|
@ -109,6 +109,8 @@ public:
|
||||||
|
|
||||||
bool supportsDropping(int index) const override;
|
bool supportsDropping(int index) const override;
|
||||||
|
|
||||||
|
bool canEnterOnHover(int index) const override;
|
||||||
|
|
||||||
QString roleDescription(const QByteArray &role) const override;
|
QString roleDescription(const QByteArray &role) const override;
|
||||||
|
|
||||||
QList<QPair<int, QVariant>> groups() const override;
|
QList<QPair<int, QVariant>> groups() const override;
|
||||||
|
|
|
@ -827,11 +827,12 @@ bool KItemListController::dragMoveEvent(QGraphicsSceneDragDropEvent *event, cons
|
||||||
Q_EMIT itemHovered(index);
|
Q_EMIT itemHovered(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_autoActivationTimer->isActive() && m_autoActivationTimer->interval() >= 0) {
|
if (!m_autoActivationTimer->isActive() && m_autoActivationTimer->interval() >= 0 && m_model->canEnterOnHover(index)) {
|
||||||
m_autoActivationTimer->setProperty("index", index);
|
m_autoActivationTimer->setProperty("index", index);
|
||||||
m_autoActivationTimer->start();
|
m_autoActivationTimer->start();
|
||||||
newHoveredWidget->startActivateSoonAnimation(m_autoActivationTimer->remainingTime());
|
newHoveredWidget->startActivateSoonAnimation(m_autoActivationTimer->remainingTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
m_autoActivationTimer->stop();
|
m_autoActivationTimer->stop();
|
||||||
if (newHoveredWidget && newHoveredWidget->isHovered()) {
|
if (newHoveredWidget && newHoveredWidget->isHovered()) {
|
||||||
|
|
|
@ -128,6 +128,12 @@ bool KItemModelBase::supportsDropping(int index) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool KItemModelBase::canEnterOnHover(int index) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(index)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QString KItemModelBase::blacklistItemDropEventMimeType() const
|
QString KItemModelBase::blacklistItemDropEventMimeType() const
|
||||||
{
|
{
|
||||||
return QStringLiteral("application/x-dolphin-blacklist-drop");
|
return QStringLiteral("application/x-dolphin-blacklist-drop");
|
||||||
|
|
|
@ -159,6 +159,15 @@ public:
|
||||||
// decision whether it accepts the drop?
|
// decision whether it accepts the drop?
|
||||||
virtual bool supportsDropping(int index) const;
|
virtual bool supportsDropping(int index) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return True, if the item with the index \a index can be entered in during hover actions.
|
||||||
|
* Per default false is returned.
|
||||||
|
*
|
||||||
|
* This is used to check that if the item
|
||||||
|
* we're hovering on is either directory or a desktop file.
|
||||||
|
*/
|
||||||
|
virtual bool canEnterOnHover(int index) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return An internal mimetype to signal that an itemDropEvent() should be rejected by
|
* @return An internal mimetype to signal that an itemDropEvent() should be rejected by
|
||||||
* the receiving model.
|
* the receiving model.
|
||||||
|
|
Loading…
Reference in a new issue