diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -87,6 +87,7 @@ add_executable(${PROGRAM_NAME} WIN32
commandwidget.cpp
commandedit.cpp
dataformatpanel.cpp
+ tooltipfilter.cpp
${UI_FILES}
${RES_FILES}
misc/windows_icon.rc
diff --git a/main.cpp b/main.cpp
--- a/main.cpp
+++ b/main.cpp
@@ -17,12 +17,14 @@
along with serialplot. If not, see .
*/
-#include "mainwindow.h"
#include
#include
+#include "mainwindow.h"
+#include "tooltipfilter.h"
#include "version.h"
+
MainWindow* pMainWindow;
void messageHandler(QtMsgType type, const QMessageLogContext &context,
@@ -40,6 +42,9 @@ int main(int argc, char *argv[])
qInstallMessageHandler(messageHandler);
+ ToolTipFilter ttf;
+ a.installEventFilter(&ttf);
+
// log application information
qDebug() << "SerialPlot" << VERSION_STRING;
qDebug() << "Revision" << VERSION_REVISION;
diff --git a/tooltipfilter.cpp b/tooltipfilter.cpp
new file mode 100644
--- /dev/null
+++ b/tooltipfilter.cpp
@@ -0,0 +1,54 @@
+/*
+ Copyright © 2015 Hasan Yavuz Özderya
+
+ This file is part of serialplot.
+
+ serialplot is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ serialplot is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with serialplot. If not, see .
+*/
+
+#include
+#include
+#include
+#include
+#include
+
+#include "tooltipfilter.h"
+
+bool ToolTipFilter::eventFilter(QObject *obj, QEvent *ev)
+{
+ if (ev->type() == QEvent::ToolTip && obj->inherits("QToolButton"))
+ {
+ // prepare tooltip message
+ QToolButton* toolButton = (QToolButton*) obj;
+ QAction* action = toolButton->defaultAction();
+ QString toolTip = action->toolTip();
+
+ if (toolTip.isEmpty()) return false;
+
+ QKeySequence keys = action->shortcut();
+ if (!keys.isEmpty())
+ {
+ toolTip += QString(" [") + keys.toString() + "]";
+ }
+
+ // show tooltip message
+ QHelpEvent *helpEvent = static_cast(ev);
+ QToolTip::showText(helpEvent->globalPos(), toolTip);
+ return true;
+ }
+ else
+ {
+ return QObject::eventFilter(obj, ev);
+ }
+}
diff --git a/tooltipfilter.h b/tooltipfilter.h
new file mode 100644
--- /dev/null
+++ b/tooltipfilter.h
@@ -0,0 +1,32 @@
+/*
+ Copyright © 2015 Hasan Yavuz Özderya
+
+ This file is part of serialplot.
+
+ serialplot is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ serialplot is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with serialplot. If not, see .
+*/
+
+#ifndef TOOLTIPFILTER_H
+#define TOOLTIPFILTER_H
+
+#include
+#include
+
+class ToolTipFilter : public QObject
+{
+protected:
+ bool eventFilter(QObject *obj, QEvent *ev);
+};
+
+#endif /* TOOLTIPFILTER_H */