Skip to content

Commit 3e1bfbd

Browse files
committed
bugfix: theme change problem
Removed: - BUILD_STATIC option and the entire "Platform-specific" static linking block
1 parent 755e953 commit 3e1bfbd

2 files changed

Lines changed: 3 additions & 91 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ set(CMAKE_AUTOMOC ON)
1111
set(CMAKE_AUTORCC ON)
1212
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1313

14-
option(BUILD_STATIC "Build a fully static executable" OFF)
1514
option(BUILD_TESTING "Build unit tests" OFF)
1615
option(ENABLE_CLANG_TIDY "Run clang-tidy during compilation" OFF)
1716

@@ -31,7 +30,7 @@ find_package(Qt6 REQUIRED COMPONENTS Widgets Svg PrintSupport)
3130

3231
# ---- Library (all sources except main.cpp) -----------------------------------
3332

34-
add_library(ymind_lib STATIC
33+
add_library(ymind_lib OBJECT
3534
# Core – application infrastructure
3635
src/core/AppSettings.h src/core/AppSettings.cpp
3736
src/core/Commands.h src/core/Commands.cpp
@@ -88,12 +87,6 @@ endif()
8887
target_sources(ymind PRIVATE src/main.cpp)
8988
target_link_libraries(ymind PRIVATE ymind_lib)
9089

91-
# ---- Platform-specific -------------------------------------------------------
92-
93-
if(BUILD_STATIC AND WIN32)
94-
target_link_options(ymind PRIVATE -static -static-libgcc -static-libstdc++)
95-
endif()
96-
9790
# ---- Install -----------------------------------------------------------------
9891

9992
install(TARGETS ymind DESTINATION bin)

src/ui/ThemeManager.cpp

Lines changed: 2 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <QGraphicsItem>
1212
#include <QGraphicsView>
1313
#include <QPainter>
14-
#include <QPalette>
1514
#include <QStandardPaths>
1615
#include <QTimer>
1716
#include <cmath>
@@ -101,100 +100,20 @@ static QString generateCloseIcon(bool dark) {
101100
return path;
102101
}
103102

104-
// ---------------------------------------------------------------------------
105-
// Build a QPalette that matches the stylesheet so unstyled widgets also
106-
// follow the chosen theme. Without this, Qt6 on Windows picks up the
107-
// system dark/light palette and unstyled widgets ignore the stylesheet.
108-
// ---------------------------------------------------------------------------
109-
static QPalette buildPalette(bool dark) {
110-
QPalette pal;
111-
if (dark) {
112-
QColor windowBg("#2D2D30");
113-
QColor windowFg("#D4D4D4");
114-
QColor baseBg("#252526");
115-
QColor highlight("#094771");
116-
QColor highlightText("#FFFFFF");
117-
QColor buttonBg("#3C3C3C");
118-
QColor disabledFg("#5A5A5A");
119-
120-
pal.setColor(QPalette::Window, windowBg);
121-
pal.setColor(QPalette::WindowText, windowFg);
122-
pal.setColor(QPalette::Base, baseBg);
123-
pal.setColor(QPalette::AlternateBase, windowBg);
124-
pal.setColor(QPalette::Text, windowFg);
125-
pal.setColor(QPalette::Button, buttonBg);
126-
pal.setColor(QPalette::ButtonText, windowFg);
127-
pal.setColor(QPalette::BrightText, Qt::white);
128-
pal.setColor(QPalette::Highlight, highlight);
129-
pal.setColor(QPalette::HighlightedText, highlightText);
130-
pal.setColor(QPalette::ToolTipBase, windowBg);
131-
pal.setColor(QPalette::ToolTipText, windowFg);
132-
pal.setColor(QPalette::PlaceholderText, disabledFg);
133-
pal.setColor(QPalette::Light, QColor("#3F3F46"));
134-
pal.setColor(QPalette::Midlight, QColor("#353535"));
135-
pal.setColor(QPalette::Mid, QColor("#2D2D30"));
136-
pal.setColor(QPalette::Dark, QColor("#1E1E1E"));
137-
pal.setColor(QPalette::Shadow, QColor("#111111"));
138-
139-
// Disabled state
140-
pal.setColor(QPalette::Disabled, QPalette::WindowText, disabledFg);
141-
pal.setColor(QPalette::Disabled, QPalette::Text, disabledFg);
142-
pal.setColor(QPalette::Disabled, QPalette::ButtonText, disabledFg);
143-
} else {
144-
QColor windowBg("#FFFFFF");
145-
QColor windowFg("#1E1E1E");
146-
QColor baseBg("#FFFFFF");
147-
QColor highlight("#CCE4F7");
148-
QColor highlightText("#1E1E1E");
149-
QColor buttonBg("#E1E4E8");
150-
QColor disabledFg("#B0B0B0");
151-
152-
pal.setColor(QPalette::Window, windowBg);
153-
pal.setColor(QPalette::WindowText, windowFg);
154-
pal.setColor(QPalette::Base, baseBg);
155-
pal.setColor(QPalette::AlternateBase, QColor("#F8F8F8"));
156-
pal.setColor(QPalette::Text, windowFg);
157-
pal.setColor(QPalette::Button, buttonBg);
158-
pal.setColor(QPalette::ButtonText, windowFg);
159-
pal.setColor(QPalette::BrightText, Qt::black);
160-
pal.setColor(QPalette::Highlight, highlight);
161-
pal.setColor(QPalette::HighlightedText, highlightText);
162-
pal.setColor(QPalette::ToolTipBase, QColor("#F5F5F5"));
163-
pal.setColor(QPalette::ToolTipText, windowFg);
164-
pal.setColor(QPalette::PlaceholderText, disabledFg);
165-
pal.setColor(QPalette::Light, QColor("#FFFFFF"));
166-
pal.setColor(QPalette::Midlight, QColor("#F0F0F0"));
167-
pal.setColor(QPalette::Mid, QColor("#D0D0D0"));
168-
pal.setColor(QPalette::Dark, QColor("#A0A0A0"));
169-
pal.setColor(QPalette::Shadow, QColor("#808080"));
170-
171-
// Disabled state
172-
pal.setColor(QPalette::Disabled, QPalette::WindowText, disabledFg);
173-
pal.setColor(QPalette::Disabled, QPalette::Text, disabledFg);
174-
pal.setColor(QPalette::Disabled, QPalette::ButtonText, disabledFg);
175-
}
176-
return pal;
177-
}
178-
179103
// ---------------------------------------------------------------------------
180104
// Apply theme to application and invalidate caches on all scenes
181105
// ---------------------------------------------------------------------------
182106
void ThemeManager::applyTheme(const QList<TabState>& tabs) {
183107
bool dark = (AppSettings::instance().theme() == AppTheme::Dark);
184108

185-
QString stylesheet =
186-
dark ? QString(StyleSheetGenerator::darkStyleSheet())
187-
: QString(StyleSheetGenerator::lightStyleSheet());
109+
QString stylesheet = dark ? QString(StyleSheetGenerator::darkStyleSheet())
110+
: QString(StyleSheetGenerator::lightStyleSheet());
188111

189112
// Generate a close-button icon matching the theme and inject into stylesheet
190113
QString iconPath = generateCloseIcon(dark);
191114
iconPath.replace("\\", "/"); // Qt URL paths require forward slashes
192115
stylesheet += QString("\nQTabBar::close-button { image: url(%1); }").arg(iconPath);
193116

194-
// Set palette BEFORE stylesheet so Qt's palette and CSS are in sync.
195-
// This is critical on Windows where Qt6 auto-detects system dark mode
196-
// and applies a system palette that overrides unstyled widget colors.
197-
qApp->setPalette(buildPalette(dark));
198117
qApp->setStyleSheet(stylesheet);
199118

200119
// Invalidate caches on ALL open scenes

0 commit comments

Comments
 (0)