Raise minimal Qt version to 5.5.1

This commit is contained in:
Eugene Shalygin
2017-01-19 13:31:35 +01:00
parent e64bb1de8c
commit 008d7dbedc
7 changed files with 32 additions and 65 deletions

View File

@@ -54,17 +54,22 @@ FileGuard::~FileGuard()
Utils::Fs::forceRemove(m_path); // forceRemove() checks for file existence
}
TorrentFileGuard::TorrentFileGuard(const QString &path)
: m_mode {autoDeleteMode()}
TorrentFileGuard::TorrentFileGuard(const QString &path, TorrentFileGuard::AutoDeleteMode mode)
: FileGuard {mode != Never ? path : QString()}
, m_mode {mode}
, m_wasAdded {false}
, m_guard {m_mode != Never ? path : QString()}
{
}
TorrentFileGuard::TorrentFileGuard(const QString &path)
: TorrentFileGuard {path, autoDeleteMode()}
{
}
TorrentFileGuard::~TorrentFileGuard()
{
if (!m_wasAdded && (m_mode != Always))
m_guard.setAutoRemove(false);
setAutoRemove(false);
}
void TorrentFileGuard::markAsAddedToSession()
@@ -74,7 +79,7 @@ void TorrentFileGuard::markAsAddedToSession()
void TorrentFileGuard::setAutoRemove(bool remove)
{
m_guard.setAutoRemove(remove);
setAutoRemove(remove);
}
TorrentFileGuard::AutoDeleteMode TorrentFileGuard::autoDeleteMode()
@@ -92,11 +97,5 @@ void TorrentFileGuard::setAutoDeleteMode(TorrentFileGuard::AutoDeleteMode mode)
QMetaEnum TorrentFileGuard::modeMetaEnum()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
return QMetaEnum::fromType<AutoDeleteMode>();
#else
const int enumeratorIndex = staticMetaObject.indexOfEnumerator("AutoDeleteMode");
Q_ASSERT(enumeratorIndex >= 0);
return staticMetaObject.enumerator(enumeratorIndex);
#endif
}

View File

@@ -50,13 +50,9 @@ private:
/// Reads settings for .torrent files from preferences
/// and sets the file guard up accordingly
class TorrentFileGuard
class TorrentFileGuard: private FileGuard
{
Q_GADGET
// moc from Qt4 ignores Q_ENUMS when it is behind #if QT_VERSION check
// this declaration is needed for Qt 4 only
// TODO Qt5: remove when dropping Qt4 support
Q_ENUMS(AutoDeleteMode)
public:
TorrentFileGuard(const QString &path = QString());
@@ -79,25 +75,12 @@ public:
private:
static QMetaEnum modeMetaEnum();
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
TorrentFileGuard(const QString &path, AutoDeleteMode mode);
Q_ENUM(AutoDeleteMode)
#endif
AutoDeleteMode m_mode;
bool m_wasAdded;
// Qt 4 moc has troubles with Q_GADGET: if Q_GADGET is present in a class, moc unconditionally
// references in the generated code the statiMetaObject from the class ancestor.
// Moreover, if the ancestor class has Q_GADGET but does not have other
// Q_ declarations, moc does not generate staticMetaObject for it. These results
// in referencing the non existent staticMetaObject and such code fails to compile.
// This problem is NOT present in Qt 5.7.0 and maybe in some older Qt 5 versions too
// Qt 4.8.7 has it.
// Therefore, we can't inherit FileGuard :(
// TODO Qt5: port to private inheritance when dropping Qt 4 support
FileGuard m_guard;
};
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
Q_DECLARE_METATYPE(TorrentFileGuard::AutoDeleteMode)
#endif
#endif // TOFFENTFILEGURAD_H

View File

@@ -662,14 +662,10 @@ QString Utils::Misc::osName()
{
// static initialization for usage in signal handler
static const QString name =
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
QString("%1 %2 %3")
.arg(QSysInfo::prettyProductName())
.arg(QSysInfo::kernelVersion())
.arg(QSysInfo::currentCpuArchitecture());
#else
"<Input OS name here>";
#endif
return name;
}