1
1
/*
2
2
* Copyright (c) 2022, Tim Flynn <[email protected] >
3
+ * Copyright (c) 2025, RatcheT2497 <[email protected] >
3
4
*
4
5
* SPDX-License-Identifier: BSD-2-Clause
5
6
*/
6
7
7
8
#include " TimeZoneSettingsWidget.h"
8
9
#include < AK/Time.h>
9
- #include < Applications/ClockSettings/TimeZoneSettingsWidgetGML.h>
10
10
#include < LibGUI/ComboBox.h>
11
11
#include < LibGUI/Event.h>
12
12
#include < LibGUI/ImageWidget.h>
24
24
#include < spawn.h>
25
25
#include < unistd.h>
26
26
27
+ namespace ClockSettings {
28
+
27
29
static constexpr auto PI_OVER_180 = M_PIf32 / 180 .0f ;
28
30
static constexpr auto PI_OVER_4 = M_PIf32 / 4 .0f ;
29
31
static constexpr auto TAU = M_PIf32 * 2 .0f ;
@@ -38,28 +40,17 @@ static constexpr auto TIME_ZONE_TEXT_HEIGHT = 40;
38
40
static constexpr auto TIME_ZONE_TEXT_PADDING = 5 ;
39
41
static constexpr auto TIME_ZONE_TEXT_COLOR = Gfx::Color::from_rgb(0xeaf688 );
40
42
41
- ErrorOr<NonnullRefPtr<TimeZoneSettingsWidget>> TimeZoneSettingsWidget::create ()
43
+ ErrorOr<void > TimeZoneSettingsWidget::initialize ()
42
44
{
43
- auto timezonesettings_widget = TRY (adopt_nonnull_ref_or_enomem (new (nothrow) TimeZoneSettingsWidget));
44
-
45
45
auto time_zone_map_bitmap = TRY (Gfx::Bitmap::load_from_file (" /res/graphics/map.png" sv));
46
46
auto time_zone_rect = time_zone_map_bitmap->rect ().shrunken (TIME_ZONE_MAP_NORTHERN_TRIM, 0 , TIME_ZONE_MAP_SOUTHERN_TRIM, 0 );
47
47
time_zone_map_bitmap = TRY (time_zone_map_bitmap->cropped (time_zone_rect));
48
48
49
- timezonesettings_widget-> m_time_zone_map = *timezonesettings_widget-> find_descendant_of_type_named <GUI::ImageWidget>(" time_zone_map" );
50
- timezonesettings_widget-> m_time_zone_map ->set_bitmap (time_zone_map_bitmap);
49
+ m_time_zone_map = find_descendant_of_type_named<GUI::ImageWidget>(" time_zone_map" );
50
+ m_time_zone_map->set_bitmap (time_zone_map_bitmap);
51
51
52
52
auto time_zone_marker = TRY (Gfx::Bitmap::load_from_file (" /res/icons/32x32/ladyball.png" sv));
53
- timezonesettings_widget->m_time_zone_marker = TRY (time_zone_marker->scaled (0 .75f , 0 .75f ));
54
-
55
- timezonesettings_widget->set_time_zone_location ();
56
-
57
- return timezonesettings_widget;
58
- }
59
-
60
- TimeZoneSettingsWidget::TimeZoneSettingsWidget ()
61
- {
62
- load_from_gml (time_zone_settings_widget_gml).release_value_but_fixme_should_propagate_errors ();
53
+ m_time_zone_marker = TRY (time_zone_marker->scaled (0 .75f , 0 .75f ));
63
54
64
55
static auto time_zones = []() {
65
56
Vector<StringView> time_zones;
@@ -81,6 +72,10 @@ TimeZoneSettingsWidget::TimeZoneSettingsWidget()
81
72
m_time_zone_combo_box->on_change = [&](auto , auto ) {
82
73
set_modified (true );
83
74
};
75
+
76
+ set_time_zone_location ();
77
+
78
+ return {};
84
79
}
85
80
86
81
void TimeZoneSettingsWidget::second_paint_event (GUI::PaintEvent& event)
@@ -176,3 +171,5 @@ void TimeZoneSettingsWidget::set_time_zone()
176
171
{
177
172
GUI::Process::spawn_or_show_error (window (), " /bin/timezone" sv, Array { m_time_zone.characters () });
178
173
}
174
+
175
+ }
0 commit comments