Show torrent added date/time in details dialog (GTK). (#3124)
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
4617776253
commit
0f29958751
|
@ -117,6 +117,7 @@ private:
|
||||||
sigc::connection idle_spin_tag_;
|
sigc::connection idle_spin_tag_;
|
||||||
sigc::connection max_peers_spin_tag_;
|
sigc::connection max_peers_spin_tag_;
|
||||||
|
|
||||||
|
Gtk::Label* added_lb_ = nullptr;
|
||||||
Gtk::Label* size_lb_ = nullptr;
|
Gtk::Label* size_lb_ = nullptr;
|
||||||
Gtk::Label* state_lb_ = nullptr;
|
Gtk::Label* state_lb_ = nullptr;
|
||||||
Gtk::Label* have_lb_ = nullptr;
|
Gtk::Label* have_lb_ = nullptr;
|
||||||
|
@ -604,6 +605,11 @@ void gtr_text_buffer_set_text(Glib::RefPtr<Gtk::TextBuffer> const& b, Glib::ustr
|
||||||
return t == 0 ? _("N/A") : fmt::format(FMT_STRING("{:%x}"), fmt::localtime(t));
|
return t == 0 ? _("N/A") : fmt::format(FMT_STRING("{:%x}"), fmt::localtime(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] std::string get_date_time_string(time_t t)
|
||||||
|
{
|
||||||
|
return t == 0 ? _("N/A") : fmt::format(FMT_STRING("{:%c}"), fmt::localtime(t));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void DetailsDialog::Impl::refreshInfo(std::vector<tr_torrent*> const& torrents)
|
void DetailsDialog::Impl::refreshInfo(std::vector<tr_torrent*> const& torrents)
|
||||||
|
@ -649,6 +655,31 @@ void DetailsDialog::Impl::refreshInfo(std::vector<tr_torrent*> const& torrents)
|
||||||
|
|
||||||
privacy_lb_->set_text(str);
|
privacy_lb_->set_text(str);
|
||||||
|
|
||||||
|
/* added_lb */
|
||||||
|
if (stats.empty())
|
||||||
|
{
|
||||||
|
str = no_torrent;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto const baseline = stats.front()->addedDate;
|
||||||
|
bool const is_uniform = std::all_of(
|
||||||
|
stats.begin(),
|
||||||
|
stats.end(),
|
||||||
|
[baseline](auto const* stat) { return stat->addedDate == baseline; });
|
||||||
|
|
||||||
|
if (is_uniform)
|
||||||
|
{
|
||||||
|
str = get_date_time_string(baseline);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str = mixed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
added_lb_->set_text(str);
|
||||||
|
|
||||||
/* origin_lb */
|
/* origin_lb */
|
||||||
if (infos.empty())
|
if (infos.empty())
|
||||||
{
|
{
|
||||||
|
@ -1137,6 +1168,11 @@ Gtk::Widget* DetailsDialog::Impl::info_page_new()
|
||||||
origin_lb_->set_ellipsize(Pango::ELLIPSIZE_END);
|
origin_lb_->set_ellipsize(Pango::ELLIPSIZE_END);
|
||||||
t->add_row(row, _("Origin:"), *origin_lb_);
|
t->add_row(row, _("Origin:"), *origin_lb_);
|
||||||
|
|
||||||
|
/* added */
|
||||||
|
added_lb_ = Gtk::make_managed<Gtk::Label>();
|
||||||
|
added_lb_->set_single_line_mode(true);
|
||||||
|
t->add_row(row, _("Added:"), *added_lb_);
|
||||||
|
|
||||||
/* comment */
|
/* comment */
|
||||||
comment_buffer_ = Gtk::TextBuffer::create();
|
comment_buffer_ = Gtk::TextBuffer::create();
|
||||||
auto* tw = Gtk::make_managed<Gtk::TextView>(comment_buffer_);
|
auto* tw = Gtk::make_managed<Gtk::TextView>(comment_buffer_);
|
||||||
|
|
Loading…
Reference in New Issue