mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-03 22:22:33 -06:00
Implement enum support in CachedSettingValue
Enums are stored as strings, that improves configuration file readability and maintainability. String values are obtained via QMetaEnum, and since with Qt 5.5 QMetaEnum::fromType() includes a static_assert, this has to be a safe method.
This commit is contained in:
@@ -29,10 +29,11 @@
|
||||
#ifndef TOFFENTFILEGURAD_H
|
||||
#define TOFFENTFILEGURAD_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QMetaType>
|
||||
|
||||
class QMetaEnum;
|
||||
template <typename T> class CachedSettingValue;
|
||||
|
||||
/// Utility class to defer file deletion
|
||||
class FileGuard
|
||||
{
|
||||
@@ -62,7 +63,7 @@ public:
|
||||
void markAsAddedToSession();
|
||||
using FileGuard::setAutoRemove;
|
||||
|
||||
enum AutoDeleteMode // do not change these names: they are stored in config file
|
||||
enum AutoDeleteMode: int // do not change these names: they are stored in config file
|
||||
{
|
||||
Never,
|
||||
IfAdded,
|
||||
@@ -74,9 +75,8 @@ public:
|
||||
static void setAutoDeleteMode(AutoDeleteMode mode);
|
||||
|
||||
private:
|
||||
static QMetaEnum modeMetaEnum();
|
||||
|
||||
TorrentFileGuard(const QString &path, AutoDeleteMode mode);
|
||||
static CachedSettingValue<AutoDeleteMode> &autoDeleteModeSetting();
|
||||
|
||||
Q_ENUM(AutoDeleteMode)
|
||||
AutoDeleteMode m_mode;
|
||||
|
||||
Reference in New Issue
Block a user