diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c9cfc40b..23c67bc7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,13 +23,19 @@ include(CPack) OPTION(ENABLE_TAGLIB "Enable TagLib library (required for tag editing, replaygain calculation, device support, etc)" ON) OPTION(ENABLE_TAGLIB_EXTRAS "Enable TagLib-Extras library (used by tag editing, replaygain calculation, device support, etc)" ON) OPTION(ENABLE_PHONON "Enable Phonon library (required to playback MPD HTTP streams)" OFF) -OPTION(ENABLE_KDE "Enable KDE libraries (required for device support, and to use KDE dialogs)" ON) +OPTION(ENABLE_KDE "Enable KDE libraries" ON) +OPTION(ENABLE_QT5 "Build against Qt5" OFF) OPTION(ENABLE_MTP "Enable MTP library (required to support MTP devices)" ON) OPTION(ENABLE_WEBKIT "Enable WebKit library (required for artist/album information)" ON) OPTION(ENABLE_FFMPEG "Enable ffmpeg/libav libraries (required for replaygain calculation)" ON) OPTION(ENABLE_MPG123 "Enable mpg123 libraries (required for replaygain calculation)" ON) OPTION(ENABLE_SPEEXDSP "Enable SpeexDSP libraries (used to speed-up replaygain calculation)" ON) +if (ENABLE_QT5) + set(ENABLE_PHONON FALSE) + set(ENABLE_KDE FALSE) +endif (ENABLE_QT5) + macro(cantata_check_for_sse) # check for SSE extensions include(CheckCXXSourceRuns) @@ -312,22 +318,67 @@ include_directories( ${CMAKE_SOURCE_DIR}/gui ${CMAKE_BINARY_DIR} ) -# this command finds Qt4 libraries and sets all required variables -FIND_PACKAGE( Qt4 REQUIRED QtCore QtGui QtXml QtNetwork ) +if (ENABLE_QT5) + find_package(Qt5Widgets REQUIRED) + find_package(Qt5Xml REQUIRED) + find_package(Qt5Network REQUIRED) + find_package(Qt5Concurrent REQUIRED) + set (QTLIBS ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Concurrent_LIBRARIES}) + set (QTINCLUDES ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS} ${Qt5Concurrent_INCLUDE_DIRS}) + add_definitions(${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS} ${Qt5Xml_DEFINITIONS} ${Qt5Concurrent_DEFINITIONS}) + set (CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") + if(NOT WIN32) + find_package(Qt5DBus REQUIRED) + set (QTLIBS ${QTLIBS} ${Qt5DBus_LIBRARIES}) + set (QTINCLUDES ${QTINCLUDES} ${Qt5DBus_INCLUDE_DIRS}) + add_definitions(${Qt5DBus_DEFINITIONS}) + endif(NOT WIN32) +else (ENABLE_QT5) + find_package(Qt4 REQUIRED QtCore QtGui QtXml QtNetwork) + set (QTLIBS ${QT_QTXML_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTDBUS_LIBRARY} ) + set (QTINCLUDES ${QT_INCLUDES}) + add_definitions( -DQT_NO_STL -DQT_NO_CAST_TO_ASCII -Wall -Wextra ) +endif (ENABLE_QT5) + +if (ENABLE_WEBKIT) + if (ENABLE_KDE_SUPPORT) + TARGET_LINK_LIBRARIES( cantata ${KDE4_KDEWEBKIT_LIBRARY} ${QT_QTWEBKIT_LIBRARY} ) + else (ENABLE_KDE_SUPPORT) + if (ENABLE_QT5) + find_package(Qt5WebKit REQUIRED) + find_package(Qt5WebKitWidgets REQUIRED) + set (QTLIBS ${QTLIBS} ${Qt5WebKit_LIBRARIES} ${Qt5WebKitWidgets_LIBRARIES}) + set (QTINCLUDES ${QTINCLUDES} ${Qt5WebKit_INCLUDE_DIRS} ${Qt5WebKitWidgets_INCLUDE_DIRS}) + add_definitions(${Qt5WebKit_DEFINITIONS} ${Qt5WebKitWidgets_DEFINITIONS}) + else (ENABLE_QT5) + set (QTLIBS ${QTLIBS} ${QT_QTWEBKIT_LIBRARY}) + endif (ENABLE_QT5) + endif (ENABLE_KDE_SUPPORT) +endif (ENABLE_WEBKIT) + if (ENABLE_PHONON) FIND_PACKAGE( Phonon ) endif (ENABLE_PHONON) if(NOT WIN32) - qt4_add_dbus_adaptor(CANTATA_SRCS dbus/org.mpris.MediaPlayer2.Player.xml dbus/mpris.h Mpris) - qt4_add_dbus_adaptor(CANTATA_SRCS dbus/org.mpris.MediaPlayer2.root.xml dbus/mpris.h Mpris) - qt4_add_dbus_adaptor(CANTATA_SRCS dbus/com.googlecode.cantata.xml gui/mainwindow.h MainWindow) - if (NOT ENABLE_KDE_SUPPORT) - qt4_add_dbus_interfaces(CANTATA_SRCS dbus/org.freedesktop.Notifications.xml) - qt4_add_dbus_interfaces(CANTATA_SRCS dbus/org.freedesktop.UPower.xml) - endif (NOT ENABLE_KDE_SUPPORT) - qt4_add_dbus_interfaces(CANTATA_SRCS dbus/org.gnome.SettingsDaemon.MediaKeys.xml) + if (ENABLE_QT5) + qt5_add_dbus_adaptor(CANTATA_SRCS dbus/org.mpris.MediaPlayer2.Player.xml dbus/mpris.h Mpris) + qt5_add_dbus_adaptor(CANTATA_SRCS dbus/org.mpris.MediaPlayer2.root.xml dbus/mpris.h Mpris) + qt5_add_dbus_adaptor(CANTATA_SRCS dbus/com.googlecode.cantata.xml gui/mainwindow.h MainWindow) + qt5_add_dbus_interfaces(CANTATA_SRCS dbus/org.freedesktop.Notifications.xml) + qt5_add_dbus_interfaces(CANTATA_SRCS dbus/org.freedesktop.UPower.xml) + qt5_add_dbus_interfaces(CANTATA_SRCS dbus/org.gnome.SettingsDaemon.MediaKeys.xml) + else (ENABLE_QT5) + qt4_add_dbus_adaptor(CANTATA_SRCS dbus/org.mpris.MediaPlayer2.Player.xml dbus/mpris.h Mpris) + qt4_add_dbus_adaptor(CANTATA_SRCS dbus/org.mpris.MediaPlayer2.root.xml dbus/mpris.h Mpris) + qt4_add_dbus_adaptor(CANTATA_SRCS dbus/com.googlecode.cantata.xml gui/mainwindow.h MainWindow) + if (NOT ENABLE_KDE_SUPPORT) + qt4_add_dbus_interfaces(CANTATA_SRCS dbus/org.freedesktop.Notifications.xml) + qt4_add_dbus_interfaces(CANTATA_SRCS dbus/org.freedesktop.UPower.xml) + endif (NOT ENABLE_KDE_SUPPORT) + qt4_add_dbus_interfaces(CANTATA_SRCS dbus/org.gnome.SettingsDaemon.MediaKeys.xml) + endif (ENABLE_QT5) endif(NOT WIN32) IF( ENABLE_KDE ) @@ -435,7 +486,11 @@ if (TAGLIB_FOUND) devices/remotedevicepropertieswidget.h) SET(CANTATA_UIS ${CANTATA_UIS} devices/remotedevicepropertieswidget.ui) if (ENABLE_MOUNTER) - qt4_add_dbus_interfaces(CANTATA_SRCS devices/mounter/com.googlecode.cantata.mounter.xml) + if (ENABLE_QT5) + qt5_add_dbus_interfaces(CANTATA_SRCS devices/mounter/com.googlecode.cantata.mounter.xml) + else (ENABLE_QT5) + qt4_add_dbus_interfaces(CANTATA_SRCS devices/mounter/com.googlecode.cantata.mounter.xml) + endif (ENABLE_QT5) add_subdirectory(devices/mounter) endif (ENABLE_MOUNTER) endif (ENABLE_REMOTE_DEVICES) @@ -476,10 +531,16 @@ ELSE( ENABLE_KDE_SUPPORT ) SET( CANTATA_MOC_HDRS ${CANTATA_MOC_HDRS} network/proxysettings.h ) SET( CANTATA_UIS ${CANTATA_UIS} network/proxysettings.ui ) SET( CANTATA_RCS ${CANTATA_RCS} cantata_qt.qrc ) - QT4_ADD_RESOURCES( CANTATA_RC_SRCS ${CANTATA_RCS} ) - QT4_WRAP_UI( CANTATA_UI_HDRS ${CANTATA_UIS} ) - INCLUDE( ${QT_USE_FILE} ) - QT4_WRAP_CPP( CANTATA_MOC_SRCS ${CANTATA_MOC_HDRS} ) + if (ENABLE_QT5) + QT5_ADD_RESOURCES( CANTATA_RC_SRCS ${CANTATA_RCS} ) + QT5_WRAP_UI( CANTATA_UI_HDRS ${CANTATA_UIS} ) + QT5_WRAP_CPP( CANTATA_MOC_SRCS ${CANTATA_MOC_HDRS} ) + else (ENABLE_QT5) + QT4_ADD_RESOURCES( CANTATA_RC_SRCS ${CANTATA_RCS} ) + QT4_WRAP_UI( CANTATA_UI_HDRS ${CANTATA_UIS} ) + INCLUDE( ${QT_USE_FILE} ) + QT4_WRAP_CPP( CANTATA_MOC_SRCS ${CANTATA_MOC_HDRS} ) + endif (ENABLE_QT5) if (WIN32) SET(CMAKE_BUILD_TYPE "Release") @@ -490,7 +551,6 @@ ELSE( ENABLE_KDE_SUPPORT ) endif (WIN32) install( TARGETS cantata RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) - ADD_DEFINITIONS( -DQT_NO_STL -DQT_NO_CAST_TO_ASCII -Wall -Wextra ) SET( XDG_APPS_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/applications" ) if (WIN32) @@ -516,8 +576,8 @@ endif (MTP_FOUND AND NOT WIN32) ADD_SUBDIRECTORY( icons ) -TARGET_LINK_LIBRARIES(cantata support ${QT_QTXML_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTDBUS_LIBRARY} -lz) -include_directories( ${QT_INCLUDES}) +TARGET_LINK_LIBRARIES(cantata support ${QTLIBS} -lz) +include_directories(${QTINCLUDES}) if (TAGLIB_FOUND) TARGET_LINK_LIBRARIES(cantata ${TAGLIB_LIBRARIES}) @@ -551,14 +611,6 @@ if (PHONON_FOUND) include_directories( ${PHONON_INCLUDES}) endif (PHONON_FOUND) -if (ENABLE_WEBKIT) - IF( ENABLE_KDE_SUPPORT ) - TARGET_LINK_LIBRARIES( cantata ${KDE4_KDEWEBKIT_LIBRARY} ${QT_QTWEBKIT_LIBRARY} ) - ELSE( ENABLE_KDE_SUPPORT ) - TARGET_LINK_LIBRARIES( cantata ${QT_QTWEBKIT_LIBRARY} ) - ENDIF( ENABLE_KDE_SUPPORT ) -endif (ENABLE_WEBKIT) - # enable warnings ADD_DEFINITIONS( -DQT_NO_DEBUG_OUTPUT ) @@ -573,7 +625,11 @@ IF( ENABLE_KDE_SUPPORT ) message("INFO: Building KDE version") else ( ENABLE_KDE_SUPPORT ) if (NOT WIN32) - message("INFO: Building Qt-Only version") + if (ENABLE_QT5) + message("INFO: Building Qt5 version") + else (ENABLE_QT5) + message("INFO: Building Qt4 version") + endif (ENABLE_QT5) endif (NOT WIN32) endif ( ENABLE_KDE_SUPPORT ) diff --git a/ChangeLog b/ChangeLog index 55522ac4e..f9ff00a7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -79,6 +79,8 @@ items in the genre combos. 46. Remove 'Auto' cover size setting. Now cover sizes are based upon setting and font size. +47. Initial support for Qt5. Currently crashes if using WebKit - this seems to + cause a link to QtGui from Qt4? (Thefore compile with -DENABLE_WEBKIT=OFF) 0.9.2 ----- diff --git a/INSTALL b/INSTALL index 2310f97dd..1bce1e2c1 100644 --- a/INSTALL +++ b/INSTALL @@ -7,8 +7,8 @@ With KDE Support 5. sudo make install -Qt-Only -======= +Qt4 +=== 1. mkdir build 2. cd build 3. cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_KDE=OFF @@ -16,6 +16,15 @@ Qt-Only 5. sudo make install +Qt5 +=== +1. mkdir build +2. cd build +3. cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_KDE=OFF -DENABLE_QT5=ON +4. make +5. sudo make install + + CMake Options ============= @@ -44,6 +53,10 @@ The following options may be passed to CMake: Link against KDE libraries, use KDE dialogs, etc. Default: ON + -DENABLE_QT5=ON + Build against Qt5, not Qt4 + Default: OFF + -DENABLE_PHONON=ON Enable support for playing back MPD HTTP streams via Phonon. Default: OFF diff --git a/README b/README index 6cb5b174a..7ada4a134 100644 --- a/README +++ b/README @@ -8,7 +8,7 @@ both the code itself, and the GUI are now *very* different to QtMPC. Dependencies ============ -Cantata requires the following Qt4 libraries: +Cantata requires the following Qt libraries: 1. QtCore 2. QtGui diff --git a/TODO b/TODO index ac67e5eba..320a7e2b6 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,13 @@ +- Qt5 port + - Crash if link to QtWebKit? + Looks like QtWebKit is sonehow pulling in QtGui from Qt4 + - QUrl.setEncodedUrl + covers.cpp + magnatuneservice.cpp + infopage.cpp + - Fix raising of mainwindow via dbus. + Qt5 no longer has QX11Info + - Albums - Coverflow view? diff --git a/dbus/notify.cpp b/dbus/notify.cpp index db5b29f4c..926db4a89 100644 --- a/dbus/notify.cpp +++ b/dbus/notify.cpp @@ -66,7 +66,7 @@ QDBusArgument& operator<< (QDBusArgument &arg, const QImage &image) int channels = i.isGrayscale() ? 1 : (i.hasAlphaChannel() ? 4 : 3); arg << i.depth() / channels; arg << channels; - arg << QByteArray(reinterpret_cast(i.bits()), i.numBytes()); + arg << QByteArray(reinterpret_cast(i.bits()), i.byteCount()); arg.endStructure(); return arg; } diff --git a/devices/mounter/CMakeLists.txt b/devices/mounter/CMakeLists.txt index d1b7b1a42..e9bfe697f 100644 --- a/devices/mounter/CMakeLists.txt +++ b/devices/mounter/CMakeLists.txt @@ -1,17 +1,26 @@ set( CANTATA_MOUNTER_SRCS main.cpp mounter.cpp ) set( CANTATA_MOUNTER_MOC_HDRS mounter.h ) -qt4_wrap_cpp( CANTATA_MOUNTER_MOC_SRCS ${CANTATA_MOUNTER_MOC_HDRS} ) -qt4_add_dbus_adaptor(CANTATA_MOUNTER_SRCS com.googlecode.cantata.mounter.xml mounter.h Mounter ) +if (ENABLE_QT5) + qt5_wrap_cpp( CANTATA_MOUNTER_MOC_SRCS ${CANTATA_MOUNTER_MOC_HDRS} ) + qt5_add_dbus_adaptor(CANTATA_MOUNTER_SRCS com.googlecode.cantata.mounter.xml mounter.h Mounter ) +else (ENABLE_QT5) + qt4_wrap_cpp( CANTATA_MOUNTER_MOC_SRCS ${CANTATA_MOUNTER_MOC_HDRS} ) + qt4_add_dbus_adaptor(CANTATA_MOUNTER_SRCS com.googlecode.cantata.mounter.xml mounter.h Mounter ) + add_definitions( -DQT_NO_STL -DQT_NO_CAST_TO_ASCII -Wall -Wextra ) +endif (ENABLE_QT5) add_executable( cantata-mounter ${CANTATA_MOUNTER_SRCS} ${CANTATA_MOUNTER_MOC_SRCS} ) install( TARGETS cantata-mounter RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) -add_definitions( -DQT_NO_STL -DQT_NO_CAST_TO_ASCII -Wall -Wextra ) configure_file(com.googlecode.cantata.mounter.service.cmake ${CMAKE_CURRENT_BINARY_DIR}/com.googlecode.cantata.mounter.service) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/com.googlecode.cantata.mounter.service DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dbus-1/system-services/ ) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/com.googlecode.cantata.mounter.conf DESTINATION /etc/dbus-1/system.d/ ) -target_link_libraries(cantata-mounter ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY}) -include_directories( ${QT_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}) +if (ENABLE_QT5) + target_link_libraries(cantata-mounter ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES}) +else (ENABLE_QT5) + target_link_libraries(cantata-mounter ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY}) +endif (ENABLE_QT5) +include_directories( ${QTINCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}) install(FILES ${_qmFile} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cantata/) diff --git a/devices/mounter/mounter.cpp b/devices/mounter/mounter.cpp index 9d7bee45f..67f8907d4 100644 --- a/devices/mounter/mounter.cpp +++ b/devices/mounter/mounter.cpp @@ -27,6 +27,9 @@ #include #include #include +#if QT_VERSION >= 0x050000 +#include +#endif #include #include #include @@ -84,9 +87,16 @@ void Mounter::mount(const QString &url, const QString &mountPoint, int uid, int QString password=u.password(); int port=u.port(); + #if QT_VERSION < 0x050000 if (u.hasQueryItem("domain")) { domain=u.queryItemValue("domain"); } + #else + QUrlQuery q(u); + if (q.hasQueryItem("domain")) { + domain=q.queryItemValue("domain"); + } + #endif QTemporaryFile *temp=0; diff --git a/devices/remotedevicepropertieswidget.cpp b/devices/remotedevicepropertieswidget.cpp index 96e561c87..c593cf17a 100644 --- a/devices/remotedevicepropertieswidget.cpp +++ b/devices/remotedevicepropertieswidget.cpp @@ -27,6 +27,9 @@ #include "localize.h" #include #include +#if QT_VERSION >= 0x050000 +#include +#endif #include "lineedit.h" #include "config.h" @@ -98,11 +101,20 @@ void RemoteDevicePropertiesWidget::update(const RemoteFsDevice::Details &d, bool smbHost->setText(d.url.host()); smbUser->setText(d.url.userName()); smbPassword->setText(d.url.password()); + #if QT_VERSION < 0x050000 if (d.url.hasQueryItem(RemoteFsDevice::constDomainQuery)) { smbDomain->setText(d.url.queryItemValue(RemoteFsDevice::constDomainQuery)); } else { smbDomain->setText(QString()); } + #else + QUrlQuery q(d.url); + if (q.hasQueryItem(RemoteFsDevice::constDomainQuery)) { + smbDomain->setText(q.queryItemValue(RemoteFsDevice::constDomainQuery)); + } else { + smbDomain->setText(QString()); + } + #endif break; } #endif @@ -190,7 +202,13 @@ RemoteFsDevice::Details RemoteDevicePropertiesWidget::details() det.url.setScheme(RemoteFsDevice::constSambaProtocol); det.url.setPassword(smbPassword->text().trimmed()); if (!smbDomain->text().trimmed().isEmpty()) { + #if QT_VERSION < 0x050000 det.url.addQueryItem(RemoteFsDevice::constDomainQuery, smbDomain->text().trimmed()); + #else + QUrlQuery q; + q.addQueryItem(RemoteFsDevice::constDomainQuery, smbDomain->text().trimmed()); + det.url.setQuery(q); + #endif } break; #endif diff --git a/dynamic/dynamic.cpp b/dynamic/dynamic.cpp index f842cbc13..1cfdd45e7 100644 --- a/dynamic/dynamic.cpp +++ b/dynamic/dynamic.cpp @@ -40,6 +40,10 @@ K_GLOBAL_STATIC(Dynamic, instance) #include #include #include +#include +#if QT_VERSION >= 0x050000 +#include +#endif #include static const QString constDir=QLatin1String("dynamic"); @@ -196,9 +200,17 @@ bool Dynamic::save(const Entry &e) return false; } + #if QT_VERSION < 0x050000 QUrl url(dynamicUrl+"/"+constSaveCmd); url.addQueryItem("name", e.name); url.addQueryItem(constStatusTime, QString::number(statusTime)); + #else + QUrl url(dynamicUrl+"/"+constSaveCmd); + QUrlQuery query; + query.addQueryItem("name", e.name); + query.addQueryItem(constStatusTime, QString::number(statusTime)); + url.setQuery(query); + #endif currentJob=NetworkAccessManager::self()->post(QNetworkRequest(url), string.toUtf8()); connect(currentJob, SIGNAL(finished()), this, SLOT(jobFinished())); @@ -649,8 +661,16 @@ void Dynamic::sendCommand(const QString &cmd, const QStringList &args) if (constDeleteCmd==cmd) { if (!args.isEmpty()) { + #if QT_VERSION < 0x050000 QUrl url(dynamicUrl+"/"+args.at(0)); url.addQueryItem(constStatusTime, QString::number(statusTime)); + #else + QUrl url(dynamicUrl+"/"+args.at(0)); + QUrlQuery query; + query.addQueryItem(constStatusTime, QString::number(statusTime)); + url.setQuery(query); + #endif + currentJob=NetworkAccessManager::self()->deleteResource(QNetworkRequest(url)); } else { currentCommand.clear(); @@ -658,12 +678,20 @@ void Dynamic::sendCommand(const QString &cmd, const QStringList &args) } } else { QUrl url(dynamicUrl+"/"+currentCommand); + #if QT_VERSION < 0x050000 + QUrl &query=url; + #else + QUrlQuery query; + #endif if (!args.isEmpty() && 0==args.size()%2) { for (int i=0; i= 0x050000 + url.setQuery(query); + #endif if (constSetActiveCmd==cmd || constControlCmd==cmd) { currentJob=NetworkAccessManager::self()->post(QNetworkRequest(url), QByteArray()); } else { diff --git a/gui/coverdialog.cpp b/gui/coverdialog.cpp index 1124665dd..f8b1e96f5 100644 --- a/gui/coverdialog.cpp +++ b/gui/coverdialog.cpp @@ -55,6 +55,10 @@ #endif #include #include +#if QT_VERSION >= 0x050000 +#include +#include +#endif #include #include #include @@ -664,26 +668,45 @@ void CoverDialog::sendQuery() cancelButton->setEnabled(true); currentQueryString=fixedQuery; - QUrl lastFm; - lastFm.setScheme("http"); - lastFm.setHost(constLastFmHost); - lastFm.setPath("/2.0/"); - lastFm.addQueryItem("api_key", Covers::constLastFmApiKey); - lastFm.addQueryItem("limit", QString::number(20)); - lastFm.addQueryItem("page", QString::number(page)); - lastFm.addQueryItem("album", fixedQuery); - lastFm.addQueryItem("method", "album.search"); - sendQueryRequest(lastFm); + #if QT_VERSION < 0x050000 + QUrl lastFmUrl; + QUrl &lastFmQuery=lastFmUrl; + #else + QUrl lastFmUrl; + QUrlQuery lastFmQuery; + #endif + lastFmUrl.setScheme("http"); + lastFmUrl.setHost(constLastFmHost); + lastFmUrl.setPath("/2.0/"); + lastFmQuery.addQueryItem("api_key", Covers::constLastFmApiKey); + lastFmQuery.addQueryItem("limit", QString::number(20)); + lastFmQuery.addQueryItem("page", QString::number(page)); + lastFmQuery.addQueryItem("album", fixedQuery); + lastFmQuery.addQueryItem("method", "album.search"); + #if QT_VERSION >= 0x050000 + lastFmUrl.setQuery(lastFmQuery); + #endif + sendQueryRequest(lastFmUrl); + + #if QT_VERSION < 0x050000 + QUrl googleUrl; + QUrl &googleQuery=googleUrl; + #else + QUrl googleUrl; + QUrlQuery googleQuery; + #endif + googleUrl.setScheme("http"); + googleUrl.setHost(constGoogleHost); + googleUrl.setPath("/images"); + googleQuery.addQueryItem("q", fixedQuery); + googleQuery.addQueryItem("gbv", QChar('1')); + googleQuery.addQueryItem("filter", QChar('1')); + googleQuery.addQueryItem("start", QString::number(20 * page)); + #if QT_VERSION >= 0x050000 + googleUrl.setQuery(googleQuery); + #endif + sendQueryRequest(googleUrl); - QUrl google; - google.setScheme("http"); - google.setHost(constGoogleHost); - google.setPath("/images"); - google.addQueryItem("q", fixedQuery); - google.addQueryItem("gbv", QChar('1')); - google.addQueryItem("filter", QChar('1')); - google.addQueryItem("start", QString::number(20 * page)); - sendQueryRequest(google); // QUrl yahoo; // yahoo.setScheme("http"); @@ -932,7 +955,12 @@ void CoverDialog::parseGoogleQueryResponse(const QString &resp) QString html = xml.replace(QLatin1String("&"), QLatin1String("&")); while (-1!=(pos=rx.indexIn(html, pos))) { + #if QT_VERSION < 0x050000 QUrl url("http://www.google.com"+rx.cap(1)); + #else + QUrl u("http://www.google.com"+rx.cap(1)); + QUrlQuery url(u); + #endif int width=url.queryItemValue("w").toInt(); int height=url.queryItemValue("h").toInt(); if (width>=100 && height>=100) { @@ -1141,16 +1169,25 @@ bool CoverDialog::saveCover(const QString &src, const QImage &img) } } +static bool hasMimeType(QDropEvent *event) +{ + #if QT_VERSION < 0x050000 + return event->provides("text/uri-list"); + #else + return event->mimeData()->formats().contains(QLatin1String("text/uri-list")); + #endif +} + void CoverDialog::dragEnterEvent(QDragEnterEvent *event) { - if(event->provides("text/uri-list")) { + if (hasMimeType(event)) { event->acceptProposedAction(); } } void CoverDialog::dropEvent(QDropEvent *event) { - if(event->provides("text/uri-list") && Qt::CopyAction==event->dropAction()) { + if (hasMimeType(event) && Qt::CopyAction==event->dropAction()) { event->acceptProposedAction(); QList urls(event->mimeData()->urls()); diff --git a/gui/covers.cpp b/gui/covers.cpp index d961e9bd2..e08d9645a 100644 --- a/gui/covers.cpp +++ b/gui/covers.cpp @@ -37,6 +37,9 @@ #include #include #include +#if QT_VERSION >= 0x050000 +#include +#endif #include #include #include @@ -440,7 +443,12 @@ Covers::Image Covers::getImage(const Song &song) bool haveAbsPath=song.file.startsWith('/'); if (song.isCantataStream()) { + #if QT_VERSION < 0x050000 QUrl u(songFile); + #else + QUrl url(songFile); + QUrlQuery u(url); + #endif songFile=u.hasQueryItem("file") ? u.queryItemValue("file") : QString(); } if (!songFile.isEmpty() && !song.file.startsWith(("http:/")) && @@ -693,7 +701,11 @@ void Covers::downloadViaHttp(Job &job, JobType type) coverName=constFileName; } coverName+=constExtensions.at(JobHttpJpg==type ? 0 : 1); + #if QT_VERSION < 0x050000 u.setEncodedUrl(MPDConnection::self()->getDetails().dir.toLatin1()+QUrl::toPercentEncoding(Utils::getDir(job.song.file), "/")+coverName.toLatin1()); + #else + u=QUrl(MPDConnection::self()->getDetails().dir.toLatin1()+QUrl::toPercentEncoding(Utils::getDir(job.song.file), "/")+coverName.toLatin1()); + #endif job.type=type; QNetworkReply *j=NetworkAccessManager::self()->get(QNetworkRequest(u)); @@ -827,7 +839,11 @@ void Covers::lastFmCallFinished() if (!url.isEmpty()) { QUrl u; + #if QT_VERSION < 0x050000 u.setEncodedUrl(url.toLatin1()); + #else + u=QUrl(url.toLatin1()); + #endif QNetworkReply *j=NetworkAccessManager::self()->get(QNetworkRequest(u)); connect(j, SIGNAL(finished()), this, SLOT(jobFinished())); jobs.insert(j, job); diff --git a/gui/infopage.cpp b/gui/infopage.cpp index 45f2a76b3..656b7946d 100644 --- a/gui/infopage.cpp +++ b/gui/infopage.cpp @@ -34,6 +34,9 @@ #include #include #include +#if QT_VERSION >= 0x050000 +#include +#endif #ifdef ENABLE_KDE_SUPPORT #include #include @@ -185,10 +188,19 @@ void InfoPage::googleAnswer(const QString &ans) if (!answer.contains("m.wikipedia.org")) { answer.replace("wikipedia.org", "m.wikipedia.org"); } + #if QT_VERSION < 0x050000 wikiInfo.setEncodedUrl(answer/*.replace("/wiki/", "/wiki/Special:Export/")*/.toUtf8()); wikiInfo.addQueryItem("action", "view"); wikiInfo.addQueryItem("useskin", "monobook"); wikiInfo.addQueryItem("useformat", "mobile"); + #else + wikiInfo=QUrl(answer/*.replace("/wiki/", "/wiki/Special:Export/")*/.toUtf8()); + QUrlQuery query; + query.addQueryItem("action", "view"); + query.addQueryItem("useskin", "monobook"); + query.addQueryItem("useformat", "mobile"); + wikiInfo.setQuery(query); + #endif // view->settings()->resetFontSize(QWebSettings::MinimumFontSize); // view->settings()->resetFontSize(QWebSettings::MinimumLogicalFontSize); @@ -288,7 +300,11 @@ void InfoPage::get(const QUrl &url) // lie to prevent google etc. from believing we'd be some automated tool, abusing their ... errr ;-P request.setRawHeader("User-Agent", "Mozilla/5.0 (X11; Linux i686; rv:6.0) Gecko/20100101 Firefox/6.0"); if (!lang.isEmpty()) { + #if QT_VERSION < 0x050000 request.setRawHeader("Accept-Language", lang.toAscii()); + #else + request.setRawHeader("Accept-Language", lang.toLatin1()); + #endif } QNetworkReply *reply = view->page()->networkAccessManager()->get(request); diff --git a/gui/main.cpp b/gui/main.cpp index 7de90e9ac..ed97cfeec 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -77,7 +77,9 @@ static void loadTranslation(const QString &prefix, const QString &path, const QS delete t; } + #if QT_VERSION < 0x050000 QTextCodec::setCodecForTr(QTextCodec::codecForLocale()); + #endif } #endif diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 9e8b3bd79..387ffd8bf 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -2942,9 +2942,11 @@ QString MainWindow::coverFile() const } #ifndef Q_OS_WIN +#if QT_VERSION < 0x050000 #include #include #endif +#endif void MainWindow::hideWindow() { @@ -2962,6 +2964,7 @@ void MainWindow::restoreWindow() showNormal(); activateWindow(); #ifndef Q_OS_WIN + #if QT_VERSION < 0x050000 // This section seems to be required for compiz... // ...without this, when 'qdbus com.googlecode.cantata /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Raise' is used // the Unity launcher item is highlighted, but the window is not shown! @@ -2983,6 +2986,7 @@ void MainWindow::restoreWindow() XSendEvent(QX11Info::display(), QX11Info::appRootWindow(info.screen()), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); #endif + #endif if (wasHidden && !lastPos.isNull()) { move(lastPos); } diff --git a/http/httpserver.cpp b/http/httpserver.cpp index c30d3a831..94d990ce1 100644 --- a/http/httpserver.cpp +++ b/http/httpserver.cpp @@ -27,6 +27,9 @@ #include "tags.h" #include "settings.h" #include +#if QT_VERSION >= 0x050000 +#include +#endif #include #ifdef ENABLE_KDE_SUPPORT #include @@ -107,39 +110,48 @@ QByteArray HttpServer::encodeUrl(const Song &s) const if (!isAlive()) { return QByteArray(); } + #if QT_VERSION < 0x050000 QUrl url; + QUrl &query=url; + #else + QUrl url; + QUrlQuery query; + #endif url.setScheme("http"); url.setHost(socket->address()); url.setPort(socket->serverPort()); url.setPath(s.file); if (!s.album.isEmpty()) { - url.addQueryItem("album", s.album); + query.addQueryItem("album", s.album); } if (!s.artist.isEmpty()) { - url.addQueryItem("artist", s.artist); + query.addQueryItem("artist", s.artist); } if (!s.albumartist.isEmpty()) { - url.addQueryItem("albumartist", s.albumartist); + query.addQueryItem("albumartist", s.albumartist); } if (!s.title.isEmpty()) { - url.addQueryItem("title", s.title); + query.addQueryItem("title", s.title); } if (!s.genre.isEmpty()) { - url.addQueryItem("genre", s.genre); + query.addQueryItem("genre", s.genre); } if (s.disc) { - url.addQueryItem("disc", QString::number(s.disc)); + query.addQueryItem("disc", QString::number(s.disc)); } if (s.year) { - url.addQueryItem("year", QString::number(s.year)); + query.addQueryItem("year", QString::number(s.year)); } if (s.time) { - url.addQueryItem("time", QString::number(s.time)); + query.addQueryItem("time", QString::number(s.time)); } if (s.track) { - url.addQueryItem("track", QString::number(s.track)); + query.addQueryItem("track", QString::number(s.track)); } - url.addQueryItem("cantata", "song"); + query.addQueryItem("cantata", "song"); + #if QT_VERSION >= 0x050000 + url.setQuery(query); + #endif return url.toEncoded(); } @@ -153,35 +165,41 @@ QByteArray HttpServer::encodeUrl(const QString &file) const Song HttpServer::decodeUrl(const QString &url) const { Song s; + #if QT_VERSION < 0x050000 QUrl u(url); + QUrl &q=u; + #else + QUrl u(url); + QUrlQuery q(u); + #endif - if (u.hasQueryItem("cantata") && u.queryItemValue("cantata")=="song") { - if (u.hasQueryItem("album")) { - s.album=u.queryItemValue("album"); + if (q.hasQueryItem("cantata") && q.queryItemValue("cantata")=="song") { + if (q.hasQueryItem("album")) { + s.album=q.queryItemValue("album"); } - if (u.hasQueryItem("artist")) { - s.artist=u.queryItemValue("artist"); + if (q.hasQueryItem("artist")) { + s.artist=q.queryItemValue("artist"); } - if (u.hasQueryItem("albumartist")) { - s.albumartist=u.queryItemValue("albumartist"); + if (q.hasQueryItem("albumartist")) { + s.albumartist=q.queryItemValue("albumartist"); } - if (u.hasQueryItem("title")) { - s.title=u.queryItemValue("title"); + if (q.hasQueryItem("title")) { + s.title=q.queryItemValue("title"); } - if (u.hasQueryItem("genre")) { - s.genre=u.queryItemValue("genre"); + if (q.hasQueryItem("genre")) { + s.genre=q.queryItemValue("genre"); } - if (u.hasQueryItem("disc")) { - s.disc=u.queryItemValue("disc").toInt(); + if (q.hasQueryItem("disc")) { + s.disc=q.queryItemValue("disc").toInt(); } - if (u.hasQueryItem("year")) { - s.year=u.queryItemValue("year").toInt(); + if (q.hasQueryItem("year")) { + s.year=q.queryItemValue("year").toInt(); } - if (u.hasQueryItem("time")) { - s.time=u.queryItemValue("time").toInt(); + if (q.hasQueryItem("time")) { + s.time=q.queryItemValue("time").toInt(); } - if (u.hasQueryItem("track")) { - s.track=u.queryItemValue("track").toInt(); + if (q.hasQueryItem("track")) { + s.track=q.queryItemValue("track").toInt(); } s.file=u.path(); } diff --git a/http/httpsocket.cpp b/http/httpsocket.cpp index e118a516d..3aa6f86d8 100644 --- a/http/httpsocket.cpp +++ b/http/httpsocket.cpp @@ -29,6 +29,9 @@ #include #include #include +#if QT_VERSION >= 0x050000 +#include +#endif #ifdef ENABLE_KDE_SUPPORT #include #endif @@ -226,10 +229,16 @@ void HttpSocket::readClient() if (socket->canReadLine()) { QList tokens = split(socket->readLine()); // QRegExp("[ \r\n][ \r\n]*")); if (tokens.length()>=2 && "GET"==tokens[0]) { + #if QT_VERSION < 0x050000 QUrl url(QUrl::fromEncoded(tokens[1])); + QUrl &q=url; + #else + QUrl url(QUrl::fromEncoded(tokens[1])); + QUrlQuery q(url); + #endif bool ok=false; - if (url.hasQueryItem("cantata")) { + if (q.hasQueryItem("cantata")) { QFile f(url.path()); if (f.open(QIODevice::ReadOnly)) { diff --git a/lyrics/lyricspage.cpp b/lyrics/lyricspage.cpp index 8e2829d9f..82e465fc0 100644 --- a/lyrics/lyricspage.cpp +++ b/lyrics/lyricspage.cpp @@ -47,6 +47,9 @@ #include #include #include +#if QT_VERSION >= 0x050000 +#include +#endif const QLatin1String LyricsPage::constLyricsDir("lyrics/"); const QLatin1String LyricsPage::constExtension(".lyrics"); @@ -282,7 +285,12 @@ void LyricsPage::update(const Song &s, bool force) QString songFile=song.file; if (song.isCantataStream()) { + #if QT_VERSION < 0x050000 QUrl u(songFile); + #else + QUrl qu(songFile); + QUrlQuery u(qu); + #endif songFile=u.hasQueryItem("file") ? u.queryItemValue("file") : QString(); } diff --git a/lyrics/ultimatelyricsprovider.cpp b/lyrics/ultimatelyricsprovider.cpp index 5516b8e17..de3864139 100644 --- a/lyrics/ultimatelyricsprovider.cpp +++ b/lyrics/ultimatelyricsprovider.cpp @@ -41,7 +41,11 @@ UltimateLyricsProvider::UltimateLyricsProvider() void UltimateLyricsProvider::FetchInfo(int id, const Song& metadata) { // Get the text codec + #if QT_VERSION < 0x050000 const QTextCodec* codec = QTextCodec::codecForName(charset_.toAscii().constData()); + #else + const QTextCodec* codec = QTextCodec::codecForName(charset_.toLatin1().constData()); + #endif if (!codec) { //qWarning() << "Invalid codec" << charset_; //emit Finished(id); @@ -117,7 +121,11 @@ void UltimateLyricsProvider::LyricsFetched() { return; } + #if QT_VERSION < 0x050000 const QTextCodec* codec = QTextCodec::codecForName(charset_.toAscii().constData()); + #else + const QTextCodec* codec = QTextCodec::codecForName(charset_.toLatin1().constData()); + #endif const QString original_content = codec->toUnicode(reply->readAll()); // Check for invalid indicators diff --git a/online/magnatuneservice.cpp b/online/magnatuneservice.cpp index fabf70bc4..69863026b 100644 --- a/online/magnatuneservice.cpp +++ b/online/magnatuneservice.cpp @@ -131,7 +131,11 @@ Song MagnatuneService::fixPath(const Song &orig) const Song s=orig; QUrl url; + #if QT_VERSION < 0x050000 url.setEncodedUrl(orig.file.toLocal8Bit()); + #else + url=QUrl(orig.file.toLocal8Bit()); + #endif url.setScheme("http"); url.setHost(MB_Streaming==membership ? constStreamingHostname : constDownloadHostname); url.setUserName(username); diff --git a/qtiocompressor/CMakeLists.txt b/qtiocompressor/CMakeLists.txt index f339daba9..5c6faff3f 100644 --- a/qtiocompressor/CMakeLists.txt +++ b/qtiocompressor/CMakeLists.txt @@ -8,7 +8,13 @@ set(IOCOMPRESSOR-MOC-HEADERS qtiocompressor.h ) -QT4_WRAP_CPP(IOCOMPRESSOR-SOURCES-MOC ${IOCOMPRESSOR-MOC-HEADERS}) +if (ENABLE_QT5) + QT5_WRAP_CPP(IOCOMPRESSOR-SOURCES-MOC ${IOCOMPRESSOR-MOC-HEADERS}) +else (ENABLE_QT5) + QT4_WRAP_CPP(IOCOMPRESSOR-SOURCES-MOC ${IOCOMPRESSOR-MOC-HEADERS}) +endif (ENABLE_QT5) + +include_directories(${QTINCLUDES}) ADD_LIBRARY(qtiocompressor STATIC ${IOCOMPRESSOR-SOURCES} diff --git a/replaygain/rgdialog.cpp b/replaygain/rgdialog.cpp index 309a2fc7e..41a307a95 100644 --- a/replaygain/rgdialog.cpp +++ b/replaygain/rgdialog.cpp @@ -80,6 +80,28 @@ int RgDialog::instanceCount() return iCount; } +#if QT_VERSION < 0x050000 +static inline void setResizeMode(QHeaderView *hdr, int idx, QHeaderView::ResizeMode mode) +{ + hdr->setResizeMode(idx, mode); +} + +static inline void setResizeMode(QHeaderView *hdr, QHeaderView::ResizeMode mode) +{ + hdr->setResizeMode(mode); +} +#else +static inline void setResizeMode(QHeaderView *hdr, int idx, QHeaderView::ResizeMode mode) +{ + hdr->setSectionResizeMode(idx, mode); +} + +static inline void setResizeMode(QHeaderView *hdr, QHeaderView::ResizeMode mode) +{ + hdr->setSectionResizeMode(mode); +} +#endif + RgDialog::RgDialog(QWidget *parent) : Dialog(parent) , state(State_Idle) @@ -109,13 +131,13 @@ RgDialog::RgDialog(QWidget *parent) hdr->setText(COL_TRACKPEAK, i18n("Track Peak")); QHeaderView *hv=view->header(); - hv->setResizeMode(COL_ARTIST, QHeaderView::ResizeToContents); - hv->setResizeMode(COL_ALBUM, QHeaderView::ResizeToContents); - hv->setResizeMode(COL_TITLE, QHeaderView::Stretch); - hv->setResizeMode(COL_ALBUMGAIN, QHeaderView::Fixed); - hv->setResizeMode(COL_TRACKGAIN, QHeaderView::Fixed); - hv->setResizeMode(COL_ALBUMPEAK, QHeaderView::Fixed); - hv->setResizeMode(COL_TRACKPEAK, QHeaderView::Fixed); + setResizeMode(hv, COL_ARTIST, QHeaderView::ResizeToContents); + setResizeMode(hv, COL_ALBUM, QHeaderView::ResizeToContents); + setResizeMode(hv, COL_TITLE, QHeaderView::Stretch); + setResizeMode(hv, COL_ALBUMGAIN, QHeaderView::Fixed); + setResizeMode(hv, COL_TRACKGAIN, QHeaderView::Fixed); + setResizeMode(hv, COL_ALBUMPEAK, QHeaderView::Fixed); + setResizeMode(hv, COL_TRACKPEAK, QHeaderView::Fixed); hv->setStretchLastSection(false); layout->addWidget(view); diff --git a/solid-lite/CMakeLists.txt b/solid-lite/CMakeLists.txt index 2d0ab737b..1b24cc7de 100644 --- a/solid-lite/CMakeLists.txt +++ b/solid-lite/CMakeLists.txt @@ -2,7 +2,7 @@ INCLUDE(MacroOptionalFindPackage) INCLUDE(MacroLogFeature) add_subdirectory( ifaces ) -include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${QT_INCLUDES}) +include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${QTINCLUDES}) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/backends/hal @@ -233,7 +233,11 @@ if(APPLE) set(solidlite_OPTIONAL_LIBS ${IOKIT_LIBRARY}) endif(APPLE) -QT4_WRAP_CPP(solidlite_LIB_MOC_SRCS ${solidlite_LIB_MOC_HDRS} ) +if (ENABLE_QT5) + QT5_WRAP_CPP(solidlite_LIB_MOC_SRCS ${solidlite_LIB_MOC_HDRS} ) +else (ENABLE_QT5) + QT4_WRAP_CPP(solidlite_LIB_MOC_SRCS ${solidlite_LIB_MOC_HDRS} ) +endif (ENABLE_QT5) add_library(solidlite ${solidlite_LIB_SRCS} ${solidlite_LIB_MOC_SRCS}) # set_target_properties(solidlite PROPERTIES AUTOMOC TRUE) diff --git a/solid-lite/backends/udev/udevmanager.cpp b/solid-lite/backends/udev/udevmanager.cpp index d28b63d4e..6713c97be 100644 --- a/solid-lite/backends/udev/udevmanager.cpp +++ b/solid-lite/backends/udev/udevmanager.cpp @@ -90,7 +90,11 @@ bool UDevManager::Private::isOfInterest(const UdevQt::Device &device) QString path = device.deviceProperty("DEVPATH").toString(); int lastSlash = path.length() - path.lastIndexOf(QLatin1String("/")) -1; + #if QT_VERSION < 0x050000 QByteArray lastElement = path.right(lastSlash).toAscii(); + #else + QByteArray lastElement = path.right(lastSlash).toLatin1(); + #endif if (lastElement.startsWith("tty") && !path.startsWith("/devices/virtual")) { return true; diff --git a/solid-lite/device_p.h b/solid-lite/device_p.h index d2a42498e..a59b48c90 100644 --- a/solid-lite/device_p.h +++ b/solid-lite/device_p.h @@ -23,17 +23,24 @@ #include #include +#if QT_VERSION < 0x050000 #include +#else +#include +#include "ifaces/device.h" +#endif #include #include "deviceinterface.h" namespace Solid { + #if QT_VERSION < 0x050000 namespace Ifaces { class Device; } + #endif class DevicePrivate : public QObject, public QSharedData { @@ -55,7 +62,11 @@ namespace Solid private: QString m_udi; + #if QT_VERSION < 0x050000 QWeakPointer m_backendObject; + #else + QPointer m_backendObject; + #endif QMap m_ifaces; }; } diff --git a/solid-lite/deviceinterface.h b/solid-lite/deviceinterface.h index 4bf143fc9..9e7d0cd3a 100644 --- a/solid-lite/deviceinterface.h +++ b/solid-lite/deviceinterface.h @@ -22,7 +22,9 @@ #define SOLID_DEVICEINTERFACE_H #include +#if QT_VERSION < 0x050000 #include +#endif #include diff --git a/solid-lite/deviceinterface_p.h b/solid-lite/deviceinterface_p.h index 6163f3128..deeb69f7f 100644 --- a/solid-lite/deviceinterface_p.h +++ b/solid-lite/deviceinterface_p.h @@ -21,7 +21,11 @@ #ifndef SOLID_DEVICEINTERFACE_P_H #define SOLID_DEVICEINTERFACE_P_H +#if QT_VERSION < 0x050000 #include +#else +#include +#endif namespace Solid { @@ -37,7 +41,11 @@ namespace Solid void setDevicePrivate(DevicePrivate *devicePrivate); private: + #if QT_VERSION < 0x050000 QWeakPointer m_backendObject; + #else + QPointer m_backendObject; + #endif DevicePrivate* m_devicePrivate; }; } diff --git a/solid-lite/devicemanager.cpp b/solid-lite/devicemanager.cpp index a6989743a..31143f261 100644 --- a/solid-lite/devicemanager.cpp +++ b/solid-lite/devicemanager.cpp @@ -32,6 +32,12 @@ SOLID_GLOBAL_STATIC(Solid::DeviceManagerStorage, globalDeviceStorage) +#if QT_VERSION < 0x050000 +#define QtPointer QWeakPointer +#else +#define QtPointer QPointer +#endif + Solid::DeviceManagerPrivate::DeviceManagerPrivate() : m_nullDevice(new DevicePrivate(QString())) { @@ -53,7 +59,7 @@ Solid::DeviceManagerPrivate::~DeviceManagerPrivate() disconnect(backend, 0, this, 0); } - foreach (QWeakPointer dev, m_devicesMap) { + foreach (QtPointer dev, m_devicesMap) { if (!dev.data()->ref.deref()) { delete dev.data(); } @@ -228,7 +234,7 @@ Solid::DevicePrivate *Solid::DeviceManagerPrivate::findRegisteredDevice(const QS DevicePrivate *devData = new DevicePrivate(udi); devData->setBackendObject(iface); - QWeakPointer ptr(devData); + QtPointer ptr(devData); m_devicesMap[udi] = ptr; m_reverseMap[devData] = udi; diff --git a/solid-lite/devicemanager_p.h b/solid-lite/devicemanager_p.h index 6e7dcde7d..00e083efd 100644 --- a/solid-lite/devicemanager_p.h +++ b/solid-lite/devicemanager_p.h @@ -26,7 +26,11 @@ #include "devicenotifier.h" #include +#if QT_VERSION < 0x050000 #include +#else +#include +#endif #include #include @@ -57,7 +61,11 @@ namespace Solid Ifaces::Device *createBackendObject(const QString &udi); QExplicitlySharedDataPointer m_nullDevice; + #if QT_VERSION < 0x050000 QMap > m_devicesMap; + #else + QMap > m_devicesMap; + #endif QMap m_reverseMap; }; diff --git a/solid-lite/ifaces/deviceinterface.h b/solid-lite/ifaces/deviceinterface.h index f5b09c883..0a7867c9a 100644 --- a/solid-lite/ifaces/deviceinterface.h +++ b/solid-lite/ifaces/deviceinterface.h @@ -22,7 +22,9 @@ #define SOLID_IFACES_DEVICEINTERFACE_H #include +#if QT_VERSION < 0x050000 #include +#endif namespace Solid { diff --git a/solid-lite/ifaces/genericinterface.h b/solid-lite/ifaces/genericinterface.h index 00274b3ac..a250d4717 100644 --- a/solid-lite/ifaces/genericinterface.h +++ b/solid-lite/ifaces/genericinterface.h @@ -22,7 +22,9 @@ #define SOLID_IFACES_GENERICINTERFACE_H #include +#if QT_VERSION < 0x050000 #include +#endif #include #include diff --git a/solid-lite/predicateparse.cpp b/solid-lite/predicateparse.cpp index 7447813a7..d0fa963ee 100644 --- a/solid-lite/predicateparse.cpp +++ b/solid-lite/predicateparse.cpp @@ -57,7 +57,11 @@ Solid::Predicate Solid::Predicate::fromString(const QString &predicate) { Solid::PredicateParse::ParsingData *data = new Solid::PredicateParse::ParsingData(); s_parsingData->setLocalData(data); + #if QT_VERSION < 0x050000 data->buffer = predicate.toAscii(); + #else + data->buffer = predicate.toLatin1(); + #endif PredicateParse_mainParse(data->buffer.constData()); Predicate result; if (data->result) diff --git a/solid-lite/soliddefs_p.h b/solid-lite/soliddefs_p.h index 51d28e089..3f1071eef 100644 --- a/solid-lite/soliddefs_p.h +++ b/solid-lite/soliddefs_p.h @@ -76,6 +76,7 @@ namespace Solid #define SOLID_GLOBAL_STATIC(TYPE, NAME) SOLID_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ()) +#if QT_VERSION < 0x050000 #define SOLID_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \ static QBasicAtomicPointer _solid_static_##NAME = Q_BASIC_ATOMIC_INITIALIZER(0);\ static bool _solid_static_##NAME##_destroyed; \ @@ -119,4 +120,49 @@ static struct SOLID_GLOBAL_STATIC_STRUCT_NAME(NAME) \ } \ } NAME; +#else +#define SOLID_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \ +static QBasicAtomicPointer _solid_static_##NAME = Q_BASIC_ATOMIC_INITIALIZER(0);\ +static bool _solid_static_##NAME##_destroyed; \ +static struct SOLID_GLOBAL_STATIC_STRUCT_NAME(NAME) \ +{ \ + bool isDestroyed() \ + { \ + return _solid_static_##NAME##_destroyed; \ + } \ + inline operator TYPE*() \ + { \ + return operator->(); \ + } \ + inline TYPE *operator->() \ + { \ + if (!_solid_static_##NAME.load()) { \ + if (isDestroyed()) { \ + qFatal("Fatal Error: Accessed global static '%s *%s()' after destruction. " \ + "Defined at %s:%d", #TYPE, #NAME, __FILE__, __LINE__); \ + } \ + TYPE *x = new TYPE ARGS; \ + if (!_solid_static_##NAME.testAndSetOrdered(0, x) \ + && _solid_static_##NAME.load() != x ) { \ + delete x; \ + } else { \ + static Solid::CleanUpGlobalStatic cleanUpObject = { destroy }; \ + } \ + } \ + return _solid_static_##NAME.load(); \ + } \ + inline TYPE &operator*() \ + { \ + return *operator->(); \ + } \ + static void destroy() \ + { \ + _solid_static_##NAME##_destroyed = true; \ + TYPE *x = _solid_static_##NAME.load(); \ + _solid_static_##NAME.store(0); \ + delete x; \ + } \ +} NAME; +#endif + #endif diff --git a/support/CMakeLists.txt b/support/CMakeLists.txt index 7204fa07b..88f73dfcc 100644 --- a/support/CMakeLists.txt +++ b/support/CMakeLists.txt @@ -35,10 +35,18 @@ else (ENABLE_KDE_SUPPORT) SET( SUPPORT_MOC_HDRS ${SUPPORT_MOC_HDRS} pathrequester.h lineedit.h kmessagewidget.h urllabel.h dialog.h shortcutsmodel.h shortcutssettingspage.h keysequencewidget.h spinner.h ) SET( SUPPORT_UIS shortcutssettingspage.ui ) - QT4_WRAP_UI( SUPPORT_UI_HDRS ${SUPPORT_UIS} ) + if (ENABLE_QT5) + QT5_WRAP_UI( SUPPORT_UI_HDRS ${SUPPORT_UIS} ) + else (ENABLE_QT5) + QT4_WRAP_UI( SUPPORT_UI_HDRS ${SUPPORT_UIS} ) + endif (ENABLE_QT5) endif (ENABLE_KDE_SUPPORT) -QT4_WRAP_CPP( SUPPORT_MOC_SRCS ${SUPPORT_MOC_HDRS} ) +if (ENABLE_QT5) + QT5_WRAP_CPP( SUPPORT_MOC_SRCS ${SUPPORT_MOC_HDRS} ) +else (ENABLE_QT5) + QT4_WRAP_CPP( SUPPORT_MOC_SRCS ${SUPPORT_MOC_HDRS} ) +endif (ENABLE_QT5) -include_directories( ${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ) +include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${QTINCLUDES} ) add_library( support STATIC ${SUPPORT_MOC_SRCS} ${SUPPORT_SRCS} ${SUPPORT_UI_HDRS} ) diff --git a/support/actioncollection.cpp b/support/actioncollection.cpp index da0960548..1cc4c64c4 100644 --- a/support/actioncollection.cpp +++ b/support/actioncollection.cpp @@ -235,6 +235,7 @@ void ActionCollection::actionDestroyed(QObject *obj) { } void ActionCollection::connectNotify(const char *signal) { + #if QT_VERSION < 0x050000 if(_connectHovered && _connectTriggered) return; @@ -253,8 +254,35 @@ void ActionCollection::connectNotify(const char *signal) { } QObject::connectNotify(signal); + #else + Q_UNUSED(signal) + #endif } +#if QT_VERSION >= 0x050000 +#include +void ActionCollection::connectNotify(const QMetaMethod &signal) { + if(_connectHovered && _connectTriggered) + return; + + if(QMetaObject::normalizedSignature(SIGNAL(actionHovered(QAction*))) == signal.methodSignature()) { + if(!_connectHovered) { + _connectHovered = true; + foreach (QAction* action, actions()) + connect(action, SIGNAL(hovered()), SLOT(slotActionHovered())); + } + } else if(QMetaObject::normalizedSignature(SIGNAL(actionTriggered(QAction*))) == signal.methodSignature()) { + if(!_connectTriggered) { + _connectTriggered = true; + foreach (QAction* action, actions()) + connect(action, SIGNAL(triggered(bool)), SLOT(slotActionTriggered())); + } + } + + QObject::connectNotify(signal); +} +#endif + void ActionCollection::associateWidget(QWidget *widget) const { foreach(QAction *action, actions()) { if(!widget->actions().contains(action)) diff --git a/support/actioncollection.h b/support/actioncollection.h index 9868f1bb5..5d9f25d68 100644 --- a/support/actioncollection.h +++ b/support/actioncollection.h @@ -116,6 +116,11 @@ class ActionCollection : public QObject { virtual void connectNotify(const char *signal); virtual void slotActionTriggered(); + #if QT_VERSION >= 0x050000 + protected: + virtual void connectNotify(const QMetaMethod &signal); + #endif + private slots: void slotActionHovered(); void actionDestroyed(QObject *); diff --git a/support/fancytabwidget.cpp b/support/fancytabwidget.cpp index 8f1c707c1..a78a9e19e 100644 --- a/support/fancytabwidget.cpp +++ b/support/fancytabwidget.cpp @@ -37,21 +37,16 @@ #include "localize.h" #include "icon.h" #include "gtkstyle.h" -// #include "stylehelper.h" - -// #include #include #include #include #include #include #include -#include -#include +#include #include #include #include -#include #include #include #include @@ -320,7 +315,6 @@ FancyTabBar::FancyTabBar(QWidget *parent, bool hasBorder, bool text, int iSize, , m_pos(pos) , m_iconSize(iSize) { -// setStyle(new QWindowsStyle); setAttribute(Qt::WA_Hover, true); setFocusPolicy(Qt::NoFocus); setMouseTracking(true); // Needed for hover events diff --git a/support/gtkstyle.cpp b/support/gtkstyle.cpp index b1e03f559..68a1700b8 100644 --- a/support/gtkstyle.cpp +++ b/support/gtkstyle.cpp @@ -22,17 +22,21 @@ */ #include "gtkstyle.h" -#include "windowmanager.h" #include "config.h" #include #include #include #include -#include #include #include #include #include +#if !defined Q_OS_WIN +#include "windowmanager.h" +#if QT_VERSION < 0x050000 +#include +#endif +#endif static bool usingGtkStyle=false; static bool useFullGtkStyle=false; @@ -147,10 +151,12 @@ QString GtkStyle::themeName() } } + #if QT_VERSION < 0x050000 // Fall back to gconf if (name.isEmpty()) { name = QGtkStyle::getGConfString(QLatin1String("/desktop/gnome/interface/gtk_theme")); } + #endif } #endif return name; diff --git a/support/gtkstyle.h b/support/gtkstyle.h index 1ecd8696b..2a9130978 100644 --- a/support/gtkstyle.h +++ b/support/gtkstyle.h @@ -24,7 +24,7 @@ #ifndef GTKSTYLE_H #define GTKSTYLE_H -class QStyleOptionViewItemV4; +#include class QPainter; class QWidget; diff --git a/support/windowmanager.h b/support/windowmanager.h index 1179baca8..ce92416c6 100644 --- a/support/windowmanager.h +++ b/support/windowmanager.h @@ -44,7 +44,13 @@ #include #include #include +#if QT_VERSION < 0x050000 #include +#define WmPointer QWeakPointer +#else +#include +#define WmPointer QPointer +#endif #include class WindowManager: public QObject @@ -52,7 +58,7 @@ class WindowManager: public QObject Q_OBJECT #if QT_VERSION < 0x040600 - class Pointer : public QObject + class WmPointer : public QObject { public: Pointer(QWidget *w=0L) : widget_(w) {} @@ -156,9 +162,9 @@ private: //! target being dragged /*! QWeakPointer is used in case the target gets deleted while drag is in progress */ #if QT_VERSION < 0x040600 - Pointer _target; + WmPointer _target; #else - QWeakPointer _target; + WmPointer _target; #endif //! true if drag is about to start diff --git a/tags/tags.cpp b/tags/tags.cpp index bb68c8f95..9ef873b9a 100644 --- a/tags/tags.cpp +++ b/tags/tags.cpp @@ -583,7 +583,11 @@ static bool writeVorbisCommentTags(TagLib::Ogg::XiphComment *tag, const Song &fr } if (!img.isEmpty()) { + #if QT_VERSION < 0x050000 tag->addField("COVERART", qString2TString(QString::fromAscii(img.toBase64()))); + #else + tag->addField("COVERART", qString2TString(QString::fromLatin1(img.toBase64()))); + #endif changed=true; } return changed; diff --git a/widgets/playqueueview.cpp b/widgets/playqueueview.cpp index 5bf9bb144..350629d74 100644 --- a/widgets/playqueueview.cpp +++ b/widgets/playqueueview.cpp @@ -55,6 +55,28 @@ PlayQueueTreeView::~PlayQueueTreeView() { } +#if QT_VERSION < 0x050000 +static inline void setResizeMode(QHeaderView *hdr, int idx, QHeaderView::ResizeMode mode) +{ + hdr->setResizeMode(idx, mode); +} + +static inline void setResizeMode(QHeaderView *hdr, QHeaderView::ResizeMode mode) +{ + hdr->setResizeMode(mode); +} +#else +static inline void setResizeMode(QHeaderView *hdr, int idx, QHeaderView::ResizeMode mode) +{ + hdr->setSectionResizeMode(idx, mode); +} + +static inline void setResizeMode(QHeaderView *hdr, QHeaderView::ResizeMode mode) +{ + hdr->setSectionResizeMode(mode); +} +#endif + void PlayQueueTreeView::initHeader() { if (!model()) { @@ -64,20 +86,20 @@ void PlayQueueTreeView::initHeader() QFontMetrics fm(font()); QHeaderView *hdr=header(); if (!menu) { - hdr->setResizeMode(QHeaderView::Interactive); + setResizeMode(hdr, QHeaderView::Interactive); hdr->setContextMenuPolicy(Qt::CustomContextMenu); hdr->resizeSection(PlayQueueModel::COL_STATUS, 20); hdr->resizeSection(PlayQueueModel::COL_TRACK, fm.width("999")); hdr->resizeSection(PlayQueueModel::COL_YEAR, fm.width("99999")); - hdr->setResizeMode(PlayQueueModel::COL_STATUS, QHeaderView::Fixed); - hdr->setResizeMode(PlayQueueModel::COL_TITLE, QHeaderView::Interactive); - hdr->setResizeMode(PlayQueueModel::COL_ARTIST, QHeaderView::Interactive); - hdr->setResizeMode(PlayQueueModel::COL_ALBUM, QHeaderView::Stretch); - hdr->setResizeMode(PlayQueueModel::COL_TRACK, QHeaderView::Fixed); - hdr->setResizeMode(PlayQueueModel::COL_LENGTH, QHeaderView::ResizeToContents); - hdr->setResizeMode(PlayQueueModel::COL_DISC, QHeaderView::ResizeToContents); - hdr->setResizeMode(PlayQueueModel::COL_PRIO, QHeaderView::ResizeToContents); - hdr->setResizeMode(PlayQueueModel::COL_YEAR, QHeaderView::Fixed); + setResizeMode(hdr, PlayQueueModel::COL_STATUS, QHeaderView::Fixed); + setResizeMode(hdr, PlayQueueModel::COL_TITLE, QHeaderView::Interactive); + setResizeMode(hdr, PlayQueueModel::COL_ARTIST, QHeaderView::Interactive); + setResizeMode(hdr, PlayQueueModel::COL_ALBUM, QHeaderView::Stretch); + setResizeMode(hdr, PlayQueueModel::COL_TRACK, QHeaderView::Fixed); + setResizeMode(hdr, PlayQueueModel::COL_LENGTH, QHeaderView::ResizeToContents); + setResizeMode(hdr, PlayQueueModel::COL_DISC, QHeaderView::ResizeToContents); + setResizeMode(hdr, PlayQueueModel::COL_PRIO, QHeaderView::ResizeToContents); + setResizeMode(hdr, PlayQueueModel::COL_YEAR, QHeaderView::Fixed); hdr->setStretchLastSection(false); connect(hdr, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showMenu())); }