Merge pull request #6457 from spycrab/qt_misc

Qt: Improve spacing again
This commit is contained in:
Pierre Bourdon 2018-03-21 01:10:01 +01:00 committed by GitHub
commit 6860259c44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);
description_box->setLayout(description_layout);
description_box->setMinimumHeight(230);
description_box->setFixedHeight(230);
m_description->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_description->setWordWrap(true);
@ -68,14 +68,15 @@ void GraphicsWindow::CreateMainLayout()
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_enhancements_widget, this, 250), tr("Enhancements"));
m_tab_widget->addTab(GetWrappedWidget(m_hacks_widget, this, 250), tr("Hacks"));
m_tab_widget->addTab(GetWrappedWidget(m_advanced_widget, this, 250), tr("Advanced"));
m_tab_widget->addTab(GetWrappedWidget(m_general_widget, this, 50, 325), tr("General"));
m_tab_widget->addTab(GetWrappedWidget(m_enhancements_widget, this, 50, 325),
tr("Enhancements"));
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
{
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);

View File

@ -313,7 +313,7 @@ void MappingWindow::SetMappingType(MappingWindow::Type type)
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

View File

@ -38,16 +38,16 @@ PropertiesDialog::PropertiesDialog(QWidget* parent, const UICommon::GameFile& ga
connect(ar, &ARCodeWidget::OpenGeneralSettings, this, &PropertiesDialog::OpenGeneralSettings);
tab_widget->addTab(GetWrappedWidget(game_config, this), tr("Game Config"));
tab_widget->addTab(GetWrappedWidget(patches, this), tr("Patches"));
tab_widget->addTab(GetWrappedWidget(ar, this), tr("AR Codes"));
tab_widget->addTab(GetWrappedWidget(gecko, this), tr("Gecko Codes"));
tab_widget->addTab(GetWrappedWidget(info, this), tr("Info"));
tab_widget->addTab(GetWrappedWidget(game_config, this, 50, 80), tr("Game Config"));
tab_widget->addTab(GetWrappedWidget(patches, this, 50, 80), tr("Patches"));
tab_widget->addTab(GetWrappedWidget(ar, this, 50, 80), tr("AR Codes"));
tab_widget->addTab(GetWrappedWidget(gecko, this, 50, 80), tr("Gecko Codes"));
tab_widget->addTab(GetWrappedWidget(info, this, 50, 80), tr("Info"));
if (DiscIO::IsDisc(game.GetPlatform()))
{
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);

View File

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

View File

@ -7,7 +7,8 @@
class QLayout;
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
void WrapInScrollArea(QWidget* parent, QLayout* wrapped_layout, QWidget* to_resize = nullptr);