2023-11-01 22:11:11 +01:00
|
|
|
// This file Copyright © Mnemosyne LLC.
|
2022-08-08 13:05:39 -05:00
|
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only),
|
2022-01-20 12:27:56 -06:00
|
|
|
// or any future license endorsed by Mnemosyne LLC.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2016-03-29 16:37:21 +00:00
|
|
|
#pragma once
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2023-06-19 16:51:34 -05:00
|
|
|
#include <map>
|
2020-11-08 13:54:40 -06:00
|
|
|
#include <memory>
|
2022-07-27 16:53:39 -05:00
|
|
|
#include <unordered_set>
|
2020-11-08 13:54:40 -06:00
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QString>
|
|
|
|
#include <QTimer>
|
|
|
|
|
2021-12-14 11:43:27 +03:00
|
|
|
#include <libtransmission/tr-macros.h>
|
|
|
|
|
2015-09-01 20:19:26 +00:00
|
|
|
#include "BaseDialog.h"
|
2020-07-29 11:56:23 -05:00
|
|
|
#include "Session.h"
|
2019-11-11 19:37:05 -06:00
|
|
|
#include "Typedefs.h"
|
2015-09-01 20:19:26 +00:00
|
|
|
|
2015-06-10 21:27:11 +00:00
|
|
|
#include "ui_DetailsDialog.h"
|
2022-02-18 11:52:01 -06:00
|
|
|
#include "ui_TrackersDialog.h"
|
2014-12-14 18:12:21 +00:00
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
class QTreeWidgetItem;
|
2015-06-12 22:12:12 +00:00
|
|
|
|
|
|
|
class Prefs;
|
2009-04-09 18:55:47 +00:00
|
|
|
class Session;
|
|
|
|
class Torrent;
|
2009-04-18 23:18:28 +00:00
|
|
|
class TorrentModel;
|
2010-07-27 19:43:32 +00:00
|
|
|
class TrackerDelegate;
|
|
|
|
class TrackerModel;
|
2010-07-28 14:43:47 +00:00
|
|
|
class TrackerModelFilter;
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2017-04-19 15:04:45 +03:00
|
|
|
class DetailsDialog : public BaseDialog
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2013-01-26 01:19:54 +00:00
|
|
|
Q_OBJECT
|
2020-08-11 13:11:55 -05:00
|
|
|
TR_DISABLE_COPY_MOVE(DetailsDialog)
|
2013-01-26 01:19:54 +00:00
|
|
|
|
2017-04-19 15:04:45 +03:00
|
|
|
public:
|
2017-04-20 19:02:19 +03:00
|
|
|
DetailsDialog(Session&, Prefs&, TorrentModel const&, QWidget* parent = nullptr);
|
2022-01-24 23:16:33 -06:00
|
|
|
~DetailsDialog() override;
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2019-11-11 19:37:05 -06:00
|
|
|
void setIds(torrent_ids_t const& ids);
|
2015-06-12 22:12:12 +00:00
|
|
|
|
|
|
|
// QWidget
|
2019-11-11 19:37:05 -06:00
|
|
|
QSize sizeHint() const override
|
2017-04-19 15:04:45 +03:00
|
|
|
{
|
2023-07-18 10:20:17 -05:00
|
|
|
return QSize{ 440, 460 };
|
2017-04-19 15:04:45 +03:00
|
|
|
}
|
2013-01-26 01:19:54 +00:00
|
|
|
|
2017-04-19 15:04:45 +03:00
|
|
|
private:
|
|
|
|
void initPeersTab();
|
|
|
|
void initTrackerTab();
|
|
|
|
void initInfoTab();
|
2020-11-08 21:31:02 -06:00
|
|
|
void initFilesTab() const;
|
2017-04-19 15:04:45 +03:00
|
|
|
void initOptionsTab();
|
2013-01-26 01:19:54 +00:00
|
|
|
|
2019-11-09 08:44:40 -06:00
|
|
|
void setEnabled(bool);
|
2013-01-26 01:19:54 +00:00
|
|
|
|
2017-04-19 15:04:45 +03:00
|
|
|
private slots:
|
2020-07-29 11:56:23 -05:00
|
|
|
void refreshModel();
|
2017-04-19 15:04:45 +03:00
|
|
|
void refreshPref(int key);
|
2020-07-29 11:56:23 -05:00
|
|
|
void refreshUI();
|
2013-01-26 01:19:54 +00:00
|
|
|
|
2020-06-18 15:34:11 -05:00
|
|
|
void onTorrentsEdited(torrent_ids_t const& ids);
|
2020-06-23 16:11:16 -05:00
|
|
|
void onTorrentsChanged(torrent_ids_t const& ids, Torrent::fields_t const& fields);
|
2020-07-29 11:56:23 -05:00
|
|
|
void onSessionCalled(Session::Tag tag);
|
2013-01-26 01:19:54 +00:00
|
|
|
|
2015-06-12 22:12:12 +00:00
|
|
|
// Tracker tab
|
2017-04-19 15:04:45 +03:00
|
|
|
void onTrackerSelectionChanged();
|
|
|
|
void onAddTrackerClicked();
|
2022-02-18 11:52:01 -06:00
|
|
|
void onEditTrackersClicked();
|
2017-04-19 15:04:45 +03:00
|
|
|
void onRemoveTrackerClicked();
|
|
|
|
void onShowTrackerScrapesToggled(bool);
|
|
|
|
void onShowBackupTrackersToggled(bool);
|
2022-02-18 11:52:01 -06:00
|
|
|
void onTrackerListEdited(QString);
|
2013-01-26 01:19:54 +00:00
|
|
|
|
2015-06-12 22:12:12 +00:00
|
|
|
// Files tab
|
2023-10-24 21:14:37 -04:00
|
|
|
void onFilePriorityChanged(file_indices_t const& file_indices, int);
|
|
|
|
void onFileWantedChanged(file_indices_t const& file_indices, bool);
|
2020-05-27 16:53:12 -05:00
|
|
|
void onPathEdited(QString const& old_path, QString const& new_name);
|
2020-11-08 21:31:02 -06:00
|
|
|
void onOpenRequested(QString const& path) const;
|
2015-06-12 22:12:12 +00:00
|
|
|
|
|
|
|
// Options tab
|
2017-04-19 15:04:45 +03:00
|
|
|
void onBandwidthPriorityChanged(int);
|
|
|
|
void onHonorsSessionLimitsToggled(bool);
|
|
|
|
void onDownloadLimitedToggled(bool);
|
|
|
|
void onSpinBoxEditingFinished();
|
|
|
|
void onUploadLimitedToggled(bool);
|
|
|
|
void onRatioModeChanged(int);
|
|
|
|
void onIdleModeChanged(int);
|
|
|
|
void onIdleLimitChanged();
|
|
|
|
|
|
|
|
private:
|
2020-07-29 11:56:23 -05:00
|
|
|
/* When a torrent property is edited in the details dialog (e.g.
|
|
|
|
file priority, speed limits, etc.), don't update those UI fields
|
|
|
|
until we know the server has processed the request. This keeps
|
|
|
|
the UI from appearing to undo the change if we receive a refresh
|
|
|
|
that was already in-flight _before_ the property was edited. */
|
2021-08-15 12:41:48 +03:00
|
|
|
bool canEdit() const
|
|
|
|
{
|
|
|
|
return std::empty(pending_changes_tags_);
|
|
|
|
}
|
2020-07-29 11:56:23 -05:00
|
|
|
std::unordered_set<Session::Tag> pending_changes_tags_;
|
|
|
|
QMetaObject::Connection pending_changes_connection_;
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void torrentSet(torrent_ids_t const& ids, tr_quark key, T val)
|
|
|
|
{
|
|
|
|
auto const tag = session_.torrentSet(ids, key, val);
|
|
|
|
pending_changes_tags_.insert(tag);
|
|
|
|
if (!pending_changes_connection_)
|
|
|
|
{
|
|
|
|
pending_changes_connection_ = connect(&session_, &Session::sessionCalled, this, &DetailsDialog::onSessionCalled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void torrentSet(tr_quark key, T val)
|
|
|
|
{
|
|
|
|
torrentSet(ids_, key, val);
|
|
|
|
}
|
|
|
|
|
2020-05-27 16:53:12 -05:00
|
|
|
Session& session_;
|
|
|
|
Prefs& prefs_;
|
|
|
|
TorrentModel const& model_;
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2020-06-05 14:02:11 -05:00
|
|
|
Ui::DetailsDialog ui_ = {};
|
2022-02-18 11:52:01 -06:00
|
|
|
Ui::TrackersDialog trackers_ui_ = {};
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2020-05-27 16:53:12 -05:00
|
|
|
torrent_ids_t ids_;
|
2020-07-29 11:56:23 -05:00
|
|
|
QTimer model_timer_;
|
|
|
|
QTimer ui_debounce_timer_;
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2020-11-08 13:54:40 -06:00
|
|
|
std::shared_ptr<TrackerModel> tracker_model_;
|
|
|
|
std::shared_ptr<TrackerModelFilter> tracker_filter_;
|
|
|
|
std::shared_ptr<TrackerDelegate> tracker_delegate_;
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2023-06-19 16:51:34 -05:00
|
|
|
std::map<QString, QTreeWidgetItem*> peers_;
|
2020-08-15 10:42:51 -05:00
|
|
|
|
2023-11-21 09:02:03 -06:00
|
|
|
QIcon const icon_encrypted_ = QIcon{ QStringLiteral(":/icons/encrypted.svg") };
|
2020-11-01 19:13:32 -06:00
|
|
|
QIcon const icon_unencrypted_ = {};
|
2022-01-24 23:16:33 -06:00
|
|
|
|
|
|
|
static int prev_tab_index_;
|
2009-04-09 18:55:47 +00:00
|
|
|
};
|