diff options
author | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2017-09-24 15:25:57 +0300 |
---|---|---|
committer | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2017-09-24 15:25:57 +0300 |
commit | f351b00075f8f8b5ef5b355b55b9572eb0cc525c (patch) | |
tree | eca6362d2e6564b87cdd464116f7480201fc0eda /src/ui | |
parent | Ctrl-Q from the main window quits the application (#69) (diff) | |
download | nheko-f351b00075f8f8b5ef5b355b55b9572eb0cc525c.tar.xz |
Manually remove KDE accelerators
fixes #14
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/FlatButton.cc | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/ui/FlatButton.cc b/src/ui/FlatButton.cc index 4ba92a38..f2314078 100644 --- a/src/ui/FlatButton.cc +++ b/src/ui/FlatButton.cc @@ -11,6 +11,21 @@ #include "RippleOverlay.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 FlatButton::init() { @@ -327,7 +342,7 @@ FlatButton::sizeHint() const { ensurePolished(); - QSize label(fontMetrics().size(Qt::TextSingleLine, text())); + QSize label(fontMetrics().size(Qt::TextSingleLine, removeKDEAccelerators(text()))); int w = 20 + label.width(); int h = label.height(); @@ -500,11 +515,11 @@ FlatButton::paintForeground(QPainter *painter) } if (icon().isNull()) { - painter->drawText(rect(), Qt::AlignCenter, text()); + painter->drawText(rect(), Qt::AlignCenter, removeKDEAccelerators(text())); return; } - QSize textSize(fontMetrics().size(Qt::TextSingleLine, text())); + QSize textSize(fontMetrics().size(Qt::TextSingleLine, removeKDEAccelerators(text()))); QSize base(size() - textSize); const int iw = iconSize().width() + IconPadding; @@ -519,7 +534,7 @@ FlatButton::paintForeground(QPainter *painter) /* iconGeometry.translate(textSize.width() + IconPadding, 0); */ /* } */ - painter->drawText(textGeometry, Qt::AlignCenter, text()); + painter->drawText(textGeometry, Qt::AlignCenter, removeKDEAccelerators(text())); QPixmap pixmap = icon().pixmap(iconSize()); QPainter icon(&pixmap); |