[Home] Keep actions bounded and reachable at every window height (#7747)

This commit is contained in:
Bryce! 2026-11-04 11:06:58 -05:00 • committed by GitHub
parent 5ea16c805f
commit d944273335
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 30 additions and 30 deletions

View file

@ -1,4 +1,4 @@
<events> <events>
<!-- Open a new deck editor tab from the home page --> <!-- Open a new deck editor tab from the home page -->
<event widget="MainWindow/tabSupervisor/stackedWidget/TabHome/homeWidget/homeButtonsBox/homeCreateNewDeckButton" command="activate" arguments="" /> <event widget="MainWindow/tabSupervisor/stackedWidget/TabHome/homeWidget/homeActionsScrollArea/qt_scrollarea_viewport/homeButtonsBox/homeCreateNewDeckButton" command="activate" arguments="" />
</events> </events>

View file

@ -1,6 +1,6 @@
<events> <events>
<!-- Open a new visual deck editor tab from the home page --> <!-- Open a new visual deck editor tab from the home page -->
<event widget="MainWindow/tabSupervisor/stackedWidget/TabHome/homeWidget/homeButtonsBox/homeCreateNewDeckButton" command="activate" arguments="" /> <event widget="MainWindow/tabSupervisor/stackedWidget/TabHome/homeWidget/homeActionsScrollArea/qt_scrollarea_viewport/homeButtonsBox/homeCreateNewDeckButton" command="activate" arguments="" />
<!-- Type "Lightning" into the search box (keycodes for L-i-g-h-t-n-i-n-g) --> <!-- Type "Lightning" into the search box (keycodes for L-i-g-h-t-n-i-n-g) -->
<event widget="MainWindow/tabSupervisor/stackedWidget/TabDeckEditorVisual/databaseDisplayDock/databaseDisplayDockContents/databaseDisplayWidget/searchEdit" command="key" arguments="76" /> <event widget="MainWindow/tabSupervisor/stackedWidget/TabDeckEditorVisual/databaseDisplayDock/databaseDisplayDockContents/databaseDisplayWidget/searchEdit" command="key" arguments="76" />
<event widget="MainWindow/tabSupervisor/stackedWidget/TabDeckEditorVisual/databaseDisplayDock/databaseDisplayDockContents/databaseDisplayWidget/searchEdit" command="key" arguments="105" /> <event widget="MainWindow/tabSupervisor/stackedWidget/TabDeckEditorVisual/databaseDisplayDock/databaseDisplayDockContents/databaseDisplayWidget/searchEdit" command="key" arguments="105" />

View file

@ -36,7 +36,7 @@
<event widget="MainWindow/settingsDialog/settingsOkButton" command="activate" arguments="" /> <event widget="MainWindow/settingsDialog/settingsOkButton" command="activate" arguments="" />
<!-- Tier 3: Open deck editor from home and type in search --> <!-- Tier 3: Open deck editor from home and type in search -->
<event widget="MainWindow/tabSupervisor/stackedWidget/TabHome/homeWidget/homeButtonsBox/homeCreateNewDeckButton" command="activate" arguments="" /> <event widget="MainWindow/tabSupervisor/stackedWidget/TabHome/homeWidget/homeActionsScrollArea/qt_scrollarea_viewport/homeButtonsBox/homeCreateNewDeckButton" command="activate" arguments="" />
<event widget="MainWindow/tabSupervisor/stackedWidget/TabDeckEditorVisual/databaseDisplayDock/databaseDisplayDockContents/databaseDisplayWidget/searchEdit" command="key" arguments="76" /> <event widget="MainWindow/tabSupervisor/stackedWidget/TabDeckEditorVisual/databaseDisplayDock/databaseDisplayDockContents/databaseDisplayWidget/searchEdit" command="key" arguments="76" />
<event widget="MainWindow/tabSupervisor/stackedWidget/TabDeckEditorVisual/databaseDisplayDock/databaseDisplayDockContents/databaseDisplayWidget/searchEdit" command="key" arguments="105" /> <event widget="MainWindow/tabSupervisor/stackedWidget/TabDeckEditorVisual/databaseDisplayDock/databaseDisplayDockContents/databaseDisplayWidget/searchEdit" command="key" arguments="105" />
<event widget="MainWindow/tabSupervisor/stackedWidget/TabDeckEditorVisual/databaseDisplayDock/databaseDisplayDockContents/databaseDisplayWidget/searchEdit" command="key" arguments="103" /> <event widget="MainWindow/tabSupervisor/stackedWidget/TabDeckEditorVisual/databaseDisplayDock/databaseDisplayDockContents/databaseDisplayWidget/searchEdit" command="key" arguments="103" />

View file

@ -21,8 +21,8 @@ class QWidget;
HomeStyledButton::HomeStyledButton(const QString &text, QPair<QColor, QColor> _gradientColors, QWidget *parent) HomeStyledButton::HomeStyledButton(const QString &text, QPair<QColor, QColor> _gradientColors, QWidget *parent)
: QPushButton(text, parent), gradientColors(_gradientColors) : QPushButton(text, parent), gradientColors(_gradientColors)
{ {
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // Keep the font/style-derived height even when the home page has ample space.
setMinimumHeight(25); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setStyleSheet(generateButtonStylesheet(gradientColors)); setStyleSheet(generateButtonStylesheet(gradientColors));
applyInterfaceDefaultFont(); applyInterfaceDefaultFont();
connect(themeManager, &ThemeManager::fontsChanged, this, &HomeStyledButton::applyInterfaceDefaultFont); connect(themeManager, &ThemeManager::fontsChanged, this, &HomeStyledButton::applyInterfaceDefaultFont);

View file

@ -27,10 +27,11 @@
#include <QFlags> #include <QFlags>
#include <QFont> #include <QFont>
#include <QFontMetrics> #include <QFontMetrics>
#include <QGridLayout> #include <QFrame>
#include <QGroupBox> #include <QGroupBox>
#include <QImage> #include <QImage>
#include <QLabel> #include <QLabel>
#include <QLayout>
#include <QLinearGradient> #include <QLinearGradient>
#include <QList> #include <QList>
#include <QMap> #include <QMap>
@ -44,9 +45,9 @@
#include <QRect> #include <QRect>
#include <QRectF> #include <QRectF>
#include <QRgb> #include <QRgb>
#include <QScrollArea>
#include <QSharedPointer> #include <QSharedPointer>
#include <QSize> #include <QSize>
#include <QSizePolicy>
#include <QString> #include <QString>
#include <QStringLiteral> #include <QStringLiteral>
#include <QTimer> #include <QTimer>
@ -60,6 +61,7 @@
#include <libcockatrice/network/client/remote/remote_client.h> #include <libcockatrice/network/client/remote/remote_client.h>
#include <libcockatrice/settings/appearance_settings.h> #include <libcockatrice/settings/appearance_settings.h>
#include <libcockatrice/settings/paths_settings.h> #include <libcockatrice/settings/paths_settings.h>
#include <libcockatrice/utility/qt_utils.h>
#include <optional> #include <optional>
#include <qlogging.h> #include <qlogging.h>
#include <qnamespace.h> #include <qnamespace.h>
@ -69,20 +71,25 @@ HomeWidget::HomeWidget(QWidget *parent, TabSupervisor *_tabSupervisor)
: QWidget(parent), tabSupervisor(_tabSupervisor), background(themePixmap(QStringLiteral("backgrounds/home"))) : QWidget(parent), tabSupervisor(_tabSupervisor), background(themePixmap(QStringLiteral("backgrounds/home")))
{ {
setObjectName("homeWidget"); setObjectName("homeWidget");
layout = new QGridLayout(this);
backgroundSourceCard = new CardInfoPictureArtCropWidget(this); backgroundSourceCard = new CardInfoPictureArtCropWidget(this);
gradientColors = determineButtonColor(); gradientColors = determineButtonColor();
layout->addWidget(createButtons(), 1, 1, Qt::AlignVCenter | Qt::AlignHCenter); // The launcher keeps its natural size on a large display and stays centred in the
// viewport. On a small window it scrolls, instead of its combined minimum height
// becoming the minimum height of the entire application.
auto *scrollArea = QtUtils::makeScrollArea(this, Qt::ScrollBarAsNeeded, Qt::ScrollBarAsNeeded);
scrollArea->setObjectName("homeActionsScrollArea");
scrollArea->setFrameShape(QFrame::NoFrame);
scrollArea->setWidgetResizable(false);
scrollArea->setAlignment(Qt::AlignCenter);
// The home background is painted by this widget, so let it show through the viewport.
scrollArea->viewport()->setAutoFillBackground(false);
scrollArea->setWidget(createButtons());
layout->setRowStretch(0, 1); auto *layout = new QVBoxLayout(this);
layout->setRowStretch(2, 1); layout->addWidget(scrollArea);
layout->setColumnStretch(0, 1);
layout->setColumnStretch(2, 1);
setLayout(layout);
cardChangeTimer = new QTimer(this); cardChangeTimer = new QTimer(this);
connect(cardChangeTimer, &QTimer::timeout, this, &HomeWidget::updateRandomCard); connect(cardChangeTimer, &QTimer::timeout, this, &HomeWidget::updateRandomCard);
@ -289,18 +296,10 @@ QGroupBox *HomeWidget::createButtons()
{ {
QGroupBox *box = new QGroupBox(this); QGroupBox *box = new QGroupBox(this);
box->setObjectName("homeButtonsBox"); box->setObjectName("homeButtonsBox");
box->setStyleSheet(R"( // The box only stacks the logo and the actions: no frame, and no background of its
QGroupBox { // own, so the home background art stays visible. It never shows a title. The rule is
color: white; /* Title text color */ // load-bearing: QScrollArea::setWidget() turns autoFillBackground on for its widget.
background: transparent; box->setStyleSheet("QGroupBox { background: transparent; border: none; }");
}
QGroupBox::title {
color: white;
subcontrol-origin: margin;
subcontrol-position: top center; /* or top left / right */
}
)");
// Family comes from the InterfaceDefault theme role; the 20px size stays caller-side. // Family comes from the InterfaceDefault theme role; the 20px size stays caller-side.
auto applyBoxFont = [box]() { auto applyBoxFont = [box]() {
QFont boxFont = themeManager->appFont(AppFont::InterfaceDefault); QFont boxFont = themeManager->appFont(AppFont::InterfaceDefault);
@ -309,9 +308,12 @@ QGroupBox *HomeWidget::createButtons()
}; };
applyBoxFont(); applyBoxFont();
connect(themeManager, &ThemeManager::fontsChanged, this, applyBoxFont); connect(themeManager, &ThemeManager::fontsChanged, this, applyBoxFont);
box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QVBoxLayout *boxLayout = new QVBoxLayout; QVBoxLayout *boxLayout = new QVBoxLayout;
boxLayout->setAlignment(Qt::AlignHCenter); boxLayout->setAlignment(Qt::AlignHCenter);
// The scroll area is not resizable, so the box has to size itself: SetFixedSize keeps
// it at its content size and re-fixes it whenever the labels or fonts change, which is
// what makes the scroll area's scroll bars follow the content.
boxLayout->setSizeConstraint(QLayout::SetFixedSize);
logoLabel = new QLabel; logoLabel = new QLabel;
logoLabel->setAlignment(Qt::AlignCenter); logoLabel->setAlignment(Qt::AlignCenter);

View file

@ -16,7 +16,6 @@
#include <libcockatrice/network/client/abstract/abstract_client.h> #include <libcockatrice/network/client/abstract/abstract_client.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
class QGridLayout;
class QLabel; class QLabel;
class CardInfoPictureArtCropWidget; class CardInfoPictureArtCropWidget;
class ExactCard; class ExactCard;
@ -46,7 +45,6 @@ public slots:
void updateConnectButton(const ClientStatus status); void updateConnectButton(const ClientStatus status);
private: private:
QGridLayout *layout;
QTimer *cardChangeTimer; QTimer *cardChangeTimer;
TabSupervisor *tabSupervisor; TabSupervisor *tabSupervisor;
QPixmap background; QPixmap background;