Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent false-positive when matching dark themes #24133

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Telegram/SourceFiles/platform/linux/specific_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,12 @@ QString GetIconName() {
return Result;
}

[[nodiscard]] bool IsGtkDarkTheme(const QString &theme) {
const auto themeLower = theme.toLower();
return themeLower.contains(qsl("-dark-"))
|| themeLower.endsWith(qsl("-dark"));
}

std::optional<bool> IsDarkMode() {
[[maybe_unused]] static const auto Inited = [] {
static const auto Setter = [] {
Expand Down Expand Up @@ -474,9 +480,7 @@ std::optional<bool> IsDarkMode() {
const auto gtkThemeX = xSettings->setting("Net/ThemeName");
if (gtkThemeX.isValid()) {
result = false;
if (gtkThemeX.toString().contains(
qsl("-dark"),
Qt::CaseInsensitive)) {
if (IsGtkDarkTheme(gtkThemeX.toString())) {
result = true;
return result;
}
Expand All @@ -499,9 +503,7 @@ std::optional<bool> IsDarkMode() {

result = false;

if (gtkThemePortalString.contains(
qsl("-dark"),
Qt::CaseInsensitive)) {
if (IsGtkDarkTheme(gtkThemePortalString)) {
result = true;
return result;
}
Expand Down