|
@@ -149,12 +149,56 @@ namespace components {
|
|
|
|
|
|
void MainWindow::onVideoSetup(const Glib::RefPtr<Gtk::ListItem>& list_item)
|
|
|
{
|
|
|
- auto box_main = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL);
|
|
|
+ // Главный контейнер
|
|
|
+ auto layout = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL);
|
|
|
+
|
|
|
+ // Превью
|
|
|
auto thumbnail = Gtk::make_managed<Gtk::Picture>();
|
|
|
- auto label = Gtk::make_managed<Gtk::Label>("", Gtk::Align::START);
|
|
|
- box_main->append(*thumbnail);
|
|
|
- box_main->append(*label);
|
|
|
- list_item->set_child(*box_main);
|
|
|
+
|
|
|
+ // Контейнер деталей видео
|
|
|
+ auto details = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL);
|
|
|
+
|
|
|
+ // Название
|
|
|
+ auto title = Gtk::make_managed<Gtk::Label>("", Gtk::Align::START);
|
|
|
+
|
|
|
+ // Контейнер для времени, канала и кол-ва просмотров
|
|
|
+ auto info = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL);
|
|
|
+
|
|
|
+ // Надпись: время публикации
|
|
|
+ auto published_at_label = Gtk::make_managed<Gtk::Label>();
|
|
|
+
|
|
|
+ // Надпись: название канала
|
|
|
+ auto channel_label = Gtk::make_managed<Gtk::Label>();
|
|
|
+
|
|
|
+ // Надпись: количество просмотров
|
|
|
+ auto views_count_label = Gtk::make_managed<Gtk::Label>();
|
|
|
+
|
|
|
+ // Контейнер для кнопок
|
|
|
+ auto buttons = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL);
|
|
|
+
|
|
|
+ // Кнопка "Воспроизвести"
|
|
|
+ auto play_button = Gtk::make_managed<Gtk::Button>();
|
|
|
+ play_button->set_icon_name("media-playlist-play");
|
|
|
+
|
|
|
+ // Кнопка "Добавить в очередь"
|
|
|
+ auto queue_button = Gtk::make_managed<Gtk::Button>();
|
|
|
+ queue_button->set_icon_name("playlist-queue");
|
|
|
+
|
|
|
+ info->append(*published_at_label);
|
|
|
+ info->append(*channel_label);
|
|
|
+ info->append(*views_count_label);
|
|
|
+
|
|
|
+ buttons->append(*play_button);
|
|
|
+ buttons->append(*queue_button);
|
|
|
+
|
|
|
+ details->append(*title);
|
|
|
+ details->append(*info);
|
|
|
+ details->append(*buttons);
|
|
|
+
|
|
|
+ layout->append(*thumbnail);
|
|
|
+ layout->append(*details);
|
|
|
+
|
|
|
+ list_item->set_child(*layout);
|
|
|
}
|
|
|
|
|
|
void MainWindow::onVideoBind(const Glib::RefPtr<Gtk::ListItem>& list_item)
|
|
@@ -164,16 +208,41 @@ namespace components {
|
|
|
auto item = m_video_storage->get_item(pos);
|
|
|
auto obj = item->m_obj;
|
|
|
|
|
|
- auto box_main = dynamic_cast<Gtk::Box*>(list_item->get_child());
|
|
|
- if (!box_main) return;
|
|
|
+ auto layout = dynamic_cast<Gtk::Box*>(list_item->get_child());
|
|
|
+ if (!layout) return;
|
|
|
|
|
|
- auto thumbnail = dynamic_cast<Gtk::Picture*>(box_main->get_first_child());
|
|
|
+ auto thumbnail = dynamic_cast<Gtk::Picture*>(layout->get_first_child());
|
|
|
if (!thumbnail) return;
|
|
|
|
|
|
- auto lbl_title = dynamic_cast<Gtk::Label*>(thumbnail->get_next_sibling());
|
|
|
- if (!lbl_title) return;
|
|
|
+ auto details = dynamic_cast<Gtk::Box*>(thumbnail->get_next_sibling());
|
|
|
+ if (!details) return;
|
|
|
+
|
|
|
+ auto title = dynamic_cast<Gtk::Label*>(details->get_first_child());
|
|
|
+ if (!title) return;
|
|
|
+
|
|
|
+ auto info = dynamic_cast<Gtk::Box*>(title->get_next_sibling());
|
|
|
+ if (!info) return;
|
|
|
+
|
|
|
+ auto published_at_label = dynamic_cast<Gtk::Label*>(info->get_first_child());
|
|
|
+ if (!published_at_label) return;
|
|
|
+
|
|
|
+ auto channel_label = dynamic_cast<Gtk::Label*>(published_at_label->get_next_sibling());
|
|
|
+ if (!channel_label) return;
|
|
|
+
|
|
|
+ auto views_count_label = dynamic_cast<Gtk::Label*>(channel_label->get_next_sibling());
|
|
|
+ if (!views_count_label) return;
|
|
|
+
|
|
|
+ auto buttons = dynamic_cast<Gtk::Box*>(info->get_next_sibling());
|
|
|
+ if (!buttons) return;
|
|
|
+
|
|
|
+ auto play_button = dynamic_cast<Gtk::Button*>(buttons->get_first_child());
|
|
|
+ if (!play_button) return;
|
|
|
+
|
|
|
+ auto queue_button = dynamic_cast<Gtk::Button*>(play_button->get_next_sibling());
|
|
|
+ if (!queue_button) return;
|
|
|
|
|
|
// Загрузка изображения превью видео с диска
|
|
|
+ // TODO: ~/.cache/ytmpv/thumbnails -- брать из appcore
|
|
|
std::string thumbnail_path = "thumbnails/default/" + obj.ytid + ".jpg";
|
|
|
Glib::RefPtr<Gdk::Pixbuf> thumbnail_pixbuf;
|
|
|
try {
|
|
@@ -197,7 +266,11 @@ namespace components {
|
|
|
thumbnail->set_can_shrink(false);
|
|
|
thumbnail->set_content_fit(Gtk::ContentFit::COVER);
|
|
|
|
|
|
- lbl_title->set_text(obj.title);
|
|
|
+ title->set_text(obj.title);
|
|
|
+
|
|
|
+ published_at_label->set_text(m_appcore->getDateText(obj.published_at));
|
|
|
+ channel_label->set_text(obj.author_obj.name);
|
|
|
+ views_count_label->set_text(m_appcore->getNumberGrouped(obj.views_count));
|
|
|
}
|
|
|
|
|
|
void MainWindow::onVideoChanged()
|