mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +00:00
Don't reinterpret_cast QEvent
We know that we'll be a `QHelpEvent` from `QEvent::ToolTip`, so do a static_cast from the event handler (where it's obvious from context), and then pass it along to `tryShowNameToolTip`.
This commit is contained in:
parent
f3a0986b8b
commit
5ebc6b865d
|
@ -925,7 +925,7 @@ bool DolphinView::eventFilter(QObject* watched, QEvent* event)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QEvent::ToolTip:
|
case QEvent::ToolTip:
|
||||||
tryShowNameToolTip(event);
|
tryShowNameToolTip(static_cast<QHelpEvent*>(event));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -2196,11 +2196,10 @@ void DolphinView::updatePlaceholderLabel()
|
||||||
m_placeholderLabel->setVisible(true);
|
m_placeholderLabel->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::tryShowNameToolTip(QEvent* event)
|
void DolphinView::tryShowNameToolTip(QHelpEvent* event)
|
||||||
{
|
{
|
||||||
if (!GeneralSettings::showToolTips() && m_mode == DolphinView::IconsView) {
|
if (!GeneralSettings::showToolTips() && m_mode == DolphinView::IconsView) {
|
||||||
QHelpEvent *hoverEvent = reinterpret_cast<QHelpEvent *>(event);
|
const std::optional<int> index = m_view->itemAt(event->pos());
|
||||||
const std::optional<int> index = m_view->itemAt(hoverEvent->pos());
|
|
||||||
|
|
||||||
if (!index.has_value()) {
|
if (!index.has_value()) {
|
||||||
return;
|
return;
|
||||||
|
@ -2212,7 +2211,7 @@ void DolphinView::tryShowNameToolTip(QEvent* event)
|
||||||
if(isElided) {
|
if(isElided) {
|
||||||
const KFileItem item = m_model->fileItem(index.value());
|
const KFileItem item = m_model->fileItem(index.value());
|
||||||
const QString text = item.text();
|
const QString text = item.text();
|
||||||
const QPoint pos = mapToGlobal(hoverEvent->pos());
|
const QPoint pos = mapToGlobal(event->pos());
|
||||||
QToolTip::showText(pos, text);
|
QToolTip::showText(pos, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ class VersionControlObserver;
|
||||||
class ViewProperties;
|
class ViewProperties;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QGraphicsSceneDragDropEvent;
|
class QGraphicsSceneDragDropEvent;
|
||||||
|
class QHelpEvent;
|
||||||
class QRegularExpression;
|
class QRegularExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -862,7 +863,7 @@ private:
|
||||||
|
|
||||||
void updatePlaceholderLabel();
|
void updatePlaceholderLabel();
|
||||||
|
|
||||||
void tryShowNameToolTip(QEvent* event);
|
void tryShowNameToolTip(QHelpEvent* event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updatePalette();
|
void updatePalette();
|
||||||
|
|
Loading…
Reference in a new issue