forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3ca724
commit 1b593da
Showing
8 changed files
with
41 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,28 @@ | ||
/* | ||
* Copyright (c) 2022, cflip <[email protected]> | ||
* Copyright (c) 2022, Sam Atkins <[email protected]> | ||
* Copyright (c) 2025, RatcheT2497 <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include "ClockSettingsWidget.h" | ||
#include <Applications/ClockSettings/ClockSettingsWidgetGML.h> | ||
#include <LibConfig/Client.h> | ||
#include <LibCore/DateTime.h> | ||
#include <LibGUI/CheckBox.h> | ||
#include <LibGUI/Label.h> | ||
#include <LibGUI/RadioButton.h> | ||
#include <LibGUI/TextBox.h> | ||
|
||
namespace ClockSettings { | ||
|
||
constexpr auto time_format_12h = "%I:%M %p"sv; | ||
constexpr auto time_format_12h_seconds = "%r"sv; | ||
constexpr auto time_format_24h = "%R"sv; | ||
constexpr auto time_format_24h_seconds = "%T"sv; | ||
|
||
ErrorOr<NonnullRefPtr<ClockSettingsWidget>> ClockSettingsWidget::try_create() | ||
{ | ||
auto widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ClockSettingsWidget())); | ||
TRY(widget->setup()); | ||
return widget; | ||
} | ||
|
||
ErrorOr<void> ClockSettingsWidget::setup() | ||
ErrorOr<void> ClockSettingsWidget::initialize() | ||
{ | ||
TRY(load_from_gml(clock_settings_widget_gml)); | ||
|
||
m_24_hour_radio = *find_descendant_of_type_named<GUI::RadioButton>("24hour_radio"); | ||
auto& twelve_hour_radio = *find_descendant_of_type_named<GUI::RadioButton>("12hour_radio"); | ||
m_show_seconds_checkbox = *find_descendant_of_type_named<GUI::CheckBox>("seconds_checkbox"); | ||
|
@@ -130,3 +123,5 @@ void ClockSettingsWidget::update_clock_preview() | |
{ | ||
m_clock_preview->set_text(Core::DateTime::now().to_string(m_time_format).release_value_but_fixme_should_propagate_errors()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (c) 2022, cflip <[email protected]> | ||
* Copyright (c) 2025, RatcheT2497 <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
@@ -9,15 +10,17 @@ | |
#include <AK/RefPtr.h> | ||
#include <LibGUI/SettingsWindow.h> | ||
|
||
namespace ClockSettings { | ||
|
||
class ClockSettingsWidget final : public GUI::SettingsWindow::Tab { | ||
C_OBJECT_ABSTRACT(ClockSettingsWidget) | ||
|
||
public: | ||
static ErrorOr<NonnullRefPtr<ClockSettingsWidget>> try_create(); | ||
ErrorOr<void> initialize(); | ||
|
||
private: | ||
ClockSettingsWidget() = default; | ||
ErrorOr<void> setup(); | ||
|
||
virtual void apply_settings() override; | ||
virtual void reset_default_values() override; | ||
|
@@ -34,3 +37,5 @@ class ClockSettingsWidget final : public GUI::SettingsWindow::Tab { | |
|
||
ByteString m_time_format; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
/* | ||
* Copyright (c) 2022, Tim Flynn <[email protected]> | ||
* Copyright (c) 2025, RatcheT2497 <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include "TimeZoneSettingsWidget.h" | ||
#include <AK/Time.h> | ||
#include <Applications/ClockSettings/TimeZoneSettingsWidgetGML.h> | ||
#include <LibGUI/ComboBox.h> | ||
#include <LibGUI/Event.h> | ||
#include <LibGUI/ImageWidget.h> | ||
|
@@ -24,6 +24,8 @@ | |
#include <spawn.h> | ||
#include <unistd.h> | ||
|
||
namespace ClockSettings { | ||
|
||
static constexpr auto PI_OVER_180 = M_PIf32 / 180.0f; | ||
static constexpr auto PI_OVER_4 = M_PIf32 / 4.0f; | ||
static constexpr auto TAU = M_PIf32 * 2.0f; | ||
|
@@ -38,28 +40,17 @@ static constexpr auto TIME_ZONE_TEXT_HEIGHT = 40; | |
static constexpr auto TIME_ZONE_TEXT_PADDING = 5; | ||
static constexpr auto TIME_ZONE_TEXT_COLOR = Gfx::Color::from_rgb(0xeaf688); | ||
|
||
ErrorOr<NonnullRefPtr<TimeZoneSettingsWidget>> TimeZoneSettingsWidget::create() | ||
ErrorOr<void> TimeZoneSettingsWidget::initialize() | ||
{ | ||
auto timezonesettings_widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) TimeZoneSettingsWidget)); | ||
|
||
auto time_zone_map_bitmap = TRY(Gfx::Bitmap::load_from_file("/res/graphics/map.png"sv)); | ||
auto time_zone_rect = time_zone_map_bitmap->rect().shrunken(TIME_ZONE_MAP_NORTHERN_TRIM, 0, TIME_ZONE_MAP_SOUTHERN_TRIM, 0); | ||
time_zone_map_bitmap = TRY(time_zone_map_bitmap->cropped(time_zone_rect)); | ||
|
||
timezonesettings_widget->m_time_zone_map = *timezonesettings_widget->find_descendant_of_type_named<GUI::ImageWidget>("time_zone_map"); | ||
timezonesettings_widget->m_time_zone_map->set_bitmap(time_zone_map_bitmap); | ||
m_time_zone_map = find_descendant_of_type_named<GUI::ImageWidget>("time_zone_map"); | ||
m_time_zone_map->set_bitmap(time_zone_map_bitmap); | ||
|
||
auto time_zone_marker = TRY(Gfx::Bitmap::load_from_file("/res/icons/32x32/ladyball.png"sv)); | ||
timezonesettings_widget->m_time_zone_marker = TRY(time_zone_marker->scaled(0.75f, 0.75f)); | ||
|
||
timezonesettings_widget->set_time_zone_location(); | ||
|
||
return timezonesettings_widget; | ||
} | ||
|
||
TimeZoneSettingsWidget::TimeZoneSettingsWidget() | ||
{ | ||
load_from_gml(time_zone_settings_widget_gml).release_value_but_fixme_should_propagate_errors(); | ||
m_time_zone_marker = TRY(time_zone_marker->scaled(0.75f, 0.75f)); | ||
|
||
static auto time_zones = []() { | ||
Vector<StringView> time_zones; | ||
|
@@ -81,6 +72,10 @@ TimeZoneSettingsWidget::TimeZoneSettingsWidget() | |
m_time_zone_combo_box->on_change = [&](auto, auto) { | ||
set_modified(true); | ||
}; | ||
|
||
set_time_zone_location(); | ||
|
||
return {}; | ||
} | ||
|
||
void TimeZoneSettingsWidget::second_paint_event(GUI::PaintEvent& event) | ||
|
@@ -176,3 +171,5 @@ void TimeZoneSettingsWidget::set_time_zone() | |
{ | ||
GUI::Process::spawn_or_show_error(window(), "/bin/timezone"sv, Array { m_time_zone.characters() }); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (c) 2022, Tim Flynn <[email protected]> | ||
* Copyright (c) 2025, RatcheT2497 <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
@@ -13,13 +14,16 @@ | |
#include <LibGUI/TextEditor.h> | ||
#include <LibGUI/Window.h> | ||
|
||
namespace ClockSettings { | ||
|
||
class TimeZoneSettingsWidget final : public GUI::SettingsWindow::Tab { | ||
C_OBJECT_ABSTRACT(TimeZoneSettingsWidget) | ||
public: | ||
static ErrorOr<NonnullRefPtr<TimeZoneSettingsWidget>> create(); | ||
static ErrorOr<NonnullRefPtr<TimeZoneSettingsWidget>> try_create(); | ||
ErrorOr<void> initialize(); | ||
|
||
private: | ||
TimeZoneSettingsWidget(); | ||
TimeZoneSettingsWidget() = default; | ||
|
||
virtual void second_paint_event(GUI::PaintEvent&) override; | ||
|
||
|
@@ -38,3 +42,5 @@ class TimeZoneSettingsWidget final : public GUI::SettingsWindow::Tab { | |
Optional<Gfx::FloatPoint> m_time_zone_location; | ||
ByteString m_time_zone_text; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters