Skip to content

Commit fa9cd23

Browse files
committed
massive ui update
1 parent 1fffb0f commit fa9cd23

6 files changed

Lines changed: 276 additions & 88 deletions

File tree

src/gamecard.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,18 @@ bool GameCard::hasThumbnail() const {
8080
}
8181

8282
void GameCard::setSelected(bool selected) {
83+
if (m_selected == selected) return;
8384
m_selected = selected;
8485
update();
86+
emit selectionChanged(m_selected, this);
87+
}
88+
89+
void GameCard::setSelectable(bool selectable) {
90+
if (m_isSelectable == selectable) return;
91+
m_isSelectable = selectable;
92+
if (!selectable && m_selected) {
93+
setSelected(false);
94+
}
8595
}
8696

8797
bool GameCard::isSelected() const {
@@ -341,7 +351,12 @@ void GameCard::paintEvent(QPaintEvent* event) {
341351
void GameCard::mousePressEvent(QMouseEvent* event) {
342352
Q_UNUSED(event);
343353
if (m_isSkeleton) return;
344-
emit clicked(this);
354+
355+
if (m_isSelectable) {
356+
setSelected(!m_selected);
357+
} else {
358+
emit clicked(this);
359+
}
345360
}
346361

347362
void GameCard::enterEvent(QEnterEvent* event) {

src/gamecard.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class GameCard : public QWidget {
2323
void setSelected(bool selected);
2424
bool isSelected() const;
2525

26+
void setSelectable(bool selectable);
27+
bool isSelectable() const { return m_isSelectable; }
28+
2629
QString appId() const;
2730
QColor getDominantColor() const;
2831

@@ -34,6 +37,7 @@ class GameCard : public QWidget {
3437

3538
signals:
3639
void clicked(GameCard* card);
40+
void selectionChanged(bool selected, GameCard* card);
3741

3842
protected:
3943
void paintEvent(QPaintEvent* event) override;
@@ -49,6 +53,7 @@ private slots:
4953
QPixmap m_thumbnail;
5054
bool m_hasThumbnail = false;
5155
bool m_selected = false;
56+
bool m_isSelectable = false;
5257
bool m_hovered = false;
5358
bool m_isSkeleton = false;
5459
QTimer* m_skeletonTimer = nullptr;

src/gamedetailspage.cpp

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,25 @@ void GameDetailsPage::buildUI() {
172172
connect(m_installButton, &QPushButton::clicked, this, [this]() {
173173
if (m_isDownloading) return;
174174
m_isDownloading = true;
175-
// The reset will be handled if needed, but for now we emit
175+
// Reset state before new attempt
176+
m_installButton->setText("Downloading...");
177+
m_installProgressBar->setValue(0);
178+
m_installProgressBar->show();
179+
176180
emit addToLibraryClicked(m_appId, m_gameName, m_hasFix);
177181
});
178182
actionLayout->addWidget(m_installButton);
183+
184+
m_installProgressBar = new QProgressBar();
185+
m_installProgressBar->setFixedSize(220, 4);
186+
m_installProgressBar->setTextVisible(false);
187+
m_installProgressBar->setStyleSheet(
188+
"QProgressBar { background: #1B5E20; border: none; border-radius: 2px; }"
189+
"QProgressBar::chunk { background: #00E676; border-radius: 2px; }"
190+
);
191+
m_installProgressBar->hide();
192+
actionLayout->addWidget(m_installProgressBar);
193+
179194
infoLayout->addWidget(actionWidget, 1); // Takes 1/4 space
180195

181196
m_contentLayout->addWidget(infoRow);
@@ -332,10 +347,12 @@ void GameDetailsPage::loadGame(const QString& appId, const QString& name, bool s
332347

333348
// Update Action Button
334349
m_installButton->setEnabled(supported);
335-
m_installButton->setText(hasFix ? "Download Patch" : "Generate Patch");
350+
m_installButton->setText("Install");
351+
m_installProgressBar->hide();
352+
m_installProgressBar->setValue(0);
336353
m_installButton->setStyleSheet(
337354
"QPushButton {"
338-
" background: #2E7D32; color: white; font-weight: 800; font-size: 16px; border-radius: 4px; font-family: 'Segoe UI';"
355+
" background: #2E7D32; color: white; font-weight: 800; font-size: 18px; border-radius: 8px; font-family: 'Segoe UI';"
339356
"}"
340357
"QPushButton:hover {"
341358
" background: #388E3C;"
@@ -506,26 +523,32 @@ void GameDetailsPage::populate(const QJsonObject& data) {
506523
}
507524

508525
void GameDetailsPage::updateInstallProgress(int pct) {
509-
if (pct < 100) {
510-
m_isDownloading = true;
511-
m_installButton->setText(QString("Downloading... %1%").arg(pct));
512-
double ratio = pct / 100.0;
513-
double stop2 = ratio + 0.001;
514-
if (stop2 > 1.0) stop2 = 1.0;
515-
516-
m_installButton->setStyleSheet(QString(
517-
"QPushButton {"
518-
" background: qlineargradient(x1:0, y1:0, x2:1, y2:0, "
519-
" stop:0 #2E7D32, stop:%1 #2E7D32, stop:%2 #424242, stop:1 #424242);"
520-
" color: white; font-weight: 800; font-size: 16px; border-radius: 4px; font-family: 'Segoe UI';"
521-
"}").arg(ratio).arg(stop2));
522-
} else {
523-
m_isDownloading = false;
524-
m_installButton->setText("Installed / Restart Steam");
525-
m_installButton->setStyleSheet(
526-
"QPushButton {"
527-
" background: #2E7D32; color: white; font-weight: 800; font-size: 16px; border-radius: 4px; font-family: 'Segoe UI';"
528-
"}"
529-
);
530-
}
526+
if (!m_isDownloading) return;
527+
m_installProgressBar->show();
528+
m_installProgressBar->setValue(pct);
529+
}
530+
531+
void GameDetailsPage::installFinished() {
532+
m_isDownloading = false;
533+
m_installProgressBar->hide();
534+
m_installButton->setText("Installed");
535+
m_installButton->setStyleSheet(
536+
"QPushButton {"
537+
" background: #2E7D32; color: white; font-weight: 800; font-size: 18px; border-radius: 8px; font-family: 'Segoe UI';"
538+
"}"
539+
);
540+
}
541+
542+
void GameDetailsPage::installError(const QString& err) {
543+
m_isDownloading = false;
544+
m_installProgressBar->hide();
545+
m_installButton->setText("Error (Retry)");
546+
m_installButton->setStyleSheet(
547+
"QPushButton {"
548+
" background: #D32F2F; color: white; font-weight: 800; font-size: 18px; border-radius: 8px; font-family: 'Segoe UI';"
549+
"}"
550+
"QPushButton:hover {"
551+
" background: #F44336;"
552+
"}"
553+
);
531554
}

src/gamedetailspage.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <QNetworkReply>
1111
#include <QPixmap>
1212
#include <QPushButton>
13+
#include <QProgressBar>
1314
#include <QMap>
1415

1516
// Forward declaration
@@ -36,6 +37,8 @@ private slots:
3637

3738
public slots:
3839
void updateInstallProgress(int pct);
40+
void installFinished();
41+
void installError(const QString& err);
3942

4043
private:
4144
void buildUI();
@@ -63,6 +66,7 @@ public slots:
6366
QLabel* m_gameTitleLabel;
6467
QLabel* m_descriptionLabel;
6568
QPushButton* m_installButton;
69+
QProgressBar* m_installProgressBar;
6670
bool m_isDownloading = false;
6771

6872
// Screenshots

0 commit comments

Comments
 (0)