Răsfoiți Sursa

Добавлен параметр к обработчику кнопки проигрывания

Вадим Королёв 1 an în urmă
părinte
comite
ab0b6351db
2 a modificat fișierele cu 24 adăugiri și 3 ștergeri
  1. 21 2
      src/YTMPV/MainWindow.cpp
  2. 3 1
      src/YTMPV/MainWindow.hpp

+ 21 - 2
src/YTMPV/MainWindow.cpp

@@ -13,6 +13,18 @@
 #include <gdkmm/pixbuf.h>
 #include <glibmm/fileutils.h>
 
+namespace
+{
+    struct PlayButtonParams
+    {
+        // Какой id видео
+        std::string yt_id;
+
+        // Кнопка
+        Gtk::Button* caller;
+    };
+}
+
 namespace components {
 
     MainWindow* MainWindow::create()
@@ -250,9 +262,10 @@ namespace components {
         auto btn_play = Gtk::make_managed<Gtk::Button>();
         btn_play->set_child(*(core::getButtonContents("Play video", "player_play")));
         btn_play->set_hexpand();
+        auto btn_event = PlayButtonParams{ yt_id, btn_play };
         btn_play->signal_clicked().connect(sigc::bind(
-            sigc::mem_fun(*this, &MainWindow::playSingleVideo),
-            yt_id
+            sigc::mem_fun(*this, &MainWindow::onPlayButtonClicked),
+            btn_play
         ));
         box_buttons->append(*btn_play);
 
@@ -321,4 +334,10 @@ namespace components {
         std::string command = "xdg-open https://youtu.be/"+yt_id;
         system(command.c_str());
     }
+
+    void MainWindow::onPlayButtonClicked(PlayButtonParams e)
+    {
+        MainWindow::playSingleVideo(e.yt_id);
+    }
+
 }

+ 3 - 1
src/YTMPV/MainWindow.hpp

@@ -59,6 +59,8 @@ namespace components {
         void onVideoBind(const Glib::RefPtr<Gtk::ListItem>& list_item);
         // При выборе видео из списка
         void onVideoChanged();
+        // При клике на кнопку "Воспроизвести"
+        void onPlayButtonClicked();
 
         // --Общее--
         // Устанавливает боковую панель просмотра видео в обычный режим
@@ -76,4 +78,4 @@ namespace components {
         // Открывает страницу видео в YouTube
         void openVideoInWebBrowser(std::string yt_id);
     };
-}
+}