Qt: Various layout fixes

This commit is contained in:
spycrab 2018-03-18 00:06:44 +01:00
parent 7465906a0f
commit 1b06e66f1d
5 changed files with 21 additions and 17 deletions

View File

@ -43,7 +43,7 @@ void GraphicsWindow::CreateMainLayout()
m_button_box = new QDialogButtonBox(QDialogButtonBox::Ok); m_button_box = new QDialogButtonBox(QDialogButtonBox::Ok);
description_box->setLayout(description_layout); description_box->setLayout(description_layout);
description_box->setMinimumHeight(230); description_box->setFixedHeight(230);
m_description->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_description->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_description->setWordWrap(true); m_description->setWordWrap(true);
@ -68,14 +68,15 @@ void GraphicsWindow::CreateMainLayout()
if (SConfig::GetInstance().m_strVideoBackend != "Software Renderer") if (SConfig::GetInstance().m_strVideoBackend != "Software Renderer")
{ {
m_tab_widget->addTab(GetWrappedWidget(m_general_widget, this, 250), tr("General")); m_tab_widget->addTab(GetWrappedWidget(m_general_widget, this, 50, 325), tr("General"));
m_tab_widget->addTab(GetWrappedWidget(m_enhancements_widget, this, 250), tr("Enhancements")); m_tab_widget->addTab(GetWrappedWidget(m_enhancements_widget, this, 50, 325),
m_tab_widget->addTab(GetWrappedWidget(m_hacks_widget, this, 250), tr("Hacks")); tr("Enhancements"));
m_tab_widget->addTab(GetWrappedWidget(m_advanced_widget, this, 250), tr("Advanced")); m_tab_widget->addTab(GetWrappedWidget(m_hacks_widget, this, 50, 325), tr("Hacks"));
m_tab_widget->addTab(GetWrappedWidget(m_advanced_widget, this, 50, 325), tr("Advanced"));
} }
else else
{ {
m_tab_widget->addTab(GetWrappedWidget(m_software_renderer, this, 250), tr("Software Renderer")); m_tab_widget->addTab(GetWrappedWidget(m_software_renderer, this, 325), tr("Software Renderer"));
} }
setLayout(main_layout); setLayout(main_layout);

View File

@ -313,7 +313,7 @@ void MappingWindow::SetMappingType(MappingWindow::Type type)
void MappingWindow::AddWidget(const QString& name, QWidget* widget) void MappingWindow::AddWidget(const QString& name, QWidget* widget)
{ {
m_tab_widget->addTab(GetWrappedWidget(widget, this, 150), name); m_tab_widget->addTab(GetWrappedWidget(widget, this, 150, 150), name);
} }
int MappingWindow::GetPort() const int MappingWindow::GetPort() const

View File

@ -38,16 +38,16 @@ PropertiesDialog::PropertiesDialog(QWidget* parent, const UICommon::GameFile& ga
connect(ar, &ARCodeWidget::OpenGeneralSettings, this, &PropertiesDialog::OpenGeneralSettings); connect(ar, &ARCodeWidget::OpenGeneralSettings, this, &PropertiesDialog::OpenGeneralSettings);
tab_widget->addTab(GetWrappedWidget(game_config, this), tr("Game Config")); tab_widget->addTab(GetWrappedWidget(game_config, this, 50, 80), tr("Game Config"));
tab_widget->addTab(GetWrappedWidget(patches, this), tr("Patches")); tab_widget->addTab(GetWrappedWidget(patches, this, 50, 80), tr("Patches"));
tab_widget->addTab(GetWrappedWidget(ar, this), tr("AR Codes")); tab_widget->addTab(GetWrappedWidget(ar, this, 50, 80), tr("AR Codes"));
tab_widget->addTab(GetWrappedWidget(gecko, this), tr("Gecko Codes")); tab_widget->addTab(GetWrappedWidget(gecko, this, 50, 80), tr("Gecko Codes"));
tab_widget->addTab(GetWrappedWidget(info, this), tr("Info")); tab_widget->addTab(GetWrappedWidget(info, this, 50, 80), tr("Info"));
if (DiscIO::IsDisc(game.GetPlatform())) if (DiscIO::IsDisc(game.GetPlatform()))
{ {
FilesystemWidget* filesystem = new FilesystemWidget(game); FilesystemWidget* filesystem = new FilesystemWidget(game);
tab_widget->addTab(filesystem, tr("Filesystem")); tab_widget->addTab(GetWrappedWidget(filesystem, this, 50, 80), tr("Filesystem"));
} }
layout->addWidget(tab_widget); layout->addWidget(tab_widget);

View File

@ -10,7 +10,8 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QWidget> #include <QWidget>
QWidget* GetWrappedWidget(QWidget* wrapped_widget, QWidget* to_resize, int margin) QWidget* GetWrappedWidget(QWidget* wrapped_widget, QWidget* to_resize, int margin_width,
int margin_height)
{ {
auto* scroll = new QScrollArea; auto* scroll = new QScrollArea;
scroll->setWidget(wrapped_widget); scroll->setWidget(wrapped_widget);
@ -20,8 +21,9 @@ QWidget* GetWrappedWidget(QWidget* wrapped_widget, QWidget* to_resize, int margi
if (to_resize != nullptr) if (to_resize != nullptr)
{ {
// For some reason width() is bigger than it needs to be. // For some reason width() is bigger than it needs to be.
int recommended_width = wrapped_widget->width() * 0.9; auto min_size = wrapped_widget->minimumSizeHint();
int recommended_height = wrapped_widget->height() + margin; int recommended_width = min_size.width() + margin_width;
int recommended_height = min_size.height() + margin_height;
to_resize->resize(std::max(recommended_width, to_resize->width()), to_resize->resize(std::max(recommended_width, to_resize->width()),
std::max(recommended_height, to_resize->height())); std::max(recommended_height, to_resize->height()));

View File

@ -7,7 +7,8 @@
class QLayout; class QLayout;
class QWidget; class QWidget;
QWidget* GetWrappedWidget(QWidget* wrapped_widget, QWidget* to_resize = nullptr, int margin = 50); QWidget* GetWrappedWidget(QWidget* wrapped_widget, QWidget* to_resize = nullptr,
int margin_width = 50, int margin_height = 50);
// Wrap wrapped_layout in a QScrollArea and fill the parent widget with it // Wrap wrapped_layout in a QScrollArea and fill the parent widget with it
void WrapInScrollArea(QWidget* parent, QLayout* wrapped_layout, QWidget* to_resize = nullptr); void WrapInScrollArea(QWidget* parent, QLayout* wrapped_layout, QWidget* to_resize = nullptr);