From 5b8d64b0b5e5b3aa1edac7a98be6cbf471869dd0 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 27 Jan 2021 21:23:45 -0800 Subject: [PATCH] Qt: Better initial shortcut editor column sizes --- CHANGES | 1 + src/platform/qt/ShortcutView.cpp | 10 ++++++++++ src/platform/qt/ShortcutView.h | 1 + src/platform/qt/ShortcutView.ui | 3 +++ 4 files changed, 15 insertions(+) diff --git a/CHANGES b/CHANGES index 8623265ce..e0c8e9eec 100644 --- a/CHANGES +++ b/CHANGES @@ -124,6 +124,7 @@ Misc: - Qt: Unify monospace font usage - Qt: Add button to jump to log settings - Qt: Use relative paths in portable mode when applicable (fixes mgba.io/i/838) + - Qt: Better initial shortcut editor column sizes - SDL: Fall back to sw blit if OpenGL init fails - Util: Reset vector size on deinit - VFS: Change semantics of VFile.sync on mapped files (fixes mgba.io/i/1730) diff --git a/src/platform/qt/ShortcutView.cpp b/src/platform/qt/ShortcutView.cpp index cf0826006..badd7d5af 100644 --- a/src/platform/qt/ShortcutView.cpp +++ b/src/platform/qt/ShortcutView.cpp @@ -10,6 +10,7 @@ #include "ShortcutController.h" #include "ShortcutModel.h" +#include #include using namespace QGBA; @@ -134,6 +135,15 @@ void ShortcutView::closeEvent(QCloseEvent*) { } } +void ShortcutView::showEvent(QShowEvent*) { + QString longString("Ctrl+Alt+Shift+Tab"); + int width = QFontMetrics(QFont()).width(longString); + QHeaderView* header = m_ui.shortcutTable->header(); + header->resizeSection(0, header->length() - width * 2); + header->resizeSection(1, width); + header->resizeSection(2, width); +} + bool ShortcutView::event(QEvent* event) { if (m_input) { QEvent::Type type = event->type(); diff --git a/src/platform/qt/ShortcutView.h b/src/platform/qt/ShortcutView.h index 340541640..903d365c8 100644 --- a/src/platform/qt/ShortcutView.h +++ b/src/platform/qt/ShortcutView.h @@ -30,6 +30,7 @@ public: protected: virtual bool event(QEvent*) override; virtual void closeEvent(QCloseEvent*) override; + virtual void showEvent(QShowEvent*) override; private slots: void load(const QModelIndex&); diff --git a/src/platform/qt/ShortcutView.ui b/src/platform/qt/ShortcutView.ui index 8b28e4d52..aa20f9a2e 100644 --- a/src/platform/qt/ShortcutView.ui +++ b/src/platform/qt/ShortcutView.ui @@ -16,6 +16,9 @@ + + Qt::ScrollBarAlwaysOn + 120