Merge pull request #6917 from spycrab/qt_mpbtn_size

Qt/MappingButton: Enforce more consistent size
This commit is contained in:
spycrab 2018-05-20 21:27:41 +02:00 committed by GitHub
commit 8af8c58eb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 4 deletions

View File

@ -4,6 +4,8 @@
#include <thread> #include <thread>
#include <QApplication>
#include <QFontMetrics>
#include <QMouseEvent> #include <QMouseEvent>
#include <QRegExp> #include <QRegExp>
#include <QString> #include <QString>
@ -27,6 +29,7 @@
#include "InputCommon/ControllerInterface/Device.h" #include "InputCommon/ControllerInterface/Device.h"
constexpr int SLIDER_TICK_COUNT = 100; constexpr int SLIDER_TICK_COUNT = 100;
constexpr int VERTICAL_PADDING = 2;
static QString EscapeAmpersand(QString&& string) static QString EscapeAmpersand(QString&& string)
{ {
@ -42,6 +45,17 @@ MappingButton::MappingButton(MappingWidget* widget, ControlReference* ref, bool
: ElidedButton(EscapeAmpersand(QString::fromStdString(ref->GetExpression()))), m_parent(widget), : ElidedButton(EscapeAmpersand(QString::fromStdString(ref->GetExpression()))), m_parent(widget),
m_reference(ref) m_reference(ref)
{ {
// Force all mapping buttons to use stay at a minimal height
int height = QFontMetrics(qApp->font()).height() + 2 * VERTICAL_PADDING;
setMinimumHeight(height);
setMaximumHeight(height);
// Make sure that long entries don't throw our layout out of whack
setMaximumWidth(115);
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
Connect(); Connect();
setToolTip( setToolTip(
tr("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options.")); tr("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options."));
@ -76,10 +90,6 @@ MappingButton::MappingButton(MappingWidget* widget, ControlReference* ref, bool
}); });
m_timer->start(1000 / 30); m_timer->start(1000 / 30);
setMaximumHeight(24);
setMaximumWidth(200);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
} }
void MappingButton::Connect() void MappingButton::Connect()