Don't stuck loading on mismatching info-hashes in resume data
[qBittorrent.git] / src / gui / torrentcreatordialog.h
blobaddda955d8325d14a74d1ba403fe5fb003122236
1 /*
2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2017 Mike Tzou (Chocobo1)
4 * Copyright (C) 2010 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 <QDialog>
33 #include <QThreadPool>
35 #include "base/bittorrent/torrentcreator.h"
36 #include "base/path.h"
37 #include "base/settingvalue.h"
39 namespace Ui
41 class TorrentCreatorDialog;
44 class TorrentCreatorDialog final : public QDialog
46 Q_OBJECT
47 Q_DISABLE_COPY_MOVE(TorrentCreatorDialog)
49 public:
50 TorrentCreatorDialog(QWidget *parent = nullptr, const Path &defaultPath = {});
51 ~TorrentCreatorDialog() override;
52 void updateInputPath(const Path &path);
54 private slots:
55 void updateProgressBar(int progress);
56 void updatePiecesCount();
57 void onCreateButtonClicked();
58 void onAddFileButtonClicked();
59 void onAddFolderButtonClicked();
60 void handleCreationFailure(const QString &msg);
61 void handleCreationSuccess(const Path &path, const Path &branchPath);
63 private:
64 void dropEvent(QDropEvent *event) override;
65 void dragEnterEvent(QDragEnterEvent *event) override;
67 void saveSettings();
68 void loadSettings();
69 void setInteractionEnabled(bool enabled) const;
71 int getPieceSize() const;
72 #ifdef QBT_USES_LIBTORRENT2
73 BitTorrent::TorrentFormat getTorrentFormat() const;
74 #else
75 int getPaddedFileSizeLimit() const;
76 #endif
78 Ui::TorrentCreatorDialog *m_ui = nullptr;
79 QThreadPool m_threadPool;
81 // settings
82 SettingValue<QSize> m_storeDialogSize;
83 SettingValue<int> m_storePieceSize;
84 SettingValue<bool> m_storePrivateTorrent;
85 SettingValue<bool> m_storeStartSeeding;
86 SettingValue<bool> m_storeIgnoreRatio;
87 #ifdef QBT_USES_LIBTORRENT2
88 SettingValue<int> m_storeTorrentFormat;
89 #else
90 SettingValue<bool> m_storeOptimizeAlignment;
91 SettingValue<int> m_paddedFileSizeLimit;
92 #endif
93 SettingValue<Path> m_storeLastAddPath;
94 SettingValue<QString> m_storeTrackerList;
95 SettingValue<QString> m_storeWebSeedList;
96 SettingValue<QString> m_storeComments;
97 SettingValue<Path> m_storeLastSavePath;
98 SettingValue<QString> m_storeSource;