mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-06 10:03:26 -08:00
[QtUtils] Use makeLayout() for zero-margin layouts (#7620)
* [QtUtils] Add parent lookup, layout clearing, scroll area and monospace helpers * [QtUtils] Adopt shared Qt helpers across the client * [QtUtils] Add layout creation and relayout helpers * Swap parameter order (spacing before margin) and remove static from relayout() * [QtUtils] Use relayout() after rebuilding dynamic layouts * [QtUtils] Use makeLayout() for zero-margin layouts * Consolidate setSpacing() calls into makeLayout() using new parameter order --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
06b9ca368f
commit
e806085681
56 changed files with 116 additions and 175 deletions
|
|
@ -29,6 +29,7 @@
|
|||
#include <QVariant>
|
||||
#include <QWidget>
|
||||
#include <QtGlobal>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
class DeckListModel;
|
||||
|
|
@ -110,14 +111,10 @@ VisualDatabaseDisplayFilterToolbarWidget::VisualDatabaseDisplayFilterToolbarWidg
|
|||
|
||||
void VisualDatabaseDisplayFilterToolbarWidget::initialize()
|
||||
{
|
||||
auto sortLayout = new QHBoxLayout(sortGroupBox);
|
||||
sortLayout->setContentsMargins(0, 0, 0, 0);
|
||||
sortLayout->setSpacing(0);
|
||||
auto sortLayout = QtUtils::makeLayout<QHBoxLayout>(sortGroupBox, 0);
|
||||
sortLayout->setAlignment(Qt::AlignLeft);
|
||||
|
||||
auto filterLayout = new QHBoxLayout(filterGroupBox);
|
||||
filterLayout->setContentsMargins(0, 0, 0, 0);
|
||||
filterLayout->setSpacing(2);
|
||||
auto filterLayout = QtUtils::makeLayout<QHBoxLayout>(filterGroupBox, 2);
|
||||
filterLayout->setAlignment(Qt::AlignLeft);
|
||||
|
||||
// create settings widgets
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <algorithm>
|
||||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
#include <libcockatrice/filters/filter_tree.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <limits>
|
||||
#include <qnamespace.h>
|
||||
|
||||
|
|
@ -48,8 +49,7 @@ VisualDatabaseDisplayFormatLegalityFilterWidget::VisualDatabaseDisplayFormatLega
|
|||
layout->addWidget(flowWidget);
|
||||
|
||||
// Create a container for the threshold control
|
||||
auto *thresholdLayout = new QHBoxLayout();
|
||||
thresholdLayout->setContentsMargins(0, 0, 0, 0);
|
||||
auto *thresholdLayout = QtUtils::makeLayout<QHBoxLayout>();
|
||||
|
||||
thresholdLabel = new QLabel(this);
|
||||
thresholdLayout->addWidget(thresholdLabel);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include <QtGlobal>
|
||||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
#include <libcockatrice/filters/filter_tree.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
VisualDatabaseDisplayMainTypeFilterWidget::VisualDatabaseDisplayMainTypeFilterWidget(QWidget *parent,
|
||||
|
|
@ -42,8 +43,7 @@ VisualDatabaseDisplayMainTypeFilterWidget::VisualDatabaseDisplayMainTypeFilterWi
|
|||
layout->addWidget(flowWidget);
|
||||
|
||||
// Create a container for the threshold control
|
||||
auto *thresholdLayout = new QHBoxLayout();
|
||||
thresholdLayout->setContentsMargins(0, 0, 0, 0);
|
||||
auto *thresholdLayout = QtUtils::makeLayout<QHBoxLayout>();
|
||||
|
||||
thresholdLabel = new QLabel(this);
|
||||
thresholdLayout->addWidget(thresholdLabel);
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@
|
|||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
#include <libcockatrice/filters/filter_tree.h>
|
||||
#include <libcockatrice/settings/visual_deck_storage_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
VisualDatabaseDisplayRecentSetFilterSettingsWidget::VisualDatabaseDisplayRecentSetFilterSettingsWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
layout = new QHBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout = QtUtils::makeLayout<QHBoxLayout>(this);
|
||||
|
||||
setLayout(layout);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <QtGlobal>
|
||||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
#include <libcockatrice/filters/filter_tree.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
VisualDatabaseDisplaySubTypeFilterWidget::VisualDatabaseDisplaySubTypeFilterWidget(QWidget *parent,
|
||||
|
|
@ -47,8 +48,7 @@ VisualDatabaseDisplaySubTypeFilterWidget::VisualDatabaseDisplaySubTypeFilterWidg
|
|||
layout->addWidget(flowWidget);
|
||||
|
||||
// Create a container for the threshold control
|
||||
auto *thresholdLayout = new QHBoxLayout();
|
||||
thresholdLayout->setContentsMargins(0, 0, 0, 0);
|
||||
auto *thresholdLayout = QtUtils::makeLayout<QHBoxLayout>();
|
||||
|
||||
thresholdLabel = new QLabel(this);
|
||||
thresholdLayout->addWidget(thresholdLabel);
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@
|
|||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
#include <libcockatrice/deck_list/tree/inner_deck_list_node.h>
|
||||
#include <libcockatrice/settings/cards_display_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <utility>
|
||||
|
||||
class QMouseEvent;
|
||||
|
|
@ -92,10 +93,8 @@ VisualDatabaseDisplayWidget::VisualDatabaseDisplayWidget(QWidget *parent,
|
|||
// Set up main layout and widgets
|
||||
setMinimumSize(0, 0);
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
mainLayout = new QVBoxLayout(this);
|
||||
mainLayout = QtUtils::makeLayout<QVBoxLayout>(this, 0, 1);
|
||||
setLayout(mainLayout);
|
||||
mainLayout->setSpacing(1);
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
flowWidget = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarPolicy::ScrollBarAsNeeded);
|
||||
cardSizeWidget = new CardSizeWidget(this, flowWidget,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue