#include <QScrollBar>
#include <QSize>
#include <QTimer>
+#include <QToolTip>
#include <QVBoxLayout>
DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
if (watched == m_view) {
m_dragging = false;
}
+ break;
+
+ case QEvent::ToolTip:
+ tryShowNameToolTip(event);
+
default:
break;
}
void DolphinView::hideToolTip(const ToolTipManager::HideBehavior behavior)
{
-#ifdef HAVE_BALOO
if (GeneralSettings::showToolTips()) {
+#ifdef HAVE_BALOO
m_toolTipManager->hideToolTip(behavior);
- }
#else
Q_UNUSED(behavior)
#endif
+ } else if (m_mode == DolphinView::IconsView) {
+ QToolTip::hideText();
+ }
}
void DolphinView::slotTwoClicksRenamingTimerTimeout()
m_placeholderLabel->setVisible(true);
}
+
+void DolphinView::tryShowNameToolTip(QEvent* event)
+{
+ if (!GeneralSettings::showToolTips() && m_mode == DolphinView::IconsView) {
+ QHelpEvent *hoverEvent = reinterpret_cast<QHelpEvent *>(event);
+ const std::optional<int> index = m_view->itemAt(hoverEvent->pos());
+
+ if (!index.has_value()) {
+ return;
+ }
+
+ // Check whether the filename has been elided
+ const bool isElided = m_view->isElided(index.value());
+
+ if(isElided) {
+ const KFileItem item = m_model->fileItem(index.value());
+ const QString text = item.text();
+ const QPoint pos = mapToGlobal(hoverEvent->pos());
+ QToolTip::showText(pos, text);
+ }
+ }
+}