Skip to content

Commit f20e915

Browse files
committed
ui update
1 parent a46e6a6 commit f20e915

3 files changed

Lines changed: 81 additions & 83 deletions

File tree

src/glassbutton.cpp

Lines changed: 68 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ GlassButton::GlassButton(const QString& iconChar, const QString& title,
1414
, m_titleText(title)
1515
, m_descText(description)
1616
, m_accentColor(accentColor)
17+
, m_isActive(false)
1718
{
18-
setFixedHeight(80);
19+
// Removed fixed height to allow dynamic sizing
20+
setMinimumHeight(40);
21+
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
1922
setCursor(Qt::PointingHandCursor);
2023

2124
m_opacityEffect = new QGraphicsOpacityEffect(this);
@@ -34,6 +37,12 @@ void GlassButton::setEnabled(bool enabled) {
3437
update();
3538
}
3639

40+
void GlassButton::setActive(bool active) {
41+
if (m_isActive == active) return;
42+
m_isActive = active;
43+
update();
44+
}
45+
3746
void GlassButton::paintEvent(QPaintEvent* event) {
3847
Q_UNUSED(event);
3948

@@ -45,36 +54,51 @@ void GlassButton::paintEvent(QPaintEvent* event) {
4554
bool isPressed = isDown() && isEnabled();
4655

4756
QRect rect = this->rect();
57+
int h = rect.height();
58+
bool isCompact = (h < 60); // Compact mode for sidebar items
59+
4860
QRect bgRect = rect.adjusted(1, 1, -1, -1);
4961

5062
// 1. Background (Glass)
5163
QColor bgColor = Colors::toQColor(Colors::GLASS_BG);
52-
if (isHover) {
64+
65+
if (m_isActive) {
66+
// Active state background (Accent tint)
67+
bgColor = QColor(m_accentColor);
68+
bgColor.setAlpha(30);
69+
} else if (isHover) {
5370
bgColor = Colors::toQColor(Colors::GLASS_HOVER);
54-
}
55-
if (isPressed) {
71+
} else if (isPressed) {
5672
bgColor = QColor(m_accentColor);
5773
bgColor.setAlpha(40);
5874
}
5975

6076
QPainterPath path;
61-
path.addRoundedRect(bgRect, 16, 16);
77+
path.addRoundedRect(bgRect, 8, 8); // Reduced radius for cleaner look
6278
painter.fillPath(path, bgColor);
6379

64-
// 2. Border
65-
QColor borderColor = Colors::toQColor(Colors::GLASS_BORDER);
66-
if (isHover || isPressed) {
67-
borderColor = QColor(m_accentColor);
68-
borderColor.setAlpha(100);
80+
// 2. Active Indicator (Left Border)
81+
if (m_isActive) {
82+
painter.fillRect(0, 4, 3, h - 8, QColor(m_accentColor));
83+
}
84+
85+
// 3. Border (Optional)
86+
if (!m_isActive) {
87+
QColor borderColor = Colors::toQColor(Colors::GLASS_BORDER);
88+
if (isHover || isPressed) {
89+
borderColor = QColor(m_accentColor);
90+
borderColor.setAlpha(80);
91+
}
92+
QPen pen(borderColor, 1);
93+
painter.setPen(pen);
94+
painter.drawPath(path);
6995
}
7096

71-
QPen pen(borderColor, 1);
72-
painter.setPen(pen);
73-
painter.drawPath(path);
97+
// 4. Icon Box (Left)
98+
int iconSize = isCompact ? 28 : 40; // Reduced from 48
99+
int padding = isCompact ? 8 : 16;
74100

75-
// 3. Icon Box (Left)
76-
int iconSize = 48;
77-
QRect iconRect(20, (rect.height() - iconSize) / 2, iconSize, iconSize);
101+
QRect iconRect(padding, (h - iconSize) / 2, iconSize, iconSize);
78102

79103
// Icon Background Gradient
80104
QLinearGradient grad(iconRect.topLeft(), iconRect.bottomRight());
@@ -85,29 +109,38 @@ void GlassButton::paintEvent(QPaintEvent* event) {
85109

86110
painter.setPen(Qt::NoPen);
87111
painter.setBrush(QBrush(grad));
88-
painter.drawRoundedRect(iconRect, 12, 12);
112+
painter.drawRoundedRect(iconRect, isCompact ? 8 : 10, isCompact ? 8 : 10);
89113

90114
// Icon Text
91115
painter.setPen(QColor("#FFFFFF"));
92-
QFont iconFont("Segoe UI Symbol", 18);
116+
QFont iconFont("Segoe UI Symbol", isCompact ? 12 : 16); // Reduced from 18
93117
painter.setFont(iconFont);
94118
painter.drawText(iconRect, Qt::AlignCenter, m_iconChar);
95119

96-
// 4. Text Content
97-
int textX = 20 + iconSize + 16;
98-
int textW = rect.width() - textX - 10;
99-
100-
// Title
101-
QRect titleRect(textX, 18, textW, 24);
102-
painter.setPen(Colors::toQColor(Colors::TEXT_PRIMARY));
103-
QFont titleFont("Segoe UI", 11, QFont::Bold);
104-
painter.setFont(titleFont);
105-
painter.drawText(titleRect, Qt::AlignLeft | Qt::AlignVCenter, m_titleText);
106-
107-
// Description
108-
QRect descRect(textX, 42, textW, 20);
109-
painter.setPen(Colors::toQColor(Colors::TEXT_SECONDARY));
110-
QFont descFont("Segoe UI", 9);
111-
painter.setFont(descFont);
112-
painter.drawText(descRect, Qt::AlignLeft | Qt::AlignVCenter, m_descText);
120+
// 5. Text Content
121+
int textX = padding + iconSize + (isCompact ? 10 : 14);
122+
int textW = rect.width() - textX - 5;
123+
124+
painter.setPen(m_isActive ? QColor(m_accentColor) : Colors::toQColor(Colors::TEXT_PRIMARY));
125+
126+
if (isCompact || m_descText.isEmpty()) {
127+
// Center Title Only
128+
QRect titleRect(textX, 0, textW, h);
129+
QFont titleFont("Segoe UI", isCompact ? 9 : 10, QFont::Bold); // Reduced from 11
130+
painter.setFont(titleFont);
131+
painter.drawText(titleRect, Qt::AlignLeft | Qt::AlignVCenter, m_titleText.trimmed());
132+
} else {
133+
// Title & Description
134+
int titleY = (h / 2) - 10;
135+
QRect titleRect(textX, titleY - 2, textW, 20);
136+
QFont titleFont("Segoe UI", 10, QFont::Bold);
137+
painter.setFont(titleFont);
138+
painter.drawText(titleRect, Qt::AlignLeft | Qt::AlignVCenter, m_titleText);
139+
140+
QRect descRect(textX, titleY + 18, textW, 16);
141+
painter.setPen(Colors::toQColor(Colors::TEXT_SECONDARY));
142+
QFont descFont("Segoe UI", 8); // Reduced from 9
143+
painter.setFont(descFont);
144+
painter.drawText(descRect, Qt::AlignLeft | Qt::AlignVCenter, m_descText);
145+
}
113146
}

src/glassbutton.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class GlassButton : public QPushButton {
1414

1515
void setDescription(const QString& desc);
1616
void setEnabled(bool enabled);
17+
void setActive(bool active);
1718

1819
protected:
1920
void paintEvent(QPaintEvent* event) override;
@@ -23,6 +24,7 @@ class GlassButton : public QPushButton {
2324
QString m_titleText;
2425
QString m_descText;
2526
QString m_accentColor;
27+
bool m_isActive = false;
2628
QGraphicsOpacityEffect* m_opacityEffect;
2729
};
2830

src/mainwindow.cpp

Lines changed: 11 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,12 @@ void MainWindow::initUI() {
119119

120120
// Nav Buttons
121121
m_tabLua = new GlassButton("", " Lua Patcher", "", Colors::ACCENT_BLUE);
122-
m_tabLua->setFixedHeight(40);
123-
m_tabLua->setStyleSheet("text-align: left; padding-left: 10px;");
122+
m_tabLua->setFixedHeight(40); // Compact Mode
124123
connect(m_tabLua, &QPushButton::clicked, this, [this](){ switchMode(AppMode::LuaPatcher); });
125124
sidebarLayout->addWidget(m_tabLua);
126125

127126
m_tabFix = new GlassButton("🔧", " Fix Manager", "", Colors::ACCENT_PURPLE);
128-
m_tabFix->setFixedHeight(40);
129-
m_tabFix->setStyleSheet("text-align: left; padding-left: 10px;");
127+
m_tabFix->setFixedHeight(40); // Compact Mode
130128
connect(m_tabFix, &QPushButton::clicked, this, [this](){ switchMode(AppMode::FixManager); });
131129
sidebarLayout->addWidget(m_tabFix);
132130

@@ -150,17 +148,20 @@ void MainWindow::initUI() {
150148

151149
// Actions (Contextual Buttons in Sidebar)
152150
m_btnPatch = new GlassButton("", "Patch", "Install Patch", Colors::ACCENT_GREEN);
151+
m_btnPatch->setFixedHeight(50); // Compact Mode
153152
m_btnPatch->setEnabled(false);
154153
connect(m_btnPatch, &QPushButton::clicked, this, &MainWindow::doPatch);
155154
sidebarLayout->addWidget(m_btnPatch);
156155

157156
m_btnGenerate = new GlassButton("", "Generate", "Fetch Data", Colors::ACCENT_BLUE);
157+
m_btnGenerate->setFixedHeight(50);
158158
m_btnGenerate->setEnabled(false);
159159
m_btnGenerate->hide();
160160
connect(m_btnGenerate, &QPushButton::clicked, this, &MainWindow::doGenerate);
161161
sidebarLayout->addWidget(m_btnGenerate);
162162

163163
m_btnApplyFix = new GlassButton("🔧", "Apply Fix", "Apply Fix Files", Colors::ACCENT_PURPLE);
164+
m_btnApplyFix->setFixedHeight(50);
164165
m_btnApplyFix->setEnabled(false);
165166
m_btnApplyFix->hide();
166167
connect(m_btnApplyFix, &QPushButton::clicked, this, &MainWindow::doApplyFix);
@@ -169,6 +170,7 @@ void MainWindow::initUI() {
169170
sidebarLayout->addSpacing(10);
170171

171172
m_btnRestart = new GlassButton("", "Restart Steam", "Apply Changes", Colors::ACCENT_PURPLE);
173+
m_btnRestart->setFixedHeight(50); // Compact Mode
172174
connect(m_btnRestart, &QPushButton::clicked, this, &MainWindow::doRestart);
173175
sidebarLayout->addWidget(m_btnRestart);
174176

@@ -1016,53 +1018,14 @@ void MainWindow::populateFixList() {
10161018
}
10171019

10181020
void MainWindow::updateModeUI() {
1019-
// Update Tab Styles with Left Border Indicator
1020-
1021-
// Active: Semi-transparent background + Accent Color Text + Left Border
1022-
QString activeStyle = QString(
1023-
"background: rgba(59, 130, 246, 0.15);" // Slight blue tint
1024-
"border: none;"
1025-
"border-left: 3px solid %1;" // Accent color border
1026-
"color: %2;"
1027-
"text-align: left;"
1028-
"padding-left: 10px;"
1029-
"font-weight: bold;"
1030-
).arg(Colors::ACCENT_BLUE).arg(Colors::ACCENT_BLUE);
1031-
1032-
// Inactive: Transparent + Gray Text
1033-
QString inactiveStyle = QString(
1034-
"background: transparent;"
1035-
"border: none;"
1036-
"border-left: 3px solid transparent;"
1037-
"color: %1;"
1038-
"text-align: left;"
1039-
"padding-left: 10px;"
1040-
).arg(Colors::TEXT_SECONDARY);
1041-
1021+
// Use the new GlassButton active state mechanism
10421022
if (m_currentMode == AppMode::LuaPatcher) {
1043-
m_tabLua->setStyleSheet(activeStyle);
1044-
// Fix tab uses purple accent for active state if we want to differentiate,
1045-
// but for now let's keep it consistent or use its own accent
1046-
1047-
QString fixInactive = inactiveStyle; // Standard inactive
1048-
m_tabFix->setStyleSheet(fixInactive);
1049-
1023+
m_tabLua->setActive(true);
1024+
m_tabFix->setActive(false);
10501025
m_stack->setCurrentIndex(1);
10511026
} else {
1052-
m_tabLua->setStyleSheet(inactiveStyle);
1053-
1054-
// Active Style for Fix Manager (Purple Accent)
1055-
QString fixActive = QString(
1056-
"background: rgba(168, 85, 247, 0.15);" // Slight purple tint
1057-
"border: none;"
1058-
"border-left: 3px solid %1;"
1059-
"color: %2;"
1060-
"text-align: left;"
1061-
"padding-left: 10px;"
1062-
"font-weight: bold;"
1063-
).arg(Colors::ACCENT_PURPLE).arg(Colors::ACCENT_PURPLE);
1064-
1065-
m_tabFix->setStyleSheet(fixActive);
1027+
m_tabLua->setActive(false);
1028+
m_tabFix->setActive(true);
10661029
m_stack->setCurrentIndex(1);
10671030
}
10681031
}

0 commit comments

Comments
 (0)