WebUI: migrate to fetch API
[qBittorrent.git] / src / gui / addnewtorrentdialog.h
blobbc530953bd9171418c62cfa4d360f8ca193d7c3f
1 /*
2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2022-2024 Vladimir Golovnev <glassez@yandex.ru>
4 * Copyright (C) 2012 Christophe Dumez <chris@qbittorrent.org>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * In addition, as a special exception, the copyright holders give permission to
21 * link this program with the OpenSSL project's "OpenSSL" library (or with
22 * modified versions of it that use the same license as the "OpenSSL" library),
23 * and distribute the linked executables. You must obey the GNU General Public
24 * License in all respects for all of the code used other than "OpenSSL". If you
25 * modify file(s), you may extend this exception to your version of the file(s),
26 * but you are not obligated to do so. If you do not wish to do so, delete this
27 * exception statement from your version.
30 #pragma once
32 #include <memory>
34 #include <QDialog>
36 #include "base/path.h"
37 #include "base/settingvalue.h"
38 #include "filterpatternformat.h"
40 class LineEdit;
42 namespace BitTorrent
44 class TorrentDescriptor;
45 class TorrentInfo;
46 struct AddTorrentParams;
49 namespace Ui
51 class AddNewTorrentDialog;
54 class AddNewTorrentDialog final : public QDialog
56 Q_OBJECT
57 Q_DISABLE_COPY_MOVE(AddNewTorrentDialog)
59 public:
60 explicit AddNewTorrentDialog(const BitTorrent::TorrentDescriptor &torrentDescr
61 , const BitTorrent::AddTorrentParams &inParams, QWidget *parent);
62 ~AddNewTorrentDialog() override;
64 bool isDoNotDeleteTorrentChecked() const;
65 void updateMetadata(const BitTorrent::TorrentInfo &metadata);
67 signals:
68 void torrentAccepted(const BitTorrent::TorrentDescriptor &torrentDescriptor, const BitTorrent::AddTorrentParams &addTorrentParams);
69 void torrentRejected(const BitTorrent::TorrentDescriptor &torrentDescriptor);
71 private slots:
72 void updateDiskSpaceLabel();
73 void onSavePathChanged(const Path &newPath);
74 void onDownloadPathChanged(const Path &newPath);
75 void onUseDownloadPathChanged(bool checked);
76 void TMMChanged(int index);
77 void categoryChanged(int index);
78 void contentLayoutChanged();
80 void accept() override;
81 void reject() override;
83 private:
84 class TorrentContentAdaptor;
85 struct Context;
87 void showEvent(QShowEvent *event) override;
89 void setCurrentContext(std::shared_ptr<Context> context);
90 void updateCurrentContext();
91 void populateSavePaths();
92 void loadState();
93 void saveState();
94 void setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText = {});
95 void setupTreeview();
96 void saveTorrentFile();
97 void showContentFilterContextMenu();
98 void setContentFilterPattern();
100 Ui::AddNewTorrentDialog *m_ui = nullptr;
101 std::unique_ptr<TorrentContentAdaptor> m_contentAdaptor;
102 int m_savePathIndex = -1;
103 int m_downloadPathIndex = -1;
104 bool m_useDownloadPath = false;
105 LineEdit *m_filterLine = nullptr;
107 std::shared_ptr<Context> m_currentContext;
109 SettingValue<QSize> m_storeDialogSize;
110 SettingValue<QString> m_storeDefaultCategory;
111 SettingValue<bool> m_storeRememberLastSavePath;
112 SettingValue<QByteArray> m_storeTreeHeaderState;
113 SettingValue<QByteArray> m_storeSplitterState;
114 SettingValue<FilterPatternFormat> m_storeFilterPatternFormat;