Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #6436 from spycrab/qt_layout
Qt: Improve spacing
- Loading branch information
Showing
14 changed files
with
116 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // Copyright 2018 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #include "DolphinQt2/QtUtils/WrapInScrollArea.h" | ||
|
|
||
| #include <QFrame> | ||
| #include <QLayout> | ||
| #include <QScrollArea> | ||
| #include <QVBoxLayout> | ||
| #include <QWidget> | ||
|
|
||
| QWidget* GetWrappedWidget(QWidget* wrapped_widget, QWidget* to_resize, int margin) | ||
| { | ||
| auto* scroll = new QScrollArea; | ||
| scroll->setWidget(wrapped_widget); | ||
| scroll->setWidgetResizable(true); | ||
| scroll->setFrameStyle(QFrame::NoFrame); | ||
|
|
||
| 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; | ||
|
|
||
| to_resize->resize(std::max(recommended_width, to_resize->width()), | ||
| std::max(recommended_height, to_resize->height())); | ||
| } | ||
|
|
||
| return scroll; | ||
| } | ||
|
|
||
| void WrapInScrollArea(QWidget* parent, QLayout* wrapped_layout, QWidget* to_resize) | ||
| { | ||
| if (to_resize == nullptr) | ||
| to_resize = parent; | ||
|
|
||
| auto* widget = new QWidget; | ||
| widget->setLayout(wrapped_layout); | ||
|
|
||
| auto* scroll_area = GetWrappedWidget(widget, to_resize); | ||
|
|
||
| auto* scroll_layout = new QVBoxLayout; | ||
| scroll_layout->addWidget(scroll_area); | ||
| scroll_layout->setMargin(0); | ||
|
|
||
| parent->setLayout(scroll_layout); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // Copyright 2018 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #pragma once | ||
|
|
||
| class QLayout; | ||
| class QWidget; | ||
|
|
||
| QWidget* GetWrappedWidget(QWidget* wrapped_widget, QWidget* to_resize = nullptr, int margin = 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); |