Merge pull request #4212 from notpeelz/fix-namespace-pollution

Fix namespace pollution
This commit is contained in:
Alexis Rouillard
2025-06-22 08:21:24 +01:00
committed by GitHub
6 changed files with 33 additions and 36 deletions

View File

@ -42,24 +42,24 @@ class Clock final : public ALabel {
int cldWnLen_{3}; // calendar week number length int cldWnLen_{3}; // calendar week number length
const int cldMonColLen_{20}; // calendar month column length const int cldMonColLen_{20}; // calendar month column length
WS cldWPos_{WS::HIDDEN}; // calendar week side to print WS cldWPos_{WS::HIDDEN}; // calendar week side to print
months cldCurrShift_{0}; // calendar months shift date::months cldCurrShift_{0}; // calendar months shift
int cldShift_{1}; // calendar months shift factor int cldShift_{1}; // calendar months shift factor
year_month_day cldYearShift_; // calendar Year mode. Cached ymd date::year_month_day cldYearShift_; // calendar Year mode. Cached ymd
std::string cldYearCached_; // calendar Year mode. Cached calendar std::string cldYearCached_; // calendar Year mode. Cached calendar
year_month cldMonShift_; // calendar Month mode. Cached ym date::year_month cldMonShift_; // calendar Month mode. Cached ym
std::string cldMonCached_; // calendar Month mode. Cached calendar std::string cldMonCached_; // calendar Month mode. Cached calendar
day cldBaseDay_{0}; // calendar Cached day. Is used when today is changing(midnight) date::day cldBaseDay_{0}; // calendar Cached day. Is used when today is changing(midnight)
std::string cldText_{""}; // calendar text to print std::string cldText_{""}; // calendar text to print
CldMode cldMode_{CldMode::MONTH}; CldMode cldMode_{CldMode::MONTH};
auto get_calendar(const year_month_day& today, const year_month_day& ymd, const time_zone* tz) auto get_calendar(const date::year_month_day& today, const date::year_month_day& ymd,
-> const std::string; const date::time_zone* tz) -> const std::string;
// get local time zone // get local time zone
auto local_zone() -> const time_zone*; auto local_zone() -> const date::time_zone*;
// time zoned time in tooltip // time zoned time in tooltip
const bool tzInTooltip_; // if need to print time zones text const bool tzInTooltip_; // if need to print time zones text
std::vector<const time_zone*> tzList_; // time zones list std::vector<const date::time_zone*> tzList_; // time zones list
int tzCurrIdx_; // current time zone index for tzList_ int tzCurrIdx_; // current time zone index for tzList_
std::string tzText_{""}; // time zones text to print std::string tzText_{""}; // time zones text to print
util::SleeperThread thread_; util::SleeperThread thread_;
@ -67,10 +67,10 @@ class Clock final : public ALabel {
// ordinal date in tooltip // ordinal date in tooltip
const bool ordInTooltip_; const bool ordInTooltip_;
std::string ordText_{""}; std::string ordText_{""};
auto get_ordinal_date(const year_month_day& today) -> std::string; auto get_ordinal_date(const date::year_month_day& today) -> std::string;
auto getTZtext(sys_seconds now) -> std::string; auto getTZtext(date::sys_seconds now) -> std::string;
auto first_day_of_week() -> weekday; auto first_day_of_week() -> date::weekday;
// Module actions // Module actions
void cldModeSwitch(); void cldModeSwitch();
void cldShift_up(); void cldShift_up();

View File

@ -15,7 +15,7 @@
namespace date { namespace date {
#if HAVE_CHRONO_TIMEZONES #if HAVE_CHRONO_TIMEZONES
using namespace std::chrono; using namespace std::chrono;
using namespace std; using std::format;
#else #else
using system_clock = std::chrono::system_clock; using system_clock = std::chrono::system_clock;
@ -73,5 +73,3 @@ struct fmt::formatter<date::zoned_time<Duration, TimeZonePtr>> {
} }
}; };
#endif #endif
using namespace date;

View File

@ -6,14 +6,12 @@
namespace waybar { namespace waybar {
using namespace Gio;
enum class Appearance { enum class Appearance {
UNKNOWN = 0, UNKNOWN = 0,
DARK = 1, DARK = 1,
LIGHT = 2, LIGHT = 2,
}; };
class Portal : private DBus::Proxy { class Portal : private Gio::DBus::Proxy {
public: public:
Portal(); Portal();
void refreshAppearance(); void refreshAppearance();

View File

@ -16,6 +16,7 @@
#include <clocale> #include <clocale>
#endif #endif
using namespace date;
namespace fmt_lib = waybar::util::date::format; namespace fmt_lib = waybar::util::date::format;
waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config) waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
@ -349,9 +350,9 @@ auto waybar::modules::Clock::get_calendar(const year_month_day& today, const yea
m_locale_, fmtMap_[4], m_locale_, fmtMap_[4],
fmt_lib::make_format_args( fmt_lib::make_format_args(
(line == 2) (line == 2)
? static_cast<const date::zoned_seconds&&>( ? static_cast<const zoned_seconds&&>(
zoned_seconds{tz, local_days{ymTmp / 1}}) zoned_seconds{tz, local_days{ymTmp / 1}})
: static_cast<const date::zoned_seconds&&>(zoned_seconds{ : static_cast<const zoned_seconds&&>(zoned_seconds{
tz, local_days{cldGetWeekForLine(ymTmp, firstdow, line)}}))) tz, local_days{cldGetWeekForLine(ymTmp, firstdow, line)}})))
<< ' '; << ' ';
} else } else
@ -372,9 +373,9 @@ auto waybar::modules::Clock::get_calendar(const year_month_day& today, const yea
<< fmt_lib::vformat( << fmt_lib::vformat(
m_locale_, fmtMap_[4], m_locale_, fmtMap_[4],
fmt_lib::make_format_args( fmt_lib::make_format_args(
(line == 2) ? static_cast<const date::zoned_seconds&&>( (line == 2) ? static_cast<const zoned_seconds&&>(
zoned_seconds{tz, local_days{ymTmp / 1}}) zoned_seconds{tz, local_days{ymTmp / 1}})
: static_cast<const date::zoned_seconds&&>( : static_cast<const zoned_seconds&&>(
zoned_seconds{tz, local_days{cldGetWeekForLine( zoned_seconds{tz, local_days{cldGetWeekForLine(
ymTmp, firstdow, line)}}))); ymTmp, firstdow, line)}})));
else else

View File

@ -17,8 +17,6 @@ static constexpr const char* PORTAL_NAMESPACE = "org.freedesktop.appearance";
static constexpr const char* PORTAL_KEY = "color-scheme"; static constexpr const char* PORTAL_KEY = "color-scheme";
} // namespace waybar } // namespace waybar
using namespace Gio;
auto fmt::formatter<waybar::Appearance>::format(waybar::Appearance c, format_context& ctx) const { auto fmt::formatter<waybar::Appearance>::format(waybar::Appearance c, format_context& ctx) const {
string_view name; string_view name;
switch (c) { switch (c) {
@ -36,8 +34,8 @@ auto fmt::formatter<waybar::Appearance>::format(waybar::Appearance c, format_con
} }
waybar::Portal::Portal() waybar::Portal::Portal()
: DBus::Proxy(DBus::Connection::get_sync(DBus::BusType::BUS_TYPE_SESSION), PORTAL_BUS_NAME, : Gio::DBus::Proxy(Gio::DBus::Connection::get_sync(Gio::DBus::BusType::BUS_TYPE_SESSION),
PORTAL_OBJ_PATH, PORTAL_INTERFACE), PORTAL_BUS_NAME, PORTAL_OBJ_PATH, PORTAL_INTERFACE),
currentMode(Appearance::UNKNOWN) { currentMode(Appearance::UNKNOWN) {
refreshAppearance(); refreshAppearance();
}; };

View File

@ -18,8 +18,10 @@
return return
#endif #endif
using namespace date;
using namespace std::literals::chrono_literals; using namespace std::literals::chrono_literals;
namespace fmt_lib = waybar::util::date::format; namespace fmt_lib = waybar::util::date::format;
/* /*
* Check that the date/time formatter with locale and timezone support is working as expected. * Check that the date/time formatter with locale and timezone support is working as expected.
*/ */