[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:
BruebachL 2026-10-24 19:06:18 +02:00 • committed by GitHub
parent 06b9ca368f
commit e806085681
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 116 additions and 175 deletions

View file

@ -14,6 +14,7 @@
#include <QObject> #include <QObject>
#include <QPoint> #include <QPoint>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
LatencyStatusWidget::LatencyStatusWidget(QWidget *parent) : QWidget(parent) LatencyStatusWidget::LatencyStatusWidget(QWidget *parent) : QWidget(parent)
@ -24,9 +25,7 @@ LatencyStatusWidget::LatencyStatusWidget(QWidget *parent) : QWidget(parent)
latencyGraph = new LatencyGraphWidget(this); latencyGraph = new LatencyGraphWidget(this);
latencyGraph->setFixedSize(90, 14); latencyGraph->setFixedSize(90, 14);
auto *layout = new QHBoxLayout(this); auto *layout = QtUtils::makeLayout<QHBoxLayout>(this, 4);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(4);
layout->addWidget(latencyGraph); layout->addWidget(latencyGraph);
layout->addWidget(pingLabel); layout->addWidget(pingLabel);

View file

@ -13,6 +13,7 @@
#include <QVariant> #include <QVariant>
#include <QtGlobal> #include <QtGlobal>
#include <libcockatrice/filters/filter_card.h> #include <libcockatrice/filters/filter_card.h>
#include <libcockatrice/utility/qt_utils.h>
#include <stddef.h> #include <stddef.h>
FilterBuilder::FilterBuilder(QWidget *parent) : QWidget(parent) FilterBuilder::FilterBuilder(QWidget *parent) : QWidget(parent)
@ -39,9 +40,8 @@ FilterBuilder::FilterBuilder(QWidget *parent) : QWidget(parent)
edit->setClearButtonEnabled(true); edit->setClearButtonEnabled(true);
edit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); edit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
QGridLayout *layout = new QGridLayout; QGridLayout *layout = QtUtils::makeLayout<QGridLayout>();
layout->setObjectName("layout"); layout->setObjectName("layout");
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(typeCombo, 0, 0, 1, 2); layout->addWidget(typeCombo, 0, 0, 1, 2);
layout->addWidget(filterCombo, 0, 2, 1, 2); layout->addWidget(filterCombo, 0, 2, 1, 2);

View file

@ -43,6 +43,7 @@
#include <libcockatrice/protocol/pending_command.h> #include <libcockatrice/protocol/pending_command.h>
#include <libcockatrice/settings/interface_settings.h> #include <libcockatrice/settings/interface_settings.h>
#include <libcockatrice/settings/visual_deck_storage_settings.h> #include <libcockatrice/settings/visual_deck_storage_settings.h>
#include <libcockatrice/utility/qt_utils.h>
#include <libcockatrice/utility/string_limits.h> #include <libcockatrice/utility/string_limits.h>
#include <optional> #include <optional>
#include <qnamespace.h> #include <qnamespace.h>
@ -111,10 +112,9 @@ DeckViewContainer::DeckViewContainer(int _playerId, TabGame *parent)
connect(deckView, &DeckView::newCardAdded, this, &DeckViewContainer::newCardAdded); connect(deckView, &DeckView::newCardAdded, this, &DeckViewContainer::newCardAdded);
connect(deckView, &DeckView::sideboardPlanChanged, this, &DeckViewContainer::sideboardPlanChanged); connect(deckView, &DeckView::sideboardPlanChanged, this, &DeckViewContainer::sideboardPlanChanged);
deckViewLayout = new QVBoxLayout; deckViewLayout = QtUtils::makeLayout<QVBoxLayout>();
deckViewLayout->addLayout(buttonHBox); deckViewLayout->addLayout(buttonHBox);
deckViewLayout->addWidget(deckView); deckViewLayout->addWidget(deckView);
deckViewLayout->setContentsMargins(0, 0, 0, 0);
setLayout(deckViewLayout); setLayout(deckViewLayout);
retranslateUi(); retranslateUi();

View file

@ -7,6 +7,7 @@
#include <QProgressBar> #include <QProgressBar>
#include <QtGlobal> #include <QtGlobal>
#include <climits> #include <climits>
#include <libcockatrice/utility/qt_utils.h>
namespace namespace
{ {
@ -32,8 +33,7 @@ QString stageName(CardUpdateStage stage, const QString &fallback)
CardDatabaseUpdateStatusBar::CardDatabaseUpdateStatusBar(QWidget *parent) : QWidget(parent) CardDatabaseUpdateStatusBar::CardDatabaseUpdateStatusBar(QWidget *parent) : QWidget(parent)
{ {
layout = new QHBoxLayout(this); layout = QtUtils::makeLayout<QHBoxLayout>(this);
layout->setContentsMargins(0, 0, 0, 0);
stageLabel = new QLabel(this); stageLabel = new QLabel(this);
progressBar = new QProgressBar(this); progressBar = new QProgressBar(this);

View file

@ -25,6 +25,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QWidget> #include <QWidget>
#include <initializer_list> #include <initializer_list>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
PaletteEditorDialog::PaletteEditorDialog(const QString &_themeDirPath, const QString &_themeName, QWidget *parent) PaletteEditorDialog::PaletteEditorDialog(const QString &_themeDirPath, const QString &_themeName, QWidget *parent)
@ -57,9 +58,7 @@ PaletteEditorDialog::PaletteEditorDialog(const QString &_themeDirPath, const QSt
void PaletteEditorDialog::setupUi() void PaletteEditorDialog::setupUi()
{ {
auto *root = new QVBoxLayout(this); auto *root = QtUtils::makeLayout<QVBoxLayout>(this, 0, 0);
root->setSpacing(0);
root->setContentsMargins(0, 0, 0, 0);
// Header // Header
header = new QWidget; header = new QWidget;

View file

@ -18,6 +18,7 @@
#include <QTimer> #include <QTimer>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QtGlobal> #include <QtGlobal>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
#include <utility> #include <utility>
@ -74,8 +75,7 @@ PaletteGridWidget::PaletteGridWidget(QWidget *parent) : QWidget(parent)
refreshChromePalettes(); refreshChromePalettes();
scroll->setWidget(gridHost); scroll->setWidget(gridHost);
layout = new QVBoxLayout(this); layout = QtUtils::makeLayout<QVBoxLayout>(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(scroll); layout->addWidget(scroll);
} }

View file

@ -23,9 +23,7 @@
ColorIdentityWidget::ColorIdentityWidget(QWidget *parent, const QString &_colorIdentity) ColorIdentityWidget::ColorIdentityWidget(QWidget *parent, const QString &_colorIdentity)
: QWidget(parent), colorIdentity(_colorIdentity) : QWidget(parent), colorIdentity(_colorIdentity)
{ {
layout = new QHBoxLayout(this); layout = QtUtils::makeLayout<QHBoxLayout>(this, 5);
layout->setSpacing(5); // Small spacing between icons
layout->setContentsMargins(0, 0, 0, 0);
layout->setAlignment(Qt::AlignCenter); // Ensure icons are centered layout->setAlignment(Qt::AlignCenter); // Ensure icons are centered
setLayout(layout); setLayout(layout);

View file

@ -11,12 +11,11 @@
#include <QResizeEvent> #include <QResizeEvent>
#include <QSize> #include <QSize>
#include <QtGlobal> #include <QtGlobal>
#include <libcockatrice/utility/qt_utils.h>
ManaCostWidget::ManaCostWidget(QWidget *parent, CardInfoPtr _card) : QWidget(parent), card(_card) ManaCostWidget::ManaCostWidget(QWidget *parent, CardInfoPtr _card) : QWidget(parent), card(_card)
{ {
layout = new QHBoxLayout(this); layout = QtUtils::makeLayout<QHBoxLayout>(this, 5);
layout->setSpacing(5); // Small spacing between icons
layout->setContentsMargins(0, 0, 0, 0);
setLayout(layout); setLayout(layout);
setFixedHeight(50); // Fixed height setFixedHeight(50); // Fixed height

View file

@ -17,6 +17,7 @@
#include <QString> #include <QString>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <libcockatrice/card/database/card_database_manager.h> #include <libcockatrice/card/database/card_database_manager.h>
#include <libcockatrice/utility/qt_utils.h>
class QWidget; class QWidget;
@ -30,9 +31,8 @@ CardInfoDisplayWidget::CardInfoDisplayWidget(const CardRef &cardRef, QWidget *pa
text->setObjectName("text"); text->setObjectName("text");
connect(text, &CardInfoTextWidget::linkActivated, this, [this](const QString &card) { setCard({card}); }); connect(text, &CardInfoTextWidget::linkActivated, this, [this](const QString &card) { setCard({card}); });
auto *layout = new QVBoxLayout(); auto *layout = QtUtils::makeLayout<QVBoxLayout>();
layout->setObjectName("layout"); layout->setObjectName("layout");
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0); layout->setSpacing(0);
layout->addWidget(pic, 0, Qt::AlignCenter); layout->addWidget(pic, 0, Qt::AlignCenter);
layout->addWidget(text, 0, Qt::AlignCenter); layout->addWidget(text, 0, Qt::AlignCenter);

View file

@ -19,6 +19,7 @@
#include <libcockatrice/card/relation/card_relation.h> #include <libcockatrice/card/relation/card_relation.h>
#include <libcockatrice/settings/cards_display_settings.h> #include <libcockatrice/settings/cards_display_settings.h>
#include <libcockatrice/utility/card_ref.h> #include <libcockatrice/utility/card_ref.h>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
struct CardRef; struct CardRef;
@ -49,15 +50,13 @@ CardInfoFrameWidget::CardInfoFrameWidget(QWidget *parent)
insertTab(ImageAndTextView, tab3, QString()); insertTab(ImageAndTextView, tab3, QString());
connect(this, &CardInfoFrameWidget::currentChanged, this, &CardInfoFrameWidget::setViewMode); connect(this, &CardInfoFrameWidget::currentChanged, this, &CardInfoFrameWidget::setViewMode);
tab1Layout = new QVBoxLayout(); tab1Layout = QtUtils::makeLayout<QVBoxLayout>();
tab1Layout->setObjectName("tab1Layout"); tab1Layout->setObjectName("tab1Layout");
tab1Layout->setContentsMargins(0, 0, 0, 0);
tab1Layout->setSpacing(0); tab1Layout->setSpacing(0);
tab1->setLayout(tab1Layout); tab1->setLayout(tab1Layout);
tab2Layout = new QVBoxLayout(); tab2Layout = QtUtils::makeLayout<QVBoxLayout>();
tab2Layout->setObjectName("tab2Layout"); tab2Layout->setObjectName("tab2Layout");
tab2Layout->setContentsMargins(0, 0, 0, 0);
tab2Layout->setSpacing(0); tab2Layout->setSpacing(0);
tab2->setLayout(tab2Layout); tab2->setLayout(tab2Layout);
@ -65,9 +64,8 @@ CardInfoFrameWidget::CardInfoFrameWidget(QWidget *parent)
splitter->setObjectName("splitter"); splitter->setObjectName("splitter");
splitter->setOrientation(Qt::Vertical); splitter->setOrientation(Qt::Vertical);
tab3Layout = new QVBoxLayout(); tab3Layout = QtUtils::makeLayout<QVBoxLayout>();
tab3Layout->setObjectName("tab3Layout"); tab3Layout->setObjectName("tab3Layout");
tab3Layout->setContentsMargins(0, 0, 0, 0);
tab3Layout->setSpacing(0); tab3Layout->setSpacing(0);
tab3Layout->addWidget(splitter); tab3Layout->addWidget(splitter);
tab3->setLayout(tab3Layout); tab3->setLayout(tab3Layout);

View file

@ -16,14 +16,13 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QVector> #include <QVector>
#include <algorithm> #include <algorithm>
#include <libcockatrice/utility/qt_utils.h>
constexpr int MIN_ROW_HEIGHT = 100; // Minimum readable height per row constexpr int MIN_ROW_HEIGHT = 100; // Minimum readable height per row
ManaCurveCategoryWidget::ManaCurveCategoryWidget(QWidget *parent) : QWidget(parent) ManaCurveCategoryWidget::ManaCurveCategoryWidget(QWidget *parent) : QWidget(parent)
{ {
layout = new QVBoxLayout(this); layout = QtUtils::makeLayout<QVBoxLayout>(this, 0, 4);
layout->setSpacing(4);
layout->setContentsMargins(0, 0, 0, 0);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
} }
@ -95,9 +94,7 @@ void ManaCurveCategoryWidget::updateDisplay(int minCmc,
row->setFixedHeight(MIN_ROW_HEIGHT); row->setFixedHeight(MIN_ROW_HEIGHT);
QHBoxLayout *rowLayout = new QHBoxLayout(row); QHBoxLayout *rowLayout = QtUtils::makeLayout<QHBoxLayout>(row, 4);
rowLayout->setContentsMargins(0, 0, 0, 0);
rowLayout->setSpacing(4);
QLabel *categoryLabel = new QLabel(cat, row); QLabel *categoryLabel = new QLabel(cat, row);
categoryLabel->setFixedWidth(80); categoryLabel->setFixedWidth(80);

View file

@ -28,6 +28,7 @@
#include <QTimer> #include <QTimer>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QtGlobal> #include <QtGlobal>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
ResizablePanel::ResizablePanel(const QString &_typeId, AbstractAnalyticsPanelWidget *analyticsPanel, QWidget *parent) ResizablePanel::ResizablePanel(const QString &_typeId, AbstractAnalyticsPanelWidget *analyticsPanel, QWidget *parent)
@ -35,18 +36,14 @@ ResizablePanel::ResizablePanel(const QString &_typeId, AbstractAnalyticsPanelWid
{ {
setAcceptDrops(true); setAcceptDrops(true);
auto *mainLayout = new QVBoxLayout(this); auto *mainLayout = QtUtils::makeLayout<QVBoxLayout>(this, 0);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setSpacing(0);
// Frame for selection highlight // Frame for selection highlight
frame = new QFrame(this); frame = new QFrame(this);
frame->setFrameShape(QFrame::Box); frame->setFrameShape(QFrame::Box);
frame->setLineWidth(2); frame->setLineWidth(2);
auto *frameLayout = new QVBoxLayout(frame); auto *frameLayout = QtUtils::makeLayout<QVBoxLayout>(frame, 0);
frameLayout->setContentsMargins(0, 0, 0, 0);
frameLayout->setSpacing(0);
// Add the analytics panel // Add the analytics panel
frameLayout->addWidget(analyticsPanel); frameLayout->addWidget(analyticsPanel);
@ -63,9 +60,7 @@ ResizablePanel::ResizablePanel(const QString &_typeId, AbstractAnalyticsPanelWid
// Bottom bar with drag button and resize handle // Bottom bar with drag button and resize handle
auto *bottomBar = new QWidget(frame); auto *bottomBar = new QWidget(frame);
auto *bottomLayout = new QHBoxLayout(bottomBar); auto *bottomLayout = QtUtils::makeLayout<QHBoxLayout>(bottomBar, 0);
bottomLayout->setContentsMargins(0, 0, 0, 0);
bottomLayout->setSpacing(0);
// Drag button on the left // Drag button on the left
dragButton = new QPushButton("☰", bottomBar); dragButton = new QPushButton("☰", bottomBar);

View file

@ -28,6 +28,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QVariant> #include <QVariant>
#include <QWidget> #include <QWidget>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
DeckEditorFilterDockWidget::DeckEditorFilterDockWidget(AbstractTabDeckEditor *parent) DeckEditorFilterDockWidget::DeckEditorFilterDockWidget(AbstractTabDeckEditor *parent)
@ -80,9 +81,8 @@ void DeckEditorFilterDockWidget::createFiltersDock()
filterDelAll->setDefaultAction(aClearFilterAll); filterDelAll->setDefaultAction(aClearFilterAll);
filterDelAll->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); filterDelAll->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
auto *filterLayout = new QGridLayout; auto *filterLayout = QtUtils::makeLayout<QGridLayout>();
filterLayout->setObjectName("filterLayout"); filterLayout->setObjectName("filterLayout");
filterLayout->setContentsMargins(0, 0, 0, 0);
filterLayout->addWidget(filterBuilder, 0, 0, 1, 3); filterLayout->addWidget(filterBuilder, 0, 0, 1, 3);
filterLayout->addWidget(filterView, 1, 0, 1, 3); filterLayout->addWidget(filterView, 1, 0, 1, 3);
filterLayout->addWidget(filterDelOne, 2, 0, 1, 1); filterLayout->addWidget(filterDelOne, 2, 0, 1, 1);

View file

@ -15,6 +15,7 @@
#include <QStringLiteral> #include <QStringLiteral>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <libcockatrice/card/database/card_database_querier.h> #include <libcockatrice/card/database/card_database_querier.h>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
SharedDeckPreviewWidget::SharedDeckPreviewWidget(QWidget *parent, SharedDeckPreviewWidget::SharedDeckPreviewWidget(QWidget *parent,
@ -62,8 +63,7 @@ SharedDeckPreviewWidget::SharedDeckPreviewWidget(QWidget *parent,
selectionRow->addWidget(selectionCheckBox); selectionRow->addWidget(selectionCheckBox);
selectionRow->addStretch(1); selectionRow->addStretch(1);
auto *layout = new QVBoxLayout(this); auto *layout = QtUtils::makeLayout<QVBoxLayout>(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->addLayout(selectionRow); layout->addLayout(selectionRow);
layout->addWidget(bannerCardDisplayWidget, 0, Qt::AlignHCenter); layout->addWidget(bannerCardDisplayWidget, 0, Qt::AlignHCenter);
layout->addWidget(colorIdentityWidget, 0, Qt::AlignHCenter); layout->addWidget(colorIdentityWidget, 0, Qt::AlignHCenter);

View file

@ -17,6 +17,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QWidget> #include <QWidget>
#include <libcockatrice/settings/visual_deck_storage_settings.h> #include <libcockatrice/settings/visual_deck_storage_settings.h>
#include <libcockatrice/utility/qt_utils.h>
DlgDefaultTagsEditor::DlgDefaultTagsEditor(QWidget *parent) : QDialog(parent) DlgDefaultTagsEditor::DlgDefaultTagsEditor(QWidget *parent) : QDialog(parent)
{ {
@ -120,8 +121,7 @@ void DlgDefaultTagsEditor::addItem()
// Add new tag // Add new tag
auto *item = new QListWidgetItem(listWidget); auto *item = new QListWidgetItem(listWidget);
QWidget *widget = new QWidget(this); QWidget *widget = new QWidget(this);
QHBoxLayout *layout = new QHBoxLayout(widget); QHBoxLayout *layout = QtUtils::makeLayout<QHBoxLayout>(widget);
layout->setContentsMargins(0, 0, 0, 0);
// Editable tag label // Editable tag label
QLineEdit *lineEdit = new QLineEdit(newTag, this); QLineEdit *lineEdit = new QLineEdit(newTag, this);

View file

@ -84,8 +84,7 @@ DlgSelectSetForCards::DlgSelectSetForCards(QWidget *parent, DeckStateManager *de
// Left container // Left container
QWidget *leftContainer = new QWidget(this); QWidget *leftContainer = new QWidget(this);
QVBoxLayout *leftLayout = new QVBoxLayout(leftContainer); QVBoxLayout *leftLayout = QtUtils::makeLayout<QVBoxLayout>(leftContainer);
leftLayout->setContentsMargins(0, 0, 0, 0);
uneditedCardsLabel = new QLabel(this); uneditedCardsLabel = new QLabel(this);
uneditedCardsArea = QtUtils::makeScrollArea(this); uneditedCardsArea = QtUtils::makeScrollArea(this);
@ -100,8 +99,7 @@ DlgSelectSetForCards::DlgSelectSetForCards(QWidget *parent, DeckStateManager *de
// Right container // Right container
QWidget *rightContainer = new QWidget(this); QWidget *rightContainer = new QWidget(this);
QVBoxLayout *rightLayout = new QVBoxLayout(rightContainer); QVBoxLayout *rightLayout = QtUtils::makeLayout<QVBoxLayout>(rightContainer);
rightLayout->setContentsMargins(0, 0, 0, 0);
modifiedCardsLabel = new QLabel(this); modifiedCardsLabel = new QLabel(this);
modifiedCardsArea = QtUtils::makeScrollArea(this); modifiedCardsArea = QtUtils::makeScrollArea(this);

View file

@ -48,8 +48,7 @@ FlowWidget::FlowWidget(QWidget *parent,
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
} }
mainLayout = new QHBoxLayout(this); mainLayout = QtUtils::makeLayout<QHBoxLayout>(this);
mainLayout->setContentsMargins(0, 0, 0, 0);
setLayout(mainLayout); setLayout(mainLayout);
const bool useScrollArea = (horizontalPolicy != Qt::ScrollBarAlwaysOff || verticalPolicy != Qt::ScrollBarAlwaysOff); const bool useScrollArea = (horizontalPolicy != Qt::ScrollBarAlwaysOff || verticalPolicy != Qt::ScrollBarAlwaysOff);

View file

@ -17,6 +17,7 @@
#include <QPushButton> #include <QPushButton>
#include <QStackedWidget> #include <QStackedWidget>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
#include <utility> #include <utility>
@ -51,8 +52,7 @@ FirstRunWizard::FirstRunWizard(QWidget *parent) : QDialog(parent)
connect(skipButton, &QPushButton::clicked, this, &FirstRunWizard::skip); connect(skipButton, &QPushButton::clicked, this, &FirstRunWizard::skip);
connect(nextButton, &QPushButton::clicked, this, &FirstRunWizard::goNext); connect(nextButton, &QPushButton::clicked, this, &FirstRunWizard::goNext);
auto *headerLayout = new QVBoxLayout; auto *headerLayout = QtUtils::makeLayout<QVBoxLayout>();
headerLayout->setContentsMargins(0, 0, 0, 0);
headerLayout->addWidget(bannerHost); headerLayout->addWidget(bannerHost);
headerLayout->addSpacing(12); headerLayout->addSpacing(12);
headerLayout->addWidget(titleLabel); headerLayout->addWidget(titleLabel);

View file

@ -19,6 +19,7 @@
#include <QString> #include <QString>
#include <QUrl> #include <QUrl>
#include <QtGlobal> #include <QtGlobal>
#include <libcockatrice/utility/qt_utils.h>
#include <qmath.h> #include <qmath.h>
#include <qnamespace.h> #include <qnamespace.h>
#include <qnumeric.h> #include <qnumeric.h>
@ -151,8 +152,7 @@ BannerHost::BannerHost(QWidget *parent) : QWidget(parent)
{ {
setFixedHeight(150); setFixedHeight(150);
stack = new QStackedLayout(this); stack = QtUtils::makeLayout<QStackedLayout>(this);
stack->setContentsMargins(0, 0, 0, 0);
fallback = new GradientFallbackWidget(this); fallback = new GradientFallbackWidget(this);
stack->addWidget(fallback); stack->addWidget(fallback);

View file

@ -22,6 +22,7 @@
#include <QVariant> #include <QVariant>
#include <algorithm> #include <algorithm>
#include <functional> #include <functional>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
class QModelIndex; class QModelIndex;
@ -42,9 +43,7 @@ CardAmountWidget::CardAmountWidget(QWidget *parent,
: QWidget(parent), deckStateManager(deckStateManager), cardSizeSlider(cardSizeSlider), rootCard(rootCard), : QWidget(parent), deckStateManager(deckStateManager), cardSizeSlider(cardSizeSlider), rootCard(rootCard),
zoneName(zoneName), hovered(false) zoneName(zoneName), hovered(false)
{ {
layout = new QHBoxLayout(this); layout = QtUtils::makeLayout<QHBoxLayout>(this, 10);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(10);
this->setLayout(layout); this->setLayout(layout);
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
layout->setAlignment(Qt::AlignHCenter); layout->setAlignment(Qt::AlignHCenter);

View file

@ -32,6 +32,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <libcockatrice/settings/cards_display_settings.h> #include <libcockatrice/settings/cards_display_settings.h>
#include <libcockatrice/utility/macros.h> #include <libcockatrice/utility/macros.h>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
/** /**
@ -84,9 +85,7 @@ PrintingSelector::PrintingSelector(QWidget *parent, AbstractTabDeckEditor *_deck
displayOptionsWidget->addSettingsWidget(cardSizeWidget); displayOptionsWidget->addSettingsWidget(cardSizeWidget);
sortAndOptionsContainer = new QWidget(this); sortAndOptionsContainer = new QWidget(this);
sortAndOptionsLayout = new QHBoxLayout(sortAndOptionsContainer); sortAndOptionsLayout = QtUtils::makeLayout<QHBoxLayout>(sortAndOptionsContainer, 0, 3);
sortAndOptionsLayout->setSpacing(3);
sortAndOptionsLayout->setContentsMargins(0, 0, 0, 0);
sortAndOptionsContainer->setLayout(sortAndOptionsLayout); sortAndOptionsContainer->setLayout(sortAndOptionsLayout);
searchBar = new PrintingSelectorCardSearchWidget(this); searchBar = new PrintingSelectorCardSearchWidget(this);

View file

@ -40,6 +40,7 @@
#include <libcockatrice/card/database/card_database_manager.h> #include <libcockatrice/card/database/card_database_manager.h>
#include <libcockatrice/card/relation/card_relation.h> #include <libcockatrice/card/relation/card_relation.h>
#include <libcockatrice/settings/card_override_settings.h> #include <libcockatrice/settings/card_override_settings.h>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
class DeckStateManager; class DeckStateManager;
@ -108,9 +109,7 @@ PrintingSelectorCardOverlayWidget::PrintingSelectorCardOverlayWidget(QWidget *pa
: QWidget(parent), deckEditor(_deckEditor), rootCard(_rootCard) : QWidget(parent), deckEditor(_deckEditor), rootCard(_rootCard)
{ {
// Set up the main layout // Set up the main layout
auto *mainLayout = new QVBoxLayout(this); auto *mainLayout = QtUtils::makeLayout<QVBoxLayout>(this, 0);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setSpacing(0);
setLayout(mainLayout); setLayout(mainLayout);
// Add CardInfoPictureWidget // Add CardInfoPictureWidget

View file

@ -5,6 +5,7 @@
#include <QRect> #include <QRect>
#include <QSizePolicy> #include <QSizePolicy>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
/** /**
@ -19,8 +20,7 @@ SetNameAndCollectorsNumberDisplayWidget::SetNameAndCollectorsNumberDisplayWidget
: QWidget(parent) : QWidget(parent)
{ {
// Set up the layout for the widget // Set up the layout for the widget
layout = new QVBoxLayout(this); layout = QtUtils::makeLayout<QVBoxLayout>(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(1); layout->setSpacing(1);
setLayout(layout); setLayout(layout);

View file

@ -15,6 +15,7 @@
#include <QSizePolicy> #include <QSizePolicy>
#include <QStringLiteral> #include <QStringLiteral>
#include <QToolButton> #include <QToolButton>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
SettingsButtonWidget::SettingsButtonWidget(QWidget *parent) SettingsButtonWidget::SettingsButtonWidget(QWidget *parent)
@ -26,9 +27,8 @@ SettingsButtonWidget::SettingsButtonWidget(QWidget *parent)
connect(button, &QToolButton::clicked, this, &SettingsButtonWidget::togglePopup); connect(button, &QToolButton::clicked, this, &SettingsButtonWidget::togglePopup);
connect(popup, &SettingsPopupWidget::aboutToClose, this, &SettingsButtonWidget::onPopupClosed); connect(popup, &SettingsPopupWidget::aboutToClose, this, &SettingsButtonWidget::onPopupClosed);
layout = new QHBoxLayout(this); layout = QtUtils::makeLayout<QHBoxLayout>(this);
layout->addWidget(button); layout->addWidget(button);
layout->setContentsMargins(0, 0, 0, 0);
setLayout(layout); setLayout(layout);
} }

View file

@ -11,6 +11,7 @@
#include <QtGlobal> #include <QtGlobal>
#include <libcockatrice/settings/interface_settings.h> #include <libcockatrice/settings/interface_settings.h>
#include <libcockatrice/settings/personal_settings.h> #include <libcockatrice/settings/personal_settings.h>
#include <libcockatrice/utility/qt_utils.h>
ReplayQuickSettingsWidget::ReplayQuickSettingsWidget(QWidget *parent) : SettingsButtonWidget(parent) ReplayQuickSettingsWidget::ReplayQuickSettingsWidget(QWidget *parent) : SettingsButtonWidget(parent)
{ {
@ -28,8 +29,7 @@ ReplayQuickSettingsWidget::ReplayQuickSettingsWidget(QWidget *parent) : Settings
// putting it all together // putting it all together
auto *widget = new QWidget; auto *widget = new QWidget;
auto *grid = new QGridLayout(widget); auto *grid = QtUtils::makeLayout<QGridLayout>(widget);
grid->setContentsMargins(0, 0, 0, 0);
grid->addWidget(&fastForwardSpeedLabel, 0, 0, 1, 1); grid->addWidget(&fastForwardSpeedLabel, 0, 0, 1, 1);
grid->addWidget(&fastForwardSpeedBox, 0, 1, 1, 1); grid->addWidget(&fastForwardSpeedBox, 0, 1, 1, 1);
grid->addWidget(&skipEmptyCheckBox, 1, 0, 1, 2); grid->addWidget(&skipEmptyCheckBox, 1, 0, 1, 2);

View file

@ -14,6 +14,7 @@
#include <QString> #include <QString>
#include <QVariant> #include <QVariant>
#include <QtGlobal> #include <QtGlobal>
#include <libcockatrice/utility/qt_utils.h>
class TabSupervisor; class TabSupervisor;
template <class Key, class T> class QMap; template <class Key, class T> class QMap;
@ -24,8 +25,7 @@ GameSelectorQuickFilterToolBar::GameSelectorQuickFilterToolBar(QWidget *parent,
const QMap<int, QString> &allGameTypes) const QMap<int, QString> &allGameTypes)
: QWidget(parent), tabSupervisor(_tabSupervisor), model(_model) : QWidget(parent), tabSupervisor(_tabSupervisor), model(_model)
{ {
mainLayout = new QHBoxLayout(this); mainLayout = QtUtils::makeLayout<QHBoxLayout>(this);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setSpacing(5); mainLayout->setSpacing(5);
const GameFilterConfigs &filters = model->getFilters(); const GameFilterConfigs &filters = model->getFilters();

View file

@ -33,6 +33,7 @@
#include <libcockatrice/protocol/pb/session_commands.pb.h> #include <libcockatrice/protocol/pb/session_commands.pb.h>
#include <libcockatrice/protocol/pending_command.h> #include <libcockatrice/protocol/pending_command.h>
#include <libcockatrice/utility/passwordhasher.h> #include <libcockatrice/utility/passwordhasher.h>
#include <libcockatrice/utility/qt_utils.h>
#include <string> #include <string>
#include <sys/types.h> #include <sys/types.h>
@ -53,8 +54,7 @@ UserInfoBox::UserInfoBox(AbstractClient *_client, bool _editable, QWidget *paren
avatarPic.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); avatarPic.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
avatarPic.setAlignment(Qt::AlignCenter); avatarPic.setAlignment(Qt::AlignCenter);
auto *avatarLayout = new QHBoxLayout; auto *avatarLayout = QtUtils::makeLayout<QHBoxLayout>();
avatarLayout->setContentsMargins(0, 0, 0, 0);
avatarLayout->addStretch(1); avatarLayout->addStretch(1);
avatarLayout->addWidget(&avatarPic, 3); avatarLayout->addWidget(&avatarPic, 3);
avatarLayout->addStretch(1); avatarLayout->addStretch(1);

View file

@ -55,6 +55,7 @@
#include <libcockatrice/protocol/pb/response_get_games_of_user.pb.h> #include <libcockatrice/protocol/pb/response_get_games_of_user.pb.h>
#include <libcockatrice/protocol/pending_command.h> #include <libcockatrice/protocol/pending_command.h>
#include <libcockatrice/utility/card_ref.h> #include <libcockatrice/utility/card_ref.h>
#include <libcockatrice/utility/qt_utils.h>
#include <qnumeric.h> #include <qnumeric.h>
#include <string> #include <string>
@ -402,9 +403,7 @@ UserInfoPopup::UserInfoPopup(TabSupervisor *_ts,
void UserInfoPopup::buildUi() void UserInfoPopup::buildUi()
{ {
auto *root = new QVBoxLayout(this); auto *root = QtUtils::makeLayout<QVBoxLayout>(this, 0);
root->setContentsMargins(0, 0, 0, 0);
root->setSpacing(0);
// Header // Header
header = new UserInfoHeaderWidget(this); header = new UserInfoHeaderWidget(this);

View file

@ -9,6 +9,7 @@
#include <QStringLiteral> #include <QStringLiteral>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <libcockatrice/settings/interface_settings.h> #include <libcockatrice/settings/interface_settings.h>
#include <libcockatrice/utility/qt_utils.h>
namespace namespace
{ {
@ -31,9 +32,7 @@ QString sectionKey(UserListWidget::Section section)
UserListPanelWidget::UserListPanelWidget(TabSupervisor *_tabSupervisor, AbstractClient *_client, QWidget *parent) UserListPanelWidget::UserListPanelWidget(TabSupervisor *_tabSupervisor, AbstractClient *_client, QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
auto *mainLayout = new QVBoxLayout(this); auto *mainLayout = QtUtils::makeLayout<QVBoxLayout>(this, 2);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setSpacing(2);
searchBar = new QLineEdit(this); searchBar = new QLineEdit(this);
searchBar->setClearButtonEnabled(true); searchBar->setClearButtonEnabled(true);

View file

@ -18,6 +18,7 @@
#include <libcockatrice/settings/interface_settings.h> #include <libcockatrice/settings/interface_settings.h>
#include <libcockatrice/settings/personal_settings.h> #include <libcockatrice/settings/personal_settings.h>
#include <libcockatrice/settings/visual_deck_storage_settings.h> #include <libcockatrice/settings/visual_deck_storage_settings.h>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
enum visualDeckStoragePromptForConversionIndex enum visualDeckStoragePromptForConversionIndex
@ -248,8 +249,7 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
updateCommanderSpellbookUiState(); updateCommanderSpellbookUiState();
auto *labelLayout = new QHBoxLayout; auto *labelLayout = QtUtils::makeLayout<QHBoxLayout>();
labelLayout->setContentsMargins(0, 0, 0, 0);
labelLayout->addWidget(&commanderSpellbookIntegrationUseOfficialBracketNamesLabel); labelLayout->addWidget(&commanderSpellbookIntegrationUseOfficialBracketNamesLabel);
labelLayout->addWidget(&commanderSpellbookIntegrationUseOfficialBracketNamesExplainer); labelLayout->addWidget(&commanderSpellbookIntegrationUseOfficialBracketNamesExplainer);

View file

@ -238,7 +238,5 @@ void ArchidektApiResponseDeckDisplayWidget::constructZoneWidgetsFromDeckListMode
void ArchidektApiResponseDeckDisplayWidget::resizeEvent(QResizeEvent *event) void ArchidektApiResponseDeckDisplayWidget::resizeEvent(QResizeEvent *event)
{ {
QWidget::resizeEvent(event); QWidget::resizeEvent(event);
layout->invalidate(); QtUtils::relayout(layout);
layout->activate();
layout->update();
} }

View file

@ -24,6 +24,7 @@
#include <QVariant> #include <QVariant>
#include <QWidget> #include <QWidget>
#include <QtGlobal> #include <QtGlobal>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
#include <version_string.h> #include <version_string.h>
@ -241,9 +242,7 @@ void ArchidektApiResponseDeckEntryDisplayWidget::updateScaledPreview()
void ArchidektApiResponseDeckEntryDisplayWidget::resizeEvent(QResizeEvent *event) void ArchidektApiResponseDeckEntryDisplayWidget::resizeEvent(QResizeEvent *event)
{ {
QWidget::resizeEvent(event); QWidget::resizeEvent(event);
layout->invalidate(); QtUtils::relayout(layout);
layout->activate();
layout->update();
} }
void ArchidektApiResponseDeckEntryDisplayWidget::actRequestNavigationToDeck() void ArchidektApiResponseDeckEntryDisplayWidget::actRequestNavigationToDeck()

View file

@ -11,6 +11,7 @@
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkRequest> #include <QNetworkRequest>
#include <QSlider> #include <QSlider>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
ArchidektApiResponseDeckListingsDisplayWidget::ArchidektApiResponseDeckListingsDisplayWidget( ArchidektApiResponseDeckListingsDisplayWidget::ArchidektApiResponseDeckListingsDisplayWidget(
@ -19,8 +20,7 @@ ArchidektApiResponseDeckListingsDisplayWidget::ArchidektApiResponseDeckListingsD
CardSizeWidget *_cardSizeSlider) CardSizeWidget *_cardSizeSlider)
: QWidget(parent), cardSizeSlider(_cardSizeSlider) : QWidget(parent), cardSizeSlider(_cardSizeSlider)
{ {
layout = new QHBoxLayout(this); layout = QtUtils::makeLayout<QHBoxLayout>(this);
layout->setContentsMargins(0, 0, 0, 0);
setLayout(layout); setLayout(layout);
flowWidget = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAsNeeded); flowWidget = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAsNeeded);
@ -64,7 +64,5 @@ void ArchidektApiResponseDeckListingsDisplayWidget::append(const ArchidektDeckLi
void ArchidektApiResponseDeckListingsDisplayWidget::resizeEvent(QResizeEvent *event) void ArchidektApiResponseDeckListingsDisplayWidget::resizeEvent(QResizeEvent *event)
{ {
QWidget::resizeEvent(event); QWidget::resizeEvent(event);
layout->invalidate(); QtUtils::relayout(layout);
layout->activate();
layout->update();
} }

View file

@ -81,9 +81,7 @@ void TabArchidekt::initializeUi()
{ {
// Main container // Main container
container = new QWidget(this); container = new QWidget(this);
mainLayout = new QVBoxLayout(container); mainLayout = QtUtils::makeLayout<QVBoxLayout>(container, 0);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setSpacing(0);
// Primary toolbar (most important filters) // Primary toolbar (most important filters)
primaryToolbar = new QWidget(container); primaryToolbar = new QWidget(container);
@ -106,9 +104,7 @@ void TabArchidekt::initializeUi()
// Color filter (inline) // Color filter (inline)
QWidget *colorWidget = new QWidget(primaryToolbar); QWidget *colorWidget = new QWidget(primaryToolbar);
QHBoxLayout *colorLayout = new QHBoxLayout(colorWidget); QHBoxLayout *colorLayout = QtUtils::makeLayout<QHBoxLayout>(colorWidget, 2);
colorLayout->setContentsMargins(0, 0, 0, 0);
colorLayout->setSpacing(2);
QString colorIdentity = "WUBRG"; QString colorIdentity = "WUBRG";
for (const QChar &color : colorIdentity) { for (const QChar &color : colorIdentity) {
@ -190,9 +186,7 @@ void TabArchidekt::initializeUi()
scrollArea = QtUtils::makeScrollArea(container); scrollArea = QtUtils::makeScrollArea(container);
resultsContainer = new QWidget(); resultsContainer = new QWidget();
resultsLayout = new QVBoxLayout(resultsContainer); resultsLayout = QtUtils::makeLayout<QVBoxLayout>(resultsContainer, 0);
resultsLayout->setContentsMargins(0, 0, 0, 0);
resultsLayout->setSpacing(0);
scrollArea->setWidget(resultsContainer); scrollArea->setWidget(resultsContainer);

View file

@ -21,6 +21,7 @@
#include <QToolButton> #include <QToolButton>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <libcockatrice/settings/deck_editor_settings.h> #include <libcockatrice/settings/deck_editor_settings.h>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
template <class T> class QSharedPointer; template <class T> class QSharedPointer;
@ -44,8 +45,7 @@ CommanderBracketWidget::CommanderBracketWidget(QWidget *parent) : QWidget(parent
connect(bracketRefreshButton, &QToolButton::clicked, this, &CommanderBracketWidget::requestBracketEstimate); connect(bracketRefreshButton, &QToolButton::clicked, this, &CommanderBracketWidget::requestBracketEstimate);
auto *layout = new QGridLayout(this); auto *layout = QtUtils::makeLayout<QGridLayout>(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(bracketLabel, 0, 0); layout->addWidget(bracketLabel, 0, 0);
auto *bracketRow = new QHBoxLayout; auto *bracketRow = new QHBoxLayout;
@ -110,8 +110,7 @@ bool CommanderBracketWidget::promptCommanderSpellbookIntegration()
// Create label + explainer button // Create label + explainer button
auto *labelWidget = new QWidget(&dialog); auto *labelWidget = new QWidget(&dialog);
auto *labelLayout = new QHBoxLayout(labelWidget); auto *labelLayout = QtUtils::makeLayout<QHBoxLayout>(labelWidget);
labelLayout->setContentsMargins(0, 0, 0, 0);
auto *namingLabel = new QLabel(tr("Bracket naming:"), labelWidget); auto *namingLabel = new QLabel(tr("Bracket naming:"), labelWidget);
auto *explainerButton = new QToolButton(labelWidget); auto *explainerButton = new QToolButton(labelWidget);

View file

@ -107,9 +107,7 @@ void EdhrecCommanderApiResponseDisplayWidget::resizeEvent(QResizeEvent *event)
{ {
QWidget::resizeEvent(event); QWidget::resizeEvent(event);
qDebug() << event->size(); qDebug() << event->size();
layout->invalidate(); QtUtils::relayout(layout);
layout->activate();
layout->update();
if (scrollArea && scrollArea->widget()) { if (scrollArea && scrollArea->widget()) {
scrollArea->widget()->resize(event->size()); scrollArea->widget()->resize(event->size());
} }

View file

@ -43,9 +43,7 @@ EdhrecTopCardsApiResponseDisplayWidget::EdhrecTopCardsApiResponseDisplayWidget(Q
void EdhrecTopCardsApiResponseDisplayWidget::resizeEvent(QResizeEvent *event) void EdhrecTopCardsApiResponseDisplayWidget::resizeEvent(QResizeEvent *event)
{ {
QWidget::resizeEvent(event); QWidget::resizeEvent(event);
layout->invalidate(); QtUtils::relayout(layout);
layout->activate();
layout->update();
if (scrollArea && scrollArea->widget()) { if (scrollArea && scrollArea->widget()) {
scrollArea->widget()->resize(event->size()); scrollArea->widget()->resize(event->size());
} }

View file

@ -48,9 +48,7 @@ void EdhrecTopCommandersApiResponseDisplayWidget::resizeEvent(QResizeEvent *even
{ {
QWidget::resizeEvent(event); QWidget::resizeEvent(event);
qDebug() << event->size(); qDebug() << event->size();
layout->invalidate(); QtUtils::relayout(layout);
layout->activate();
layout->update();
if (scrollArea && scrollArea->widget()) { if (scrollArea && scrollArea->widget()) {
scrollArea->widget()->resize(event->size()); scrollArea->widget()->resize(event->size());
} }

View file

@ -43,9 +43,7 @@ EdhrecTopTagsApiResponseDisplayWidget::EdhrecTopTagsApiResponseDisplayWidget(QWi
void EdhrecTopTagsApiResponseDisplayWidget::resizeEvent(QResizeEvent *event) void EdhrecTopTagsApiResponseDisplayWidget::resizeEvent(QResizeEvent *event)
{ {
QWidget::resizeEvent(event); QWidget::resizeEvent(event);
layout->invalidate(); QtUtils::relayout(layout);
layout->activate();
layout->update();
if (scrollArea && scrollArea->widget()) { if (scrollArea && scrollArea->widget()) {
scrollArea->widget()->resize(event->size()); scrollArea->widget()->resize(event->size());
} }

View file

@ -78,6 +78,7 @@
#include <libcockatrice/settings/debug_settings.h> #include <libcockatrice/settings/debug_settings.h>
#include <libcockatrice/settings/interface_settings.h> #include <libcockatrice/settings/interface_settings.h>
#include <libcockatrice/settings/layouts_settings.h> #include <libcockatrice/settings/layouts_settings.h>
#include <libcockatrice/utility/qt_utils.h>
#include <libcockatrice/utility/string_limits.h> #include <libcockatrice/utility/string_limits.h>
#include <qnamespace.h> #include <qnamespace.h>
#include <qobjectdefs.h> #include <qobjectdefs.h>
@ -1287,8 +1288,7 @@ void TabGame::createPlayAreaWidget(bool bReplay)
connect(game->getGameEventHandler(), &GameEventHandler::arrowDeleted, scene, &GameScene::deleteArrow); connect(game->getGameEventHandler(), &GameEventHandler::arrowDeleted, scene, &GameScene::deleteArrow);
gameView = new GameView(scene); gameView = new GameView(scene);
auto gamePlayAreaVBox = new QVBoxLayout; auto gamePlayAreaVBox = QtUtils::makeLayout<QVBoxLayout>();
gamePlayAreaVBox->setContentsMargins(0, 0, 0, 0);
gamePlayAreaVBox->addWidget(gameView); gamePlayAreaVBox->addWidget(gameView);
gamePlayAreaWidget = new QWidget; gamePlayAreaWidget = new QWidget;
@ -1320,8 +1320,7 @@ void TabGame::createDeckViewContainerWidget(bool bReplay)
deckViewContainerWidget = new QWidget(); deckViewContainerWidget = new QWidget();
deckViewContainerWidget->setObjectName("deckViewContainerWidget"); deckViewContainerWidget->setObjectName("deckViewContainerWidget");
deckViewContainerLayout = new QVBoxLayout; deckViewContainerLayout = QtUtils::makeLayout<QVBoxLayout>();
deckViewContainerLayout->setContentsMargins(0, 0, 0, 0);
deckViewContainerWidget->setLayout(deckViewContainerLayout); deckViewContainerWidget->setLayout(deckViewContainerLayout);
} }
@ -1336,8 +1335,7 @@ void TabGame::createCardInfoDock(bool bReplay)
cardInfoFrameWidget = new CardInfoFrameWidget(); cardInfoFrameWidget = new CardInfoFrameWidget();
auto cardHInfoLayout = new QHBoxLayout; auto cardHInfoLayout = new QHBoxLayout;
auto cardVInfoLayout = new QVBoxLayout; auto cardVInfoLayout = QtUtils::makeLayout<QVBoxLayout>();
cardVInfoLayout->setContentsMargins(0, 0, 0, 0);
cardVInfoLayout->addWidget(cardInfoFrameWidget); cardVInfoLayout->addWidget(cardInfoFrameWidget);
cardVInfoLayout->addLayout(cardHInfoLayout); cardVInfoLayout->addLayout(cardHInfoLayout);
@ -1364,9 +1362,7 @@ void TabGame::createPlayerListDock(bool bReplay)
playerListWidget->setFocusPolicy(Qt::NoFocus); playerListWidget->setFocusPolicy(Qt::NoFocus);
auto *playerListBox = new QWidget(this); auto *playerListBox = new QWidget(this);
auto *vbox = new QVBoxLayout(playerListBox); auto *vbox = QtUtils::makeLayout<QVBoxLayout>(playerListBox, 0);
vbox->setContentsMargins(0, 0, 0, 0);
vbox->setSpacing(0);
vbox->addWidget(playerListWidget); vbox->addWidget(playerListWidget);
@ -1391,8 +1387,7 @@ void TabGame::createPlayerListDock(bool bReplay)
void TabGame::createMessageDock(bool bReplay) void TabGame::createMessageDock(bool bReplay)
{ {
auto messageLogLayout = new QVBoxLayout; auto messageLogLayout = QtUtils::makeLayout<QVBoxLayout>();
messageLogLayout->setContentsMargins(0, 0, 0, 0);
// clock // clock
if (!bReplay) { if (!bReplay) {

View file

@ -210,8 +210,7 @@ TabReport::TabReport(TabSupervisor *_tabSupervisor, AbstractClient *_client) : T
sgLayout->addWidget(statsTrendLabel); sgLayout->addWidget(statsTrendLabel);
sgLayout->addWidget(statsCategoriesLabel); sgLayout->addWidget(statsCategoriesLabel);
sgLayout->addWidget(statsDetailText); sgLayout->addWidget(statsDetailText);
auto *statsGroupLayout = new QVBoxLayout(statsGroup); auto *statsGroupLayout = QtUtils::makeLayout<QVBoxLayout>(statsGroup);
statsGroupLayout->setContentsMargins(0, 0, 0, 0);
statsGroupLayout->addWidget(statsContent); statsGroupLayout->addWidget(statsContent);
statsGroup->setChecked(true); statsGroup->setChecked(true);
connect(statsGroup, &QGroupBox::toggled, this, [this, statsContent](bool checked) { connect(statsGroup, &QGroupBox::toggled, this, [this, statsContent](bool checked) {

View file

@ -23,6 +23,7 @@
#include <libcockatrice/protocol/pb/response.pb.h> #include <libcockatrice/protocol/pb/response.pb.h>
#include <libcockatrice/protocol/pending_command.h> #include <libcockatrice/protocol/pending_command.h>
#include <libcockatrice/settings/network_settings.h> #include <libcockatrice/settings/network_settings.h>
#include <libcockatrice/utility/qt_utils.h>
#include <optional> #include <optional>
#include <string> #include <string>
@ -46,9 +47,7 @@ TabDeckStorageVisual::TabDeckStorageVisual(TabSupervisor *_tabSupervisor, Abstra
}); });
auto *widget = new QWidget(this); auto *widget = new QWidget(this);
auto *layout = new QVBoxLayout(widget); auto *layout = QtUtils::makeLayout<QVBoxLayout>(widget, 0);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
widget->setLayout(layout); widget->setLayout(layout);
this->setCentralWidget(widget); this->setCentralWidget(widget);
layout->addWidget(visualDeckStorageWidget); layout->addWidget(visualDeckStorageWidget);

View file

@ -15,6 +15,7 @@
#include <QPushButton> #include <QPushButton>
#include <QStringLiteral> #include <QStringLiteral>
#include <QToolTip> #include <QToolTip>
#include <libcockatrice/utility/qt_utils.h>
SequenceEdit::SequenceEdit(const QString &_shortcutName, QWidget *parent) : QWidget(parent) SequenceEdit::SequenceEdit(const QString &_shortcutName, QWidget *parent) : QWidget(parent)
{ {
@ -26,9 +27,7 @@ SequenceEdit::SequenceEdit(const QString &_shortcutName, QWidget *parent) : QWid
clearButton->setIcon(themePixmap(QStringLiteral("icons/clearsearch"))); clearButton->setIcon(themePixmap(QStringLiteral("icons/clearsearch")));
defaultButton->setIcon(themePixmap(QStringLiteral("icons/update"))); defaultButton->setIcon(themePixmap(QStringLiteral("icons/update")));
auto *layout = new QHBoxLayout(this); auto *layout = QtUtils::makeLayout<QHBoxLayout>(this, 1);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(1);
layout->addWidget(lineEdit); layout->addWidget(lineEdit);
layout->addWidget(clearButton); layout->addWidget(clearButton);
layout->addWidget(defaultButton); layout->addWidget(defaultButton);

View file

@ -29,6 +29,7 @@
#include <QVariant> #include <QVariant>
#include <QWidget> #include <QWidget>
#include <QtGlobal> #include <QtGlobal>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
class DeckListModel; class DeckListModel;
@ -110,14 +111,10 @@ VisualDatabaseDisplayFilterToolbarWidget::VisualDatabaseDisplayFilterToolbarWidg
void VisualDatabaseDisplayFilterToolbarWidget::initialize() void VisualDatabaseDisplayFilterToolbarWidget::initialize()
{ {
auto sortLayout = new QHBoxLayout(sortGroupBox); auto sortLayout = QtUtils::makeLayout<QHBoxLayout>(sortGroupBox, 0);
sortLayout->setContentsMargins(0, 0, 0, 0);
sortLayout->setSpacing(0);
sortLayout->setAlignment(Qt::AlignLeft); sortLayout->setAlignment(Qt::AlignLeft);
auto filterLayout = new QHBoxLayout(filterGroupBox); auto filterLayout = QtUtils::makeLayout<QHBoxLayout>(filterGroupBox, 2);
filterLayout->setContentsMargins(0, 0, 0, 0);
filterLayout->setSpacing(2);
filterLayout->setAlignment(Qt::AlignLeft); filterLayout->setAlignment(Qt::AlignLeft);
// create settings widgets // create settings widgets

View file

@ -22,6 +22,7 @@
#include <algorithm> #include <algorithm>
#include <libcockatrice/card/database/card_database_manager.h> #include <libcockatrice/card/database/card_database_manager.h>
#include <libcockatrice/filters/filter_tree.h> #include <libcockatrice/filters/filter_tree.h>
#include <libcockatrice/utility/qt_utils.h>
#include <limits> #include <limits>
#include <qnamespace.h> #include <qnamespace.h>
@ -48,8 +49,7 @@ VisualDatabaseDisplayFormatLegalityFilterWidget::VisualDatabaseDisplayFormatLega
layout->addWidget(flowWidget); layout->addWidget(flowWidget);
// Create a container for the threshold control // Create a container for the threshold control
auto *thresholdLayout = new QHBoxLayout(); auto *thresholdLayout = QtUtils::makeLayout<QHBoxLayout>();
thresholdLayout->setContentsMargins(0, 0, 0, 0);
thresholdLabel = new QLabel(this); thresholdLabel = new QLabel(this);
thresholdLayout->addWidget(thresholdLabel); thresholdLayout->addWidget(thresholdLabel);

View file

@ -21,6 +21,7 @@
#include <QtGlobal> #include <QtGlobal>
#include <libcockatrice/card/database/card_database_manager.h> #include <libcockatrice/card/database/card_database_manager.h>
#include <libcockatrice/filters/filter_tree.h> #include <libcockatrice/filters/filter_tree.h>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
VisualDatabaseDisplayMainTypeFilterWidget::VisualDatabaseDisplayMainTypeFilterWidget(QWidget *parent, VisualDatabaseDisplayMainTypeFilterWidget::VisualDatabaseDisplayMainTypeFilterWidget(QWidget *parent,
@ -42,8 +43,7 @@ VisualDatabaseDisplayMainTypeFilterWidget::VisualDatabaseDisplayMainTypeFilterWi
layout->addWidget(flowWidget); layout->addWidget(flowWidget);
// Create a container for the threshold control // Create a container for the threshold control
auto *thresholdLayout = new QHBoxLayout(); auto *thresholdLayout = QtUtils::makeLayout<QHBoxLayout>();
thresholdLayout->setContentsMargins(0, 0, 0, 0);
thresholdLabel = new QLabel(this); thresholdLabel = new QLabel(this);
thresholdLayout->addWidget(thresholdLabel); thresholdLayout->addWidget(thresholdLabel);

View file

@ -30,13 +30,13 @@
#include <libcockatrice/card/database/card_database_manager.h> #include <libcockatrice/card/database/card_database_manager.h>
#include <libcockatrice/filters/filter_tree.h> #include <libcockatrice/filters/filter_tree.h>
#include <libcockatrice/settings/visual_deck_storage_settings.h> #include <libcockatrice/settings/visual_deck_storage_settings.h>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
VisualDatabaseDisplayRecentSetFilterSettingsWidget::VisualDatabaseDisplayRecentSetFilterSettingsWidget(QWidget *parent) VisualDatabaseDisplayRecentSetFilterSettingsWidget::VisualDatabaseDisplayRecentSetFilterSettingsWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
layout = new QHBoxLayout(this); layout = QtUtils::makeLayout<QHBoxLayout>(this);
layout->setContentsMargins(0, 0, 0, 0);
setLayout(layout); setLayout(layout);

View file

@ -22,6 +22,7 @@
#include <QtGlobal> #include <QtGlobal>
#include <libcockatrice/card/database/card_database_manager.h> #include <libcockatrice/card/database/card_database_manager.h>
#include <libcockatrice/filters/filter_tree.h> #include <libcockatrice/filters/filter_tree.h>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
VisualDatabaseDisplaySubTypeFilterWidget::VisualDatabaseDisplaySubTypeFilterWidget(QWidget *parent, VisualDatabaseDisplaySubTypeFilterWidget::VisualDatabaseDisplaySubTypeFilterWidget(QWidget *parent,
@ -47,8 +48,7 @@ VisualDatabaseDisplaySubTypeFilterWidget::VisualDatabaseDisplaySubTypeFilterWidg
layout->addWidget(flowWidget); layout->addWidget(flowWidget);
// Create a container for the threshold control // Create a container for the threshold control
auto *thresholdLayout = new QHBoxLayout(); auto *thresholdLayout = QtUtils::makeLayout<QHBoxLayout>();
thresholdLayout->setContentsMargins(0, 0, 0, 0);
thresholdLabel = new QLabel(this); thresholdLabel = new QLabel(this);
thresholdLayout->addWidget(thresholdLabel); thresholdLayout->addWidget(thresholdLabel);

View file

@ -54,6 +54,7 @@
#include <libcockatrice/card/database/card_database_manager.h> #include <libcockatrice/card/database/card_database_manager.h>
#include <libcockatrice/deck_list/tree/inner_deck_list_node.h> #include <libcockatrice/deck_list/tree/inner_deck_list_node.h>
#include <libcockatrice/settings/cards_display_settings.h> #include <libcockatrice/settings/cards_display_settings.h>
#include <libcockatrice/utility/qt_utils.h>
#include <utility> #include <utility>
class QMouseEvent; class QMouseEvent;
@ -92,10 +93,8 @@ VisualDatabaseDisplayWidget::VisualDatabaseDisplayWidget(QWidget *parent,
// Set up main layout and widgets // Set up main layout and widgets
setMinimumSize(0, 0); setMinimumSize(0, 0);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
mainLayout = new QVBoxLayout(this); mainLayout = QtUtils::makeLayout<QVBoxLayout>(this, 0, 1);
setLayout(mainLayout); setLayout(mainLayout);
mainLayout->setSpacing(1);
mainLayout->setContentsMargins(0, 0, 0, 0);
flowWidget = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarPolicy::ScrollBarAsNeeded); flowWidget = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarPolicy::ScrollBarAsNeeded);
cardSizeWidget = new CardSizeWidget(this, flowWidget, cardSizeWidget = new CardSizeWidget(this, flowWidget,

View file

@ -26,9 +26,7 @@
VisualDeckDisplayOptionsWidget::VisualDeckDisplayOptionsWidget(QWidget *parent) : QWidget(parent) VisualDeckDisplayOptionsWidget::VisualDeckDisplayOptionsWidget(QWidget *parent) : QWidget(parent)
{ {
groupAndSortLayout = new QHBoxLayout(this); groupAndSortLayout = QtUtils::makeLayout<QHBoxLayout>(this, 3);
groupAndSortLayout->setContentsMargins(0, 0, 0, 0);
groupAndSortLayout->setSpacing(3);
groupAndSortLayout->setAlignment(Qt::AlignLeft); groupAndSortLayout->setAlignment(Qt::AlignLeft);
this->setLayout(groupAndSortLayout); this->setLayout(groupAndSortLayout);

View file

@ -25,6 +25,7 @@
#include <compare> #include <compare>
#include <libcockatrice/card/database/card_database_manager.h> #include <libcockatrice/card/database/card_database_manager.h>
#include <libcockatrice/settings/cards_display_settings.h> #include <libcockatrice/settings/cards_display_settings.h>
#include <libcockatrice/utility/qt_utils.h>
#include <qlogging.h> #include <qlogging.h>
#include <qnamespace.h> #include <qnamespace.h>
#include <qobjectdefs.h> #include <qobjectdefs.h>
@ -41,9 +42,7 @@ VisualDeckEditorSampleHandWidget::VisualDeckEditorSampleHandWidget(QWidget *pare
layout->setSpacing(0); layout->setSpacing(0);
setLayout(layout); setLayout(layout);
auto upperLayout = new QVBoxLayout(); auto upperLayout = QtUtils::makeLayout<QVBoxLayout>(nullptr, 0);
upperLayout->setContentsMargins(0, 0, 0, 0);
upperLayout->setSpacing(0);
resetAndHandSizeContainerWidget = new QWidget(this); resetAndHandSizeContainerWidget = new QWidget(this);
resetAndHandSizeLayout = new QHBoxLayout(resetAndHandSizeContainerWidget); resetAndHandSizeLayout = new QHBoxLayout(resetAndHandSizeContainerWidget);

View file

@ -16,6 +16,7 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QSizePolicy> #include <QSizePolicy>
#include <libcockatrice/settings/paths_settings.h> #include <libcockatrice/settings/paths_settings.h>
#include <libcockatrice/utility/qt_utils.h>
#include <optional> #include <optional>
#include <qnamespace.h> #include <qnamespace.h>
@ -26,8 +27,7 @@ DeckPreviewDeckTagsDisplayWidget::DeckPreviewDeckTagsDisplayWidget(QWidget *_par
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
// Create layout // Create layout
auto *layout = new QHBoxLayout(this); auto *layout = QtUtils::makeLayout<QHBoxLayout>(this);
layout->setContentsMargins(0, 0, 0, 0);
setFixedHeight(100); setFixedHeight(100);

View file

@ -2,13 +2,12 @@
#include <QCheckBox> #include <QCheckBox>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <libcockatrice/utility/qt_utils.h>
DeckPreviewTagItemWidget::DeckPreviewTagItemWidget(const QString &tagName, bool isChecked, QWidget *parent) DeckPreviewTagItemWidget::DeckPreviewTagItemWidget(const QString &tagName, bool isChecked, QWidget *parent)
: QWidget(parent), checkBox_(new QCheckBox(this)) : QWidget(parent), checkBox_(new QCheckBox(this))
{ {
auto *layout = new QHBoxLayout(this); auto *layout = QtUtils::makeLayout<QHBoxLayout>(this, 5);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(5);
checkBox_->setText(tagName); // Set the tag name as the checkbox label checkBox_->setText(tagName); // Set the tag name as the checkbox label
checkBox_->setChecked(isChecked); // Set the initial state of the checkbox checkBox_->setChecked(isChecked); // Set the initial state of the checkbox

View file

@ -16,6 +16,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <libcockatrice/card/database/card_database_manager.h> #include <libcockatrice/card/database/card_database_manager.h>
#include <libcockatrice/settings/visual_deck_storage_settings.h> #include <libcockatrice/settings/visual_deck_storage_settings.h>
#include <libcockatrice/utility/qt_utils.h>
#include <qnamespace.h> #include <qnamespace.h>
PublicDeckPreviewWidget::PublicDeckPreviewWidget(QWidget *parent, const RemotePublicDecksModel::DeckEntry &entry) PublicDeckPreviewWidget::PublicDeckPreviewWidget(QWidget *parent, const RemotePublicDecksModel::DeckEntry &entry)
@ -36,8 +37,7 @@ PublicDeckPreviewWidget::PublicDeckPreviewWidget(QWidget *parent, const RemotePu
tagsFlowWidget = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAsNeeded); tagsFlowWidget = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAsNeeded);
tagsFlowWidget->setSpacing(3, 3); tagsFlowWidget->setSpacing(3, 3);
auto *layout = new QVBoxLayout(this); auto *layout = QtUtils::makeLayout<QVBoxLayout>(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(bannerCardDisplayWidget); layout->addWidget(bannerCardDisplayWidget);
layout->addWidget(uploadTimeLabel); layout->addWidget(uploadTimeLabel);
layout->addWidget(colorIdentityWidget); layout->addWidget(colorIdentityWidget);

View file

@ -9,6 +9,7 @@
#include <QLineEdit> #include <QLineEdit>
#include <QStringLiteral> #include <QStringLiteral>
#include <QTimer> #include <QTimer>
#include <libcockatrice/utility/qt_utils.h>
/** /**
* @brief Constructs a search bar for filtering decks in the Visual Deck Storage. * @brief Constructs a search bar for filtering decks in the Visual Deck Storage.
@ -20,8 +21,7 @@
*/ */
VisualDeckStorageSearchWidget::VisualDeckStorageSearchWidget(QWidget *parent) : QWidget(parent) VisualDeckStorageSearchWidget::VisualDeckStorageSearchWidget(QWidget *parent) : QWidget(parent)
{ {
layout = new QHBoxLayout(this); layout = QtUtils::makeLayout<QHBoxLayout>(this);
layout->setContentsMargins(0, 0, 0, 0);
setLayout(layout); setLayout(layout);
searchBar = new QLineEdit(this); searchBar = new QLineEdit(this);

View file

@ -7,11 +7,11 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QtGlobal> #include <QtGlobal>
#include <libcockatrice/settings/visual_deck_storage_settings.h> #include <libcockatrice/settings/visual_deck_storage_settings.h>
#include <libcockatrice/utility/qt_utils.h>
VisualDeckStorageSortWidget::VisualDeckStorageSortWidget(VisualDeckStorageWidget *parent) : QWidget(parent) VisualDeckStorageSortWidget::VisualDeckStorageSortWidget(VisualDeckStorageWidget *parent) : QWidget(parent)
{ {
layout = new QHBoxLayout(this); layout = QtUtils::makeLayout<QHBoxLayout>(this);
layout->setContentsMargins(0, 0, 0, 0);
setLayout(layout); setLayout(layout);
// Initialize the ComboBox // Initialize the ComboBox