Manually remove KDE accelerators

fixes #14
This commit is contained in:
Konstantinos Sideris 2017-09-24 15:25:57 +03:00
parent b1214a9ae8
commit f351b00075

View file

@ -11,6 +11,21 @@
#include "RippleOverlay.h" #include "RippleOverlay.h"
#include "ThemeManager.h" #include "ThemeManager.h"
// The ampersand is automatically set in QPushButton or QCheckbx
// by KDEPlatformTheme plugin in Qt5. [https://bugs.kde.org/show_bug.cgi?id=337491]
//
// A workaroud is to add
//
// [Development]
// AutoCheckAccelerators=false
//
// to ~/.config/kdeglobals
static QString
removeKDEAccelerators(QString text)
{
return text.remove(QChar('&'));
}
void void
FlatButton::init() FlatButton::init()
{ {
@ -327,7 +342,7 @@ FlatButton::sizeHint() const
{ {
ensurePolished(); ensurePolished();
QSize label(fontMetrics().size(Qt::TextSingleLine, text())); QSize label(fontMetrics().size(Qt::TextSingleLine, removeKDEAccelerators(text())));
int w = 20 + label.width(); int w = 20 + label.width();
int h = label.height(); int h = label.height();
@ -500,11 +515,11 @@ FlatButton::paintForeground(QPainter *painter)
} }
if (icon().isNull()) { if (icon().isNull()) {
painter->drawText(rect(), Qt::AlignCenter, text()); painter->drawText(rect(), Qt::AlignCenter, removeKDEAccelerators(text()));
return; return;
} }
QSize textSize(fontMetrics().size(Qt::TextSingleLine, text())); QSize textSize(fontMetrics().size(Qt::TextSingleLine, removeKDEAccelerators(text())));
QSize base(size() - textSize); QSize base(size() - textSize);
const int iw = iconSize().width() + IconPadding; const int iw = iconSize().width() + IconPadding;
@ -519,7 +534,7 @@ FlatButton::paintForeground(QPainter *painter)
/* iconGeometry.translate(textSize.width() + IconPadding, 0); */ /* iconGeometry.translate(textSize.width() + IconPadding, 0); */
/* } */ /* } */
painter->drawText(textGeometry, Qt::AlignCenter, text()); painter->drawText(textGeometry, Qt::AlignCenter, removeKDEAccelerators(text()));
QPixmap pixmap = icon().pixmap(iconSize()); QPixmap pixmap = icon().pixmap(iconSize());
QPainter icon(&pixmap); QPainter icon(&pixmap);