mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-06 18:13:29 -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
|
|
@ -238,7 +238,5 @@ void ArchidektApiResponseDeckDisplayWidget::constructZoneWidgetsFromDeckListMode
|
|||
void ArchidektApiResponseDeckDisplayWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
layout->invalidate();
|
||||
layout->activate();
|
||||
layout->update();
|
||||
QtUtils::relayout(layout);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include <QVariant>
|
||||
#include <QWidget>
|
||||
#include <QtGlobal>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
#include <version_string.h>
|
||||
|
||||
|
|
@ -241,9 +242,7 @@ void ArchidektApiResponseDeckEntryDisplayWidget::updateScaledPreview()
|
|||
void ArchidektApiResponseDeckEntryDisplayWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
layout->invalidate();
|
||||
layout->activate();
|
||||
layout->update();
|
||||
QtUtils::relayout(layout);
|
||||
}
|
||||
|
||||
void ArchidektApiResponseDeckEntryDisplayWidget::actRequestNavigationToDeck()
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QSlider>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
ArchidektApiResponseDeckListingsDisplayWidget::ArchidektApiResponseDeckListingsDisplayWidget(
|
||||
|
|
@ -19,8 +20,7 @@ ArchidektApiResponseDeckListingsDisplayWidget::ArchidektApiResponseDeckListingsD
|
|||
CardSizeWidget *_cardSizeSlider)
|
||||
: QWidget(parent), cardSizeSlider(_cardSizeSlider)
|
||||
{
|
||||
layout = new QHBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout = QtUtils::makeLayout<QHBoxLayout>(this);
|
||||
setLayout(layout);
|
||||
|
||||
flowWidget = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAsNeeded);
|
||||
|
|
@ -64,7 +64,5 @@ void ArchidektApiResponseDeckListingsDisplayWidget::append(const ArchidektDeckLi
|
|||
void ArchidektApiResponseDeckListingsDisplayWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
layout->invalidate();
|
||||
layout->activate();
|
||||
layout->update();
|
||||
QtUtils::relayout(layout);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,9 +81,7 @@ void TabArchidekt::initializeUi()
|
|||
{
|
||||
// Main container
|
||||
container = new QWidget(this);
|
||||
mainLayout = new QVBoxLayout(container);
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
mainLayout->setSpacing(0);
|
||||
mainLayout = QtUtils::makeLayout<QVBoxLayout>(container, 0);
|
||||
|
||||
// Primary toolbar (most important filters)
|
||||
primaryToolbar = new QWidget(container);
|
||||
|
|
@ -106,9 +104,7 @@ void TabArchidekt::initializeUi()
|
|||
|
||||
// Color filter (inline)
|
||||
QWidget *colorWidget = new QWidget(primaryToolbar);
|
||||
QHBoxLayout *colorLayout = new QHBoxLayout(colorWidget);
|
||||
colorLayout->setContentsMargins(0, 0, 0, 0);
|
||||
colorLayout->setSpacing(2);
|
||||
QHBoxLayout *colorLayout = QtUtils::makeLayout<QHBoxLayout>(colorWidget, 2);
|
||||
|
||||
QString colorIdentity = "WUBRG";
|
||||
for (const QChar &color : colorIdentity) {
|
||||
|
|
@ -190,9 +186,7 @@ void TabArchidekt::initializeUi()
|
|||
scrollArea = QtUtils::makeScrollArea(container);
|
||||
|
||||
resultsContainer = new QWidget();
|
||||
resultsLayout = new QVBoxLayout(resultsContainer);
|
||||
resultsLayout->setContentsMargins(0, 0, 0, 0);
|
||||
resultsLayout->setSpacing(0);
|
||||
resultsLayout = QtUtils::makeLayout<QVBoxLayout>(resultsContainer, 0);
|
||||
|
||||
scrollArea->setWidget(resultsContainer);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include <QToolButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <libcockatrice/settings/deck_editor_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
template <class T> class QSharedPointer;
|
||||
|
|
@ -44,8 +45,7 @@ CommanderBracketWidget::CommanderBracketWidget(QWidget *parent) : QWidget(parent
|
|||
|
||||
connect(bracketRefreshButton, &QToolButton::clicked, this, &CommanderBracketWidget::requestBracketEstimate);
|
||||
|
||||
auto *layout = new QGridLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
auto *layout = QtUtils::makeLayout<QGridLayout>(this);
|
||||
layout->addWidget(bracketLabel, 0, 0);
|
||||
|
||||
auto *bracketRow = new QHBoxLayout;
|
||||
|
|
@ -110,8 +110,7 @@ bool CommanderBracketWidget::promptCommanderSpellbookIntegration()
|
|||
|
||||
// Create label + explainer button
|
||||
auto *labelWidget = new QWidget(&dialog);
|
||||
auto *labelLayout = new QHBoxLayout(labelWidget);
|
||||
labelLayout->setContentsMargins(0, 0, 0, 0);
|
||||
auto *labelLayout = QtUtils::makeLayout<QHBoxLayout>(labelWidget);
|
||||
|
||||
auto *namingLabel = new QLabel(tr("Bracket naming:"), labelWidget);
|
||||
auto *explainerButton = new QToolButton(labelWidget);
|
||||
|
|
|
|||
|
|
@ -107,9 +107,7 @@ void EdhrecCommanderApiResponseDisplayWidget::resizeEvent(QResizeEvent *event)
|
|||
{
|
||||
QWidget::resizeEvent(event);
|
||||
qDebug() << event->size();
|
||||
layout->invalidate();
|
||||
layout->activate();
|
||||
layout->update();
|
||||
QtUtils::relayout(layout);
|
||||
if (scrollArea && scrollArea->widget()) {
|
||||
scrollArea->widget()->resize(event->size());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,9 +43,7 @@ EdhrecTopCardsApiResponseDisplayWidget::EdhrecTopCardsApiResponseDisplayWidget(Q
|
|||
void EdhrecTopCardsApiResponseDisplayWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
layout->invalidate();
|
||||
layout->activate();
|
||||
layout->update();
|
||||
QtUtils::relayout(layout);
|
||||
if (scrollArea && scrollArea->widget()) {
|
||||
scrollArea->widget()->resize(event->size());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,9 +48,7 @@ void EdhrecTopCommandersApiResponseDisplayWidget::resizeEvent(QResizeEvent *even
|
|||
{
|
||||
QWidget::resizeEvent(event);
|
||||
qDebug() << event->size();
|
||||
layout->invalidate();
|
||||
layout->activate();
|
||||
layout->update();
|
||||
QtUtils::relayout(layout);
|
||||
if (scrollArea && scrollArea->widget()) {
|
||||
scrollArea->widget()->resize(event->size());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,9 +43,7 @@ EdhrecTopTagsApiResponseDisplayWidget::EdhrecTopTagsApiResponseDisplayWidget(QWi
|
|||
void EdhrecTopTagsApiResponseDisplayWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
layout->invalidate();
|
||||
layout->activate();
|
||||
layout->update();
|
||||
QtUtils::relayout(layout);
|
||||
if (scrollArea && scrollArea->widget()) {
|
||||
scrollArea->widget()->resize(event->size());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@
|
|||
#include <libcockatrice/settings/debug_settings.h>
|
||||
#include <libcockatrice/settings/interface_settings.h>
|
||||
#include <libcockatrice/settings/layouts_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
#include <qnamespace.h>
|
||||
#include <qobjectdefs.h>
|
||||
|
|
@ -1287,8 +1288,7 @@ void TabGame::createPlayAreaWidget(bool bReplay)
|
|||
connect(game->getGameEventHandler(), &GameEventHandler::arrowDeleted, scene, &GameScene::deleteArrow);
|
||||
gameView = new GameView(scene);
|
||||
|
||||
auto gamePlayAreaVBox = new QVBoxLayout;
|
||||
gamePlayAreaVBox->setContentsMargins(0, 0, 0, 0);
|
||||
auto gamePlayAreaVBox = QtUtils::makeLayout<QVBoxLayout>();
|
||||
gamePlayAreaVBox->addWidget(gameView);
|
||||
|
||||
gamePlayAreaWidget = new QWidget;
|
||||
|
|
@ -1320,8 +1320,7 @@ void TabGame::createDeckViewContainerWidget(bool bReplay)
|
|||
|
||||
deckViewContainerWidget = new QWidget();
|
||||
deckViewContainerWidget->setObjectName("deckViewContainerWidget");
|
||||
deckViewContainerLayout = new QVBoxLayout;
|
||||
deckViewContainerLayout->setContentsMargins(0, 0, 0, 0);
|
||||
deckViewContainerLayout = QtUtils::makeLayout<QVBoxLayout>();
|
||||
deckViewContainerWidget->setLayout(deckViewContainerLayout);
|
||||
}
|
||||
|
||||
|
|
@ -1336,8 +1335,7 @@ void TabGame::createCardInfoDock(bool bReplay)
|
|||
|
||||
cardInfoFrameWidget = new CardInfoFrameWidget();
|
||||
auto cardHInfoLayout = new QHBoxLayout;
|
||||
auto cardVInfoLayout = new QVBoxLayout;
|
||||
cardVInfoLayout->setContentsMargins(0, 0, 0, 0);
|
||||
auto cardVInfoLayout = QtUtils::makeLayout<QVBoxLayout>();
|
||||
cardVInfoLayout->addWidget(cardInfoFrameWidget);
|
||||
cardVInfoLayout->addLayout(cardHInfoLayout);
|
||||
|
||||
|
|
@ -1364,9 +1362,7 @@ void TabGame::createPlayerListDock(bool bReplay)
|
|||
playerListWidget->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
auto *playerListBox = new QWidget(this);
|
||||
auto *vbox = new QVBoxLayout(playerListBox);
|
||||
vbox->setContentsMargins(0, 0, 0, 0);
|
||||
vbox->setSpacing(0);
|
||||
auto *vbox = QtUtils::makeLayout<QVBoxLayout>(playerListBox, 0);
|
||||
|
||||
vbox->addWidget(playerListWidget);
|
||||
|
||||
|
|
@ -1391,8 +1387,7 @@ void TabGame::createPlayerListDock(bool bReplay)
|
|||
|
||||
void TabGame::createMessageDock(bool bReplay)
|
||||
{
|
||||
auto messageLogLayout = new QVBoxLayout;
|
||||
messageLogLayout->setContentsMargins(0, 0, 0, 0);
|
||||
auto messageLogLayout = QtUtils::makeLayout<QVBoxLayout>();
|
||||
|
||||
// clock
|
||||
if (!bReplay) {
|
||||
|
|
|
|||
|
|
@ -210,8 +210,7 @@ TabReport::TabReport(TabSupervisor *_tabSupervisor, AbstractClient *_client) : T
|
|||
sgLayout->addWidget(statsTrendLabel);
|
||||
sgLayout->addWidget(statsCategoriesLabel);
|
||||
sgLayout->addWidget(statsDetailText);
|
||||
auto *statsGroupLayout = new QVBoxLayout(statsGroup);
|
||||
statsGroupLayout->setContentsMargins(0, 0, 0, 0);
|
||||
auto *statsGroupLayout = QtUtils::makeLayout<QVBoxLayout>(statsGroup);
|
||||
statsGroupLayout->addWidget(statsContent);
|
||||
statsGroup->setChecked(true);
|
||||
connect(statsGroup, &QGroupBox::toggled, this, [this, statsContent](bool checked) {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include <libcockatrice/protocol/pb/response.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/settings/network_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
|
|
@ -46,9 +47,7 @@ TabDeckStorageVisual::TabDeckStorageVisual(TabSupervisor *_tabSupervisor, Abstra
|
|||
});
|
||||
|
||||
auto *widget = new QWidget(this);
|
||||
auto *layout = new QVBoxLayout(widget);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setSpacing(0);
|
||||
auto *layout = QtUtils::makeLayout<QVBoxLayout>(widget, 0);
|
||||
widget->setLayout(layout);
|
||||
this->setCentralWidget(widget);
|
||||
layout->addWidget(visualDeckStorageWidget);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue