Enable customizing the save statistics time interval
[qBittorrent.git] / src / gui / addnewtorrentdialog.h
blobf81bd305bcb574f8a895ad023511e267ebf502f8
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);
70 private slots:
71 void updateDiskSpaceLabel();
72 void onSavePathChanged(const Path &newPath);
73 void onDownloadPathChanged(const Path &newPath);
74 void onUseDownloadPathChanged(bool checked);
75 void TMMChanged(int index);
76 void categoryChanged(int index);
77 void contentLayoutChanged();
79 void accept() override;
80 void reject() override;
82 private:
83 class TorrentContentAdaptor;
84 struct Context;
86 void showEvent(QShowEvent *event) override;
88 void setCurrentContext(std::shared_ptr<Context> context);
89 void updateCurrentContext();
90 void populateSavePaths();
91 void loadState();
92 void saveState();
93 void setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText = {});
94 void setupTreeview();
95 void saveTorrentFile();
96 void showContentFilterContextMenu();
97 void setContentFilterPattern();
99 Ui::AddNewTorrentDialog *m_ui = nullptr;
100 std::unique_ptr<TorrentContentAdaptor> m_contentAdaptor;
101 int m_savePathIndex = -1;
102 int m_downloadPathIndex = -1;
103 bool m_useDownloadPath = false;
104 LineEdit *m_filterLine = nullptr;
106 std::shared_ptr<Context> m_currentContext;
108 SettingValue<QSize> m_storeDialogSize;
109 SettingValue<QString> m_storeDefaultCategory;
110 SettingValue<bool> m_storeRememberLastSavePath;
111 SettingValue<QByteArray> m_storeTreeHeaderState;
112 SettingValue<QByteArray> m_storeSplitterState;
113 SettingValue<FilterPatternFormat> m_storeFilterPatternFormat;