|
@@ -14,12 +14,19 @@
|
|
|
#include <glibmm/fileutils.h>
|
|
|
|
|
|
namespace components {
|
|
|
+
|
|
|
+ MainWindow* MainWindow::create()
|
|
|
+ {
|
|
|
+ return Gtk::make_managed<MainWindow>();
|
|
|
+ }
|
|
|
|
|
|
MainWindow::MainWindow()
|
|
|
: Gtk::ApplicationWindow()
|
|
|
, m_layout(Gtk::Orientation::VERTICAL)
|
|
|
- , m_stack()
|
|
|
+ , m_head(Gtk::Orientation::VERTICAL)
|
|
|
+ , m_body()
|
|
|
, m_stackswitcher()
|
|
|
+ //~ , m_gears()
|
|
|
|
|
|
, m_search_layout(Gtk::Orientation::VERTICAL)
|
|
|
, m_search_head(Gtk::Orientation::HORIZONTAL)
|
|
@@ -30,10 +37,15 @@ namespace components {
|
|
|
, m_search_video_list()
|
|
|
{
|
|
|
set_title("YTMPV");
|
|
|
- set_default_size(800, 600);
|
|
|
+ set_default_size(1024, 640);
|
|
|
set_icon_name("youtube");
|
|
|
+ set_show_menubar();
|
|
|
|
|
|
- // Создание модели выбора видео в поиске
|
|
|
+ // -- Переключатель вкладок --
|
|
|
+ m_stackswitcher.set_stack(m_body);
|
|
|
+ m_head.append(m_stackswitcher);
|
|
|
+
|
|
|
+ // -- Создание модели выбора видео в поиске --
|
|
|
m_video_storage = Gio::ListStore<components::VideoModel>::create();
|
|
|
selection_model = Gtk::SingleSelection::create(m_video_storage);
|
|
|
selection_model->set_autoselect(false);
|
|
@@ -51,11 +63,11 @@ namespace components {
|
|
|
m_search_video_list.set_factory(factory);
|
|
|
|
|
|
// SearchView head
|
|
|
- m_search_button.set_child(*(core::getButtonContents("Поиск", "find")));
|
|
|
+ m_search_button.set_child(*(core::getButtonContents("Find", "find")));
|
|
|
m_search_button.signal_clicked().connect(
|
|
|
sigc::mem_fun(*this, &MainWindow::onSearchButtonClicked));
|
|
|
m_search_entry.set_hexpand(true);
|
|
|
- m_search_entry.set_placeholder_text("Введите запрос");
|
|
|
+ m_search_entry.set_placeholder_text("Search something");
|
|
|
m_search_head.append(m_search_entry);
|
|
|
m_search_head.append(m_search_button);
|
|
|
m_search_head.set_margin(8);
|
|
@@ -73,11 +85,10 @@ namespace components {
|
|
|
// WelcomeView
|
|
|
// TODO
|
|
|
|
|
|
- m_stack.add(m_search_layout, "search", "Поиск видео");
|
|
|
- m_stackswitcher.set_stack(m_stack);
|
|
|
+ m_body.add(m_search_layout, "search", "Searching video");
|
|
|
|
|
|
- m_layout.append(m_stackswitcher);
|
|
|
- m_layout.append(m_stack);
|
|
|
+ m_layout.append(m_head);
|
|
|
+ m_layout.append(m_body);
|
|
|
set_child(m_layout);
|
|
|
}
|
|
|
|
|
@@ -193,7 +204,7 @@ namespace components {
|
|
|
|
|
|
auto icon = Gio::Icon::create("find");
|
|
|
auto img_icon = Gtk::make_managed<Gtk::Image>(icon);
|
|
|
- auto label = Gtk::make_managed<Gtk::Label>("Поиск видео");
|
|
|
+ auto label = Gtk::make_managed<Gtk::Label>("Search results");
|
|
|
|
|
|
box->append(*img_icon);
|
|
|
box->append(*label);
|
|
@@ -202,11 +213,12 @@ namespace components {
|
|
|
}
|
|
|
|
|
|
void MainWindow::searchSidebarVideoDetailsMode(
|
|
|
- Glib::ustring title,
|
|
|
- Glib::ustring channel_title,
|
|
|
- Glib::ustring description,
|
|
|
- std::string published_at,
|
|
|
- std::string yt_id)
|
|
|
+ Glib::ustring title,
|
|
|
+ Glib::ustring channel_title,
|
|
|
+ Glib::ustring description,
|
|
|
+ std::string published_at,
|
|
|
+ std::string yt_id
|
|
|
+ )
|
|
|
{
|
|
|
// Главный объект
|
|
|
auto layout = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL);
|
|
@@ -217,7 +229,7 @@ namespace components {
|
|
|
// Область деталей (текст)
|
|
|
auto box_textdetails = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL);
|
|
|
// Область кнопок
|
|
|
- auto box_buttons = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL);
|
|
|
+ auto box_buttons = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL);
|
|
|
|
|
|
auto thumbnail = Gtk::make_managed<Gtk::Picture>();
|
|
|
auto lbl_title = Gtk::make_managed<Gtk::Label>();
|
|
@@ -230,7 +242,7 @@ namespace components {
|
|
|
|
|
|
// Добавление кнопки "Воспроизвести"
|
|
|
auto btn_play = Gtk::make_managed<Gtk::Button>();
|
|
|
- btn_play->set_child(*(core::getButtonContents("Воспроизвести", "player_play")));
|
|
|
+ btn_play->set_child(*(core::getButtonContents("Play video", "player_play")));
|
|
|
btn_play->set_hexpand();
|
|
|
btn_play->signal_clicked().connect(sigc::bind(
|
|
|
sigc::mem_fun(*this, &MainWindow::playSingleVideo),
|
|
@@ -238,6 +250,15 @@ namespace components {
|
|
|
));
|
|
|
box_buttons->append(*btn_play);
|
|
|
|
|
|
+ // Добавление кнопки "Открыть в веб-браузере"
|
|
|
+ auto btn_webbrowser = Gtk::make_managed<Gtk::Button>();
|
|
|
+ btn_webbrowser->set_child(*(core::getButtonContents("Open in web browser", "web-browser")));
|
|
|
+ btn_webbrowser->set_hexpand();
|
|
|
+ btn_webbrowser->signal_clicked().connect(sigc::bind(
|
|
|
+ sigc::mem_fun(*this, &MainWindow::openVideoInWebBrowser),
|
|
|
+ yt_id
|
|
|
+ ));
|
|
|
+
|
|
|
// Скачивание большого превью
|
|
|
std::string thumbnail_path = "thumbnails/large/" + yt_id + ".jpg";
|
|
|
std::cout << thumbnail_path << std::endl;
|
|
@@ -272,6 +293,7 @@ namespace components {
|
|
|
box_textdetails->append(*lbl_channel_title);
|
|
|
box_textdetails->append(*lbl_description);
|
|
|
box_textdetails->append(*lbl_published_at);
|
|
|
+ box_textdetails->append(*btn_webbrowser);
|
|
|
box_textdetails->set_margin(8);
|
|
|
|
|
|
box_details->append(*thumbnail);
|
|
@@ -284,4 +306,13 @@ namespace components {
|
|
|
|
|
|
m_search_body.set_start_child(*layout);
|
|
|
}
|
|
|
+
|
|
|
+ void MainWindow::openVideoInWebBrowser(std::string yt_id)
|
|
|
+ {
|
|
|
+ // TODO:
|
|
|
+ // - Windows
|
|
|
+ // - MacOs
|
|
|
+ std::string command = "xdg-open https://youtu.be/"+yt_id;
|
|
|
+ system(command.c_str());
|
|
|
+ }
|
|
|
}
|