Qt: Better initial shortcut editor column sizes

This commit is contained in:
Vicki Pfau 2021-01-27 21:23:45 -08:00
parent b1a06ed52b
commit 5b8d64b0b5
4 changed files with 15 additions and 0 deletions

View File

@ -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)

View File

@ -10,6 +10,7 @@
#include "ShortcutController.h"
#include "ShortcutModel.h"
#include <QFontMetrics>
#include <QKeyEvent>
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();

View File

@ -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&);

View File

@ -16,6 +16,9 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTreeView" name="shortcutTable">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<attribute name="headerDefaultSectionSize">
<number>120</number>
</attribute>