2023-02-11 20:49:42 +00:00
|
|
|
// This file Copyright © 2009-2023 Mnemosyne LLC.
|
2022-08-08 18:05:39 +00:00
|
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only),
|
2022-01-20 18:27:56 +00: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 21:51:34 +00:00
|
|
|
#include <map>
|
2020-11-08 19:54:40 +00:00
|
|
|
#include <memory>
|
2022-07-27 21:53:39 +00:00
|
|
|
#include <unordered_set>
|
2020-11-08 19:54:40 +00:00
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QString>
|
|
|
|
#include <QSet>
|
|
|
|
#include <QTimer>
|
|
|
|
|
2021-12-14 08:43:27 +00:00
|
|
|
#include <libtransmission/tr-macros.h>
|
|
|
|
|
2015-09-01 20:19:26 +00:00
|
|
|
#include "BaseDialog.h"
|
2020-07-29 16:56:23 +00:00
|
|
|
#include "Session.h"
|
2019-11-12 01:37:05 +00: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 17:52:01 +00: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 12:04:45 +00: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 18:11:55 +00:00
|
|
|
TR_DISABLE_COPY_MOVE(DetailsDialog)
|
2013-01-26 01:19:54 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
public:
|
2017-04-20 16:02:19 +00:00
|
|
|
DetailsDialog(Session&, Prefs&, TorrentModel const&, QWidget* parent = nullptr);
|
2022-01-25 05:16:33 +00:00
|
|
|
~DetailsDialog() override;
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2019-11-12 01:37:05 +00:00
|
|
|
void setIds(torrent_ids_t const& ids);
|
2015-06-12 22:12:12 +00:00
|
|
|
|
|
|
|
// QWidget
|
2019-11-12 01:37:05 +00:00
|
|
|
QSize sizeHint() const override
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
|
|
|
return QSize(440, 460);
|
|
|
|
}
|
2013-01-26 01:19:54 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
private:
|
|
|
|
void initPeersTab();
|
|
|
|
void initTrackerTab();
|
|
|
|
void initInfoTab();
|
2020-11-09 03:31:02 +00:00
|
|
|
void initFilesTab() const;
|
2017-04-19 12:04:45 +00:00
|
|
|
void initOptionsTab();
|
2013-01-26 01:19:54 +00:00
|
|
|
|
2019-11-09 14:44:40 +00:00
|
|
|
void setEnabled(bool);
|
2013-01-26 01:19:54 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
private slots:
|
2020-07-29 16:56:23 +00:00
|
|
|
void refreshModel();
|
2017-04-19 12:04:45 +00:00
|
|
|
void refreshPref(int key);
|
2020-07-29 16:56:23 +00:00
|
|
|
void refreshUI();
|
2013-01-26 01:19:54 +00:00
|
|
|
|
2020-06-18 20:34:11 +00:00
|
|
|
void onTorrentsEdited(torrent_ids_t const& ids);
|
2020-06-23 21:11:16 +00:00
|
|
|
void onTorrentsChanged(torrent_ids_t const& ids, Torrent::fields_t const& fields);
|
2020-07-29 16:56:23 +00: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 12:04:45 +00:00
|
|
|
void onTrackerSelectionChanged();
|
|
|
|
void onAddTrackerClicked();
|
2022-02-18 17:52:01 +00:00
|
|
|
void onEditTrackersClicked();
|
2017-04-19 12:04:45 +00:00
|
|
|
void onRemoveTrackerClicked();
|
|
|
|
void onShowTrackerScrapesToggled(bool);
|
|
|
|
void onShowBackupTrackersToggled(bool);
|
2022-02-18 17:52:01 +00:00
|
|
|
void onTrackerListEdited(QString);
|
2013-01-26 01:19:54 +00:00
|
|
|
|
2015-06-12 22:12:12 +00:00
|
|
|
// Files tab
|
2020-05-27 21:53:12 +00:00
|
|
|
void onFilePriorityChanged(QSet<int> const& file_indices, int);
|
|
|
|
void onFileWantedChanged(QSet<int> const& file_indices, bool);
|
|
|
|
void onPathEdited(QString const& old_path, QString const& new_name);
|
2020-11-09 03:31:02 +00:00
|
|
|
void onOpenRequested(QString const& path) const;
|
2015-06-12 22:12:12 +00:00
|
|
|
|
|
|
|
// Options tab
|
2017-04-19 12:04:45 +00: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 16:56:23 +00: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 09:41:48 +00:00
|
|
|
bool canEdit() const
|
|
|
|
{
|
|
|
|
return std::empty(pending_changes_tags_);
|
|
|
|
}
|
2020-07-29 16:56:23 +00: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 21:53:12 +00:00
|
|
|
Session& session_;
|
|
|
|
Prefs& prefs_;
|
|
|
|
TorrentModel const& model_;
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2020-06-05 19:02:11 +00:00
|
|
|
Ui::DetailsDialog ui_ = {};
|
2022-02-18 17:52:01 +00:00
|
|
|
Ui::TrackersDialog trackers_ui_ = {};
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2020-05-27 21:53:12 +00:00
|
|
|
torrent_ids_t ids_;
|
2020-07-29 16:56:23 +00:00
|
|
|
QTimer model_timer_;
|
|
|
|
QTimer ui_debounce_timer_;
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2020-11-08 19:54:40 +00: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 21:51:34 +00:00
|
|
|
std::map<QString, QTreeWidgetItem*> peers_;
|
2020-08-15 15:42:51 +00:00
|
|
|
|
2022-07-03 01:42:43 +00:00
|
|
|
QIcon const icon_encrypted_ = QIcon(QStringLiteral(":/icons/encrypted.svg"));
|
2020-11-02 01:13:32 +00:00
|
|
|
QIcon const icon_unencrypted_ = {};
|
2022-01-25 05:16:33 +00:00
|
|
|
|
|
|
|
static int prev_tab_index_;
|
2009-04-09 18:55:47 +00:00
|
|
|
};
|