diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index 7b9cbeb3e..147b90f04 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -30,6 +30,7 @@ #include "addnewtorrentdialog.h" #include +#include #include #include @@ -141,10 +142,11 @@ class AddNewTorrentDialog::TorrentContentAdaptor final { public: TorrentContentAdaptor(BitTorrent::TorrentInfo &torrentInfo, PathList &filePaths - , QVector &filePriorities) + , QVector &filePriorities, std::function onFilePrioritiesChanged) : m_torrentInfo {torrentInfo} , m_filePaths {filePaths} , m_filePriorities {filePriorities} + , m_onFilePrioritiesChanged {std::move(onFilePrioritiesChanged)} { Q_ASSERT(filePaths.isEmpty() || (filePaths.size() == torrentInfo.filesCount())); @@ -255,6 +257,8 @@ public: { Q_ASSERT(priorities.size() == filesCount()); m_filePriorities = priorities; + if (m_onFilePrioritiesChanged) + m_onFilePrioritiesChanged(); } Path actualStorageLocation() const override @@ -275,6 +279,7 @@ private: BitTorrent::TorrentInfo &m_torrentInfo; PathList &m_filePaths; QVector &m_filePriorities; + std::function m_onFilePrioritiesChanged; Path m_originalRootFolder; BitTorrent::TorrentContentLayout m_currentContentLayout; }; @@ -992,7 +997,8 @@ void AddNewTorrentDialog::setupTreeview() if (m_torrentParams.filePaths.isEmpty()) m_torrentParams.filePaths = m_torrentInfo.filePaths(); - m_contentAdaptor = std::make_unique(m_torrentInfo, m_torrentParams.filePaths, m_torrentParams.filePriorities); + m_contentAdaptor = std::make_unique(m_torrentInfo, m_torrentParams.filePaths + , m_torrentParams.filePriorities, [this] { updateDiskSpaceLabel(); }); const auto contentLayout = static_cast(m_ui->contentLayoutComboBox->currentIndex()); m_contentAdaptor->applyContentLayout(contentLayout);