Bladeren bron

Исправлены недоработки в списке видео

Вадим Королёв 1 jaar geleden
bovenliggende
commit
4bc6b0bb56
2 gewijzigde bestanden met toevoegingen van 21 en 12 verwijderingen
  1. 14 5
      src/YTMPV/MainWindow.cpp
  2. 7 7
      src/YTMPV/core.cpp

+ 14 - 5
src/YTMPV/MainWindow.cpp

@@ -157,32 +157,41 @@ namespace components {
 
         // Контейнер деталей видео
         auto details = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL);
+        details->set_margin(8);
 
         // Название
-        auto title = Gtk::make_managed<Gtk::Label>("", Gtk::Align::START);
+        auto title = Gtk::make_managed<Gtk::Label>();
+        title->set_halign(Gtk::Align::START);
 
         // Контейнер для времени, канала и кол-ва просмотров
-        auto info = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL);
+        auto info = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL);
+        info->set_homogeneous();
+        info->set_hexpand();
 
         // Надпись: время публикации
         auto published_at_label = Gtk::make_managed<Gtk::Label>();
+        published_at_label->set_halign(Gtk::Align::START);
 
         // Надпись: название канала
         auto channel_label = Gtk::make_managed<Gtk::Label>();
+        channel_label->set_halign(Gtk::Align::START);
 
         // Надпись: количество просмотров
         auto views_count_label = Gtk::make_managed<Gtk::Label>();
+        views_count_label->set_halign(Gtk::Align::START);
 
         // Контейнер для кнопок
-        auto buttons = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL);
+        auto buttons = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL);
+        buttons->set_spacing(4);
+        buttons->set_margin(8);
 
         // Кнопка "Воспроизвести"
         auto play_button = Gtk::make_managed<Gtk::Button>();
-        play_button->set_icon_name("media-playlist-play");
+        play_button->set_icon_name("media-playback-start");
 
         // Кнопка "Добавить в очередь"
         auto queue_button = Gtk::make_managed<Gtk::Button>();
-        queue_button->set_icon_name("playlist-queue");
+        queue_button->set_icon_name("list-add");
 
         info->append(*published_at_label);
         info->append(*channel_label);

+ 7 - 7
src/YTMPV/core.cpp

@@ -1,7 +1,7 @@
 #include "core.hpp"
 #include <nlohmann/json.hpp>
 #include <Database/database.hpp>
-#include <format>
+#include <iomanip>
 
 using json = nlohmann::json;
 
@@ -226,11 +226,11 @@ namespace core {
         std::string suffix;
         
         if (n > 1000000) {
-            value = (float)n / 1000000.0);
+            value = (float)n / 1000000.0;
             suffix = "M";
 
         } else if (n > 1000) {
-            value = (float)n / 1000.0);
+            value = (float)n / 1000.0;
             suffix = "K";
 
         } else {
@@ -238,10 +238,10 @@ namespace core {
             suffix = "";
         } 
 
-        // Округление до тысячных: https://stackoverflow.com/a/14369745
-        value = std::round(value * 1000) / 1000.0;
+        std::stringstream value_stream;
+        value_stream << std::fixed << std::setprecision(3) << value;
 
-        return std::format("{}{}", value, suffix);
+        return value_stream.str() + suffix;
     }
 
     std::string Core::getDateText(std::string date)
@@ -249,7 +249,7 @@ namespace core {
         // 1. Получить информацию о времени
         std::tm t;
         std::istringstream ss(date);
-        ss >> std::get_time(&t, "%Y-%m-%d%H:%M:%SZ");
+        ss >> std::get_time(&t, "%Y-%m-%dT%H:%M:%SZ");
         if (ss.fail()) {
             return "<couldn't format date>";
         }