Skip to content

Commit

Permalink
query: theme: fix query because of static member
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni500github committed Jan 26, 2025
1 parent d7a999a commit d43dd9d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
10 changes: 6 additions & 4 deletions include/query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,19 @@ class Theme
Theme(const std::uint8_t ver, systemInfo_t& queried_themes, const std::string& theme_name_version,
const Config& config, const bool gsettings_only = false);

Theme(const Config& config, const bool gsettings_only = false);
Theme(systemInfo_t& queried_themes, const Config& config, const bool gsettings_only = false);

std::string& gtk_theme() noexcept;
std::string& gtk_icon_theme() noexcept;
std::string& gtk_font() noexcept;
std::string gtk_theme() noexcept;
std::string gtk_icon_theme() noexcept;
std::string gtk_font() noexcept;
std::string& cursor() noexcept;
std::string& cursor_size() noexcept;

private:
User query_user;
std::string m_wmde_name;
std::string m_theme_name;
systemInfo_t& m_queried_themes;
static Theme_t m_theme_infos;
};

Expand Down
10 changes: 5 additions & 5 deletions src/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ void addValueFromModuleMember(const std::string& moduleName, const std::string&

else if (moduleName == "theme")
{
Query::Theme query_theme(config, false);
Query::Theme query_theme(queried_themes, config, false);

if (sysInfo.find(moduleName) == sysInfo.end())
sysInfo.insert({ moduleName, {} });
Expand Down Expand Up @@ -1266,7 +1266,7 @@ void addValueFromModuleMember(const std::string& moduleName, const std::string&
{
if (hasStart(moduleMemberName, "cursor"))
{
Query::Theme query_cursor(config, true);
Query::Theme query_cursor(queried_themes, config, true);
switch (moduleMember_hash)
{
case "cursor"_fnv1a16:
Expand Down Expand Up @@ -1306,9 +1306,9 @@ void addValueFromModuleMember(const std::string& moduleName, const std::string&
{
switch (moduleMember_hash)
{
case "name"_fnv1a16: SYSINFO_INSERT(get_auto_gtk_format(gtk2.gtk_theme(), gtk3.gtk_theme(), gtk4.gtk_theme())); break;
case "icons"_fnv1a16: SYSINFO_INSERT(get_auto_gtk_format(gtk2.gtk_icon_theme(), gtk3.gtk_icon_theme(), gtk4.gtk_icon_theme())); break;
case "font"_fnv1a16: SYSINFO_INSERT(get_auto_gtk_format(gtk2.gtk_font(), gtk3.gtk_font(), gtk4.gtk_font())); break;
case "name"_fnv1a16: SYSINFO_INSERT(get_auto_gtk_format(gtk2.gtk_theme(), gtk3.gtk_theme(), gtk4.gtk_theme())); break;
case "icons"_fnv1a16: SYSINFO_INSERT(get_auto_gtk_format(gtk2.gtk_icon_theme(), gtk3.gtk_icon_theme(), gtk4.gtk_icon_theme())); break;
case "font"_fnv1a16: SYSINFO_INSERT(get_auto_gtk_format(gtk2.gtk_font(), gtk3.gtk_font(), gtk4.gtk_font())); break;
}
}
}
Expand Down
17 changes: 9 additions & 8 deletions src/query/android/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,26 @@ using namespace Query;

Theme::Theme(const std::uint8_t ver, systemInfo_t& queried_themes, const std::string& theme_name_version,
const Config& config, const bool gsettings_only)
: m_queried_themes(queried_themes)
{
m_theme_infos.cursor = m_theme_infos.gtk_font = m_theme_infos.cursor_size = m_theme_infos.gtk_theme_name =
m_theme_infos.gtk_icon_theme = MAGIC_LINE;
m_theme_infos.cursor = m_theme_infos.gtk_font = m_theme_infos.cursor_size = m_theme_infos.gtk_theme_name = m_theme_infos.gtk_icon_theme
= MAGIC_LINE;
}

Theme::Theme(const Config& config, const bool gsettings_only)
Theme::Theme(systemInfo_t& queried_themes, const Config& config, const bool gsettings_only) : m_queried_themes(queried_themes)
{
m_theme_infos.cursor = m_theme_infos.gtk_font = m_theme_infos.cursor_size = m_theme_infos.gtk_theme_name =
m_theme_infos.gtk_icon_theme = MAGIC_LINE;
m_theme_infos.cursor = m_theme_infos.gtk_font = m_theme_infos.cursor_size = m_theme_infos.gtk_theme_name = m_theme_infos.gtk_icon_theme
= MAGIC_LINE;
}

// clang-format off
std::string& Theme::gtk_theme() noexcept
std::string Theme::gtk_theme() noexcept
{ return m_theme_infos.gtk_theme_name; }

std::string& Theme::gtk_icon_theme() noexcept
std::string Theme::gtk_icon_theme() noexcept
{ return m_theme_infos.gtk_icon_theme; }

std::string& Theme::gtk_font() noexcept
std::string Theme::gtk_font() noexcept
{ return m_theme_infos.gtk_font; }

std::string& Theme::cursor() noexcept
Expand Down
27 changes: 12 additions & 15 deletions src/query/unix/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,20 +478,17 @@ static void get_gtk_theme(const bool dont_query_dewm, const std::uint8_t ver, co
// clang-format off
Theme::Theme(const std::uint8_t ver, systemInfo_t& queried_themes,
const std::string& theme_name_version, const Config& config, const bool gsettings_only)
: m_theme_name(theme_name_version),
m_queried_themes(queried_themes)
{
if (queried_themes.find(theme_name_version) != queried_themes.end())
{
m_theme_infos.gtk_theme_name = getInfoFromName(queried_themes, theme_name_version, "theme-name");
m_theme_infos.gtk_font = getInfoFromName(queried_themes, theme_name_version, "icon-theme-name");
m_theme_infos.gtk_icon_theme = getInfoFromName(queried_themes, theme_name_version, "font-name");
return;
}

const std::string& wm_name = query_user.wm_name(query_user.m_bDont_query_dewm, query_user.term_name());
const std::string& de_name = query_user.de_name(query_user.m_bDont_query_dewm, query_user.term_name(), wm_name);

if (((de_name != MAGIC_LINE && wm_name != MAGIC_LINE) &&
de_name == wm_name) || de_name == MAGIC_LINE)
de_name == wm_name) || de_name == MAGIC_LINE)
m_wmde_name = wm_name;
else
m_wmde_name = de_name;
Expand All @@ -507,8 +504,8 @@ Theme::Theme(const std::uint8_t ver, systemInfo_t& queried_themes,
if (m_theme_infos.gtk_icon_theme.empty())
m_theme_infos.gtk_icon_theme = MAGIC_LINE;

queried_themes.insert(
{theme_name_version, {
m_queried_themes.insert(
{m_theme_name, {
{"theme-name", variant(m_theme_infos.gtk_theme_name)},
{"icon-theme-name", variant(m_theme_infos.gtk_icon_theme)},
{"font-name", variant(m_theme_infos.gtk_font)},
Expand All @@ -517,7 +514,7 @@ Theme::Theme(const std::uint8_t ver, systemInfo_t& queried_themes,
}

// only use it for cursor
Theme::Theme(const Config& config, const bool gsettings_only)
Theme::Theme(systemInfo_t& queried_themes, const Config& config, const bool gsettings_only) : m_queried_themes(queried_themes)
{
const std::string& wm_name = query_user.wm_name(query_user.m_bDont_query_dewm, query_user.term_name());
const std::string& de_name = query_user.de_name(query_user.m_bDont_query_dewm, query_user.term_name(), wm_name);
Expand Down Expand Up @@ -551,14 +548,14 @@ Theme::Theme(const Config& config, const bool gsettings_only)

}

std::string& Theme::gtk_theme() noexcept
{ return m_theme_infos.gtk_theme_name; }
std::string Theme::gtk_theme() noexcept
{ return getInfoFromName(m_queried_themes, m_theme_name, "theme-name"); }

std::string& Theme::gtk_icon_theme() noexcept
{ return m_theme_infos.gtk_icon_theme; }
std::string Theme::gtk_icon_theme() noexcept
{ return getInfoFromName(m_queried_themes, m_theme_name, "icon-theme-name"); }

std::string& Theme::gtk_font() noexcept
{ return m_theme_infos.gtk_font; }
std::string Theme::gtk_font() noexcept
{ return getInfoFromName(m_queried_themes, m_theme_name, "font-name"); }

std::string& Theme::cursor() noexcept
{ return m_theme_infos.cursor; }
Expand Down

0 comments on commit d43dd9d

Please sign in to comment.