2009-04-09 18:55:47 +00:00
|
|
|
/*
|
2015-06-10 21:27:11 +00:00
|
|
|
* This file Copyright (C) 2009-2015 Mnemosyne LLC
|
2009-04-09 18:55:47 +00:00
|
|
|
*
|
2014-01-21 03:10:30 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-01-19 01:09:44 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
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
|
|
|
|
Qt 6 support (#2069)
* Bump minimum Qt version to 5.6
* Switch from QRegExp to QRegularExpression
While still available, QRegExp has been moved to Qt6::Core5Compat module
and is not part of Qt6::Core.
* Use qIsEffectiveTLD instead of QUrl::topLevelDomain
The latter is not part of Qt6::Core. The former is a private utility in
Qt6::Network; using it for now, until (and if) we switch to something
non-Qt-specific.
* Use QStyle::State_Horizontal state when drawing progress bars
Although available for a long time, this state either didn't apply to
progress bars before Qt 6, or was deduced based on bar size. With Qt 6,
failing to specify it results in bad rendering.
* Don't use QStringRef (and associated methods)
While still available, QStringRef has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core. Related method (e.g.
QString::midRef) have been removed in Qt 6.
* Use Qt::ItemIsAutoTristate instead of Qt::ItemIsTristate
The latter was deprecated and replaced with the former in Qt 5.6.
* Don't use QApplication::globalStrut
This property has been deprecated in Qt 5.15 and removed in Qt 6.
* Use QImage::fromHICON instead of QtWin::fromHICON
WinExtras module (providind the latter helper) has been removed in Qt 6.
* Use QStringDecoder instead of QTextCodec
While still available, QTextCodec has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core.
* Don't forward-declare QStringList
Instead of being a standalone class, its definition has changed to
QList<QString> template specialization in Qt 6.
* Use explicit (since Qt 6) QFileInfo constructor
* Use QDateTime's {to,from}SecsSinceEpoch instead of {to,from}Time_t
The latter was deprecated in Qt 5.8 and removed in Qt 6.
* Don't use QFuture<>'s operator==
It has been removed in Qt 6. Since the original issue this code was
solving was caused by future reuse, just don't reuse futures and create
new finished ones when necessary.
* Use std::vector<> instead of QVector<>
The latter has been changed to a typedef for QList<>, which might not be
what one wants, and which also changed behavior a bit leading to
compilation errors.
* Don't use + for flags, cast to int explicitly
Operator+ for enum values has been deleted in Qt 6, so using operator|
instead. Then, there's no conversion from QFlags<> to QVariant, so need
to cast to int.
* Support Qt 6 in CMake and for MSI packaging
* Remove extra (empty) CMake variable use when constructing Qt target names
* Simplify logic in tr_qt_add_translation CMake helper
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-11-03 21:20:11 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2014-12-29 04:03:56 +00:00
|
|
|
#include <QCryptographicHash>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QDir>
|
2014-12-29 04:03:56 +00:00
|
|
|
#include <QFile>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QMap>
|
2010-08-01 18:55:04 +00:00
|
|
|
#include <QString>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QTimer>
|
|
|
|
|
2015-06-10 21:27:11 +00:00
|
|
|
#include "AddData.h" // AddData
|
2015-09-01 20:19:26 +00:00
|
|
|
#include "BaseDialog.h"
|
2020-08-11 18:11:55 +00:00
|
|
|
#include "Macros.h"
|
2015-06-10 21:27:11 +00:00
|
|
|
#include "Torrent.h" // FileList
|
|
|
|
#include "ui_OptionsDialog.h"
|
2013-02-09 04:05:03 +00:00
|
|
|
|
|
|
|
class Prefs;
|
2009-04-09 18:55:47 +00:00
|
|
|
class Session;
|
|
|
|
|
2013-08-24 19:26:21 +00:00
|
|
|
extern "C"
|
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
struct tr_variant;
|
2013-08-24 19:26:21 +00:00
|
|
|
}
|
2009-05-15 02:05:07 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
class OptionsDialog : public BaseDialog
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2013-02-09 21:47:42 +00:00
|
|
|
Q_OBJECT
|
2020-08-11 18:11:55 +00:00
|
|
|
TR_DISABLE_COPY_MOVE(OptionsDialog)
|
2013-02-09 21:47:42 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
public:
|
2020-06-05 19:02:11 +00:00
|
|
|
OptionsDialog(Session& session, Prefs const& prefs, AddData addme, QWidget* parent = nullptr);
|
2020-09-09 14:24:39 +00:00
|
|
|
~OptionsDialog() override;
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
private slots:
|
|
|
|
void onAccepted();
|
2020-05-27 21:53:12 +00:00
|
|
|
void onPriorityChanged(QSet<int> const& file_indices, int);
|
|
|
|
void onWantedChanged(QSet<int> const& file_indices, bool);
|
2017-04-19 12:04:45 +00:00
|
|
|
void onVerify();
|
|
|
|
void onTimeout();
|
2014-12-29 04:03:56 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void onSourceChanged();
|
|
|
|
void onDestinationChanged();
|
2013-02-09 21:47:42 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void onSessionUpdated();
|
2016-10-03 18:26:28 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
private:
|
2020-11-05 22:46:21 +00:00
|
|
|
using mybins_t = QMap<uint32_t, int32_t>;
|
|
|
|
|
|
|
|
void reload();
|
|
|
|
void updateWidgetsLocality();
|
|
|
|
void clearInfo();
|
|
|
|
void clearVerify();
|
|
|
|
|
2020-05-27 21:53:12 +00:00
|
|
|
AddData add_;
|
|
|
|
FileList files_;
|
2020-11-02 01:13:32 +00:00
|
|
|
QCryptographicHash verify_hash_ = QCryptographicHash(QCryptographicHash::Sha1);
|
|
|
|
|
2020-05-27 21:53:12 +00:00
|
|
|
QDir local_destination_;
|
|
|
|
QFile verify_file_;
|
|
|
|
QPushButton* verify_button_ = {};
|
|
|
|
QTimer edit_timer_;
|
|
|
|
QTimer verify_timer_;
|
Qt 6 support (#2069)
* Bump minimum Qt version to 5.6
* Switch from QRegExp to QRegularExpression
While still available, QRegExp has been moved to Qt6::Core5Compat module
and is not part of Qt6::Core.
* Use qIsEffectiveTLD instead of QUrl::topLevelDomain
The latter is not part of Qt6::Core. The former is a private utility in
Qt6::Network; using it for now, until (and if) we switch to something
non-Qt-specific.
* Use QStyle::State_Horizontal state when drawing progress bars
Although available for a long time, this state either didn't apply to
progress bars before Qt 6, or was deduced based on bar size. With Qt 6,
failing to specify it results in bad rendering.
* Don't use QStringRef (and associated methods)
While still available, QStringRef has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core. Related method (e.g.
QString::midRef) have been removed in Qt 6.
* Use Qt::ItemIsAutoTristate instead of Qt::ItemIsTristate
The latter was deprecated and replaced with the former in Qt 5.6.
* Don't use QApplication::globalStrut
This property has been deprecated in Qt 5.15 and removed in Qt 6.
* Use QImage::fromHICON instead of QtWin::fromHICON
WinExtras module (providind the latter helper) has been removed in Qt 6.
* Use QStringDecoder instead of QTextCodec
While still available, QTextCodec has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core.
* Don't forward-declare QStringList
Instead of being a standalone class, its definition has changed to
QList<QString> template specialization in Qt 6.
* Use explicit (since Qt 6) QFileInfo constructor
* Use QDateTime's {to,from}SecsSinceEpoch instead of {to,from}Time_t
The latter was deprecated in Qt 5.8 and removed in Qt 6.
* Don't use QFuture<>'s operator==
It has been removed in Qt 6. Since the original issue this code was
solving was caused by future reuse, just don't reuse futures and create
new finished ones when necessary.
* Use std::vector<> instead of QVector<>
The latter has been changed to a typedef for QList<>, which might not be
what one wants, and which also changed behavior a bit leading to
compilation errors.
* Don't use + for flags, cast to int explicitly
Operator+ for enum values has been deleted in Qt 6, so using operator|
instead. Then, there's no conversion from QFlags<> to QVariant, so need
to cast to int.
* Support Qt 6 in CMake and for MSI packaging
* Remove extra (empty) CMake variable use when constructing Qt target names
* Simplify logic in tr_qt_add_translation CMake helper
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-11-03 21:20:11 +00:00
|
|
|
std::vector<bool> verify_flags_;
|
|
|
|
std::vector<bool> wanted_;
|
|
|
|
std::vector<int> priorities_;
|
2020-05-27 21:53:12 +00:00
|
|
|
Session& session_;
|
2020-06-05 19:02:11 +00:00
|
|
|
Ui::OptionsDialog ui_ = {};
|
2020-05-27 21:53:12 +00:00
|
|
|
mybins_t verify_bins_;
|
2020-06-05 19:02:11 +00:00
|
|
|
tr_info info_ = {};
|
2020-05-27 21:53:12 +00:00
|
|
|
uint64_t verify_file_pos_ = {};
|
|
|
|
uint32_t verify_piece_index_ = {};
|
|
|
|
uint32_t verify_piece_pos_ = {};
|
|
|
|
int verify_file_index_ = {};
|
|
|
|
char verify_buf_[2048 * 4] = {};
|
|
|
|
bool have_info_ = {};
|
|
|
|
bool is_local_ = {};
|
2009-04-09 18:55:47 +00:00
|
|
|
};
|