Skip to content

Commit fc1904d

Browse files
committed
use system theme colors
1 parent 9e03bdf commit fc1904d

File tree

4 files changed

+36
-49
lines changed

4 files changed

+36
-49
lines changed

src/Data.hpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,6 @@ struct ExecutableNames {
103103
};
104104
};
105105

106-
struct GameRelease {
107-
QMap<int, QString> data = {
108-
{0, "null"},
109-
{1, "1996-11-14"},
110-
{2, "1997-11-21"},
111-
{3, "1998-11-20"},
112-
{4, "1999-11-24"},
113-
{5, "2000-11-17"},
114-
{6, "2003-07-01"},
115-
{7, "1998-12-31"},
116-
{8, "1999-06-04"},
117-
{9, "2000-03-00"},
118-
{10, "1999-12-00"},
119-
};
120-
};
121-
122106
/**
123107
* @struct MoodFolderNames
124108
* @brief Folder names moods used on Windows.

src/TombRaiderLinuxLauncher.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,6 @@ TombRaiderLinuxLauncher::TombRaiderLinuxLauncher(QWidget *parent)
8484
filterButton_p->setIconSize(QSize(16, 16));
8585
});
8686

87-
// Get the system palette
88-
QPalette systemPalette = ui->filterButton->palette();
89-
90-
// Get system colors for different roles
91-
QColor normalColor = systemPalette.color(QPalette::Button);
92-
QColor hoverColor = systemPalette.color(QPalette::Highlight);
93-
QColor textColor = systemPalette.color(QPalette::ButtonText);
94-
QColor borderColor = systemPalette.color(QPalette::Mid);
95-
9687
QIcon arrowDownIcon(":/icons/down-arrow.svg");
9788
QIcon arrowUpIcon(":/icons/up-arrow.svg");
9889

@@ -128,6 +119,7 @@ TombRaiderLinuxLauncher::TombRaiderLinuxLauncher(QWidget *parent)
128119
CardItemDelegate* delegate = new CardItemDelegate(ui->listViewLevels);
129120
ui->listViewLevels->setItemDelegate(delegate);
130121
ui->listViewLevels->setSpacing(8);
122+
ui->listViewLevels->setMouseTracking(true);
131123
connect(
132124
ui->listViewLevels->selectionModel(),
133125
&QItemSelectionModel::currentChanged,

src/levelViewList.hpp

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -558,19 +558,28 @@ class CardItemDelegate : public QStyledItemDelegate {
558558
const QModelIndex &index) const override {
559559
painter->save();
560560
const bool selected = option.state & QStyle::State_Selected;
561+
const bool hovered = option.state & QStyle::State_MouseOver;
562+
const QPalette &palette = option.palette;
561563

562564
// Card background
563565
painter->setRenderHint(QPainter::Antialiasing);
564566
QRectF cardRect = option.rect.adjusted(4, 4, -4, -4);
565-
QColor bgColor = selected ? QColor("#e0f7fa") : QColor("#ffffff");
567+
QColor bgColor;
568+
if (selected) {
569+
bgColor = palette.color(QPalette::Highlight);
570+
} else if (hovered) {
571+
bgColor = palette.color(QPalette::AlternateBase);
572+
} else {
573+
bgColor = palette.color(QPalette::Base);
574+
}
566575
painter->setBrush(bgColor);
567576
painter->setPen(Qt::NoPen);
568-
painter->drawRoundedRect(cardRect, 10, 10);
577+
painter->drawRoundedRect(cardRect, 0, 0);
569578

570579
// Picture space (left side)
571580
qint64 x = cardRect.left() + 10;
572-
qint64 y = cardRect.top() + 10;
573-
QRect imageRect = QRect(x, y, 320, 240);
581+
qint64 y = cardRect.top() + 40;
582+
QRect imageRect = QRect(x, y, 160, 120);
574583
painter->setBrush(QColor("#cccccc"));
575584
QPixmap cover = index.data(Qt::UserRole + 4).value<QPixmap>();
576585

@@ -591,7 +600,7 @@ class CardItemDelegate : public QStyledItemDelegate {
591600
painter->setPen(Qt::black);
592601

593602
QString title = index.data(Qt::DisplayRole).toString();
594-
point.setX(textX);
603+
point.setX(imageRect.left());
595604
point.setY(textY + 15);
596605
painter->drawText(point, title);
597606

@@ -601,7 +610,8 @@ class CardItemDelegate : public QStyledItemDelegate {
601610

602611
qint64 typeId = index.data(Qt::UserRole + 2).toInt();
603612
QString type = StaticData().getType()[typeId];
604-
point.setY(textY + 50);
613+
point.setX(textX);
614+
point.setY(textY + 60);
605615
QString typeText = QString("Type: %1").arg(type);
606616
painter->drawText(point, typeText);
607617

@@ -611,34 +621,34 @@ class CardItemDelegate : public QStyledItemDelegate {
611621
if (authors.size() > 100) {
612622
authors = "Various";
613623
}
614-
point.setY(textY + 35);
624+
point.setY(textY + 45);
615625
QString authorsText = QString("By: %1").arg(authors);
616626
painter->drawText(point, authorsText);
617627

618628
qint64 classId = index.data(Qt::UserRole + 7).toInt();
619629
QString class_ = StaticData().getClass()[classId];
620-
point.setY(textY + 80);
630+
point.setY(textY + 90);
621631
QString classText = QString("class: %1").arg(class_);
622632
painter->drawText(point, classText);
623633

624634
qint64 difficultyId = index.data(Qt::UserRole + 8).toInt();
625635
QString difficulty = StaticData().getDifficulty()[difficultyId];
626-
point.setY(textY + 110);
636+
point.setY(textY + 120);
627637
QString difficultyText = QString("Difficulty: %1").arg(difficulty);
628638
painter->drawText(point, difficultyText);
629639

630640
qint64 durationId = index.data(Qt::UserRole + 9).toInt();
631641
QString duration = StaticData().getDuration()[durationId];
632-
point.setY(textY + 95);
642+
point.setY(textY + 105);
633643
QString durationText = QString("Duration: %1").arg(duration);
634644
painter->drawText(point, durationText);
635645
} else {
636646
QString shortBody = index.data(Qt::UserRole + 5).toString();
637-
point.setY(textY + 80);
647+
point.setY(textY + 90);
638648
painter->drawText(point, shortBody);
639649
}
640650
QString release = index.data(Qt::UserRole + 3).toString();
641-
point.setY(textY + 65);
651+
point.setY(textY + 75);
642652
QString releaseText = QString("Released: %1").arg(release);
643653
painter->drawText(point, releaseText);
644654

@@ -648,7 +658,7 @@ class CardItemDelegate : public QStyledItemDelegate {
648658

649659
QSize sizeHint(
650660
const QStyleOptionViewItem&, const QModelIndex&) const override {
651-
return QSize(600, 300);
661+
return QSize(600, 180);
652662
}
653663
};
654664

src/staticData.hpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifndef SRC_STATICDATA_HPP_
1515
#define SRC_STATICDATA_HPP_
1616
#include <QString>
17+
#include <QMap>
1718
#include <unordered_map>
1819

1920
struct OriginalGameStaticData {
@@ -54,17 +55,17 @@ struct OriginalGameStaticData {
5455
}
5556

5657
QMap<qint64, QString> release = {
57-
{0, ""},
58-
{1, "2002"},
59-
{2, ""},
60-
{3, ""},
61-
{4, ""},
62-
{5, ""},
63-
{6, ""},
64-
{7, ""},
65-
{8, ""},
66-
{9, ""},
67-
{10, ""},
58+
{0, "null"},
59+
{1, "1996-11-14"},
60+
{2, "1997-11-21"},
61+
{3, "1998-11-20"},
62+
{4, "1999-11-24"},
63+
{5, "2000-11-17"},
64+
{6, "2003-07-01"},
65+
{7, "1998-12-31"},
66+
{8, "1999-06-04"},
67+
{9, "2000-03-00"},
68+
{10, "1999-12-00"},
6869
};
6970

7071
const QString getRelease(qint64 id) {

0 commit comments

Comments
 (0)