Browse Source

Raise minimal Qt version to 5.5.1

adaptive-webui-19844
Eugene Shalygin 8 years ago
parent
commit
008d7dbedc
  1. 24
      configure
  2. 10
      m4/qbittorrent.m4
  3. 2
      src/CMakeLists.txt
  4. 21
      src/base/torrentfileguard.cpp
  5. 25
      src/base/torrentfileguard.h
  6. 4
      src/base/utils/misc.cpp
  7. 11
      src/webui/btjson.cpp

24
configure vendored

@ -1407,7 +1407,7 @@ Some influential environment variables:
directories to add to pkg-config's search path directories to add to pkg-config's search path
PKG_CONFIG_LIBDIR PKG_CONFIG_LIBDIR
path overriding pkg-config's built-in search path path overriding pkg-config's built-in search path
QT_QMAKE value of host_bins for Qt5Core >= 5.2.0, overriding pkg-config QT_QMAKE value of host_bins for Qt5Core >= 5.5.1, overriding pkg-config
libtorrent_CFLAGS libtorrent_CFLAGS
C compiler flags for libtorrent, overriding pkg-config C compiler flags for libtorrent, overriding pkg-config
libtorrent_LIBS libtorrent_LIBS
@ -4424,8 +4424,8 @@ $as_echo "$enable_webui" >&6; }
esac esac
if test -n "$PKG_CONFIG" && \ if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Core >= 5.2.0\""; } >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Core >= 5.5.1\""; } >&5
($PKG_CONFIG --exists --print-errors "Qt5Core >= 5.2.0") 2>&5 ($PKG_CONFIG --exists --print-errors "Qt5Core >= 5.5.1") 2>&5
ac_status=$? ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then test $ac_status = 0; }; then
@ -4434,12 +4434,12 @@ if test -n "$QT_QMAKE"; then
pkg_cv_QT_QMAKE="$QT_QMAKE" pkg_cv_QT_QMAKE="$QT_QMAKE"
elif test -n "$PKG_CONFIG"; then elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \ if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Core >= 5.2.0\""; } >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Core >= 5.5.1\""; } >&5
($PKG_CONFIG --exists --print-errors "Qt5Core >= 5.2.0") 2>&5 ($PKG_CONFIG --exists --print-errors "Qt5Core >= 5.5.1") 2>&5
ac_status=$? ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then test $ac_status = 0; }; then
pkg_cv_QT_QMAKE=`$PKG_CONFIG --variable="host_bins" "Qt5Core >= 5.2.0" 2>/dev/null` pkg_cv_QT_QMAKE=`$PKG_CONFIG --variable="host_bins" "Qt5Core >= 5.5.1" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes test "x$?" != "x0" && pkg_failed=yes
else else
pkg_failed=yes pkg_failed=yes
@ -4466,8 +4466,8 @@ fi
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Qt5 qmake >= 5.2.0" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Qt5 qmake >= 5.5.1" >&5
$as_echo_n "checking for Qt5 qmake >= 5.2.0... " >&6; } $as_echo_n "checking for Qt5 qmake >= 5.5.1... " >&6; }
if test "x$QT_QMAKE" != "x"; then : if test "x$QT_QMAKE" != "x"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $QT_QMAKE" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $QT_QMAKE" >&5
$as_echo "$QT_QMAKE" >&6; } $as_echo "$QT_QMAKE" >&6; }
@ -4483,11 +4483,11 @@ case "x$enable_qt_dbus" in #(
"xyes") : "xyes") :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; } $as_echo "yes" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Qt5DBus >= 5.2.0" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Qt5DBus >= 5.5.1" >&5
$as_echo_n "checking for Qt5DBus >= 5.2.0... " >&6; } $as_echo_n "checking for Qt5DBus >= 5.5.1... " >&6; }
if test -n "$PKG_CONFIG" && \ if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5DBus >= 5.2.0\""; } >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5DBus >= 5.5.1\""; } >&5
($PKG_CONFIG --exists --print-errors "Qt5DBus >= 5.2.0") 2>&5 ($PKG_CONFIG --exists --print-errors "Qt5DBus >= 5.5.1") 2>&5
ac_status=$? ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then test $ac_status = 0; }; then

10
m4/qbittorrent.m4

@ -5,9 +5,9 @@
# Sets the QT_QMAKE variable to the path of Qt5 qmake if found. # Sets the QT_QMAKE variable to the path of Qt5 qmake if found.
# -------------------------------------- # --------------------------------------
AC_DEFUN([FIND_QT5], AC_DEFUN([FIND_QT5],
[PKG_CHECK_EXISTS([Qt5Core >= 5.2.0], [PKG_CHECK_EXISTS([Qt5Core >= 5.5.1],
[PKG_CHECK_VAR(QT_QMAKE, [PKG_CHECK_VAR(QT_QMAKE,
[Qt5Core >= 5.2.0], [Qt5Core >= 5.5.1],
[host_bins]) [host_bins])
]) ])
@ -18,7 +18,7 @@ AS_IF([test -f "$QT_QMAKE/qmake"],
[QT_QMAKE=""]) [QT_QMAKE=""])
]) ])
AC_MSG_CHECKING([for Qt5 qmake >= 5.2.0]) AC_MSG_CHECKING([for Qt5 qmake >= 5.5.1])
AS_IF([test "x$QT_QMAKE" != "x"], AS_IF([test "x$QT_QMAKE" != "x"],
[AC_MSG_RESULT([$QT_QMAKE])], [AC_MSG_RESULT([$QT_QMAKE])],
[AC_MSG_RESULT([not found])] [AC_MSG_RESULT([not found])]
@ -29,8 +29,8 @@ AS_IF([test "x$QT_QMAKE" != "x"],
# Sets the HAVE_QTDBUS variable to true or false. # Sets the HAVE_QTDBUS variable to true or false.
# -------------------------------------- # --------------------------------------
AC_DEFUN([FIND_QTDBUS], AC_DEFUN([FIND_QTDBUS],
[AC_MSG_CHECKING([for Qt5DBus >= 5.2.0]) [AC_MSG_CHECKING([for Qt5DBus >= 5.5.1])
PKG_CHECK_EXISTS([Qt5DBus >= 5.2.0], PKG_CHECK_EXISTS([Qt5DBus >= 5.5.1],
[AC_MSG_RESULT([found]) [AC_MSG_RESULT([found])
HAVE_QTDBUS=[true]], HAVE_QTDBUS=[true]],
[AC_MSG_RESULT([not found]) [AC_MSG_RESULT([not found])

2
src/CMakeLists.txt

@ -15,7 +15,7 @@ endif (GUI)
if (DBUS) if (DBUS)
list (APPEND QBT_QT_COMPONENTS DBus) list (APPEND QBT_QT_COMPONENTS DBus)
endif (DBUS) endif (DBUS)
find_package(Qt5 5.2.0 COMPONENTS ${QBT_QT_COMPONENTS} REQUIRED) find_package(Qt5 5.5.1 COMPONENTS ${QBT_QT_COMPONENTS} REQUIRED)
set(CMAKE_AUTOMOC True) set(CMAKE_AUTOMOC True)

21
src/base/torrentfileguard.cpp

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

25
src/base/torrentfileguard.h

@ -50,13 +50,9 @@ private:
/// Reads settings for .torrent files from preferences /// Reads settings for .torrent files from preferences
/// and sets the file guard up accordingly /// and sets the file guard up accordingly
class TorrentFileGuard class TorrentFileGuard: private FileGuard
{ {
Q_GADGET 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: public:
TorrentFileGuard(const QString &path = QString()); TorrentFileGuard(const QString &path = QString());
@ -79,25 +75,12 @@ public:
private: private:
static QMetaEnum modeMetaEnum(); static QMetaEnum modeMetaEnum();
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
TorrentFileGuard(const QString &path, AutoDeleteMode mode);
Q_ENUM(AutoDeleteMode) Q_ENUM(AutoDeleteMode)
#endif
AutoDeleteMode m_mode; AutoDeleteMode m_mode;
bool m_wasAdded; 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 #endif // TOFFENTFILEGURAD_H

4
src/base/utils/misc.cpp

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

11
src/webui/btjson.cpp

@ -899,17 +899,6 @@ QVariantMap generateSyncData(int acceptedResponseId, QVariantMap data, QVariantM
if (fullUpdate) { if (fullUpdate) {
lastAcceptedData.clear(); lastAcceptedData.clear();
syncData = data; syncData = data;
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
// QJsonDocument::fromVariant() supports QVariantHash only
// since Qt5.5, so manually convert data["torrents"]
QVariantMap torrentsMap;
QVariantHash torrents = data["torrents"].toHash();
foreach (const QString &key, torrents.keys())
torrentsMap[key] = torrents[key];
syncData["torrents"] = torrentsMap;
#endif
syncData[KEY_FULL_UPDATE] = true; syncData[KEY_FULL_UPDATE] = true;
} }

Loading…
Cancel
Save