From bd163f989e49e5b800f4af79e975f6d70fb01d7d Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sun, 18 Mar 2018 18:39:30 +0100 Subject: [PATCH] Remove non-moc headers from makefile +++ --- CMakeLists.txt | 66 +++++++++-------------------------- src/CMakeLists.txt | 76 ++++------------------------------------- src/core/appearance.h | 4 +-- src/core/application.h | 2 ++ src/core/main.cpp | 73 +++++++++++---------------------------- src/widgets/osd.cpp | 1 + src/widgets/osd_x11.cpp | 33 ++++++++---------- 7 files changed, 61 insertions(+), 194 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84f0d7582..1a8036931 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ project(strawberry) cmake_minimum_required(VERSION 2.8.11) -cmake_policy(SET CMP0011 OLD) +#cmake_policy(SET CMP0011 OLD) #aux_source_directory(. SRC_LIST) @@ -78,10 +78,8 @@ endif(APPLE) find_package(OpenGL REQUIRED) find_package(Boost REQUIRED) -find_package(Gettext REQUIRED) find_package(PkgConfig REQUIRED) find_package(Protobuf REQUIRED) -find_package(FFTW3) find_package(Threads) if(LINUX) find_package(ALSA REQUIRED) @@ -193,20 +191,6 @@ endif(WIN32) add_definitions(-DQT_NO_CAST_TO_ASCII -DQT_STRICT_ITERATORS) -# Translations stuff -find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext PATHS /target/bin) -if(NOT GETTEXT_XGETTEXT_EXECUTABLE) - message(FATAL_ERROR "Could not find xgettext executable") -endif(NOT GETTEXT_XGETTEXT_EXECUTABLE) -find_program(GETTEXT_MSGMERGE_EXECUTABLE msgmerge PATHS /target/bin) -if(NOT GETTEXT_MSGMERGE_EXECUTABLE) - message(FATAL_ERROR "Could not find msgmerge executable") -endif(NOT GETTEXT_MSGMERGE_EXECUTABLE) -find_program(GETTEXT_MSGFMT_EXECUTABLE msgfmt PATHS /target/bin) -if(NOT GETTEXT_MSGFMT_EXECUTABLE) - message(FATAL_ERROR "Could not find msgfmt executable") -endif(NOT GETTEXT_MSGFMT_EXECUTABLE) - # Optional bits if(WIN32) option(ENABLE_WIN32_CONSOLE "Show the windows console even outside Debug mode" OFF) @@ -276,28 +260,23 @@ else(WIN32) set(QT_LIBRARIES Qt5::Core Qt5::OpenGL Qt5::Sql Qt5::Network Qt5::Xml Qt5::Widgets Qt5::Concurrent Qt5::X11Extras Qt5::DBus) endif(WIN32) -# Remove GLU and GL from the link line - they're not really required -# and don't exist on my mingw toolchain -list(REMOVE_ITEM QT_LIBRARIES "-lGLU -lGL") +# Remove GLU and GL from the link line - they're not really required and don't exist on my mingw toolchain +#list(REMOVE_ITEM QT_LIBRARIES "-lGLU -lGL") -# SQLITE -#find_path(SQLITE_INCLUDE_DIRS sqlite.h) -#find_library(SQLITE_LIBRARIES sqlite) -#if(SQLITE_LIBRARIES AND SQLITE_INCLUDE_DIRS) -# message(STATUS "Using system sqlite library") -# set(USE_SYSTEM_SQLITE ON) -#endif () +# QSqlLiteDriver: +# We do this because we can't guarantee that the driver shipped with Qt exposes the raw sqlite3 functions required for FTS support. +# This way we know that those symbols exist at compile-time and that our code links to the same sqlite library as the Qt driver. +option(USE_SYSTEM_QSQLITE "Don't set this unless you can guarantee that the driver shipped with Qt exposes the raw sqlite3 functions required for FTS support" OFF) +if(USE_SYSTEM_QSQLITE) + message(STATUS "Using system qsqlite driver") +else(USE_SYSTEM_QSQLITE) + message(STATUS "Using builtin qsqlite driver") + add_subdirectory(3rdparty/qsqlite) + set(QSQLITE_LIBRARIES qsqlite) + set(QSQLITE_INCLUDE_DIRS "3rdparty/qsqlite") +endif(USE_SYSTEM_QSQLITE) -# Build our copy of QSqlLiteDriver. -# We do this because we can't guarantee that the driver shipped with Qt exposes the -# raw sqlite3_ functions required for FTS support. This way we know that those symbols -# exist at compile-time and that our code links to the same sqlite library as the -# Qt driver. -add_subdirectory(3rdparty/qsqlite) -include_directories("3rdparty/qsqlite") - -# When/if upstream accepts our patches then these options can be used to link -# to system installed qtsingleapplication instead. +# When/if upstream accepts our patches then these options can be used to link to system installed qtsingleapplication instead. option(USE_SYSTEM_QTSINGLEAPPLICATION "Don't set this option unless your system QtSingleApplication library has been compiled with the Strawberry patches in 3rdparty" OFF) if(USE_SYSTEM_QTSINGLEAPPLICATION) find_path(QTSINGLEAPPLICATION_INCLUDE_DIRS qtsingleapplication.h PATH_SUFFIXES QtSolutions) @@ -309,17 +288,7 @@ else(USE_SYSTEM_QTSINGLEAPPLICATION) set(QTSINGLEAPPLICATION_LIBRARIES qtsingleapplication) endif(USE_SYSTEM_QTSINGLEAPPLICATION) -# QtIoCompressor isn't patched, so we can use a system version if it's available -#find_path(QTIOCOMPRESSOR_INCLUDE_DIRS qtiocompressor.h PATH_SUFFIXES QtSolutions) -#find_library(QTIOCOMPRESSOR_LIBRARIES QtSolutions_IOCompressor-2.3) -#if(NOT QTIOCOMPRESSOR_INCLUDE_DIRS OR NOT QTIOCOMPRESSOR_LIBRARIES) -# add_subdirectory(3rdparty/qtiocompressor) -# set(QTIOCOMPRESSOR_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/qtiocompressor) -# set(QTIOCOMPRESSOR_LIBRARIES qtiocompressor) -#endif(NOT QTIOCOMPRESSOR_INCLUDE_DIRS OR NOT QTIOCOMPRESSOR_LIBRARIES) - -# When/if upstream accepts our or reimplement our patches then these options can be -# used to link to system installed qxt instead. +# When/if upstream accepts our or reimplement our patches then these options can be used to link to system installed qxt instead. option(USE_SYSTEM_QXT "Don't set this option unless your system Qxt library has been compiled with the Strawberry patches in 3rdparty" OFF) if (USE_SYSTEM_QXT) find_path(QXTCORE_INCLUDE_DIRS qxtglobal.h PATH_SUFFIXES QxtCore) @@ -373,7 +342,6 @@ if (WIN32) add_subdirectory(3rdparty/qtwin) add_subdirectory(3rdparty/tinysvcmdns) endif (WIN32) -#add_subdirectory(tests) add_subdirectory(dist) add_subdirectory(ext/libstrawberry-common) add_subdirectory(ext/libstrawberry-tagreader) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eaf13237d..22cb9369e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -56,6 +56,7 @@ include_directories(${QTSINGLEAPPLICATION_INCLUDE_DIRS}) include_directories(${QXT_INCLUDE_DIRS}) include_directories(${SHA2_INCLUDE_DIRS}) include_directories(${CHROMAPRINT_INCLUDE_DIRS}) +include_directories(${QSQLITE_INCLUDE_DIRS}) find_package(OpenGL) include_directories(${OPENGL_INCLUDE_DIR}) @@ -265,58 +266,26 @@ set(SOURCES set(HEADERS core/mainwindow.h core/application.h - core/appearance.h core/player.h - core/commandlineoptions.h core/database.h - core/metatypes.h core/deletefiles.h - core/filesystemmusicstorage.h core/filesystemwatcherinterface.h core/mergedproxymodel.h - core/multisortfilterproxy.h - core/musicstorage.h core/network.h - core/networkproxyfactory.h core/qtfslistener.h - core/settingsprovider.h - core/signalchecker.h - core/song.h core/songloader.h - core/stylesheetloader.h core/tagreaderclient.h core/taskmanager.h - core/thread.h core/urlhandler.h - core/utilities.h - core/scangiomodulepath.h - core/flowlayout.h - core/iconloader.h core/qtsystemtrayicon.h core/standarditemiconloader.h core/systemtrayicon.h core/windows7thumbbar.h - core/screensaver.h - core/cachedlist.h core/mimedata.h - core/qhash_qurl.h - core/simpletreeitem.h - core/simpletreemodel.h - core/timeconstants.h - core/qt_blurimage.h - core/scopedtransaction.h - core/scopedgobject.h - core/scoped_cftyperef.h - core/scoped_nsautorelease_pool.h - core/scoped_nsobject.h - - engine/enginetype.h + engine/enginebase.h engine/enginedevice.h - engine/devicefinder.h - engine/engine_fwd.h - analyzer/fht.h analyzer/analyzerbase.h analyzer/analyzercontainer.h analyzer/blockanalyzer.h @@ -332,12 +301,7 @@ set(HEADERS collection/collectionviewcontainer.h collection/collectiondirectorymodel.h collection/collectionfilterwidget.h - collection/collectionplaylistitem.h - collection/collectionquery.h - collection/collectionitem.h - collection/sqlrow.h collection/savedgroupingmanager.h - collection/directory.h collection/groupbydialog.h playlist/playlist.h @@ -345,7 +309,6 @@ set(HEADERS playlist/playlistcontainer.h playlist/playlistdelegates.h playlist/playlistfilter.h - playlist/playlistfilterparser.h playlist/playlistheader.h playlist/playlistlistcontainer.h playlist/playlistlistmodel.h @@ -354,14 +317,12 @@ set(HEADERS playlist/playlistsaveoptionsdialog.h playlist/playlistsequence.h playlist/playlisttabbar.h - playlist/playlistundocommands.h playlist/playlistview.h playlist/playlistitemmimedata.h playlist/queue.h playlist/queuemanager.h playlist/songloaderinserter.h playlist/songmimedata.h - playlist/songplaylistitem.h playlistparsers/asxiniparser.h playlistparsers/asxparser.h @@ -370,14 +331,11 @@ set(HEADERS playlistparsers/parserbase.h playlistparsers/playlistparser.h playlistparsers/plsparser.h - playlistparsers/wplparser.h - playlistparsers/xmlparser.h playlistparsers/xspfparser.h covermanager/albumcovermanager.h covermanager/albumcovermanagerlist.h covermanager/albumcoverloader.h - covermanager/albumcoverloaderoptions.h covermanager/albumcoverfetcher.h covermanager/albumcoverfetchersearch.h covermanager/albumcoversearcher.h @@ -387,7 +345,6 @@ set(HEADERS covermanager/coverprovider.h covermanager/coverproviders.h covermanager/coversearchstatisticsdialog.h - covermanager/coversearchstatistics.h covermanager/coverexportrunnable.h covermanager/currentartloader.h covermanager/coverfromurldialog.h @@ -422,7 +379,6 @@ set(HEADERS widgets/favoritewidget.h widgets/fileview.h widgets/fileviewlist.h - widgets/forcescrollperpixel.h widgets/freespacebar.h widgets/groupediconview.h widgets/lineedit.h @@ -440,7 +396,6 @@ set(HEADERS widgets/sliderwidget.h widgets/stickyslider.h widgets/stretchheaderview.h - widgets/stylehelper.h widgets/trackslider.h widgets/tracksliderpopup.h widgets/tracksliderslider.h @@ -452,7 +407,6 @@ set(HEADERS globalshortcuts/globalshortcutbackend.h globalshortcuts/globalshortcuts.h globalshortcuts/gnomeglobalshortcutbackend.h - globalshortcuts/qxtglobalshortcutbackend.h globalshortcuts/globalshortcutgrabber.h device/connecteddevice.h @@ -532,17 +486,17 @@ option(USE_INSTALL_PREFIX "Look for data in CMAKE_INSTALL_PREFIX" ON) # Engines set(GST_ENGINE_SRC engine/gstengine.cpp engine/gstenginepipeline.cpp engine/gstelementdeleter.cpp) -set(GST_ENGINE_MOC engine/gstengine.h engine/gstenginepipeline.h engine/gstelementdeleter.h engine/bufferconsumer.h) +set(GST_ENGINE_MOC engine/gstengine.h engine/gstenginepipeline.h engine/gstelementdeleter.h) #set(GST_ENGINE_LIB GSTREAMER GSTREAMER_BASE GSTREAMER_APP GSTREAMER_AUDIO GSTREAMER_TAG GSTREAMER_PBUTILS GSTREAMER_QTGLIB GSTREAMER_QTGST GSTREAMER_QTGSTUI GSTREAMER_QTGSTUTILS) set(GST_ENGINE_LIB GSTREAMER GSTREAMER_BASE GSTREAMER_APP GSTREAMER_AUDIO GSTREAMER_TAG GSTREAMER_PBUTILS) #set(GST_ENGINE_LIB gstreamer-1.0 gstreamer-base-1.0 gstreamer-app-1.0 streamer-audio-1.0 gstreamer-tag-1.0 gstreamer-pbutils-1.0) #set(GST_ENGINE_LIB ${GSTREAMER_BASE_LIBRARIES} ${GSTREAMER_LIBRARIES} ${GSTREAMER_APP_LIBRARIES} ${GSTREAMER_TAG_LIBRARIES} ${GSTREAMER_PBUTILS_LIBRARIES}) set(XINE_ENGINE_SRC engine/xineengine.cpp engine/xinescope.c) -set(XINE_ENGINE_MOC engine/xineengine.h engine/xinescope.h) +set(XINE_ENGINE_MOC engine/xineengine.h) set(VLC_ENGINE_SRC engine/vlcengine.cpp) -set(VLC_ENGINE_MOC engine/vlcengine.h engine/vlcscopedref.h) +set(VLC_ENGINE_MOC engine/vlcengine.h) set(PHONON_ENGINE_SRC engine/phononengine.cpp) set(PHONON_ENGINE_MOC engine/phononengine.h) @@ -561,15 +515,12 @@ optional_source(HAVE_LIBLASTFM covermanager/lastfmcompat.cpp HEADERS covermanager/lastfmcoverprovider.h - covermanager/lastfmcompat.h ) # Platform specific - Linux optional_source(LINUX SOURCES engine/alsadevicefinder.cpp - HEADERS - engine/alsadevicefinder.h ) # Platform specific - OS X @@ -742,8 +693,6 @@ optional_source(HAVE_DBUS HEADERS core/mpris.h core/mpris2.h - core/mpris_common.h - core/dbusscreensaver.h ) optional_source(HAVE_DEVICEKIT @@ -804,7 +753,6 @@ optional_source(HAVE_LIBMTP HEADERS device/mtpdevice.h device/mtploader.h - device/mtpconnection.h ) # Pulse audio integration @@ -813,8 +761,6 @@ optional_source(HAVE_LIBPULSE ${LIBPULSE_INCLUDE_DIRS} SOURCES engine/pulsedevicefinder.cpp - HEADERS - engine/pulsedevicefinder.h ) optional_source(HAVE_GSTREAMER @@ -838,23 +784,14 @@ SOURCES transcoder/transcoderoptionswma.cpp HEADERS core/organise.h - core/organiseformat.h settings/transcodersettingspage.h dialogs/organisedialog.h dialogs/organiseerrordialog.h - musicbrainz/chromaprinter.h musicbrainz/tagfetcher.h transcoder/transcoder.h transcoder/transcodedialog.h - transcoder/transcoderoptionsaac.h transcoder/transcoderoptionsdialog.h - transcoder/transcoderoptionsflac.h - transcoder/transcoderoptionsinterface.h transcoder/transcoderoptionsmp3.h - transcoder/transcoderoptionsopus.h - transcoder/transcoderoptionsspeex.h - transcoder/transcoderoptionsvorbis.h - transcoder/transcoderoptionswma.h UI settings/transcodersettingspage.ui dialogs/organisedialog.ui @@ -986,7 +923,6 @@ else (APPLE) target_link_libraries(strawberry_lib ${QXT_LIBRARIES}) endif (APPLE) -set(3RDPARTY_SQLITE_LIBRARY qsqlite) target_link_libraries(strawberry_lib qsqlite) if (WIN32) @@ -1014,7 +950,7 @@ if (UNIX AND NOT APPLE) endif () endif () -#add_dependencies(strawberry_lib qtsingleapplication) +add_dependencies(strawberry_lib qtsingleapplication) ############################################################################### diff --git a/src/core/appearance.h b/src/core/appearance.h index 8e8a1ae89..92987fd6c 100644 --- a/src/core/appearance.h +++ b/src/core/appearance.h @@ -23,14 +23,14 @@ #include "config.h" +#include #include #include class Appearance : public QObject { public: explicit Appearance(QObject* parent = nullptr); - // Load the user preferred theme, which could the default system theme or a - // custom set of colors that user has chosen + // Load the user preferred theme, which could the default system theme or a custom set of colors that user has chosen void LoadUserTheme(); void ResetToSystemDefaultTheme(); void ChangeForegroundColor(const QColor& color); diff --git a/src/core/application.h b/src/core/application.h index 18e246d47..f16c6550e 100644 --- a/src/core/application.h +++ b/src/core/application.h @@ -26,6 +26,8 @@ #include #include +#include +#include #include "settings/settingsdialog.h" diff --git a/src/core/main.cpp b/src/core/main.cpp index e389bd21c..2d6f38e33 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -36,13 +36,6 @@ #include #endif // Q_OS_UNIX -#ifdef HAVE_DBUS - #include "core/mpris.h" - #include "core/mpris2.h" - #include - #include -#endif - #ifdef Q_OS_DARWIN #include #include @@ -55,7 +48,10 @@ #include #endif // Q_OS_WIN32 +#include +#include #include +#include #include #include #include @@ -65,10 +61,18 @@ #include #include #include -#include #include #include +#include +#ifdef HAVE_DBUS + #include + #include +#endif +#ifdef HAVE_DBUS + #include "core/mpris.h" + #include "core/mpris2.h" +#endif #include "core/application.h" #include "core/mainwindow.h" #include "core/commandlineoptions.h" @@ -89,15 +93,6 @@ #endif #include "version.h" #include "widgets/osd.h" -#if 0 -#ifdef HAVE_LIBLASTFM - #include "covermanager/lastfmcoverprovider.h" -#endif -#include "covermanager/amazoncoverprovider.h" -#include "covermanager/coverproviders.h" -#include "covermanager/musicbrainzcoverprovider.h" -#include "covermanager/discogscoverprovider.h" -#endif #include "tagreadermessages.pb.h" @@ -145,24 +140,19 @@ int main(int argc, char* argv[]) { RegisterMetaTypes(); - // Initialise logging. Log levels are set after the commandline options are - // parsed below. + // Initialise logging. Log levels are set after the commandline options are parsed below. logging::Init(); g_log_set_default_handler(reinterpret_cast(&logging::GLog), nullptr); CommandlineOptions options(argc, argv); { - // Only start a core application now so we can check if there's another - // Strawberry running without needing an X server. - // This MUST be done before parsing the commandline options so QTextCodec - // gets the right system locale for filenames. + // Only start a core application now so we can check if there's another Strawberry running without needing an X server. + // This MUST be done before parsing the commandline options so QTextCodec gets the right system locale for filenames. QtSingleCoreApplication a(argc, argv); Utilities::CheckPortable(); - //crash_reporting.SetApplicationPath(a.applicationFilePath()); - // Parse commandline options - need to do this before starting the - // full QApplication so it works without an X server + // Parse commandline options - need to do this before starting the full QApplication so it works without an X server if (!options.Parse()) return 1; logging::SetLevels(options.log_levels()); @@ -182,8 +172,7 @@ int main(int argc, char* argv[]) { setenv("XDG_CONFIG_HOME", Utilities::GetConfigPath(Utilities::Path_Root).toLocal8Bit().constData(), 1); #endif - // Output the version, so when people attach log output to bug reports they - // don't have to tell us which version they're using. + // Output the version, so when people attach log output to bug reports they don't have to tell us which version they're using. qLog(Info) << "Strawberry" << STRAWBERRY_VERSION_DISPLAY; // Seed the random number generators. @@ -195,14 +184,6 @@ int main(int argc, char* argv[]) { QtSingleApplication a(argc, argv); - // A bug in Qt means the wheel_scroll_lines setting gets ignored and replaced - // with the default value of 3 in QApplicationPrivate::initialize. - { - QSettings qt_settings(QSettings::UserScope, "Trolltech"); - qt_settings.beginGroup("Qt"); - QApplication::setWheelScrollLines(qt_settings.value("wheelScrollLines", QApplication::wheelScrollLines()).toInt()); - } - #ifdef Q_OS_DARWIN QCoreApplication::setCollectionPaths( QStringList() << QCoreApplication::applicationDirPath() + "/../PlugIns"); @@ -216,8 +197,7 @@ int main(int argc, char* argv[]) { } #ifndef Q_OS_DARWIN - // Gnome on Ubuntu has menu icons disabled by default. I think that's a bad - // idea, and makes some menus in Strawberry look confusing. + // Gnome on Ubuntu has menu icons disabled by default. I think that's a bad idea, and makes some menus in Strawberry look confusing. QCoreApplication::setAttribute(Qt::AA_DontShowIconsInMenus, false); #else QCoreApplication::setAttribute(Qt::AA_DontShowIconsInMenus, true); @@ -225,8 +205,7 @@ int main(int argc, char* argv[]) { QCoreApplication::setAttribute(Qt::AA_NativeWindows, true); #endif -// Set the permissions on the config file on Unix - it can contain passwords -// for internet services so it's important that other users can't read it. +// Set the permissions on the config file on Unix - it can contain passwords for internet services so it's important that other users can't read it. // On Windows these are stored in the registry instead. #ifdef Q_OS_UNIX { @@ -254,25 +233,11 @@ int main(int argc, char* argv[]) { // Icons IconLoader::Init(); - // This is a nasty hack to ensure that everything in libprotobuf is - // initialised in the main thread. It fixes issue 3265 but nobody knows why. - // Don't remove this unless you can reproduce the error that it fixes. - //ParseAProto(); - //QtConcurrent::run(&ParseAProto); - Application app; // Network proxy QNetworkProxyFactory::setApplicationProxyFactory(NetworkProxyFactory::Instance()); -#if 0 -//#ifdef HAVE_LIBLASTFM - app.cover_providers()->AddProvider(new LastFmCoverProvider); - app.cover_providers()->AddProvider(new AmazonCoverProvider); - app.cover_providers()->AddProvider(new DiscogsCoverProvider); - app.cover_providers()->AddProvider(new MusicbrainzCoverProvider); -#endif - // Create the tray icon and OSD std::unique_ptr tray_icon(SystemTrayIcon::CreateSystemTrayIcon()); OSD osd(tray_icon.get(), &app); diff --git a/src/widgets/osd.cpp b/src/widgets/osd.cpp index d62d4cb77..d2fd7acb8 100644 --- a/src/widgets/osd.cpp +++ b/src/widgets/osd.cpp @@ -85,6 +85,7 @@ void OSD::ReloadSettings() { if (!SupportsTrayPopups() && behaviour_ == TrayPopup) behaviour_ = Disabled; ReloadPrettyOSDSettings(); + } // Reload just Pretty OSD settings, not everything diff --git a/src/widgets/osd_x11.cpp b/src/widgets/osd_x11.cpp index 900e4ad6f..9b6b5e816 100644 --- a/src/widgets/osd_x11.cpp +++ b/src/widgets/osd_x11.cpp @@ -35,6 +35,7 @@ #include QDBusArgument& operator<<(QDBusArgument& arg, const QImage& image) { + if (image.isNull()) { // Sometimes this gets called with a null QImage for no obvious reason. arg.beginStructure(); @@ -74,6 +75,7 @@ QDBusArgument& operator<<(QDBusArgument& arg, const QImage& image) { arg << QByteArray(reinterpret_cast(i.bits()), i.byteCount()); arg.endStructure(); return arg; + } const QDBusArgument& operator>>(const QDBusArgument& arg, QImage& image) { @@ -84,31 +86,32 @@ const QDBusArgument& operator>>(const QDBusArgument& arg, QImage& image) { #endif // HAVE_DBUS void OSD::Init() { + #ifdef HAVE_DBUS notification_id_ = 0; - interface_.reset(new OrgFreedesktopNotificationsInterface( - OrgFreedesktopNotificationsInterface::staticInterfaceName(), - "/org/freedesktop/Notifications", - QDBusConnection::sessionBus())); + interface_.reset(new OrgFreedesktopNotificationsInterface(OrgFreedesktopNotificationsInterface::staticInterfaceName(), "/org/freedesktop/Notifications", QDBusConnection::sessionBus())); if (!interface_->isValid()) { qLog(Warning) << "Error connecting to notifications service."; } #endif // HAVE_DBUS + } bool OSD::SupportsNativeNotifications() { + #ifdef HAVE_DBUS return true; #else return false; #endif + } bool OSD::SupportsTrayPopups() { return true; } -void OSD::ShowMessageNative(const QString& summary, const QString& message, - const QString& icon, const QImage& image) { +void OSD::ShowMessageNative(const QString& summary, const QString& message, const QString& icon, const QImage& image) { + #ifdef HAVE_DBUS if (!interface_) return; @@ -118,33 +121,25 @@ void OSD::ShowMessageNative(const QString& summary, const QString& message, } int id = 0; - if (last_notification_time_.secsTo(QDateTime::currentDateTime()) * 1000 - < timeout_msec_) { + if (last_notification_time_.secsTo(QDateTime::currentDateTime()) * 1000 < timeout_msec_) { // Reuse the existing popup if it's still open. The reason we don't always // reuse the popup is because the notification daemon on KDE4 won't re-show // the bubble if it's already gone to the tray. See issue #118 id = notification_id_; } - QDBusPendingReply reply = interface_->Notify( - QCoreApplication::applicationName(), - id, - icon, - summary, - message, - QStringList(), - hints, - timeout_msec_); + QDBusPendingReply reply = interface_->Notify(QCoreApplication::applicationName(), id, icon, summary, message, QStringList(), hints, timeout_msec_); QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(CallFinished(QDBusPendingCallWatcher*))); + connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(CallFinished(QDBusPendingCallWatcher*))); #else // HAVE_DBUS qLog(Warning) << "not implemented"; #endif // HAVE_DBUS + } #ifdef HAVE_DBUS void OSD::CallFinished(QDBusPendingCallWatcher* watcher) { + std::unique_ptr w(watcher); QDBusPendingReply reply = *watcher;