Commit 906b97b4 authored by Felix Ernst's avatar Felix Ernst 🇺🇦
Browse files

Show keyboard shortcuts in tooltips only once not twice

The tools on the left bar of Kolourpaint show their respective
keyboard shortcuts in their tooltips.

There was a change in KDE frameworks
(https://commits.kde.org/kxmlgui/ecd7cefd8d4b8ddb15b8e3a3e6e9bd5c55a9c12c)
that made it so all tooltips of actions show their keyboard
shortcuts in their tooltips by default.

Together this meant that the keyboard shortcut is shown twice.
This commit fixes this by removing the Kolourpaint-specific code
to show the keyboard shortcut in the tooltip.

BUG: 456888
parent 8b6d4d1b
......@@ -108,8 +108,6 @@ void kpTool::initAction ()
d->action->setActionGroup(d->environ->toolsActionGroup ());
d->action->setWhatsThis(d->description);
connect (d->action, &kpToolAction::changed, this, &kpTool::actionToolTipChanged);
}
//---------------------------------------------------------------------
......@@ -120,37 +118,6 @@ QString kpTool::text () const
return d->text;
}
//---------------------------------------------------------------------
static bool KeyIsText (int key)
{
// TODO: should work like !QKeyEvent::text().isEmpty()
return !(static_cast<unsigned int> (key) & (Qt::KeyboardModifierMask ^ Qt::ShiftModifier));
}
//---------------------------------------------------------------------
// public static
QString kpTool::toolTipForTextAndShortcut (const QString &text,
const QList<QKeySequence> &shortcut)
{
for(const auto &seq : shortcut)
{
if (seq.count () == 1 && ::KeyIsText (seq [0])) {
return i18nc ("<Tool Name> (<Single Accel Key>)", "%1 (%2)", text, seq.toString ().toUpper ());
}
}
return text;
}
//---------------------------------------------------------------------
QString kpTool::toolTip () const
{
return toolTipForTextAndShortcut(d->text, d->action->shortcuts());
}
//---------------------------------------------------------------------
// public static
......
......@@ -87,9 +87,6 @@ public:
QString text () const;
static QString toolTipForTextAndShortcut (const QString &text, const QList<QKeySequence> &shortcut);
QString toolTip () const;
// Given a single <key>, returns a shortcut with <key>
// (disabled when the user is editing text) and as an alternate,
// <some modifiers>+<key>.
......@@ -121,9 +118,6 @@ private:
// Only called by ctor to create action().
void initAction ();
signals:
void actionToolTipChanged();
public slots:
// Call this when something below the mouse cursor may have changed
// and/or if the view has moved relative to the cursor (as opposed to
......
......@@ -45,26 +45,8 @@ kpToolAction::kpToolAction(const QString &text,
connect (this, SIGNAL(triggered(bool)), receiver, slot);
}
updateToolTip();
connect (this, &kpToolAction::changed, this, &kpToolAction::updateToolTip);
ac->addAction(name, this);
}
//---------------------------------------------------------------------
// protected
void kpToolAction::updateToolTip()
{
const QString newToolTip =
kpTool::toolTipForTextAndShortcut(text(), shortcuts()).remove(QLatin1Char('&'));
if ( newToolTip == toolTip() ) {
return;
}
setToolTip(newToolTip);
}
//---------------------------------------------------------------------
......@@ -44,9 +44,6 @@ class kpToolAction : public KToggleAction
const QString &pic, const QList<QKeySequence> &shortcut,
const QObject *receiver, const char *slot,
KActionCollection *ac, const QString &name);
private slots:
void updateToolTip();
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment