mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 01:23:24 -08:00
[Home] Keep actions bounded and reachable at every window height (#7747)
This commit is contained in:
parent
5ea16c805f
commit
d944273335
6 changed files with 30 additions and 30 deletions
|
|
@ -1,4 +1,4 @@
|
|||
<events>
|
||||
<!-- 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>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<events>
|
||||
<!-- 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) -->
|
||||
<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" />
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
<event widget="MainWindow/settingsDialog/settingsOkButton" command="activate" arguments="" />
|
||||
|
||||
<!-- 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="105" />
|
||||
<event widget="MainWindow/tabSupervisor/stackedWidget/TabDeckEditorVisual/databaseDisplayDock/databaseDisplayDockContents/databaseDisplayWidget/searchEdit" command="key" arguments="103" />
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ class QWidget;
|
|||
HomeStyledButton::HomeStyledButton(const QString &text, QPair<QColor, QColor> _gradientColors, QWidget *parent)
|
||||
: QPushButton(text, parent), gradientColors(_gradientColors)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
setMinimumHeight(25);
|
||||
// Keep the font/style-derived height even when the home page has ample space.
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
setStyleSheet(generateButtonStylesheet(gradientColors));
|
||||
applyInterfaceDefaultFont();
|
||||
connect(themeManager, &ThemeManager::fontsChanged, this, &HomeStyledButton::applyInterfaceDefaultFont);
|
||||
|
|
|
|||
|
|
@ -27,10 +27,11 @@
|
|||
#include <QFlags>
|
||||
#include <QFont>
|
||||
#include <QFontMetrics>
|
||||
#include <QGridLayout>
|
||||
#include <QFrame>
|
||||
#include <QGroupBox>
|
||||
#include <QImage>
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
#include <QLinearGradient>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
|
|
@ -44,9 +45,9 @@
|
|||
#include <QRect>
|
||||
#include <QRectF>
|
||||
#include <QRgb>
|
||||
#include <QScrollArea>
|
||||
#include <QSharedPointer>
|
||||
#include <QSize>
|
||||
#include <QSizePolicy>
|
||||
#include <QString>
|
||||
#include <QStringLiteral>
|
||||
#include <QTimer>
|
||||
|
|
@ -60,6 +61,7 @@
|
|||
#include <libcockatrice/network/client/remote/remote_client.h>
|
||||
#include <libcockatrice/settings/appearance_settings.h>
|
||||
#include <libcockatrice/settings/paths_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <optional>
|
||||
#include <qlogging.h>
|
||||
#include <qnamespace.h>
|
||||
|
|
@ -69,20 +71,25 @@ HomeWidget::HomeWidget(QWidget *parent, TabSupervisor *_tabSupervisor)
|
|||
: QWidget(parent), tabSupervisor(_tabSupervisor), background(themePixmap(QStringLiteral("backgrounds/home")))
|
||||
{
|
||||
setObjectName("homeWidget");
|
||||
layout = new QGridLayout(this);
|
||||
|
||||
backgroundSourceCard = new CardInfoPictureArtCropWidget(this);
|
||||
|
||||
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);
|
||||
layout->setRowStretch(2, 1);
|
||||
layout->setColumnStretch(0, 1);
|
||||
layout->setColumnStretch(2, 1);
|
||||
|
||||
setLayout(layout);
|
||||
auto *layout = new QVBoxLayout(this);
|
||||
layout->addWidget(scrollArea);
|
||||
|
||||
cardChangeTimer = new QTimer(this);
|
||||
connect(cardChangeTimer, &QTimer::timeout, this, &HomeWidget::updateRandomCard);
|
||||
|
|
@ -289,18 +296,10 @@ QGroupBox *HomeWidget::createButtons()
|
|||
{
|
||||
QGroupBox *box = new QGroupBox(this);
|
||||
box->setObjectName("homeButtonsBox");
|
||||
box->setStyleSheet(R"(
|
||||
QGroupBox {
|
||||
color: white; /* Title text color */
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
QGroupBox::title {
|
||||
color: white;
|
||||
subcontrol-origin: margin;
|
||||
subcontrol-position: top center; /* or top left / right */
|
||||
}
|
||||
)");
|
||||
// The box only stacks the logo and the actions: no frame, and no background of its
|
||||
// own, so the home background art stays visible. It never shows a title. The rule is
|
||||
// load-bearing: QScrollArea::setWidget() turns autoFillBackground on for its widget.
|
||||
box->setStyleSheet("QGroupBox { background: transparent; border: none; }");
|
||||
// Family comes from the InterfaceDefault theme role; the 20px size stays caller-side.
|
||||
auto applyBoxFont = [box]() {
|
||||
QFont boxFont = themeManager->appFont(AppFont::InterfaceDefault);
|
||||
|
|
@ -309,9 +308,12 @@ QGroupBox *HomeWidget::createButtons()
|
|||
};
|
||||
applyBoxFont();
|
||||
connect(themeManager, &ThemeManager::fontsChanged, this, applyBoxFont);
|
||||
box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
QVBoxLayout *boxLayout = new QVBoxLayout;
|
||||
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->setAlignment(Qt::AlignCenter);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
#include <libcockatrice/network/client/abstract/abstract_client.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
class QGridLayout;
|
||||
class QLabel;
|
||||
class CardInfoPictureArtCropWidget;
|
||||
class ExactCard;
|
||||
|
|
@ -46,7 +45,6 @@ public slots:
|
|||
void updateConnectButton(const ClientStatus status);
|
||||
|
||||
private:
|
||||
QGridLayout *layout;
|
||||
QTimer *cardChangeTimer;
|
||||
TabSupervisor *tabSupervisor;
|
||||
QPixmap background;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue