mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 20:32:35 -03:00
qt: Get rid of cursor in out-of-focus labels
This change is a temporary fix of QTBUG-59514.
This commit is contained in:
parent
374fd6fc8b
commit
bd315eb5e2
3 changed files with 39 additions and 0 deletions
|
@ -556,6 +556,8 @@ int GuiMain(int argc, char* argv[])
|
||||||
/// 9. Main GUI initialization
|
/// 9. Main GUI initialization
|
||||||
// Install global event filter that makes sure that long tooltips can be word-wrapped
|
// Install global event filter that makes sure that long tooltips can be word-wrapped
|
||||||
app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
|
app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
|
||||||
|
// Install global event filter that makes sure that out-of-focus labels do not contain text cursor.
|
||||||
|
app.installEventFilter(new GUIUtil::LabelOutOfFocusEventFilter(&app));
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
// Install global event filter for processing Windows session related Windows messages (WM_QUERYENDSESSION and WM_ENDSESSION)
|
// Install global event filter for processing Windows session related Windows messages (WM_QUERYENDSESSION and WM_ENDSESSION)
|
||||||
qApp->installNativeEventFilter(new WinShutdownMonitor());
|
qApp->installNativeEventFilter(new WinShutdownMonitor());
|
||||||
|
|
|
@ -450,6 +450,28 @@ bool ToolTipToRichTextFilter::eventFilter(QObject *obj, QEvent *evt)
|
||||||
return QObject::eventFilter(obj, evt);
|
return QObject::eventFilter(obj, evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LabelOutOfFocusEventFilter::LabelOutOfFocusEventFilter(QObject* parent)
|
||||||
|
: QObject(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LabelOutOfFocusEventFilter::eventFilter(QObject* watched, QEvent* event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::FocusOut) {
|
||||||
|
auto focus_out = static_cast<QFocusEvent*>(event);
|
||||||
|
if (focus_out->reason() != Qt::PopupFocusReason) {
|
||||||
|
auto label = qobject_cast<QLabel*>(watched);
|
||||||
|
if (label) {
|
||||||
|
auto flags = label->textInteractionFlags();
|
||||||
|
label->setTextInteractionFlags(Qt::NoTextInteraction);
|
||||||
|
label->setTextInteractionFlags(flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QObject::eventFilter(watched, event);
|
||||||
|
}
|
||||||
|
|
||||||
void TableViewLastColumnResizingFixer::connectViewHeadersSignals()
|
void TableViewLastColumnResizingFixer::connectViewHeadersSignals()
|
||||||
{
|
{
|
||||||
connect(tableView->horizontalHeader(), &QHeaderView::sectionResized, this, &TableViewLastColumnResizingFixer::on_sectionResized);
|
connect(tableView->horizontalHeader(), &QHeaderView::sectionResized, this, &TableViewLastColumnResizingFixer::on_sectionResized);
|
||||||
|
|
|
@ -161,6 +161,21 @@ namespace GUIUtil
|
||||||
int size_threshold;
|
int size_threshold;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Qt event filter that intercepts QEvent::FocusOut events for QLabel objects, and
|
||||||
|
* resets their `textInteractionFlags' property to get rid of the visible cursor.
|
||||||
|
*
|
||||||
|
* This is a temporary fix of QTBUG-59514.
|
||||||
|
*/
|
||||||
|
class LabelOutOfFocusEventFilter : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit LabelOutOfFocusEventFilter(QObject* parent);
|
||||||
|
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a QTableView last column feel as if it was being resized from its left border.
|
* Makes a QTableView last column feel as if it was being resized from its left border.
|
||||||
* Also makes sure the column widths are never larger than the table's viewport.
|
* Also makes sure the column widths are never larger than the table's viewport.
|
||||||
|
|
Loading…
Reference in a new issue