summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Haumann <dhaumann@kde.org>2014-01-23 00:16:13 (GMT)
committerDominik Haumann <dhaumann@kde.org>2014-01-23 00:16:13 (GMT)
commit50b12866e5115b8886fc8def0e4cd8453c7816a2 (patch)
tree19e3b80adff1d9f563cad86cb4eba1f8c741cd67
parent81ecf94bcb5964cd6eec21a84aa69669c3513488 (diff)
show short cut in tool tips
Now, hovering over a tool button will also show the short cut, example: "Quick Open (Ctrl+Alt+O)" Would be cool, if that is the default in Qt... Something like: QAction::setShowShortcutInToolTip(bool)
-rw-r--r--kate/app/kateviewspace.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/kate/app/kateviewspace.cpp b/kate/app/kateviewspace.cpp
index f526ad8..746cac8 100644
--- a/kate/app/kateviewspace.cpp
+++ b/kate/app/kateviewspace.cpp
@@ -36,6 +36,8 @@
#include <QToolButton>
#include <QMouseEvent>
#include <QStackedWidget>
+#include <QHelpEvent>
+#include <QToolTip>
//BEGIN KateViewSpace
KateViewSpace::KateViewSpace( KateViewManager *viewManager,
@@ -50,6 +52,8 @@ KateViewSpace::KateViewSpace( KateViewManager *viewManager,
//BEGIN tab bar
QHBoxLayout * hLayout = new QHBoxLayout();
+ hLayout->setSpacing(0);
+ hLayout->setMargin(0);
// add tab bar
m_tabBar = new KateTabBar(this);
@@ -99,7 +103,20 @@ KateViewSpace::~KateViewSpace()
bool KateViewSpace::eventFilter(QObject *obj, QEvent *event)
{
- if (! isActiveSpace() && qobject_cast<QToolButton*>(obj) && event->type() == QEvent::MouseButtonPress) {
+ QToolButton * button = qobject_cast<QToolButton*>(obj);
+
+ // maybe a tool tip of a QToolButton: show shortcuts
+ if (button && event->type() == QEvent::ToolTip) {
+ QHelpEvent * e = static_cast<QHelpEvent *>(event);
+ if (button->defaultAction()) {
+ QToolTip::showText(e->globalPos(),
+ button->toolTip() + QStringLiteral(" (%1)").arg(button->defaultAction()->shortcut().toString()), button);
+ return true;
+ }
+ }
+
+ // on mouse press on view space bar tool buttons: activate this space
+ if (button && ! isActiveSpace() && event->type() == QEvent::MouseButtonPress) {
m_viewManager->setActiveSpace(this);
m_viewManager->activateView(currentView()->document());
}