From 1c31749fd642a23f853612795d88b015df16827b Mon Sep 17 00:00:00 2001 From: "James C. Owens" Date: Fri, 13 Dec 2019 21:25:04 -0500 Subject: [PATCH] Implements a global event filter to suppress help question mark --- src/qt/bitcoin.cpp | 3 +++ src/qt/guiutil.cpp | 19 +++++++++++++++++++ src/qt/guiutil.h | 18 ++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index f92658cdda..5eeec57892 100755 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -329,6 +329,9 @@ int StartGridcoinQt(int argc, char *argv[]) // Install global event filter that makes sure that long tooltips can be word-wrapped app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app)); + // Install global event filter that suppresses help context question mark + app.installEventFilter(new GUIUtil::WindowContextHelpButtonHintFilter(&app)); + #if QT_VERSION < 0x050000 // Install qDebug() message handler to route to debug.log qInstallMsgHandler(DebugMessageHandler); diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index e5ee652fc5..60c53c1ff7 100755 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -357,6 +357,25 @@ bool ToolTipToRichTextFilter::eventFilter(QObject *obj, QEvent *evt) return QObject::eventFilter(obj, evt); } +WindowContextHelpButtonHintFilter::WindowContextHelpButtonHintFilter(QObject *parent) : + QObject(parent) +{ + +} + +bool WindowContextHelpButtonHintFilter::eventFilter (QObject *obj, QEvent *event) +{ + if (event->type () == QEvent::Create) + { + if (obj->isWidgetType ()) + { + auto w = static_cast (obj); + w->setWindowFlags (w->windowFlags () & (~Qt::WindowContextHelpButtonHint)); + } + } + return QObject::eventFilter (obj, event); +} + #ifdef WIN32 boost::filesystem::path static StartupShortcutPath() { diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index e67bf41261..6416261483 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -109,6 +109,24 @@ namespace GUIUtil int size_threshold; }; + /** Qt event filter that suppress context help question mark for all windows. + */ + + class WindowContextHelpButtonHintFilter : public QObject + { + Q_OBJECT + + public: + explicit WindowContextHelpButtonHintFilter(QObject *parent = 0); + + protected: + bool eventFilter(QObject *obj, QEvent *evt); + + private: + int size_threshold; + }; + + bool GetStartOnSystemStartup(); bool SetStartOnSystemStartup(bool fAutoStart);