2006-10-24 01:42:37 +04:00
|
|
|
/*
|
2018-04-14 22:53:45 +03:00
|
|
|
* Bittorrent Client using Qt and libtorrent.
|
2023-02-11 15:22:01 +03:00
|
|
|
* Copyright (C) 2022 Vladimir Golovnev <glassez@yandex.ru>
|
2018-04-14 22:53:45 +03:00
|
|
|
* Copyright (C) 2012 Christophe Dumez <chris@qbittorrent.org>
|
2006-10-24 01:42:37 +04:00
|
|
|
*
|
2007-07-14 18:31:59 +04:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2006-10-24 01:42:37 +04:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2007-07-14 18:31:59 +04:00
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
2009-04-05 21:00:55 +04:00
|
|
|
* In addition, as a special exception, the copyright holders give permission to
|
|
|
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
|
|
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
|
|
|
* and distribute the linked executables. You must obey the GNU General Public
|
|
|
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
|
|
|
* modify file(s), you may extend this exception to your version of the file(s),
|
|
|
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
|
|
|
* exception statement from your version.
|
2006-10-24 01:42:37 +04:00
|
|
|
*/
|
|
|
|
|
2020-12-10 20:56:37 +03:00
|
|
|
#pragma once
|
2010-11-14 00:15:52 +03:00
|
|
|
|
2019-02-16 07:29:57 +03:00
|
|
|
#include <memory>
|
|
|
|
|
2012-05-15 20:57:31 +04:00
|
|
|
#include <QDialog>
|
2013-09-21 11:59:58 +04:00
|
|
|
|
2018-04-14 22:53:45 +03:00
|
|
|
#include "base/bittorrent/addtorrentparams.h"
|
2020-09-07 18:05:55 +03:00
|
|
|
#include "base/bittorrent/magneturi.h"
|
2015-09-25 11:10:05 +03:00
|
|
|
#include "base/bittorrent/torrentinfo.h"
|
2022-04-01 09:35:45 +03:00
|
|
|
#include "base/path.h"
|
2018-10-21 14:51:58 +03:00
|
|
|
#include "base/settingvalue.h"
|
2006-10-24 01:42:37 +04:00
|
|
|
|
2016-01-07 14:22:35 +03:00
|
|
|
namespace BitTorrent
|
|
|
|
{
|
2020-09-07 18:05:55 +03:00
|
|
|
class InfoHash;
|
2016-01-07 14:22:35 +03:00
|
|
|
}
|
|
|
|
|
2019-03-01 10:38:16 +03:00
|
|
|
namespace Net
|
|
|
|
{
|
|
|
|
struct DownloadResult;
|
|
|
|
}
|
|
|
|
|
2016-01-07 14:22:35 +03:00
|
|
|
namespace Ui
|
|
|
|
{
|
2015-02-01 02:27:51 +03:00
|
|
|
class AddNewTorrentDialog;
|
2012-05-15 20:57:31 +04:00
|
|
|
}
|
2012-05-28 16:16:05 +04:00
|
|
|
|
2022-06-04 07:57:50 +03:00
|
|
|
class LineEdit;
|
2016-04-07 17:58:30 +03:00
|
|
|
class TorrentFileGuard;
|
2010-11-14 00:15:52 +03:00
|
|
|
|
2020-04-19 05:42:11 +03:00
|
|
|
class AddNewTorrentDialog final : public QDialog
|
2012-05-15 20:57:31 +04:00
|
|
|
{
|
2015-02-01 02:27:51 +03:00
|
|
|
Q_OBJECT
|
2021-06-29 09:45:23 +03:00
|
|
|
Q_DISABLE_COPY_MOVE(AddNewTorrentDialog)
|
2015-02-01 02:27:51 +03:00
|
|
|
|
2010-06-19 16:07:39 +04:00
|
|
|
public:
|
2018-05-18 09:24:54 +03:00
|
|
|
static const int minPathHistoryLength = 0;
|
|
|
|
static const int maxPathHistoryLength = 99;
|
2017-10-16 16:10:25 +03:00
|
|
|
|
2019-03-01 10:38:16 +03:00
|
|
|
~AddNewTorrentDialog() override;
|
2010-06-19 16:07:39 +04:00
|
|
|
|
2016-02-09 11:56:48 +03:00
|
|
|
static bool isEnabled();
|
|
|
|
static void setEnabled(bool value);
|
|
|
|
static bool isTopLevel();
|
|
|
|
static void setTopLevel(bool value);
|
2017-10-16 16:10:25 +03:00
|
|
|
static int savePathHistoryLength();
|
|
|
|
static void setSavePathHistoryLength(int value);
|
2010-06-19 16:07:39 +04:00
|
|
|
|
2018-12-28 08:38:08 +03:00
|
|
|
static void show(const QString &source, const BitTorrent::AddTorrentParams &inParams, QWidget *parent);
|
|
|
|
static void show(const QString &source, QWidget *parent);
|
2013-09-17 16:18:01 +04:00
|
|
|
|
2012-05-15 20:57:31 +04:00
|
|
|
private slots:
|
2015-02-01 02:27:51 +03:00
|
|
|
void updateDiskSpaceLabel();
|
2022-02-08 06:03:48 +03:00
|
|
|
void onSavePathChanged(const Path &newPath);
|
|
|
|
void onDownloadPathChanged(const Path &newPath);
|
2021-05-20 10:36:44 +03:00
|
|
|
void onUseDownloadPathChanged(bool checked);
|
2020-08-14 16:32:09 +03:00
|
|
|
void updateMetadata(const BitTorrent::TorrentInfo &metadata);
|
2021-10-06 21:45:37 +03:00
|
|
|
void handleDownloadFinished(const Net::DownloadResult &downloadResult);
|
2016-05-08 22:47:50 +03:00
|
|
|
void TMMChanged(int index);
|
2016-02-09 11:56:48 +03:00
|
|
|
void categoryChanged(int index);
|
2022-04-01 09:35:45 +03:00
|
|
|
void contentLayoutChanged();
|
2016-04-07 17:58:30 +03:00
|
|
|
void doNotDeleteTorrentClicked(bool checked);
|
2013-07-27 23:04:16 +04:00
|
|
|
|
2016-02-09 11:56:48 +03:00
|
|
|
void accept() override;
|
|
|
|
void reject() override;
|
2010-12-04 13:31:14 +03:00
|
|
|
|
2011-03-13 13:09:31 +03:00
|
|
|
private:
|
2023-02-11 15:22:01 +03:00
|
|
|
class TorrentContentAdaptor;
|
|
|
|
|
2016-07-15 05:15:10 +03:00
|
|
|
explicit AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inParams, QWidget *parent);
|
2022-04-01 09:35:45 +03:00
|
|
|
|
2022-02-08 06:03:48 +03:00
|
|
|
bool loadTorrentFile(const QString &source);
|
2019-02-13 17:41:38 +03:00
|
|
|
bool loadTorrentImpl();
|
2016-01-07 14:22:35 +03:00
|
|
|
bool loadMagnet(const BitTorrent::MagnetUri &magnetUri);
|
2021-05-20 10:36:44 +03:00
|
|
|
void populateSavePaths();
|
2015-02-01 02:27:51 +03:00
|
|
|
void loadState();
|
|
|
|
void saveState();
|
2019-02-22 04:33:04 +03:00
|
|
|
void setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText = {});
|
2015-02-01 02:27:51 +03:00
|
|
|
void setupTreeview();
|
2020-02-19 13:19:51 +03:00
|
|
|
void saveTorrentFile();
|
2021-12-09 13:05:49 +03:00
|
|
|
bool hasMetadata() const;
|
2016-02-09 11:56:48 +03:00
|
|
|
|
|
|
|
void showEvent(QShowEvent *event) override;
|
2011-03-13 13:09:31 +03:00
|
|
|
|
2022-06-23 07:28:00 +03:00
|
|
|
Ui::AddNewTorrentDialog *m_ui = nullptr;
|
2023-02-11 15:22:01 +03:00
|
|
|
TorrentContentAdaptor *m_contentAdaptor = nullptr;
|
2020-09-07 18:05:55 +03:00
|
|
|
BitTorrent::MagnetUri m_magnetURI;
|
2015-04-19 18:17:47 +03:00
|
|
|
BitTorrent::TorrentInfo m_torrentInfo;
|
2021-05-20 10:36:44 +03:00
|
|
|
int m_savePathIndex = -1;
|
|
|
|
int m_downloadPathIndex = -1;
|
|
|
|
bool m_useDownloadPath = false;
|
2022-06-04 07:57:50 +03:00
|
|
|
LineEdit *m_filterLine = nullptr;
|
2019-02-16 07:29:57 +03:00
|
|
|
std::unique_ptr<TorrentFileGuard> m_torrentGuard;
|
2016-07-15 05:15:10 +03:00
|
|
|
BitTorrent::AddTorrentParams m_torrentParams;
|
2018-10-21 14:51:58 +03:00
|
|
|
|
2020-12-28 18:32:59 +03:00
|
|
|
SettingValue<QSize> m_storeDialogSize;
|
2021-11-08 08:23:33 +03:00
|
|
|
SettingValue<QString> m_storeDefaultCategory;
|
|
|
|
SettingValue<bool> m_storeRememberLastSavePath;
|
2021-11-04 06:34:00 +03:00
|
|
|
SettingValue<QByteArray> m_storeTreeHeaderState;
|
|
|
|
SettingValue<QByteArray> m_storeSplitterState;
|
2010-06-19 16:07:39 +04:00
|
|
|
};
|