diff --git a/CMakeLists.txt b/CMakeLists.txt index 226d1253e..bc67dbfa5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION 3.9 FATAL_ERROR) +if(POLICY CMP0092) + cmake_policy(SET CMP0092 NEW) +endif() + # The value of this variable should be set prior to the first project() command invocation. # See: https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_DEPLOYMENT_TARGET.html if(CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "") diff --git a/qt/WatchDir.cc b/qt/WatchDir.cc index 774de45ab..9ec0d546e 100644 --- a/qt/WatchDir.cc +++ b/qt/WatchDir.cc @@ -30,27 +30,27 @@ WatchDir::WatchDir(TorrentModel const& model) **** ***/ -int WatchDir::metainfoTest(QString const& filename) const +WatchDir::AddResult WatchDir::metainfoTest(QString const& filename) const { auto metainfo = tr_torrent_metainfo(); if (!metainfo.parseTorrentFile(filename.toUtf8().constData())) { - return ERROR; + return AddResult::Error; } if (model_.hasTorrent(TorrentHash{ metainfo.infoHash() })) { - return DUPLICATE; + return AddResult::Duplicate; } - return OK; + return AddResult::Success; } void WatchDir::onTimeout() { auto* t = qobject_cast(sender()); - if (auto const filename = t->objectName(); metainfoTest(filename) == OK) + if (auto const filename = t->objectName(); metainfoTest(filename) == AddResult::Success) { emit torrentFileAdded(filename); } @@ -98,14 +98,14 @@ void WatchDir::watcherActivated(QString const& path) switch (metainfoTest(filename)) { - case OK: + case AddResult::Success: emit torrentFileAdded(filename); break; - case DUPLICATE: + case AddResult::Duplicate: break; - case ERROR: + case AddResult::Error: { // give the torrent a few seconds to finish downloading auto* t = new QTimer(this); diff --git a/qt/WatchDir.h b/qt/WatchDir.h index 9d262401c..ccd742438 100644 --- a/qt/WatchDir.h +++ b/qt/WatchDir.h @@ -36,14 +36,14 @@ private slots: void rescanAllWatchedDirectories(); private: - enum + enum class AddResult { - OK, - DUPLICATE, - ERROR + Success, + Duplicate, + Error }; - int metainfoTest(QString const& filename) const; + AddResult metainfoTest(QString const& filename) const; TorrentModel const& model_;