summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2024-07-24 20:01:32 +0200
committerFelix Morgner <felix.morgner@gmail.com>2024-07-25 08:00:51 +0200
commit95241c3fed6dc5c1b613a2979c3d1a89d76d8967 (patch)
treeb2e2c82cd693f73c59dd52d2ac3863a1439a00af /ui
parenteec83198b5dfdfe9a0db71b410383697eb58930c (diff)
downloadturns-95241c3fed6dc5c1b613a2979c3d1a89d76d8967.tar.xz
turns-95241c3fed6dc5c1b613a2979c3d1a89d76d8967.zip
ui: show round number in subtitle
Diffstat (limited to 'ui')
-rw-r--r--ui/include/turns/ui/windows/tracker.hpp2
-rw-r--r--ui/src/windows/tracker.cpp27
2 files changed, 23 insertions, 6 deletions
diff --git a/ui/include/turns/ui/windows/tracker.hpp b/ui/include/turns/ui/windows/tracker.hpp
index 4af7c43..04174e6 100644
--- a/ui/include/turns/ui/windows/tracker.hpp
+++ b/ui/include/turns/ui/windows/tracker.hpp
@@ -32,6 +32,8 @@ namespace turns::app::windows
auto setup_actions() -> void;
+ auto update_subtitle() -> void;
+
AdwApplicationWindow * m_adw;
Gtk::Revealer * m_controls;
Gtk::Widget * m_empty;
diff --git a/ui/src/windows/tracker.cpp b/ui/src/windows/tracker.cpp
index 4372117..b3e03d1 100644
--- a/ui/src/windows/tracker.cpp
+++ b/ui/src/windows/tracker.cpp
@@ -1,15 +1,18 @@
#include "turns/ui/windows/tracker.hpp"
-#include "turns/ui/windows/participant_editor.hpp"
#include "turns/core/participant.hpp"
#include "turns/core/turn_order.hpp"
#include "turns/lang/messages.hpp"
+#include "turns/ui/windows/participant_editor.hpp"
+
+#include <sigc++/functors/mem_fun.h>
#include <glibmm/binding.h>
#include <glibmm/i18n.h>
#include <adwaita.h>
+#include <format>
#include <utility>
namespace turns::app::windows
@@ -51,6 +54,10 @@ namespace turns::app::windows
m_stack->add(*m_turn_order_view);
+ m_turn_order->is_empty().signal_changed().connect(sigc::mem_fun(*this, &tracker::update_subtitle));
+ m_turn_order->round_number().signal_changed().connect(sigc::mem_fun(*this, &tracker::update_subtitle));
+ update_subtitle();
+
// clang-format off
Glib::Binding::bind_property(m_turn_order->is_empty(),
m_stack->property_visible_child(),
@@ -60,11 +67,6 @@ namespace turns::app::windows
Glib::Binding::bind_property(m_turn_order->is_running(),
m_controls->property_reveal_child(),
Glib::Binding::Flags::SYNC_CREATE);
-
- Glib::Binding::bind_property(m_turn_order->is_empty(),
- m_subtitle,
- Glib::Binding::Flags::SYNC_CREATE,
- [](auto empty) { return empty ? _(lang::no_active_turn_order) : ""; });
// clang-format on
}
@@ -174,4 +176,17 @@ namespace turns::app::windows
}
}
+ auto tracker::update_subtitle() -> void
+ {
+ if (m_turn_order->is_empty())
+ {
+ m_subtitle = _(lang::no_active_turn_order);
+ }
+ else
+ {
+ auto round_number = m_turn_order->round_number() + 1;
+ m_subtitle = round_number == 0 ? "" : std::vformat(_("Round {}"), std::make_format_args(round_number));
+ }
+ }
+
} // namespace turns::app::windows