diff --git a/src/core/net/private/geoipdatabase.cpp b/src/core/net/private/geoipdatabase.cpp index c3207eb88..7987b280d 100644 --- a/src/core/net/private/geoipdatabase.cpp +++ b/src/core/net/private/geoipdatabase.cpp @@ -63,7 +63,7 @@ namespace const quint32 __ENDIAN_TEST__ = 0x00000001; const bool __IS_LITTLE_ENDIAN__ = (reinterpret_cast(&__ENDIAN_TEST__)[0] == 0x01); - BEGIN_SCOPED_ENUM(DataType) + enum class DataType { Unknown = 0, Pointer = 1, @@ -81,8 +81,7 @@ namespace EndMarker = 13, Boolean = 14, Float = 15 - } - END_SCOPED_ENUM + }; struct DataFieldDescriptor { diff --git a/src/core/preferences.cpp b/src/core/preferences.cpp index 1e02aa5a8..f22ea2ae1 100644 --- a/src/core/preferences.cpp +++ b/src/core/preferences.cpp @@ -974,12 +974,12 @@ void Preferences::setGlobalMaxRatio(qreal ratio) MaxRatioAction Preferences::getMaxRatioAction() const { - return value("Preferences/Bittorrent/MaxRatioAction", MaxRatioAction::Pause).toInt(); + return value("Preferences/Bittorrent/MaxRatioAction", QVariant::fromValue(MaxRatioAction::Pause)).value(); } void Preferences::setMaxRatioAction(MaxRatioAction act) { - setValue("Preferences/Bittorrent/MaxRatioAction", act); + setValue("Preferences/Bittorrent/MaxRatioAction", QVariant::fromValue(act)); } // IP Filter diff --git a/src/core/types.h b/src/core/types.h index 4415191ff..92a24d0cf 100644 --- a/src/core/types.h +++ b/src/core/types.h @@ -31,43 +31,28 @@ #include -#define BEGIN_SCOPED_ENUM(name) class name\ -{\ - int m_val;\ -\ -public:\ - name() {}\ - name(int val) : m_val(val) {}\ - operator int() const { return m_val; }\ - operator QVariant() const { return m_val; }\ -\ - enum - -#define END_SCOPED_ENUM ; }; - const qlonglong MAX_ETA = 8640000; -BEGIN_SCOPED_ENUM(MaxRatioAction) +enum class MaxRatioAction { Pause, Remove -} -END_SCOPED_ENUM +}; -BEGIN_SCOPED_ENUM(TorrentExportFolder) +Q_DECLARE_METATYPE(MaxRatioAction) + +enum class TorrentExportFolder { Regular, Finished -} -END_SCOPED_ENUM +}; -BEGIN_SCOPED_ENUM(ShutdownAction) +enum class ShutdownAction { None, Shutdown, Suspend, Hibernate -} -END_SCOPED_ENUM +}; #endif // TYPES_H diff --git a/src/gui/options_imp.cpp b/src/gui/options_imp.cpp index baabdc8fe..beda4e089 100644 --- a/src/gui/options_imp.cpp +++ b/src/gui/options_imp.cpp @@ -469,7 +469,7 @@ void options_imp::saveOptions() pref->setEncryptionSetting(getEncryptionSetting()); pref->enableAnonymousMode(checkAnonymousMode->isChecked()); pref->setGlobalMaxRatio(getMaxRatio()); - pref->setMaxRatioAction(comboRatioLimitAct->currentIndex()); + pref->setMaxRatioAction(static_cast(comboRatioLimitAct->currentIndex())); // End Bittorrent preferences // Misc preferences // * IPFilter @@ -804,7 +804,7 @@ void options_imp::loadOptions() spinMaxRatio->setEnabled(false); comboRatioLimitAct->setEnabled(false); } - comboRatioLimitAct->setCurrentIndex(pref->getMaxRatioAction()); + comboRatioLimitAct->setCurrentIndex(static_cast(pref->getMaxRatioAction())); // End Bittorrent preferences // Web UI preferences diff --git a/src/webui/prefjson.cpp b/src/webui/prefjson.cpp index bf206df39..f08385463 100644 --- a/src/webui/prefjson.cpp +++ b/src/webui/prefjson.cpp @@ -141,7 +141,7 @@ QByteArray prefjson::getPreferences() // Share Ratio Limiting data["max_ratio_enabled"] = (pref->getGlobalMaxRatio() >= 0.); data["max_ratio"] = pref->getGlobalMaxRatio(); - data["max_ratio_act"] = pref->getMaxRatioAction(); + data["max_ratio_act"] = QVariant::fromValue(pref->getMaxRatioAction()); // Web UI // Language @@ -337,7 +337,7 @@ void prefjson::setPreferences(const QString& json) else pref->setGlobalMaxRatio(-1); if (m.contains("max_ratio_act")) - pref->setMaxRatioAction(m["max_ratio_act"].toInt()); + pref->setMaxRatioAction(m["max_ratio_act"].value()); // Web UI // Language