From bf7c8df353d51426441a6b16c9724174b2905654 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Tue, 26 Jan 2021 16:48:04 +0100 Subject: [PATCH] Connection syntax migration (#637) --- ext/libstrawberry-common/core/closure.cpp | 4 +- ext/libstrawberry-common/core/closure.h | 8 +- .../core/messagehandler.cpp | 6 +- ext/libstrawberry-common/core/workerpool.h | 6 +- src/analyzer/analyzercontainer.cpp | 12 +- src/analyzer/analyzercontainer.h | 8 +- src/analyzer/boomanalyzer.h | 6 +- src/analyzer/rainbowanalyzer.h | 8 +- src/collection/collection.cpp | 53 +-- src/collection/collection.h | 7 +- src/collection/collectionbackend.cpp | 2 +- src/collection/collectionbackend.h | 2 +- src/collection/collectiondirectorymodel.cpp | 26 +- src/collection/collectiondirectorymodel.h | 8 +- src/collection/collectionfilterwidget.cpp | 32 +- src/collection/collectionfilterwidget.h | 2 +- src/collection/collectionitemdelegate.cpp | 22 +- src/collection/collectionitemdelegate.h | 4 +- src/collection/collectionmodel.cpp | 22 +- src/collection/collectionmodel.h | 11 +- src/collection/collectionview.cpp | 50 +- src/collection/collectionview.h | 4 +- src/collection/collectionviewcontainer.cpp | 8 +- src/collection/collectionwatcher.cpp | 5 +- src/collection/collectionwatcher.h | 14 +- src/collection/groupbydialog.cpp | 2 +- src/collection/groupbydialog.h | 2 +- src/collection/savedgroupingmanager.cpp | 13 +- src/collection/savedgroupingmanager.h | 4 +- src/context/contextalbum.cpp | 6 +- src/context/contextalbum.h | 5 +- src/context/contextalbumsmodel.cpp | 40 +- src/context/contextalbumsmodel.h | 10 +- src/context/contextalbumsview.cpp | 47 +- src/context/contextalbumsview.h | 4 +- src/context/contextview.cpp | 22 +- src/context/contextview.h | 10 +- src/core/application.cpp | 16 +- src/core/application.h | 2 +- src/core/commandlineoptions.h | 1 - src/core/database.h | 2 +- src/core/deletefiles.cpp | 4 +- src/core/deletefiles.h | 4 +- src/core/macfslistener.h | 4 +- src/core/macfslistener.mm | 2 +- src/core/macsystemtrayicon.h | 8 +- src/core/macsystemtrayicon.mm | 2 +- src/core/mainwindow.cpp | 445 +++++++++--------- src/core/mainwindow.h | 17 +- src/core/mergedproxymodel.cpp | 70 +-- src/core/mergedproxymodel.h | 10 +- src/core/mpris.cpp | 2 +- src/core/mpris.h | 3 +- src/core/mpris2.cpp | 23 +- src/core/mpris2.h | 4 +- src/core/mpris_common.h | 1 - src/core/multisortfilterproxy.h | 1 - src/core/musicstorage.h | 1 - src/core/networktimeouts.cpp | 4 +- src/core/player.cpp | 32 +- src/core/player.h | 5 +- src/core/qt_blurimage.h | 2 +- src/core/qtfslistener.cpp | 2 +- src/core/qtfslistener.h | 2 +- src/core/qtsystemtrayicon.cpp | 18 +- src/core/scopedgobject.h | 1 - src/core/scopedtransaction.h | 2 +- src/core/simpletreeitem.h | 1 - src/core/simpletreemodel.h | 16 +- src/core/song.h | 1 - src/core/songloader.cpp | 8 +- src/core/songloader.h | 3 +- src/core/standarditemiconloader.cpp | 9 +- src/core/stylehelper.h | 1 - src/core/stylesheetloader.cpp | 2 +- src/core/tagreaderclient.cpp | 2 +- src/core/taskmanager.h | 1 - src/core/translations.h | 2 + src/core/urlhandler.h | 2 +- src/core/windows7thumbbar.cpp | 4 +- .../albumcoverchoicecontroller.cpp | 2 +- src/covermanager/albumcoverexport.cpp | 2 +- src/covermanager/albumcoverexport.h | 1 - src/covermanager/albumcoverexporter.cpp | 5 +- src/covermanager/albumcoverexporter.h | 2 +- src/covermanager/albumcoverfetcher.cpp | 6 +- src/covermanager/albumcoverfetcher.h | 7 +- src/covermanager/albumcoverfetchersearch.cpp | 12 +- src/covermanager/albumcoverfetchersearch.h | 4 +- src/covermanager/albumcoverloader.cpp | 4 +- src/covermanager/albumcovermanager.cpp | 58 +-- src/covermanager/albumcovermanager.h | 2 +- src/covermanager/albumcovermanagerlist.h | 1 - src/covermanager/albumcoversearcher.cpp | 21 +- src/covermanager/albumcoversearcher.h | 5 +- src/covermanager/coverexportrunnable.h | 1 - src/covermanager/coverfromurldialog.cpp | 2 +- src/covermanager/coverfromurldialog.h | 1 - src/covermanager/coverproviders.cpp | 2 +- .../coversearchstatisticsdialog.h | 1 - src/covermanager/currentalbumcoverloader.cpp | 4 +- src/covermanager/deezercoverprovider.cpp | 6 +- src/covermanager/discogscoverprovider.cpp | 12 +- src/covermanager/lastfmcoverprovider.cpp | 6 +- src/covermanager/musicbrainzcoverprovider.cpp | 8 +- src/covermanager/musixmatchcoverprovider.cpp | 6 +- src/covermanager/qobuzcoverprovider.cpp | 6 +- src/covermanager/spotifycoverprovider.cpp | 16 +- src/covermanager/spotifycoverprovider.h | 3 +- src/covermanager/tidalcoverprovider.cpp | 6 +- src/device/cddadevice.cpp | 8 +- src/device/cddadevice.h | 5 +- src/device/cddalister.h | 1 + src/device/cddasongloader.cpp | 2 +- src/device/cddasongloader.h | 10 +- src/device/connecteddevice.cpp | 10 +- src/device/connecteddevice.h | 7 +- src/device/devicelister.cpp | 2 +- src/device/devicelister.h | 9 +- src/device/devicemanager.cpp | 28 +- src/device/deviceproperties.cpp | 24 +- src/device/deviceproperties.h | 2 +- src/device/devicestatefiltermodel.cpp | 15 +- src/device/devicestatefiltermodel.h | 5 +- src/device/deviceview.cpp | 54 +-- src/device/deviceview.h | 4 +- src/device/filesystemdevice.cpp | 30 +- src/device/gpoddevice.cpp | 10 +- src/device/gpodloader.h | 1 - src/device/macosdevicelister.h | 2 +- src/device/mtpdevice.cpp | 10 +- src/device/mtploader.h | 2 +- src/device/udisks2lister.cpp | 6 +- src/dialogs/addstreamdialog.cpp | 6 +- src/dialogs/addstreamdialog.h | 2 +- src/dialogs/console.cpp | 2 +- src/dialogs/deleteconfirmationdialog.cpp | 2 +- src/dialogs/edittagdialog.cpp | 67 ++- src/dialogs/edittagdialog.h | 2 +- src/dialogs/errordialog.cpp | 3 +- src/dialogs/errordialog.h | 1 - src/dialogs/lastfmimportdialog.cpp | 17 +- src/dialogs/lastfmimportdialog.h | 7 +- src/dialogs/snapdialog.cpp | 2 +- src/dialogs/trackselectiondialog.cpp | 13 +- src/dialogs/trackselectiondialog.h | 4 +- src/engine/devicefinder.h | 1 - src/engine/directsounddevicefinder.h | 1 - src/engine/enginebase.h | 12 +- src/engine/enginetype.h | 2 +- src/engine/gstengine.cpp | 28 +- src/engine/gstengine.h | 2 +- src/engine/gstenginepipeline.cpp | 4 +- src/engine/gststartup.h | 2 +- src/engine/macosdevicefinder.h | 2 +- src/engine/pulsedevicefinder.h | 2 +- src/engine/vlcengine.h | 2 +- src/equalizer/equalizer.cpp | 16 +- src/equalizer/equalizer.h | 8 +- src/equalizer/equalizerslider.cpp | 2 +- src/equalizer/equalizerslider.h | 1 - .../globalshortcutbackend-gsd.cpp | 7 +- .../globalshortcutbackend-kde.cpp | 7 +- .../globalshortcutbackend-macos.h | 1 - .../globalshortcutbackend-system.cpp | 2 +- .../globalshortcutbackend-system.h | 1 - src/globalshortcuts/globalshortcutgrabber.cpp | 4 +- src/globalshortcuts/globalshortcuts.cpp | 2 +- src/globalshortcuts/globalshortcuts.h | 2 +- src/globalshortcuts/keymapper_win.h | 5 + src/globalshortcuts/keymapper_x11.h | 4 + src/internet/internetcollectionview.cpp | 28 +- src/internet/internetcollectionview.h | 8 +- .../internetcollectionviewcontainer.cpp | 11 +- src/internet/internetplaylistitem.h | 2 +- src/internet/internetsearchmodel.cpp | 8 +- src/internet/internetsearchview.cpp | 64 +-- src/internet/internetsearchview.h | 2 +- src/internet/internetservice.h | 70 +-- src/internet/internetservices.cpp | 4 +- src/internet/internetservices.h | 2 +- src/internet/internetsongmimedata.h | 2 +- src/internet/internetsongsview.cpp | 30 +- src/internet/internettabsview.cpp | 92 ++-- src/internet/localredirectserver.cpp | 14 +- src/internet/localredirectserver.h | 2 +- src/lyrics/auddlyricsprovider.cpp | 6 +- src/lyrics/auddlyricsprovider.h | 1 - src/lyrics/chartlyricsprovider.cpp | 6 +- src/lyrics/geniuslyricsprovider.cpp | 18 +- src/lyrics/lololyricsprovider.cpp | 6 +- src/lyrics/lyricsfetcher.cpp | 9 +- src/lyrics/lyricsfetcher.h | 4 +- src/lyrics/lyricsfetchersearch.cpp | 5 +- src/lyrics/lyricsfetchersearch.h | 4 +- src/lyrics/lyricsprovider.h | 4 +- src/lyrics/lyricsproviders.cpp | 2 +- src/lyrics/musixmatchlyricsprovider.cpp | 6 +- src/lyrics/ovhlyricsprovider.cpp | 6 +- src/lyrics/ovhlyricsprovider.h | 1 - src/main.cpp | 4 +- src/moodbar/moodbarbuilder.cpp | 12 +- src/moodbar/moodbarbuilder.h | 4 +- src/moodbar/moodbarcontroller.cpp | 13 +- src/moodbar/moodbarcontroller.h | 10 +- src/moodbar/moodbaritemdelegate.cpp | 62 +-- src/moodbar/moodbaritemdelegate.h | 24 +- src/moodbar/moodbarloader.cpp | 20 +- src/moodbar/moodbarloader.h | 11 +- src/moodbar/moodbarpipeline.cpp | 42 +- src/moodbar/moodbarpipeline.h | 20 +- src/moodbar/moodbarproxystyle.cpp | 41 +- src/moodbar/moodbarproxystyle.h | 36 +- src/moodbar/moodbarrenderer.cpp | 10 +- src/moodbar/moodbarrenderer.h | 10 +- src/musicbrainz/acoustidclient.cpp | 4 +- src/musicbrainz/acoustidclient.h | 3 +- src/musicbrainz/musicbrainzclient.cpp | 16 +- src/musicbrainz/musicbrainzclient.h | 4 +- src/musicbrainz/tagfetcher.cpp | 12 +- src/musicbrainz/tagfetcher.h | 4 +- src/organize/organize.cpp | 10 +- src/organize/organize.h | 4 +- src/organize/organizedialog.cpp | 32 +- src/organize/organizeformat.h | 1 - src/osd/osdbase.cpp | 5 +- src/osd/osddbus.cpp | 2 +- src/osd/osdpretty.cpp | 12 +- src/osd/osdpretty.h | 2 +- src/playlist/dynamicplaylistcontrols.cpp | 7 +- src/playlist/dynamicplaylistcontrols.h | 2 +- src/playlist/playlist.cpp | 28 +- src/playlist/playlist.h | 7 +- src/playlist/playlistcontainer.cpp | 88 ++-- src/playlist/playlistcontainer.h | 25 +- src/playlist/playlistdelegates.cpp | 46 +- src/playlist/playlistdelegates.h | 18 +- src/playlist/playlistheader.cpp | 16 +- src/playlist/playlistheader.h | 3 +- src/playlist/playlistitem.h | 3 +- src/playlist/playlistlistcontainer.cpp | 32 +- src/playlist/playlistlistmodel.cpp | 26 +- src/playlist/playlistlistmodel.h | 16 +- src/playlist/playlistmanager.cpp | 39 +- src/playlist/playlistmanager.h | 20 +- src/playlist/playlistsequence.cpp | 4 +- src/playlist/playlistsequence.h | 4 +- src/playlist/playlisttabbar.cpp | 61 +-- src/playlist/playlisttabbar.h | 28 +- src/playlist/playlistundocommands.h | 3 +- src/playlist/playlistview.cpp | 72 +-- src/playlist/playlistview.h | 1 + src/playlist/songloaderinserter.cpp | 11 +- src/playlist/songloaderinserter.h | 4 +- src/qobuz/qobuzbaserequest.cpp | 2 +- src/qobuz/qobuzfavoriterequest.cpp | 6 +- src/qobuz/qobuzfavoriterequest.h | 8 +- src/qobuz/qobuzrequest.cpp | 20 +- src/qobuz/qobuzrequest.h | 13 +- src/qobuz/qobuzservice.cpp | 100 ++-- src/qobuz/qobuzservice.h | 4 +- src/qobuz/qobuzstreamurlrequest.cpp | 8 +- src/qobuz/qobuzstreamurlrequest.h | 6 +- src/qobuz/qobuzurlhandler.cpp | 2 +- src/qobuz/qobuzurlhandler.h | 2 +- src/queue/queue.cpp | 30 +- src/queue/queue.h | 8 +- src/queue/queueview.cpp | 44 +- src/scrobbler/audioscrobbler.cpp | 2 +- src/scrobbler/lastfmimport.cpp | 24 +- src/scrobbler/lastfmimport.h | 4 +- src/scrobbler/listenbrainzscrobbler.cpp | 20 +- src/scrobbler/listenbrainzscrobbler.h | 3 +- src/scrobbler/scrobblerservices.cpp | 2 +- src/scrobbler/scrobblingapi20.cpp | 26 +- src/settings/appearancesettingspage.cpp | 38 +- src/settings/appearancesettingspage.h | 1 - src/settings/backendsettingspage.cpp | 24 +- src/settings/backendsettingspage.h | 4 +- src/settings/behavioursettingspage.cpp | 2 +- src/settings/behavioursettingspage.h | 2 +- src/settings/collectionsettingspage.cpp | 28 +- src/settings/collectionsettingspage.h | 2 +- src/settings/contextsettingspage.cpp | 14 +- src/settings/contextsettingspage.h | 2 +- src/settings/coverssettingspage.cpp | 22 +- src/settings/lyricssettingspage.cpp | 22 +- src/settings/notificationssettingspage.cpp | 32 +- src/settings/qobuzsettingspage.cpp | 10 +- src/settings/qobuzsettingspage.h | 13 +- src/settings/scrobblersettingspage.cpp | 24 +- src/settings/settingsdialog.cpp | 20 +- src/settings/settingsdialog.h | 4 +- src/settings/settingspage.h | 2 +- src/settings/shortcutssettingspage.cpp | 20 +- src/settings/subsonicsettingspage.cpp | 8 +- src/settings/subsonicsettingspage.h | 3 +- src/settings/tidalsettingspage.cpp | 14 +- src/smartplaylists/playlistgenerator.h | 2 +- .../playlistgeneratorinserter.cpp | 2 +- .../playlistgeneratorinserter.h | 4 +- .../smartplaylistquerywizardplugin.cpp | 26 +- .../smartplaylistsearchpreview.h | 4 +- .../smartplaylistsearchtermwidget.cpp | 31 +- .../smartplaylistsviewcontainer.cpp | 35 +- .../smartplaylistsviewcontainer.h | 1 - src/smartplaylists/smartplaylistwizard.cpp | 4 +- src/subsonic/subsonicbaserequest.cpp | 2 +- src/subsonic/subsonicrequest.cpp | 16 +- src/subsonic/subsonicrequest.h | 8 +- src/subsonic/subsonicscrobblerequest.cpp | 6 +- src/subsonic/subsonicservice.cpp | 28 +- src/subsonic/subsonicservice.h | 2 +- src/tidal/tidalbaserequest.cpp | 2 +- src/tidal/tidalbaserequest.h | 1 - src/tidal/tidalfavoriterequest.cpp | 10 +- src/tidal/tidalfavoriterequest.h | 19 +- src/tidal/tidalrequest.cpp | 24 +- src/tidal/tidalrequest.h | 17 +- src/tidal/tidalservice.cpp | 120 ++--- src/tidal/tidalservice.h | 11 +- src/tidal/tidalstreamurlrequest.cpp | 12 +- src/tidal/tidalstreamurlrequest.h | 6 +- src/tidal/tidalurlhandler.cpp | 2 +- src/tidal/tidalurlhandler.h | 2 +- src/transcoder/transcodedialog.cpp | 26 +- src/transcoder/transcoder.h | 4 +- src/transcoder/transcoderoptionsflac.h | 2 +- src/transcoder/transcoderoptionsmp3.cpp | 4 +- src/widgets/autoexpandingtreeview.cpp | 10 +- src/widgets/autoexpandingtreeview.h | 3 +- src/widgets/busyindicator.h | 1 - src/widgets/fancytabwidget.cpp | 6 +- src/widgets/favoritewidget.h | 5 + src/widgets/fileview.cpp | 35 +- src/widgets/fileview.h | 10 +- src/widgets/fileviewlist.cpp | 21 +- src/widgets/fileviewlist.h | 11 +- src/widgets/groupediconview.cpp | 36 +- src/widgets/groupediconview.h | 12 +- src/widgets/lineedit.cpp | 36 +- src/widgets/lineedit.h | 8 +- src/widgets/loginstatewidget.cpp | 4 +- src/widgets/multiloadingindicator.cpp | 14 +- src/widgets/multiloadingindicator.h | 3 +- src/widgets/playingwidget.cpp | 34 +- src/widgets/playingwidget.h | 23 +- src/widgets/qsearchfield.h | 2 +- src/widgets/qsearchfield_nonmac.cpp | 10 +- src/widgets/renametablineedit.h | 1 - src/widgets/stretchheaderview.cpp | 2 +- src/widgets/stretchheaderview.h | 2 +- src/widgets/trackslider.cpp | 37 +- src/widgets/trackslider.h | 16 +- src/widgets/tracksliderpopup.h | 2 +- src/widgets/tracksliderslider.cpp | 25 +- src/widgets/tracksliderslider.h | 8 +- src/widgets/volumeslider.cpp | 2 +- tests/src/collectionbackend_test.cpp | 18 +- tests/src/collectionmodel_test.cpp | 24 +- tests/src/concurrentrun_test.cpp | 16 +- tests/src/mergedproxymodel_test.cpp | 16 +- 362 files changed, 2452 insertions(+), 2434 deletions(-) diff --git a/ext/libstrawberry-common/core/closure.cpp b/ext/libstrawberry-common/core/closure.cpp index 8fb8151e..10afd5a0 100644 --- a/ext/libstrawberry-common/core/closure.cpp +++ b/ext/libstrawberry-common/core/closure.cpp @@ -48,8 +48,8 @@ ObjectHelper* ClosureBase::helper() const { ObjectHelper::ObjectHelper(QObject *sender, const char *signal, ClosureBase *closure) : closure_(closure) { - connect(sender, signal, SLOT(Invoked())); - connect(sender, SIGNAL(destroyed()), SLOT(deleteLater())); + QObject::connect(sender, signal, SLOT(Invoked())); + QObject::connect(sender, &QObject::destroyed, this, &ObjectHelper::deleteLater); } diff --git a/ext/libstrawberry-common/core/closure.h b/ext/libstrawberry-common/core/closure.h index b915b6ce..98b5490f 100644 --- a/ext/libstrawberry-common/core/closure.h +++ b/ext/libstrawberry-common/core/closure.h @@ -110,7 +110,7 @@ class Closure : public ClosureBase { const int index = meta_receiver->indexOfSlot(normalised_slot.constData()); Q_ASSERT(index != -1); slot_ = meta_receiver->method(index); - QObject::connect(receiver_, SIGNAL(destroyed()), helper_, SLOT(deleteLater())); + QObject::connect(receiver_, &QObject::destroyed, helper_, &QObject::deleteLater); } void Invoke() override { @@ -207,7 +207,7 @@ template _detail::ClosureBase *NewClosure(QFuture future, QObject *receiver, const char *slot, const Args&... args) { QFutureWatcher *watcher = new QFutureWatcher; watcher->setFuture(future); - QObject::connect(watcher, SIGNAL(finished()), watcher, SLOT(deleteLater())); + QObject::connect(watcher, &QFutureWatcher::finished, watcher, &QFutureWatcher::deleteLater); return NewClosure(watcher, SIGNAL(finished()), receiver, slot, args...); } @@ -215,7 +215,7 @@ template _detail::ClosureBase *NewClosure(QFuture future, const F &callback, const Args&... args) { QFutureWatcher *watcher = new QFutureWatcher; watcher->setFuture(future); - QObject::connect(watcher, SIGNAL(finished()), watcher, SLOT(deleteLater())); + QObject::connect(watcher, &QFutureWatcher::finished, watcher, &QFutureWatcher::deleteLater); return NewClosure(watcher, SIGNAL(finished()), callback, args...); } @@ -228,7 +228,7 @@ void DoAfter(std::function callback, std::chrono::duration duratio QTimer *timer = new QTimer; timer->setSingleShot(true); NewClosure(timer, SIGNAL(timeout()), callback); - QObject::connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater())); + QObject::connect(timer, &QTimer::timeout, timer, &QTimer::deleteLater); std::chrono::milliseconds msec = std::chrono::duration_cast(duration); timer->start(msec.count()); } diff --git a/ext/libstrawberry-common/core/messagehandler.cpp b/ext/libstrawberry-common/core/messagehandler.cpp index 129a41e7..33e01517 100644 --- a/ext/libstrawberry-common/core/messagehandler.cpp +++ b/ext/libstrawberry-common/core/messagehandler.cpp @@ -44,16 +44,16 @@ void _MessageHandlerBase::SetDevice(QIODevice *device) { buffer_.open(QIODevice::ReadWrite); - connect(device, SIGNAL(readyRead()), SLOT(DeviceReadyRead())); + QObject::connect(device, &QIODevice::readyRead, this, &_MessageHandlerBase::DeviceReadyRead); // Yeah I know. if (QAbstractSocket *abstractsocket = qobject_cast(device)) { flush_abstract_socket_ = &QAbstractSocket::flush; - connect(abstractsocket, SIGNAL(disconnected()), SLOT(DeviceClosed())); + QObject::connect(abstractsocket, &QAbstractSocket::disconnected, this, &_MessageHandlerBase::DeviceClosed); } else if (QLocalSocket *localsocket = qobject_cast(device)) { flush_local_socket_ = &QLocalSocket::flush; - connect(localsocket, SIGNAL(disconnected()), SLOT(DeviceClosed())); + QObject::connect(localsocket, &QLocalSocket::disconnected, this, &_MessageHandlerBase::DeviceClosed); } else { qFatal("Unsupported device type passed to _MessageHandlerBase"); diff --git a/ext/libstrawberry-common/core/workerpool.h b/ext/libstrawberry-common/core/workerpool.h index 5353e74c..0fd56743 100644 --- a/ext/libstrawberry-common/core/workerpool.h +++ b/ext/libstrawberry-common/core/workerpool.h @@ -173,7 +173,7 @@ WorkerPool::~WorkerPool() { for (const Worker &worker : workers_) { if (worker.local_socket_ && worker.process_) { - disconnect(worker.process_, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(ProcessError(QProcess::ProcessError))); + QObject::disconnect(worker.process_, &QProcess::errorOccurred, this, &WorkerPool::ProcessError); // The worker is connected. Close his socket and wait for him to exit. qLog(Debug) << "Closing worker socket"; @@ -272,8 +272,8 @@ void WorkerPool::StartOneWorker(Worker *worker) { worker->local_server_ = new QLocalServer(this); worker->process_ = new QProcess(this); - connect(worker->local_server_, SIGNAL(newConnection()), SLOT(NewConnection())); - connect(worker->process_, SIGNAL(errorOccurred(QProcess::ProcessError)), SLOT(ProcessError(QProcess::ProcessError))); + QObject::connect(worker->local_server_, &QLocalServer::newConnection, this, &WorkerPool::NewConnection); + QObject::connect(worker->process_, &QProcess::errorOccurred, this, &WorkerPool::ProcessError); // Create a server, find an unused name and start listening forever { diff --git a/src/analyzer/analyzercontainer.cpp b/src/analyzer/analyzercontainer.cpp index 852e8556..2b26597d 100644 --- a/src/analyzer/analyzercontainer.cpp +++ b/src/analyzer/analyzercontainer.cpp @@ -83,7 +83,7 @@ AnalyzerContainer::AnalyzerContainer(QWidget *parent) AddAnalyzerType(); AddAnalyzerType(); - disable_action_ = context_menu_->addAction(tr("No analyzer"), this, SLOT(DisableAnalyzer())); + disable_action_ = context_menu_->addAction(tr("No analyzer"), this, &AnalyzerContainer::DisableAnalyzer); disable_action_->setCheckable(true); group_->addAction(disable_action_); @@ -91,7 +91,7 @@ AnalyzerContainer::AnalyzerContainer(QWidget *parent) double_click_timer_->setSingleShot(true); double_click_timer_->setInterval(250); - connect(double_click_timer_, SIGNAL(timeout()), SLOT(ShowPopupMenu())); + QObject::connect(double_click_timer_, &QTimer::timeout, this, &AnalyzerContainer::ShowPopupMenu); Load(); @@ -131,7 +131,7 @@ void AnalyzerContainer::DisableAnalyzer() { Save(); } -void AnalyzerContainer::ChangeAnalyzer(int id) { +void AnalyzerContainer::ChangeAnalyzer(const int id) { QObject *instance = analyzer_types_[id]->newInstance(Q_ARG(QWidget*, this)); @@ -201,7 +201,7 @@ void AnalyzerContainer::Load() { } -void AnalyzerContainer::SaveFramerate(int framerate) { +void AnalyzerContainer::SaveFramerate(const int framerate) { // For now, framerate is common for all analyzers. Maybe each analyzer should have its own framerate? current_framerate_ = framerate; @@ -221,12 +221,12 @@ void AnalyzerContainer::Save() { } -void AnalyzerContainer::AddFramerate(const QString& name, int framerate) { +void AnalyzerContainer::AddFramerate(const QString& name, const int framerate) { QAction *action = context_menu_framerate_->addAction(name); group_framerate_->addAction(action); framerate_list_ << framerate; action->setCheckable(true); - connect(action, &QAction::triggered, [this, framerate]() { ChangeFramerate(framerate); } ); + QObject::connect(action, &QAction::triggered, [this, framerate]() { ChangeFramerate(framerate); } ); } diff --git a/src/analyzer/analyzercontainer.h b/src/analyzer/analyzercontainer.h index d0f9a153..f45314d1 100644 --- a/src/analyzer/analyzercontainer.h +++ b/src/analyzer/analyzercontainer.h @@ -60,7 +60,7 @@ class AnalyzerContainer : public QWidget { void wheelEvent(QWheelEvent *e) override; private slots: - void ChangeAnalyzer(int id); + void ChangeAnalyzer(const int id); void ChangeFramerate(int new_framerate); void DisableAnalyzer(); void ShowPopupMenu(); @@ -73,10 +73,10 @@ class AnalyzerContainer : public QWidget { void Load(); void Save(); - void SaveFramerate(int framerate); + void SaveFramerate(const int framerate); template void AddAnalyzerType(); - void AddFramerate(const QString& name, int framerate); + void AddFramerate(const QString& name, const int framerate); private: int current_framerate_; // fps @@ -109,7 +109,7 @@ void AnalyzerContainer::AddAnalyzerType() { group_->addAction(action); action->setCheckable(true); actions_ << action; - connect(action, &QAction::triggered, [this, id]() { ChangeAnalyzer(id); } ); + QObject::connect(action, &QAction::triggered, [this, id]() { ChangeAnalyzer(id); } ); } diff --git a/src/analyzer/boomanalyzer.h b/src/analyzer/boomanalyzer.h index 00e8304a..574a29d7 100644 --- a/src/analyzer/boomanalyzer.h +++ b/src/analyzer/boomanalyzer.h @@ -44,15 +44,15 @@ class BoomAnalyzer : public Analyzer::Base { static const char* kName; - void transform(Analyzer::Scope& s) override; - void analyze(QPainter& p, const Analyzer::Scope&, bool new_frame) override; + void transform(Analyzer::Scope &s) override; + void analyze(QPainter &p, const Analyzer::Scope&, bool new_frame) override; public slots: void changeK_barHeight(int); void changeF_peakSpeed(int); protected: - void resizeEvent(QResizeEvent* e) override; + void resizeEvent(QResizeEvent *e) override; static const uint kColumnWidth; static const uint kMaxBandCount; diff --git a/src/analyzer/rainbowanalyzer.h b/src/analyzer/rainbowanalyzer.h index 55707fb5..14319ecd 100644 --- a/src/analyzer/rainbowanalyzer.h +++ b/src/analyzer/rainbowanalyzer.h @@ -50,14 +50,14 @@ class RainbowAnalyzer : public Analyzer::Base { Dash = 1 }; - RainbowAnalyzer(const RainbowType& rbtype, QWidget* parent); + RainbowAnalyzer(const RainbowType &rbtype, QWidget *parent); protected: void transform(Analyzer::Scope&) override; - void analyze(QPainter& p, const Analyzer::Scope&, bool new_frame) override; + void analyze(QPainter &p, const Analyzer::Scope&, bool new_frame) override; - void timerEvent(QTimerEvent* e) override; - void resizeEvent(QResizeEvent* e) override; + void timerEvent(QTimerEvent *e) override; + void resizeEvent(QResizeEvent *e) override; private: static const int kHeight[]; diff --git a/src/collection/collection.cpp b/src/collection/collection.cpp index 919db09a..34b6dedd 100644 --- a/src/collection/collection.cpp +++ b/src/collection/collection.cpp @@ -97,21 +97,19 @@ void SCollection::Init() { watcher_->set_backend(backend_); watcher_->set_task_manager(app_->task_manager()); - connect(backend_, SIGNAL(DirectoryDiscovered(Directory, SubdirectoryList)), watcher_, SLOT(AddDirectory(Directory, SubdirectoryList))); - connect(backend_, SIGNAL(DirectoryDeleted(Directory)), watcher_, SLOT(RemoveDirectory(Directory))); - connect(watcher_, SIGNAL(NewOrUpdatedSongs(SongList)), backend_, SLOT(AddOrUpdateSongs(SongList))); - connect(watcher_, SIGNAL(SongsMTimeUpdated(SongList)), backend_, SLOT(UpdateMTimesOnly(SongList))); - connect(watcher_, SIGNAL(SongsDeleted(SongList)), backend_, SLOT(DeleteSongs(SongList))); - connect(watcher_, SIGNAL(SongsUnavailable(SongList)), backend_, SLOT(MarkSongsUnavailable(SongList))); - connect(watcher_, SIGNAL(SongsReadded(SongList, bool)), backend_, SLOT(MarkSongsUnavailable(SongList, bool))); - connect(watcher_, SIGNAL(SubdirsDiscovered(SubdirectoryList)), backend_, SLOT(AddOrUpdateSubdirs(SubdirectoryList))); - connect(watcher_, SIGNAL(SubdirsMTimeUpdated(SubdirectoryList)), backend_, SLOT(AddOrUpdateSubdirs(SubdirectoryList))); - connect(watcher_, SIGNAL(CompilationsNeedUpdating()), backend_, SLOT(UpdateCompilations())); - connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), SLOT(CurrentSongChanged(Song))); - connect(app_->player(), SIGNAL(Stopped()), SLOT(Stopped())); + QObject::connect(backend_, &CollectionBackend::DirectoryDiscovered, watcher_, &CollectionWatcher::AddDirectory); + QObject::connect(backend_, &CollectionBackend::DirectoryDeleted, watcher_, &CollectionWatcher::RemoveDirectory); + QObject::connect(watcher_, &CollectionWatcher::NewOrUpdatedSongs, backend_, &CollectionBackend::AddOrUpdateSongs); + QObject::connect(watcher_, &CollectionWatcher::SongsMTimeUpdated, backend_, &CollectionBackend::UpdateMTimesOnly); + QObject::connect(watcher_, &CollectionWatcher::SongsDeleted, backend_, &CollectionBackend::DeleteSongs); + QObject::connect(watcher_, &CollectionWatcher::SongsUnavailable, backend_, &CollectionBackend::MarkSongsUnavailable); + QObject::connect(watcher_, &CollectionWatcher::SongsReadded, backend_, &CollectionBackend::MarkSongsUnavailable); + QObject::connect(watcher_, &CollectionWatcher::SubdirsDiscovered, backend_, &CollectionBackend::AddOrUpdateSubdirs); + QObject::connect(watcher_, &CollectionWatcher::SubdirsMTimeUpdated, backend_, &CollectionBackend::AddOrUpdateSubdirs); + QObject::connect(watcher_, &CollectionWatcher::CompilationsNeedUpdating, backend_, &CollectionBackend::CompilationsNeedUpdating); - connect(app_->lastfm_import(), SIGNAL(UpdateLastPlayed(QString, QString, QString, qint64)), backend_, SLOT(UpdateLastPlayed(QString, QString, QString, qint64))); - connect(app_->lastfm_import(), SIGNAL(UpdatePlayCount(QString, QString, int)), backend_, SLOT(UpdatePlayCount(QString, QString, int))); + QObject::connect(app_->lastfm_import(), &LastFMImport::UpdateLastPlayed, backend_, &CollectionBackend::UpdateLastPlayed); + QObject::connect(app_->lastfm_import(), &LastFMImport::UpdatePlayCount, backend_, &CollectionBackend::UpdatePlayCount); // This will start the watcher checking for updates backend_->LoadDirectoriesAsync(); @@ -122,11 +120,11 @@ void SCollection::Exit() { wait_for_exit_ << backend_ << watcher_; - disconnect(backend_, nullptr, watcher_, nullptr); - disconnect(watcher_, nullptr, backend_, nullptr); + QObject::disconnect(backend_, nullptr, watcher_, nullptr); + QObject::disconnect(watcher_, nullptr, backend_, nullptr); - connect(backend_, SIGNAL(ExitFinished()), this, SLOT(ExitReceived())); - connect(watcher_, SIGNAL(ExitFinished()), this, SLOT(ExitReceived())); + QObject::connect(backend_, &CollectionBackend::ExitFinished, this, &SCollection::ExitReceived); + QObject::connect(watcher_, &CollectionWatcher::ExitFinished, this, &SCollection::ExitReceived); backend_->ExitAsync(); watcher_->ExitAsync(); @@ -135,7 +133,7 @@ void SCollection::Exit() { void SCollection::ExitReceived() { QObject *obj = qobject_cast(sender()); - disconnect(obj, nullptr, this, nullptr); + QObject::disconnect(obj, nullptr, this, nullptr); qLog(Debug) << obj << "successfully exited."; wait_for_exit_.removeAll(obj); if (wait_for_exit_.isEmpty()) emit ExitFinished(); @@ -165,20 +163,3 @@ void SCollection::ReloadSettings() { model_->ReloadSettings(); } - -void SCollection::Stopped() { - - CurrentSongChanged(Song()); -} - -void SCollection::CurrentSongChanged(const Song &song) { // FIXME - - Q_UNUSED(song); - - TagReaderReply *reply = nullptr; - - if (reply) { - connect(reply, SIGNAL(Finished(bool)), reply, SLOT(deleteLater())); - } - -} diff --git a/src/collection/collection.h b/src/collection/collection.h index f48a447a..edc508cb 100644 --- a/src/collection/collection.h +++ b/src/collection/collection.h @@ -73,13 +73,10 @@ class SCollection : public QObject { void AbortScan(); void Rescan(const SongList &songs); - private slots: - void ExitReceived(); - void IncrementalScan(); - void CurrentSongChanged(const Song &song); - void Stopped(); + private slots: + void ExitReceived(); signals: void ExitFinished(); diff --git a/src/collection/collectionbackend.cpp b/src/collection/collectionbackend.cpp index 69062832..4d5fef6a 100644 --- a/src/collection/collectionbackend.cpp +++ b/src/collection/collectionbackend.cpp @@ -902,7 +902,7 @@ Song::Source CollectionBackend::Source() const { return source_; } -void CollectionBackend::UpdateCompilations() { +void CollectionBackend::CompilationsNeedUpdating() { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); diff --git a/src/collection/collectionbackend.h b/src/collection/collectionbackend.h index 0403ef33..03d6aea6 100644 --- a/src/collection/collectionbackend.h +++ b/src/collection/collectionbackend.h @@ -204,7 +204,7 @@ class CollectionBackend : public CollectionBackendInterface { void DeleteSongs(const SongList &songs); void MarkSongsUnavailable(const SongList &songs, const bool unavailable = true); void AddOrUpdateSubdirs(const SubdirectoryList &subdirs); - void UpdateCompilations(); + void CompilationsNeedUpdating(); void UpdateManualAlbumArt(const QString &artist, const QString &albumartist, const QString &album, const QUrl &cover_url); void ForceCompilation(const QString &album, const QList &artists, const bool on); void IncrementPlayCount(const int id); diff --git a/src/collection/collectiondirectorymodel.cpp b/src/collection/collectiondirectorymodel.cpp index 572a2296..70e9b7ed 100644 --- a/src/collection/collectiondirectorymodel.cpp +++ b/src/collection/collectiondirectorymodel.cpp @@ -37,11 +37,10 @@ CollectionDirectoryModel::CollectionDirectoryModel(CollectionBackend *backend, QObject *parent) : QStandardItemModel(parent), dir_icon_(IconLoader::Load("document-open-folder")), - backend_(backend) -{ + backend_(backend) { - connect(backend_, SIGNAL(DirectoryDiscovered(Directory, SubdirectoryList)), SLOT(DirectoryDiscovered(Directory))); - connect(backend_, SIGNAL(DirectoryDeleted(Directory)), SLOT(DirectoryDeleted(Directory))); + QObject::connect(backend_, &CollectionBackend::DirectoryDiscovered, this, &CollectionDirectoryModel::DirectoryDiscovered); + QObject::connect(backend_, &CollectionBackend::DirectoryDeleted, this, &CollectionDirectoryModel::DirectoryDeleted); } @@ -77,34 +76,33 @@ void CollectionDirectoryModel::AddDirectory(const QString &path) { } -void CollectionDirectoryModel::RemoveDirectory(const QModelIndex &index) { +void CollectionDirectoryModel::RemoveDirectory(const QModelIndex &idx) { - if (!backend_ || !index.isValid()) return; + if (!backend_ || !idx.isValid()) return; Directory dir; - dir.path = index.data().toString(); - dir.id = index.data(kIdRole).toInt(); + dir.path = idx.data().toString(); + dir.id = idx.data(kIdRole).toInt(); backend_->RemoveDirectory(dir); } -QVariant CollectionDirectoryModel::data(const QModelIndex &index, int role) const { +QVariant CollectionDirectoryModel::data(const QModelIndex &idx, int role) const { switch (role) { case MusicStorage::Role_Storage: case MusicStorage::Role_StorageForceConnect: - return QVariant::fromValue(storage_[index.row()]); + return QVariant::fromValue(storage_[idx.row()]); case MusicStorage::Role_FreeSpace: - return Utilities::FileSystemFreeSpace(data(index, Qt::DisplayRole).toString()); + return Utilities::FileSystemFreeSpace(data(idx, Qt::DisplayRole).toString()); case MusicStorage::Role_Capacity: - return Utilities::FileSystemCapacity(data(index, Qt::DisplayRole).toString()); + return Utilities::FileSystemCapacity(data(idx, Qt::DisplayRole).toString()); default: - return QStandardItemModel::data(index, role); + return QStandardItemModel::data(idx, role); } } - diff --git a/src/collection/collectiondirectorymodel.h b/src/collection/collectiondirectorymodel.h index a5d352a5..55ab6740 100644 --- a/src/collection/collectiondirectorymodel.h +++ b/src/collection/collectiondirectorymodel.h @@ -42,14 +42,14 @@ class CollectionDirectoryModel : public QStandardItemModel { Q_OBJECT public: - explicit CollectionDirectoryModel(CollectionBackend* backend, QObject *parent = nullptr); + explicit CollectionDirectoryModel(CollectionBackend *backend, QObject *parent = nullptr); ~CollectionDirectoryModel() override; // To be called by GUIs void AddDirectory(const QString &path); - void RemoveDirectory(const QModelIndex &index); + void RemoveDirectory(const QModelIndex &idx); - QVariant data(const QModelIndex &index, int role) const override; + QVariant data(const QModelIndex &idx, int role) const override; private slots: // To be called by the backend @@ -61,7 +61,7 @@ class CollectionDirectoryModel : public QStandardItemModel { QIcon dir_icon_; CollectionBackend* backend_; - QList > storage_; + QList> storage_; }; #endif // COLLECTIONDIRECTORYMODEL_H diff --git a/src/collection/collectionfilterwidget.cpp b/src/collection/collectionfilterwidget.cpp index 22533027..79dcd9d5 100644 --- a/src/collection/collectionfilterwidget.cpp +++ b/src/collection/collectionfilterwidget.cpp @@ -85,8 +85,8 @@ CollectionFilterWidget::CollectionFilterWidget(QWidget *parent) QString("

") ); - connect(ui_->filter, SIGNAL(returnPressed()), SIGNAL(ReturnPressed())); - connect(filter_delay_, SIGNAL(timeout()), SLOT(FilterDelayTimeout())); + QObject::connect(ui_->filter, &QSearchField::returnPressed, this, &CollectionFilterWidget::ReturnPressed); + QObject::connect(filter_delay_, &QTimer::timeout, this, &CollectionFilterWidget::FilterDelayTimeout); filter_delay_->setInterval(kFilterDelay); filter_delay_->setSingleShot(true); @@ -119,9 +119,9 @@ CollectionFilterWidget::CollectionFilterWidget(QWidget *parent) group_by_menu_ = new QMenu(tr("Group by"), this); group_by_menu_->addActions(group_by_group_->actions()); - connect(group_by_group_, SIGNAL(triggered(QAction*)), SLOT(GroupByClicked(QAction*))); - connect(ui_->save_grouping, SIGNAL(triggered()), this, SLOT(SaveGroupBy())); - connect(ui_->manage_groupings, SIGNAL(triggered()), this, SLOT(ShowGroupingManager())); + QObject::connect(group_by_group_, &QActionGroup::triggered, this, &CollectionFilterWidget::GroupByClicked); + QObject::connect(ui_->save_grouping, &QAction::triggered, this, &CollectionFilterWidget::SaveGroupBy); + QObject::connect(ui_->manage_groupings, &QAction::triggered, this, &CollectionFilterWidget::ShowGroupingManager); // Collection config menu collection_menu_ = new QMenu(tr("Display options"), this); @@ -133,7 +133,7 @@ CollectionFilterWidget::CollectionFilterWidget(QWidget *parent) collection_menu_->addSeparator(); ui_->options->setMenu(collection_menu_); - connect(ui_->filter, SIGNAL(textChanged(QString)), SLOT(FilterTextChanged(QString))); + QObject::connect(ui_->filter, &QSearchField::textChanged, this, &CollectionFilterWidget::FilterTextChanged); ReloadSettings(); @@ -179,14 +179,14 @@ QString CollectionFilterWidget::group_by(const int number) { return group_by() + void CollectionFilterWidget::UpdateGroupByActions() { if (group_by_group_) { - disconnect(group_by_group_, nullptr, nullptr, nullptr); + QObject::disconnect(group_by_group_, nullptr, this, nullptr); delete group_by_group_; } group_by_group_ = CreateGroupByActions(this); group_by_menu_->clear(); group_by_menu_->addActions(group_by_group_->actions()); - connect(group_by_group_, SIGNAL(triggered(QAction*)), SLOT(GroupByClicked(QAction*))); + QObject::connect(group_by_group_, &QActionGroup::triggered, this, &CollectionFilterWidget::GroupByClicked); if (model_) { CheckCurrentGrouping(model_->GetGroupBy()); } @@ -300,24 +300,24 @@ void CollectionFilterWidget::FocusOnFilter(QKeyEvent *event) { void CollectionFilterWidget::SetCollectionModel(CollectionModel *model) { if (model_) { - disconnect(model_, nullptr, this, nullptr); - disconnect(model_, nullptr, group_by_dialog_.get(), nullptr); - disconnect(group_by_dialog_.get(), nullptr, model_, nullptr); + QObject::disconnect(model_, nullptr, this, nullptr); + QObject::disconnect(model_, nullptr, group_by_dialog_.get(), nullptr); + QObject::disconnect(group_by_dialog_.get(), nullptr, model_, nullptr); for (QAction *action : filter_ages_.keys()) { - disconnect(action, &QAction::triggered, model_, nullptr); + QObject::disconnect(action, &QAction::triggered, model_, nullptr); } } model_ = model; // Connect signals - connect(model_, SIGNAL(GroupingChanged(CollectionModel::Grouping)), group_by_dialog_.get(), SLOT(CollectionGroupingChanged(CollectionModel::Grouping))); - connect(model_, SIGNAL(GroupingChanged(CollectionModel::Grouping)), SLOT(GroupingChanged(CollectionModel::Grouping))); - connect(group_by_dialog_.get(), SIGNAL(Accepted(CollectionModel::Grouping)), model_, SLOT(SetGroupBy(CollectionModel::Grouping))); + QObject::connect(model_, &CollectionModel::GroupingChanged, group_by_dialog_.get(), &GroupByDialog::CollectionGroupingChanged); + QObject::connect(model_, &CollectionModel::GroupingChanged, this, &CollectionFilterWidget::GroupingChanged); + QObject::connect(group_by_dialog_.get(), &GroupByDialog::Accepted, model_, &CollectionModel::SetGroupBy); for (QAction *action : filter_ages_.keys()) { int age = filter_ages_[action]; - connect(action, &QAction::triggered, [this, age]() { model_->SetFilterAge(age); } ); + QObject::connect(action, &QAction::triggered, [this, age]() { model_->SetFilterAge(age); } ); } // Load settings diff --git a/src/collection/collectionfilterwidget.h b/src/collection/collectionfilterwidget.h index ea64c487..f190ed45 100644 --- a/src/collection/collectionfilterwidget.h +++ b/src/collection/collectionfilterwidget.h @@ -90,7 +90,7 @@ class CollectionFilterWidget : public QWidget { void UpPressed(); void DownPressed(); void ReturnPressed(); - void Filter(const QString &text); + void Filter(QString text); protected: void keyReleaseEvent(QKeyEvent *e) override; diff --git a/src/collection/collectionitemdelegate.cpp b/src/collection/collectionitemdelegate.cpp index 7bb1f97e..63d26519 100644 --- a/src/collection/collectionitemdelegate.cpp +++ b/src/collection/collectionitemdelegate.cpp @@ -48,12 +48,12 @@ CollectionItemDelegate::CollectionItemDelegate(QObject *parent) : QStyledItemDelegate(parent) {} -void CollectionItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &index) const { +void CollectionItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &idx) const { - const bool is_divider = index.data(CollectionModel::Role_IsDivider).toBool(); + const bool is_divider = idx.data(CollectionModel::Role_IsDivider).toBool(); if (is_divider) { - QString text(index.data().toString()); + QString text(idx.data().toString()); painter->save(); @@ -61,7 +61,7 @@ void CollectionItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem // Does this item have an icon? QPixmap pixmap; - QVariant decoration = index.data(Qt::DecorationRole); + QVariant decoration = idx.data(Qt::DecorationRole); if (!decoration.isNull()) { if (decoration.canConvert()) { pixmap = decoration.value(); @@ -113,35 +113,35 @@ void CollectionItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem painter->restore(); } else { - QStyledItemDelegate::paint(painter, opt, index); + QStyledItemDelegate::paint(painter, opt, idx); } } -bool CollectionItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index) { +bool CollectionItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &idx) { Q_UNUSED(option); if (!event || !view) return false; QHelpEvent *he = static_cast(event); - QString text = displayText(index.data(), QLocale::system()); + QString text = displayText(idx.data(), QLocale::system()); if (text.isEmpty() || !he) return false; switch (event->type()) { case QEvent::ToolTip: { - QSize real_text = sizeHint(option, index); - QRect displayed_text = view->visualRect(index); + QSize real_text = sizeHint(option, idx); + QRect displayed_text = view->visualRect(idx); bool is_elided = displayed_text.width() < real_text.width(); if (is_elided) { QToolTip::showText(he->globalPos(), text, view); } - else if (index.data(Qt::ToolTipRole).isValid()) { + else if (idx.data(Qt::ToolTipRole).isValid()) { // If the item has a tooltip text, display it - QString tooltip_text = index.data(Qt::ToolTipRole).toString(); + QString tooltip_text = idx.data(Qt::ToolTipRole).toString(); QToolTip::showText(he->globalPos(), tooltip_text, view); } else { diff --git a/src/collection/collectionitemdelegate.h b/src/collection/collectionitemdelegate.h index 168f0746..c4e0c837 100644 --- a/src/collection/collectionitemdelegate.h +++ b/src/collection/collectionitemdelegate.h @@ -37,10 +37,10 @@ class CollectionItemDelegate : public QStyledItemDelegate { public: explicit CollectionItemDelegate(QObject *parent); - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override; public slots: - bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index) override; + bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &idx) override; }; #endif // COLLECTIONITEMDELEGATE_H diff --git a/src/collection/collectionmodel.cpp b/src/collection/collectionmodel.cpp index 2f4e4ead..d3fe7142 100644 --- a/src/collection/collectionmodel.cpp +++ b/src/collection/collectionmodel.cpp @@ -107,7 +107,7 @@ CollectionModel::CollectionModel(CollectionBackend *backend, Application *app, Q cover_loader_options_.scale_output_image_ = true; if (app_) { - connect(app_->album_cover_loader(), SIGNAL(AlbumCoverLoaded(quint64, AlbumCoverLoaderResult)), SLOT(AlbumCoverLoaded(quint64, AlbumCoverLoaderResult))); + QObject::connect(app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &CollectionModel::AlbumCoverLoaded); } QIcon nocover = IconLoader::Load("cdcase"); @@ -118,17 +118,17 @@ CollectionModel::CollectionModel(CollectionBackend *backend, Application *app, Q if (app_ && !sIconCache) { sIconCache = new QNetworkDiskCache(this); sIconCache->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/" + kPixmapDiskCacheDir); - connect(app_, SIGNAL(ClearPixmapDiskCache()), SLOT(ClearDiskCache())); + QObject::connect(app_, &Application::ClearPixmapDiskCache, this, &CollectionModel::ClearDiskCache); } - connect(backend_, SIGNAL(SongsDiscovered(SongList)), SLOT(SongsDiscovered(SongList))); - connect(backend_, SIGNAL(SongsDeleted(SongList)), SLOT(SongsDeleted(SongList))); - connect(backend_, SIGNAL(DatabaseReset()), SLOT(Reset())); - connect(backend_, SIGNAL(TotalSongCountUpdated(int)), SLOT(TotalSongCountUpdatedSlot(int))); - connect(backend_, SIGNAL(TotalArtistCountUpdated(int)), SLOT(TotalArtistCountUpdatedSlot(int))); - connect(backend_, SIGNAL(TotalAlbumCountUpdated(int)), SLOT(TotalAlbumCountUpdatedSlot(int))); - connect(backend_, SIGNAL(SongsStatisticsChanged(SongList)), SLOT(SongsSlightlyChanged(SongList))); - connect(backend_, SIGNAL(SongsRatingChanged(SongList)), SLOT(SongsSlightlyChanged(SongList))); + QObject::connect(backend_, &CollectionBackend::SongsDiscovered, this, &CollectionModel::SongsDiscovered); + QObject::connect(backend_, &CollectionBackend::SongsDeleted, this, &CollectionModel::SongsDeleted); + QObject::connect(backend_, &CollectionBackend::DatabaseReset, this, &CollectionModel::Reset); + QObject::connect(backend_, &CollectionBackend::TotalSongCountUpdated, this, &CollectionModel::TotalSongCountUpdatedSlot); + QObject::connect(backend_, &CollectionBackend::TotalArtistCountUpdated, this, &CollectionModel::TotalArtistCountUpdatedSlot); + QObject::connect(backend_, &CollectionBackend::TotalAlbumCountUpdated, this, &CollectionModel::TotalAlbumCountUpdatedSlot); + QObject::connect(backend_, &CollectionBackend::SongsStatisticsChanged, this, &CollectionModel::SongsSlightlyChanged); + QObject::connect(backend_, &CollectionBackend::SongsRatingChanged, this, &CollectionModel::SongsSlightlyChanged); backend_->UpdateTotalSongCountAsync(); backend_->UpdateTotalArtistCountAsync(); @@ -909,12 +909,14 @@ void CollectionModel::LazyPopulate(CollectionItem *parent, const bool signal) { } void CollectionModel::ResetAsync() { + #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QFuture future = QtConcurrent::run(&CollectionModel::RunQuery, this, root_); #else QFuture future = QtConcurrent::run(this, &CollectionModel::RunQuery, root_); #endif NewClosure(future, this, SLOT(ResetAsyncQueryFinished(QFuture)), future); + } void CollectionModel::ResetAsyncQueryFinished(QFuture future) { diff --git a/src/collection/collectionmodel.h b/src/collection/collectionmodel.h index 4bc19c95..4879faa1 100644 --- a/src/collection/collectionmodel.h +++ b/src/collection/collectionmodel.h @@ -196,10 +196,10 @@ class CollectionModel : public SimpleTreeModel { void ExpandAll(CollectionItem *item = nullptr) const; signals: - void TotalSongCountUpdated(const int count); - void TotalArtistCountUpdated(const int count); - void TotalAlbumCountUpdated(const int count); - void GroupingChanged(const CollectionModel::Grouping &g); + void TotalSongCountUpdated(int count); + void TotalArtistCountUpdated(int count); + void TotalAlbumCountUpdated(int count); + void GroupingChanged(CollectionModel::Grouping g); public slots: void SetFilterAge(const int age); @@ -212,13 +212,14 @@ class CollectionModel : public SimpleTreeModel { void Reset(); void ResetAsync(); + void SongsDiscovered(const SongList &songs); + protected: void LazyPopulate(CollectionItem *item) override { LazyPopulate(item, true); } void LazyPopulate(CollectionItem *parent, const bool signal); private slots: // From CollectionBackend - void SongsDiscovered(const SongList &songs); void SongsDeleted(const SongList &songs); void SongsSlightlyChanged(const SongList &songs); void TotalSongCountUpdatedSlot(const int count); diff --git a/src/collection/collectionview.cpp b/src/collection/collectionview.cpp index afef9ec1..50f32e9e 100644 --- a/src/collection/collectionview.cpp +++ b/src/collection/collectionview.cpp @@ -338,33 +338,33 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) { if (!context_menu_) { context_menu_ = new QMenu(this); - action_add_to_playlist_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, SLOT(AddToPlaylist())); - action_load_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, SLOT(Load())); - action_open_in_new_playlist_ = context_menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, SLOT(OpenInNewPlaylist())); + action_add_to_playlist_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, &CollectionView::AddToPlaylist); + action_load_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, &CollectionView::Load); + action_open_in_new_playlist_ = context_menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, &CollectionView::OpenInNewPlaylist); context_menu_->addSeparator(); - action_add_to_playlist_enqueue_ = context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue track"), this, SLOT(AddToPlaylistEnqueue())); - action_add_to_playlist_enqueue_next_ = context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue to play next"), this, SLOT(AddToPlaylistEnqueueNext())); + action_add_to_playlist_enqueue_ = context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue track"), this, &CollectionView::AddToPlaylistEnqueue); + action_add_to_playlist_enqueue_next_ = context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue to play next"), this, &CollectionView::AddToPlaylistEnqueueNext); context_menu_->addSeparator(); - action_organize_ = context_menu_->addAction(IconLoader::Load("edit-copy"), tr("Organize files..."), this, SLOT(Organize())); + action_organize_ = context_menu_->addAction(IconLoader::Load("edit-copy"), tr("Organize files..."), this, &CollectionView::Organize); #ifndef Q_OS_WIN - action_copy_to_device_ = context_menu_->addAction(IconLoader::Load("device"), tr("Copy to device..."), this, SLOT(CopyToDevice())); + action_copy_to_device_ = context_menu_->addAction(IconLoader::Load("device"), tr("Copy to device..."), this, &CollectionView::CopyToDevice); #endif - action_delete_files_ = context_menu_->addAction(IconLoader::Load("edit-delete"), tr("Delete from disk..."), this, SLOT(Delete())); + action_delete_files_ = context_menu_->addAction(IconLoader::Load("edit-delete"), tr("Delete from disk..."), this, &CollectionView::Delete); context_menu_->addSeparator(); - action_edit_track_ = context_menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit track information..."), this, SLOT(EditTracks())); - action_edit_tracks_ = context_menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit tracks information..."), this, SLOT(EditTracks())); - action_show_in_browser_ = context_menu_->addAction(IconLoader::Load("document-open-folder"), tr("Show in file browser..."), this, SLOT(ShowInBrowser())); + action_edit_track_ = context_menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit track information..."), this, &CollectionView::EditTracks); + action_edit_tracks_ = context_menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit tracks information..."), this, &CollectionView::EditTracks); + action_show_in_browser_ = context_menu_->addAction(IconLoader::Load("document-open-folder"), tr("Show in file browser..."), this, &CollectionView::ShowInBrowser); context_menu_->addSeparator(); - action_rescan_songs_ = context_menu_->addAction(tr("Rescan song(s)"), this, SLOT(RescanSongs())); + action_rescan_songs_ = context_menu_->addAction(tr("Rescan song(s)"), this, &CollectionView::RescanSongs); context_menu_->addSeparator(); - action_show_in_various_ = context_menu_->addAction( tr("Show in various artists"), this, SLOT(ShowInVarious())); - action_no_show_in_various_ = context_menu_->addAction( tr("Don't show in various artists"), this, SLOT(NoShowInVarious())); + action_show_in_various_ = context_menu_->addAction(tr("Show in various artists"), this, &CollectionView::ShowInVarious); + action_no_show_in_various_ = context_menu_->addAction(tr("Don't show in various artists"), this, &CollectionView::NoShowInVarious); context_menu_->addSeparator(); @@ -372,7 +372,7 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) { #ifndef Q_OS_WIN action_copy_to_device_->setDisabled(app_->device_manager()->connected_devices_model()->rowCount() == 0); - connect(app_->device_manager()->connected_devices_model(), SIGNAL(IsEmptyChanged(bool)), action_copy_to_device_, SLOT(setDisabled(bool))); + QObject::connect(app_->device_manager()->connected_devices_model(), &DeviceStateFilterModel::IsEmptyChanged, action_copy_to_device_, &QAction::setDisabled); #endif } @@ -387,9 +387,9 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) { int regular_elements = 0; int regular_editable = 0; - for (const QModelIndex &index : selected_indexes) { + for (const QModelIndex &idx : selected_indexes) { ++regular_elements; - if(app_->collection_model()->data(index, CollectionModel::Role_Editable).toBool()) { + if (app_->collection_model()->data(idx, CollectionModel::Role_Editable).toBool()) { ++regular_editable; } } @@ -442,11 +442,11 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) { } -void CollectionView::ShowInVarious() { ShowInVarious(true); } +void CollectionView::ShowInVarious() { SetShowInVarious(true); } -void CollectionView::NoShowInVarious() { ShowInVarious(false); } +void CollectionView::NoShowInVarious() { SetShowInVarious(false); } -void CollectionView::ShowInVarious(const bool on) { +void CollectionView::SetShowInVarious(const bool on) { if (!context_menu_index_.isValid()) return; @@ -547,12 +547,12 @@ void CollectionView::keyboardSearch(const QString &search) { } -void CollectionView::scrollTo(const QModelIndex &index, ScrollHint hint) { +void CollectionView::scrollTo(const QModelIndex &idx, ScrollHint hint) { if (is_in_keyboard_search_) - QTreeView::scrollTo(index, QAbstractItemView::PositionAtTop); + QTreeView::scrollTo(idx, QAbstractItemView::PositionAtTop); else - QTreeView::scrollTo(index, hint); + QTreeView::scrollTo(idx, hint); } @@ -582,7 +582,7 @@ void CollectionView::EditTracks() { if (!edit_tag_dialog_) { edit_tag_dialog_.reset(new EditTagDialog(app_, this)); - connect(edit_tag_dialog_.get(), SIGNAL(Error(QString)), SLOT(EditTagError(QString))); + QObject::connect(edit_tag_dialog_.get(), &EditTagDialog::Error, this, &CollectionView::EditTagError); } edit_tag_dialog_->SetSongs(GetSelectedSongs()); edit_tag_dialog_->show(); @@ -668,7 +668,7 @@ void CollectionView::Delete() { std::shared_ptr storage = app_->collection_model()->directory_model()->index(0, 0).data(MusicStorage::Role_Storage).value>(); DeleteFiles *delete_files = new DeleteFiles(app_->task_manager(), storage, true); - connect(delete_files, SIGNAL(Finished(SongList)), SLOT(DeleteFinished(SongList))); + QObject::connect(delete_files, &DeleteFiles::Finished, this, &CollectionView::DeleteFilesFinished); delete_files->Start(selected_songs); } diff --git a/src/collection/collectionview.h b/src/collection/collectionview.h index 723acb9e..4083591a 100644 --- a/src/collection/collectionview.h +++ b/src/collection/collectionview.h @@ -63,7 +63,7 @@ class CollectionView : public AutoExpandingTreeView { // QTreeView void keyboardSearch(const QString &search) override; - void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override; + void scrollTo(const QModelIndex &idx, ScrollHint hint = EnsureVisible) override; int TotalSongs(); int TotalArtists(); @@ -114,7 +114,7 @@ class CollectionView : public AutoExpandingTreeView { private: void RecheckIsEmpty(); - void ShowInVarious(const bool on); + void SetShowInVarious(const bool on); bool RestoreLevelFocus(const QModelIndex &parent = QModelIndex()); void SaveContainerPath(const QModelIndex &child); diff --git a/src/collection/collectionviewcontainer.cpp b/src/collection/collectionviewcontainer.cpp index 411a1ac5..1dabf740 100644 --- a/src/collection/collectionviewcontainer.cpp +++ b/src/collection/collectionviewcontainer.cpp @@ -33,10 +33,10 @@ CollectionViewContainer::CollectionViewContainer(QWidget *parent) : QWidget(pare ui_->setupUi(this); view()->SetFilter(filter()); - connect(filter(), SIGNAL(UpPressed()), view(), SLOT(UpAndFocus())); - connect(filter(), SIGNAL(DownPressed()), view(), SLOT(DownAndFocus())); - connect(filter(), SIGNAL(ReturnPressed()), view(), SLOT(FilterReturnPressed())); - connect(view(), SIGNAL(FocusOnFilterSignal(QKeyEvent*)), filter(), SLOT(FocusOnFilter(QKeyEvent*))); + QObject::connect(filter(), &CollectionFilterWidget::UpPressed, view(), &CollectionView::UpAndFocus); + QObject::connect(filter(), &CollectionFilterWidget::DownPressed, view(), &CollectionView::DownAndFocus); + QObject::connect(filter(), &CollectionFilterWidget::ReturnPressed, view(), &CollectionView::FilterReturnPressed); + QObject::connect(view(), &CollectionView::FocusOnFilterSignal, filter(), &CollectionFilterWidget::FocusOnFilter); ReloadSettings(); diff --git a/src/collection/collectionwatcher.cpp b/src/collection/collectionwatcher.cpp index b5678f1d..b5222b42 100644 --- a/src/collection/collectionwatcher.cpp +++ b/src/collection/collectionwatcher.cpp @@ -91,7 +91,8 @@ CollectionWatcher::CollectionWatcher(Song::Source source, QObject *parent) ReloadSettings(); - connect(rescan_timer_, SIGNAL(timeout()), SLOT(RescanPathsNow())); + QObject::connect(rescan_timer_, &QTimer::timeout, this, &CollectionWatcher::RescanPathsNow); + } void CollectionWatcher::ExitAsync() { @@ -644,7 +645,7 @@ void CollectionWatcher::AddWatch(const Directory &dir, const QString &path) { if (!QFile::exists(path)) return; - connect(fs_watcher_, SIGNAL(PathChanged(QString)), this, SLOT(DirectoryChanged(QString)), Qt::UniqueConnection); + QObject::connect(fs_watcher_, &FileSystemWatcherInterface::PathChanged, this, &CollectionWatcher::DirectoryChanged, Qt::UniqueConnection); fs_watcher_->AddPath(path); subdir_mapping_[path] = dir; diff --git a/src/collection/collectionwatcher.h b/src/collection/collectionwatcher.h index c9e8cc21..2e548de5 100644 --- a/src/collection/collectionwatcher.h +++ b/src/collection/collectionwatcher.h @@ -65,13 +65,13 @@ class CollectionWatcher : public QObject { void ExitAsync(); signals: - void NewOrUpdatedSongs(const SongList &songs); - void SongsMTimeUpdated(const SongList &songs); - void SongsDeleted(const SongList &songs); - void SongsUnavailable(const SongList &songs); - void SongsReadded(const SongList &songs, bool unavailable = false); - void SubdirsDiscovered(const SubdirectoryList &subdirs); - void SubdirsMTimeUpdated(const SubdirectoryList &subdirs); + void NewOrUpdatedSongs(SongList); + void SongsMTimeUpdated(SongList); + void SongsDeleted(SongList); + void SongsUnavailable(SongList songs, bool unavailable = true); + void SongsReadded(SongList songs, bool unavailable = false); + void SubdirsDiscovered(SubdirectoryList subdirs); + void SubdirsMTimeUpdated(SubdirectoryList subdirs); void CompilationsNeedUpdating(); void ExitFinished(); diff --git a/src/collection/groupbydialog.cpp b/src/collection/groupbydialog.cpp index 9f465116..2d8f72f3 100644 --- a/src/collection/groupbydialog.cpp +++ b/src/collection/groupbydialog.cpp @@ -102,7 +102,7 @@ GroupByDialog::GroupByDialog(QWidget *parent) : QDialog(parent), ui_(new Ui_Grou p_->mapping_.insert(Mapping(CollectionModel::GroupBy_Bitdepth, 18)); p_->mapping_.insert(Mapping(CollectionModel::GroupBy_Bitrate, 19)); - connect(ui_->buttonbox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), SLOT(Reset())); + QObject::connect(ui_->buttonbox->button(QDialogButtonBox::Reset), &QPushButton::clicked, this, &GroupByDialog::Reset); resize(sizeHint()); diff --git a/src/collection/groupbydialog.h b/src/collection/groupbydialog.h index 3d0bcfdd..219eaec6 100644 --- a/src/collection/groupbydialog.h +++ b/src/collection/groupbydialog.h @@ -48,7 +48,7 @@ class GroupByDialog : public QDialog { void accept() override; signals: - void Accepted(const CollectionModel::Grouping &g); + void Accepted(CollectionModel::Grouping g); private slots: void Reset(); diff --git a/src/collection/savedgroupingmanager.cpp b/src/collection/savedgroupingmanager.cpp index 17c7092c..1e242723 100644 --- a/src/collection/savedgroupingmanager.cpp +++ b/src/collection/savedgroupingmanager.cpp @@ -61,9 +61,10 @@ SavedGroupingManager::SavedGroupingManager(QWidget *parent) ui_->remove->setEnabled(false); ui_->remove->setShortcut(QKeySequence::Delete); - connect(ui_->list->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), SLOT(UpdateButtonState())); + QObject::connect(ui_->list->selectionModel(), &QItemSelectionModel::selectionChanged, this, &SavedGroupingManager::UpdateButtonState); + + QObject::connect(ui_->remove, &QPushButton::clicked, this, &SavedGroupingManager::Remove); - connect(ui_->remove, SIGNAL(clicked()), SLOT(Remove())); } SavedGroupingManager::~SavedGroupingManager() { @@ -184,10 +185,10 @@ void SavedGroupingManager::Remove() { if (ui_->list->selectionModel()->hasSelection()) { QSettings s; s.beginGroup(CollectionModel::kSavedGroupingsSettingsGroup); - for (const QModelIndex &index : ui_->list->selectionModel()->selectedRows()) { - if (index.isValid()) { - qLog(Debug) << "Remove saved grouping: " << model_->item(index.row(), 0)->text(); - s.remove(model_->item(index.row(), 0)->text()); + for (const QModelIndex &idx : ui_->list->selectionModel()->selectedRows()) { + if (idx.isValid()) { + qLog(Debug) << "Remove saved grouping: " << model_->item(idx.row(), 0)->text(); + s.remove(model_->item(idx.row(), 0)->text()); } } s.endGroup(); diff --git a/src/collection/savedgroupingmanager.h b/src/collection/savedgroupingmanager.h index 97379ab1..079880e0 100644 --- a/src/collection/savedgroupingmanager.h +++ b/src/collection/savedgroupingmanager.h @@ -43,7 +43,7 @@ class SavedGroupingManager : public QDialog { ~SavedGroupingManager() override; void UpdateModel(); - void SetFilter(CollectionFilterWidget* filter) { filter_ = filter; } + void SetFilter(CollectionFilterWidget *filter) { filter_ = filter; } static QString GroupByToString(const CollectionModel::GroupBy &g); @@ -52,7 +52,7 @@ class SavedGroupingManager : public QDialog { void Remove(); private: - Ui_SavedGroupingManager* ui_; + Ui_SavedGroupingManager *ui_; QStandardItemModel *model_; CollectionFilterWidget *filter_; }; diff --git a/src/context/contextalbum.cpp b/src/context/contextalbum.cpp index ef01d2ab..1eb70f5f 100644 --- a/src/context/contextalbum.cpp +++ b/src/context/contextalbum.cpp @@ -65,7 +65,7 @@ ContextAlbum::ContextAlbum(QWidget *parent) : QPair images = AlbumCoverLoader::ScaleAndPad(cover_loader_options_, image_strawberry_); pixmap_current_ = QPixmap::fromImage(images.first); - connect(timeline_fade_, SIGNAL(valueChanged(qreal)), SLOT(FadePreviousTrack(qreal))); + QObject::connect(timeline_fade_, &QTimeLine::valueChanged, this, &ContextAlbum::FadePreviousTrack); timeline_fade_->setDirection(QTimeLine::Backward); // 1.0 -> 0.0 } @@ -75,7 +75,7 @@ void ContextAlbum::Init(ContextView *context_view, AlbumCoverChoiceController *a context_view_ = context_view; album_cover_choice_controller_ = album_cover_choice_controller; - connect(album_cover_choice_controller_, SIGNAL(AutomaticCoverSearchDone()), this, SLOT(AutomaticCoverSearchDone())); + QObject::connect(album_cover_choice_controller_, &AlbumCoverChoiceController::AutomaticCoverSearchDone, this, &ContextAlbum::AutomaticCoverSearchDone); QList cover_actions = album_cover_choice_controller_->GetAllActions(); cover_actions.append(album_cover_choice_controller_->search_cover_auto_action()); @@ -188,7 +188,7 @@ void ContextAlbum::SearchCoverInProgress() { // Show a spinner animation spinner_animation_.reset(new QMovie(":/pictures/spinner.gif", QByteArray(), this)); - connect(spinner_animation_.get(), SIGNAL(updated(QRect)), SLOT(update())); + QObject::connect(spinner_animation_.get(), &QMovie::updated, this, &ContextAlbum::Update); spinner_animation_->start(); update(); diff --git a/src/context/contextalbum.h b/src/context/contextalbum.h index 37aa6225..dfc419b3 100644 --- a/src/context/contextalbum.h +++ b/src/context/contextalbum.h @@ -65,10 +65,13 @@ class ContextAlbum : public QWidget { void FadeStopFinished(); private slots: - void SearchCoverInProgress(); + void Update() { update(); } void AutomaticCoverSearchDone(); void FadePreviousTrack(const qreal value); + public slots: + void SearchCoverInProgress(); + private: static const int kWidgetSpacing; diff --git a/src/context/contextalbumsmodel.cpp b/src/context/contextalbumsmodel.cpp index 623db3f4..8f3d4960 100644 --- a/src/context/contextalbumsmodel.cpp +++ b/src/context/contextalbumsmodel.cpp @@ -71,7 +71,7 @@ ContextAlbumsModel::ContextAlbumsModel(CollectionBackend *backend, Application * cover_loader_options_.pad_output_image_ = true; cover_loader_options_.scale_output_image_ = true; - connect(app_->album_cover_loader(), SIGNAL(AlbumCoverLoaded(quint64, AlbumCoverLoaderResult)), SLOT(AlbumCoverLoaded(quint64, AlbumCoverLoaderResult))); + QObject::connect(app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &ContextAlbumsModel::AlbumCoverLoaded); QIcon nocover = IconLoader::Load("cdcase"); no_cover_icon_ = nocover.pixmap(nocover.availableSizes().last()).scaled(kPrettyCoverSize, kPrettyCoverSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); @@ -104,10 +104,10 @@ void ContextAlbumsModel::AddSongs(const SongList &songs) { } -QString ContextAlbumsModel::AlbumIconPixmapCacheKey(const QModelIndex &index) const { +QString ContextAlbumsModel::AlbumIconPixmapCacheKey(const QModelIndex &idx) const { QStringList path; - QModelIndex index_copy(index); + QModelIndex index_copy(idx); while (index_copy.isValid()) { path.prepend(index_copy.data().toString()); index_copy = index_copy.parent(); @@ -116,13 +116,13 @@ QString ContextAlbumsModel::AlbumIconPixmapCacheKey(const QModelIndex &index) co } -QVariant ContextAlbumsModel::AlbumIcon(const QModelIndex &index) { +QVariant ContextAlbumsModel::AlbumIcon(const QModelIndex &idx) { - CollectionItem *item = IndexToItem(index); + CollectionItem *item = IndexToItem(idx); if (!item) return no_cover_icon_; // Check the cache for a pixmap we already loaded. - const QString cache_key = AlbumIconPixmapCacheKey(index); + const QString cache_key = AlbumIconPixmapCacheKey(idx); QPixmap cached_pixmap; if (QPixmapCache::find(cache_key, &cached_pixmap)) { @@ -135,7 +135,7 @@ QVariant ContextAlbumsModel::AlbumIcon(const QModelIndex &index) { } // No art is cached and we're not loading it already. Load art for the first song in the album. - SongList songs = GetChildSongs(index); + SongList songs = GetChildSongs(idx); if (!songs.isEmpty()) { const quint64 id = app_->album_cover_loader()->LoadImageAsync(cover_loader_options_, songs.first()); pending_art_[id] = ItemAndCacheKey(item, cache_key); @@ -169,17 +169,17 @@ void ContextAlbumsModel::AlbumCoverLoaded(const quint64 id, const AlbumCoverLoad QPixmapCache::insert(cache_key, image_pixmap); } - const QModelIndex index = ItemToIndex(item); - emit dataChanged(index, index); + const QModelIndex idx = ItemToIndex(item); + emit dataChanged(idx, idx); } -QVariant ContextAlbumsModel::data(const QModelIndex &index, int role) const { +QVariant ContextAlbumsModel::data(const QModelIndex &idx, int role) const { - const CollectionItem *item = IndexToItem(index); + const CollectionItem *item = IndexToItem(idx); if (role == Qt::DecorationRole && item->type == CollectionItem::Type_Container && item->container_level == 0) { - return const_cast(this)->AlbumIcon(index); + return const_cast(this)->AlbumIcon(idx); } return data(item, role); @@ -401,9 +401,9 @@ QString ContextAlbumsModel::SortTextForSong(const Song &song) { } -Qt::ItemFlags ContextAlbumsModel::flags(const QModelIndex &index) const { +Qt::ItemFlags ContextAlbumsModel::flags(const QModelIndex &idx) const { - switch (IndexToItem(index)->type) { + switch (IndexToItem(idx)->type) { case CollectionItem::Type_Song: case CollectionItem::Type_Container: return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled; @@ -429,8 +429,8 @@ QMimeData *ContextAlbumsModel::mimeData(const QModelIndexList &indexes) const { data->backend = backend_; - for (const QModelIndex &index : indexes) { - GetChildSongs(IndexToItem(index), &urls, &data->songs, &song_ids); + for (const QModelIndex &idx : indexes) { + GetChildSongs(IndexToItem(idx), &urls, &data->songs, &song_ids); } data->setUrls(urls); @@ -489,15 +489,15 @@ SongList ContextAlbumsModel::GetChildSongs(const QModelIndexList &indexes) const SongList ret; QSet song_ids; - for (const QModelIndex &index : indexes) { - GetChildSongs(IndexToItem(index), &dontcare, &ret, &song_ids); + for (const QModelIndex &idx : indexes) { + GetChildSongs(IndexToItem(idx), &dontcare, &ret, &song_ids); } return ret; } -SongList ContextAlbumsModel::GetChildSongs(const QModelIndex &index) const { - return GetChildSongs(QModelIndexList() << index); +SongList ContextAlbumsModel::GetChildSongs(const QModelIndex &idx) const { + return GetChildSongs(QModelIndexList() << idx); } bool ContextAlbumsModel::canFetchMore(const QModelIndex &parent) const { diff --git a/src/context/contextalbumsmodel.h b/src/context/contextalbumsmodel.h index a85e0e4f..2e2d87b9 100644 --- a/src/context/contextalbumsmodel.h +++ b/src/context/contextalbumsmodel.h @@ -78,11 +78,11 @@ class ContextAlbumsModel : public SimpleTreeModel { }; void GetChildSongs(CollectionItem *item, QList *urls, SongList *songs, QSet *song_ids) const; - SongList GetChildSongs(const QModelIndex &index) const; + SongList GetChildSongs(const QModelIndex &idx) const; SongList GetChildSongs(const QModelIndexList &indexes) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - Qt::ItemFlags flags(const QModelIndex &index) const override; + QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override; + Qt::ItemFlags flags(const QModelIndex &idx) const override; QStringList mimeTypes() const override; QMimeData *mimeData(const QModelIndexList &indexes) const override; bool canFetchMore(const QModelIndex &parent) const override; @@ -107,8 +107,8 @@ class ContextAlbumsModel : public SimpleTreeModel { void PostQuery(CollectionItem *parent, const QueryResult &result, bool signal); CollectionItem *ItemFromSong(CollectionItem::Type item_type, bool signal, CollectionItem *parent, const Song &s, int container_level); - QString AlbumIconPixmapCacheKey(const QModelIndex &index) const; - QVariant AlbumIcon(const QModelIndex &index); + QString AlbumIconPixmapCacheKey(const QModelIndex &idx) const; + QVariant AlbumIcon(const QModelIndex &idx); QVariant data(const CollectionItem *item, int role) const; bool CompareItems(const CollectionItem *a, const CollectionItem *b) const; diff --git a/src/context/contextalbumsview.cpp b/src/context/contextalbumsview.cpp index e8c5eee0..9687da38 100644 --- a/src/context/contextalbumsview.cpp +++ b/src/context/contextalbumsview.cpp @@ -63,7 +63,7 @@ ContextItemDelegate::ContextItemDelegate(QObject *parent) : QStyledItemDelegate(parent) {} -bool ContextItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index) { +bool ContextItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &idx) { return true; @@ -72,23 +72,23 @@ bool ContextItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *view, if (!event || !view) return false; QHelpEvent *he = static_cast(event); - QString text = displayText(index.data(), QLocale::system()); + QString text = displayText(idx.data(), QLocale::system()); if (text.isEmpty() || !he) return false; switch (event->type()) { case QEvent::ToolTip: { - QSize real_text = sizeHint(option, index); - QRect displayed_text = view->visualRect(index); + QSize real_text = sizeHint(option, idx); + QRect displayed_text = view->visualRect(idx); bool is_elided = displayed_text.width() < real_text.width(); if (is_elided) { QToolTip::showText(he->globalPos(), text, view); } - else if (index.data(Qt::ToolTipRole).isValid()) { + else if (idx.data(Qt::ToolTipRole).isValid()) { // If the item has a tooltip text, display it - QString tooltip_text = index.data(Qt::ToolTipRole).toString(); + QString tooltip_text = idx.data(Qt::ToolTipRole).toString(); QToolTip::showText(he->globalPos(), tooltip_text, view); } else { @@ -231,8 +231,8 @@ void ContextAlbumsView::Init(Application *app) { setModel(model_); - connect(model_, SIGNAL(modelAboutToBeReset()), this, SLOT(SaveFocus())); - connect(model_, SIGNAL(modelReset()), this, SLOT(RestoreFocus())); + QObject::connect(model_, &ContextAlbumsModel::modelAboutToBeReset, this, &ContextAlbumsView::SaveFocus); + QObject::connect(model_, &ContextAlbumsModel::modelReset, this, &ContextAlbumsView::RestoreFocus); } @@ -249,29 +249,29 @@ void ContextAlbumsView::contextMenuEvent(QContextMenuEvent *e) { if (!context_menu_) { context_menu_ = new QMenu(this); - add_to_playlist_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, SLOT(AddToPlaylist())); - load_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, SLOT(Load())); - open_in_new_playlist_ = context_menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, SLOT(OpenInNewPlaylist())); + add_to_playlist_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, &ContextAlbumsView::AddToPlaylist); + load_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, &ContextAlbumsView::Load); + open_in_new_playlist_ = context_menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, &ContextAlbumsView::OpenInNewPlaylist); context_menu_->addSeparator(); - add_to_playlist_enqueue_ = context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue track"), this, SLOT(AddToPlaylistEnqueue())); + add_to_playlist_enqueue_ = context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue track"), this, &ContextAlbumsView::AddToPlaylistEnqueue); context_menu_->addSeparator(); - organize_ = context_menu_->addAction(IconLoader::Load("edit-copy"), tr("Organize files..."), this, SLOT(Organize())); + organize_ = context_menu_->addAction(IconLoader::Load("edit-copy"), tr("Organize files..."), this, &ContextAlbumsView::Organize); #ifndef Q_OS_WIN - copy_to_device_ = context_menu_->addAction(IconLoader::Load("device"), tr("Copy to device..."), this, SLOT(CopyToDevice())); + copy_to_device_ = context_menu_->addAction(IconLoader::Load("device"), tr("Copy to device..."), this, &ContextAlbumsView::CopyToDevice); #endif context_menu_->addSeparator(); - edit_track_ = context_menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit track information..."), this, SLOT(EditTracks())); - edit_tracks_ = context_menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit tracks information..."), this, SLOT(EditTracks())); - show_in_browser_ = context_menu_->addAction(IconLoader::Load("document-open-folder"), tr("Show in file browser..."), this, SLOT(ShowInBrowser())); + edit_track_ = context_menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit track information..."), this, &ContextAlbumsView::EditTracks); + edit_tracks_ = context_menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit tracks information..."), this, &ContextAlbumsView::EditTracks); + show_in_browser_ = context_menu_->addAction(IconLoader::Load("document-open-folder"), tr("Show in file browser..."), this, &ContextAlbumsView::ShowInBrowser); context_menu_->addSeparator(); #ifndef Q_OS_WIN copy_to_device_->setDisabled(app_->device_manager()->connected_devices_model()->rowCount() == 0); - connect(app_->device_manager()->connected_devices_model(), SIGNAL(IsEmptyChanged(bool)), copy_to_device_, SLOT(setDisabled(bool))); + QObject::connect(app_->device_manager()->connected_devices_model(), &DeviceStateFilterModel::IsEmptyChanged, copy_to_device_, &QAction::setDisabled); #endif } @@ -283,9 +283,9 @@ void ContextAlbumsView::contextMenuEvent(QContextMenuEvent *e) { int regular_elements = 0; int regular_editable = 0; - for (const QModelIndex &index : selected_indexes) { + for (const QModelIndex &idx : selected_indexes) { regular_elements++; - if(model_->data(index, ContextAlbumsModel::Role_Editable).toBool()) { + if (model_->data(idx, ContextAlbumsModel::Role_Editable).toBool()) { regular_editable++; } } @@ -355,12 +355,12 @@ void ContextAlbumsView::OpenInNewPlaylist() { } -void ContextAlbumsView::scrollTo(const QModelIndex &index, ScrollHint hint) { +void ContextAlbumsView::scrollTo(const QModelIndex &idx, ScrollHint hint) { if (is_in_keyboard_search_) - QTreeView::scrollTo(index, QAbstractItemView::PositionAtTop); + QTreeView::scrollTo(idx, QAbstractItemView::PositionAtTop); else - QTreeView::scrollTo(index, hint); + QTreeView::scrollTo(idx, hint); } @@ -414,4 +414,5 @@ void ContextAlbumsView::ShowInBrowser() { } Utilities::OpenInFileBrowser(urls); + } diff --git a/src/context/contextalbumsview.h b/src/context/contextalbumsview.h index 72d384ad..24f8770a 100644 --- a/src/context/contextalbumsview.h +++ b/src/context/contextalbumsview.h @@ -57,7 +57,7 @@ class ContextItemDelegate : public QStyledItemDelegate { explicit ContextItemDelegate(QObject *parent); public slots: - bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index) override; + bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &idx) override; }; class ContextAlbumsView : public AutoExpandingTreeView { @@ -74,7 +74,7 @@ class ContextAlbumsView : public AutoExpandingTreeView { void Init(Application *app); // QTreeView - void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override; + void scrollTo(const QModelIndex &idx, ScrollHint hint = EnsureVisible) override; ContextAlbumsModel *albums_model() { return model_; } diff --git a/src/context/contextview.cpp b/src/context/contextview.cpp index e713a9ec..53fb0beb 100644 --- a/src/context/contextview.cpp +++ b/src/context/contextview.cpp @@ -285,7 +285,7 @@ ContextView::ContextView(QWidget *parent) : QFontDatabase::addApplicationFont(":/fonts/HumongousofEternitySt.ttf"); - connect(widget_album_, SIGNAL(FadeStopFinished()), SLOT(FadeStopFinished())); + QObject::connect(widget_album_, &ContextAlbum::FadeStopFinished, this, &ContextView::FadeStopFinished); } @@ -305,10 +305,10 @@ void ContextView::Init(Application *app, CollectionView *collectionview, AlbumCo widget_albums_->Init(app_); lyrics_fetcher_ = new LyricsFetcher(app_->lyrics_providers(), this); - connect(collectionview_, SIGNAL(TotalSongCountUpdated_()), this, SLOT(UpdateNoSong())); - connect(collectionview_, SIGNAL(TotalArtistCountUpdated_()), this, SLOT(UpdateNoSong())); - connect(collectionview_, SIGNAL(TotalAlbumCountUpdated_()), this, SLOT(UpdateNoSong())); - connect(lyrics_fetcher_, SIGNAL(LyricsFetched(quint64, QString, QString)), this, SLOT(UpdateLyrics(quint64, QString, QString))); + QObject::connect(collectionview_, &CollectionView::TotalSongCountUpdated_, this, &ContextView::UpdateNoSong); + QObject::connect(collectionview_, &CollectionView::TotalArtistCountUpdated_, this, &ContextView::UpdateNoSong); + QObject::connect(collectionview_, &CollectionView::TotalAlbumCountUpdated_, this, &ContextView::UpdateNoSong); + QObject::connect(lyrics_fetcher_, &LyricsFetcher::LyricsFetched, this, &ContextView::UpdateLyrics); AddActions(); @@ -350,12 +350,12 @@ void ContextView::AddActions() { ReloadSettings(); - connect(action_show_album_, SIGNAL(triggered()), this, SLOT(ActionShowAlbums())); - connect(action_show_data_, SIGNAL(triggered()), this, SLOT(ActionShowData())); - connect(action_show_output_, SIGNAL(triggered()), this, SLOT(ActionShowOutput())); - connect(action_show_albums_, SIGNAL(triggered()), this, SLOT(ActionShowAlbums())); - connect(action_show_lyrics_, SIGNAL(triggered()), this, SLOT(ActionShowLyrics())); - connect(action_search_lyrics_, SIGNAL(triggered()), this, SLOT(ActionSearchLyrics())); + QObject::connect(action_show_album_, &QAction::triggered, this, &ContextView::ActionShowAlbums); + QObject::connect(action_show_data_, &QAction::triggered, this, &ContextView::ActionShowData); + QObject::connect(action_show_output_, &QAction::triggered, this, &ContextView::ActionShowOutput); + QObject::connect(action_show_albums_, &QAction::triggered, this, &ContextView::ActionShowAlbums); + QObject::connect(action_show_lyrics_, &QAction::triggered, this, &ContextView::ActionShowLyrics); + QObject::connect(action_search_lyrics_, &QAction::triggered, this, &ContextView::ActionSearchLyrics); } diff --git a/src/context/contextview.h b/src/context/contextview.h index 324f62d6..0a49ff3d 100644 --- a/src/context/contextview.h +++ b/src/context/contextview.h @@ -92,16 +92,16 @@ class ContextView : public QWidget { void ActionShowLyrics(); void ActionSearchLyrics(); void UpdateNoSong(); - void Playing(); - void Stopped(); - void Error(); - void SongChanged(const Song &song); - void AlbumCoverLoaded(const Song &song, const QImage &image); void FadeStopFinished(); void UpdateLyrics(const quint64 id, const QString &provider, const QString &lyrics); public slots: void ReloadSettings(); + void Playing(); + void Stopped(); + void Error(); + void SongChanged(const Song &song); + void AlbumCoverLoaded(const Song &song, const QImage &image); private: Application *app_; diff --git a/src/core/application.cpp b/src/core/application.cpp index 15375853..dbc07acd 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -265,24 +265,24 @@ void Application::Exit() { #endif << internet_services(); - connect(tag_reader_client(), SIGNAL(ExitFinished()), this, SLOT(ExitReceived())); + QObject::connect(tag_reader_client(), &TagReaderClient::ExitFinished, this, &Application::ExitReceived); tag_reader_client()->ExitAsync(); - connect(collection(), SIGNAL(ExitFinished()), this, SLOT(ExitReceived())); + QObject::connect(collection(), &SCollection::ExitFinished, this, &Application::ExitReceived); collection()->Exit(); - connect(playlist_backend(), SIGNAL(ExitFinished()), this, SLOT(ExitReceived())); + QObject::connect(playlist_backend(), &PlaylistBackend::ExitFinished, this, &Application::ExitReceived); playlist_backend()->ExitAsync(); - connect(album_cover_loader(), SIGNAL(ExitFinished()), this, SLOT(ExitReceived())); + QObject::connect(album_cover_loader(), &AlbumCoverLoader::ExitFinished, this, &Application::ExitReceived); album_cover_loader()->ExitAsync(); #ifndef Q_OS_WIN - connect(device_manager(), SIGNAL(ExitFinished()), this, SLOT(ExitReceived())); + QObject::connect(device_manager(), &DeviceManager::ExitFinished, this, &Application::ExitReceived); device_manager()->Exit(); #endif - connect(internet_services(), SIGNAL(ExitFinished()), this, SLOT(ExitReceived())); + QObject::connect(internet_services(), &InternetServices::ExitFinished, this, &Application::ExitReceived); internet_services()->Exit(); } @@ -290,14 +290,14 @@ void Application::Exit() { void Application::ExitReceived() { QObject *obj = static_cast(sender()); - disconnect(obj, nullptr, this, nullptr); + QObject::disconnect(obj, nullptr, this, nullptr); qLog(Debug) << obj << "successfully exited."; wait_for_exit_.removeAll(obj); if (wait_for_exit_.isEmpty()) { database()->Close(); - connect(database(), SIGNAL(ExitFinished()), this, SIGNAL(ExitFinished())); + QObject::connect(database(), &Database::ExitFinished, this, &Application::ExitFinished); database()->ExitAsync(); } diff --git a/src/core/application.h b/src/core/application.h index 80b8f42b..b93682a9 100644 --- a/src/core/application.h +++ b/src/core/application.h @@ -117,7 +117,7 @@ class Application : public QObject { void OpenSettingsDialogAtPage(SettingsDialog::Page page); signals: - void ErrorAdded(const QString &message); + void ErrorAdded(QString message); void SettingsChanged(); void SettingsDialogRequested(SettingsDialog::Page page); void ExitFinished(); diff --git a/src/core/commandlineoptions.h b/src/core/commandlineoptions.h index 5b682b21..a529196c 100644 --- a/src/core/commandlineoptions.h +++ b/src/core/commandlineoptions.h @@ -128,4 +128,3 @@ QDataStream &operator<<(QDataStream &s, const CommandlineOptions &a); QDataStream &operator>>(QDataStream &s, CommandlineOptions &a); #endif // COMMANDLINEOPTIONS_H - diff --git a/src/core/database.h b/src/core/database.h index 0ce1cc79..add26f7e 100644 --- a/src/core/database.h +++ b/src/core/database.h @@ -85,7 +85,7 @@ class Database : public QObject { signals: void ExitFinished(); - void Error(const QString &message); + void Error(QString message); private slots: void Exit(); diff --git a/src/core/deletefiles.cpp b/src/core/deletefiles.cpp index 85adf2ec..f47187f6 100644 --- a/src/core/deletefiles.cpp +++ b/src/core/deletefiles.cpp @@ -57,7 +57,7 @@ void DeleteFiles::Start(const SongList &songs) { task_manager_->SetTaskBlocksCollectionScans(true); thread_ = new QThread(this); - connect(thread_, SIGNAL(started()), SLOT(ProcessSomeFiles())); + QObject::connect(thread_, &QThread::started, this, &DeleteFiles::ProcessSomeFiles); moveToThread(thread_); thread_->start(); @@ -120,7 +120,7 @@ void DeleteFiles::ProcessSomeFiles() { } } - QTimer::singleShot(0, this, SLOT(ProcessSomeFiles())); + QTimer::singleShot(0, this, &DeleteFiles::ProcessSomeFiles); } diff --git a/src/core/deletefiles.h b/src/core/deletefiles.h index 5fb7288c..1dbaaf74 100644 --- a/src/core/deletefiles.h +++ b/src/core/deletefiles.h @@ -46,8 +46,8 @@ class DeleteFiles : public QObject { void Start(const SongList &songs); void Start(const QStringList &filenames); -signals: - void Finished(const SongList &songs_with_errors); + signals: + void Finished(SongList songs_with_errors); private slots: void ProcessSomeFiles(); diff --git a/src/core/macfslistener.h b/src/core/macfslistener.h index 562ba0f5..11ad9d2d 100644 --- a/src/core/macfslistener.h +++ b/src/core/macfslistener.h @@ -43,8 +43,8 @@ class MacFSListener : public FileSystemWatcherInterface { void RemovePath(const QString &path); void Clear(); -signals: - void PathChanged(const QString &path); + signals: + void PathChanged(QString path); private slots: void UpdateStream(); diff --git a/src/core/macfslistener.mm b/src/core/macfslistener.mm index 7be2b019..2b5ecb15 100644 --- a/src/core/macfslistener.mm +++ b/src/core/macfslistener.mm @@ -39,7 +39,7 @@ MacFSListener::MacFSListener(QObject* parent) update_timer_->setSingleShot(true); update_timer_->setInterval(2000); - connect(update_timer_, SIGNAL(timeout()), SLOT(UpdateStream())); + QObject::connect(update_timer_, &QTimer::timeout, this, &MacFSListener::UpdateStream); } diff --git a/src/core/macsystemtrayicon.h b/src/core/macsystemtrayicon.h index 316375b7..8bd935a4 100644 --- a/src/core/macsystemtrayicon.h +++ b/src/core/macsystemtrayicon.h @@ -46,17 +46,17 @@ class MacSystemTrayIcon : public SystemTrayIcon { void SetNowPlaying(const Song& song, const QUrl &cover_url); void ClearNowPlaying(); -private: + private: void SetupMenuItem(QAction *action); -private slots: + private slots: void ActionChanged(); -protected: + protected: // SystemTrayIcon void UpdateIcon(); -private: + private: QPixmap normal_icon_; QPixmap grey_icon_; std::unique_ptr p_; diff --git a/src/core/macsystemtrayicon.mm b/src/core/macsystemtrayicon.mm index bb531fae..64d4546c 100644 --- a/src/core/macsystemtrayicon.mm +++ b/src/core/macsystemtrayicon.mm @@ -191,7 +191,7 @@ void MacSystemTrayIcon::SetupMenu(QAction* previous, QAction* play, QAction* sto void MacSystemTrayIcon::SetupMenuItem(QAction* action) { p_->AddMenuItem(action); - connect(action, SIGNAL(changed()), SLOT(ActionChanged())); + QObject::connect(action, &QAction::changed, this, &MacSystemTrayIcon::ActionChanged); } void MacSystemTrayIcon::UpdateIcon() { diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index ff61aaa6..0a9bf44f 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -245,7 +245,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd cover_manager->Init(); // Cover manager connections - connect(cover_manager, SIGNAL(AddToPlaylist(QMimeData*)), this, SLOT(AddToPlaylist(QMimeData*))); + QObject::connect(cover_manager, &AlbumCoverManager::AddToPlaylist, this, &MainWindow::AddToPlaylist); return cover_manager; }), equalizer_(new Equalizer), @@ -262,7 +262,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd #endif add_stream_dialog_([=]() { AddStreamDialog *add_stream_dialog = new AddStreamDialog; - connect(add_stream_dialog, SIGNAL(accepted()), this, SLOT(AddStreamAccepted())); + QObject::connect(add_stream_dialog, &AddStreamDialog::accepted, this, &MainWindow::AddStreamAccepted); return add_stream_dialog; }), smartplaylists_view_(new SmartPlaylistsViewContainer(app, this)), @@ -318,8 +318,8 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd qLog(Debug) << "Starting"; - connect(app, SIGNAL(ErrorAdded(QString)), SLOT(ShowErrorDialog(QString))); - connect(app, SIGNAL(SettingsDialogRequested(SettingsDialog::Page)), SLOT(OpenSettingsDialogAtPage(SettingsDialog::Page))); + QObject::connect(app, &Application::ErrorAdded, this, &MainWindow::ShowErrorDialog); + QObject::connect(app, &Application::SettingsDialogRequested, this, &MainWindow::OpenSettingsDialogAtPage); // Initialize the UI ui_->setupUi(this); @@ -359,9 +359,9 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd ui_->tabs->Load(kSettingsGroup); track_position_timer_->setInterval(kTrackPositionUpdateTimeMs); - connect(track_position_timer_, SIGNAL(timeout()), SLOT(UpdateTrackPosition())); + QObject::connect(track_position_timer_, &QTimer::timeout, this, &MainWindow::UpdateTrackPosition); track_slider_timer_->setInterval(kTrackSliderUpdateTimeMs); - connect(track_slider_timer_, SIGNAL(timeout()), SLOT(UpdateTrackSliderPosition())); + QObject::connect(track_slider_timer_, &QTimer::timeout, this, &MainWindow::UpdateTrackSliderPosition); // Start initializing the player qLog(Debug) << "Initializing player"; @@ -383,7 +383,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd qLog(Debug) << "Creating models finished"; - connect(ui_->playlist, SIGNAL(ViewSelectionModelChanged()), SLOT(PlaylistViewSelectionModelChanged())); + QObject::connect(ui_->playlist, &PlaylistContainer::ViewSelectionModelChanged, this, &MainWindow::PlaylistViewSelectionModelChanged); ui_->playlist->SetManager(app_->playlist_manager()); @@ -453,70 +453,70 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd ui_->action_love->setIcon(IconLoader::Load("love")); // File view connections - connect(file_view_, SIGNAL(AddToPlaylist(QMimeData*)), SLOT(AddToPlaylist(QMimeData*))); - connect(file_view_, SIGNAL(PathChanged(QString)), SLOT(FilePathChanged(QString))); + QObject::connect(file_view_, &FileView::AddToPlaylist, this, &MainWindow::AddToPlaylist); + QObject::connect(file_view_, &FileView::PathChanged, this, &MainWindow::FilePathChanged); #ifdef HAVE_GSTREAMER - connect(file_view_, SIGNAL(CopyToCollection(QList)), SLOT(CopyFilesToCollection(QList))); - connect(file_view_, SIGNAL(MoveToCollection(QList)), SLOT(MoveFilesToCollection(QList))); - connect(file_view_, SIGNAL(EditTags(QList)), SLOT(EditFileTags(QList))); + QObject::connect(file_view_, &FileView::CopyToCollection, this, &MainWindow::CopyFilesToCollection); + QObject::connect(file_view_, &FileView::MoveToCollection, this, &MainWindow::MoveFilesToCollection); + QObject::connect(file_view_, &FileView::EditTags, this, &MainWindow::EditFileTags); #ifndef Q_OS_WIN - connect(file_view_, SIGNAL(CopyToDevice(QList)), SLOT(CopyFilesToDevice(QList))); + QObject::connect(file_view_, &FileView::CopyToDevice, this, &MainWindow::CopyFilesToDevice); #endif #endif file_view_->SetTaskManager(app_->task_manager()); // Action connections - connect(ui_->action_next_track, SIGNAL(triggered()), app_->player(), SLOT(Next())); - connect(ui_->action_previous_track, SIGNAL(triggered()), app_->player(), SLOT(Previous())); - connect(ui_->action_play_pause, SIGNAL(triggered()), app_->player(), SLOT(PlayPause())); - connect(ui_->action_stop, SIGNAL(triggered()), app_->player(), SLOT(Stop())); - connect(ui_->action_quit, SIGNAL(triggered()), SLOT(Exit())); - connect(ui_->action_stop_after_this_track, SIGNAL(triggered()), SLOT(StopAfterCurrent())); - connect(ui_->action_mute, SIGNAL(triggered()), app_->player(), SLOT(Mute())); + QObject::connect(ui_->action_next_track, &QAction::triggered, app_->player(), &Player::Next); + QObject::connect(ui_->action_previous_track, &QAction::triggered, app_->player(), &Player::Previous); + QObject::connect(ui_->action_play_pause, &QAction::triggered, app_->player(), &Player::PlayPauseHelper); + QObject::connect(ui_->action_stop, &QAction::triggered, app_->player(), &Player::Stop); + QObject::connect(ui_->action_quit, &QAction::triggered, this, &MainWindow::Exit); + QObject::connect(ui_->action_stop_after_this_track, &QAction::triggered, this, &MainWindow::StopAfterCurrent); + QObject::connect(ui_->action_mute, &QAction::triggered, app_->player(), &Player::Mute); - connect(ui_->action_clear_playlist, SIGNAL(triggered()), SLOT(PlaylistClearCurrent())); - connect(ui_->action_remove_duplicates, SIGNAL(triggered()), app_->playlist_manager(), SLOT(RemoveDuplicatesCurrent())); - connect(ui_->action_remove_unavailable, SIGNAL(triggered()), app_->playlist_manager(), SLOT(RemoveUnavailableCurrent())); - connect(ui_->action_remove_from_playlist, SIGNAL(triggered()), SLOT(PlaylistRemoveCurrent())); - connect(ui_->action_edit_track, SIGNAL(triggered()), SLOT(EditTracks())); - connect(ui_->action_renumber_tracks, SIGNAL(triggered()), SLOT(RenumberTracks())); - connect(ui_->action_selection_set_value, SIGNAL(triggered()), SLOT(SelectionSetValue())); - connect(ui_->action_edit_value, SIGNAL(triggered()), SLOT(EditValue())); + QObject::connect(ui_->action_clear_playlist, &QAction::triggered, this, &MainWindow::PlaylistClearCurrent); + QObject::connect(ui_->action_remove_duplicates, &QAction::triggered, app_->playlist_manager(), &PlaylistManager::RemoveDuplicatesCurrent); + QObject::connect(ui_->action_remove_unavailable, &QAction::triggered, app_->playlist_manager(), &PlaylistManager::RemoveUnavailableCurrent); + QObject::connect(ui_->action_remove_from_playlist, &QAction::triggered, this, &MainWindow::PlaylistRemoveCurrent); + QObject::connect(ui_->action_edit_track, &QAction::triggered, this, &MainWindow::EditTracks); + QObject::connect(ui_->action_renumber_tracks, &QAction::triggered, this, &MainWindow::RenumberTracks); + QObject::connect(ui_->action_selection_set_value, &QAction::triggered, this, &MainWindow::SelectionSetValue); + QObject::connect(ui_->action_edit_value, &QAction::triggered, this, &MainWindow::EditValue); #if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) - connect(ui_->action_auto_complete_tags, SIGNAL(triggered()), SLOT(AutoCompleteTags())); + QObject::connect(ui_->action_auto_complete_tags, &QAction::triggered, this, &MainWindow::AutoCompleteTags); #endif - connect(ui_->action_settings, SIGNAL(triggered()), SLOT(OpenSettingsDialog())); - connect(ui_->action_import_data_from_last_fm, SIGNAL(triggered()), lastfm_import_dialog_, SLOT(show())); - connect(ui_->action_toggle_show_sidebar, SIGNAL(toggled(bool)), SLOT(ToggleSidebar(bool))); - connect(ui_->action_about_strawberry, SIGNAL(triggered()), SLOT(ShowAboutDialog())); - connect(ui_->action_about_qt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); - connect(ui_->action_shuffle, SIGNAL(triggered()), app_->playlist_manager(), SLOT(ShuffleCurrent())); - connect(ui_->action_open_file, SIGNAL(triggered()), SLOT(AddFile())); - connect(ui_->action_open_cd, SIGNAL(triggered()), SLOT(AddCDTracks())); - connect(ui_->action_add_file, SIGNAL(triggered()), SLOT(AddFile())); - connect(ui_->action_add_folder, SIGNAL(triggered()), SLOT(AddFolder())); - connect(ui_->action_add_stream, SIGNAL(triggered()), SLOT(AddStream())); - connect(ui_->action_cover_manager, SIGNAL(triggered()), SLOT(ShowCoverManager())); - connect(ui_->action_equalizer, SIGNAL(triggered()), SLOT(ShowEqualizer())); + QObject::connect(ui_->action_settings, &QAction::triggered, this, &MainWindow::OpenSettingsDialog); + QObject::connect(ui_->action_import_data_from_last_fm, &QAction::triggered, lastfm_import_dialog_, &LastFMImportDialog::show); + QObject::connect(ui_->action_toggle_show_sidebar, &QAction::toggled, this, &MainWindow::ToggleSidebar); + QObject::connect(ui_->action_about_strawberry, &QAction::triggered, this, &MainWindow::ShowAboutDialog); + QObject::connect(ui_->action_about_qt, &QAction::triggered, qApp, &QApplication::aboutQt); + QObject::connect(ui_->action_shuffle, &QAction::triggered, app_->playlist_manager(), &PlaylistManager::ShuffleCurrent); + QObject::connect(ui_->action_open_file, &QAction::triggered, this, &MainWindow::AddFile); + QObject::connect(ui_->action_open_cd, &QAction::triggered, this, &MainWindow::AddCDTracks); + QObject::connect(ui_->action_add_file, &QAction::triggered, this, &MainWindow::AddFile); + QObject::connect(ui_->action_add_folder, &QAction::triggered, this, &MainWindow::AddFolder); + QObject::connect(ui_->action_add_stream, &QAction::triggered, this, &MainWindow::AddStream); + QObject::connect(ui_->action_cover_manager, &QAction::triggered, this, &MainWindow::ShowCoverManager); + QObject::connect(ui_->action_equalizer, &QAction::triggered, this, &MainWindow::ShowEqualizer); #if defined(HAVE_GSTREAMER) - connect(ui_->action_transcoder, SIGNAL(triggered()), SLOT(ShowTranscodeDialog())); + QObject::connect(ui_->action_transcoder, &QAction::triggered, this, &MainWindow::ShowTranscodeDialog); #else ui_->action_transcoder->setDisabled(true); #endif - connect(ui_->action_jump, SIGNAL(triggered()), ui_->playlist->view(), SLOT(JumpToCurrentlyPlayingTrack())); - connect(ui_->action_update_collection, SIGNAL(triggered()), app_->collection(), SLOT(IncrementalScan())); - connect(ui_->action_full_collection_scan, SIGNAL(triggered()), app_->collection(), SLOT(FullScan())); - connect(ui_->action_abort_collection_scan, SIGNAL(triggered()), app_->collection(), SLOT(AbortScan())); + QObject::connect(ui_->action_jump, &QAction::triggered, ui_->playlist->view(), &PlaylistView::JumpToCurrentlyPlayingTrack); + QObject::connect(ui_->action_update_collection, &QAction::triggered, app_->collection(), &SCollection::IncrementalScan); + QObject::connect(ui_->action_full_collection_scan, &QAction::triggered, app_->collection(), &SCollection::FullScan); + QObject::connect(ui_->action_abort_collection_scan, &QAction::triggered, app_->collection(), &SCollection::AbortScan); #if defined(HAVE_GSTREAMER) - connect(ui_->action_add_files_to_transcoder, SIGNAL(triggered()), SLOT(AddFilesToTranscoder())); + QObject::connect(ui_->action_add_files_to_transcoder, &QAction::triggered, this, &MainWindow::AddFilesToTranscoder); ui_->action_add_files_to_transcoder->setIcon(IconLoader::Load("tools-wizard")); #else ui_->action_add_files_to_transcoder->setDisabled(true); #endif - connect(ui_->action_toggle_scrobbling, SIGNAL(triggered()), app_->scrobbler(), SLOT(ToggleScrobbling())); - connect(ui_->action_love, SIGNAL(triggered()), SLOT(Love())); - connect(app_->scrobbler(), SIGNAL(ErrorMessage(QString)), SLOT(ShowErrorDialog(QString))); + QObject::connect(ui_->action_toggle_scrobbling, &QAction::triggered, app_->scrobbler(), &AudioScrobbler::ToggleScrobbling); + QObject::connect(ui_->action_love, &QAction::triggered, this, &MainWindow::Love); + QObject::connect(app_->scrobbler(), &AudioScrobbler::ErrorMessage, this, &MainWindow::ShowErrorDialog); // Playlist view actions ui_->action_next_playlist->setShortcuts(QList() << QKeySequence::fromString("Ctrl+Tab")<< QKeySequence::fromString("Ctrl+PgDown")); @@ -547,79 +547,79 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd ui_->stop_button->setMenu(stop_menu); // Player connections - connect(ui_->volume, SIGNAL(valueChanged(int)), app_->player(), SLOT(SetVolume(int))); + QObject::connect(ui_->volume, &VolumeSlider::valueChanged, app_->player(), &Player::SetVolume); - connect(app_->player(), SIGNAL(EngineChanged(Engine::EngineType)), SLOT(EngineChanged(Engine::EngineType))); - connect(app_->player(), SIGNAL(Error(QString)), SLOT(ShowErrorDialog(QString))); - connect(app_->player(), SIGNAL(SongChangeRequestProcessed(QUrl,bool)), app_->playlist_manager(), SLOT(SongChangeRequestProcessed(QUrl,bool))); + QObject::connect(app_->player(), &Player::EngineChanged, this, &MainWindow::EngineChanged); + QObject::connect(app_->player(), &Player::Error, this, &MainWindow::ShowErrorDialog); + QObject::connect(app_->player(), &Player::SongChangeRequestProcessed, app_->playlist_manager(), &PlaylistManager::SongChangeRequestProcessed); - connect(app_->player(), SIGNAL(Paused()), SLOT(MediaPaused())); - connect(app_->player(), SIGNAL(Playing()), SLOT(MediaPlaying())); - connect(app_->player(), SIGNAL(Stopped()), SLOT(MediaStopped())); - connect(app_->player(), SIGNAL(Seeked(qlonglong)), SLOT(Seeked(qlonglong))); - connect(app_->player(), SIGNAL(TrackSkipped(PlaylistItemPtr)), SLOT(TrackSkipped(PlaylistItemPtr))); - connect(app_->player(), SIGNAL(VolumeChanged(int)), SLOT(VolumeChanged(int))); + QObject::connect(app_->player(), &Player::Paused, this, &MainWindow::MediaPaused); + QObject::connect(app_->player(), &Player::Playing, this, &MainWindow::MediaPlaying); + QObject::connect(app_->player(), &Player::Stopped, this, &MainWindow::MediaStopped); + QObject::connect(app_->player(), &Player::Seeked, this, &MainWindow::Seeked); + QObject::connect(app_->player(), &Player::TrackSkipped, this, &MainWindow::TrackSkipped); + QObject::connect(app_->player(), &Player::VolumeChanged, this, &MainWindow::VolumeChanged); - connect(app_->player(), SIGNAL(Paused()), ui_->playlist, SLOT(ActivePaused())); - connect(app_->player(), SIGNAL(Playing()), ui_->playlist, SLOT(ActivePlaying())); - connect(app_->player(), SIGNAL(Stopped()), ui_->playlist, SLOT(ActiveStopped())); + QObject::connect(app_->player(), &Player::Paused, ui_->playlist, &PlaylistContainer::ActivePaused); + QObject::connect(app_->player(), &Player::Playing, ui_->playlist, &PlaylistContainer::ActivePlaying); + QObject::connect(app_->player(), &Player::Stopped, ui_->playlist, &PlaylistContainer::ActiveStopped); - connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), osd_, SLOT(SongChanged(Song))); - connect(app_->player(), SIGNAL(Paused()), osd_, SLOT(Paused())); - connect(app_->player(), SIGNAL(Resumed()), osd_, SLOT(Resumed())); - connect(app_->player(), SIGNAL(Stopped()), osd_, SLOT(Stopped())); - connect(app_->player(), SIGNAL(PlaylistFinished()), osd_, SLOT(PlaylistFinished())); - connect(app_->player(), SIGNAL(VolumeChanged(int)), osd_, SLOT(VolumeChanged(int))); - connect(app_->player(), SIGNAL(VolumeChanged(int)), ui_->volume, SLOT(setValue(int))); - connect(app_->player(), SIGNAL(ForceShowOSD(Song, bool)), SLOT(ForceShowOSD(Song, bool))); + QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, osd_, &OSDBase::SongChanged); + QObject::connect(app_->player(), &Player::Paused, osd_, &OSDBase::Paused); + QObject::connect(app_->player(), &Player::Resumed, osd_, &OSDBase::Resumed); + QObject::connect(app_->player(), &Player::Stopped, osd_, &OSDBase::Stopped); + QObject::connect(app_->player(), &Player::PlaylistFinished, osd_, &OSDBase::PlaylistFinished); + QObject::connect(app_->player(), &Player::VolumeChanged, osd_, &OSDBase::VolumeChanged); + QObject::connect(app_->player(), &Player::VolumeChanged, ui_->volume, &VolumeSlider::setValue); + QObject::connect(app_->player(), &Player::ForceShowOSD, this, &MainWindow::ForceShowOSD); - connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), SLOT(SongChanged(Song))); - connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), app_->player(), SLOT(CurrentMetadataChanged(Song))); - connect(app_->playlist_manager(), SIGNAL(EditingFinished(QModelIndex)), SLOT(PlaylistEditFinished(QModelIndex))); - connect(app_->playlist_manager(), SIGNAL(Error(QString)), SLOT(ShowErrorDialog(QString))); - connect(app_->playlist_manager(), SIGNAL(SummaryTextChanged(QString)), ui_->playlist_summary, SLOT(setText(QString))); - connect(app_->playlist_manager(), SIGNAL(PlayRequested(QModelIndex, Playlist::AutoScroll)), SLOT(PlayIndex(QModelIndex, Playlist::AutoScroll))); + QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &MainWindow::SongChanged); + QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, app_->player(), &Player::CurrentMetadataChanged); + QObject::connect(app_->playlist_manager(), &PlaylistManager::EditingFinished, this, &MainWindow::PlaylistEditFinished); + QObject::connect(app_->playlist_manager(), &PlaylistManager::Error, this, &MainWindow::ShowErrorDialog); + QObject::connect(app_->playlist_manager(), &PlaylistManager::SummaryTextChanged, ui_->playlist_summary, &QLabel::setText); + QObject::connect(app_->playlist_manager(), &PlaylistManager::PlayRequested, this, &MainWindow::PlayIndex); - connect(ui_->playlist->view(), SIGNAL(doubleClicked(QModelIndex)), SLOT(PlaylistDoubleClick(QModelIndex))); - connect(ui_->playlist->view(), SIGNAL(PlayItem(QModelIndex, Playlist::AutoScroll)), SLOT(PlayIndex(QModelIndex, Playlist::AutoScroll))); - connect(ui_->playlist->view(), SIGNAL(PlayPause(Playlist::AutoScroll)), app_->player(), SLOT(PlayPause(Playlist::AutoScroll))); - connect(ui_->playlist->view(), SIGNAL(RightClicked(QPoint, QModelIndex)), SLOT(PlaylistRightClick(QPoint, QModelIndex))); - connect(ui_->playlist->view(), SIGNAL(SeekForward()), app_->player(), SLOT(SeekForward())); - connect(ui_->playlist->view(), SIGNAL(SeekBackward()), app_->player(), SLOT(SeekBackward())); - connect(ui_->playlist->view(), SIGNAL(BackgroundPropertyChanged()), SLOT(RefreshStyleSheet())); + QObject::connect(ui_->playlist->view(), &PlaylistView::doubleClicked, this, &MainWindow::PlaylistDoubleClick); + QObject::connect(ui_->playlist->view(), &PlaylistView::PlayItem, this, &MainWindow::PlayIndex); + QObject::connect(ui_->playlist->view(), &PlaylistView::PlayPause, app_->player(), &Player::PlayPause); + QObject::connect(ui_->playlist->view(), &PlaylistView::RightClicked, this, &MainWindow::PlaylistRightClick); + QObject::connect(ui_->playlist->view(), &PlaylistView::SeekForward, app_->player(), &Player::SeekForward); + QObject::connect(ui_->playlist->view(), &PlaylistView::SeekBackward, app_->player(), &Player::SeekBackward); + QObject::connect(ui_->playlist->view(), &PlaylistView::BackgroundPropertyChanged, this, &MainWindow::RefreshStyleSheet); - connect(ui_->track_slider, SIGNAL(ValueChangedSeconds(int)), app_->player(), SLOT(SeekTo(int))); - connect(ui_->track_slider, SIGNAL(SeekForward()), app_->player(), SLOT(SeekForward())); - connect(ui_->track_slider, SIGNAL(SeekBackward()), app_->player(), SLOT(SeekBackward())); - connect(ui_->track_slider, SIGNAL(Previous()), app_->player(), SLOT(Previous())); - connect(ui_->track_slider, SIGNAL(Next()), app_->player(), SLOT(Next())); + QObject::connect(ui_->track_slider, &TrackSlider::ValueChangedSeconds, app_->player(), &Player::SeekTo); + QObject::connect(ui_->track_slider, &TrackSlider::SeekForward, app_->player(), &Player::SeekForward); + QObject::connect(ui_->track_slider, &TrackSlider::SeekBackward, app_->player(), &Player::SeekBackward); + QObject::connect(ui_->track_slider, &TrackSlider::Previous, app_->player(), &Player::Previous); + QObject::connect(ui_->track_slider, &TrackSlider::Next, app_->player(), &Player::Next); // Collection connections - connect(collection_view_->view(), SIGNAL(AddToPlaylistSignal(QMimeData*)), SLOT(AddToPlaylist(QMimeData*))); - connect(collection_view_->view(), SIGNAL(ShowConfigDialog()), SLOT(ShowCollectionConfig())); - connect(collection_view_->view(), SIGNAL(Error(QString)), SLOT(ShowErrorDialog(QString))); - connect(app_->collection_model(), SIGNAL(TotalSongCountUpdated(int)), collection_view_->view(), SLOT(TotalSongCountUpdated(int))); - connect(app_->collection_model(), SIGNAL(TotalArtistCountUpdated(int)), collection_view_->view(), SLOT(TotalArtistCountUpdated(int))); - connect(app_->collection_model(), SIGNAL(TotalAlbumCountUpdated(int)), collection_view_->view(), SLOT(TotalAlbumCountUpdated(int))); - connect(app_->collection_model(), SIGNAL(modelAboutToBeReset()), collection_view_->view(), SLOT(SaveFocus())); - connect(app_->collection_model(), SIGNAL(modelReset()), collection_view_->view(), SLOT(RestoreFocus())); + QObject::connect(collection_view_->view(), &CollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist); + QObject::connect(collection_view_->view(), &CollectionView::ShowConfigDialog, this, &MainWindow::ShowCollectionConfig); + QObject::connect(collection_view_->view(), &CollectionView::Error, this, &MainWindow::ShowErrorDialog); + QObject::connect(app_->collection_model(), &CollectionModel::TotalSongCountUpdated, collection_view_->view(), &CollectionView::TotalSongCountUpdated); + QObject::connect(app_->collection_model(), &CollectionModel::TotalArtistCountUpdated, collection_view_->view(), &CollectionView::TotalArtistCountUpdated); + QObject::connect(app_->collection_model(), &CollectionModel::TotalAlbumCountUpdated, collection_view_->view(), &CollectionView::TotalAlbumCountUpdated); + QObject::connect(app_->collection_model(), &CollectionModel::modelAboutToBeReset, collection_view_->view(), &CollectionView::SaveFocus); + QObject::connect(app_->collection_model(), &CollectionModel::modelReset, collection_view_->view(), &CollectionView::RestoreFocus); - connect(app_->task_manager(), SIGNAL(PauseCollectionWatchers()), app_->collection(), SLOT(PauseWatcher())); - connect(app_->task_manager(), SIGNAL(ResumeCollectionWatchers()), app_->collection(), SLOT(ResumeWatcher())); + QObject::connect(app_->task_manager(), &TaskManager::PauseCollectionWatchers, app_->collection(), &SCollection::PauseWatcher); + QObject::connect(app_->task_manager(), &TaskManager::ResumeCollectionWatchers, app_->collection(), &SCollection::ResumeWatcher); - connect(app_->current_albumcover_loader(), SIGNAL(AlbumCoverLoaded(Song, AlbumCoverLoaderResult)), SLOT(AlbumCoverLoaded(Song, AlbumCoverLoaderResult))); - connect(album_cover_choice_controller_->cover_from_file_action(), SIGNAL(triggered()), this, SLOT(LoadCoverFromFile())); - connect(album_cover_choice_controller_->cover_to_file_action(), SIGNAL(triggered()), this, SLOT(SaveCoverToFile())); - connect(album_cover_choice_controller_->cover_from_url_action(), SIGNAL(triggered()), this, SLOT(LoadCoverFromURL())); - connect(album_cover_choice_controller_->search_for_cover_action(), SIGNAL(triggered()), this, SLOT(SearchForCover())); - connect(album_cover_choice_controller_->unset_cover_action(), SIGNAL(triggered()), this, SLOT(UnsetCover())); - connect(album_cover_choice_controller_->show_cover_action(), SIGNAL(triggered()), this, SLOT(ShowCover())); - connect(album_cover_choice_controller_->search_cover_auto_action(), SIGNAL(triggered()), this, SLOT(SearchCoverAutomatically())); - connect(album_cover_choice_controller_->search_cover_auto_action(), SIGNAL(toggled(bool)), SLOT(ToggleSearchCoverAuto(bool))); + QObject::connect(app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::AlbumCoverLoaded, this, &MainWindow::AlbumCoverLoaded); + QObject::connect(album_cover_choice_controller_->cover_from_file_action(), &QAction::triggered, this, &MainWindow::LoadCoverFromFile); + QObject::connect(album_cover_choice_controller_->cover_to_file_action(), &QAction::triggered, this, &MainWindow::SaveCoverToFile); + QObject::connect(album_cover_choice_controller_->cover_from_url_action(), &QAction::triggered, this, &MainWindow::LoadCoverFromURL); + QObject::connect(album_cover_choice_controller_->search_for_cover_action(), &QAction::triggered, this, &MainWindow::SearchForCover); + QObject::connect(album_cover_choice_controller_->unset_cover_action(), &QAction::triggered, this, &MainWindow::UnsetCover); + QObject::connect(album_cover_choice_controller_->show_cover_action(), &QAction::triggered, this, &MainWindow::ShowCover); + QObject::connect(album_cover_choice_controller_->search_cover_auto_action(), &QAction::triggered, this, &MainWindow::SearchCoverAutomatically); + QObject::connect(album_cover_choice_controller_->search_cover_auto_action(), &QAction::toggled, this, &MainWindow::ToggleSearchCoverAuto); #ifndef Q_OS_WIN // Devices connections - connect(device_view_->view(), SIGNAL(AddToPlaylistSignal(QMimeData*)), SLOT(AddToPlaylist(QMimeData*))); + QObject::connect(device_view_->view(), &DeviceView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist); #endif // Collection filter widget @@ -634,10 +634,10 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd collection_show_untagged_->setCheckable(true); collection_show_all_->setChecked(true); - connect(collection_view_group, SIGNAL(triggered(QAction*)), SLOT(ChangeCollectionQueryMode(QAction*))); + QObject::connect(collection_view_group, &QActionGroup::triggered, this, &MainWindow::ChangeCollectionQueryMode); QAction *collection_config_action = new QAction(IconLoader::Load("configure"), tr("Configure collection..."), this); - connect(collection_config_action, SIGNAL(triggered()), SLOT(ShowCollectionConfig())); + QObject::connect(collection_config_action, &QAction::triggered, this, &MainWindow::ShowCollectionConfig); collection_view_->filter()->SetSettingsGroup(CollectionSettingsPage::kSettingsGroup); collection_view_->filter()->SetCollectionModel(app_->collection()->model()); @@ -651,37 +651,37 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd collection_view_->filter()->AddMenuAction(collection_config_action); #ifdef HAVE_SUBSONIC - connect(subsonic_view_->view(), SIGNAL(AddToPlaylistSignal(QMimeData*)), SLOT(AddToPlaylist(QMimeData*))); + QObject::connect(subsonic_view_->view(), &InternetCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist); #endif #ifdef HAVE_TIDAL - connect(tidal_view_->artists_collection_view(), SIGNAL(AddToPlaylistSignal(QMimeData*)), SLOT(AddToPlaylist(QMimeData*))); - connect(tidal_view_->albums_collection_view(), SIGNAL(AddToPlaylistSignal(QMimeData*)), SLOT(AddToPlaylist(QMimeData*))); - connect(tidal_view_->songs_collection_view(), SIGNAL(AddToPlaylistSignal(QMimeData*)), SLOT(AddToPlaylist(QMimeData*))); - connect(tidal_view_->search_view(), SIGNAL(AddToPlaylist(QMimeData*)), SLOT(AddToPlaylist(QMimeData*))); + QObject::connect(tidal_view_->artists_collection_view(), &InternetCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist); + QObject::connect(tidal_view_->albums_collection_view(), &InternetCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist); + QObject::connect(tidal_view_->songs_collection_view(), &InternetCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist); + QObject::connect(tidal_view_->search_view(), &InternetSearchView::AddToPlaylist, this, &MainWindow::AddToPlaylist); if (TidalService *tidalservice = qobject_cast (app_->internet_services()->ServiceBySource(Song::Source_Tidal))) - connect(this, SIGNAL(AuthorizationUrlReceived(QUrl)), tidalservice, SLOT(AuthorizationUrlReceived(QUrl))); + QObject::connect(this, &MainWindow::AuthorizationUrlReceived, tidalservice, &TidalService::AuthorizationUrlReceived); #endif #ifdef HAVE_QOBUZ - connect(qobuz_view_->artists_collection_view(), SIGNAL(AddToPlaylistSignal(QMimeData*)), SLOT(AddToPlaylist(QMimeData*))); - connect(qobuz_view_->albums_collection_view(), SIGNAL(AddToPlaylistSignal(QMimeData*)), SLOT(AddToPlaylist(QMimeData*))); - connect(qobuz_view_->songs_collection_view(), SIGNAL(AddToPlaylistSignal(QMimeData*)), SLOT(AddToPlaylist(QMimeData*))); - connect(qobuz_view_->search_view(), SIGNAL(AddToPlaylist(QMimeData*)), SLOT(AddToPlaylist(QMimeData*))); + QObject::connect(qobuz_view_->artists_collection_view(), &InternetCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist); + QObject::connect(qobuz_view_->albums_collection_view(), &InternetCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist); + QObject::connect(qobuz_view_->songs_collection_view(), &InternetCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist); + QObject::connect(qobuz_view_->search_view(), &InternetSearchView::AddToPlaylist, this, &MainWindow::AddToPlaylist); #endif // Playlist menu - connect(playlist_menu_, SIGNAL(aboutToHide()), SLOT(PlaylistMenuHidden())); - playlist_play_pause_ = playlist_menu_->addAction(tr("Play"), this, SLOT(PlaylistPlay())); + QObject::connect(playlist_menu_, &QMenu::aboutToHide, this, &MainWindow::PlaylistMenuHidden); + playlist_play_pause_ = playlist_menu_->addAction(tr("Play"), this, &MainWindow::PlaylistPlay); playlist_menu_->addAction(ui_->action_stop); - playlist_stop_after_ = playlist_menu_->addAction(IconLoader::Load("media-playback-stop"), tr("Stop after this track"), this, SLOT(PlaylistStopAfter())); - playlist_queue_ = playlist_menu_->addAction(IconLoader::Load("go-next"), tr("Toggle queue status"), this, SLOT(PlaylistQueue())); + playlist_stop_after_ = playlist_menu_->addAction(IconLoader::Load("media-playback-stop"), tr("Stop after this track"), this, &MainWindow::PlaylistStopAfter); + playlist_queue_ = playlist_menu_->addAction(IconLoader::Load("go-next"), tr("Toggle queue status"), this, &MainWindow::PlaylistQueue); playlist_queue_->setShortcut(QKeySequence("Ctrl+D")); ui_->playlist->addAction(playlist_queue_); - playlist_queue_play_next_ = playlist_menu_->addAction(IconLoader::Load("go-next"), tr("Queue selected tracks to play next"), this, SLOT(PlaylistQueuePlayNext())); + playlist_queue_play_next_ = playlist_menu_->addAction(IconLoader::Load("go-next"), tr("Queue selected tracks to play next"), this, &MainWindow::PlaylistQueuePlayNext); playlist_queue_play_next_->setShortcut(QKeySequence("Ctrl+Shift+D")); ui_->playlist->addAction(playlist_queue_play_next_); - playlist_skip_ = playlist_menu_->addAction(IconLoader::Load("media-skip-forward"), tr("Toggle skip status"), this, SLOT(PlaylistSkip())); + playlist_skip_ = playlist_menu_->addAction(IconLoader::Load("media-skip-forward"), tr("Toggle skip status"), this, &MainWindow::PlaylistSkip); ui_->playlist->addAction(playlist_skip_); playlist_menu_->addSeparator(); @@ -694,22 +694,22 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd #if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) playlist_menu_->addAction(ui_->action_auto_complete_tags); #endif - playlist_rescan_songs_ = playlist_menu_->addAction(IconLoader::Load("view-refresh"), tr("Rescan song(s)..."), this, SLOT(RescanSongs())); + playlist_rescan_songs_ = playlist_menu_->addAction(IconLoader::Load("view-refresh"), tr("Rescan song(s)..."), this, &MainWindow::RescanSongs); playlist_menu_->addAction(playlist_rescan_songs_); #ifdef HAVE_GSTREAMER playlist_menu_->addAction(ui_->action_add_files_to_transcoder); #endif playlist_menu_->addSeparator(); - playlist_copy_url_ = playlist_menu_->addAction(IconLoader::Load("edit-copy"), tr("Copy URL(s)..."), this, SLOT(PlaylistCopyUrl())); - playlist_show_in_collection_ = playlist_menu_->addAction(IconLoader::Load("edit-find"), tr("Show in collection..."), this, SLOT(ShowInCollection())); - playlist_open_in_browser_ = playlist_menu_->addAction(IconLoader::Load("document-open-folder"), tr("Show in file browser..."), this, SLOT(PlaylistOpenInBrowser())); - playlist_organize_ = playlist_menu_->addAction(IconLoader::Load("edit-copy"), tr("Organize files..."), this, SLOT(PlaylistMoveToCollection())); - playlist_copy_to_collection_ = playlist_menu_->addAction(IconLoader::Load("edit-copy"), tr("Copy to collection..."), this, SLOT(PlaylistCopyToCollection())); - playlist_move_to_collection_ = playlist_menu_->addAction(IconLoader::Load("go-jump"), tr("Move to collection..."), this, SLOT(PlaylistMoveToCollection())); + playlist_copy_url_ = playlist_menu_->addAction(IconLoader::Load("edit-copy"), tr("Copy URL(s)..."), this, &MainWindow::PlaylistCopyUrl); + playlist_show_in_collection_ = playlist_menu_->addAction(IconLoader::Load("edit-find"), tr("Show in collection..."), this, &MainWindow::ShowInCollection); + playlist_open_in_browser_ = playlist_menu_->addAction(IconLoader::Load("document-open-folder"), tr("Show in file browser..."), this, &MainWindow::PlaylistOpenInBrowser); + playlist_organize_ = playlist_menu_->addAction(IconLoader::Load("edit-copy"), tr("Organize files..."), this, &MainWindow::PlaylistMoveToCollection); + playlist_copy_to_collection_ = playlist_menu_->addAction(IconLoader::Load("edit-copy"), tr("Copy to collection..."), this, &MainWindow::PlaylistCopyToCollection); + playlist_move_to_collection_ = playlist_menu_->addAction(IconLoader::Load("go-jump"), tr("Move to collection..."), this, &MainWindow::PlaylistMoveToCollection); #if defined(HAVE_GSTREAMER) && !defined(Q_OS_WIN) - playlist_copy_to_device_ = playlist_menu_->addAction(IconLoader::Load("device"), tr("Copy to device..."), this, SLOT(PlaylistCopyToDevice())); + playlist_copy_to_device_ = playlist_menu_->addAction(IconLoader::Load("device"), tr("Copy to device..."), this, &MainWindow::PlaylistCopyToDevice); #endif - playlist_delete_ = playlist_menu_->addAction(IconLoader::Load("edit-delete"), tr("Delete from disk..."), this, SLOT(PlaylistDelete())); + playlist_delete_ = playlist_menu_->addAction(IconLoader::Load("edit-delete"), tr("Delete from disk..."), this, &MainWindow::PlaylistDelete); playlist_menu_->addSeparator(); playlistitem_actions_separator_ = playlist_menu_->addSeparator(); playlist_menu_->addAction(ui_->action_clear_playlist); @@ -724,16 +724,16 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd // We have to add the actions on the playlist menu to this QWidget otherwise their shortcut keys don't work addActions(playlist_menu_->actions()); - connect(ui_->playlist, SIGNAL(UndoRedoActionsChanged(QAction*, QAction*)), SLOT(PlaylistUndoRedoChanged(QAction*, QAction*))); + QObject::connect(ui_->playlist, &PlaylistContainer::UndoRedoActionsChanged, this, &MainWindow::PlaylistUndoRedoChanged); #if defined(HAVE_GSTREAMER) && !defined(Q_OS_WIN) playlist_copy_to_device_->setDisabled(app_->device_manager()->connected_devices_model()->rowCount() == 0); - connect(app_->device_manager()->connected_devices_model(), SIGNAL(IsEmptyChanged(bool)), playlist_copy_to_device_, SLOT(setDisabled(bool))); + QObject::connect(app_->device_manager()->connected_devices_model(), &DeviceStateFilterModel::IsEmptyChanged, playlist_copy_to_device_, &QAction::setDisabled); #endif - connect(app_->scrobbler(), SIGNAL(ScrobblingEnabledChanged(bool)), SLOT(ScrobblingEnabledChanged(bool))); - connect(app_->scrobbler(), SIGNAL(ScrobbleButtonVisibilityChanged(bool)), SLOT(ScrobbleButtonVisibilityChanged(bool))); - connect(app_->scrobbler(), SIGNAL(LoveButtonVisibilityChanged(bool)), SLOT(LoveButtonVisibilityChanged(bool))); + QObject::connect(app_->scrobbler(), &AudioScrobbler::ScrobblingEnabledChanged, this, &MainWindow::ScrobblingEnabledChanged); + QObject::connect(app_->scrobbler(), &AudioScrobbler::ScrobbleButtonVisibilityChanged, this, &MainWindow::ScrobbleButtonVisibilityChanged); + QObject::connect(app_->scrobbler(), &AudioScrobbler::LoveButtonVisibilityChanged, this, &MainWindow::LoveButtonVisibilityChanged); #ifdef Q_OS_MACOS mac::SetApplicationHandler(this); @@ -741,13 +741,13 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd // Tray icon if (tray_icon_) { tray_icon_->SetupMenu(ui_->action_previous_track, ui_->action_play_pause, ui_->action_stop, ui_->action_stop_after_this_track, ui_->action_next_track, ui_->action_mute, ui_->action_love, ui_->action_quit); - connect(tray_icon_, SIGNAL(PlayPause()), app_->player(), SLOT(PlayPause())); - connect(tray_icon_, SIGNAL(SeekForward()), app_->player(), SLOT(SeekForward())); - connect(tray_icon_, SIGNAL(SeekBackward()), app_->player(), SLOT(SeekBackward())); - connect(tray_icon_, SIGNAL(NextTrack()), app_->player(), SLOT(Next())); - connect(tray_icon_, SIGNAL(PreviousTrack()), app_->player(), SLOT(Previous())); - connect(tray_icon_, SIGNAL(ShowHide()), SLOT(ToggleShowHide())); - connect(tray_icon_, SIGNAL(ChangeVolume(int)), SLOT(VolumeWheelEvent(int))); + QObject::connect(tray_icon_, &SystemTrayIcon::PlayPause, app_->player(), &Player::PlayPauseHelper); + QObject::connect(tray_icon_, &SystemTrayIcon::SeekForward, app_->player(), &Player::SeekForward); + QObject::connect(tray_icon_, &SystemTrayIcon::SeekBackward, app_->player(), &Player::SeekBackward); + QObject::connect(tray_icon_, &SystemTrayIcon::NextTrack, app_->player(), &Player::Next); + QObject::connect(tray_icon_, &SystemTrayIcon::PreviousTrack, app_->player(), &Player::Previous); + QObject::connect(tray_icon_, &SystemTrayIcon::ShowHide, this, &MainWindow::ToggleShowHide); + QObject::connect(tray_icon_, &SystemTrayIcon::ChangeVolume, this, &MainWindow::VolumeWheelEvent); } // Windows 7 thumbbar buttons @@ -758,47 +758,47 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd #if defined(HAVE_SPARKLE) || defined(HAVE_QTSPARKLE) QAction *check_updates = ui_->menu_tools->addAction(tr("Check for updates...")); check_updates->setMenuRole(QAction::ApplicationSpecificRole); - connect(check_updates, SIGNAL(triggered(bool)), SLOT(CheckForUpdates())); + QObject::connect(check_updates, &QAction::triggered, this, &MainWindow::CheckForUpdates); #endif #ifdef HAVE_GLOBALSHORTCUTS // Global shortcuts - connect(global_shortcuts_, SIGNAL(Play()), app_->player(), SLOT(Play())); - connect(global_shortcuts_, SIGNAL(Pause()), app_->player(), SLOT(Pause())); - connect(global_shortcuts_, SIGNAL(PlayPause()), ui_->action_play_pause, SLOT(trigger())); - connect(global_shortcuts_, SIGNAL(Stop()), ui_->action_stop, SLOT(trigger())); - connect(global_shortcuts_, SIGNAL(StopAfter()), ui_->action_stop_after_this_track, SLOT(trigger())); - connect(global_shortcuts_, SIGNAL(Next()), ui_->action_next_track, SLOT(trigger())); - connect(global_shortcuts_, SIGNAL(Previous()), ui_->action_previous_track, SLOT(trigger())); - connect(global_shortcuts_, SIGNAL(IncVolume()), app_->player(), SLOT(VolumeUp())); - connect(global_shortcuts_, SIGNAL(DecVolume()), app_->player(), SLOT(VolumeDown())); - connect(global_shortcuts_, SIGNAL(Mute()), app_->player(), SLOT(Mute())); - connect(global_shortcuts_, SIGNAL(SeekForward()), app_->player(), SLOT(SeekForward())); - connect(global_shortcuts_, SIGNAL(SeekBackward()), app_->player(), SLOT(SeekBackward())); - connect(global_shortcuts_, SIGNAL(ShowHide()), SLOT(ToggleShowHide())); - connect(global_shortcuts_, SIGNAL(ShowOSD()), app_->player(), SLOT(ShowOSD())); - connect(global_shortcuts_, SIGNAL(TogglePrettyOSD()), app_->player(), SLOT(TogglePrettyOSD())); - connect(global_shortcuts_, SIGNAL(ToggleScrobbling()), app_->scrobbler(), SLOT(ToggleScrobbling())); - connect(global_shortcuts_, SIGNAL(Love()), app_->scrobbler(), SLOT(Love())); + QObject::connect(global_shortcuts_, &GlobalShortcuts::Play, app_->player(), &Player::Play); + QObject::connect(global_shortcuts_, &GlobalShortcuts::Pause, app_->player(), &Player::Pause); + QObject::connect(global_shortcuts_, &GlobalShortcuts::PlayPause, ui_->action_play_pause, &QAction::trigger); + QObject::connect(global_shortcuts_, &GlobalShortcuts::Stop, ui_->action_stop, &QAction::trigger); + QObject::connect(global_shortcuts_, &GlobalShortcuts::StopAfter, ui_->action_stop_after_this_track, &QAction::trigger); + QObject::connect(global_shortcuts_, &GlobalShortcuts::Next, ui_->action_next_track, &QAction::trigger); + QObject::connect(global_shortcuts_, &GlobalShortcuts::Previous, ui_->action_previous_track, &QAction::trigger); + QObject::connect(global_shortcuts_, &GlobalShortcuts::IncVolume, app_->player(), &Player::VolumeUp); + QObject::connect(global_shortcuts_, &GlobalShortcuts::DecVolume, app_->player(), &Player::VolumeDown); + QObject::connect(global_shortcuts_, &GlobalShortcuts::Mute, app_->player(), &Player::Mute); + QObject::connect(global_shortcuts_, &GlobalShortcuts::SeekForward, app_->player(), &Player::SeekForward); + QObject::connect(global_shortcuts_, &GlobalShortcuts::SeekBackward, app_->player(), &Player::SeekBackward); + QObject::connect(global_shortcuts_, &GlobalShortcuts::ShowHide, this, &MainWindow::ToggleShowHide); + QObject::connect(global_shortcuts_, &GlobalShortcuts::ShowOSD, app_->player(), &Player::ShowOSD); + QObject::connect(global_shortcuts_, &GlobalShortcuts::TogglePrettyOSD, app_->player(), &Player::TogglePrettyOSD); + QObject::connect(global_shortcuts_, &GlobalShortcuts::ToggleScrobbling, app_->scrobbler(), &AudioScrobbler::ToggleScrobbling); + QObject::connect(global_shortcuts_, &GlobalShortcuts::Love, app_->scrobbler(), &AudioScrobbler::Love); #endif // Fancy tabs - connect(ui_->tabs, SIGNAL(CurrentChanged(int)), SLOT(TabSwitched())); + QObject::connect(ui_->tabs, &FancyTabWidget::CurrentChanged, this, &MainWindow::TabSwitched); // Context - connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), context_view_, SLOT(SongChanged(Song))); - connect(app_->playlist_manager(), SIGNAL(SongMetadataChanged(Song)), context_view_, SLOT(SongChanged(Song))); - connect(app_->player(), SIGNAL(PlaylistFinished()), context_view_, SLOT(Stopped())); - connect(app_->player(), SIGNAL(Playing()), context_view_, SLOT(Playing())); - connect(app_->player(), SIGNAL(Stopped()), context_view_, SLOT(Stopped())); - connect(app_->player(), SIGNAL(Error()), context_view_, SLOT(Error())); - connect(this, SIGNAL(AlbumCoverReady(Song, QImage)), context_view_, SLOT(AlbumCoverLoaded(Song, QImage))); - connect(this, SIGNAL(SearchCoverInProgress()), context_view_->album_widget(), SLOT(SearchCoverInProgress())); - connect(context_view_, SIGNAL(AlbumEnabledChanged()), SLOT(TabSwitched())); - connect(context_view_->albums_widget(), SIGNAL(AddToPlaylistSignal(QMimeData*)), SLOT(AddToPlaylist(QMimeData*))); + QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, context_view_, &ContextView::SongChanged); + QObject::connect(app_->playlist_manager(), &PlaylistManager::SongMetadataChanged, context_view_, &ContextView::SongChanged); + QObject::connect(app_->player(), &Player::PlaylistFinished, context_view_, &ContextView::Stopped); + QObject::connect(app_->player(), &Player::Playing, context_view_, &ContextView::Playing); + QObject::connect(app_->player(), &Player::Stopped, context_view_, &ContextView::Stopped); + QObject::connect(app_->player(), &Player::Error, context_view_, &ContextView::Error); + QObject::connect(this, &MainWindow::AlbumCoverReady, context_view_, &ContextView::AlbumCoverLoaded); + QObject::connect(this, &MainWindow::SearchCoverInProgress, context_view_->album_widget(), &ContextAlbum::SearchCoverInProgress); + QObject::connect(context_view_, &ContextView::AlbumEnabledChanged, this, &MainWindow::TabSwitched); + QObject::connect(context_view_->albums_widget(), &ContextAlbumsView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist); // Analyzer - connect(ui_->analyzer, SIGNAL(WheelEvent(int)), SLOT(VolumeWheelEvent(int))); + QObject::connect(ui_->analyzer, &AnalyzerContainer::WheelEvent, this, &MainWindow::VolumeWheelEvent); // Statusbar widgets #if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)) @@ -807,28 +807,28 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd ui_->playlist_summary->setMinimumWidth(QFontMetrics(font()).width("WW selected of WW tracks - [ WW:WW ]")); #endif ui_->status_bar_stack->setCurrentWidget(ui_->playlist_summary_page); - connect(ui_->multi_loading_indicator, SIGNAL(TaskCountChange(int)), SLOT(TaskCountChanged(int))); + QObject::connect(ui_->multi_loading_indicator, &MultiLoadingIndicator::TaskCountChange, this, &MainWindow::TaskCountChanged); ui_->track_slider->SetApplication(app); #ifdef HAVE_MOODBAR // Moodbar connections - connect(app_->moodbar_controller(), SIGNAL(CurrentMoodbarDataChanged(QByteArray)), ui_->track_slider->moodbar_style(), SLOT(SetMoodbarData(QByteArray))); + QObject::connect(app_->moodbar_controller(), &MoodbarController::CurrentMoodbarDataChanged, ui_->track_slider->moodbar_style(), &MoodbarProxyStyle::SetMoodbarData); #endif // Playing widget qLog(Debug) << "Creating playing widget"; ui_->widget_playing->set_ideal_height(ui_->status_bar->sizeHint().height() + ui_->player_controls->sizeHint().height()); - connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), ui_->widget_playing, SLOT(SongChanged(Song))); - connect(app_->player(), SIGNAL(PlaylistFinished()), ui_->widget_playing, SLOT(Stopped())); - connect(app_->player(), SIGNAL(Playing()), ui_->widget_playing, SLOT(Playing())); - connect(app_->player(), SIGNAL(Stopped()), ui_->widget_playing, SLOT(Stopped())); - connect(app_->player(), SIGNAL(Error()), ui_->widget_playing, SLOT(Error())); - connect(ui_->widget_playing, SIGNAL(ShowAboveStatusBarChanged(bool)), SLOT(PlayingWidgetPositionChanged(bool))); - connect(this, SIGNAL(AlbumCoverReady(Song, QImage)), ui_->widget_playing, SLOT(AlbumCoverLoaded(Song, QImage))); - connect(this, SIGNAL(SearchCoverInProgress()), ui_->widget_playing, SLOT(SearchCoverInProgress())); + QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, ui_->widget_playing, &PlayingWidget::SongChanged); + QObject::connect(app_->player(), &Player::PlaylistFinished, ui_->widget_playing, &PlayingWidget::Stopped); + QObject::connect(app_->player(), &Player::Playing, ui_->widget_playing, &PlayingWidget::Playing); + QObject::connect(app_->player(), &Player::Stopped, ui_->widget_playing, &PlayingWidget::Stopped); + QObject::connect(app_->player(), &Player::Error, ui_->widget_playing, &PlayingWidget::Error); + QObject::connect(ui_->widget_playing, &PlayingWidget::ShowAboveStatusBarChanged, this, &MainWindow::PlayingWidgetPositionChanged); + QObject::connect(this, &MainWindow::AlbumCoverReady, ui_->widget_playing, &PlayingWidget::AlbumCoverLoaded); + QObject::connect(this, &MainWindow::SearchCoverInProgress, ui_->widget_playing, &PlayingWidget::SearchCoverInProgress); - connect(ui_->action_console, SIGNAL(triggered()), SLOT(ShowConsole())); + QObject::connect(ui_->action_console, &QAction::triggered, this, &MainWindow::ShowConsole); PlayingWidgetPositionChanged(ui_->widget_playing->show_above_status_bar()); // Load theme @@ -845,28 +845,28 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd queue_view_->SetPlaylistManager(app_->playlist_manager()); // This connection must be done after the playlists have been initialized. - connect(this, SIGNAL(StopAfterToggled(bool)), osd_, SLOT(StopAfterToggle(bool))); + QObject::connect(this, &MainWindow::StopAfterToggled, osd_, &OSDBase::StopAfterToggle); // We need to connect these global shortcuts here after the playlist have been initialized #ifdef HAVE_GLOBALSHORTCUTS - connect(global_shortcuts_, SIGNAL(CycleShuffleMode()), app_->playlist_manager()->sequence(), SLOT(CycleShuffleMode())); - connect(global_shortcuts_, SIGNAL(CycleRepeatMode()), app_->playlist_manager()->sequence(), SLOT(CycleRepeatMode())); + QObject::connect(global_shortcuts_, &GlobalShortcuts::CycleShuffleMode, app_->playlist_manager()->sequence(), &PlaylistSequence::CycleShuffleMode); + QObject::connect(global_shortcuts_, &GlobalShortcuts::CycleRepeatMode, app_->playlist_manager()->sequence(), &PlaylistSequence::CycleRepeatMode); #endif - connect(app_->playlist_manager()->sequence(), SIGNAL(RepeatModeChanged(PlaylistSequence::RepeatMode)), osd_, SLOT(RepeatModeChanged(PlaylistSequence::RepeatMode))); - connect(app_->playlist_manager()->sequence(), SIGNAL(ShuffleModeChanged(PlaylistSequence::ShuffleMode)), osd_, SLOT(ShuffleModeChanged(PlaylistSequence::ShuffleMode))); + QObject::connect(app_->playlist_manager()->sequence(), &PlaylistSequence::RepeatModeChanged, osd_, &OSDBase::RepeatModeChanged); + QObject::connect(app_->playlist_manager()->sequence(), &PlaylistSequence::ShuffleModeChanged, osd_, &OSDBase::ShuffleModeChanged); // Smart playlists - connect(smartplaylists_view_, SIGNAL(AddToPlaylist(QMimeData*)), SLOT(AddToPlaylist(QMimeData*))); + QObject::connect(smartplaylists_view_, &SmartPlaylistsViewContainer::AddToPlaylist, this, &MainWindow::AddToPlaylist); ScrobbleButtonVisibilityChanged(app_->scrobbler()->ScrobbleButton()); LoveButtonVisibilityChanged(app_->scrobbler()->LoveButton()); ScrobblingEnabledChanged(app_->scrobbler()->IsEnabled()); // Last.fm ImportData - connect(app_->lastfm_import(), SIGNAL(Finished()), lastfm_import_dialog_, SLOT(Finished())); - connect(app_->lastfm_import(), SIGNAL(FinishedWithError(QString)), lastfm_import_dialog_, SLOT(FinishedWithError(QString))); - connect(app_->lastfm_import(), SIGNAL(UpdateTotal(int, int)), lastfm_import_dialog_, SLOT(UpdateTotal(int, int))); - connect(app_->lastfm_import(), SIGNAL(UpdateProgress(int, int)), lastfm_import_dialog_, SLOT(UpdateProgress(int, int))); + QObject::connect(app_->lastfm_import(), &LastFMImport::Finished, lastfm_import_dialog_, &LastFMImportDialog::Finished); + QObject::connect(app_->lastfm_import(), &LastFMImport::FinishedWithError, lastfm_import_dialog_, &LastFMImportDialog::FinishedWithError); + QObject::connect(app_->lastfm_import(), &LastFMImport::UpdateTotal, lastfm_import_dialog_, &LastFMImportDialog::UpdateTotal); + QObject::connect(app_->lastfm_import(), &LastFMImport::UpdateProgress, lastfm_import_dialog_, &LastFMImportDialog::UpdateProgress); // Load settings qLog(Debug) << "Loading settings"; @@ -958,7 +958,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd QShortcut *close_window_shortcut = new QShortcut(this); close_window_shortcut->setKey(Qt::CTRL | Qt::Key_W); - connect(close_window_shortcut, SIGNAL(activated()), SLOT(SetHiddenInTray())); + QObject::connect(close_window_shortcut, &QShortcut::activated, this, &MainWindow::ToggleHide); CheckFullRescanRevisions(); @@ -983,7 +983,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd qtsparkle::Updater *updater = new qtsparkle::Updater(sparkle_url, this); updater->SetNetworkAccessManager(new NetworkAccessManager(this)); updater->SetVersion(STRAWBERRY_VERSION_PACKAGE); - connect(check_updates, SIGNAL(triggered()), updater, SLOT(CheckNow())); + QObject::connect(check_updates, &QAction::triggered, updater, &qtsparkle::Updater::CheckNow); } #endif @@ -1169,7 +1169,7 @@ void MainWindow::Exit() { else { if (app_->player()->engine()->is_fadeout_enabled()) { // To shut down the application when fadeout will be finished - connect(app_->player()->engine(), SIGNAL(FadeoutFinishedSignal()), this, SLOT(DoExit())); + QObject::connect(app_->player()->engine(), &EngineBase::FadeoutFinishedSignal, this, &MainWindow::DoExit); if (app_->player()->GetState() == Engine::Playing) { app_->player()->Stop(); hide(); @@ -1184,7 +1184,7 @@ void MainWindow::Exit() { void MainWindow::DoExit() { - connect(app_, SIGNAL(ExitFinished()), this, SLOT(ExitFinished())); + QObject::connect(app_, &Application::ExitFinished, this, &MainWindow::ExitFinished); app_->Exit(); } @@ -1400,7 +1400,7 @@ void MainWindow::LoadPlaybackStatus() { s.endGroup(); if (resume_playback && playback_state != Engine::Empty && playback_state != Engine::Idle) { - connect(app_->playlist_manager(), SIGNAL(AllPlaylistsLoaded()), SLOT(ResumePlayback())); + QObject::connect(app_->playlist_manager(), &PlaylistManager::AllPlaylistsLoaded, this, &MainWindow::ResumePlayback); } } @@ -1409,7 +1409,7 @@ void MainWindow::ResumePlayback() { qLog(Debug) << "Resuming playback"; - disconnect(app_->playlist_manager(), SIGNAL(AllPlaylistsLoaded()), this, SLOT(ResumePlayback())); + QObject::disconnect(app_->playlist_manager(), &PlaylistManager::AllPlaylistsLoaded, this, &MainWindow::ResumePlayback); QSettings s; s.beginGroup(Player::kSettingsGroup); @@ -1520,6 +1520,10 @@ void MainWindow::ToggleShowHide() { } +void MainWindow::ToggleHide() { + if (!hidden_) SetHiddenInTray(true); +} + void MainWindow::StopAfterCurrent() { app_->playlist_manager()->current()->StopAfter(app_->playlist_manager()->current()->current_row()); emit StopAfterToggled(app_->playlist_manager()->active()->stop_after_current()); @@ -1687,7 +1691,7 @@ void MainWindow::AddToPlaylist(QMimeData *q_mimedata) { } -void MainWindow::AddToPlaylist(QAction *action) { +void MainWindow::AddToPlaylistFromAction(QAction *action) { const int destination = action->data().toInt(); PlaylistItemList items; @@ -1951,7 +1955,7 @@ void MainWindow::PlaylistRightClick(const QPoint &global_pos, const QModelIndex add_to_another_menu->addAction(new_playlist); playlist_add_to_another_ = playlist_menu_->insertMenu(ui_->action_remove_from_playlist, add_to_another_menu); - connect(add_to_another_menu, SIGNAL(triggered(QAction*)), SLOT(AddToPlaylist(QAction*))); + QObject::connect(add_to_another_menu, &QMenu::triggered, this, &MainWindow::AddToPlaylistFromAction); } @@ -2058,7 +2062,7 @@ void MainWindow::RenumberTracks() { if (song.IsEditable()) { song.set_track(track); TagReaderReply *reply = TagReaderClient::Instance()->SaveFile(song.url().toLocalFile(), song); - NewClosure(reply, SIGNAL(Finished(bool)), this, SLOT(SongSaveComplete(TagReaderReply*, QPersistentModelIndex)),reply, QPersistentModelIndex(source_index)); + NewClosure(reply, SIGNAL(Finished(bool)), this, SLOT(SongSaveComplete(TagReaderReply*, QPersistentModelIndex)), reply, QPersistentModelIndex(source_index)); } ++track; } @@ -2658,10 +2662,11 @@ SettingsDialog *MainWindow::CreateSettingsDialog() { #endif // Settings - connect(settings_dialog, SIGNAL(ReloadSettings()), SLOT(ReloadAllSettings())); + QObject::connect(settings_dialog, &SettingsDialog::ReloadSettings, this, &MainWindow::ReloadAllSettings); // Allows custom notification preview - connect(settings_dialog, SIGNAL(NotificationPreview(OSDBase::Behaviour, QString, QString)), SLOT(HandleNotificationPreview(OSDBase::Behaviour, QString, QString))); + QObject::connect(settings_dialog, &SettingsDialog::NotificationPreview, this, &MainWindow::HandleNotificationPreview); + return settings_dialog; } @@ -2680,8 +2685,8 @@ void MainWindow::OpenSettingsDialogAtPage(SettingsDialog::Page page) { EditTagDialog *MainWindow::CreateEditTagDialog() { EditTagDialog *edit_tag_dialog = new EditTagDialog(app_); - connect(edit_tag_dialog, SIGNAL(accepted()), SLOT(EditTagDialogAccepted())); - connect(edit_tag_dialog, SIGNAL(Error(QString)), SLOT(ShowErrorDialog(QString))); + QObject::connect(edit_tag_dialog, &EditTagDialog::accepted, this, &MainWindow::EditTagDialogAccepted); + QObject::connect(edit_tag_dialog, &EditTagDialog::Error, this, &MainWindow::ShowErrorDialog); return edit_tag_dialog; } @@ -2740,7 +2745,7 @@ void MainWindow::CheckFullRescanRevisions() { void MainWindow::PlaylistViewSelectionModelChanged() { - connect(ui_->playlist->view()->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), SLOT(PlaylistCurrentChanged(QModelIndex))); + QObject::connect(ui_->playlist->view()->selectionModel(), &QItemSelectionModel::currentChanged, this, &MainWindow::PlaylistCurrentChanged); } @@ -2790,11 +2795,11 @@ void MainWindow::AutoCompleteTags() { track_selection_dialog_.reset(new TrackSelectionDialog); track_selection_dialog_->set_save_on_close(true); - connect(tag_fetcher_.get(), SIGNAL(ResultAvailable(Song, SongList)), track_selection_dialog_.get(), SLOT(FetchTagFinished(Song, SongList)), Qt::QueuedConnection); - connect(tag_fetcher_.get(), SIGNAL(Progress(Song, QString)), track_selection_dialog_.get(), SLOT(FetchTagProgress(Song, QString))); - connect(track_selection_dialog_.get(), SIGNAL(accepted()), SLOT(AutoCompleteTagsAccepted())); - connect(track_selection_dialog_.get(), SIGNAL(finished(int)), tag_fetcher_.get(), SLOT(Cancel())); - connect(track_selection_dialog_.get(), SIGNAL(Error(QString)), SLOT(ShowErrorDialog(QString))); + QObject::connect(tag_fetcher_.get(), &TagFetcher::ResultAvailable, track_selection_dialog_.get(), &TrackSelectionDialog::FetchTagFinished, Qt::QueuedConnection); + QObject::connect(tag_fetcher_.get(), &TagFetcher::Progress, track_selection_dialog_.get(), &TrackSelectionDialog::FetchTagProgress); + QObject::connect(track_selection_dialog_.get(), &TrackSelectionDialog::accepted, this, &MainWindow::AutoCompleteTagsAccepted); + QObject::connect(track_selection_dialog_.get(), &TrackSelectionDialog::finished, tag_fetcher_.get(), &TagFetcher::Cancel); + QObject::connect(track_selection_dialog_.get(), &TrackSelectionDialog::Error, this, &MainWindow::ShowErrorDialog); } // Get the selected songs and start fetching tags for them @@ -3022,7 +3027,7 @@ void MainWindow::PlaylistDelete() { std::shared_ptr storage(new FilesystemMusicStorage("/")); DeleteFiles *delete_files = new DeleteFiles(app_->task_manager(), storage, true); - connect(delete_files, SIGNAL(Finished(SongList)), SLOT(DeleteFinished(SongList))); + //QObject::connect(delete_files, &DeleteFiles::Finished, this, &MainWindow::DeleteFinished); delete_files->Start(selected_songs); } diff --git a/src/core/mainwindow.h b/src/core/mainwindow.h index 2156561c..cda0ccef 100644 --- a/src/core/mainwindow.h +++ b/src/core/mainwindow.h @@ -130,12 +130,12 @@ class MainWindow : public QMainWindow, public PlatformInterface { bool LoadUrl(const QString &url) override; signals: - void AlbumCoverReady(const Song &song, const QImage &image); + void AlbumCoverReady(Song song, QImage image); void SearchCoverInProgress(); // Signals that stop playing after track was toggled. void StopAfterToggled(bool stop); - void AuthorizationUrlReceived(const QUrl &url); + void AuthorizationUrlReceived(QUrl url); private slots: void FilePathChanged(const QString &path); @@ -148,7 +148,7 @@ class MainWindow : public QMainWindow, public PlatformInterface { void ForceShowOSD(const Song &song, const bool toggle); void PlaylistMenuHidden(); - void PlaylistRightClick(const QPoint &global_pos, const QModelIndex &index); + void PlaylistRightClick(const QPoint &global_pos, const QModelIndex &idx); void PlaylistCurrentChanged(const QModelIndex ¤t); void PlaylistViewSelectionModelChanged(); void PlaylistPlay(); @@ -193,10 +193,11 @@ class MainWindow : public QMainWindow, public PlatformInterface { void EditFileTags(const QList &urls); void AddToPlaylist(QMimeData *q_mimedata); - void AddToPlaylist(QAction *action); + void AddToPlaylistFromAction(QAction *action); void VolumeWheelEvent(const int delta); void ToggleShowHide(); + void ToggleHide(); void Seeked(const qlonglong microseconds); void UpdateTrackPosition(); @@ -216,8 +217,6 @@ class MainWindow : public QMainWindow, public PlatformInterface { void AddStream(); void AddStreamAccepted(); - void CommandlineOptionsReceived(const quint32 instanceId, const QByteArray &string_options); - void CheckForUpdates(); void PlayingWidgetPositionChanged(const bool above_status_bar); @@ -244,8 +243,6 @@ class MainWindow : public QMainWindow, public PlatformInterface { void ResumePlayback(); void ResumePlaybackSeek(const int playback_position); - void Raise(); - void Exit(); void DoExit(); @@ -272,6 +269,10 @@ class MainWindow : public QMainWindow, public PlatformInterface { void PlaylistDelete(); + public slots: + void CommandlineOptionsReceived(const quint32 instanceId, const QByteArray &string_options); + void Raise(); + private: void SaveSettings(); diff --git a/src/core/mergedproxymodel.cpp b/src/core/mergedproxymodel.cpp index 985a792a..d58fb259 100644 --- a/src/core/mergedproxymodel.cpp +++ b/src/core/mergedproxymodel.cpp @@ -56,7 +56,7 @@ using boost::multi_index::multi_index_container; using boost::multi_index::ordered_unique; using boost::multi_index::tag; -std::size_t hash_value(const QModelIndex &index) { return qHash(index); } +std::size_t hash_value(const QModelIndex &idx) { return qHash(idx); } namespace { @@ -100,13 +100,13 @@ void MergedProxyModel::DeleteAllMappings() { void MergedProxyModel::AddSubModel(const QModelIndex &source_parent, QAbstractItemModel *submodel) { - connect(submodel, SIGNAL(modelAboutToBeReset()), this, SLOT(SubModelAboutToBeReset())); - connect(submodel, SIGNAL(modelReset()), this, SLOT(SubModelReset())); - connect(submodel, SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(RowsAboutToBeInserted(QModelIndex, int, int))); - connect(submodel, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(RowsAboutToBeRemoved(QModelIndex, int, int))); - connect(submodel, SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(RowsInserted(QModelIndex, int, int))); - connect(submodel, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(RowsRemoved(QModelIndex, int, int))); - connect(submodel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(DataChanged(QModelIndex, QModelIndex))); + QObject::connect(submodel, &QAbstractItemModel::modelAboutToBeReset, this, &MergedProxyModel::SubModelAboutToBeReset); + QObject::connect(submodel, &QAbstractItemModel::modelReset, this, &MergedProxyModel::SubModelResetSlot); + QObject::connect(submodel, &QAbstractItemModel::rowsAboutToBeInserted, this, &MergedProxyModel::RowsAboutToBeInserted); + QObject::connect(submodel, &QAbstractItemModel::rowsAboutToBeRemoved, this, &MergedProxyModel::RowsAboutToBeRemoved); + QObject::connect(submodel, &QAbstractItemModel::rowsInserted, this, &MergedProxyModel::RowsInserted); + QObject::connect(submodel, &QAbstractItemModel::rowsRemoved, this, &MergedProxyModel::RowsRemoved); + QObject::connect(submodel, &QAbstractItemModel::dataChanged, this, &MergedProxyModel::DataChanged); QModelIndex proxy_parent = mapFromSource(source_parent); const int rows = submodel->rowCount(); @@ -153,26 +153,26 @@ void MergedProxyModel::RemoveSubModel(const QModelIndex &source_parent) { void MergedProxyModel::setSourceModel(QAbstractItemModel *source_model) { if (sourceModel()) { - disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(SourceModelReset())); - disconnect(sourceModel(), SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), this, SLOT(RowsAboutToBeInserted(QModelIndex,int,int))); - disconnect(sourceModel(), SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(RowsAboutToBeRemoved(QModelIndex,int,int))); - disconnect(sourceModel(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(RowsInserted(QModelIndex,int,int))); - disconnect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(RowsRemoved(QModelIndex,int,int))); - disconnect(sourceModel(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(DataChanged(QModelIndex, QModelIndex))); - disconnect(sourceModel(), SIGNAL(layoutAboutToBeChanged()), this, SLOT(LayoutAboutToBeChanged())); - disconnect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(LayoutChanged())); + QObject::disconnect(sourceModel(), &QAbstractItemModel::modelReset, this, &MergedProxyModel::SourceModelReset); + QObject::disconnect(sourceModel(), &QAbstractItemModel::rowsAboutToBeInserted, this, &MergedProxyModel::RowsAboutToBeInserted); + QObject::disconnect(sourceModel(), &QAbstractItemModel::rowsAboutToBeRemoved, this, &MergedProxyModel::RowsAboutToBeRemoved); + QObject::disconnect(sourceModel(), &QAbstractItemModel::rowsInserted, this, &MergedProxyModel::RowsInserted); + QObject::disconnect(sourceModel(), &QAbstractItemModel::rowsRemoved, this, &MergedProxyModel::RowsRemoved); + QObject::disconnect(sourceModel(), &QAbstractItemModel::dataChanged, this, &MergedProxyModel::DataChanged); + QObject::disconnect(sourceModel(), &QAbstractItemModel::layoutAboutToBeChanged, this, &MergedProxyModel::LayoutAboutToBeChanged); + QObject::disconnect(sourceModel(), &QAbstractItemModel::layoutChanged, this, &MergedProxyModel::LayoutChanged); } QAbstractProxyModel::setSourceModel(source_model); - connect(sourceModel(), SIGNAL(modelReset()), this, SLOT(SourceModelReset())); - connect(sourceModel(), SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(RowsAboutToBeInserted(QModelIndex, int, int))); - connect(sourceModel(), SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(RowsAboutToBeRemoved(QModelIndex, int, int))); - connect(sourceModel(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(RowsInserted(QModelIndex,int,int))); - connect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(RowsRemoved(QModelIndex,int,int))); - connect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(DataChanged(QModelIndex,QModelIndex))); - connect(sourceModel(), SIGNAL(layoutAboutToBeChanged()), this, SLOT(LayoutAboutToBeChanged())); - connect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(LayoutChanged())); + QObject::connect(sourceModel(), &QAbstractItemModel::modelReset, this, &MergedProxyModel::SourceModelReset); + QObject::connect(sourceModel(), &QAbstractItemModel::rowsAboutToBeInserted, this, &MergedProxyModel::RowsAboutToBeInserted); + QObject::connect(sourceModel(), &QAbstractItemModel::rowsAboutToBeRemoved, this, &MergedProxyModel::RowsAboutToBeRemoved); + QObject::connect(sourceModel(), &QAbstractItemModel::rowsInserted, this, &MergedProxyModel::RowsInserted); + QObject::connect(sourceModel(), &QAbstractItemModel::rowsRemoved, this, &MergedProxyModel::RowsRemoved); + QObject::connect(sourceModel(), &QAbstractItemModel::dataChanged, this, &MergedProxyModel::DataChanged); + QObject::connect(sourceModel(), &QAbstractItemModel::layoutAboutToBeChanged, this, &MergedProxyModel::LayoutAboutToBeChanged); + QObject::connect(sourceModel(), &QAbstractItemModel::layoutChanged, this, &MergedProxyModel::LayoutChanged); } @@ -219,7 +219,7 @@ void MergedProxyModel::SubModelAboutToBeReset() { } -void MergedProxyModel::SubModelReset() { +void MergedProxyModel::SubModelResetSlot() { QAbstractItemModel *submodel = static_cast(sender()); @@ -393,22 +393,22 @@ QMap MergedProxyModel::itemData(const QModelIndex &proxy_index) c } -Qt::ItemFlags MergedProxyModel::flags(const QModelIndex &index) const { +Qt::ItemFlags MergedProxyModel::flags(const QModelIndex &idx) const { - QModelIndex source_index = mapToSource(index); + QModelIndex source_index = mapToSource(idx); if (!source_index.isValid()) return sourceModel()->flags(QModelIndex()); return source_index.model()->flags(source_index); } -bool MergedProxyModel::setData(const QModelIndex &index, const QVariant &value, int role) { +bool MergedProxyModel::setData(const QModelIndex &idx, const QVariant &value, int role) { - QModelIndex source_index = mapToSource(index); + QModelIndex source_index = mapToSource(idx); if (!source_index.isValid()) - return sourceModel()->setData(index, value, role); - return GetModel(index)->setData(index, value, role); + return sourceModel()->setData(idx, value, role); + return GetModel(idx)->setData(idx, value, role); } @@ -542,8 +542,8 @@ bool MergedProxyModel::IsKnownModel(const QAbstractItemModel *model) const { QModelIndexList MergedProxyModel::mapFromSource(const QModelIndexList &source_indexes) const { QModelIndexList ret; - for (const QModelIndex &index : source_indexes) { - ret << mapFromSource(index); + for (const QModelIndex &idx : source_indexes) { + ret << mapFromSource(idx); } return ret; @@ -552,8 +552,8 @@ QModelIndexList MergedProxyModel::mapFromSource(const QModelIndexList &source_in QModelIndexList MergedProxyModel::mapToSource(const QModelIndexList &proxy_indexes) const { QModelIndexList ret; - for (const QModelIndex &index : proxy_indexes) { - ret << mapToSource(index); + for (const QModelIndex &idx : proxy_indexes) { + ret << mapToSource(idx); } return ret; diff --git a/src/core/mergedproxymodel.h b/src/core/mergedproxymodel.h index 03c6b238..1f827dc0 100644 --- a/src/core/mergedproxymodel.h +++ b/src/core/mergedproxymodel.h @@ -36,7 +36,7 @@ class QMimeData; -std::size_t hash_value(const QModelIndex &index); +std::size_t hash_value(const QModelIndex &idx); class MergedProxyModelPrivate; @@ -63,8 +63,8 @@ class MergedProxyModel : public QAbstractProxyModel { QVariant data(const QModelIndex &proxy_index, int role = Qt::DisplayRole) const override; bool hasChildren(const QModelIndex &parent) const override; QMap itemData(const QModelIndex &proxy_index) const override; - Qt::ItemFlags flags(const QModelIndex &index) const override; - bool setData(const QModelIndex &index, const QVariant &value, int role) override; + Qt::ItemFlags flags(const QModelIndex &idx) const override; + bool setData(const QModelIndex &idx, const QVariant &value, int role) override; QStringList mimeTypes() const override; QMimeData *mimeData(const QModelIndexList &indexes) const override; bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; @@ -83,12 +83,12 @@ class MergedProxyModel : public QAbstractProxyModel { QModelIndexList mapToSource(const QModelIndexList &proxy_indexes) const; signals: - void SubModelReset(const QModelIndex &root, QAbstractItemModel *model); + void SubModelReset(QModelIndex root, QAbstractItemModel *model); private slots: void SourceModelReset(); void SubModelAboutToBeReset(); - void SubModelReset(); + void SubModelResetSlot(); void RowsAboutToBeInserted(const QModelIndex &source_parent, int start, int end); void RowsInserted(const QModelIndex &source_parent, int start, int end); diff --git a/src/core/mpris.cpp b/src/core/mpris.cpp index aa53f88e..0eddb497 100644 --- a/src/core/mpris.cpp +++ b/src/core/mpris.cpp @@ -28,7 +28,7 @@ namespace mpris { Mpris::Mpris(Application *app, QObject *parent) : QObject(parent), mpris2_(new mpris::Mpris2(app, this)) { - connect(mpris2_, SIGNAL(RaiseMainWindow()), SIGNAL(RaiseMainWindow())); + QObject::connect(mpris2_, &Mpris2::RaiseMainWindow, this, &Mpris::RaiseMainWindow); } } // namespace mpris diff --git a/src/core/mpris.h b/src/core/mpris.h index 4b8065b0..638a4b52 100644 --- a/src/core/mpris.h +++ b/src/core/mpris.h @@ -38,7 +38,7 @@ class Mpris : public QObject { public: explicit Mpris(Application *app, QObject *parent = nullptr); -signals: + signals: void RaiseMainWindow(); private: @@ -48,4 +48,3 @@ signals: } // namespace mpris #endif // MPRIS_H - diff --git a/src/core/mpris2.cpp b/src/core/mpris2.cpp index 6c34b49c..1a96080f 100644 --- a/src/core/mpris2.cpp +++ b/src/core/mpris2.cpp @@ -120,16 +120,16 @@ Mpris2::Mpris2(Application *app, QObject *parent) return; } - connect(app_->current_albumcover_loader(), SIGNAL(AlbumCoverLoaded(Song, AlbumCoverLoaderResult)), SLOT(AlbumCoverLoaded(Song, AlbumCoverLoaderResult))); + QObject::connect(app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::AlbumCoverLoaded, this, &Mpris2::AlbumCoverLoaded); - connect(app_->player()->engine(), SIGNAL(StateChanged(Engine::State)), SLOT(EngineStateChanged(Engine::State))); - connect(app_->player(), SIGNAL(VolumeChanged(int)), SLOT(VolumeChanged())); - connect(app_->player(), SIGNAL(Seeked(qlonglong)), SIGNAL(Seeked(qlonglong))); + QObject::connect(app_->player()->engine(), &EngineBase::StateChanged, this, &Mpris2::EngineStateChanged); + QObject::connect(app_->player(), &Player::VolumeChanged, this, &Mpris2::VolumeChanged); + QObject::connect(app_->player(), &Player::Seeked, this, &Mpris2::Seeked); - connect(app_->playlist_manager(), SIGNAL(PlaylistManagerInitialized()), SLOT(PlaylistManagerInitialized())); - connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), SLOT(CurrentSongChanged(Song))); - connect(app_->playlist_manager(), SIGNAL(PlaylistChanged(Playlist*)), SLOT(PlaylistChanged(Playlist*))); - connect(app_->playlist_manager(), SIGNAL(CurrentChanged(Playlist*)), SLOT(PlaylistCollectionChanged(Playlist*))); + QObject::connect(app_->playlist_manager(), &PlaylistManager::PlaylistManagerInitialized, this, &Mpris2::PlaylistManagerInitialized); + QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &Mpris2::CurrentSongChanged); + QObject::connect(app_->playlist_manager(), &PlaylistManager::PlaylistChanged, this, &Mpris2::PlaylistChangedSlot); + QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentChanged, this, &Mpris2::PlaylistCollectionChanged); app_name_[0] = app_name_[0].toUpper(); @@ -159,8 +159,8 @@ Mpris2::Mpris2(Application *app, QObject *parent) // when PlaylistManager gets it ready, we connect PlaylistSequence with this void Mpris2::PlaylistManagerInitialized() { - connect(app_->playlist_manager()->sequence(), SIGNAL(ShuffleModeChanged(PlaylistSequence::ShuffleMode)), SLOT(ShuffleModeChanged())); - connect(app_->playlist_manager()->sequence(), SIGNAL(RepeatModeChanged(PlaylistSequence::RepeatMode)), SLOT(RepeatModeChanged())); + QObject::connect(app_->playlist_manager()->sequence(), &PlaylistSequence::ShuffleModeChanged, this, &Mpris2::ShuffleModeChanged); + QObject::connect(app_->playlist_manager()->sequence(), &PlaylistSequence::RepeatModeChanged, this, &Mpris2::RepeatModeChanged); } void Mpris2::EngineStateChanged(Engine::State newState) { @@ -605,11 +605,12 @@ MprisPlaylistList Mpris2::GetPlaylists(quint32 index, quint32 max_count, const Q } -void Mpris2::PlaylistChanged(Playlist *playlist) { +void Mpris2::PlaylistChangedSlot(Playlist *playlist) { MprisPlaylist mpris_playlist; mpris_playlist.id = MakePlaylistPath(playlist->id()); mpris_playlist.name = app_->playlist_manager()->GetPlaylistName(playlist->id()); + emit PlaylistChanged(mpris_playlist); } diff --git a/src/core/mpris2.h b/src/core/mpris2.h index 516ba874..7811a631 100644 --- a/src/core/mpris2.h +++ b/src/core/mpris2.h @@ -185,7 +185,7 @@ class Mpris2 : public QObject { void ActivatePlaylist(const QDBusObjectPath &playlist_id); QList GetPlaylists(quint32 index, quint32 max_count, const QString &order, bool reverse_order); -signals: + signals: // Player void Seeked(qlonglong position); @@ -209,7 +209,7 @@ signals: void CurrentSongChanged(const Song &song); void ShuffleModeChanged(); void RepeatModeChanged(); - void PlaylistChanged(Playlist *playlist); + void PlaylistChangedSlot(Playlist *playlist); void PlaylistCollectionChanged(Playlist *playlist); private: diff --git a/src/core/mpris_common.h b/src/core/mpris_common.h index 68a7aa9d..b78dc9dc 100644 --- a/src/core/mpris_common.h +++ b/src/core/mpris_common.h @@ -62,4 +62,3 @@ inline QString AsMPRISDateTimeType(const int time) { } // namespace mpris #endif // MPRIS_COMMON_H - diff --git a/src/core/multisortfilterproxy.h b/src/core/multisortfilterproxy.h index 5a36b4da..e010cddc 100644 --- a/src/core/multisortfilterproxy.h +++ b/src/core/multisortfilterproxy.h @@ -47,4 +47,3 @@ class MultiSortFilterProxy : public QSortFilterProxyModel { }; #endif // MULTISORTFILTERPROXY_H - diff --git a/src/core/musicstorage.h b/src/core/musicstorage.h index 099bff73..e7c744d1 100644 --- a/src/core/musicstorage.h +++ b/src/core/musicstorage.h @@ -97,4 +97,3 @@ Q_DECLARE_METATYPE(MusicStorage*) Q_DECLARE_METATYPE(std::shared_ptr) #endif // MUSICSTORAGE_H - diff --git a/src/core/networktimeouts.cpp b/src/core/networktimeouts.cpp index 6d3e6771..38779462 100644 --- a/src/core/networktimeouts.cpp +++ b/src/core/networktimeouts.cpp @@ -34,8 +34,8 @@ void NetworkTimeouts::AddReply(QNetworkReply *reply) { if (timers_.contains(reply)) return; - connect(reply, SIGNAL(destroyed()), SLOT(ReplyFinished())); - connect(reply, SIGNAL(finished()), SLOT(ReplyFinished())); + QObject::connect(reply, &QNetworkReply::destroyed, this, &NetworkTimeouts::ReplyFinished); + QObject::connect(reply, &QNetworkReply::finished, this, &NetworkTimeouts::ReplyFinished); timers_[reply] = startTimer(timeout_msec_); } diff --git a/src/core/player.cpp b/src/core/player.cpp index 93017561..d97e5a41 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -170,20 +170,20 @@ void Player::Init() { analyzer_->SetEngine(engine_.get()); - connect(engine_.get(), SIGNAL(Error(QString)), SIGNAL(Error(QString))); - connect(engine_.get(), SIGNAL(FatalError()), SLOT(FatalError())); - connect(engine_.get(), SIGNAL(ValidSongRequested(QUrl)), SLOT(ValidSongRequested(QUrl))); - connect(engine_.get(), SIGNAL(InvalidSongRequested(QUrl)), SLOT(InvalidSongRequested(QUrl))); - connect(engine_.get(), SIGNAL(StateChanged(Engine::State)), SLOT(EngineStateChanged(Engine::State))); - connect(engine_.get(), SIGNAL(TrackAboutToEnd()), SLOT(TrackAboutToEnd())); - connect(engine_.get(), SIGNAL(TrackEnded()), SLOT(TrackEnded())); - connect(engine_.get(), SIGNAL(MetaData(Engine::SimpleMetaBundle)), SLOT(EngineMetadataReceived(Engine::SimpleMetaBundle))); + QObject::connect(engine_.get(), &EngineBase::Error, this, &Player::Error); + QObject::connect(engine_.get(), &EngineBase::FatalError, this, &Player::FatalError); + QObject::connect(engine_.get(), &EngineBase::ValidSongRequested, this, &Player::ValidSongRequested); + QObject::connect(engine_.get(), &EngineBase::InvalidSongRequested, this, &Player::InvalidSongRequested); + QObject::connect(engine_.get(), &EngineBase::StateChanged, this, &Player::EngineStateChanged); + QObject::connect(engine_.get(), &EngineBase::TrackAboutToEnd, this, &Player::TrackAboutToEnd); + QObject::connect(engine_.get(), &EngineBase::TrackEnded, this, &Player::TrackEnded); + QObject::connect(engine_.get(), &EngineBase::MetaData, this, &Player::EngineMetadataReceived); // Equalizer - connect(equalizer_, SIGNAL(StereoBalancerEnabledChanged(bool)), app_->player()->engine(), SLOT(SetStereoBalancerEnabled(bool))); - connect(equalizer_, SIGNAL(StereoBalanceChanged(float)), app_->player()->engine(), SLOT(SetStereoBalance(float))); - connect(equalizer_, SIGNAL(EqualizerEnabledChanged(bool)), app_->player()->engine(), SLOT(SetEqualizerEnabled(bool))); - connect(equalizer_, SIGNAL(EqualizerParametersChanged(int, QList)), app_->player()->engine(), SLOT(SetEqualizerParameters(int, QList))); + QObject::connect(equalizer_, &Equalizer::StereoBalancerEnabledChanged, app_->player()->engine(), &EngineBase::SetStereoBalancerEnabled); + QObject::connect(equalizer_, &Equalizer::StereoBalanceChanged, app_->player()->engine(), &EngineBase::SetStereoBalance); + QObject::connect(equalizer_, &Equalizer::EqualizerEnabledChanged, app_->player()->engine(), &EngineBase::SetEqualizerEnabled); + QObject::connect(equalizer_, &Equalizer::EqualizerParametersChanged, app_->player()->engine(), &EngineBase::SetEqualizerParameters); engine_->SetStereoBalancerEnabled(equalizer_->is_stereo_balancer_enabled()); engine_->SetStereoBalance(equalizer_->stereo_balance()); @@ -828,8 +828,8 @@ void Player::RegisterUrlHandler(UrlHandler *handler) { qLog(Info) << "Registered URL handler for" << scheme; url_handlers_.insert(scheme, handler); - connect(handler, SIGNAL(destroyed(QObject*)), SLOT(UrlHandlerDestroyed(QObject*))); - connect(handler, SIGNAL(AsyncLoadComplete(UrlHandler::LoadResult)), SLOT(HandleLoadResult(UrlHandler::LoadResult))); + QObject::connect(handler, &UrlHandler::destroyed, this, &Player::UrlHandlerDestroyed); + QObject::connect(handler, &UrlHandler::AsyncLoadComplete, this, &Player::HandleLoadResult); } @@ -843,8 +843,8 @@ void Player::UnregisterUrlHandler(UrlHandler *handler) { qLog(Info) << "Unregistered URL handler for" << scheme; url_handlers_.remove(scheme); - disconnect(handler, SIGNAL(destroyed(QObject*)), this, SLOT(UrlHandlerDestroyed(QObject*))); - disconnect(handler, SIGNAL(AsyncLoadComplete(UrlHandler::LoadResult)), this, SLOT(HandleLoadResult(UrlHandler::LoadResult))); + QObject::disconnect(handler, &UrlHandler::destroyed, this, &Player::UrlHandlerDestroyed); + QObject::disconnect(handler, &UrlHandler::AsyncLoadComplete, this, &Player::HandleLoadResult); } diff --git a/src/core/player.h b/src/core/player.h index 3a092b47..575baad5 100644 --- a/src/core/player.h +++ b/src/core/player.h @@ -77,6 +77,7 @@ class PlayerInterface : public QObject { // If there's currently a song playing, pause it, otherwise play the track that was playing last, or the first one on the playlist virtual void PlayPause(Playlist::AutoScroll autoscroll = Playlist::AutoScroll_Always) = 0; + virtual void PlayPauseHelper() = 0; virtual void RestartOrPrevious() = 0; // Skips this track. Might load more of the current radio station. @@ -106,11 +107,10 @@ class PlayerInterface : public QObject { // Emitted only when playback is manually resumed void Resumed(); void Stopped(); - void Error(); + void Error(QString message = QString()); void PlaylistFinished(); void VolumeEnabled(bool); void VolumeChanged(int volume); - void Error(QString message); void TrackSkipped(PlaylistItemPtr old_track); // Emitted when there's a manual change to the current's track position. void Seeked(qlonglong microseconds); @@ -160,6 +160,7 @@ class Player : public PlayerInterface { void PlayAt(const int index, Engine::TrackChangeFlags change, const Playlist::AutoScroll autoscroll, const bool reshuffle, const bool force_inform = false) override; void PlayPause(Playlist::AutoScroll autoscroll = Playlist::AutoScroll_Always) override; + void PlayPauseHelper() override { PlayPause(); } void RestartOrPrevious() override; void Next() override; void Previous() override; diff --git a/src/core/qt_blurimage.h b/src/core/qt_blurimage.h index 10084419..91e4727e 100644 --- a/src/core/qt_blurimage.h +++ b/src/core/qt_blurimage.h @@ -26,4 +26,4 @@ // Exported by QtGui void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0); -#endif // QT_BLURIMAGE_H +#endif // QT_BLURIMAGE_H diff --git a/src/core/qtfslistener.cpp b/src/core/qtfslistener.cpp index 13fb8e91..f0993686 100644 --- a/src/core/qtfslistener.cpp +++ b/src/core/qtfslistener.cpp @@ -28,7 +28,7 @@ QtFSListener::QtFSListener(QObject *parent) : FileSystemWatcherInterface(parent), watcher_(this) { - connect(&watcher_, SIGNAL(directoryChanged(QString)), SIGNAL(PathChanged(QString))); + QObject::connect(&watcher_, &QFileSystemWatcher::directoryChanged, this, &QtFSListener::PathChanged); } diff --git a/src/core/qtfslistener.h b/src/core/qtfslistener.h index 15fa12a6..dea4b79c 100644 --- a/src/core/qtfslistener.h +++ b/src/core/qtfslistener.h @@ -43,4 +43,4 @@ class QtFSListener : public FileSystemWatcherInterface { }; -#endif +#endif // QTFSLISTENER_H diff --git a/src/core/qtsystemtrayicon.cpp b/src/core/qtsystemtrayicon.cpp index fa208967..6ab6dee6 100644 --- a/src/core/qtsystemtrayicon.cpp +++ b/src/core/qtsystemtrayicon.cpp @@ -62,7 +62,7 @@ QtSystemTrayIcon::QtSystemTrayIcon(QObject *parent) tray_->installEventFilter(this); ClearNowPlaying(); - connect(tray_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(Clicked(QSystemTrayIcon::ActivationReason))); + QObject::connect(tray_, &QSystemTrayIcon::activated, this, &QtSystemTrayIcon::Clicked); } @@ -122,23 +122,23 @@ void QtSystemTrayIcon::SetupMenu(QAction *previous, QAction *play, QAction *stop // Creating new actions and connecting them to old ones. // This allows us to use old actions without displaying shortcuts that can not be used when Strawberry's window is hidden - menu_->addAction(previous->icon(), previous->text(), previous, SLOT(trigger())); - action_play_pause_ = menu_->addAction(play->icon(), play->text(), play, SLOT(trigger())); - action_stop_ = menu_->addAction(stop->icon(), stop->text(), stop, SLOT(trigger())); - action_stop_after_this_track_ = menu_->addAction(stop_after->icon(), stop_after->text(), stop_after, SLOT(trigger())); - menu_->addAction(next->icon(), next->text(), next, SLOT(trigger())); + menu_->addAction(previous->icon(), previous->text(), previous, &QAction::trigger); + action_play_pause_ = menu_->addAction(play->icon(), play->text(), play, &QAction::trigger); + action_stop_ = menu_->addAction(stop->icon(), stop->text(), stop, &QAction::trigger); + action_stop_after_this_track_ = menu_->addAction(stop_after->icon(), stop_after->text(), stop_after, &QAction::trigger); + menu_->addAction(next->icon(), next->text(), next, &QAction::trigger); menu_->addSeparator(); - action_mute_ = menu_->addAction(mute->icon(), mute->text(), mute, SLOT(trigger())); + action_mute_ = menu_->addAction(mute->icon(), mute->text(), mute, &QAction::trigger); action_mute_->setCheckable(true); action_mute_->setChecked(mute->isChecked()); menu_->addSeparator(); - action_love_ = menu_->addAction(love->icon(), love->text(), love, SLOT(trigger())); + action_love_ = menu_->addAction(love->icon(), love->text(), love, &QAction::trigger); action_love_->setVisible(love->isVisible()); action_love_->setEnabled(love->isEnabled()); menu_->addSeparator(); - menu_->addAction(quit->icon(), quit->text(), quit, SLOT(trigger())); + menu_->addAction(quit->icon(), quit->text(), quit, &QAction::trigger); tray_->setContextMenu(menu_); diff --git a/src/core/scopedgobject.h b/src/core/scopedgobject.h index f5a27606..1a291ba4 100644 --- a/src/core/scopedgobject.h +++ b/src/core/scopedgobject.h @@ -68,4 +68,3 @@ class ScopedGObject { }; #endif // SCOPEDGOBJECT_H - diff --git a/src/core/scopedtransaction.h b/src/core/scopedtransaction.h index e8422e60..77fd9e6c 100644 --- a/src/core/scopedtransaction.h +++ b/src/core/scopedtransaction.h @@ -41,4 +41,4 @@ class ScopedTransaction : boost::noncopyable { bool pending_; }; -#endif // SCOPEDTRANSACTION_H +#endif // SCOPEDTRANSACTION_H diff --git a/src/core/simpletreeitem.h b/src/core/simpletreeitem.h index 85785315..1247b02d 100644 --- a/src/core/simpletreeitem.h +++ b/src/core/simpletreeitem.h @@ -159,4 +159,3 @@ T *SimpleTreeItem::ChildByKey(const QString &_key) const { } #endif // SIMPLETREEITEM_H - diff --git a/src/core/simpletreemodel.h b/src/core/simpletreemodel.h index f876070d..157cdb5e 100644 --- a/src/core/simpletreemodel.h +++ b/src/core/simpletreemodel.h @@ -35,13 +35,13 @@ class SimpleTreeModel : public QAbstractItemModel { // QAbstractItemModel int columnCount(const QModelIndex &parent) const override; QModelIndex index(int row, int, const QModelIndex &parent = QModelIndex()) const override; - QModelIndex parent(const QModelIndex &index) const override; + QModelIndex parent(const QModelIndex &idx) const override; int rowCount(const QModelIndex &parent) const override; bool hasChildren(const QModelIndex &parent) const override; bool canFetchMore(const QModelIndex &parent) const override; void fetchMore(const QModelIndex &parent) override; - T *IndexToItem(const QModelIndex &index) const; + T *IndexToItem(const QModelIndex &idx) const; QModelIndex ItemToIndex(T *item) const; // Called by items @@ -63,9 +63,9 @@ SimpleTreeModel::SimpleTreeModel(T *root, QObject *parent) : QAbstractItemModel(parent), root_(root) {} template -T *SimpleTreeModel::IndexToItem(const QModelIndex &index) const { - if (!index.isValid()) return root_; - return reinterpret_cast(index.internalPointer()); +T *SimpleTreeModel::IndexToItem(const QModelIndex &idx) const { + if (!idx.isValid()) return root_; + return reinterpret_cast(idx.internalPointer()); } template @@ -81,16 +81,18 @@ int SimpleTreeModel::columnCount(const QModelIndex&) const { template QModelIndex SimpleTreeModel::index(int row, int, const QModelIndex &parent) const { + T *parent_item = IndexToItem(parent); if (!parent_item || row < 0 || parent_item->children.count() <= row) return QModelIndex(); return ItemToIndex(parent_item->children[row]); + } template -QModelIndex SimpleTreeModel::parent(const QModelIndex &index) const { - return ItemToIndex(IndexToItem(index)->parent); +QModelIndex SimpleTreeModel::parent(const QModelIndex &idx) const { + return ItemToIndex(IndexToItem(idx)->parent); } template diff --git a/src/core/song.h b/src/core/song.h index 4d22aab5..7ea8873c 100644 --- a/src/core/song.h +++ b/src/core/song.h @@ -388,4 +388,3 @@ uint qHash(const Song &song); uint HashSimilar(const Song &song); #endif // SONG_H - diff --git a/src/core/songloader.cpp b/src/core/songloader.cpp index d6ef5991..12a9486f 100644 --- a/src/core/songloader.cpp +++ b/src/core/songloader.cpp @@ -96,7 +96,7 @@ SongLoader::SongLoader(CollectionBackendInterface *collection, const Player *pla timeout_timer_->setSingleShot(true); - connect(timeout_timer_, SIGNAL(timeout()), SLOT(Timeout())); + QObject::connect(timeout_timer_, &QTimer::timeout, this, &SongLoader::Timeout); } @@ -182,8 +182,8 @@ SongLoader::Result SongLoader::LoadAudioCD() { #if defined(HAVE_AUDIOCD) && defined(HAVE_GSTREAMER) if (player_->engine()->type() == Engine::GStreamer) { CddaSongLoader *cdda_song_loader = new CddaSongLoader(QUrl(), this); - connect(cdda_song_loader, SIGNAL(SongsDurationLoaded(SongList, QString)), this, SLOT(AudioCDTracksLoadFinishedSlot(SongList, QString))); - connect(cdda_song_loader, SIGNAL(SongsMetadataLoaded(SongList)), this, SLOT(AudioCDTracksTagsLoaded(SongList))); + QObject::connect(cdda_song_loader, &CddaSongLoader::SongsDurationLoaded, this, &SongLoader::AudioCDTracksLoadFinishedSlot); + QObject::connect(cdda_song_loader, &CddaSongLoader::SongsMetadataLoaded, this, &SongLoader::AudioCDTracksTagsLoaded); cdda_song_loader->LoadSongs(); return Success; } @@ -460,7 +460,7 @@ SongLoader::Result SongLoader::LoadRemote() { gst_object_unref(pad); QEventLoop loop; - loop.connect(this, SIGNAL(LoadRemoteFinished()), SLOT(quit())); + loop.connect(this, &SongLoader::LoadRemoteFinished, &loop, &QEventLoop::quit); // Start "playing" gst_element_set_state(pipeline.get(), GST_STATE_PLAYING); diff --git a/src/core/songloader.h b/src/core/songloader.h index 8a8d8d5d..0a5842ab 100644 --- a/src/core/songloader.h +++ b/src/core/songloader.h @@ -88,7 +88,7 @@ class SongLoader : public QObject { signals: void AudioCDTracksLoadFinished(); - void LoadAudioCDFinished(const bool success); + void LoadAudioCDFinished(bool success); void LoadRemoteFinished(); private slots: @@ -159,4 +159,3 @@ class SongLoader : public QObject { }; #endif // SONGLOADER_H - diff --git a/src/core/standarditemiconloader.cpp b/src/core/standarditemiconloader.cpp index 783b865a..689f529d 100644 --- a/src/core/standarditemiconloader.cpp +++ b/src/core/standarditemiconloader.cpp @@ -40,19 +40,20 @@ StandardItemIconLoader::StandardItemIconLoader(AlbumCoverLoader *cover_loader, Q cover_options_.desired_height_ = 16; - connect(cover_loader_, SIGNAL(AlbumCoverLoaded(quint64, AlbumCoverLoaderResult)), SLOT(AlbumCoverLoaded(quint64, AlbumCoverLoaderResult))); + QObject::connect(cover_loader_, &AlbumCoverLoader::AlbumCoverLoaded, this, &StandardItemIconLoader::AlbumCoverLoaded); + } void StandardItemIconLoader::SetModel(QAbstractItemModel *model) { if (model_) { - disconnect(model_, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(RowsAboutToBeRemoved(QModelIndex, int, int))); + QObject::disconnect(model_, &QAbstractItemModel::rowsAboutToBeRemoved, this, &StandardItemIconLoader::RowsAboutToBeRemoved); } model_ = model; - connect(model_, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), SLOT(RowsAboutToBeRemoved(QModelIndex,int,int))); - connect(model_, SIGNAL(modelAboutToBeReset()), SLOT(ModelReset())); + QObject::connect(model_, &QAbstractItemModel::rowsAboutToBeRemoved, this, &StandardItemIconLoader::RowsAboutToBeRemoved); + QObject::connect(model_, &QAbstractItemModel::modelAboutToBeReset, this, &StandardItemIconLoader::ModelReset); } diff --git a/src/core/stylehelper.h b/src/core/stylehelper.h index c7ed596c..d0b4a2bd 100644 --- a/src/core/stylehelper.h +++ b/src/core/stylehelper.h @@ -105,4 +105,3 @@ private: using Utils::StyleHelper; #endif // STYLEHELPER_H - diff --git a/src/core/stylesheetloader.cpp b/src/core/stylesheetloader.cpp index b80e0ddf..2c9bb689 100644 --- a/src/core/stylesheetloader.cpp +++ b/src/core/stylesheetloader.cpp @@ -42,7 +42,7 @@ StyleSheetLoader::StyleSheetLoader(QObject *parent) : QObject(parent), timer_res timer_reset_counter_->setSingleShot(true); timer_reset_counter_->setInterval(1000); - connect(timer_reset_counter_, SIGNAL(timeout()), this, SLOT(ResetCounters())); + QObject::connect(timer_reset_counter_, &QTimer::timeout, this, &StyleSheetLoader::ResetCounters); } diff --git a/src/core/tagreaderclient.cpp b/src/core/tagreaderclient.cpp index dd91712a..27c4907d 100644 --- a/src/core/tagreaderclient.cpp +++ b/src/core/tagreaderclient.cpp @@ -47,7 +47,7 @@ TagReaderClient::TagReaderClient(QObject *parent) : QObject(parent), worker_pool worker_pool_->SetExecutableName(kWorkerExecutableName); worker_pool_->SetWorkerCount(qBound(1, QThread::idealThreadCount() / 2, 4)); - connect(worker_pool_, SIGNAL(WorkerFailedToStart()), SLOT(WorkerFailedToStart())); + QObject::connect(worker_pool_, &WorkerPool::WorkerFailedToStart, this, &TagReaderClient::WorkerFailedToStart); } diff --git a/src/core/taskmanager.h b/src/core/taskmanager.h index 55be352e..3fb98c8a 100644 --- a/src/core/taskmanager.h +++ b/src/core/taskmanager.h @@ -83,4 +83,3 @@ class TaskManager : public QObject { }; #endif // TASKMANAGER_H - diff --git a/src/core/translations.h b/src/core/translations.h index 651c86ab..7d18acda 100644 --- a/src/core/translations.h +++ b/src/core/translations.h @@ -17,6 +17,8 @@ * */ +#pragma once + #include "config.h" #include diff --git a/src/core/urlhandler.h b/src/core/urlhandler.h index 10601ed6..36bae689 100644 --- a/src/core/urlhandler.h +++ b/src/core/urlhandler.h @@ -90,7 +90,7 @@ class UrlHandler : public QObject { virtual LoadResult StartLoading(const QUrl &url) { return LoadResult(url); } signals: - void AsyncLoadComplete(const UrlHandler::LoadResult &result); + void AsyncLoadComplete(UrlHandler::LoadResult result); }; diff --git a/src/core/windows7thumbbar.cpp b/src/core/windows7thumbbar.cpp index 9c1ece09..bde2ff47 100644 --- a/src/core/windows7thumbbar.cpp +++ b/src/core/windows7thumbbar.cpp @@ -53,7 +53,7 @@ Windows7ThumbBar::Windows7ThumbBar(QWidget *widget) timer_->setSingleShot(true); timer_->setInterval(300); - connect(timer_, SIGNAL(timeout()), SLOT(ActionChanged())); + QObject::connect(timer_, &QTimer::timeout, this, &Windows7ThumbBar::ActionChanged); } @@ -65,7 +65,7 @@ void Windows7ThumbBar::SetActions(const QList &actions) { actions_ = actions; for (QAction *action : actions) { if (action) { - connect(action, SIGNAL(changed()), SLOT(ActionChangedTriggered())); + QObject::connect(action, &QAction::changed, this, &Windows7ThumbBar::ActionChangedTriggered); } } qLog(Debug) << "Done"; diff --git a/src/covermanager/albumcoverchoicecontroller.cpp b/src/covermanager/albumcoverchoicecontroller.cpp index 6672a677..ebca9007 100644 --- a/src/covermanager/albumcoverchoicecontroller.cpp +++ b/src/covermanager/albumcoverchoicecontroller.cpp @@ -112,7 +112,7 @@ void AlbumCoverChoiceController::Init(Application *app) { cover_searcher_ = new AlbumCoverSearcher(QIcon(":/pictures/cdcase.png"), app, this); cover_searcher_->Init(cover_fetcher_); - connect(cover_fetcher_, SIGNAL(AlbumCoverFetched(quint64, QUrl, QImage, CoverSearchStatistics)), this, SLOT(AlbumCoverFetched(quint64, QUrl, QImage, CoverSearchStatistics))); + QObject::connect(cover_fetcher_, &AlbumCoverFetcher::AlbumCoverFetched, this, &AlbumCoverChoiceController::AlbumCoverFetched); } diff --git a/src/covermanager/albumcoverexport.cpp b/src/covermanager/albumcoverexport.cpp index 83324079..ef93e74c 100644 --- a/src/covermanager/albumcoverexport.cpp +++ b/src/covermanager/albumcoverexport.cpp @@ -38,7 +38,7 @@ AlbumCoverExport::AlbumCoverExport(QWidget *parent) : QDialog(parent), ui_(new U ui_->setupUi(this); - connect(ui_->forceSize, SIGNAL(stateChanged(int)), SLOT(ForceSizeToggled(int))); + QObject::connect(ui_->forceSize, &QCheckBox::stateChanged, this, &AlbumCoverExport::ForceSizeToggled); } diff --git a/src/covermanager/albumcoverexport.h b/src/covermanager/albumcoverexport.h index ef3ada79..cba578c9 100644 --- a/src/covermanager/albumcoverexport.h +++ b/src/covermanager/albumcoverexport.h @@ -77,4 +77,3 @@ class AlbumCoverExport : public QDialog { }; #endif // ALBUMCOVEREXPORT_H - diff --git a/src/covermanager/albumcoverexporter.cpp b/src/covermanager/albumcoverexporter.cpp index 908c4f81..889f9c8c 100644 --- a/src/covermanager/albumcoverexporter.cpp +++ b/src/covermanager/albumcoverexporter.cpp @@ -61,8 +61,8 @@ void AlbumCoverExporter::AddJobsToPool() { while (!requests_.isEmpty() && thread_pool_->activeThreadCount() < thread_pool_->maxThreadCount()) { CoverExportRunnable *runnable = requests_.dequeue(); - connect(runnable, SIGNAL(CoverExported()), SLOT(CoverExported())); - connect(runnable, SIGNAL(CoverSkipped()), SLOT(CoverSkipped())); + QObject::connect(runnable, &CoverExportRunnable::CoverExported, this, &AlbumCoverExporter::CoverExported); + QObject::connect(runnable, &CoverExportRunnable::CoverSkipped, this, &AlbumCoverExporter::CoverSkipped); thread_pool_->start(runnable); } @@ -80,4 +80,3 @@ void AlbumCoverExporter::CoverSkipped() { emit AlbumCoversExportUpdate(exported_, skipped_, all_); AddJobsToPool(); } - diff --git a/src/covermanager/albumcoverexporter.h b/src/covermanager/albumcoverexporter.h index 19f53e46..f50f79ff 100644 --- a/src/covermanager/albumcoverexporter.h +++ b/src/covermanager/albumcoverexporter.h @@ -48,7 +48,7 @@ class AlbumCoverExporter : public QObject { int request_count() { return requests_.size(); } -signals: + signals: void AlbumCoversExportUpdate(int exported, int skipped, int all); private slots: diff --git a/src/covermanager/albumcoverfetcher.cpp b/src/covermanager/albumcoverfetcher.cpp index 9d31e735..d20965d9 100644 --- a/src/covermanager/albumcoverfetcher.cpp +++ b/src/covermanager/albumcoverfetcher.cpp @@ -42,7 +42,7 @@ AlbumCoverFetcher::AlbumCoverFetcher(CoverProviders *cover_providers, QObject *p request_starter_(new QTimer(this)) { request_starter_->setInterval(1000); - connect(request_starter_, SIGNAL(timeout()), SLOT(StartRequests())); + QObject::connect(request_starter_, &QTimer::timeout, this, &AlbumCoverFetcher::StartRequests); } @@ -127,8 +127,8 @@ void AlbumCoverFetcher::StartRequests() { AlbumCoverFetcherSearch *search = new AlbumCoverFetcherSearch(request, network_, this); active_requests_.insert(request.id, search); - connect(search, SIGNAL(SearchFinished(quint64, CoverSearchResults)), SLOT(SingleSearchFinished(quint64, CoverSearchResults))); - connect(search, SIGNAL(AlbumCoverFetched(quint64, QUrl, QImage)), SLOT(SingleCoverFetched(quint64, QUrl, QImage))); + QObject::connect(search, &AlbumCoverFetcherSearch::SearchFinished, this, &AlbumCoverFetcher::SingleSearchFinished); + QObject::connect(search, &AlbumCoverFetcherSearch::AlbumCoverFetched, this, &AlbumCoverFetcher::SingleCoverFetched); search->Start(cover_providers_); } diff --git a/src/covermanager/albumcoverfetcher.h b/src/covermanager/albumcoverfetcher.h index 382387da..59118d87 100644 --- a/src/covermanager/albumcoverfetcher.h +++ b/src/covermanager/albumcoverfetcher.h @@ -35,11 +35,12 @@ #include #include +#include "coversearchstatistics.h" + class QTimer; class NetworkAccessManager; class CoverProviders; class AlbumCoverFetcherSearch; -struct CoverSearchStatistics; // This class represents a single search-for-cover request. It identifies and describes the request. struct CoverSearchRequest { @@ -115,8 +116,8 @@ class AlbumCoverFetcher : public QObject { void Clear(); signals: - void AlbumCoverFetched(const quint64 request_id, const QUrl &cover_url, const QImage &cover, const CoverSearchStatistics &statistics); - void SearchFinished(const quint64 request_id, const CoverSearchResults &results, const CoverSearchStatistics &statistics); + void AlbumCoverFetched(quint64 request_id, QUrl cover_url, QImage cover, CoverSearchStatistics statistics); + void SearchFinished(quint64 request_id, CoverSearchResults results, CoverSearchStatistics statistics); private slots: void SingleSearchFinished(const quint64, const CoverSearchResults results); diff --git a/src/covermanager/albumcoverfetchersearch.cpp b/src/covermanager/albumcoverfetchersearch.cpp index 4f5e361f..311adf6d 100644 --- a/src/covermanager/albumcoverfetchersearch.cpp +++ b/src/covermanager/albumcoverfetchersearch.cpp @@ -60,7 +60,7 @@ AlbumCoverFetcherSearch::AlbumCoverFetcherSearch(const CoverSearchRequest &reque cancel_requested_(false) { // We will terminate the search after kSearchTimeoutMs milliseconds if we are not able to find all of the results before that point in time - QTimer::singleShot(kSearchTimeoutMs, this, SLOT(TerminateSearch())); + QTimer::singleShot(kSearchTimeoutMs, this, &AlbumCoverFetcherSearch::TerminateSearch); } @@ -109,8 +109,8 @@ void AlbumCoverFetcherSearch::Start(CoverProviders *cover_providers) { continue; } - connect(provider, SIGNAL(SearchResults(int, CoverSearchResults)), SLOT(ProviderSearchResults(int, CoverSearchResults))); - connect(provider, SIGNAL(SearchFinished(int, CoverSearchResults)), SLOT(ProviderSearchFinished(int, CoverSearchResults))); + QObject::connect(provider, &CoverProvider::SearchResults, this, QOverload::of(&AlbumCoverFetcherSearch::ProviderSearchResults)); + QObject::connect(provider, &CoverProvider::SearchFinished, this, &AlbumCoverFetcherSearch::ProviderSearchFinished); const int id = cover_providers->NextId(); const bool success = provider->StartSearch(request_.artist, request_.album, request_.title, id); @@ -286,7 +286,7 @@ void AlbumCoverFetcherSearch::FetchMoreImages() { req.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); #endif QNetworkReply *image_reply = network_->get(req); - connect(image_reply, &QNetworkReply::finished, [=] { ProviderCoverFetchFinished(image_reply); }); + QObject::connect(image_reply, &QNetworkReply::finished, [this, image_reply]() { ProviderCoverFetchFinished(image_reply); }); pending_image_loads_[image_reply] = result; image_load_timeout_->AddReply(image_reply); @@ -305,7 +305,7 @@ void AlbumCoverFetcherSearch::FetchMoreImages() { void AlbumCoverFetcherSearch::ProviderCoverFetchFinished(QNetworkReply *reply) { - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); if (!pending_image_loads_.contains(reply)) return; @@ -412,7 +412,7 @@ void AlbumCoverFetcherSearch::Cancel() { } else if (!pending_image_loads_.isEmpty()) { for (QNetworkReply *reply : pending_image_loads_.keys()) { - disconnect(reply, &QNetworkReply::finished, this, nullptr); + QObject::disconnect(reply, &QNetworkReply::finished, this, nullptr); reply->abort(); reply->deleteLater(); } diff --git a/src/covermanager/albumcoverfetchersearch.h b/src/covermanager/albumcoverfetchersearch.h index cdc2f65d..f705983b 100644 --- a/src/covermanager/albumcoverfetchersearch.h +++ b/src/covermanager/albumcoverfetchersearch.h @@ -63,19 +63,19 @@ class AlbumCoverFetcherSearch : public QObject { signals: // It's the end of search (when there was no fetch-me-a-cover request). - void SearchFinished(const quint64, const CoverSearchResults &results); + void SearchFinished(quint64, CoverSearchResults results); // It's the end of search and we've fetched a cover. void AlbumCoverFetched(const quint64, const QUrl &cover_url, const QImage &cover); private slots: void ProviderSearchResults(const int id, const CoverSearchResults &results); - void ProviderSearchResults(CoverProvider *provider, const CoverSearchResults &results); void ProviderSearchFinished(const int id, const CoverSearchResults &results); void ProviderCoverFetchFinished(QNetworkReply *reply); void TerminateSearch(); private: + void ProviderSearchResults(CoverProvider *provider, const CoverSearchResults &results); void AllProvidersFinished(); void FetchMoreImages(); diff --git a/src/covermanager/albumcoverloader.cpp b/src/covermanager/albumcoverloader.cpp index d34a01dc..dc950a8c 100644 --- a/src/covermanager/albumcoverloader.cpp +++ b/src/covermanager/albumcoverloader.cpp @@ -385,7 +385,7 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(Task *task) { request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); #endif QNetworkReply *reply = network_->get(request); - connect(reply, &QNetworkReply::finished, [=] { RemoteFetchFinished(reply, cover_url); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, cover_url]() { RemoteFetchFinished(reply, cover_url); }); remote_tasks_.insert(reply, *task); return TryLoadResult(true, false, type, cover_url, QImage()); @@ -417,7 +417,7 @@ void AlbumCoverLoader::RemoteFetchFinished(QNetworkReply *reply, const QUrl &cov #endif request.setUrl(redirect.toUrl()); QNetworkReply *redirected_reply = network_->get(request); - connect(redirected_reply, &QNetworkReply::finished, [=] { RemoteFetchFinished(redirected_reply, redirect.toUrl()); }); + QObject::connect(redirected_reply, &QNetworkReply::finished, [this, redirected_reply, redirect]() { RemoteFetchFinished(redirected_reply, redirect.toUrl()); }); remote_tasks_.insert(redirected_reply, task); return; diff --git a/src/covermanager/albumcovermanager.cpp b/src/covermanager/albumcovermanager.cpp index 7e1a9e9d..68dc7a44 100644 --- a/src/covermanager/albumcovermanager.cpp +++ b/src/covermanager/albumcovermanager.cpp @@ -131,13 +131,13 @@ AlbumCoverManager::AlbumCoverManager(Application *app, CollectionBackend *collec progress_bar_->hide(); abort_progress_->hide(); abort_progress_->setText(tr("Abort")); - connect(abort_progress_, SIGNAL(clicked()), this, SLOT(CancelRequests())); + QObject::connect(abort_progress_, &QPushButton::clicked, this, &AlbumCoverManager::CancelRequests); ui_->albums->setAttribute(Qt::WA_MacShowFocusRect, false); ui_->artists->setAttribute(Qt::WA_MacShowFocusRect, false); QShortcut *close = new QShortcut(QKeySequence::Close, this); - connect(close, SIGNAL(activated()), SLOT(close())); + QObject::connect(close, &QShortcut::activated, this, &AlbumCoverManager::close); EnableCoversButtons(); @@ -180,14 +180,14 @@ void AlbumCoverManager::Init() { QList actions = album_cover_choice_controller_->GetAllActions(); - connect(album_cover_choice_controller_->cover_from_file_action(), SIGNAL(triggered()), this, SLOT(LoadCoverFromFile())); - connect(album_cover_choice_controller_->cover_to_file_action(), SIGNAL(triggered()), this, SLOT(SaveCoverToFile())); - connect(album_cover_choice_controller_->cover_from_url_action(), SIGNAL(triggered()), this, SLOT(LoadCoverFromURL())); - connect(album_cover_choice_controller_->search_for_cover_action(), SIGNAL(triggered()), this, SLOT(SearchForCover())); - connect(album_cover_choice_controller_->unset_cover_action(), SIGNAL(triggered()), this, SLOT(UnsetCover())); - connect(album_cover_choice_controller_->show_cover_action(), SIGNAL(triggered()), this, SLOT(ShowCover())); + QObject::connect(album_cover_choice_controller_->cover_from_file_action(), &QAction::triggered, this, &AlbumCoverManager::LoadCoverFromFile); + QObject::connect(album_cover_choice_controller_->cover_to_file_action(), &QAction::triggered, this, &AlbumCoverManager::SaveCoverToFile); + QObject::connect(album_cover_choice_controller_->cover_from_url_action(), &QAction::triggered, this, &AlbumCoverManager::LoadCoverFromURL); + QObject::connect(album_cover_choice_controller_->search_for_cover_action(), &QAction::triggered, this, &AlbumCoverManager::SearchForCover); + QObject::connect(album_cover_choice_controller_->unset_cover_action(), &QAction::triggered, this, &AlbumCoverManager::UnsetCover); + QObject::connect(album_cover_choice_controller_->show_cover_action(), &QAction::triggered, this, &AlbumCoverManager::ShowCover); - connect(cover_exporter_, SIGNAL(AlbumCoversExportUpdate(int, int, int)), SLOT(UpdateExportStatus(int, int, int))); + QObject::connect(cover_exporter_, &AlbumCoverExporter::AlbumCoversExportUpdate, this, &AlbumCoverManager::UpdateExportStatus); context_menu_->addActions(actions); context_menu_->addSeparator(); @@ -197,17 +197,17 @@ void AlbumCoverManager::Init() { ui_->albums->installEventFilter(this); // Connections - connect(ui_->artists, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), SLOT(ArtistChanged(QListWidgetItem*))); - connect(ui_->filter, SIGNAL(textChanged(QString)), SLOT(UpdateFilter())); - connect(filter_group, SIGNAL(triggered(QAction*)), SLOT(UpdateFilter())); - connect(ui_->view, SIGNAL(clicked()), ui_->view, SLOT(showMenu())); - connect(ui_->button_fetch, SIGNAL(clicked()), SLOT(FetchAlbumCovers())); - connect(ui_->export_covers, SIGNAL(clicked()), SLOT(ExportCovers())); - connect(cover_fetcher_, SIGNAL(AlbumCoverFetched(quint64, QUrl, QImage, CoverSearchStatistics)), SLOT(AlbumCoverFetched(quint64, QUrl, QImage, CoverSearchStatistics))); - connect(ui_->action_fetch, SIGNAL(triggered()), SLOT(FetchSingleCover())); - connect(ui_->albums, SIGNAL(doubleClicked(QModelIndex)), SLOT(AlbumDoubleClicked(QModelIndex))); - connect(ui_->action_add_to_playlist, SIGNAL(triggered()), SLOT(AddSelectedToPlaylist())); - connect(ui_->action_load, SIGNAL(triggered()), SLOT(LoadSelectedToPlaylist())); + QObject::connect(ui_->artists, &QListWidget::currentItemChanged, this, &AlbumCoverManager::ArtistChanged); + QObject::connect(ui_->filter, &QSearchField::textChanged, this, &AlbumCoverManager::UpdateFilter); + QObject::connect(filter_group, &QActionGroup::triggered, this, &AlbumCoverManager::UpdateFilter); + QObject::connect(ui_->view, &QToolButton::clicked, ui_->view, &QToolButton::showMenu); + QObject::connect(ui_->button_fetch, &QPushButton::clicked, this, &AlbumCoverManager::FetchAlbumCovers); + QObject::connect(ui_->export_covers, &QPushButton::clicked, this, &AlbumCoverManager::ExportCovers); + QObject::connect(cover_fetcher_, &AlbumCoverFetcher::AlbumCoverFetched, this, &AlbumCoverManager::AlbumCoverFetched); + QObject::connect(ui_->action_fetch, &QAction::triggered, this, &AlbumCoverManager::FetchSingleCover); + QObject::connect(ui_->albums, &QListWidget::doubleClicked, this, &AlbumCoverManager::AlbumDoubleClicked); + QObject::connect(ui_->action_add_to_playlist, &QAction::triggered, this, &AlbumCoverManager::AddSelectedToPlaylist); + QObject::connect(ui_->action_load, &QAction::triggered, this, &AlbumCoverManager::LoadSelectedToPlaylist); // Restore settings QSettings s; @@ -219,7 +219,7 @@ void AlbumCoverManager::Init() { ui_->splitter->setSizes(QList() << 200 << width() - 200); } - connect(app_->album_cover_loader(), SIGNAL(AlbumCoverLoaded(quint64, AlbumCoverLoaderResult)), SLOT(AlbumCoverLoaded(quint64, AlbumCoverLoaderResult))); + QObject::connect(app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &AlbumCoverManager::AlbumCoverLoaded); cover_searcher_->Init(cover_fetcher_); @@ -541,7 +541,7 @@ void AlbumCoverManager::UpdateStatusText() { progress_bar_->setValue(fetch_statistics_.chosen_images_ + fetch_statistics_.missing_images_); if (cover_fetching_tasks_.isEmpty()) { - QTimer::singleShot(2000, statusBar(), SLOT(clearMessage())); + QTimer::singleShot(2000, statusBar(), &QStatusBar::clearMessage); progress_bar_->hide(); abort_progress_->hide(); @@ -757,17 +757,17 @@ void AlbumCoverManager::UnsetCover() { } -SongList AlbumCoverManager::GetSongsInAlbum(const QModelIndex &index) const { +SongList AlbumCoverManager::GetSongsInAlbum(const QModelIndex &idx) const { SongList ret; CollectionQuery q; q.SetColumnSpec("ROWID," + Song::kColumnSpec); - q.AddWhere("album", index.data(Role_AlbumName).toString()); + q.AddWhere("album", idx.data(Role_AlbumName).toString()); q.SetOrderBy("disc, track, title"); - QString artist = index.data(Role_ArtistName).toString(); - QString albumartist = index.data(Role_AlbumArtistName).toString(); + QString artist = idx.data(Role_ArtistName).toString(); + QString albumartist = idx.data(Role_AlbumArtistName).toString(); if (!albumartist.isEmpty()) { q.AddWhere("albumartist", albumartist); @@ -792,8 +792,8 @@ SongList AlbumCoverManager::GetSongsInAlbum(const QModelIndex &index) const { SongList AlbumCoverManager::GetSongsInAlbums(const QModelIndexList &indexes) const { SongList ret; - for (const QModelIndex &index : indexes) { - ret << GetSongsInAlbum(index); + for (const QModelIndex &idx : indexes) { + ret << GetSongsInAlbum(idx); } return ret; @@ -904,7 +904,7 @@ void AlbumCoverManager::UpdateExportStatus(const int exported, const int skipped // End of the current process if (exported + skipped >= max) { - QTimer::singleShot(2000, statusBar(), SLOT(clearMessage())); + QTimer::singleShot(2000, statusBar(), &QStatusBar::clearMessage); progress_bar_->hide(); abort_progress_->hide(); diff --git a/src/covermanager/albumcovermanager.h b/src/covermanager/albumcovermanager.h index 3c908ba0..b7b45ef9 100644 --- a/src/covermanager/albumcovermanager.h +++ b/src/covermanager/albumcovermanager.h @@ -79,7 +79,7 @@ class AlbumCoverManager : public QMainWindow { void EnableCoversButtons(); void DisableCoversButtons(); - SongList GetSongsInAlbum(const QModelIndex &index) const; + SongList GetSongsInAlbum(const QModelIndex &idx) const; SongList GetSongsInAlbums(const QModelIndexList &indexes) const; SongMimeData *GetMimeDataForAlbums(const QModelIndexList &indexes) const; diff --git a/src/covermanager/albumcovermanagerlist.h b/src/covermanager/albumcovermanagerlist.h index 84302082..f1d82650 100644 --- a/src/covermanager/albumcovermanagerlist.h +++ b/src/covermanager/albumcovermanagerlist.h @@ -57,4 +57,3 @@ class AlbumCoverManagerList : public QListWidget { }; #endif // ALBUMCOVERMANAGERLIST_H - diff --git a/src/covermanager/albumcoversearcher.cpp b/src/covermanager/albumcoversearcher.cpp index e97c51d7..852b9262 100644 --- a/src/covermanager/albumcoversearcher.cpp +++ b/src/covermanager/albumcoversearcher.cpp @@ -71,15 +71,15 @@ const int SizeOverlayDelegate::kBackgroundAlpha = 175; SizeOverlayDelegate::SizeOverlayDelegate(QObject *parent) : QStyledItemDelegate(parent) {} -void SizeOverlayDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { +void SizeOverlayDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const { - QStyledItemDelegate::paint(painter, option, index); + QStyledItemDelegate::paint(painter, option, idx); - if (!index.data(AlbumCoverSearcher::Role_ImageFetchFinished).toBool()) { + if (!idx.data(AlbumCoverSearcher::Role_ImageFetchFinished).toBool()) { return; } - const QSize size = index.data(AlbumCoverSearcher::Role_ImageSize).toSize(); + const QSize size = idx.data(AlbumCoverSearcher::Role_ImageSize).toSize(); const QString text = Utilities::PrettySize(size); QFont font(option.font); @@ -136,10 +136,9 @@ AlbumCoverSearcher::AlbumCoverSearcher(const QIcon &no_cover_icon, Application * options_.pad_thumbnail_image_ = true; options_.thumbnail_size_ = ui_->covers->iconSize(); - connect(app_->album_cover_loader(), SIGNAL(AlbumCoverLoaded(quint64, AlbumCoverLoaderResult)), SLOT(AlbumCoverLoaded(quint64, AlbumCoverLoaderResult))); - - connect(ui_->search, SIGNAL(clicked()), SLOT(Search())); - connect(ui_->covers, SIGNAL(doubleClicked(QModelIndex)), SLOT(CoverDoubleClicked(QModelIndex))); + QObject::connect(app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &AlbumCoverSearcher::AlbumCoverLoaded); + QObject::connect(ui_->search, &QPushButton::clicked, this, &AlbumCoverSearcher::Search); + QObject::connect(ui_->covers, &GroupedIconView::doubleClicked, this, &AlbumCoverSearcher::CoverDoubleClicked); new ForceScrollPerPixel(ui_->covers, this); @@ -154,7 +153,7 @@ AlbumCoverSearcher::~AlbumCoverSearcher() { void AlbumCoverSearcher::Init(AlbumCoverFetcher *fetcher) { fetcher_ = fetcher; - connect(fetcher_, SIGNAL(SearchFinished(quint64, CoverSearchResults, CoverSearchStatistics)), this, SLOT(SearchFinished(quint64, CoverSearchResults)), Qt::QueuedConnection); + QObject::connect(fetcher_, &AlbumCoverFetcher::SearchFinished, this, &AlbumCoverSearcher::SearchFinished, Qt::QueuedConnection); } @@ -283,7 +282,7 @@ void AlbumCoverSearcher::keyPressEvent(QKeyEvent *e) { } -void AlbumCoverSearcher::CoverDoubleClicked(const QModelIndex &index) { - if (index.isValid()) accept(); +void AlbumCoverSearcher::CoverDoubleClicked(const QModelIndex &idx) { + if (idx.isValid()) accept(); } diff --git a/src/covermanager/albumcoversearcher.h b/src/covermanager/albumcoversearcher.h index d4e47405..13d7a211 100644 --- a/src/covermanager/albumcoversearcher.h +++ b/src/covermanager/albumcoversearcher.h @@ -1,3 +1,4 @@ + /* * Strawberry Music Player * This file was part of Clementine. @@ -61,7 +62,7 @@ class SizeOverlayDelegate : public QStyledItemDelegate { explicit SizeOverlayDelegate(QObject *parent = nullptr); - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override; }; // This is a dialog that lets the user search for album covers @@ -92,7 +93,7 @@ class AlbumCoverSearcher : public QDialog { void SearchFinished(const quint64 id, const CoverSearchResults &results); void AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderResult &result); - void CoverDoubleClicked(const QModelIndex &index); + void CoverDoubleClicked(const QModelIndex &idx); private: Ui_AlbumCoverSearcher *ui_; diff --git a/src/covermanager/coverexportrunnable.h b/src/covermanager/coverexportrunnable.h index d2674f84..6f817309 100644 --- a/src/covermanager/coverexportrunnable.h +++ b/src/covermanager/coverexportrunnable.h @@ -56,4 +56,3 @@ class CoverExportRunnable : public QObject, public QRunnable { }; #endif // COVEREXPORTRUNNABLE_H - diff --git a/src/covermanager/coverfromurldialog.cpp b/src/covermanager/coverfromurldialog.cpp index 6b548f4c..883ea776 100644 --- a/src/covermanager/coverfromurldialog.cpp +++ b/src/covermanager/coverfromurldialog.cpp @@ -73,7 +73,7 @@ void CoverFromURLDialog::accept() { #endif QNetworkReply *reply = network_->get(req); - connect(reply, SIGNAL(finished()), SLOT(LoadCoverFromURLFinished())); + QObject::connect(reply, &QNetworkReply::finished, this, &CoverFromURLDialog::LoadCoverFromURLFinished); } diff --git a/src/covermanager/coverfromurldialog.h b/src/covermanager/coverfromurldialog.h index 79d3d61f..ab8772a2 100644 --- a/src/covermanager/coverfromurldialog.h +++ b/src/covermanager/coverfromurldialog.h @@ -56,4 +56,3 @@ class CoverFromURLDialog : public QDialog { }; #endif // COVERFROMURLDIALOG_H - diff --git a/src/covermanager/coverproviders.cpp b/src/covermanager/coverproviders.cpp index a23e07f7..8916a59e 100644 --- a/src/covermanager/coverproviders.cpp +++ b/src/covermanager/coverproviders.cpp @@ -97,7 +97,7 @@ void CoverProviders::AddProvider(CoverProvider *provider) { { QMutexLocker locker(&mutex_); cover_providers_.insert(provider, provider->name()); - connect(provider, SIGNAL(destroyed()), SLOT(ProviderDestroyed())); + QObject::connect(provider, &CoverProvider::destroyed, this, &CoverProviders::ProviderDestroyed); } provider->set_order(++NextOrderId); diff --git a/src/covermanager/coversearchstatisticsdialog.h b/src/covermanager/coversearchstatisticsdialog.h index 2b5bf002..0e12e323 100644 --- a/src/covermanager/coversearchstatisticsdialog.h +++ b/src/covermanager/coversearchstatisticsdialog.h @@ -52,4 +52,3 @@ class CoverSearchStatisticsDialog : public QDialog { }; #endif // COVERSEARCHSTATISTICSDIALOG_H - diff --git a/src/covermanager/currentalbumcoverloader.cpp b/src/covermanager/currentalbumcoverloader.cpp index e4590905..999521a7 100644 --- a/src/covermanager/currentalbumcoverloader.cpp +++ b/src/covermanager/currentalbumcoverloader.cpp @@ -50,8 +50,8 @@ CurrentAlbumCoverLoader::CurrentAlbumCoverLoader(Application *app, QObject *pare options_.default_output_image_ = QImage(":/pictures/cdcase.png"); options_.default_thumbnail_image_ = options_.default_output_image_.scaledToHeight(120, Qt::SmoothTransformation); - connect(app_->album_cover_loader(), SIGNAL(AlbumCoverLoaded(quint64, AlbumCoverLoaderResult)), SLOT(TempAlbumCoverLoaded(quint64, AlbumCoverLoaderResult))); - connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), SLOT(LoadAlbumCover(Song))); + QObject::connect(app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &CurrentAlbumCoverLoader::TempAlbumCoverLoaded); + QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &CurrentAlbumCoverLoader::LoadAlbumCover); } diff --git a/src/covermanager/deezercoverprovider.cpp b/src/covermanager/deezercoverprovider.cpp index 0a9e8cd4..17e90192 100644 --- a/src/covermanager/deezercoverprovider.cpp +++ b/src/covermanager/deezercoverprovider.cpp @@ -59,7 +59,7 @@ DeezerCoverProvider::~DeezerCoverProvider() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } @@ -107,7 +107,7 @@ bool DeezerCoverProvider::StartSearch(const QString &artist, const QString &albu #endif QNetworkReply *reply = network_->get(req); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { HandleSearchReply(reply, id); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, id]() { HandleSearchReply(reply, id); }); return true; @@ -200,7 +200,7 @@ void DeezerCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QByteArray data = GetReplyData(reply); diff --git a/src/covermanager/discogscoverprovider.cpp b/src/covermanager/discogscoverprovider.cpp index d37f1849..0b6d397b 100644 --- a/src/covermanager/discogscoverprovider.cpp +++ b/src/covermanager/discogscoverprovider.cpp @@ -67,7 +67,7 @@ DiscogsCoverProvider::DiscogsCoverProvider(Application *app, QObject *parent) : timer_flush_requests_->setInterval(kRequestsDelay); timer_flush_requests_->setSingleShot(false); - connect(timer_flush_requests_, SIGNAL(timeout()), this, SLOT(FlushRequests())); + QObject::connect(timer_flush_requests_, &QTimer::timeout, this, &DiscogsCoverProvider::FlushRequests); } @@ -75,7 +75,7 @@ DiscogsCoverProvider::~DiscogsCoverProvider() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } @@ -144,7 +144,7 @@ void DiscogsCoverProvider::SendSearchRequest(std::shared_ptrid); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, search]() { HandleSearchReply(reply, search->id); }); } @@ -234,7 +234,7 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); if (!requests_search_.contains(id)) return; @@ -331,7 +331,7 @@ void DiscogsCoverProvider::StartReleaseRequest(std::shared_ptrdeleteLater(); if (!requests_search_.contains(search_id)) return; diff --git a/src/covermanager/lastfmcoverprovider.cpp b/src/covermanager/lastfmcoverprovider.cpp index 0cd4896e..5c8ca569 100644 --- a/src/covermanager/lastfmcoverprovider.cpp +++ b/src/covermanager/lastfmcoverprovider.cpp @@ -59,7 +59,7 @@ LastFmCoverProvider::~LastFmCoverProvider() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } @@ -122,7 +122,7 @@ bool LastFmCoverProvider::StartSearch(const QString &artist, const QString &albu req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); QNetworkReply *reply = network_->post(req, url_query.toString(QUrl::FullyEncoded).toUtf8()); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { QueryFinished(reply, id, type); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, id, type]() { QueryFinished(reply, id, type); }); return true; @@ -132,7 +132,7 @@ void LastFmCoverProvider::QueryFinished(QNetworkReply *reply, const int id, cons if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); CoverSearchResults results; diff --git a/src/covermanager/musicbrainzcoverprovider.cpp b/src/covermanager/musicbrainzcoverprovider.cpp index bbb2a74e..fb9e9d63 100644 --- a/src/covermanager/musicbrainzcoverprovider.cpp +++ b/src/covermanager/musicbrainzcoverprovider.cpp @@ -55,7 +55,7 @@ MusicbrainzCoverProvider::MusicbrainzCoverProvider(Application *app, QObject *pa timer_flush_requests_->setInterval(kRequestsDelay); timer_flush_requests_->setSingleShot(false); - connect(timer_flush_requests_, SIGNAL(timeout()), this, SLOT(FlushRequests())); + QObject::connect(timer_flush_requests_, &QTimer::timeout, this, &MusicbrainzCoverProvider::FlushRequests); } @@ -63,7 +63,7 @@ MusicbrainzCoverProvider::~MusicbrainzCoverProvider() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } @@ -106,7 +106,7 @@ void MusicbrainzCoverProvider::SendSearchRequest(const SearchRequest &request) { #endif QNetworkReply *reply = network_->get(req); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { HandleSearchReply(reply, request.id); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { HandleSearchReply(reply, request.id); }); } @@ -125,7 +125,7 @@ void MusicbrainzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); CoverSearchResults results; diff --git a/src/covermanager/musixmatchcoverprovider.cpp b/src/covermanager/musixmatchcoverprovider.cpp index 51899265..d3a65fd3 100644 --- a/src/covermanager/musixmatchcoverprovider.cpp +++ b/src/covermanager/musixmatchcoverprovider.cpp @@ -46,7 +46,7 @@ MusixmatchCoverProvider::~MusixmatchCoverProvider() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } @@ -88,7 +88,7 @@ bool MusixmatchCoverProvider::StartSearch(const QString &artist, const QString & #endif QNetworkReply *reply = network_->get(req); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { HandleSearchReply(reply, id, artist, album); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, id, artist, album]() { HandleSearchReply(reply, id, artist, album); }); //qLog(Debug) << "Musixmatch: Sending request for" << artist_stripped << album_stripped << url; @@ -102,7 +102,7 @@ void MusixmatchCoverProvider::HandleSearchReply(QNetworkReply *reply, const int if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); CoverSearchResults results; diff --git a/src/covermanager/qobuzcoverprovider.cpp b/src/covermanager/qobuzcoverprovider.cpp index 0465a297..8f087be7 100644 --- a/src/covermanager/qobuzcoverprovider.cpp +++ b/src/covermanager/qobuzcoverprovider.cpp @@ -60,7 +60,7 @@ QobuzCoverProvider::~QobuzCoverProvider() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } @@ -111,7 +111,7 @@ bool QobuzCoverProvider::StartSearch(const QString &artist, const QString &album req.setRawHeader("X-User-Auth-Token", user_auth_token_.toUtf8()); QNetworkReply *reply = network_->get(req); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { HandleSearchReply(reply, id); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, id]() { HandleSearchReply(reply, id); }); return true; @@ -167,7 +167,7 @@ void QobuzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) { if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); CoverSearchResults results; diff --git a/src/covermanager/spotifycoverprovider.cpp b/src/covermanager/spotifycoverprovider.cpp index c35e88c0..95474257 100644 --- a/src/covermanager/spotifycoverprovider.cpp +++ b/src/covermanager/spotifycoverprovider.cpp @@ -66,7 +66,7 @@ const int SpotifyCoverProvider::kLimit = 10; SpotifyCoverProvider::SpotifyCoverProvider(Application *app, QObject *parent) : JsonCoverProvider("Spotify", true, true, 2.5, true, true, app, parent), network_(new NetworkAccessManager(this)), server_(nullptr), expires_in_(0), login_time_(0) { refresh_login_timer_.setSingleShot(true); - connect(&refresh_login_timer_, SIGNAL(timeout()), SLOT(RequestAccessToken())); + QObject::connect(&refresh_login_timer_, &QTimer::timeout, this, &SpotifyCoverProvider::RequestNewAccessToken); QSettings s; s.beginGroup(kSettingsGroup); @@ -89,7 +89,7 @@ SpotifyCoverProvider::~SpotifyCoverProvider() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } @@ -118,7 +118,7 @@ void SpotifyCoverProvider::Authenticate() { server_ = nullptr; return; } - connect(server_, SIGNAL(Finished()), this, SLOT(RedirectArrived())); + QObject::connect(server_, &LocalRedirectServer::Finished, this, &SpotifyCoverProvider::RedirectArrived); } code_verifier_ = Utilities::CryptographicRandomString(44); @@ -246,8 +246,8 @@ void SpotifyCoverProvider::RequestAccessToken(const QString code, const QUrl red QNetworkReply *reply = network_->post(req, query); replies_ << reply; - connect(reply, SIGNAL(sslErrors(QList)), this, SLOT(HandleLoginSSLErrors(QList))); - connect(reply, &QNetworkReply::finished, [=] { AccessTokenRequestFinished(reply); }); + QObject::connect(reply, &QNetworkReply::sslErrors, this, &SpotifyCoverProvider::HandleLoginSSLErrors); + QObject::connect(reply, &QNetworkReply::finished, [this, reply]() { AccessTokenRequestFinished(reply); }); } @@ -263,7 +263,7 @@ void SpotifyCoverProvider::AccessTokenRequestFinished(QNetworkReply *reply) { if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); if (reply->error() != QNetworkReply::NoError || reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) { @@ -402,7 +402,7 @@ bool SpotifyCoverProvider::StartSearch(const QString &artist, const QString &alb QNetworkReply *reply = network_->get(req); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { HandleSearchReply(reply, id, extract); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, id, extract]() { HandleSearchReply(reply, id, extract); }); return true; @@ -461,7 +461,7 @@ void SpotifyCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id, if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QByteArray data = GetReplyData(reply); diff --git a/src/covermanager/spotifycoverprovider.h b/src/covermanager/spotifycoverprovider.h index e51d4e98..3e002f8d 100644 --- a/src/covermanager/spotifycoverprovider.h +++ b/src/covermanager/spotifycoverprovider.h @@ -58,14 +58,15 @@ class SpotifyCoverProvider : public JsonCoverProvider { private slots: void HandleLoginSSLErrors(QList ssl_errors); void RedirectArrived(); - void RequestAccessToken(const QString code = QString(), const QUrl redirect_url = QUrl()); void AccessTokenRequestFinished(QNetworkReply *reply); void HandleSearchReply(QNetworkReply *reply, const int id, const QString &extract); + void RequestNewAccessToken() { RequestAccessToken(); } private: QByteArray GetReplyData(QNetworkReply *reply); void AuthError(const QString &error = QString(), const QVariant &debug = QVariant()); void Error(const QString &error, const QVariant &debug = QVariant()) override; + void RequestAccessToken(const QString code = QString(), const QUrl redirect_url = QUrl()); private: typedef QPair Param; diff --git a/src/covermanager/tidalcoverprovider.cpp b/src/covermanager/tidalcoverprovider.cpp index 58da0e9e..551e7094 100644 --- a/src/covermanager/tidalcoverprovider.cpp +++ b/src/covermanager/tidalcoverprovider.cpp @@ -63,7 +63,7 @@ TidalCoverProvider::~TidalCoverProvider() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } @@ -117,7 +117,7 @@ bool TidalCoverProvider::StartSearch(const QString &artist, const QString &album QNetworkReply *reply = network_->get(req); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { HandleSearchReply(reply, id); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, id]() { HandleSearchReply(reply, id); }); return true; @@ -178,7 +178,7 @@ void TidalCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) { if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QByteArray data = GetReplyData(reply); diff --git a/src/device/cddadevice.cpp b/src/device/cddadevice.cpp index 3b042257..1dc0137c 100644 --- a/src/device/cddadevice.cpp +++ b/src/device/cddadevice.cpp @@ -35,10 +35,10 @@ class DeviceManager; CddaDevice::CddaDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, int database_id, bool first_time) : ConnectedDevice(url, lister, unique_id, manager, app, database_id, first_time), cdda_song_loader_(url) { - connect(&cdda_song_loader_, SIGNAL(SongsLoaded(SongList)), this, SLOT(SongsLoaded(SongList))); - connect(&cdda_song_loader_, SIGNAL(SongsDurationLoaded(SongList)), this, SLOT(SongsLoaded(SongList))); - connect(&cdda_song_loader_, SIGNAL(SongsMetadataLoaded(SongList)), this, SLOT(SongsLoaded(SongList))); - connect(this, SIGNAL(SongsDiscovered(SongList)), model_, SLOT(SongsDiscovered(SongList))); + QObject::connect(&cdda_song_loader_, &CddaSongLoader::SongsLoaded, this, &CddaDevice::SongsLoaded); + QObject::connect(&cdda_song_loader_, &CddaSongLoader::SongsDurationLoaded, this, &CddaDevice::SongsLoaded); + QObject::connect(&cdda_song_loader_, &CddaSongLoader::SongsMetadataLoaded, this, &CddaDevice::SongsLoaded); + QObject::connect(this, &CddaDevice::SongsDiscovered, model_, &CollectionModel::SongsDiscovered); } diff --git a/src/device/cddadevice.h b/src/device/cddadevice.h index 2cdc5924..f59aee50 100644 --- a/src/device/cddadevice.h +++ b/src/device/cddadevice.h @@ -55,7 +55,7 @@ class CddaDevice : public ConnectedDevice { static QStringList url_schemes() { return QStringList() << "cdda"; } signals: - void SongsDiscovered(const SongList &songs); + void SongsDiscovered(SongList songs); private slots: void SongsLoaded(const SongList &songs); @@ -64,5 +64,4 @@ class CddaDevice : public ConnectedDevice { CddaSongLoader cdda_song_loader_; }; -#endif - +#endif // CDDADEVICE_H diff --git a/src/device/cddalister.h b/src/device/cddalister.h index 9e302841..bafc3c1f 100644 --- a/src/device/cddalister.h +++ b/src/device/cddalister.h @@ -57,4 +57,5 @@ class CddaLister : public DeviceLister { private: QStringList devices_list_; }; + #endif // CDDALISTER_H diff --git a/src/device/cddasongloader.cpp b/src/device/cddasongloader.cpp index d430aacf..2cd84478 100644 --- a/src/device/cddasongloader.cpp +++ b/src/device/cddasongloader.cpp @@ -195,7 +195,7 @@ void CddaSongLoader::LoadSongs() { qLog(Info) << "MusicBrainz discid: " << musicbrainz_discid; MusicBrainzClient *musicbrainz_client = new MusicBrainzClient; - connect(musicbrainz_client, SIGNAL(Finished(QString, QString, MusicBrainzClient::ResultList)), SLOT(AudioCDTagsLoaded(QString, QString, MusicBrainzClient::ResultList))); + QObject::connect(musicbrainz_client, &MusicBrainzClient::DiscIdFinished, this, &CddaSongLoader::AudioCDTagsLoaded); musicbrainz_client->StartDiscIdRequest(musicbrainz_discid); g_free(string_mb); gst_message_unref(msg_tag); diff --git a/src/device/cddasongloader.h b/src/device/cddasongloader.h index 4210b92b..947d15dc 100644 --- a/src/device/cddasongloader.h +++ b/src/device/cddasongloader.h @@ -56,10 +56,10 @@ class CddaSongLoader : public QObject { QUrl GetUrlFromTrack(const int track_number) const; signals: - void SongsLoadError(const QString &error); - void SongsLoaded(const SongList &songs); - void SongsDurationLoaded(const SongList &songs, const QString &error = QString()); - void SongsMetadataLoaded(const SongList &songs); + void SongsLoadError(QString error); + void SongsLoaded(SongList songs); + void SongsDurationLoaded(SongList songs, QString error = QString()); + void SongsMetadataLoaded(SongList songs); private slots: #ifdef HAVE_CHROMAPRINT @@ -73,4 +73,4 @@ class CddaSongLoader : public QObject { QMutex mutex_load_; }; -#endif // CDDASONGLOADER_H +#endif // CDDASONGLOADER_H diff --git a/src/device/connecteddevice.cpp b/src/device/connecteddevice.cpp index d2156fa9..eed91088 100644 --- a/src/device/connecteddevice.cpp +++ b/src/device/connecteddevice.cpp @@ -59,7 +59,7 @@ ConnectedDevice::ConnectedDevice(const QUrl &url, DeviceLister *lister, const QS qLog(Debug) << backend_ << "for device" << unique_id_ << "moved to thread" << app_->database()->thread(); if (url_.scheme() != "cdda") { - connect(backend_, SIGNAL(TotalSongCountUpdated(int)), SLOT(BackendTotalSongCountUpdated(int))); + QObject::connect(backend_, &CollectionBackend::TotalSongCountUpdated, this, &ConnectedDevice::BackendTotalSongCountUpdated); } backend_->Init(app_->database(), @@ -105,18 +105,18 @@ void ConnectedDevice::InitBackendDirectory(const QString &mount_point, const boo } -void ConnectedDevice::ConnectAsync() { emit ConnectFinished(unique_id_, true); } +void ConnectedDevice::ConnectAsync() { emit DeviceConnectFinished(unique_id_, true); } void ConnectedDevice::Close() { - connect(backend_, SIGNAL(ExitFinished()), this, SLOT(CloseFinished())); + QObject::connect(backend_, &CollectionBackend::ExitFinished, this, &ConnectedDevice::BackendCloseFinished); backend_->ExitAsync(); } -void ConnectedDevice::CloseFinished() { +void ConnectedDevice::BackendCloseFinished() { - emit CloseFinished(unique_id_); + emit DeviceCloseFinished(unique_id_); } diff --git a/src/device/connecteddevice.h b/src/device/connecteddevice.h index 1e187718..44d34ac7 100644 --- a/src/device/connecteddevice.h +++ b/src/device/connecteddevice.h @@ -70,13 +70,13 @@ class ConnectedDevice : public QObject, public virtual MusicStorage, public std: virtual void Close(); public slots: - void CloseFinished(); + void BackendCloseFinished(); signals: void TaskStarted(int id); void SongCountUpdated(int count); - void ConnectFinished(const QString& id, bool success); - void CloseFinished(const QString& id); + void DeviceConnectFinished(QString id, bool success); + void DeviceCloseFinished(QString id); protected: void InitBackendDirectory(const QString &mount_point, const bool first_time, const bool rewrite_path = true); @@ -101,4 +101,3 @@ class ConnectedDevice : public QObject, public virtual MusicStorage, public std: }; #endif // CONNECTEDDEVICE_H - diff --git a/src/device/devicelister.cpp b/src/device/devicelister.cpp index 225b93f0..b0023881 100644 --- a/src/device/devicelister.cpp +++ b/src/device/devicelister.cpp @@ -59,7 +59,7 @@ DeviceLister::~DeviceLister() { void DeviceLister::Start() { thread_ = new QThread; - connect(thread_, SIGNAL(started()), SLOT(ThreadStarted())); + QObject::connect(thread_, &QThread::started, this, &DeviceLister::ThreadStarted); moveToThread(thread_); thread_->start(); diff --git a/src/device/devicelister.h b/src/device/devicelister.h index dd99139a..1e0e0988 100644 --- a/src/device/devicelister.h +++ b/src/device/devicelister.h @@ -79,10 +79,10 @@ class DeviceLister : public QObject { virtual void Exit(); signals: - void DeviceAdded(const QString &id); - void DeviceRemoved(const QString &id); - void DeviceChanged(const QString &id); - void DeviceMounted(const QString &id, int request_id, bool success); + void DeviceAdded(QString id); + void DeviceRemoved(QString id); + void DeviceChanged(QString id); + void DeviceMounted(QString id, int request_id, bool success); void ExitFinished(); protected: @@ -103,4 +103,3 @@ class DeviceLister : public QObject { }; #endif // DEVICELISTER_H - diff --git a/src/device/devicemanager.cpp b/src/device/devicemanager.cpp index 9faf6912..22ef9a69 100644 --- a/src/device/devicemanager.cpp +++ b/src/device/devicemanager.cpp @@ -92,14 +92,14 @@ DeviceManager::DeviceManager(Application *app, QObject *parent) not_connected_overlay_(IconLoader::Load("edit-delete")) { thread_pool_.setMaxThreadCount(1); - connect(app_->task_manager(), SIGNAL(TasksChanged()), SLOT(TasksChanged())); + QObject::connect(app_->task_manager(), &TaskManager::TasksChanged, this, &DeviceManager::TasksChanged); // Create the backend in the database thread backend_ = new DeviceDatabaseBackend; backend_->moveToThread(app_->database()->thread()); backend_->Init(app_->database()); - connect(this, SIGNAL(DeviceCreatedFromDB(DeviceInfo*)), SLOT(AddDeviceFromDB(DeviceInfo*))); + QObject::connect(this, &DeviceManager::DeviceCreatedFromDB, this, &DeviceManager::AddDeviceFromDB); // This reads from the database and contents on the database mutex, which can be very slow on startup. #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -168,7 +168,7 @@ void DeviceManager::CloseDevices() { if (!info->device_) continue; if (wait_for_exit_.contains(info->device_.get())) continue; wait_for_exit_ << info->device_.get(); - connect(info->device_.get(), SIGNAL(destroyed()), SLOT(DeviceDestroyed())); + QObject::connect(info->device_.get(), &ConnectedDevice::destroyed, this, &DeviceManager::DeviceDestroyed); info->device_->Close(); } if (wait_for_exit_.isEmpty()) CloseListers(); @@ -180,7 +180,7 @@ void DeviceManager::CloseListers() { for (DeviceLister *lister : listers_) { if (wait_for_exit_.contains(lister)) continue; wait_for_exit_ << lister; - connect(lister, SIGNAL(ExitFinished()), this, SLOT(ListerClosed())); + QObject::connect(lister, &DeviceLister::ExitFinished, this, &DeviceManager::ListerClosed); lister->ExitAsync(); } if (wait_for_exit_.isEmpty()) CloseBackend(); @@ -191,7 +191,7 @@ void DeviceManager::CloseBackend() { if (!backend_ || wait_for_exit_.contains(backend_)) return; wait_for_exit_ << backend_; - connect(backend_, SIGNAL(ExitFinished()), this, SLOT(BackendClosed())); + QObject::connect(backend_, &DeviceDatabaseBackend::ExitFinished, this, &DeviceManager::BackendClosed); backend_->ExitAsync(); } @@ -199,7 +199,7 @@ void DeviceManager::CloseBackend() { void DeviceManager::BackendClosed() { QObject *obj = qobject_cast(sender()); - disconnect(obj, nullptr, this, nullptr); + QObject::disconnect(obj, nullptr, this, nullptr); qLog(Debug) << obj << "successfully closed."; wait_for_exit_.removeAll(obj); if (wait_for_exit_.isEmpty()) emit ExitFinished(); @@ -211,7 +211,7 @@ void DeviceManager::ListerClosed() { DeviceLister *lister = qobject_cast(sender()); if (!lister) return; - disconnect(lister, nullptr, this, nullptr); + QObject::disconnect(lister, nullptr, this, nullptr); qLog(Debug) << lister << "successfully closed."; wait_for_exit_.removeAll(lister); @@ -389,9 +389,9 @@ QVariant DeviceManager::data(const QModelIndex &idx, int role) const { void DeviceManager::AddLister(DeviceLister *lister) { listers_ << lister; - connect(lister, SIGNAL(DeviceAdded(QString)), SLOT(PhysicalDeviceAdded(QString))); - connect(lister, SIGNAL(DeviceRemoved(QString)), SLOT(PhysicalDeviceRemoved(QString))); - connect(lister, SIGNAL(DeviceChanged(QString)), SLOT(PhysicalDeviceChanged(QString))); + QObject::connect(lister, &DeviceLister::DeviceAdded, this, &DeviceManager::PhysicalDeviceAdded); + QObject::connect(lister, &DeviceLister::DeviceRemoved, this, &DeviceManager::PhysicalDeviceRemoved); + QObject::connect(lister, &DeviceLister::DeviceChanged, this, &DeviceManager::PhysicalDeviceChanged); lister->Start(); @@ -657,10 +657,10 @@ std::shared_ptr DeviceManager::Connect(DeviceInfo *info) { emit dataChanged(idx, idx); - connect(info->device_.get(), SIGNAL(TaskStarted(int)), SLOT(DeviceTaskStarted(int))); - connect(info->device_.get(), SIGNAL(SongCountUpdated(int)), SLOT(DeviceSongCountUpdated(int))); - connect(info->device_.get(), SIGNAL(ConnectFinished(QString, bool)), SLOT(DeviceConnectFinished(QString, bool))); - connect(info->device_.get(), SIGNAL(CloseFinished(QString)), SLOT(DeviceCloseFinished(QString))); + QObject::connect(info->device_.get(), &ConnectedDevice::TaskStarted, this, &DeviceManager::DeviceTaskStarted); + QObject::connect(info->device_.get(), &ConnectedDevice::SongCountUpdated, this, &DeviceManager::DeviceSongCountUpdated); + QObject::connect(info->device_.get(), &ConnectedDevice::DeviceConnectFinished, this, &DeviceManager::DeviceConnectFinished); + QObject::connect(info->device_.get(), &ConnectedDevice::DeviceCloseFinished, this, &DeviceManager::DeviceCloseFinished); ret->ConnectAsync(); return ret; diff --git a/src/device/deviceproperties.cpp b/src/device/deviceproperties.cpp index bab37523..ea7b50eb 100644 --- a/src/device/deviceproperties.cpp +++ b/src/device/deviceproperties.cpp @@ -65,15 +65,14 @@ DeviceProperties::DeviceProperties(QWidget *parent) ui_(new Ui_DeviceProperties), manager_(nullptr), updating_formats_(false) { + ui_->setupUi(this); - connect(ui_->open_device, SIGNAL(clicked()), SLOT(OpenDevice())); + QObject::connect(ui_->open_device, &QPushButton::clicked, this, &DeviceProperties::OpenDevice); // Maximum height of the icon widget - ui_->icon->setMaximumHeight( - ui_->icon->iconSize().height() + - ui_->icon->horizontalScrollBar()->sizeHint().height() + - ui_->icon->spacing() * 2 + 5); + ui_->icon->setMaximumHeight(ui_->icon->iconSize().height() + ui_->icon->horizontalScrollBar()->sizeHint().height() + ui_->icon->spacing() * 2 + 5); + } DeviceProperties::~DeviceProperties() { delete ui_; } @@ -81,9 +80,9 @@ DeviceProperties::~DeviceProperties() { delete ui_; } void DeviceProperties::SetDeviceManager(DeviceManager *manager) { manager_ = manager; - connect(manager_, SIGNAL(dataChanged(QModelIndex,QModelIndex)), SLOT(ModelChanged())); - connect(manager_, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(ModelChanged())); - connect(manager_, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(ModelChanged())); + QObject::connect(manager_, &DeviceManager::dataChanged, this, &DeviceProperties::ModelChanged); + QObject::connect(manager_, &DeviceManager::rowsInserted, this, &DeviceProperties::ModelChanged); + QObject::connect(manager_, &DeviceManager::rowsRemoved, this, &DeviceProperties::ModelChanged); } @@ -136,7 +135,7 @@ void DeviceProperties::ShowDevice(QModelIndex idx) { } -void DeviceProperties::AddHardwareInfo(int row, const QString &key, const QString &value) { +void DeviceProperties::AddHardwareInfo(const int row, const QString &key, const QString &value) { ui_->hardware_info->setItem(row, 0, new QTableWidgetItem(key)); ui_->hardware_info->setItem(row, 1, new QTableWidgetItem(value)); } @@ -240,11 +239,14 @@ void DeviceProperties::UpdateFormats() { } if (!updating_formats_) { - // Get the device's supported formats list. This takes a long time and it - // blocks, so do it in the background. + // Get the device's supported formats list. This takes a long time and it blocks, so do it in the background. supported_formats_.clear(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QFuture future = QtConcurrent::run(&ConnectedDevice::GetSupportedFiletypes, device, &supported_formats_); +#else QFuture future = QtConcurrent::run(std::bind(&ConnectedDevice::GetSupportedFiletypes, device, &supported_formats_)); +#endif NewClosure(future, this, SLOT(UpdateFormatsFinished(QFuture)), future); ui_->formats_stack->setCurrentWidget(ui_->formats_page_loading); diff --git a/src/device/deviceproperties.h b/src/device/deviceproperties.h index 3ee488eb..3361b020 100644 --- a/src/device/deviceproperties.h +++ b/src/device/deviceproperties.h @@ -53,7 +53,7 @@ class DeviceProperties : public QDialog { private: void UpdateHardwareInfo(); - void AddHardwareInfo(int row, const QString &key, const QString &value); + void AddHardwareInfo(const int row, const QString &key, const QString &value); void UpdateFormats(); private slots: diff --git a/src/device/devicestatefiltermodel.cpp b/src/device/devicestatefiltermodel.cpp index 0b502546..9275413b 100644 --- a/src/device/devicestatefiltermodel.cpp +++ b/src/device/devicestatefiltermodel.cpp @@ -33,9 +33,9 @@ DeviceStateFilterModel::DeviceStateFilterModel(QObject *parent, DeviceManager::S : QSortFilterProxyModel(parent), state_(state) { - connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(ProxyRowCountChanged(QModelIndex, int, int))); - connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(ProxyRowCountChanged(QModelIndex, int, int))); - connect(this, SIGNAL(modelReset()), this, SLOT(ProxyRowCountChanged())); + QObject::connect(this, &DeviceStateFilterModel::rowsInserted, this, &DeviceStateFilterModel::ProxyRowCountChanged); + QObject::connect(this, &DeviceStateFilterModel::rowsRemoved, this, &DeviceStateFilterModel::ProxyRowCountChanged); + QObject::connect(this, &DeviceStateFilterModel::modelReset, this, &DeviceStateFilterModel::ProxyReset); } @@ -43,15 +43,14 @@ bool DeviceStateFilterModel::filterAcceptsRow(int row, const QModelIndex&) const return sourceModel()->index(row, 0).data(DeviceManager::Role_State).toInt() != state_ && sourceModel()->index(row, 0).data(DeviceManager::Role_CopyMusic).toBool(); } -void DeviceStateFilterModel::ProxyRowCountChanged() { +void DeviceStateFilterModel::ProxyRowCountChanged(QModelIndex, int, int) { + emit IsEmptyChanged(rowCount() == 0); + } -void DeviceStateFilterModel::ProxyRowCountChanged(QModelIndex index, int first, int last) { +void DeviceStateFilterModel::ProxyReset() { - Q_UNUSED(index); - Q_UNUSED(first); - Q_UNUSED(last); emit IsEmptyChanged(rowCount() == 0); } diff --git a/src/device/devicestatefiltermodel.h b/src/device/devicestatefiltermodel.h index 89d1de41..14164121 100644 --- a/src/device/devicestatefiltermodel.h +++ b/src/device/devicestatefiltermodel.h @@ -47,12 +47,11 @@ class DeviceStateFilterModel : public QSortFilterProxyModel { bool filterAcceptsRow(int row, const QModelIndex &parent) const override; private slots: - void ProxyRowCountChanged(); - void ProxyRowCountChanged(QModelIndex index, int first, int last); + void ProxyReset(); + void ProxyRowCountChanged(QModelIndex idx, int first, int last); private: DeviceManager::State state_; }; #endif // DEVICESTATEFILTERMODEL_H - diff --git a/src/device/deviceview.cpp b/src/device/deviceview.cpp index 5d787d99..dc0053ed 100644 --- a/src/device/deviceview.cpp +++ b/src/device/deviceview.cpp @@ -72,11 +72,11 @@ const int DeviceItemDelegate::kIconPadding = 6; DeviceItemDelegate::DeviceItemDelegate(QObject *parent) : CollectionItemDelegate(parent) {} -void DeviceItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { +void DeviceItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const { // Is it a device or a collection item? - if (index.data(DeviceManager::Role::Role_State).isNull()) { - CollectionItemDelegate::paint(painter, option, index); + if (idx.data(DeviceManager::Role::Role_State).isNull()) { + CollectionItemDelegate::paint(painter, option, idx); return; } @@ -111,14 +111,14 @@ void DeviceItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op } // Draw the icon - painter->drawPixmap(option.rect.topLeft(), index.data(Qt::DecorationRole).value()); + painter->drawPixmap(option.rect.topLeft(), idx.data(Qt::DecorationRole).value()); // Draw the first line (device name) - painter->drawText(line1, Qt::AlignLeft | Qt::AlignTop, index.data().toString()); + painter->drawText(line1, Qt::AlignLeft | Qt::AlignTop, idx.data().toString()); // Draw the second line (status) - DeviceManager::State state = static_cast(index.data(DeviceManager::Role_State).toInt()); - QVariant progress = index.data(DeviceManager::Role_UpdatingPercentage); + DeviceManager::State state = static_cast(idx.data(DeviceManager::Role_State).toInt()); + QVariant progress = idx.data(DeviceManager::Role_UpdatingPercentage); QString status_text; if (progress.isValid()) { @@ -139,13 +139,13 @@ void DeviceItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op break; case DeviceManager::State_Connected: { - QVariant song_count = index.data(DeviceManager::Role_SongCount); + QVariant song_count = idx.data(DeviceManager::Role_SongCount); if (song_count.isValid()) { int count = song_count.toInt(); status_text = tr("%1 song%2").arg(count).arg(count == 1 ? "" : "s"); } else { - status_text = index.data(DeviceManager::Role_MountPath).toString(); + status_text = idx.data(DeviceManager::Role_MountPath).toString(); } break; } @@ -196,8 +196,8 @@ void DeviceView::SetApplication(Application *app) { Q_ASSERT(app_ == nullptr); app_ = app; - connect(app_->device_manager(), SIGNAL(DeviceConnected(QModelIndex)), SLOT(DeviceConnected(QModelIndex))); - connect(app_->device_manager(), SIGNAL(DeviceDisconnected(QModelIndex)), SLOT(DeviceDisconnected(QModelIndex))); + QObject::connect(app_->device_manager(), &DeviceManager::DeviceConnected, this, &DeviceView::DeviceConnected); + QObject::connect(app_->device_manager(), &DeviceManager::DeviceDisconnected, this, &DeviceView::DeviceDisconnected); sort_model_ = new QSortFilterProxyModel(this); sort_model_->setSourceModel(app_->device_manager()); @@ -209,7 +209,7 @@ void DeviceView::SetApplication(Application *app) { merged_model_->setSourceModel(sort_model_); setModel(merged_model_); - connect(merged_model_, SIGNAL(SubModelReset(QModelIndex, QAbstractItemModel*)), SLOT(RecursivelyExpand(QModelIndex))); + QObject::connect(merged_model_, &MergedProxyModel::SubModelReset, this, &AutoExpandingTreeView::RecursivelyExpandSlot); properties_dialog_->SetDeviceManager(app_->device_manager()); @@ -225,19 +225,19 @@ void DeviceView::contextMenuEvent(QContextMenuEvent *e) { collection_menu_ = new QMenu(this); // Device menu - eject_action_ = device_menu_->addAction(IconLoader::Load("media-eject"), tr("Safely remove device"), this, SLOT(Unmount())); - forget_action_ = device_menu_->addAction(IconLoader::Load("list-remove"), tr("Forget device"), this, SLOT(Forget())); + eject_action_ = device_menu_->addAction(IconLoader::Load("media-eject"), tr("Safely remove device"), this, &DeviceView::Unmount); + forget_action_ = device_menu_->addAction(IconLoader::Load("list-remove"), tr("Forget device"), this, &DeviceView::Forget); device_menu_->addSeparator(); - properties_action_ = device_menu_->addAction(IconLoader::Load("configure"), tr("Device properties..."), this, SLOT(Properties())); + properties_action_ = device_menu_->addAction(IconLoader::Load("configure"), tr("Device properties..."), this, &DeviceView::Properties); // Collection menu - add_to_playlist_action_ = collection_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, SLOT(AddToPlaylist())); - load_action_ = collection_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, SLOT(Load())); - open_in_new_playlist_ = collection_menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, SLOT(OpenInNewPlaylist())); + add_to_playlist_action_ = collection_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, &DeviceView::AddToPlaylist); + load_action_ = collection_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, &DeviceView::Load); + open_in_new_playlist_ = collection_menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, &DeviceView::OpenInNewPlaylist); collection_menu_->addSeparator(); - organize_action_ = collection_menu_->addAction(IconLoader::Load("edit-copy"), tr("Copy to collection..."), this, SLOT(Organize())); - delete_action_ = collection_menu_->addAction(IconLoader::Load("edit-delete"), tr("Delete from device..."), this, SLOT(Delete())); + organize_action_ = collection_menu_->addAction(IconLoader::Load("edit-copy"), tr("Copy to collection..."), this, &DeviceView::Organize); + delete_action_ = collection_menu_->addAction(IconLoader::Load("edit-delete"), tr("Delete from device..."), this, &DeviceView::Delete); } menu_index_ = currentIndex(); @@ -280,9 +280,9 @@ QModelIndex DeviceView::MapToDevice(const QModelIndex &merged_model_index) const QModelIndex DeviceView::FindParentDevice(const QModelIndex &merged_model_index) const { - QModelIndex index = merged_model_->FindSourceParent(merged_model_index); - if (index.model() != sort_model_) return QModelIndex(); - return sort_model_->mapToSource(index); + QModelIndex idx = merged_model_->FindSourceParent(merged_model_index); + if (idx.model() != sort_model_) return QModelIndex(); + return sort_model_->mapToSource(idx); } @@ -350,11 +350,11 @@ void DeviceView::Properties() { properties_dialog_->ShowDevice(MapToDevice(menu_index_)); } -void DeviceView::mouseDoubleClickEvent(QMouseEvent *event) { +void DeviceView::mouseDoubleClickEvent(QMouseEvent *e) { - AutoExpandingTreeView::mouseDoubleClickEvent(event); + AutoExpandingTreeView::mouseDoubleClickEvent(e); - QModelIndex merged_index = indexAt(event->pos()); + QModelIndex merged_index = indexAt(e->pos()); QModelIndex device_index = MapToDevice(merged_index); if (device_index.isValid()) { if (!app_->device_manager()->GetConnectedDevice(device_index)) { @@ -422,7 +422,7 @@ void DeviceView::Delete() { std::shared_ptr storage = device_index.data(MusicStorage::Role_Storage).value>(); DeleteFiles *delete_files = new DeleteFiles(app_->task_manager(), storage, false); - connect(delete_files, SIGNAL(Finished(SongList)), SLOT(DeleteFinished(SongList))); + QObject::connect(delete_files, &DeleteFiles::Finished, this, &DeviceView::DeleteFinished); delete_files->Start(GetSelectedSongs()); } diff --git a/src/device/deviceview.h b/src/device/deviceview.h index 454969f7..c7c1570d 100644 --- a/src/device/deviceview.h +++ b/src/device/deviceview.h @@ -57,7 +57,7 @@ class DeviceItemDelegate : public CollectionItemDelegate { static const int kIconPadding; - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override; }; @@ -72,7 +72,7 @@ class DeviceView : public AutoExpandingTreeView { protected: void contextMenuEvent(QContextMenuEvent*) override; - void mouseDoubleClickEvent(QMouseEvent *event) override; + void mouseDoubleClickEvent(QMouseEvent *e) override; private slots: // Device menu actions diff --git a/src/device/filesystemdevice.cpp b/src/device/filesystemdevice.cpp index c49e4a95..284e04c2 100644 --- a/src/device/filesystemdevice.cpp +++ b/src/device/filesystemdevice.cpp @@ -54,15 +54,15 @@ FilesystemDevice::FilesystemDevice(const QUrl &url, DeviceLister *lister, const watcher_->set_backend(backend_); watcher_->set_task_manager(app_->task_manager()); - connect(backend_, SIGNAL(DirectoryDiscovered(Directory, SubdirectoryList)), watcher_, SLOT(AddDirectory(Directory, SubdirectoryList))); - connect(backend_, SIGNAL(DirectoryDeleted(Directory)), watcher_, SLOT(RemoveDirectory(Directory))); - connect(watcher_, SIGNAL(NewOrUpdatedSongs(SongList)), backend_, SLOT(AddOrUpdateSongs(SongList))); - connect(watcher_, SIGNAL(SongsMTimeUpdated(SongList)), backend_, SLOT(UpdateMTimesOnly(SongList))); - connect(watcher_, SIGNAL(SongsDeleted(SongList)), backend_, SLOT(DeleteSongs(SongList))); - connect(watcher_, SIGNAL(SubdirsDiscovered(SubdirectoryList)), backend_, SLOT(AddOrUpdateSubdirs(SubdirectoryList))); - connect(watcher_, SIGNAL(SubdirsMTimeUpdated(SubdirectoryList)), backend_, SLOT(AddOrUpdateSubdirs(SubdirectoryList))); - connect(watcher_, SIGNAL(CompilationsNeedUpdating()), backend_, SLOT(UpdateCompilations())); - connect(watcher_, SIGNAL(ScanStarted(int)), SIGNAL(TaskStarted(int))); + QObject::connect(backend_, &CollectionBackend::DirectoryDiscovered, watcher_, &CollectionWatcher::AddDirectory); + QObject::connect(backend_, &CollectionBackend::DirectoryDeleted, watcher_, &CollectionWatcher::RemoveDirectory); + QObject::connect(watcher_, &CollectionWatcher::NewOrUpdatedSongs, backend_, &CollectionBackend::AddOrUpdateSongs); + QObject::connect(watcher_, &CollectionWatcher::SongsMTimeUpdated, backend_, &CollectionBackend::UpdateMTimesOnly); + QObject::connect(watcher_, &CollectionWatcher::SongsDeleted, backend_, &CollectionBackend::DeleteSongs); + QObject::connect(watcher_, &CollectionWatcher::SubdirsDiscovered, backend_, &CollectionBackend::AddOrUpdateSubdirs); + QObject::connect(watcher_, &CollectionWatcher::SubdirsMTimeUpdated, backend_, &CollectionBackend::AddOrUpdateSubdirs); + QObject::connect(watcher_, &CollectionWatcher::CompilationsNeedUpdating, backend_, &CollectionBackend::CompilationsNeedUpdating); + QObject::connect(watcher_, &CollectionWatcher::ScanStarted, this, &FilesystemDevice::TaskStarted); } @@ -93,11 +93,11 @@ void FilesystemDevice::Close() { wait_for_exit_ << backend_ << watcher_; - disconnect(backend_, nullptr, watcher_, nullptr); - disconnect(watcher_, nullptr, backend_, nullptr); + QObject::disconnect(backend_, nullptr, watcher_, nullptr); + QObject::disconnect(watcher_, nullptr, backend_, nullptr); - connect(backend_, SIGNAL(ExitFinished()), this, SLOT(ExitFinished())); - connect(watcher_, SIGNAL(ExitFinished()), this, SLOT(ExitFinished())); + QObject::connect(backend_, &CollectionBackend::ExitFinished, this, &FilesystemDevice::ExitFinished); + QObject::connect(watcher_, &CollectionWatcher::ExitFinished, this, &FilesystemDevice::ExitFinished); backend_->ExitAsync(); watcher_->ExitAsync(); @@ -107,11 +107,11 @@ void FilesystemDevice::ExitFinished() { QObject *obj = qobject_cast(sender()); if (!obj) return; - disconnect(obj, nullptr, this, nullptr); + QObject::disconnect(obj, nullptr, this, nullptr); qLog(Debug) << obj << "successfully exited."; wait_for_exit_.removeAll(obj); if (wait_for_exit_.isEmpty()) { - emit CloseFinished(unique_id()); + emit DeviceCloseFinished(unique_id()); } } diff --git a/src/device/gpoddevice.cpp b/src/device/gpoddevice.cpp index f64d51ad..bcd00ccf 100644 --- a/src/device/gpoddevice.cpp +++ b/src/device/gpoddevice.cpp @@ -63,10 +63,10 @@ bool GPodDevice::Init() { loader_thread_ = new QThread(); loader_->moveToThread(loader_thread_); - connect(loader_, SIGNAL(Error(QString)), SLOT(LoaderError(QString))); - connect(loader_, SIGNAL(TaskStarted(int)), SIGNAL(TaskStarted(int))); - connect(loader_, SIGNAL(LoadFinished(Itdb_iTunesDB*, bool)), SLOT(LoadFinished(Itdb_iTunesDB*, bool))); - connect(loader_thread_, SIGNAL(started()), loader_, SLOT(LoadDatabase())); + QObject::connect(loader_, &GPodLoader::Error, this, &GPodDevice::LoaderError); + QObject::connect(loader_, &GPodLoader::TaskStarted, this, &GPodDevice::TaskStarted); + QObject::connect(loader_, &GPodLoader::LoadFinished, this, &GPodDevice::LoadFinished); + QObject::connect(loader_thread_, &QThread::started, loader_, &GPodLoader::LoadDatabase); return true; @@ -123,7 +123,7 @@ void GPodDevice::LoadFinished(Itdb_iTunesDB *db, bool success) { ConnectedDevice::Close(); } else { - emit ConnectFinished(unique_id_, success); + emit DeviceConnectFinished(unique_id_, success); } } diff --git a/src/device/gpodloader.h b/src/device/gpodloader.h index c688f60d..f797c8e9 100644 --- a/src/device/gpodloader.h +++ b/src/device/gpodloader.h @@ -73,4 +73,3 @@ class GPodLoader : public QObject { }; #endif // GPODLOADER_H - diff --git a/src/device/macosdevicelister.h b/src/device/macosdevicelister.h index cc98f2f0..b5964d03 100644 --- a/src/device/macosdevicelister.h +++ b/src/device/macosdevicelister.h @@ -118,4 +118,4 @@ inline bool operator==(const MacOsDeviceLister::MTPDevice& a, const MacOsDeviceL return (a.vendor_id == b.vendor_id) && (a.product_id == b.product_id); } -#endif +#endif // MACDEVICELISTER_H diff --git a/src/device/mtpdevice.cpp b/src/device/mtpdevice.cpp index bc2546d9..cecee40c 100644 --- a/src/device/mtpdevice.cpp +++ b/src/device/mtpdevice.cpp @@ -83,10 +83,10 @@ bool MtpDevice::Init() { loader_thread_ = new QThread(); loader_->moveToThread(loader_thread_); - connect(loader_, SIGNAL(Error(QString)), SLOT(LoaderError(QString))); - connect(loader_, SIGNAL(TaskStarted(int)), SIGNAL(TaskStarted(int))); - connect(loader_, SIGNAL(LoadFinished(bool, MtpConnection*)), SLOT(LoadFinished(bool, MtpConnection*))); - connect(loader_thread_, SIGNAL(started()), loader_, SLOT(LoadDatabase())); + QObject::connect(loader_, &MtpLoader::Error, this, &MtpDevice::LoaderError); + QObject::connect(loader_, &MtpLoader::TaskStarted, this, &MtpDevice::TaskStarted); + QObject::connect(loader_, &MtpLoader::LoadFinished, this, &MtpDevice::LoadFinished); + QObject::connect(loader_thread_, &QThread::started, loader_, &MtpLoader::LoadDatabase); return true; @@ -124,7 +124,7 @@ void MtpDevice::LoadFinished(bool success, MtpConnection *connection) { ConnectedDevice::Close(); } else { - emit ConnectFinished(unique_id_, success); + emit DeviceConnectFinished(unique_id_, success); } } diff --git a/src/device/mtploader.h b/src/device/mtploader.h index 46c52b4e..89106cbf 100644 --- a/src/device/mtploader.h +++ b/src/device/mtploader.h @@ -49,7 +49,7 @@ class MtpLoader : public QObject { void LoadDatabase(); signals: - void Error(const QString &message); + void Error(QString message); void TaskStarted(int task_id); void LoadFinished(bool success, MtpConnection*); diff --git a/src/device/udisks2lister.cpp b/src/device/udisks2lister.cpp index 467d9f41..ced09b7d 100644 --- a/src/device/udisks2lister.cpp +++ b/src/device/udisks2lister.cpp @@ -202,8 +202,8 @@ bool Udisks2Lister::Init() { emit DeviceAdded(id); } - connect(udisks2_interface_.get(), SIGNAL(InterfacesAdded(QDBusObjectPath, InterfacesAndProperties)), SLOT(DBusInterfaceAdded(QDBusObjectPath, InterfacesAndProperties))); - connect(udisks2_interface_.get(), SIGNAL(InterfacesRemoved(QDBusObjectPath, QStringList)), SLOT(DBusInterfaceRemoved(QDBusObjectPath, QStringList))); + QObject::connect(udisks2_interface_.get(), &OrgFreedesktopDBusObjectManagerInterface::InterfacesAdded, this, &Udisks2Lister::DBusInterfaceAdded); + QObject::connect(udisks2_interface_.get(), &OrgFreedesktopDBusObjectManagerInterface::InterfacesRemoved, this, &Udisks2Lister::DBusInterfaceRemoved); return true; @@ -243,7 +243,7 @@ void Udisks2Lister::DBusInterfaceAdded(const QDBusObjectPath &path, const Interf mounting_jobs_[path].dbus_interface = job; mounting_jobs_[path].is_mount = is_mount_job; mounting_jobs_[path].mounted_partitions = mounted_partitions; - connect(job.get(), SIGNAL(Completed(bool, QString)), SLOT(JobCompleted(bool, QString))); + QObject::connect(job.get(), &OrgFreedesktopUDisks2JobInterface::Completed, this, &Udisks2Lister::JobCompleted); } } } diff --git a/src/dialogs/addstreamdialog.cpp b/src/dialogs/addstreamdialog.cpp index fbcf7ecd..79fb5e53 100644 --- a/src/dialogs/addstreamdialog.cpp +++ b/src/dialogs/addstreamdialog.cpp @@ -32,18 +32,20 @@ AddStreamDialog::AddStreamDialog(QWidget* parent) : QDialog(parent), ui_(new Ui_ ui_->setupUi(this); - connect(ui_->url, SIGNAL(textChanged(QString)), SLOT(TextChanged(QString))); + QObject::connect(ui_->url, &QLineEdit::textChanged, this, &AddStreamDialog::TextChanged); TextChanged(QString()); } AddStreamDialog::~AddStreamDialog() { delete ui_; } -void AddStreamDialog::showEvent(QShowEvent*) { +void AddStreamDialog::showEvent(QShowEvent *e) { ui_->url->setFocus(); ui_->url->selectAll(); + QDialog::showEvent(e); + } void AddStreamDialog::TextChanged(const QString &text) { diff --git a/src/dialogs/addstreamdialog.h b/src/dialogs/addstreamdialog.h index 3bf7a634..aaa07c2e 100644 --- a/src/dialogs/addstreamdialog.h +++ b/src/dialogs/addstreamdialog.h @@ -38,7 +38,7 @@ class AddStreamDialog : public QDialog { void set_url(const QUrl &url) { ui_->url->setText(url.toString());} protected: - void showEvent(QShowEvent*) override; + void showEvent(QShowEvent *e) override; private slots: void TextChanged(const QString &text); diff --git a/src/dialogs/console.cpp b/src/dialogs/console.cpp index 34e320bc..68e7409e 100644 --- a/src/dialogs/console.cpp +++ b/src/dialogs/console.cpp @@ -45,7 +45,7 @@ Console::Console(Application *app, QWidget *parent) : QDialog(parent), app_(app) setWindowFlags(windowFlags()|Qt::WindowMaximizeButtonHint); - connect(ui_.run, SIGNAL(clicked()), SLOT(RunQuery())); + QObject::connect(ui_.run, &QPushButton::clicked, this, &Console::RunQuery); QFont font("Monospace"); font.setStyleHint(QFont::TypeWriter); diff --git a/src/dialogs/deleteconfirmationdialog.cpp b/src/dialogs/deleteconfirmationdialog.cpp index 4e4eb5f8..8ed99f2b 100644 --- a/src/dialogs/deleteconfirmationdialog.cpp +++ b/src/dialogs/deleteconfirmationdialog.cpp @@ -69,7 +69,7 @@ DeleteConfirmationDialog::DeleteConfirmationDialog(const QStringList &files, QWi label_text_bottom->setText(tr("Are you sure you want to continue?")); button_box_->setStandardButtons(QDialogButtonBox::Yes|QDialogButtonBox::Cancel); - connect(button_box_, SIGNAL(clicked(QAbstractButton*)), this, SLOT(ButtonClicked(QAbstractButton*))); + QObject::connect(button_box_, &QDialogButtonBox::clicked, this, &DeleteConfirmationDialog::ButtonClicked); // Add layout QGridLayout *grid = new QGridLayout(this); diff --git a/src/dialogs/edittagdialog.cpp b/src/dialogs/edittagdialog.cpp index 57a82907..75896713 100644 --- a/src/dialogs/edittagdialog.cpp +++ b/src/dialogs/edittagdialog.cpp @@ -113,13 +113,13 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent) cover_options_.default_output_image_ = AlbumCoverLoader::ScaleAndPad(cover_options_, QImage(":/pictures/cdcase.png")).first; - connect(app_->album_cover_loader(), SIGNAL(AlbumCoverLoaded(quint64, AlbumCoverLoaderResult)), SLOT(AlbumCoverLoaded(quint64, AlbumCoverLoaderResult))); + QObject::connect(app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &EditTagDialog::AlbumCoverLoaded); #if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) - connect(tag_fetcher_, SIGNAL(ResultAvailable(Song, SongList)), results_dialog_, SLOT(FetchTagFinished(Song, SongList)), Qt::QueuedConnection); - connect(tag_fetcher_, SIGNAL(Progress(Song, QString)), results_dialog_, SLOT(FetchTagProgress(Song, QString))); - connect(results_dialog_, SIGNAL(SongChosen(Song, Song)), SLOT(FetchTagSongChosen(Song, Song))); - connect(results_dialog_, SIGNAL(finished(int)), tag_fetcher_, SLOT(Cancel())); + QObject::connect(tag_fetcher_, &TagFetcher::ResultAvailable, results_dialog_, &TrackSelectionDialog::FetchTagFinished, Qt::QueuedConnection); + QObject::connect(tag_fetcher_, &TagFetcher::Progress, results_dialog_, &TrackSelectionDialog::FetchTagProgress); + QObject::connect(results_dialog_, &TrackSelectionDialog::SongChosen, this, &EditTagDialog::FetchTagSongChosen); + QObject::connect(results_dialog_, &TrackSelectionDialog::finished, tag_fetcher_, &TagFetcher::Cancel); #endif album_cover_choice_controller_->Init(app_); @@ -143,23 +143,22 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent) // Store information about the field fields_ << FieldData(label, widget, widget->objectName()); - // Connect the Reset signal - if (dynamic_cast(widget)) { - connect(widget, SIGNAL(Reset()), SLOT(ResetField())); - } - // Connect the edited signal - if (qobject_cast(widget)) { - connect(widget, SIGNAL(textChanged(QString)), SLOT(FieldValueEdited())); + if (LineEdit *lineedit = qobject_cast(widget)) { + QObject::connect(lineedit, &LineEdit::textChanged, this, &EditTagDialog::FieldValueEdited); + QObject::connect(lineedit, &LineEdit::Reset, this, &EditTagDialog::ResetField); } - else if (qobject_cast(widget)) { - connect(widget, SIGNAL(textChanged()), SLOT(FieldValueEdited())); + else if (TextEdit *textedit = qobject_cast(widget)) { + QObject::connect(textedit, &TextEdit::textChanged, this, &EditTagDialog::FieldValueEdited); + QObject::connect(textedit, &TextEdit::Reset, this, &EditTagDialog::ResetField); } - else if (qobject_cast(widget)) { - connect(widget, SIGNAL(valueChanged(int)), SLOT(FieldValueEdited())); + else if (SpinBox *spinbox = qobject_cast(widget)) { + QObject::connect(spinbox, QOverload::of(&SpinBox::valueChanged), this, &EditTagDialog::FieldValueEdited); + QObject::connect(spinbox, &SpinBox::Reset, this, &EditTagDialog::ResetField); } - else if (qobject_cast(widget)) { - connect(widget, SIGNAL(stateChanged(int)), SLOT(FieldValueEdited())); + else if (CheckBox *checkbox = qobject_cast(widget)) { + QObject::connect(checkbox, &QCheckBox::stateChanged, this, &EditTagDialog::FieldValueEdited); + QObject::connect(checkbox, &CheckBox::Reset, this, &EditTagDialog::ResetField); } } } @@ -179,11 +178,11 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent) // Pretend the summary text is just a label ui_->summary->setMaximumHeight(ui_->art->height() - ui_->summary_art_button->height() - 4); - connect(ui_->song_list->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), SLOT(SelectionChanged())); - connect(ui_->button_box, SIGNAL(clicked(QAbstractButton*)), SLOT(ButtonClicked(QAbstractButton*))); - connect(ui_->playcount_reset, SIGNAL(clicked()), SLOT(ResetPlayCounts())); + QObject::connect(ui_->song_list->selectionModel(), &QItemSelectionModel::selectionChanged, this, &EditTagDialog::SelectionChanged); + QObject::connect(ui_->button_box, &QDialogButtonBox::clicked, this, &EditTagDialog::ButtonClicked); + QObject::connect(ui_->playcount_reset, &QPushButton::clicked, this, &EditTagDialog::ResetPlayCounts); #if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) - connect(ui_->fetch_tag, SIGNAL(clicked()), SLOT(FetchTag())); + QObject::connect(ui_->fetch_tag, &QPushButton::clicked, this, &EditTagDialog::FetchTag); #endif // Set up the album cover menu @@ -191,12 +190,12 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent) QList actions = album_cover_choice_controller_->GetAllActions(); - connect(album_cover_choice_controller_->cover_from_file_action(), SIGNAL(triggered()), this, SLOT(LoadCoverFromFile())); - connect(album_cover_choice_controller_->cover_to_file_action(), SIGNAL(triggered()), this, SLOT(SaveCoverToFile())); - connect(album_cover_choice_controller_->cover_from_url_action(), SIGNAL(triggered()), this, SLOT(LoadCoverFromURL())); - connect(album_cover_choice_controller_->search_for_cover_action(), SIGNAL(triggered()), this, SLOT(SearchForCover())); - connect(album_cover_choice_controller_->unset_cover_action(), SIGNAL(triggered()), this, SLOT(UnsetCover())); - connect(album_cover_choice_controller_->show_cover_action(), SIGNAL(triggered()), this, SLOT(ShowCover())); + QObject::connect(album_cover_choice_controller_->cover_from_file_action(), &QAction::triggered, this, &EditTagDialog::LoadCoverFromFile); + QObject::connect(album_cover_choice_controller_->cover_to_file_action(), &QAction::triggered, this, &EditTagDialog::SaveCoverToFile); + QObject::connect(album_cover_choice_controller_->cover_from_url_action(), &QAction::triggered, this, &EditTagDialog::LoadCoverFromURL); + QObject::connect(album_cover_choice_controller_->search_for_cover_action(), &QAction::triggered, this, &EditTagDialog::SearchForCover); + QObject::connect(album_cover_choice_controller_->unset_cover_action(), &QAction::triggered, this, &EditTagDialog::UnsetCover); + QObject::connect(album_cover_choice_controller_->show_cover_action(), &QAction::triggered, this, &EditTagDialog::ShowCover); cover_menu_->addActions(actions); @@ -211,8 +210,8 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent) ui_->button_box->addButton(previous_button_, QDialogButtonBox::ResetRole); ui_->button_box->addButton(next_button_, QDialogButtonBox::ResetRole); - connect(previous_button_, SIGNAL(clicked()), SLOT(PreviousSong())); - connect(next_button_, SIGNAL(clicked()), SLOT(NextSong())); + QObject::connect(previous_button_, &QPushButton::clicked, this, &EditTagDialog::PreviousSong); + QObject::connect(next_button_, &QPushButton::clicked, this, &EditTagDialog::NextSong); // Set some shortcuts for the buttons new QShortcut(QKeySequence::Back, previous_button_, SLOT(click())); @@ -775,7 +774,7 @@ void EditTagDialog::SaveData(const QList &tag_data) { const Data &ref = tag_data[i]; if (ref.current_.IsMetadataEqual(ref.original_)) continue; - pending_++; + ++pending_; TagReaderReply *reply = TagReaderClient::Instance()->SaveFile(ref.current_.url().toLocalFile(), ref.current_); NewClosure(reply, SIGNAL(Finished(bool)), this, SLOT(SongSaveComplete(TagReaderReply*, QString, Song)), reply, ref.current_.url().toLocalFile(), ref.current_); @@ -902,8 +901,8 @@ void EditTagDialog::FetchTag() { SongList songs; - for (const QModelIndex &index : sel) { - Song song = data_[index.row()].original_; + for (const QModelIndex &idx : sel) { + Song song = data_[idx.row()].original_; if (!song.is_valid()) { continue; } @@ -960,7 +959,7 @@ void EditTagDialog::FetchTagSongChosen(const Song &original_song, const Song &ne void EditTagDialog::SongSaveComplete(TagReaderReply *reply, const QString &filename, const Song &song) { - pending_--; + --pending_; if (!reply->message().save_file_response().success()) { QString message = tr("An error occurred writing metadata to '%1'").arg(filename); diff --git a/src/dialogs/edittagdialog.h b/src/dialogs/edittagdialog.h index 224988b5..02f48369 100644 --- a/src/dialogs/edittagdialog.h +++ b/src/dialogs/edittagdialog.h @@ -75,7 +75,7 @@ class EditTagDialog : public QDialog { void accept() override; signals: - void Error(const QString &message); + void Error(QString message); protected: bool eventFilter(QObject *o, QEvent *e) override; diff --git a/src/dialogs/errordialog.cpp b/src/dialogs/errordialog.cpp index 977ce1b1..da2b2ad5 100644 --- a/src/dialogs/errordialog.cpp +++ b/src/dialogs/errordialog.cpp @@ -58,6 +58,8 @@ ErrorDialog::~ErrorDialog() { void ErrorDialog::ShowMessage(const QString &message) { + if (message.isEmpty()) return; + current_messages_ << message; UpdateContent(); @@ -83,4 +85,3 @@ void ErrorDialog::UpdateContent() { ui_->messages->setHtml(html); } - diff --git a/src/dialogs/errordialog.h b/src/dialogs/errordialog.h index 31cf3619..81e0d88f 100644 --- a/src/dialogs/errordialog.h +++ b/src/dialogs/errordialog.h @@ -54,4 +54,3 @@ class ErrorDialog : public QDialog { }; #endif // ERRORDIALOG_H - diff --git a/src/dialogs/lastfmimportdialog.cpp b/src/dialogs/lastfmimportdialog.cpp index db7e4803..fdebfcc9 100644 --- a/src/dialogs/lastfmimportdialog.cpp +++ b/src/dialogs/lastfmimportdialog.cpp @@ -35,8 +35,7 @@ LastFMImportDialog::LastFMImportDialog(LastFMImport *lastfm_import, QWidget *par lastfm_import_(lastfm_import), finished_(false), playcount_total_(0), - lastplayed_total_(0) - { + lastplayed_total_(0) { ui_->setupUi(this); @@ -46,21 +45,23 @@ LastFMImportDialog::LastFMImportDialog(LastFMImport *lastfm_import, QWidget *par Reset(); - connect(ui_->button_close, SIGNAL(clicked()), SLOT(Close())); - connect(ui_->button_go, SIGNAL(clicked()), SLOT(Start())); - connect(ui_->button_cancel, SIGNAL(clicked()), SLOT(Cancel())); + QObject::connect(ui_->button_close, &QPushButton::clicked, this, &LastFMImportDialog::Close); + QObject::connect(ui_->button_go, &QPushButton::clicked, this, &LastFMImportDialog::Start); + QObject::connect(ui_->button_cancel, &QPushButton::clicked, this, &LastFMImportDialog::Cancel); - connect(ui_->checkbox_last_played, SIGNAL(stateChanged(int)), SLOT(UpdateGoButtonState())); - connect(ui_->checkbox_playcounts, SIGNAL(stateChanged(int)), SLOT(UpdateGoButtonState())); + QObject::connect(ui_->checkbox_last_played, &QCheckBox::stateChanged, this, &LastFMImportDialog::UpdateGoButtonState); + QObject::connect(ui_->checkbox_playcounts, &QCheckBox::stateChanged, this, &LastFMImportDialog::UpdateGoButtonState); } LastFMImportDialog::~LastFMImportDialog() { delete ui_; } -void LastFMImportDialog::closeEvent(QCloseEvent*) { +void LastFMImportDialog::closeEvent(QCloseEvent *e) { ResetFinished(); + QDialog::closeEvent(e); + } void LastFMImportDialog::Start() { diff --git a/src/dialogs/lastfmimportdialog.h b/src/dialogs/lastfmimportdialog.h index eba5db27..fee9418c 100644 --- a/src/dialogs/lastfmimportdialog.h +++ b/src/dialogs/lastfmimportdialog.h @@ -39,7 +39,7 @@ class LastFMImportDialog : public QDialog { ~LastFMImportDialog() override; protected: - void closeEvent(QCloseEvent*) override; + void closeEvent(QCloseEvent *e) override; private: void ResetFinished(); @@ -51,10 +51,11 @@ class LastFMImportDialog : public QDialog { void Close(); void UpdateGoButtonState(); - void UpdateTotal(const int lastplayed_total, const int playcount_total); - void UpdateProgress(const int lastplayed_received, const int playcount_received); + public slots: void Finished(); void FinishedWithError(const QString &error); + void UpdateTotal(const int lastplayed_total, const int playcount_total); + void UpdateProgress(const int lastplayed_received, const int playcount_received); private: Ui_LastFMImportDialog *ui_; diff --git a/src/dialogs/snapdialog.cpp b/src/dialogs/snapdialog.cpp index 8ee41d96..9814eb35 100644 --- a/src/dialogs/snapdialog.cpp +++ b/src/dialogs/snapdialog.cpp @@ -89,7 +89,7 @@ SnapDialog::SnapDialog(QWidget *parent) : QDialog(parent), ui_(new Ui_SnapDialog ui_->buttonBox->button(QDialogButtonBox::Ok)->setShortcut(QKeySequence::Close); - connect(ui_->checkbox_do_not_show_message_again, SIGNAL(toggled(bool)), SLOT(DoNotShowMessageAgain())); + QObject::connect(ui_->checkbox_do_not_show_message_again, &QCheckBox::toggled, this, &SnapDialog::DoNotShowMessageAgain); } diff --git a/src/dialogs/trackselectiondialog.cpp b/src/dialogs/trackselectiondialog.cpp index 4d0538aa..81ec517d 100644 --- a/src/dialogs/trackselectiondialog.cpp +++ b/src/dialogs/trackselectiondialog.cpp @@ -56,14 +56,13 @@ TrackSelectionDialog::TrackSelectionDialog(QWidget *parent) : QDialog(parent), ui_(new Ui_TrackSelectionDialog), - save_on_close_(false) -{ + save_on_close_(false) { // Setup dialog window ui_->setupUi(this); - connect(ui_->song_list, SIGNAL(currentRowChanged(int)), SLOT(UpdateStack())); - connect(ui_->results, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), SLOT(ResultSelected())); + QObject::connect(ui_->song_list, &QListWidget::currentRowChanged, this, &TrackSelectionDialog::UpdateStack); + QObject::connect(ui_->results, &QTreeWidget::currentItemChanged, this, &TrackSelectionDialog::ResultSelected); ui_->splitter->setSizes(QList() << 200 << width() - 200); SetLoading(QString()); @@ -74,8 +73,8 @@ TrackSelectionDialog::TrackSelectionDialog(QWidget *parent) ui_->button_box->addButton(previous_button_, QDialogButtonBox::ResetRole); ui_->button_box->addButton(next_button_, QDialogButtonBox::ResetRole); - connect(previous_button_, SIGNAL(clicked()), SLOT(PreviousSong())); - connect(next_button_, SIGNAL(clicked()), SLOT(NextSong())); + QObject::connect(previous_button_, &QPushButton::clicked, this, &TrackSelectionDialog::PreviousSong); + QObject::connect(next_button_, &QPushButton::clicked, this, &TrackSelectionDialog::NextSong); // Set some shortcuts for the buttons new QShortcut(QKeySequence::Back, previous_button_, SLOT(click())); @@ -294,7 +293,7 @@ void TrackSelectionDialog::accept() { QFuture future = QtConcurrent::run(&TrackSelectionDialog::SaveData, data_); QFutureWatcher *watcher = new QFutureWatcher(this); watcher->setFuture(future); - connect(watcher, SIGNAL(finished()), SLOT(AcceptFinished())); + QObject::connect(watcher, &QFutureWatcher::finished, this, &TrackSelectionDialog::AcceptFinished); return; } diff --git a/src/dialogs/trackselectiondialog.h b/src/dialogs/trackselectiondialog.h index 7e4db6d8..fb8d1d6e 100644 --- a/src/dialogs/trackselectiondialog.h +++ b/src/dialogs/trackselectiondialog.h @@ -53,8 +53,8 @@ class TrackSelectionDialog : public QDialog { void accept() override; signals: - void Error(const QString&); - void SongChosen(const Song &original_song, const Song &new_metadata); + void Error(QString); + void SongChosen(Song original_song, Song new_metadata); private slots: void UpdateStack(); diff --git a/src/engine/devicefinder.h b/src/engine/devicefinder.h index 4870c399..cd6982e2 100644 --- a/src/engine/devicefinder.h +++ b/src/engine/devicefinder.h @@ -64,4 +64,3 @@ class DeviceFinder { }; #endif // DEVICEFINDER_H - diff --git a/src/engine/directsounddevicefinder.h b/src/engine/directsounddevicefinder.h index d85e8d5b..3653559c 100644 --- a/src/engine/directsounddevicefinder.h +++ b/src/engine/directsounddevicefinder.h @@ -46,4 +46,3 @@ class DirectSoundDeviceFinder : public DeviceFinder { }; #endif // DIRECTSOUNDDEVICEFINDER_H - diff --git a/src/engine/enginebase.h b/src/engine/enginebase.h index 2aeb1b4b..eb9d834a 100644 --- a/src/engine/enginebase.h +++ b/src/engine/enginebase.h @@ -138,17 +138,17 @@ public: void FadeoutFinishedSignal(); - void StatusText(const QString &text); - void Error(const QString &text); + void StatusText(QString text); + void Error(QString text); // Emitted when there was a fatal error void FatalError(); // Emitted when Engine was unable to play a song with the given QUrl. - void InvalidSongRequested(const QUrl &url); + void InvalidSongRequested(QUrl url); // Emitted when Engine successfully started playing a song with the given QUrl. - void ValidSongRequested(const QUrl &url); + void ValidSongRequested(QUrl url); - void MetaData(const Engine::SimpleMetaBundle&); + void MetaData(Engine::SimpleMetaBundle); // Signals that the engine's state has changed (a stream was stopped for example). // Always use the state from event, because it's not guaranteed that immediate subsequent call to state() won't return a stale value. @@ -235,4 +235,4 @@ struct SimpleMetaBundle { Q_DECLARE_METATYPE(EngineBase::OutputDetails) -#endif +#endif // ENGINEBASE_H diff --git a/src/engine/enginetype.h b/src/engine/enginetype.h index b4a69767..bd466194 100644 --- a/src/engine/enginetype.h +++ b/src/engine/enginetype.h @@ -41,4 +41,4 @@ QString EngineDescription(Engine::EngineType enginetype); } Q_DECLARE_METATYPE(Engine::EngineType) -#endif +#endif // ENGINETYPE_H diff --git a/src/engine/gstengine.cpp b/src/engine/gstengine.cpp index 7541db02..198ff897 100644 --- a/src/engine/gstengine.cpp +++ b/src/engine/gstengine.cpp @@ -99,7 +99,7 @@ GstEngine::GstEngine(TaskManager *task_manager) type_ = Engine::GStreamer; seek_timer_->setSingleShot(true); seek_timer_->setInterval(kSeekDelayNanosec / kNsecPerMsec); - connect(seek_timer_, SIGNAL(timeout()), SLOT(SeekNow())); + QObject::connect(seek_timer_, &QTimer::timeout, this, &GstEngine::SeekNow); ReloadSettings(); @@ -262,7 +262,7 @@ void GstEngine::Stop(const bool stop_after) { // Check if we started a fade out. If it isn't finished yet and the user pressed stop, we cancel the fader and just stop the playback. if (is_fading_out_to_pause_) { - disconnect(current_pipeline_.get(), SIGNAL(FaderFinished()), nullptr, nullptr); + QObject::disconnect(current_pipeline_.get(), &GstEnginePipeline::FaderFinished, nullptr, nullptr); is_fading_out_to_pause_ = false; has_faded_out_ = true; @@ -284,7 +284,7 @@ void GstEngine::Pause() { // Check if we started a fade out. If it isn't finished yet and the user pressed play, we inverse the fader and resume the playback. if (is_fading_out_to_pause_) { - disconnect(current_pipeline_.get(), SIGNAL(FaderFinished()), nullptr, nullptr); + QObject::disconnect(current_pipeline_.get(), &GstEnginePipeline::FaderFinished, nullptr, nullptr); current_pipeline_->StartFader(fadeout_pause_duration_nanosec_, QTimeLine::Forward, QEasingCurve::InOutQuad, false); is_fading_out_to_pause_ = false; has_faded_out_ = false; @@ -315,7 +315,7 @@ void GstEngine::Unpause() { // Check if we faded out last time. If yes, fade in no matter what the settings say. // If we pause with fadeout, deactivate fadeout and resume playback, the player would be muted if not faded in. if (has_faded_out_) { - disconnect(current_pipeline_.get(), SIGNAL(FaderFinished()), nullptr, nullptr); + QObject::disconnect(current_pipeline_.get(), &GstEnginePipeline::FaderFinished, nullptr, nullptr); current_pipeline_->StartFader(fadeout_pause_duration_nanosec_, QTimeLine::Forward, QEasingCurve::InOutQuad, false); has_faded_out_ = false; } @@ -764,24 +764,24 @@ void GstEngine::StartFadeout() { if (is_fading_out_to_pause_) return; fadeout_pipeline_ = current_pipeline_; - disconnect(fadeout_pipeline_.get(), nullptr, nullptr, nullptr); + QObject::disconnect(fadeout_pipeline_.get(), nullptr, nullptr, nullptr); fadeout_pipeline_->RemoveAllBufferConsumers(); fadeout_pipeline_->StartFader(fadeout_duration_nanosec_, QTimeLine::Backward); - connect(fadeout_pipeline_.get(), SIGNAL(FaderFinished()), SLOT(FadeoutFinished())); + QObject::connect(fadeout_pipeline_.get(), &GstEnginePipeline::FaderFinished, this, &GstEngine::FadeoutFinished); } void GstEngine::StartFadeoutPause() { fadeout_pause_pipeline_ = current_pipeline_; - disconnect(fadeout_pause_pipeline_.get(), SIGNAL(FaderFinished()), nullptr, nullptr); + QObject::disconnect(fadeout_pause_pipeline_.get(), &GstEnginePipeline::FaderFinished, nullptr, nullptr); fadeout_pause_pipeline_->StartFader(fadeout_pause_duration_nanosec_, QTimeLine::Backward, QEasingCurve::InOutQuad, false); if (fadeout_pipeline_ && fadeout_pipeline_->state() == GST_STATE_PLAYING) { fadeout_pipeline_->StartFader(fadeout_pause_duration_nanosec_, QTimeLine::Backward, QEasingCurve::Linear, false); } - connect(fadeout_pause_pipeline_.get(), SIGNAL(FaderFinished()), SLOT(FadeoutPauseFinished())); + QObject::connect(fadeout_pause_pipeline_.get(), &GstEnginePipeline::FaderFinished, this, &GstEngine::FadeoutPauseFinished); is_fading_out_to_pause_ = true; } @@ -818,12 +818,12 @@ std::shared_ptr GstEngine::CreatePipeline() { ret->AddBufferConsumer(consumer); } - connect(ret.get(), SIGNAL(EndOfStreamReached(int, bool)), SLOT(EndOfStreamReached(int, bool))); - connect(ret.get(), SIGNAL(Error(int, QString, int, int)), SLOT(HandlePipelineError(int, QString, int, int))); - connect(ret.get(), SIGNAL(MetadataFound(int, Engine::SimpleMetaBundle)), SLOT(NewMetaData(int, Engine::SimpleMetaBundle))); - connect(ret.get(), SIGNAL(BufferingStarted()), SLOT(BufferingStarted())); - connect(ret.get(), SIGNAL(BufferingProgress(int)), SLOT(BufferingProgress(int))); - connect(ret.get(), SIGNAL(BufferingFinished()), SLOT(BufferingFinished())); + QObject::connect(ret.get(), &GstEnginePipeline::EndOfStreamReached, this, &GstEngine::EndOfStreamReached); + QObject::connect(ret.get(), &GstEnginePipeline::Error, this, &GstEngine::HandlePipelineError); + QObject::connect(ret.get(), &GstEnginePipeline::MetadataFound, this, &GstEngine::NewMetaData); + QObject::connect(ret.get(), &GstEnginePipeline::BufferingStarted, this, &GstEngine::BufferingStarted); + QObject::connect(ret.get(), &GstEnginePipeline::BufferingProgress, this, &GstEngine::BufferingProgress); + QObject::connect(ret.get(), &GstEnginePipeline::BufferingFinished, this, &GstEngine::BufferingFinished); return ret; diff --git a/src/engine/gstengine.h b/src/engine/gstengine.h index 9ac8686b..9d4a8cf3 100644 --- a/src/engine/gstengine.h +++ b/src/engine/gstengine.h @@ -209,4 +209,4 @@ class GstEngine : public Engine::Base, public GstBufferConsumer { }; -#endif /* GSTENGINE_H */ +#endif // GSTENGINE_H diff --git a/src/engine/gstenginepipeline.cpp b/src/engine/gstenginepipeline.cpp index ed700cc8..f5818c48 100644 --- a/src/engine/gstenginepipeline.cpp +++ b/src/engine/gstenginepipeline.cpp @@ -1201,8 +1201,8 @@ void GstEnginePipeline::StartFader(const qint64 duration_nanosec, const QTimeLin } fader_.reset(new QTimeLine(duration_msec, this)); - connect(fader_.get(), SIGNAL(valueChanged(qreal)), SLOT(SetVolumeModifier(qreal))); - connect(fader_.get(), SIGNAL(finished()), SLOT(FaderTimelineFinished())); + QObject::connect(fader_.get(), &QTimeLine::valueChanged, this, &GstEnginePipeline::SetVolumeModifier); + QObject::connect(fader_.get(), &QTimeLine::finished, this, &GstEnginePipeline::FaderTimelineFinished); fader_->setDirection(direction); fader_->setEasingCurve(shape); fader_->setCurrentTime(start_time); diff --git a/src/engine/gststartup.h b/src/engine/gststartup.h index b35d45c6..6f3735aa 100644 --- a/src/engine/gststartup.h +++ b/src/engine/gststartup.h @@ -43,4 +43,4 @@ class GstStartup : public QObject { }; -#endif /* GSTSTARTUP_H */ +#endif // GSTSTARTUP_H diff --git a/src/engine/macosdevicefinder.h b/src/engine/macosdevicefinder.h index a1ed7cf4..fb80483c 100644 --- a/src/engine/macosdevicefinder.h +++ b/src/engine/macosdevicefinder.h @@ -35,4 +35,4 @@ class MacOsDeviceFinder : public DeviceFinder { virtual QList ListDevices(); }; -#endif // MACOSDEVICEFINDER_H +#endif // MACOSDEVICEFINDER_H diff --git a/src/engine/pulsedevicefinder.h b/src/engine/pulsedevicefinder.h index 0de31540..8bb0312b 100644 --- a/src/engine/pulsedevicefinder.h +++ b/src/engine/pulsedevicefinder.h @@ -56,4 +56,4 @@ class PulseDeviceFinder : public DeviceFinder { }; -#endif // PULSEDEVICEFINDER_H +#endif // PULSEDEVICEFINDER_H diff --git a/src/engine/vlcengine.h b/src/engine/vlcengine.h index 2931cfeb..36a7c9eb 100644 --- a/src/engine/vlcengine.h +++ b/src/engine/vlcengine.h @@ -84,4 +84,4 @@ class VLCEngine : public Engine::Base { }; -#endif // VLCENGINE_H +#endif // VLCENGINE_H diff --git a/src/equalizer/equalizer.cpp b/src/equalizer/equalizer.cpp index db4634cc..252f553d 100644 --- a/src/equalizer/equalizer.cpp +++ b/src/equalizer/equalizer.cpp @@ -74,17 +74,17 @@ Equalizer::Equalizer(QWidget *parent) // Must be done before the signals are connected ReloadSettings(); - connect(ui_->enable_equalizer, SIGNAL(toggled(bool)), SLOT(EqualizerEnabledChangedSlot(bool))); + QObject::connect(ui_->enable_equalizer, &QCheckBox::toggled, this, &Equalizer::EqualizerEnabledChangedSlot); - connect(ui_->preset, SIGNAL(currentIndexChanged(int)), SLOT(PresetChanged(int))); - connect(ui_->preset_save, SIGNAL(clicked()), SLOT(SavePreset())); - connect(ui_->preset_del, SIGNAL(clicked()), SLOT(DelPreset())); + QObject::connect(ui_->preset, QOverload::of(&QComboBox::currentIndexChanged), this, QOverload::of(&Equalizer::PresetChanged)); + QObject::connect(ui_->preset_save, &QToolButton::clicked, this, &Equalizer::SavePreset); + QObject::connect(ui_->preset_del, &QToolButton::clicked, this, &Equalizer::DelPreset); - connect(ui_->enable_stereo_balancer, SIGNAL(toggled(bool)), SLOT(StereoBalancerEnabledChangedSlot(bool))); - connect(ui_->stereo_balance_slider, SIGNAL(valueChanged(int)), SLOT(StereoBalanceSliderChanged(int))); + QObject::connect(ui_->enable_stereo_balancer, &QCheckBox::toggled, this, &Equalizer::StereoBalancerEnabledChangedSlot); + QObject::connect(ui_->stereo_balance_slider, &QSlider::valueChanged, this, &Equalizer::StereoBalanceSliderChanged); QShortcut *close = new QShortcut(QKeySequence::Close, this); - connect(close, SIGNAL(activated()), SLOT(close())); + QObject::connect(close, &QShortcut::activated, this, &Equalizer::close); } @@ -239,7 +239,7 @@ EqualizerSlider *Equalizer::AddSlider(const QString &label) { EqualizerSlider *ret = new EqualizerSlider(label, ui_->slider_container); ui_->slider_container->layout()->addWidget(ret); - connect(ret, SIGNAL(ValueChanged(int)), SLOT(EqualizerParametersChangedSlot())); + QObject::connect(ret, &EqualizerSlider::ValueChanged, this, &Equalizer::EqualizerParametersChangedSlot); return ret; diff --git a/src/equalizer/equalizer.h b/src/equalizer/equalizer.h index 3b2ef6e8..c3037060 100644 --- a/src/equalizer/equalizer.h +++ b/src/equalizer/equalizer.h @@ -67,10 +67,10 @@ class Equalizer : public QDialog { float stereo_balance() const; signals: - void StereoBalancerEnabledChanged(const bool enabled); - void StereoBalanceChanged(const float balance); - void EqualizerEnabledChanged(const bool enabled); - void EqualizerParametersChanged(const int preamp, const QList &band_gains); + void StereoBalancerEnabledChanged(bool enabled); + void StereoBalanceChanged(float balance); + void EqualizerEnabledChanged(bool enabled); + void EqualizerParametersChanged(int preamp, QList band_gains); protected: void closeEvent(QCloseEvent*) override; diff --git a/src/equalizer/equalizerslider.cpp b/src/equalizer/equalizerslider.cpp index c0a5457e..b5e9d9dc 100644 --- a/src/equalizer/equalizerslider.cpp +++ b/src/equalizer/equalizerslider.cpp @@ -48,7 +48,7 @@ EqualizerSlider::EqualizerSlider(const QString &label, QWidget *parent) ui_->slider->setValue(0); - connect(ui_->slider, SIGNAL(valueChanged(int)), this, SLOT(OnValueChanged(int))); + QObject::connect(ui_->slider, &QSlider::valueChanged, this, &EqualizerSlider::OnValueChanged); } diff --git a/src/equalizer/equalizerslider.h b/src/equalizer/equalizerslider.h index 7e139f8c..a9ef31b9 100644 --- a/src/equalizer/equalizerslider.h +++ b/src/equalizer/equalizerslider.h @@ -31,7 +31,6 @@ class Ui_EqualizerSlider; // Contains the slider and the label class EqualizerSlider : public QWidget { - Q_OBJECT public: diff --git a/src/globalshortcuts/globalshortcutbackend-gsd.cpp b/src/globalshortcuts/globalshortcutbackend-gsd.cpp index 5b15717e..53e2fa7e 100644 --- a/src/globalshortcuts/globalshortcutbackend-gsd.cpp +++ b/src/globalshortcuts/globalshortcutbackend-gsd.cpp @@ -33,7 +33,6 @@ #include #include -#include "core/closure.h" #include "core/logging.h" #include "globalshortcuts.h" #include "globalshortcutbackend.h" @@ -69,7 +68,7 @@ bool GlobalShortcutBackendGSD::DoRegister() { QDBusPendingReply<> reply = interface_->GrabMediaPlayerKeys(QCoreApplication::applicationName(), QDateTime::currentDateTime().toSecsSinceEpoch()); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - NewClosure(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(RegisterFinished(QDBusPendingCallWatcher*)), watcher); + QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &GlobalShortcutBackendGSD::RegisterFinished); return true; @@ -85,7 +84,7 @@ void GlobalShortcutBackendGSD::RegisterFinished(QDBusPendingCallWatcher *watcher return; } - connect(interface_, SIGNAL(MediaPlayerKeyPressed(QString, QString)), this, SLOT(GnomeMediaKeyPressed(QString, QString))); + QObject::connect(interface_, &OrgGnomeSettingsDaemonMediaKeysInterface::MediaPlayerKeyPressed, this, &GlobalShortcutBackendGSD::GnomeMediaKeyPressed); is_connected_ = true; qLog(Debug) << "Registered"; @@ -104,7 +103,7 @@ void GlobalShortcutBackendGSD::DoUnregister() { is_connected_ = false; interface_->ReleaseMediaPlayerKeys(QCoreApplication::applicationName()); - disconnect(interface_, SIGNAL(MediaPlayerKeyPressed(QString, QString)), this, SLOT(GnomeMediaKeyPressed(QString, QString))); + QObject::disconnect(interface_, &OrgGnomeSettingsDaemonMediaKeysInterface::MediaPlayerKeyPressed, this, &GlobalShortcutBackendGSD::GnomeMediaKeyPressed); } diff --git a/src/globalshortcuts/globalshortcutbackend-kde.cpp b/src/globalshortcuts/globalshortcutbackend-kde.cpp index b9071c84..44b2c028 100644 --- a/src/globalshortcuts/globalshortcutbackend-kde.cpp +++ b/src/globalshortcuts/globalshortcutbackend-kde.cpp @@ -35,7 +35,6 @@ #endif #include "core/logging.h" -#include "core/closure.h" #include "globalshortcutbackend-kde.h" @@ -63,7 +62,7 @@ bool GlobalShortcutBackendKDE::DoRegister() { QDBusPendingReply reply = interface_->getComponent(QCoreApplication::applicationName()); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - NewClosure(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(RegisterFinished(QDBusPendingCallWatcher*)), watcher); + QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &GlobalShortcutBackendKDE::RegisterFinished); return true; @@ -90,7 +89,7 @@ void GlobalShortcutBackendKDE::RegisterFinished(QDBusPendingCallWatcher *watcher return; } - connect(component_, SIGNAL(globalShortcutPressed(QString, QString, qlonglong)), this, SLOT(GlobalShortcutPressed(QString, QString, qlonglong)), Qt::UniqueConnection); + QObject::connect(component_, &org::kde::kglobalaccel::Component::globalShortcutPressed, this, &GlobalShortcutBackendKDE::GlobalShortcutPressed, Qt::UniqueConnection); qLog(Debug) << "Registered"; @@ -110,7 +109,7 @@ void GlobalShortcutBackendKDE::DoUnregister() { } } - if (component_) disconnect(component_, nullptr, this, nullptr); + if (component_) QObject::disconnect(component_, nullptr, this, nullptr); qLog(Debug) << "Unregistered"; diff --git a/src/globalshortcuts/globalshortcutbackend-macos.h b/src/globalshortcuts/globalshortcutbackend-macos.h index 993e5819..ebb92f9f 100644 --- a/src/globalshortcuts/globalshortcutbackend-macos.h +++ b/src/globalshortcuts/globalshortcutbackend-macos.h @@ -62,4 +62,3 @@ class GlobalShortcutBackendMacOS : public GlobalShortcutBackend { }; #endif // GLOBALSHORTCUTBACKEND_MACOS_H - diff --git a/src/globalshortcuts/globalshortcutbackend-system.cpp b/src/globalshortcuts/globalshortcutbackend-system.cpp index aaa0878a..fcfd884b 100644 --- a/src/globalshortcuts/globalshortcutbackend-system.cpp +++ b/src/globalshortcuts/globalshortcutbackend-system.cpp @@ -56,7 +56,7 @@ bool GlobalShortcutBackendSystem::AddShortcut(QAction *action) { if (action->shortcut().isEmpty()) return false; GlobalShortcut *shortcut = new GlobalShortcut(action->shortcut(), this, this); - connect(shortcut, SIGNAL(activated()), action, SLOT(trigger())); + QObject::connect(shortcut, &GlobalShortcut::activated, action, &QAction::trigger); shortcuts_ << shortcut; return true; diff --git a/src/globalshortcuts/globalshortcutbackend-system.h b/src/globalshortcuts/globalshortcutbackend-system.h index 8b6be365..078ebd57 100644 --- a/src/globalshortcuts/globalshortcutbackend-system.h +++ b/src/globalshortcuts/globalshortcutbackend-system.h @@ -46,7 +46,6 @@ class GlobalShortcutBackendSystem : public GlobalShortcutBackend { void DoUnregister() override; private: - bool AddShortcut(QAction *action); bool RemoveShortcut(QAction *action); diff --git a/src/globalshortcuts/globalshortcutgrabber.cpp b/src/globalshortcuts/globalshortcutgrabber.cpp index 2ac6af56..b1c54643 100644 --- a/src/globalshortcuts/globalshortcutgrabber.cpp +++ b/src/globalshortcuts/globalshortcutgrabber.cpp @@ -40,8 +40,8 @@ GlobalShortcutGrabber::GlobalShortcutGrabber(QWidget *parent) modifier_keys_ << Qt::Key_Shift << Qt::Key_Control << Qt::Key_Meta << Qt::Key_Alt << Qt::Key_AltGr; - connect(ui_->buttonBox, SIGNAL(accepted()), this, SLOT(Accepted())); - connect(ui_->buttonBox, SIGNAL(rejected()), this, SLOT(Rejected())); + QObject::connect(ui_->buttonBox, &QDialogButtonBox::accepted, this, &GlobalShortcutGrabber::Accepted); + QObject::connect(ui_->buttonBox, &QDialogButtonBox::rejected, this, &GlobalShortcutGrabber::Rejected); } diff --git a/src/globalshortcuts/globalshortcuts.cpp b/src/globalshortcuts/globalshortcuts.cpp index 6eb34e10..b7bc6c86 100644 --- a/src/globalshortcuts/globalshortcuts.cpp +++ b/src/globalshortcuts/globalshortcuts.cpp @@ -121,7 +121,7 @@ void GlobalShortcuts::ReloadSettings() { void GlobalShortcuts::AddShortcut(const QString &id, const QString &name, const char *signal, const QKeySequence &default_key) { Shortcut shortcut = AddShortcut(id, name, default_key); - connect(shortcut.action, SIGNAL(triggered()), this, signal); + QObject::connect(shortcut.action, SIGNAL(triggered()), this, signal); } diff --git a/src/globalshortcuts/globalshortcuts.h b/src/globalshortcuts/globalshortcuts.h index b2988f33..1aa5c133 100644 --- a/src/globalshortcuts/globalshortcuts.h +++ b/src/globalshortcuts/globalshortcuts.h @@ -100,4 +100,4 @@ class GlobalShortcuts : public QWidget { bool use_x11_; }; -#endif +#endif // GLOBALSHORTCUTS_H diff --git a/src/globalshortcuts/keymapper_win.h b/src/globalshortcuts/keymapper_win.h index 24ef8fee..f0b0186c 100644 --- a/src/globalshortcuts/keymapper_win.h +++ b/src/globalshortcuts/keymapper_win.h @@ -17,6 +17,9 @@ * */ +#ifndef KEYMAPPER_WIN_H +#define KEYMAPPER_WIN_H + #include "config.h" #include @@ -132,3 +135,5 @@ static const QMap keymapper_win_ = { }; } // namespace + +#endif // KEYMAPPER_WIN_H diff --git a/src/globalshortcuts/keymapper_x11.h b/src/globalshortcuts/keymapper_x11.h index ca823483..7f2563a1 100644 --- a/src/globalshortcuts/keymapper_x11.h +++ b/src/globalshortcuts/keymapper_x11.h @@ -17,6 +17,9 @@ * */ +#ifndef KEYMAPPER_X11_H +#define KEYMAPPER_X11_H + #include "config.h" #include @@ -249,3 +252,4 @@ static const QMap keymapper_x11_ = { }; } // namespace +#endif // KEYMAPPER_X11_H diff --git a/src/internet/internetcollectionview.cpp b/src/internet/internetcollectionview.cpp index e3992107..3b1172bc 100644 --- a/src/internet/internetcollectionview.cpp +++ b/src/internet/internetcollectionview.cpp @@ -122,8 +122,8 @@ void InternetCollectionView::SaveFocus() { switch (type.toInt()) { case CollectionItem::Type_Song: { - QModelIndex index = qobject_cast(model())->mapToSource(current); - SongList songs = collection_model_->GetChildSongs(index); + QModelIndex idx = qobject_cast(model())->mapToSource(current); + SongList songs = collection_model_->GetChildSongs(idx); if (!songs.isEmpty()) { last_selected_song_ = songs.last(); } @@ -180,8 +180,8 @@ bool InternetCollectionView::RestoreLevelFocus(const QModelIndex &parent) { switch (type.toInt()) { case CollectionItem::Type_Song: if (!last_selected_song_.url().isEmpty()) { - QModelIndex index = qobject_cast(model())->mapToSource(current); - SongList songs = collection_model_->GetChildSongs(index); + QModelIndex idx = qobject_cast(model())->mapToSource(current); + SongList songs = collection_model_->GetChildSongs(idx); for (const Song &song : songs) { if (song == last_selected_song_) { setCurrentIndex(current); @@ -308,18 +308,18 @@ void InternetCollectionView::contextMenuEvent(QContextMenuEvent *e) { if (!context_menu_) { context_menu_ = new QMenu(this); - add_to_playlist_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, SLOT(AddToPlaylist())); - load_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, SLOT(Load())); - open_in_new_playlist_ = context_menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, SLOT(OpenInNewPlaylist())); + add_to_playlist_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, &InternetCollectionView::AddToPlaylist); + load_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, &InternetCollectionView::Load); + open_in_new_playlist_ = context_menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, &InternetCollectionView::OpenInNewPlaylist); context_menu_->addSeparator(); - add_to_playlist_enqueue_ = context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue track"), this, SLOT(AddToPlaylistEnqueue())); - add_to_playlist_enqueue_next_ = context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue to play next"), this, SLOT(AddToPlaylistEnqueueNext())); + add_to_playlist_enqueue_ = context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue track"), this, &InternetCollectionView::AddToPlaylistEnqueue); + add_to_playlist_enqueue_next_ = context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue to play next"), this, &InternetCollectionView::AddToPlaylistEnqueueNext); context_menu_->addSeparator(); if (favorite_) { - remove_songs_ = context_menu_->addAction(IconLoader::Load("edit-delete"), tr("Remove from favorites"), this, SLOT(RemoveSongs())); + remove_songs_ = context_menu_->addAction(IconLoader::Load("edit-delete"), tr("Remove from favorites"), this, &InternetCollectionView::RemoveSelectedSongs); context_menu_->addSeparator(); } @@ -391,7 +391,7 @@ void InternetCollectionView::OpenInNewPlaylist() { } -void InternetCollectionView::RemoveSongs() { +void InternetCollectionView::RemoveSelectedSongs() { emit RemoveSongs(GetSelectedSongs()); @@ -405,12 +405,12 @@ void InternetCollectionView::keyboardSearch(const QString &search) { } -void InternetCollectionView::scrollTo(const QModelIndex &index, ScrollHint hint) { +void InternetCollectionView::scrollTo(const QModelIndex &idx, ScrollHint hint) { if (is_in_keyboard_search_) - QTreeView::scrollTo(index, QAbstractItemView::PositionAtTop); + QTreeView::scrollTo(idx, QAbstractItemView::PositionAtTop); else - QTreeView::scrollTo(index, hint); + QTreeView::scrollTo(idx, hint); } diff --git a/src/internet/internetcollectionview.h b/src/internet/internetcollectionview.h index f6c5ee3a..cd05e3d3 100644 --- a/src/internet/internetcollectionview.h +++ b/src/internet/internetcollectionview.h @@ -63,7 +63,7 @@ class InternetCollectionView : public AutoExpandingTreeView { // QTreeView void keyboardSearch(const QString &search) override; - void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override; + void scrollTo(const QModelIndex &idx, ScrollHint hint = EnsureVisible) override; int TotalSongs(); int TotalArtists(); @@ -85,8 +85,8 @@ class InternetCollectionView : public AutoExpandingTreeView { void TotalSongCountUpdated_(); void TotalArtistCountUpdated_(); void TotalAlbumCountUpdated_(); - void Error(const QString &message); - void RemoveSongs(const SongList &songs); + void Error(QString); + void RemoveSongs(SongList); protected: // QWidget @@ -100,7 +100,7 @@ class InternetCollectionView : public AutoExpandingTreeView { void AddToPlaylistEnqueue(); void AddToPlaylistEnqueueNext(); void OpenInNewPlaylist(); - void RemoveSongs(); + void RemoveSelectedSongs(); private: void RecheckIsEmpty(); diff --git a/src/internet/internetcollectionviewcontainer.cpp b/src/internet/internetcollectionviewcontainer.cpp index 3e72f869..ae29d93e 100644 --- a/src/internet/internetcollectionviewcontainer.cpp +++ b/src/internet/internetcollectionviewcontainer.cpp @@ -32,16 +32,15 @@ InternetCollectionViewContainer::InternetCollectionViewContainer(QWidget *parent) : QWidget(parent), - ui_(new Ui_InternetCollectionViewContainer) - { + ui_(new Ui_InternetCollectionViewContainer) { ui_->setupUi(this); view()->SetFilter(filter()); - connect(filter(), SIGNAL(UpPressed()), view(), SLOT(UpAndFocus())); - connect(filter(), SIGNAL(DownPressed()), view(), SLOT(DownAndFocus())); - connect(filter(), SIGNAL(ReturnPressed()), view(), SLOT(FilterReturnPressed())); - connect(view(), SIGNAL(FocusOnFilterSignal(QKeyEvent*)), filter(), SLOT(FocusOnFilter(QKeyEvent*))); + QObject::connect(filter(), &CollectionFilterWidget::UpPressed, view(), &InternetCollectionView::UpAndFocus); + QObject::connect(filter(), &CollectionFilterWidget::DownPressed, view(), &InternetCollectionView::DownAndFocus); + QObject::connect(filter(), &CollectionFilterWidget::ReturnPressed, view(), &InternetCollectionView::FilterReturnPressed); + QObject::connect(view(), &InternetCollectionView::FocusOnFilterSignal, filter(), &CollectionFilterWidget::FocusOnFilter); ui_->progressbar->hide(); diff --git a/src/internet/internetplaylistitem.h b/src/internet/internetplaylistitem.h index 10f5056d..a80b6c3a 100644 --- a/src/internet/internetplaylistitem.h +++ b/src/internet/internetplaylistitem.h @@ -57,4 +57,4 @@ class InternetPlaylistItem : public PlaylistItem { Song metadata_; }; -#endif +#endif // INTERNETPLAYLISTITEM_H diff --git a/src/internet/internetsearchmodel.cpp b/src/internet/internetsearchmodel.cpp index e38e3aa0..c873a9e1 100644 --- a/src/internet/internetsearchmodel.cpp +++ b/src/internet/internetsearchmodel.cpp @@ -293,8 +293,8 @@ void InternetSearchModel::Clear() { InternetSearchView::ResultList InternetSearchModel::GetChildResults(const QModelIndexList &indexes) const { QList items; - for (const QModelIndex &index : indexes) { - items << itemFromIndex(index); + for (const QModelIndex &idx : indexes) { + items << itemFromIndex(idx); } return GetChildResults(items); @@ -327,8 +327,8 @@ void InternetSearchModel::GetChildResults(const QStandardItem *item, InternetSea // Yes - visit all the children, but do so through the proxy so we get them in the right order. for (int i = 0 ; i < item->rowCount() ; ++i) { const QModelIndex proxy_index = parent_proxy_index.model()->index(i, 0, parent_proxy_index); - const QModelIndex index = proxy_->mapToSource(proxy_index); - GetChildResults(itemFromIndex(index), results, visited); + const QModelIndex idx = proxy_->mapToSource(proxy_index); + GetChildResults(itemFromIndex(idx), results, visited); } } else { diff --git a/src/internet/internetsearchview.cpp b/src/internet/internetsearchview.cpp index 02a7d2a8..46df65ef 100644 --- a/src/internet/internetsearchview.cpp +++ b/src/internet/internetsearchview.cpp @@ -185,30 +185,30 @@ void InternetSearchView::Init(Application *app, InternetService *service) { QMenu *settings_menu = new QMenu(this); settings_menu->addActions(group_by_actions_->actions()); settings_menu->addSeparator(); - settings_menu->addAction(IconLoader::Load("configure"), tr("Configure %1...").arg(Song::TextForSource(service_->source())), this, SLOT(OpenSettingsDialog())); + settings_menu->addAction(IconLoader::Load("configure"), tr("Configure %1...").arg(Song::TextForSource(service_->source())), this, &InternetSearchView::OpenSettingsDialog); ui_->settings->setMenu(settings_menu); swap_models_timer_->setSingleShot(true); swap_models_timer_->setInterval(kSwapModelsTimeoutMsec); - connect(swap_models_timer_, SIGNAL(timeout()), SLOT(SwapModels())); + QObject::connect(swap_models_timer_, &QTimer::timeout, this, &InternetSearchView::SwapModels); - connect(ui_->radiobutton_search_artists, SIGNAL(clicked(bool)), SLOT(SearchArtistsClicked(bool))); - connect(ui_->radiobutton_search_albums, SIGNAL(clicked(bool)), SLOT(SearchAlbumsClicked(bool))); - connect(ui_->radiobutton_search_songs, SIGNAL(clicked(bool)), SLOT(SearchSongsClicked(bool))); - connect(group_by_actions_, SIGNAL(triggered(QAction*)), SLOT(GroupByClicked(QAction*))); - connect(group_by_actions_, SIGNAL(triggered(QAction*)), SLOT(GroupByClicked(QAction*))); + QObject::connect(ui_->radiobutton_search_artists, &QRadioButton::clicked, this, &InternetSearchView::SearchArtistsClicked); + QObject::connect(ui_->radiobutton_search_albums, &QRadioButton::clicked, this, &InternetSearchView::SearchAlbumsClicked); + QObject::connect(ui_->radiobutton_search_songs, &QRadioButton::clicked, this, &InternetSearchView::SearchSongsClicked); + QObject::connect(group_by_actions_, &QActionGroup::triggered, this, &InternetSearchView::GroupByClicked); + QObject::connect(group_by_actions_, &QActionGroup::triggered, this, &InternetSearchView::GroupByClicked); - connect(ui_->search, SIGNAL(textChanged(QString)), SLOT(TextEdited(QString))); - connect(ui_->results, SIGNAL(AddToPlaylistSignal(QMimeData*)), SIGNAL(AddToPlaylist(QMimeData*))); - connect(ui_->results, SIGNAL(FocusOnFilterSignal(QKeyEvent*)), SLOT(FocusOnFilter(QKeyEvent*))); + QObject::connect(ui_->search, &QSearchField::textChanged, this, &InternetSearchView::TextEdited); + QObject::connect(ui_->results, &AutoExpandingTreeView::AddToPlaylistSignal, this, &InternetSearchView::AddToPlaylist); + QObject::connect(ui_->results, &AutoExpandingTreeView::FocusOnFilterSignal, this, &InternetSearchView::FocusOnFilter); - connect(service_, SIGNAL(SearchUpdateStatus(int, QString)), SLOT(UpdateStatus(int, QString))); - connect(service_, SIGNAL(SearchProgressSetMaximum(int, int)), SLOT(ProgressSetMaximum(int, int))); - connect(service_, SIGNAL(SearchUpdateProgress(int, int)), SLOT(UpdateProgress(int, int))); - connect(service_, SIGNAL(SearchResults(int, SongList, QString)), SLOT(SearchDone(int, SongList, QString))); + QObject::connect(service_, &InternetService::SearchUpdateStatus, this, &InternetSearchView::UpdateStatus); + QObject::connect(service_, &InternetService::SearchProgressSetMaximum, this, &InternetSearchView::ProgressSetMaximum); + QObject::connect(service_, &InternetService::SearchUpdateProgress, this, &InternetSearchView::UpdateProgress); + QObject::connect(service_, &InternetService::SearchResults, this, &InternetSearchView::SearchDone); - connect(app_, SIGNAL(SettingsChanged()), SLOT(ReloadSettings())); - connect(app_->album_cover_loader(), SIGNAL(AlbumCoverLoaded(quint64, AlbumCoverLoaderResult)), SLOT(AlbumCoverLoaded(quint64, AlbumCoverLoaderResult))); + QObject::connect(app_, &Application::SettingsChanged, this, &InternetSearchView::ReloadSettings); + QObject::connect(app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &InternetSearchView::AlbumCoverLoaded); ReloadSettings(); @@ -315,36 +315,36 @@ bool InternetSearchView::SearchKeyEvent(QKeyEvent *e) { bool InternetSearchView::ResultsContextMenuEvent(QContextMenuEvent *e) { context_menu_ = new QMenu(this); - context_actions_ << context_menu_->addAction( IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, SLOT(AddSelectedToPlaylist())); - context_actions_ << context_menu_->addAction( IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, SLOT(LoadSelected())); - context_actions_ << context_menu_->addAction( IconLoader::Load("document-new"), tr("Open in new playlist"), this, SLOT(OpenSelectedInNewPlaylist())); + context_actions_ << context_menu_->addAction( IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, &InternetSearchView::AddSelectedToPlaylist); + context_actions_ << context_menu_->addAction( IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, &InternetSearchView::LoadSelected); + context_actions_ << context_menu_->addAction( IconLoader::Load("document-new"), tr("Open in new playlist"), this, &InternetSearchView::OpenSelectedInNewPlaylist); context_menu_->addSeparator(); - context_actions_ << context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue track"), this, SLOT(AddSelectedToPlaylistEnqueue())); + context_actions_ << context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue track"), this, &InternetSearchView::AddSelectedToPlaylistEnqueue); context_menu_->addSeparator(); if (service_->artists_collection_model() || service_->albums_collection_model() || service_->songs_collection_model()) { if (service_->artists_collection_model()) { - context_actions_ << context_menu_->addAction(IconLoader::Load("folder-new"), tr("Add to artists"), this, SLOT(AddArtists())); + context_actions_ << context_menu_->addAction(IconLoader::Load("folder-new"), tr("Add to artists"), this, &InternetSearchView::AddArtists); } if (service_->albums_collection_model()) { - context_actions_ << context_menu_->addAction(IconLoader::Load("folder-new"), tr("Add to albums"), this, SLOT(AddAlbums())); + context_actions_ << context_menu_->addAction(IconLoader::Load("folder-new"), tr("Add to albums"), this, &InternetSearchView::AddAlbums); } if (service_->songs_collection_model()) { - context_actions_ << context_menu_->addAction(IconLoader::Load("folder-new"), tr("Add to songs"), this, SLOT(AddSongs())); + context_actions_ << context_menu_->addAction(IconLoader::Load("folder-new"), tr("Add to songs"), this, &InternetSearchView::AddSongs); } context_menu_->addSeparator(); } if (ui_->results->selectionModel() && ui_->results->selectionModel()->selectedRows().length() == 1) { - context_actions_ << context_menu_->addAction(IconLoader::Load("search"), tr("Search for this"), this, SLOT(SearchForThis())); + context_actions_ << context_menu_->addAction(IconLoader::Load("search"), tr("Search for this"), this, &InternetSearchView::SearchForThis); } context_menu_->addSeparator(); context_menu_->addMenu(tr("Group by"))->addActions(group_by_actions_->actions()); - context_menu_->addAction(IconLoader::Load("configure"), tr("Configure %1...").arg(Song::TextForSource(service_->source())), this, SLOT(OpenSettingsDialog())); + context_menu_->addAction(IconLoader::Load("configure"), tr("Configure %1...").arg(Song::TextForSource(service_->source())), this, &InternetSearchView::OpenSettingsDialog); const bool enable_context_actions = ui_->results->selectionModel() && ui_->results->selectionModel()->hasSelection(); @@ -589,10 +589,10 @@ MimeData *InternetSearchView::SelectedMimeData() { if (indexes.isEmpty()) { // There's nothing selected - take the first thing in the model that isn't a divider. for (int i = 0 ; i < front_proxy_->rowCount() ; ++i) { - QModelIndex index = front_proxy_->index(i, 0); - if (!index.data(CollectionModel::Role_IsDivider).toBool()) { - indexes << index; - ui_->results->setCurrentIndex(index); + QModelIndex idx = front_proxy_->index(i, 0); + if (!idx.data(CollectionModel::Role_IsDivider).toBool()) { + indexes << idx; + ui_->results->setCurrentIndex(idx); break; } } @@ -605,8 +605,8 @@ MimeData *InternetSearchView::SelectedMimeData() { // Get items for these indexes QList items; - for (const QModelIndex &index : indexes) { - items << (front_model_->itemFromIndex(front_proxy_->mapToSource(index))); + for (const QModelIndex &idx : indexes) { + items << (front_model_->itemFromIndex(front_proxy_->mapToSource(idx))); } // Get a MimeData for these items @@ -675,7 +675,7 @@ void InternetSearchView::GroupByClicked(QAction *action) { if (action->property("group_by").isNull()) { if (!group_by_dialog_) { group_by_dialog_.reset(new GroupByDialog); - connect(group_by_dialog_.get(), SIGNAL(Accepted(CollectionModel::Grouping)), SLOT(SetGroupBy(CollectionModel::Grouping))); + QObject::connect(group_by_dialog_.get(), &GroupByDialog::Accepted, this, &InternetSearchView::SetGroupBy); } group_by_dialog_->show(); diff --git a/src/internet/internetsearchview.h b/src/internet/internetsearchview.h index c335f6f0..bb98f66a 100644 --- a/src/internet/internetsearchview.h +++ b/src/internet/internetsearchview.h @@ -86,7 +86,7 @@ class InternetSearchView : public QWidget { void Init(Application *app, InternetService *service); - void LazyLoadAlbumCover(const QModelIndex &index); + void LazyLoadAlbumCover(const QModelIndex &idx); protected: struct PendingState { diff --git a/src/internet/internetservice.h b/src/internet/internetservice.h index c6a78aa6..ef59b45b 100644 --- a/src/internet/internetservice.h +++ b/src/internet/internetservice.h @@ -84,51 +84,51 @@ class InternetService : public QObject { void ExitFinished(); void Login(); void Logout(); - void Login(const QString &api_token, const QString &username, const QString &password); - void Login(const QString &hostname, const int, const QString &username, const QString &password); + void LoginWithCredentials(QString api_token, QString username, QString password); + void LoginWithHostname(QString hostname, int, QString username, QString password); void LoginSuccess(); - void LoginFailure(const QString &failure_reason); - void LoginComplete(const bool success, QString error = QString()); + void LoginFailure(QString failure_reason); + void LoginComplete(bool success, QString error = QString()); void TestSuccess(); - void TestFailure(const QString &failure_reason); - void TestComplete(const bool success, QString error = QString()); + void TestFailure(QString failure_reason); + void TestComplete(bool success, QString error = QString()); - void Error(const QString &error); - void Results(const SongList &songs, const QString &error); - void UpdateStatus(const QString &text); - void ProgressSetMaximum(const int max); - void UpdateProgress(const int max); + void Error(QString error); + void Results(SongList songs, QString error); + void UpdateStatus(QString text); + void ProgressSetMaximum(int max); + void UpdateProgress(int max); - void ArtistsResults(const SongList &songs, const QString &error); - void ArtistsUpdateStatus(const QString &text); - void ArtistsProgressSetMaximum(const int max); - void ArtistsUpdateProgress(const int max); + void ArtistsResults(SongList songs, QString error); + void ArtistsUpdateStatus(QString text); + void ArtistsProgressSetMaximum(int max); + void ArtistsUpdateProgress(int max); - void AlbumsResults(const SongList &songs, const QString &error); - void AlbumsUpdateStatus(const QString &text); - void AlbumsProgressSetMaximum(const int max); - void AlbumsUpdateProgress(const int max); + void AlbumsResults(SongList songs, QString error); + void AlbumsUpdateStatus(QString text); + void AlbumsProgressSetMaximum(int max); + void AlbumsUpdateProgress(int max); - void SongsResults(const SongList &songs, const QString &error); - void SongsUpdateStatus(const QString &text); - void SongsProgressSetMaximum(const int max); - void SongsUpdateProgress(const int max); + void SongsResults(SongList songs, QString error); + void SongsUpdateStatus(QString text); + void SongsProgressSetMaximum(int max); + void SongsUpdateProgress(int max); - void SearchResults(const int id, const SongList &songs, const QString &error); - void SearchUpdateStatus(const int id, const QString &text); - void SearchProgressSetMaximum(const int id, const int max); - void SearchUpdateProgress(const int id, const int max); + void SearchResults(int id, SongList songs, QString error); + void SearchUpdateStatus(int id, QString text); + void SearchProgressSetMaximum(int id, int max); + void SearchUpdateProgress(int id, int max); - void AddArtists(const SongList& songs); - void AddAlbums(const SongList& songs); - void AddSongs(const SongList& songs); + void AddArtists(SongList); + void AddAlbums(SongList); + void AddSongs(SongList); - void RemoveArtists(const SongList& songs); - void RemoveAlbums(const SongList& songs); - void RemoveSongs(const SongList& songs); + void RemoveArtists(SongList); + void RemoveAlbums(SongList); + void RemoveSongs(SongList); - void StreamURLFinished(const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration, QString error = QString()); + void StreamURLFinished(QUrl original_url, QUrl stream_url, Song::FileType filetype, int samplerate, int bit_depth, qint64 duration, QString error = QString()); protected: Application *app_; @@ -143,4 +143,4 @@ class InternetService : public QObject { }; Q_DECLARE_METATYPE(InternetService*) -#endif +#endif // INTERNETSERVICE_H diff --git a/src/internet/internetservices.cpp b/src/internet/internetservices.cpp index 7feee410..5deafe5b 100644 --- a/src/internet/internetservices.cpp +++ b/src/internet/internetservices.cpp @@ -54,7 +54,7 @@ void InternetServices::RemoveService(InternetService *service) { if (!services_.contains(service->source())) return; services_.remove(service->source()); - disconnect(service, nullptr, this, nullptr); + QObject::disconnect(service, nullptr, this, nullptr); qLog(Debug) << "Removed internet service" << service->name(); @@ -77,7 +77,7 @@ void InternetServices::Exit() { for (InternetService *service : services_.values()) { wait_for_exit_ << service; - connect(service, SIGNAL(ExitFinished()), this, SLOT(ExitReceived())); + QObject::connect(service, &InternetService::ExitFinished, this, &InternetServices::ExitReceived); service->Exit(); } if (wait_for_exit_.isEmpty()) emit ExitFinished(); diff --git a/src/internet/internetservices.h b/src/internet/internetservices.h index 99822ffd..4b3db670 100644 --- a/src/internet/internetservices.h +++ b/src/internet/internetservices.h @@ -63,4 +63,4 @@ class InternetServices : public QObject { }; -#endif +#endif // INTERNETSERVICES_H diff --git a/src/internet/internetsongmimedata.h b/src/internet/internetsongmimedata.h index 68541f49..0af9c5a6 100644 --- a/src/internet/internetsongmimedata.h +++ b/src/internet/internetsongmimedata.h @@ -36,4 +36,4 @@ class InternetSongMimeData : public MimeData { SongList songs; }; -#endif +#endif // INTERNETSONGMIMEDATA_H diff --git a/src/internet/internetsongsview.cpp b/src/internet/internetsongsview.cpp index c6c857da..e5b61670 100644 --- a/src/internet/internetsongsview.cpp +++ b/src/internet/internetsongsview.cpp @@ -59,25 +59,25 @@ InternetSongsView::InternetSongsView(Application *app, InternetService *service, ui_->filter->SetCollectionModel(service_->songs_collection_model()); QAction *action_configure = new QAction(IconLoader::Load("configure"), tr("Configure %1...").arg(Song::TextForSource(service_->source())), this); - connect(action_configure, SIGNAL(triggered()), SLOT(OpenSettingsDialog())); + QObject::connect(action_configure, &QAction::triggered, this, &InternetSongsView::OpenSettingsDialog); ui_->filter->AddMenuAction(action_configure); - connect(ui_->view, SIGNAL(GetSongs()), SLOT(GetSongs())); - connect(ui_->view, SIGNAL(RemoveSongs(SongList)), service_, SIGNAL(RemoveSongs(SongList))); + QObject::connect(ui_->view, &InternetCollectionView::GetSongs, this, &InternetSongsView::GetSongs); + QObject::connect(ui_->view, &InternetCollectionView::RemoveSongs, service_, &InternetService::RemoveSongs); - connect(ui_->refresh, SIGNAL(clicked()), SLOT(GetSongs())); - connect(ui_->close, SIGNAL(clicked()), SLOT(AbortGetSongs())); - connect(ui_->abort, SIGNAL(clicked()), SLOT(AbortGetSongs())); - connect(service_, SIGNAL(SongsResults(SongList, QString)), SLOT(SongsFinished(SongList, QString))); - connect(service_, SIGNAL(SongsUpdateStatus(QString)), ui_->status, SLOT(setText(QString))); - connect(service_, SIGNAL(SongsProgressSetMaximum(int)), ui_->progressbar, SLOT(setMaximum(int))); - connect(service_, SIGNAL(SongsUpdateProgress(int)), ui_->progressbar, SLOT(setValue(int))); + QObject::connect(ui_->refresh, &QPushButton::clicked, this, &InternetSongsView::GetSongs); + QObject::connect(ui_->close, &QPushButton::clicked, this, &InternetSongsView::AbortGetSongs); + QObject::connect(ui_->abort, &QPushButton::clicked, this, &InternetSongsView::AbortGetSongs); + QObject::connect(service_, &InternetService::SongsResults, this, &InternetSongsView::SongsFinished); + QObject::connect(service_, &InternetService::SongsUpdateStatus, ui_->status, &QLabel::setText); + QObject::connect(service_, &InternetService::SongsProgressSetMaximum, ui_->progressbar, &QProgressBar::setMaximum); + QObject::connect(service_, &InternetService::SongsUpdateProgress, ui_->progressbar, &QProgressBar::setValue); - connect(service_->songs_collection_model(), SIGNAL(TotalArtistCountUpdated(int)), ui_->view, SLOT(TotalArtistCountUpdated(int))); - connect(service_->songs_collection_model(), SIGNAL(TotalAlbumCountUpdated(int)), ui_->view, SLOT(TotalAlbumCountUpdated(int))); - connect(service_->songs_collection_model(), SIGNAL(TotalSongCountUpdated(int)), ui_->view, SLOT(TotalSongCountUpdated(int))); - connect(service_->songs_collection_model(), SIGNAL(modelAboutToBeReset()), ui_->view, SLOT(SaveFocus())); - connect(service_->songs_collection_model(), SIGNAL(modelReset()), ui_->view, SLOT(RestoreFocus())); + QObject::connect(service_->songs_collection_model(), &CollectionModel::TotalArtistCountUpdated, ui_->view, &InternetCollectionView::TotalArtistCountUpdated); + QObject::connect(service_->songs_collection_model(), &CollectionModel::TotalAlbumCountUpdated, ui_->view, &InternetCollectionView::TotalAlbumCountUpdated); + QObject::connect(service_->songs_collection_model(), &CollectionModel::TotalSongCountUpdated, ui_->view, &InternetCollectionView::TotalSongCountUpdated); + QObject::connect(service_->songs_collection_model(), &CollectionModel::modelAboutToBeReset, ui_->view, &InternetCollectionView::SaveFocus); + QObject::connect(service_->songs_collection_model(), &CollectionModel::modelReset, ui_->view, &InternetCollectionView::RestoreFocus); ReloadSettings(); diff --git a/src/internet/internettabsview.cpp b/src/internet/internettabsview.cpp index e0f1d1c8..949808b9 100644 --- a/src/internet/internettabsview.cpp +++ b/src/internet/internettabsview.cpp @@ -56,12 +56,12 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, c ui_->setupUi(this); ui_->search_view->Init(app, service); - connect(ui_->search_view, SIGNAL(AddArtistsSignal(SongList)), service_, SIGNAL(AddArtists(SongList))); - connect(ui_->search_view, SIGNAL(AddAlbumsSignal(SongList)), service_, SIGNAL(AddAlbums(SongList))); - connect(ui_->search_view, SIGNAL(AddSongsSignal(SongList)), service_, SIGNAL(AddSongs(SongList))); + QObject::connect(ui_->search_view, &InternetSearchView::AddArtistsSignal, service_, &InternetService::AddArtists); + QObject::connect(ui_->search_view, &InternetSearchView::AddAlbumsSignal, service_, &InternetService::AddAlbums); + QObject::connect(ui_->search_view, &InternetSearchView::AddSongsSignal, service_, &InternetService::AddSongs); QAction *action_configure = new QAction(IconLoader::Load("configure"), tr("Configure %1...").arg(Song::TextForSource(service_->source())), this); - connect(action_configure, SIGNAL(triggered()), SLOT(OpenSettingsDialog())); + QObject::connect(action_configure, &QAction::triggered, this, &InternetTabsView::OpenSettingsDialog); if (service_->artists_collection_model()) { ui_->artists_collection->stacked()->setCurrentWidget(ui_->artists_collection->internetcollection_page()); @@ -73,22 +73,22 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, c ui_->artists_collection->filter()->SetCollectionModel(service_->artists_collection_model()); ui_->artists_collection->filter()->AddMenuAction(action_configure); - connect(ui_->artists_collection->view(), SIGNAL(GetSongs()), SLOT(GetArtists())); - connect(ui_->artists_collection->view(), SIGNAL(RemoveSongs(SongList)), service_, SIGNAL(RemoveArtists(SongList))); + QObject::connect(ui_->artists_collection->view(), &InternetCollectionView::GetSongs, this, &InternetTabsView::GetArtists); + QObject::connect(ui_->artists_collection->view(), &InternetCollectionView::RemoveSongs, service_, &InternetService::RemoveArtists); - connect(ui_->artists_collection->button_refresh(), SIGNAL(clicked()), SLOT(GetArtists())); - connect(ui_->artists_collection->button_close(), SIGNAL(clicked()), SLOT(AbortGetArtists())); - connect(ui_->artists_collection->button_abort(), SIGNAL(clicked()), SLOT(AbortGetArtists())); - connect(service_, SIGNAL(ArtistsResults(SongList, QString)), SLOT(ArtistsFinished(SongList, QString))); - connect(service_, SIGNAL(ArtistsUpdateStatus(QString)), ui_->artists_collection->status(), SLOT(setText(QString))); - connect(service_, SIGNAL(ArtistsProgressSetMaximum(int)), ui_->artists_collection->progressbar(), SLOT(setMaximum(int))); - connect(service_, SIGNAL(ArtistsUpdateProgress(int)), ui_->artists_collection->progressbar(), SLOT(setValue(int))); + QObject::connect(ui_->artists_collection->button_refresh(), &QPushButton::clicked, this, &InternetTabsView::GetArtists); + QObject::connect(ui_->artists_collection->button_close(), &QPushButton::clicked, this, &InternetTabsView::AbortGetArtists); + QObject::connect(ui_->artists_collection->button_abort(), &QPushButton::clicked, this, &InternetTabsView::AbortGetArtists); + QObject::connect(service_, &InternetService::ArtistsResults, this, &InternetTabsView::ArtistsFinished); + QObject::connect(service_, &InternetService::ArtistsUpdateStatus, ui_->artists_collection->status(), &QLabel::setText); + QObject::connect(service_, &InternetService::ArtistsProgressSetMaximum, ui_->artists_collection->progressbar(), &QProgressBar::setMaximum); + QObject::connect(service_, &InternetService::ArtistsUpdateProgress, ui_->artists_collection->progressbar(), &QProgressBar::setValue); - connect(service_->artists_collection_model(), SIGNAL(TotalArtistCountUpdated(int)), ui_->artists_collection->view(), SLOT(TotalArtistCountUpdated(int))); - connect(service_->artists_collection_model(), SIGNAL(TotalAlbumCountUpdated(int)), ui_->artists_collection->view(), SLOT(TotalAlbumCountUpdated(int))); - connect(service_->artists_collection_model(), SIGNAL(TotalSongCountUpdated(int)), ui_->artists_collection->view(), SLOT(TotalSongCountUpdated(int))); - connect(service_->artists_collection_model(), SIGNAL(modelAboutToBeReset()), ui_->artists_collection->view(), SLOT(SaveFocus())); - connect(service_->artists_collection_model(), SIGNAL(modelReset()), ui_->artists_collection->view(), SLOT(RestoreFocus())); + QObject::connect(service_->artists_collection_model(), &CollectionModel::TotalArtistCountUpdated, ui_->artists_collection->view(), &InternetCollectionView::TotalArtistCountUpdated); + QObject::connect(service_->artists_collection_model(), &CollectionModel::TotalAlbumCountUpdated, ui_->artists_collection->view(), &InternetCollectionView::TotalAlbumCountUpdated); + QObject::connect(service_->artists_collection_model(), &CollectionModel::TotalSongCountUpdated, ui_->artists_collection->view(), &InternetCollectionView::TotalSongCountUpdated); + QObject::connect(service_->artists_collection_model(), &CollectionModel::modelAboutToBeReset, ui_->artists_collection->view(), &InternetCollectionView::SaveFocus); + QObject::connect(service_->artists_collection_model(), &CollectionModel::modelReset, ui_->artists_collection->view(), &InternetCollectionView::RestoreFocus); } else { @@ -105,22 +105,22 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, c ui_->albums_collection->filter()->SetCollectionModel(service_->albums_collection_model()); ui_->albums_collection->filter()->AddMenuAction(action_configure); - connect(ui_->albums_collection->view(), SIGNAL(GetSongs()), SLOT(GetAlbums())); - connect(ui_->albums_collection->view(), SIGNAL(RemoveSongs(SongList)), service_, SIGNAL(RemoveAlbums(SongList))); + QObject::connect(ui_->albums_collection->view(), &InternetCollectionView::GetSongs, this, &InternetTabsView::GetAlbums); + QObject::connect(ui_->albums_collection->view(), &InternetCollectionView::RemoveSongs, service_, &InternetService::RemoveAlbums); - connect(ui_->albums_collection->button_refresh(), SIGNAL(clicked()), SLOT(GetAlbums())); - connect(ui_->albums_collection->button_close(), SIGNAL(clicked()), SLOT(AbortGetAlbums())); - connect(ui_->albums_collection->button_abort(), SIGNAL(clicked()), SLOT(AbortGetAlbums())); - connect(service_, SIGNAL(AlbumsResults(SongList, QString)), SLOT(AlbumsFinished(SongList, QString))); - connect(service_, SIGNAL(AlbumsUpdateStatus(QString)), ui_->albums_collection->status(), SLOT(setText(QString))); - connect(service_, SIGNAL(AlbumsProgressSetMaximum(int)), ui_->albums_collection->progressbar(), SLOT(setMaximum(int))); - connect(service_, SIGNAL(AlbumsUpdateProgress(int)), ui_->albums_collection->progressbar(), SLOT(setValue(int))); + QObject::connect(ui_->albums_collection->button_refresh(), &QPushButton::clicked, this, &InternetTabsView::GetAlbums); + QObject::connect(ui_->albums_collection->button_close(), &QPushButton::clicked, this, &InternetTabsView::AbortGetAlbums); + QObject::connect(ui_->albums_collection->button_abort(), &QPushButton::clicked, this, &InternetTabsView::AbortGetAlbums); + QObject::connect(service_, &InternetService::AlbumsResults, this, &InternetTabsView::AlbumsFinished); + QObject::connect(service_, &InternetService::AlbumsUpdateStatus, ui_->albums_collection->status(), &QLabel::setText); + QObject::connect(service_, &InternetService::AlbumsProgressSetMaximum, ui_->albums_collection->progressbar(), &QProgressBar::setMaximum); + QObject::connect(service_, &InternetService::AlbumsUpdateProgress, ui_->albums_collection->progressbar(), &QProgressBar::setValue); - connect(service_->albums_collection_model(), SIGNAL(TotalArtistCountUpdated(int)), ui_->albums_collection->view(), SLOT(TotalArtistCountUpdated(int))); - connect(service_->albums_collection_model(), SIGNAL(TotalAlbumCountUpdated(int)), ui_->albums_collection->view(), SLOT(TotalAlbumCountUpdated(int))); - connect(service_->albums_collection_model(), SIGNAL(TotalSongCountUpdated(int)), ui_->albums_collection->view(), SLOT(TotalSongCountUpdated(int))); - connect(service_->albums_collection_model(), SIGNAL(modelAboutToBeReset()), ui_->albums_collection->view(), SLOT(SaveFocus())); - connect(service_->albums_collection_model(), SIGNAL(modelReset()), ui_->albums_collection->view(), SLOT(RestoreFocus())); + QObject::connect(service_->albums_collection_model(), &CollectionModel::TotalArtistCountUpdated, ui_->albums_collection->view(), &InternetCollectionView::TotalArtistCountUpdated); + QObject::connect(service_->albums_collection_model(), &CollectionModel::TotalAlbumCountUpdated, ui_->albums_collection->view(), &InternetCollectionView::TotalAlbumCountUpdated); + QObject::connect(service_->albums_collection_model(), &CollectionModel::TotalSongCountUpdated, ui_->albums_collection->view(), &InternetCollectionView::TotalSongCountUpdated); + QObject::connect(service_->albums_collection_model(), &CollectionModel::modelAboutToBeReset, ui_->albums_collection->view(), &InternetCollectionView::SaveFocus); + QObject::connect(service_->albums_collection_model(), &CollectionModel::modelReset, ui_->albums_collection->view(), &InternetCollectionView::RestoreFocus); } else { @@ -137,22 +137,22 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, c ui_->songs_collection->filter()->SetCollectionModel(service_->songs_collection_model()); ui_->songs_collection->filter()->AddMenuAction(action_configure); - connect(ui_->songs_collection->view(), SIGNAL(GetSongs()), SLOT(GetSongs())); - connect(ui_->songs_collection->view(), SIGNAL(RemoveSongs(SongList)), service_, SIGNAL(RemoveSongs(SongList))); + QObject::connect(ui_->songs_collection->view(), &InternetCollectionView::GetSongs, this, &InternetTabsView::GetSongs); + QObject::connect(ui_->songs_collection->view(), &InternetCollectionView::RemoveSongs, service_, &InternetService::RemoveSongs); - connect(ui_->songs_collection->button_refresh(), SIGNAL(clicked()), SLOT(GetSongs())); - connect(ui_->songs_collection->button_close(), SIGNAL(clicked()), SLOT(AbortGetSongs())); - connect(ui_->songs_collection->button_abort(), SIGNAL(clicked()), SLOT(AbortGetSongs())); - connect(service_, SIGNAL(SongsResults(SongList, QString)), SLOT(SongsFinished(SongList, QString))); - connect(service_, SIGNAL(SongsUpdateStatus(QString)), ui_->songs_collection->status(), SLOT(setText(QString))); - connect(service_, SIGNAL(SongsProgressSetMaximum(int)), ui_->songs_collection->progressbar(), SLOT(setMaximum(int))); - connect(service_, SIGNAL(SongsUpdateProgress(int)), ui_->songs_collection->progressbar(), SLOT(setValue(int))); + QObject::connect(ui_->songs_collection->button_refresh(), &QPushButton::clicked, this, &InternetTabsView::GetSongs); + QObject::connect(ui_->songs_collection->button_close(), &QPushButton::clicked, this, &InternetTabsView::AbortGetSongs); + QObject::connect(ui_->songs_collection->button_abort(), &QPushButton::clicked, this, &InternetTabsView::AbortGetSongs); + QObject::connect(service_, &InternetService::SongsResults, this, &InternetTabsView::SongsFinished); + QObject::connect(service_, &InternetService::SongsUpdateStatus, ui_->songs_collection->status(), &QLabel::setText); + QObject::connect(service_, &InternetService::SongsProgressSetMaximum, ui_->songs_collection->progressbar(), &QProgressBar::setMaximum); + QObject::connect(service_, &InternetService::SongsUpdateProgress, ui_->songs_collection->progressbar(), &QProgressBar::setValue); - connect(service_->songs_collection_model(), SIGNAL(TotalArtistCountUpdated(int)), ui_->songs_collection->view(), SLOT(TotalArtistCountUpdated(int))); - connect(service_->songs_collection_model(), SIGNAL(TotalAlbumCountUpdated(int)), ui_->songs_collection->view(), SLOT(TotalAlbumCountUpdated(int))); - connect(service_->songs_collection_model(), SIGNAL(TotalSongCountUpdated(int)), ui_->songs_collection->view(), SLOT(TotalSongCountUpdated(int))); - connect(service_->songs_collection_model(), SIGNAL(modelAboutToBeReset()), ui_->songs_collection->view(), SLOT(SaveFocus())); - connect(service_->songs_collection_model(), SIGNAL(modelReset()), ui_->songs_collection->view(), SLOT(RestoreFocus())); + QObject::connect(service_->songs_collection_model(), &CollectionModel::TotalArtistCountUpdated, ui_->songs_collection->view(), &InternetCollectionView::TotalArtistCountUpdated); + QObject::connect(service_->songs_collection_model(), &CollectionModel::TotalAlbumCountUpdated, ui_->songs_collection->view(), &InternetCollectionView::TotalAlbumCountUpdated); + QObject::connect(service_->songs_collection_model(), &CollectionModel::TotalSongCountUpdated, ui_->songs_collection->view(), &InternetCollectionView::TotalSongCountUpdated); + QObject::connect(service_->songs_collection_model(), &CollectionModel::modelAboutToBeReset, ui_->songs_collection->view(), &InternetCollectionView::SaveFocus); + QObject::connect(service_->songs_collection_model(), &CollectionModel::modelReset, ui_->songs_collection->view(), &InternetCollectionView::RestoreFocus); } else { diff --git a/src/internet/localredirectserver.cpp b/src/internet/localredirectserver.cpp index 87caa02a..f9553eba 100644 --- a/src/internet/localredirectserver.cpp +++ b/src/internet/localredirectserver.cpp @@ -252,7 +252,7 @@ bool LocalRedirectServer::Listen() { url_.setHost("localhost"); url_.setPort(serverPort()); url_.setPath("/"); - connect(this, SIGNAL(newConnection()), this, SLOT(NewConnection())); + QObject::connect(this, &QTcpServer::newConnection, this, &LocalRedirectServer::NewConnection); return true; @@ -290,8 +290,8 @@ void LocalRedirectServer::incomingConnection(qintptr socket_descriptor) { ssl_socket->setProtocol(QSsl::TlsV1_2); ssl_socket->startServerEncryption(); - connect(ssl_socket, SIGNAL(sslErrors(QList)), this, SLOT(SSLErrors(QList))); - connect(ssl_socket, SIGNAL(encrypted()), this, SLOT(Encrypted())); + QObject::connect(ssl_socket, QOverload&>::of(&QSslSocket::sslErrors), this, &LocalRedirectServer::SSLErrors); + QObject::connect(ssl_socket, &QSslSocket::encrypted, this, &LocalRedirectServer::Encrypted); socket_ = ssl_socket; } @@ -307,9 +307,9 @@ void LocalRedirectServer::incomingConnection(qintptr socket_descriptor) { socket_ = tcp_socket; } - connect(socket_, SIGNAL(connected()), this, SLOT(Connected())); - connect(socket_, SIGNAL(disconnected()), this, SLOT(Disconnected())); - connect(socket_, SIGNAL(readyRead()), this, SLOT(ReadyRead())); + QObject::connect(socket_, &QAbstractSocket::connected, this, &LocalRedirectServer::Connected); + QObject::connect(socket_, &QAbstractSocket::disconnected, this, &LocalRedirectServer::Disconnected); + QObject::connect(socket_, &QAbstractSocket::readyRead, this, &LocalRedirectServer::ReadyRead); } @@ -334,7 +334,7 @@ void LocalRedirectServer::ReadyRead() { emit Finished(); } else { - connect(socket_, SIGNAL(readyRead()), this, SLOT(ReadyRead())); + QObject::connect(socket_, &QAbstractSocket::readyRead, this, &LocalRedirectServer::ReadyRead); } } diff --git a/src/internet/localredirectserver.h b/src/internet/localredirectserver.h index 848ad568..e5262b48 100644 --- a/src/internet/localredirectserver.h +++ b/src/internet/localredirectserver.h @@ -79,4 +79,4 @@ class LocalRedirectServer : public QTcpServer { }; -#endif +#endif // LOCALREDIRECTSERVER_H diff --git a/src/lyrics/auddlyricsprovider.cpp b/src/lyrics/auddlyricsprovider.cpp index 96df03f2..d991ab87 100644 --- a/src/lyrics/auddlyricsprovider.cpp +++ b/src/lyrics/auddlyricsprovider.cpp @@ -53,7 +53,7 @@ AuddLyricsProvider::~AuddLyricsProvider() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } @@ -82,7 +82,7 @@ bool AuddLyricsProvider::StartSearch(const QString &artist, const QString &album #endif QNetworkReply *reply = network_->get(req); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { HandleSearchReply(reply, id, artist, title); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, id, artist, title]() { HandleSearchReply(reply, id, artist, title); }); //qLog(Debug) << "AudDLyrics: Sending request for" << url; @@ -96,7 +96,7 @@ void AuddLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 i if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QJsonArray json_result = ExtractResult(reply, artist, title); diff --git a/src/lyrics/auddlyricsprovider.h b/src/lyrics/auddlyricsprovider.h index e313514f..a6aff4df 100644 --- a/src/lyrics/auddlyricsprovider.h +++ b/src/lyrics/auddlyricsprovider.h @@ -62,4 +62,3 @@ class AuddLyricsProvider : public JsonLyricsProvider { }; #endif // AUDDLYRICSPROVIDER_H - diff --git a/src/lyrics/chartlyricsprovider.cpp b/src/lyrics/chartlyricsprovider.cpp index 84b933ef..ea12b3fb 100644 --- a/src/lyrics/chartlyricsprovider.cpp +++ b/src/lyrics/chartlyricsprovider.cpp @@ -47,7 +47,7 @@ ChartLyricsProvider::~ChartLyricsProvider() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } @@ -74,7 +74,7 @@ bool ChartLyricsProvider::StartSearch(const QString &artist, const QString&, con #endif QNetworkReply *reply = network_->get(req); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { HandleSearchReply(reply, id, artist, title); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, id, artist, title]() { HandleSearchReply(reply, id, artist, title); }); //qLog(Debug) << "ChartLyrics: Sending request for" << url; @@ -88,7 +88,7 @@ void ChartLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); if (reply->error() != QNetworkReply::NoError) { diff --git a/src/lyrics/geniuslyricsprovider.cpp b/src/lyrics/geniuslyricsprovider.cpp index 18b9ae4d..fa29aca6 100644 --- a/src/lyrics/geniuslyricsprovider.cpp +++ b/src/lyrics/geniuslyricsprovider.cpp @@ -77,7 +77,7 @@ GeniusLyricsProvider::~GeniusLyricsProvider() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } @@ -98,7 +98,7 @@ void GeniusLyricsProvider::Authenticate() { server_ = nullptr; return; } - connect(server_, SIGNAL(Finished()), this, SLOT(RedirectArrived())); + QObject::connect(server_, &LocalRedirectServer::Finished, this, &GeniusLyricsProvider::RedirectArrived); } code_verifier_ = Utilities::CryptographicRandomString(44); @@ -198,8 +198,8 @@ void GeniusLyricsProvider::RequestAccessToken(const QUrl &url, const QUrl &redir QNetworkReply *reply = network_->post(req, query); replies_ << reply; - connect(reply, SIGNAL(sslErrors(QList)), this, SLOT(HandleLoginSSLErrors(QList))); - connect(reply, &QNetworkReply::finished, [=] { AccessTokenRequestFinished(reply); }); + QObject::connect(reply, &QNetworkReply::sslErrors, this, &GeniusLyricsProvider::HandleLoginSSLErrors); + QObject::connect(reply, &QNetworkReply::finished, [this, reply]() { AccessTokenRequestFinished(reply); }); } @@ -222,7 +222,7 @@ void GeniusLyricsProvider::AccessTokenRequestFinished(QNetworkReply *reply) { if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); if (reply->error() != QNetworkReply::NoError || reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) { @@ -333,7 +333,7 @@ bool GeniusLyricsProvider::StartSearch(const QString &artist, const QString &alb req.setRawHeader("Authorization", "Bearer " + access_token_.toUtf8()); QNetworkReply *reply = network_->get(req); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { HandleSearchReply(reply, id); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, id]() { HandleSearchReply(reply, id); }); //qLog(Debug) << "GeniusLyrics: Sending request for" << url; @@ -347,7 +347,7 @@ void GeniusLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); if (!requests_search_.contains(id)) return; @@ -454,7 +454,7 @@ void GeniusLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 #endif QNetworkReply *new_reply = network_->get(req); replies_ << new_reply; - connect(new_reply, &QNetworkReply::finished, [=] { HandleLyricReply(new_reply, search->id, url); }); + QObject::connect(new_reply, &QNetworkReply::finished, [this, new_reply, search, url]() { HandleLyricReply(new_reply, search->id, url); }); } @@ -466,7 +466,7 @@ void GeniusLyricsProvider::HandleLyricReply(QNetworkReply *reply, const int sear if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); if (!requests_search_.contains(search_id)) return; diff --git a/src/lyrics/lololyricsprovider.cpp b/src/lyrics/lololyricsprovider.cpp index 7ba8890d..3f64e2f5 100644 --- a/src/lyrics/lololyricsprovider.cpp +++ b/src/lyrics/lololyricsprovider.cpp @@ -48,7 +48,7 @@ LoloLyricsProvider::~LoloLyricsProvider() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } @@ -77,7 +77,7 @@ bool LoloLyricsProvider::StartSearch(const QString &artist, const QString &album #endif QNetworkReply *reply = network_->get(req); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { HandleSearchReply(reply, id, artist, title); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, id, artist, title]() { HandleSearchReply(reply, id, artist, title); }); //qLog(Debug) << "LoloLyrics: Sending request for" << url; @@ -91,7 +91,7 @@ void LoloLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 i if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QString failure_reason; diff --git a/src/lyrics/lyricsfetcher.cpp b/src/lyrics/lyricsfetcher.cpp index 5bcda568..ec716e8c 100644 --- a/src/lyrics/lyricsfetcher.cpp +++ b/src/lyrics/lyricsfetcher.cpp @@ -34,11 +34,10 @@ LyricsFetcher::LyricsFetcher(LyricsProviders *lyrics_providers, QObject *parent) : QObject(parent), lyrics_providers_(lyrics_providers), next_id_(0), - request_starter_(new QTimer(this)) - { + request_starter_(new QTimer(this)) { request_starter_->setInterval(500); - connect(request_starter_, SIGNAL(timeout()), SLOT(StartRequests())); + QObject::connect(request_starter_, &QTimer::timeout, this, &LyricsFetcher::StartRequests); } @@ -93,8 +92,8 @@ void LyricsFetcher::StartRequests() { LyricsFetcherSearch *search = new LyricsFetcherSearch(request, this); active_requests_.insert(request.id, search); - connect(search, SIGNAL(SearchFinished(quint64, LyricsSearchResults)), SLOT(SingleSearchFinished(quint64, LyricsSearchResults))); - connect(search, SIGNAL(LyricsFetched(quint64, QString, QString)), SLOT(SingleLyricsFetched(quint64, QString, QString))); + QObject::connect(search, &LyricsFetcherSearch::SearchFinished, this, &LyricsFetcher::SingleSearchFinished); + QObject::connect(search, &LyricsFetcherSearch::LyricsFetched, this, &LyricsFetcher::SingleLyricsFetched); search->Start(lyrics_providers_); } diff --git a/src/lyrics/lyricsfetcher.h b/src/lyrics/lyricsfetcher.h index eec39a0b..40eccf62 100644 --- a/src/lyrics/lyricsfetcher.h +++ b/src/lyrics/lyricsfetcher.h @@ -72,8 +72,8 @@ class LyricsFetcher : public QObject { void AddRequest(const LyricsSearchRequest &req); signals: - void LyricsFetched(const quint64 request_id, const QString &provider, const QString &lyrics); - void SearchFinished(const quint64 request_id, const LyricsSearchResults &results); + void LyricsFetched(quint64 request_id, QString provider, QString lyrics); + void SearchFinished(quint64 request_id, LyricsSearchResults results); private slots: void SingleSearchFinished(const quint64 request_id, const LyricsSearchResults &results); diff --git a/src/lyrics/lyricsfetchersearch.cpp b/src/lyrics/lyricsfetchersearch.cpp index f45e6a1c..9d2d83d1 100644 --- a/src/lyrics/lyricsfetchersearch.cpp +++ b/src/lyrics/lyricsfetchersearch.cpp @@ -41,7 +41,7 @@ LyricsFetcherSearch::LyricsFetcherSearch(const LyricsSearchRequest &request, QOb request_(request), cancel_requested_(false) { - QTimer::singleShot(kSearchTimeoutMs, this, SLOT(TerminateSearch())); + QTimer::singleShot(kSearchTimeoutMs, this, &LyricsFetcherSearch::TerminateSearch); } @@ -67,7 +67,7 @@ void LyricsFetcherSearch::Start(LyricsProviders *lyrics_providers) { for (LyricsProvider *provider : lyrics_providers_sorted) { if (!provider->is_enabled() || !provider->IsAuthenticated()) continue; - connect(provider, SIGNAL(SearchFinished(quint64, LyricsSearchResults)), SLOT(ProviderSearchFinished(quint64, LyricsSearchResults))); + QObject::connect(provider, &LyricsProvider::SearchFinished, this, &LyricsFetcherSearch::ProviderSearchFinished); const int id = lyrics_providers->NextId(); const bool success = provider->StartSearch(request_.artist, request_.album, request_.title, id); if (success) pending_requests_[id] = provider; @@ -151,4 +151,3 @@ bool LyricsFetcherSearch::ProviderCompareOrder(LyricsProvider *a, LyricsProvider bool LyricsFetcherSearch::LyricsSearchResultCompareScore(const LyricsSearchResult &a, const LyricsSearchResult &b) { return a.score < b.score; } - diff --git a/src/lyrics/lyricsfetchersearch.h b/src/lyrics/lyricsfetchersearch.h index 6d336d51..e0e367c7 100644 --- a/src/lyrics/lyricsfetchersearch.h +++ b/src/lyrics/lyricsfetchersearch.h @@ -42,8 +42,8 @@ class LyricsFetcherSearch : public QObject { void Cancel(); signals: - void SearchFinished(const quint64, const LyricsSearchResults &results); - void LyricsFetched(const quint64, const QString &provider, const QString &lyrics); + void SearchFinished(quint64, LyricsSearchResults results); + void LyricsFetched(quint64, QString provider, QString lyrics); private slots: void ProviderSearchFinished(const quint64 id, const LyricsSearchResults &results); diff --git a/src/lyrics/lyricsprovider.h b/src/lyrics/lyricsprovider.h index d42e5d52..7c749362 100644 --- a/src/lyrics/lyricsprovider.h +++ b/src/lyrics/lyricsprovider.h @@ -60,7 +60,7 @@ class LyricsProvider : public QObject { void AuthenticationComplete(bool, QStringList = QStringList()); void AuthenticationSuccess(); void AuthenticationFailure(QStringList); - void SearchFinished(const quint64 id, const LyricsSearchResults &results); + void SearchFinished(quint64 id, LyricsSearchResults results); private: QString name_; @@ -69,4 +69,4 @@ class LyricsProvider : public QObject { bool authentication_required_; }; -#endif // LYRICSPROVIDER_H +#endif // LYRICSPROVIDER_H diff --git a/src/lyrics/lyricsproviders.cpp b/src/lyrics/lyricsproviders.cpp index 2e560cc7..7f701213 100644 --- a/src/lyrics/lyricsproviders.cpp +++ b/src/lyrics/lyricsproviders.cpp @@ -95,7 +95,7 @@ void LyricsProviders::AddProvider(LyricsProvider *provider) { { QMutexLocker locker(&mutex_); lyrics_providers_.insert(provider, provider->name()); - connect(provider, SIGNAL(destroyed()), SLOT(ProviderDestroyed())); + QObject::connect(provider, &LyricsProvider::destroyed, this, &LyricsProviders::ProviderDestroyed); } provider->set_order(++NextOrderId); diff --git a/src/lyrics/musixmatchlyricsprovider.cpp b/src/lyrics/musixmatchlyricsprovider.cpp index cff38ed6..bbeb4f25 100644 --- a/src/lyrics/musixmatchlyricsprovider.cpp +++ b/src/lyrics/musixmatchlyricsprovider.cpp @@ -46,7 +46,7 @@ MusixmatchLyricsProvider::~MusixmatchLyricsProvider() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } @@ -86,7 +86,7 @@ bool MusixmatchLyricsProvider::StartSearch(const QString &artist, const QString #endif QNetworkReply *reply = network_->get(req); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { HandleSearchReply(reply, id, artist, album, title); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, id, artist, album, title]() { HandleSearchReply(reply, id, artist, album, title); }); qLog(Debug) << "MusixmatchLyrics: Sending request for" << artist_stripped << title_stripped << url; @@ -102,7 +102,7 @@ void MusixmatchLyricsProvider::HandleSearchReply(QNetworkReply *reply, const qui if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); LyricsSearchResults results; diff --git a/src/lyrics/ovhlyricsprovider.cpp b/src/lyrics/ovhlyricsprovider.cpp index 4617679d..3f451f11 100644 --- a/src/lyrics/ovhlyricsprovider.cpp +++ b/src/lyrics/ovhlyricsprovider.cpp @@ -45,7 +45,7 @@ OVHLyricsProvider::~OVHLyricsProvider() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } @@ -65,7 +65,7 @@ bool OVHLyricsProvider::StartSearch(const QString &artist, const QString &album, #endif QNetworkReply *reply = network_->get(req); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { HandleSearchReply(reply, id, artist, title); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, id, artist, title]() { HandleSearchReply(reply, id, artist, title); }); //qLog(Debug) << "OVHLyrics: Sending request for" << url; @@ -79,7 +79,7 @@ void OVHLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 id if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QJsonObject json_obj = ExtractJsonObj(reply); diff --git a/src/lyrics/ovhlyricsprovider.h b/src/lyrics/ovhlyricsprovider.h index 008093f9..f592e792 100644 --- a/src/lyrics/ovhlyricsprovider.h +++ b/src/lyrics/ovhlyricsprovider.h @@ -57,4 +57,3 @@ class OVHLyricsProvider : public JsonLyricsProvider { }; #endif // OVHLYRICSPROVIDER_H - diff --git a/src/main.cpp b/src/main.cpp index e85bbbea..f2100594 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -298,9 +298,9 @@ int main(int argc, char* argv[]) { #endif // Q_OS_MACOS #ifdef HAVE_DBUS - QObject::connect(&mpris, SIGNAL(RaiseMainWindow()), &w, SLOT(Raise())); + QObject::connect(&mpris, &mpris::Mpris::RaiseMainWindow, &w, &MainWindow::Raise); #endif - QObject::connect(&a, SIGNAL(receivedMessage(quint32, QByteArray)), &w, SLOT(CommandlineOptionsReceived(quint32, QByteArray))); + QObject::connect(&a, &SingleApplication::receivedMessage, &w, QOverload::of(&MainWindow::CommandlineOptionsReceived)); int ret = a.exec(); diff --git a/src/moodbar/moodbarbuilder.cpp b/src/moodbar/moodbarbuilder.cpp index 57ae5d96..b20faa0a 100644 --- a/src/moodbar/moodbarbuilder.cpp +++ b/src/moodbar/moodbarbuilder.cpp @@ -60,7 +60,7 @@ void MoodbarBuilder::Init(int bands, int rate_hz) { } -void MoodbarBuilder::AddFrame(const double* magnitudes, int size) { +void MoodbarBuilder::AddFrame(const double *magnitudes, int size) { if (size > barkband_table_.length()) { return; @@ -86,7 +86,7 @@ void MoodbarBuilder::AddFrame(const double* magnitudes, int size) { } -void MoodbarBuilder::Normalize(QList* vals, double Rgb::*member) { +void MoodbarBuilder::Normalize(QList *vals, double Rgb::*member) { double mini = vals->at(0).*member; double maxi = vals->at(0).*member; @@ -101,7 +101,7 @@ void MoodbarBuilder::Normalize(QList* vals, double Rgb::*member) { } double avg = 0; - for (const Rgb& rgb : *vals) { + for (const Rgb &rgb : *vals) { const double value = rgb.*member; if (value != mini && value != maxi) { avg += value / vals->count(); @@ -132,7 +132,7 @@ void MoodbarBuilder::Normalize(QList* vals, double Rgb::*member) { tb = 0; double avguu = 0; double avgbb = 0; - for (const Rgb& rgb : *vals) { + for (const Rgb &rgb : *vals) { const double value = rgb.*member; if (value != mini && value != maxi) { if (value > avgu) { @@ -156,7 +156,7 @@ void MoodbarBuilder::Normalize(QList* vals, double Rgb::*member) { } for (auto it = vals->begin(); it != vals->end(); ++it) { - double* value = &((*it).*member); + double *value = &((*it).*member); *value = std::isfinite(*value) ? qBound(0.0, (*value - mini) / delta, 1.0) : 0; } @@ -166,7 +166,7 @@ QByteArray MoodbarBuilder::Finish(int width) { QByteArray ret; ret.resize(width * 3); - char* data = ret.data(); + char *data = ret.data(); if (frames_.count() == 0) return ret; Normalize(&frames_, &Rgb::r); diff --git a/src/moodbar/moodbarbuilder.h b/src/moodbar/moodbarbuilder.h index 5bf437c0..f0f52f75 100644 --- a/src/moodbar/moodbarbuilder.h +++ b/src/moodbar/moodbarbuilder.h @@ -27,7 +27,7 @@ class MoodbarBuilder { explicit MoodbarBuilder(); void Init(int bands, int rate_hz); - void AddFrame(const double* magnitudes, int size); + void AddFrame(const double *magnitudes, int size); QByteArray Finish(int width); private: @@ -39,7 +39,7 @@ class MoodbarBuilder { }; int BandFrequency(int band) const; - static void Normalize(QList* vals, double Rgb::*member); + static void Normalize(QList *vals, double Rgb::*member); QList barkband_table_; int bands_; diff --git a/src/moodbar/moodbarcontroller.cpp b/src/moodbar/moodbarcontroller.cpp index 45e3a082..03202599 100644 --- a/src/moodbar/moodbarcontroller.cpp +++ b/src/moodbar/moodbarcontroller.cpp @@ -22,7 +22,6 @@ #include #include "core/application.h" -#include "core/closure.h" #include "core/player.h" #include "core/song.h" #include "engine/engine_fwd.h" @@ -33,13 +32,13 @@ #include "moodbarloader.h" #include "moodbarpipeline.h" -MoodbarController::MoodbarController(Application* app, QObject* parent) +MoodbarController::MoodbarController(Application *app, QObject *parent) : QObject(parent), app_(app), enabled_(false) { - connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), SLOT(CurrentSongChanged(Song))); - connect(app_->player(), SIGNAL(Stopped()), SLOT(PlaybackStopped())); + QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &MoodbarController::CurrentSongChanged); + QObject::connect(app_->player(), &Player::Stopped, this, &MoodbarController::PlaybackStopped); ReloadSettings(); @@ -59,7 +58,7 @@ void MoodbarController::CurrentSongChanged(const Song &song) { if (!enabled_) return; QByteArray data; - MoodbarPipeline* pipeline = nullptr; + MoodbarPipeline *pipeline = nullptr; const MoodbarLoader::Result result = app_->moodbar_loader()->Load(song.url(), &data, &pipeline); switch (result) { @@ -76,7 +75,7 @@ void MoodbarController::CurrentSongChanged(const Song &song) { // bar. Our slot will be called when the data is actually loaded. emit CurrentMoodbarDataChanged(QByteArray()); - NewClosure(pipeline, SIGNAL(Finished(bool)), this, SLOT(AsyncLoadComplete(MoodbarPipeline*, QUrl)), pipeline, song.url()); + QObject::connect(pipeline, &MoodbarPipeline::Finished, [this, pipeline, song]() { AsyncLoadComplete(pipeline, song.url()); }); break; } @@ -88,7 +87,7 @@ void MoodbarController::PlaybackStopped() { } } -void MoodbarController::AsyncLoadComplete(MoodbarPipeline* pipeline, const QUrl& url) { +void MoodbarController::AsyncLoadComplete(MoodbarPipeline *pipeline, const QUrl &url) { // Is this song still playing? PlaylistItemPtr current_item = app_->player()->GetCurrentItem(); diff --git a/src/moodbar/moodbarcontroller.h b/src/moodbar/moodbarcontroller.h index d0c0f7af..5494ea94 100644 --- a/src/moodbar/moodbarcontroller.h +++ b/src/moodbar/moodbarcontroller.h @@ -31,20 +31,20 @@ class MoodbarController : public QObject { Q_OBJECT public: - explicit MoodbarController(Application* app, QObject* parent = nullptr); + explicit MoodbarController(Application *app, QObject *parent = nullptr); void ReloadSettings(); signals: - void CurrentMoodbarDataChanged(const QByteArray& data); + void CurrentMoodbarDataChanged(QByteArray data); private slots: - void CurrentSongChanged(const Song& song); + void CurrentSongChanged(const Song &song); void PlaybackStopped(); - void AsyncLoadComplete(MoodbarPipeline* pipeline, const QUrl& url); + void AsyncLoadComplete(MoodbarPipeline *pipeline, const QUrl &url); private: - Application* app_; + Application *app_; bool enabled_; }; diff --git a/src/moodbar/moodbaritemdelegate.cpp b/src/moodbar/moodbaritemdelegate.cpp index 01080539..4d71df17 100644 --- a/src/moodbar/moodbaritemdelegate.cpp +++ b/src/moodbar/moodbaritemdelegate.cpp @@ -47,13 +47,13 @@ MoodbarItemDelegate::Data::Data() : state_(State_None) {} -MoodbarItemDelegate::MoodbarItemDelegate(Application* app, PlaylistView* view, QObject* parent) +MoodbarItemDelegate::MoodbarItemDelegate(Application *app, PlaylistView *view, QObject *parent) : QItemDelegate(parent), app_(app), view_(view), style_(MoodbarRenderer::Style_Normal) { - connect(app_, SIGNAL(SettingsChanged()), SLOT(ReloadSettings())); + QObject::connect(app_, &Application::SettingsChanged, this, &MoodbarItemDelegate::ReloadSettings); ReloadSettings(); } @@ -72,11 +72,11 @@ void MoodbarItemDelegate::ReloadSettings() { } -void MoodbarItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { +void MoodbarItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const { - QPixmap pixmap = const_cast(this)->PixmapForIndex(index, option.rect.size()); + QPixmap pixmap = const_cast(this)->PixmapForIndex(idx, option.rect.size()); - drawBackground(painter, option, index); + drawBackground(painter, option, idx); if (!pixmap.isNull()) { // Make a little border for the moodbar @@ -86,18 +86,18 @@ void MoodbarItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o } -QPixmap MoodbarItemDelegate::PixmapForIndex(const QModelIndex& index, const QSize& size) { +QPixmap MoodbarItemDelegate::PixmapForIndex(const QModelIndex &idx, const QSize &size) { // Pixmaps are keyed off URL. - const QUrl url(index.sibling(index.row(), Playlist::Column_Filename).data().toUrl()); + const QUrl url(idx.sibling(idx.row(), Playlist::Column_Filename).data().toUrl()); - Data* data = data_[url]; + Data *data = data_[url]; if (!data) { data = new Data; data_.insert(url, data); } - data->indexes_.insert(index); + data->indexes_.insert(idx); data->desired_size_ = size; switch (data->state_) { @@ -126,13 +126,13 @@ QPixmap MoodbarItemDelegate::PixmapForIndex(const QModelIndex& index, const QSiz } -void MoodbarItemDelegate::StartLoadingData(const QUrl& url, Data* data) { +void MoodbarItemDelegate::StartLoadingData(const QUrl &url, Data *data) { data->state_ = Data::State_LoadingData; // Load a mood file for this song and generate some colors from it QByteArray bytes; - MoodbarPipeline* pipeline = nullptr; + MoodbarPipeline *pipeline = nullptr; switch (app_->moodbar_loader()->Load(url, &bytes, &pipeline)) { case MoodbarLoader::CannotLoad: data->state_ = Data::State_CannotLoad; @@ -145,16 +145,16 @@ void MoodbarItemDelegate::StartLoadingData(const QUrl& url, Data* data) { case MoodbarLoader::WillLoadAsync: // Maybe in a little while. - NewClosure(pipeline, SIGNAL(Finished(bool)), this, SLOT(DataLoaded(QUrl, MoodbarPipeline*)), url, pipeline); + QObject::connect(pipeline, &MoodbarPipeline::Finished, [this, url, pipeline]() { DataLoaded(url, pipeline); }); break; } } -bool MoodbarItemDelegate::RemoveFromCacheIfIndexesInvalid(const QUrl& url, Data* data) { +bool MoodbarItemDelegate::RemoveFromCacheIfIndexesInvalid(const QUrl &url, Data *data) { - for (const QPersistentModelIndex& index : data->indexes_) { - if (index.isValid()) { + for (const QPersistentModelIndex &idx : data->indexes_) { + if (idx.isValid()) { return false; } } @@ -166,8 +166,8 @@ bool MoodbarItemDelegate::RemoveFromCacheIfIndexesInvalid(const QUrl& url, Data* void MoodbarItemDelegate::ReloadAllColors() { - for (const QUrl& url : data_.keys()) { - Data* data = data_[url]; + for (const QUrl &url : data_.keys()) { + Data *data = data_[url]; if (data->state_ == Data::State_Loaded) { StartLoadingData(url, data); @@ -176,9 +176,9 @@ void MoodbarItemDelegate::ReloadAllColors() { } -void MoodbarItemDelegate::DataLoaded(const QUrl& url, MoodbarPipeline* pipeline) { +void MoodbarItemDelegate::DataLoaded(const QUrl &url, MoodbarPipeline *pipeline) { - Data* data = data_[url]; + Data *data = data_[url]; if (!data) { return; } @@ -197,7 +197,7 @@ void MoodbarItemDelegate::DataLoaded(const QUrl& url, MoodbarPipeline* pipeline) } -void MoodbarItemDelegate::StartLoadingColors(const QUrl& url, const QByteArray& bytes, Data* data) { +void MoodbarItemDelegate::StartLoadingColors(const QUrl &url, const QByteArray &bytes, Data *data) { data->state_ = Data::State_LoadingColors; @@ -206,9 +206,9 @@ void MoodbarItemDelegate::StartLoadingColors(const QUrl& url, const QByteArray& } -void MoodbarItemDelegate::ColorsLoaded(const QUrl& url, QFuture future) { +void MoodbarItemDelegate::ColorsLoaded(const QUrl &url, QFuture future) { - Data* data = data_[url]; + Data *data = data_[url]; if (!data) { return; } @@ -224,7 +224,7 @@ void MoodbarItemDelegate::ColorsLoaded(const QUrl& url, QFuture fut } -void MoodbarItemDelegate::StartLoadingImage(const QUrl& url, Data* data) { +void MoodbarItemDelegate::StartLoadingImage(const QUrl &url, Data *data) { data->state_ = Data::State_LoadingImage; @@ -233,9 +233,9 @@ void MoodbarItemDelegate::StartLoadingImage(const QUrl& url, Data* data) { } -void MoodbarItemDelegate::ImageLoaded(const QUrl& url, QFuture future) { +void MoodbarItemDelegate::ImageLoaded(const QUrl &url, QFuture future) { - Data* data = data_[url]; + Data *data = data_[url]; if (!data) { return; } @@ -256,14 +256,14 @@ void MoodbarItemDelegate::ImageLoaded(const QUrl& url, QFuture future) { data->pixmap_ = QPixmap::fromImage(image); data->state_ = Data::State_Loaded; - Playlist* playlist = view_->playlist(); - const QSortFilterProxyModel* filter = playlist->proxy(); + Playlist *playlist = view_->playlist(); + const QSortFilterProxyModel *filter = playlist->proxy(); // Update all the indices with the new pixmap. - for (const QPersistentModelIndex& index : data->indexes_) { - if (index.isValid() && index.sibling(index.row(), Playlist::Column_Filename).data().toUrl() == url) { - QModelIndex source_index = index; - if (index.model() == filter) { + for (const QPersistentModelIndex &idx : data->indexes_) { + if (idx.isValid() && idx.sibling(idx.row(), Playlist::Column_Filename).data().toUrl() == url) { + QModelIndex source_index = idx; + if (idx.model() == filter) { source_index = filter->mapToSource(source_index); } diff --git a/src/moodbar/moodbaritemdelegate.h b/src/moodbar/moodbaritemdelegate.h index e15bd77f..7125129b 100644 --- a/src/moodbar/moodbaritemdelegate.h +++ b/src/moodbar/moodbaritemdelegate.h @@ -44,16 +44,16 @@ class MoodbarItemDelegate : public QItemDelegate { Q_OBJECT public: - explicit MoodbarItemDelegate(Application* app, PlaylistView* view, QObject* parent = nullptr); + explicit MoodbarItemDelegate(Application *app, PlaylistView *view, QObject *parent = nullptr); - void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override; private slots: void ReloadSettings(); - void DataLoaded(const QUrl& url, MoodbarPipeline* pipeline); - void ColorsLoaded(const QUrl& url, QFuture future); - void ImageLoaded(const QUrl& url, QFuture future); + void DataLoaded(const QUrl &url, MoodbarPipeline *pipeline); + void ColorsLoaded(const QUrl &url, QFuture future); + void ImageLoaded(const QUrl &url, QFuture future); private: struct Data { @@ -77,18 +77,18 @@ class MoodbarItemDelegate : public QItemDelegate { }; private: - QPixmap PixmapForIndex(const QModelIndex& index, const QSize& size); - void StartLoadingData(const QUrl& url, Data* data); - void StartLoadingColors(const QUrl& url, const QByteArray& bytes, Data* data); - void StartLoadingImage(const QUrl& url, Data* data); + QPixmap PixmapForIndex(const QModelIndex &idx, const QSize &size); + void StartLoadingData(const QUrl &url, Data *data); + void StartLoadingColors(const QUrl &url, const QByteArray &bytes, Data *data); + void StartLoadingImage(const QUrl &url, Data *data); - bool RemoveFromCacheIfIndexesInvalid(const QUrl& url, Data* data); + bool RemoveFromCacheIfIndexesInvalid(const QUrl &url, Data *data); void ReloadAllColors(); private: - Application* app_; - PlaylistView* view_; + Application *app_; + PlaylistView *view_; QCache data_; MoodbarRenderer::MoodbarStyle style_; diff --git a/src/moodbar/moodbarloader.cpp b/src/moodbar/moodbarloader.cpp index 20dc81bb..f07bf94f 100644 --- a/src/moodbar/moodbarloader.cpp +++ b/src/moodbar/moodbarloader.cpp @@ -39,7 +39,6 @@ #include #include "core/application.h" -#include "core/closure.h" #include "core/logging.h" #include "moodbarpipeline.h" @@ -50,18 +49,17 @@ # include #endif -MoodbarLoader::MoodbarLoader(Application* app, QObject* parent) +MoodbarLoader::MoodbarLoader(Application *app, QObject *parent) : QObject(parent), cache_(new QNetworkDiskCache(this)), thread_(new QThread(this)), kMaxActiveRequests(qMax(1, QThread::idealThreadCount() / 2)), - enabled_(false), save_(false) { cache_->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/moodbar"); cache_->setMaximumCacheSize(60 * 1024 * 1024); // 60MB - enough for 20,000 moodbars - connect(app, SIGNAL(SettingsChanged()), SLOT(ReloadSettings())); + QObject::connect(app, &Application::SettingsChanged, this, &MoodbarLoader::ReloadSettings); ReloadSettings(); } @@ -82,7 +80,7 @@ void MoodbarLoader::ReloadSettings() { } -QStringList MoodbarLoader::MoodFilenames(const QString& song_filename) { +QStringList MoodbarLoader::MoodFilenames(const QString &song_filename) { const QFileInfo file_info(song_filename); const QString dir_path(file_info.dir().path()); @@ -92,7 +90,7 @@ QStringList MoodbarLoader::MoodFilenames(const QString& song_filename) { } -MoodbarLoader::Result MoodbarLoader::Load(const QUrl& url, QByteArray* data, MoodbarPipeline** async_pipeline) { +MoodbarLoader::Result MoodbarLoader::Load(const QUrl &url, QByteArray *data, MoodbarPipeline **async_pipeline) { if (url.scheme() != "file") { return CannotLoad; @@ -107,7 +105,7 @@ MoodbarLoader::Result MoodbarLoader::Load(const QUrl& url, QByteArray* data, Moo // Check if a mood file exists for this file already const QString filename(url.toLocalFile()); - for (const QString& possible_mood_file : MoodFilenames(filename)) { + for (const QString &possible_mood_file : MoodFilenames(filename)) { QFile f(possible_mood_file); if (f.open(QIODevice::ReadOnly)) { qLog(Info) << "Loading moodbar data from" << possible_mood_file; @@ -129,9 +127,9 @@ MoodbarLoader::Result MoodbarLoader::Load(const QUrl& url, QByteArray* data, Moo if (!thread_->isRunning()) thread_->start(QThread::IdlePriority); // There was no existing file, analyze the audio file and create one. - MoodbarPipeline* pipeline = new MoodbarPipeline(url); + MoodbarPipeline *pipeline = new MoodbarPipeline(url); pipeline->moveToThread(thread_); - NewClosure(pipeline, SIGNAL(Finished(bool)), this, SLOT(RequestFinished(MoodbarPipeline*, QUrl)), pipeline, url); + QObject::connect(pipeline, &MoodbarPipeline::Finished, [this, pipeline, url]() { RequestFinished(pipeline, url); }); requests_[url] = pipeline; queued_requests_ << url; @@ -170,7 +168,7 @@ void MoodbarLoader::RequestFinished(MoodbarPipeline *request, const QUrl &url) { QNetworkCacheMetaData metadata; metadata.setUrl(url); - QIODevice* cache_file = cache_->prepare(metadata); + QIODevice *cache_file = cache_->prepare(metadata); if (cache_file) { cache_file->write(request->data()); cache_->insert(cache_file); @@ -200,7 +198,7 @@ void MoodbarLoader::RequestFinished(MoodbarPipeline *request, const QUrl &url) { requests_.remove(url); active_requests_.remove(url); - QTimer::singleShot(1000, request, SLOT(deleteLater())); + QTimer::singleShot(1000, request, &MoodbarLoader::deleteLater); MaybeTakeNextRequest(); diff --git a/src/moodbar/moodbarloader.h b/src/moodbar/moodbarloader.h index f4638311..e8fd7a61 100644 --- a/src/moodbar/moodbarloader.h +++ b/src/moodbar/moodbarloader.h @@ -36,7 +36,7 @@ class MoodbarLoader : public QObject { Q_OBJECT public: - explicit MoodbarLoader(Application* app, QObject* parent = nullptr); + explicit MoodbarLoader(Application *app, QObject *parent = nullptr); ~MoodbarLoader() override; enum Result { @@ -52,7 +52,7 @@ class MoodbarLoader : public QObject { WillLoadAsync }; - Result Load(const QUrl& url, QByteArray* data, MoodbarPipeline** async_pipeline); + Result Load(const QUrl &url, QByteArray *data, MoodbarPipeline **async_pipeline); private slots: void ReloadSettings(); @@ -61,11 +61,11 @@ class MoodbarLoader : public QObject { void MaybeTakeNextRequest(); private: - static QStringList MoodFilenames(const QString& song_filename); + static QStringList MoodFilenames(const QString &song_filename); private: - QNetworkDiskCache* cache_; - QThread* thread_; + QNetworkDiskCache *cache_; + QThread *thread_; const int kMaxActiveRequests; @@ -73,7 +73,6 @@ class MoodbarLoader : public QObject { QList queued_requests_; QSet active_requests_; - bool enabled_; bool save_; }; diff --git a/src/moodbar/moodbarpipeline.cpp b/src/moodbar/moodbarpipeline.cpp index 7e0ed5f7..f2945103 100644 --- a/src/moodbar/moodbarpipeline.cpp +++ b/src/moodbar/moodbarpipeline.cpp @@ -37,7 +37,7 @@ bool MoodbarPipeline::sIsAvailable = false; const int MoodbarPipeline::kBands = 128; -MoodbarPipeline::MoodbarPipeline(const QUrl& local_filename) +MoodbarPipeline::MoodbarPipeline(const QUrl &local_filename) : QObject(nullptr), local_filename_(local_filename), pipeline_(nullptr), @@ -50,7 +50,7 @@ MoodbarPipeline::~MoodbarPipeline() { Cleanup(); } bool MoodbarPipeline::IsAvailable() { if (!sIsAvailable) { - GstElementFactory* factory = gst_element_factory_find("fftwspectrum"); + GstElementFactory *factory = gst_element_factory_find("fftwspectrum"); if (!factory) { return false; } @@ -63,9 +63,9 @@ bool MoodbarPipeline::IsAvailable() { } -GstElement* MoodbarPipeline::CreateElement(const QString& factory_name) { +GstElement *MoodbarPipeline::CreateElement(const QString &factory_name) { - GstElement* ret = gst_element_factory_make(factory_name.toLatin1().constData(), nullptr); + GstElement *ret = gst_element_factory_make(factory_name.toLatin1().constData(), nullptr); if (ret) { gst_bin_add(GST_BIN(pipeline_), ret); @@ -90,10 +90,10 @@ void MoodbarPipeline::Start() { pipeline_ = gst_pipeline_new("moodbar-pipeline"); - GstElement* decodebin = CreateElement("uridecodebin"); + GstElement *decodebin = CreateElement("uridecodebin"); convert_element_ = CreateElement("audioconvert"); - GstElement* spectrum = CreateElement("fastspectrum"); - GstElement* fakesink = CreateElement("fakesink"); + GstElement *spectrum = CreateElement("fastspectrum"); + GstElement *fakesink = CreateElement("fakesink"); if (!decodebin || !convert_element_ || !spectrum || !fakesink) { gst_object_unref(GST_OBJECT(pipeline_)); @@ -117,12 +117,12 @@ void MoodbarPipeline::Start() { g_object_set(decodebin, "uri", local_filename_.toEncoded().constData(), nullptr); g_object_set(spectrum, "bands", kBands, nullptr); - GstFastSpectrum* fast_spectrum = reinterpret_cast(spectrum); - fast_spectrum->output_callback = [this](double* magnitudes, int size) { builder_->AddFrame(magnitudes, size); }; + GstFastSpectrum *fast_spectrum = reinterpret_cast(spectrum); + fast_spectrum->output_callback = [this](double *magnitudes, int size) { builder_->AddFrame(magnitudes, size); }; // Connect signals CHECKED_GCONNECT(decodebin, "pad-added", &NewPadCallback, this); - GstBus* bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline_)); + GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline_)); gst_bus_set_sync_handler(bus, BusCallbackSync, this, nullptr); gst_object_unref(bus); @@ -134,8 +134,8 @@ void MoodbarPipeline::Start() { void MoodbarPipeline::ReportError(GstMessage *msg) { - GError* error; - gchar* debugs; + GError *error; + gchar *debugs; gst_message_parse_error(msg, &error, &debugs); QString message = QString::fromLocal8Bit(error->message); @@ -147,16 +147,16 @@ void MoodbarPipeline::ReportError(GstMessage *msg) { } -void MoodbarPipeline::NewPadCallback(GstElement*, GstPad* pad, gpointer data) { +void MoodbarPipeline::NewPadCallback(GstElement*, GstPad *pad, gpointer data) { - MoodbarPipeline* self = reinterpret_cast(data); + MoodbarPipeline *self = reinterpret_cast(data); if (!self->running_) { qLog(Warning) << "Received gstreamer callback after pipeline has stopped."; return; } - GstPad* const audiopad = gst_element_get_static_pad(self->convert_element_, "sink"); + GstPad *const audiopad = gst_element_get_static_pad(self->convert_element_, "sink"); if (GST_PAD_IS_LINKED(audiopad)) { qLog(Warning) << "audiopad is already linked, unlinking old pad"; @@ -167,8 +167,8 @@ void MoodbarPipeline::NewPadCallback(GstElement*, GstPad* pad, gpointer data) { gst_object_unref(audiopad); int rate = 0; - GstCaps* caps = gst_pad_get_current_caps(pad); - GstStructure* structure = gst_caps_get_structure(caps, 0); + GstCaps *caps = gst_pad_get_current_caps(pad); + GstStructure *structure = gst_caps_get_structure(caps, 0); gst_structure_get_int(structure, "rate", &rate); gst_caps_unref(caps); @@ -179,9 +179,9 @@ void MoodbarPipeline::NewPadCallback(GstElement*, GstPad* pad, gpointer data) { } -GstBusSyncReply MoodbarPipeline::BusCallbackSync(GstBus*, GstMessage* msg, gpointer data) { +GstBusSyncReply MoodbarPipeline::BusCallbackSync(GstBus*, GstMessage *msg, gpointer data) { - MoodbarPipeline* self = reinterpret_cast(data); + MoodbarPipeline *self = reinterpret_cast(data); switch (GST_MESSAGE_TYPE(msg)) { case GST_MESSAGE_EOS: @@ -200,7 +200,7 @@ GstBusSyncReply MoodbarPipeline::BusCallbackSync(GstBus*, GstMessage* msg, gpoin } -void MoodbarPipeline::Stop(bool success) { +void MoodbarPipeline::Stop(const bool success) { success_ = success; running_ = false; @@ -220,7 +220,7 @@ void MoodbarPipeline::Cleanup() { running_ = false; if (pipeline_) { - GstBus* bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline_)); + GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline_)); gst_bus_set_sync_handler(bus, nullptr, nullptr, nullptr); gst_object_unref(bus); diff --git a/src/moodbar/moodbarpipeline.h b/src/moodbar/moodbarpipeline.h index 0ef8cfcc..616e42d0 100644 --- a/src/moodbar/moodbarpipeline.h +++ b/src/moodbar/moodbarpipeline.h @@ -36,13 +36,13 @@ class MoodbarPipeline : public QObject { Q_OBJECT public: - explicit MoodbarPipeline(const QUrl& local_filename); + explicit MoodbarPipeline(const QUrl &local_filename); ~MoodbarPipeline() override; static bool IsAvailable(); bool success() const { return success_; } - const QByteArray& data() const { return data_; } + const QByteArray &data() const { return data_; } public slots: void Start(); @@ -51,24 +51,24 @@ class MoodbarPipeline : public QObject { void Finished(bool success); private: - GstElement* CreateElement(const QString& factory_name); + GstElement *CreateElement(const QString &factory_name); void ReportError(GstMessage *msg); - void Stop(bool success); + void Stop(const bool success); void Cleanup(); - static void NewPadCallback(GstElement*, GstPad* pad, gpointer data); - static GstFlowReturn NewBufferCallback(GstAppSink* app_sink, gpointer self); - static gboolean BusCallback(GstBus*, GstMessage* msg, gpointer data); - static GstBusSyncReply BusCallbackSync(GstBus*, GstMessage* msg, gpointer data); + static void NewPadCallback(GstElement*, GstPad *pad, gpointer data); + static GstFlowReturn NewBufferCallback(GstAppSink *app_sink, gpointer self); + static gboolean BusCallback(GstBus*, GstMessage *msg, gpointer data); + static GstBusSyncReply BusCallbackSync(GstBus*, GstMessage *msg, gpointer data); private: static bool sIsAvailable; static const int kBands; QUrl local_filename_; - GstElement* pipeline_; - GstElement* convert_element_; + GstElement *pipeline_; + GstElement *convert_element_; std::unique_ptr builder_; diff --git a/src/moodbar/moodbarproxystyle.cpp b/src/moodbar/moodbarproxystyle.cpp index d6c26b18..bbd4df8b 100644 --- a/src/moodbar/moodbarproxystyle.cpp +++ b/src/moodbar/moodbarproxystyle.cpp @@ -67,9 +67,10 @@ MoodbarProxyStyle::MoodbarProxyStyle(Application* app, QSlider* slider) slider->setStyle(this); slider->installEventFilter(this); - connect(fade_timeline_, SIGNAL(valueChanged(qreal)), SLOT(FaderValueChanged(qreal))); + QObject::connect(fade_timeline_, &QTimeLine::valueChanged, this, &MoodbarProxyStyle::FaderValueChanged); + + QObject::connect(app, &Application::SettingsChanged, this, &MoodbarProxyStyle::ReloadSettings); - connect(app, SIGNAL(SettingsChanged()), SLOT(ReloadSettings())); ReloadSettings(); } @@ -96,7 +97,7 @@ void MoodbarProxyStyle::ReloadSettings() { } -void MoodbarProxyStyle::SetMoodbarData(const QByteArray& data) { +void MoodbarProxyStyle::SetMoodbarData(const QByteArray &data) { data_ = data; moodbar_colors_dirty_ = true; // Redraw next time @@ -104,7 +105,7 @@ void MoodbarProxyStyle::SetMoodbarData(const QByteArray& data) { } -void MoodbarProxyStyle::SetMoodbarEnabled(bool enabled) { +void MoodbarProxyStyle::SetMoodbarEnabled(const bool enabled) { enabled_ = enabled; @@ -157,12 +158,12 @@ void MoodbarProxyStyle::NextState() { } -void MoodbarProxyStyle::FaderValueChanged(qreal value) { +void MoodbarProxyStyle::FaderValueChanged(const qreal value) { Q_UNUSED(value); slider_->update(); } -bool MoodbarProxyStyle::eventFilter(QObject* object, QEvent* event) { +bool MoodbarProxyStyle::eventFilter(QObject *object, QEvent *event) { if (object == slider_) { switch (event->type()) { @@ -184,7 +185,7 @@ bool MoodbarProxyStyle::eventFilter(QObject* object, QEvent* event) { } -void MoodbarProxyStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex* option, QPainter* painter, const QWidget* widget) const { +void MoodbarProxyStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const { if (control != CC_Slider || widget != slider_) { QProxyStyle::drawComplexControl(control, option, painter, widget); @@ -195,7 +196,7 @@ void MoodbarProxyStyle::drawComplexControl(ComplexControl control, const QStyleO } -void MoodbarProxyStyle::Render(ComplexControl control, const QStyleOptionSlider* option, QPainter* painter, const QWidget* widget) { +void MoodbarProxyStyle::Render(ComplexControl control, const QStyleOptionSlider *option, QPainter *painter, const QWidget *widget) { const qreal fade_value = fade_timeline_->currentValue(); @@ -256,7 +257,7 @@ void MoodbarProxyStyle::Render(ComplexControl control, const QStyleOptionSlider* } -void MoodbarProxyStyle::EnsureMoodbarRendered(const QStyleOptionSlider* opt) { +void MoodbarProxyStyle::EnsureMoodbarRendered(const QStyleOptionSlider *opt) { if (moodbar_colors_dirty_) { moodbar_colors_ = MoodbarRenderer::Colors(data_, moodbar_style_, slider_->palette()); @@ -271,7 +272,7 @@ void MoodbarProxyStyle::EnsureMoodbarRendered(const QStyleOptionSlider* opt) { } -QRect MoodbarProxyStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex* opt, SubControl sc, const QWidget* widget) const { +QRect MoodbarProxyStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const { if (cc != QStyle::CC_Slider || widget != slider_) { return QProxyStyle::subControlRect(cc, opt, sc, widget); @@ -289,7 +290,7 @@ QRect MoodbarProxyStyle::subControlRect(ComplexControl cc, const QStyleOptionCom return opt->rect.adjusted(kMarginSize, kMarginSize, -kMarginSize, -kMarginSize); case SC_SliderHandle: { - const QStyleOptionSlider* slider_opt = qstyleoption_cast(opt); + const QStyleOptionSlider *slider_opt = qstyleoption_cast(opt); int x_offset = 0; /* slider_opt->{maximum,minimum} can have the value 0 (their default @@ -314,7 +315,7 @@ QRect MoodbarProxyStyle::subControlRect(ComplexControl cc, const QStyleOptionCom return QProxyStyle::subControlRect(cc, opt, sc, widget); } -void MoodbarProxyStyle::DrawArrow(const QStyleOptionSlider* option, QPainter* painter) const { +void MoodbarProxyStyle::DrawArrow(const QStyleOptionSlider *option, QPainter *painter) const { // Get the dimensions of the arrow const QRect rect = subControlRect(CC_Slider, option, SC_SliderHandle, slider_); @@ -334,7 +335,7 @@ void MoodbarProxyStyle::DrawArrow(const QStyleOptionSlider* option, QPainter* pa } -QPixmap MoodbarProxyStyle::MoodbarPixmap(const ColorVector& colors, const QSize& size, const QPalette& palette, const QStyleOptionSlider* opt) { +QPixmap MoodbarProxyStyle::MoodbarPixmap(const ColorVector &colors, const QSize &size, const QPalette &palette, const QStyleOptionSlider *opt) { Q_UNUSED(opt); @@ -366,33 +367,33 @@ QPixmap MoodbarProxyStyle::MoodbarPixmap(const ColorVector& colors, const QSize& } -void MoodbarProxyStyle::ShowContextMenu(const QPoint& pos) { +void MoodbarProxyStyle::ShowContextMenu(const QPoint &pos) { if (!context_menu_) { context_menu_ = new QMenu(slider_); - show_moodbar_action_ = context_menu_->addAction(tr("Show moodbar"), this, SLOT(SetMoodbarEnabled(bool))); + show_moodbar_action_ = context_menu_->addAction(tr("Show moodbar"), this, &MoodbarProxyStyle::SetMoodbarEnabled); show_moodbar_action_->setCheckable(true); show_moodbar_action_->setChecked(enabled_); - QMenu* styles_menu = context_menu_->addMenu(tr("Moodbar style")); + QMenu *styles_menu = context_menu_->addMenu(tr("Moodbar style")); style_action_group_ = new QActionGroup(styles_menu); for (int i = 0; i < MoodbarRenderer::StyleCount; ++i) { const MoodbarRenderer::MoodbarStyle style = MoodbarRenderer::MoodbarStyle(i); - QAction* action = style_action_group_->addAction(MoodbarRenderer::StyleName(style)); + QAction *action = style_action_group_->addAction(MoodbarRenderer::StyleName(style)); action->setCheckable(true); action->setData(i); } styles_menu->addActions(style_action_group_->actions()); - connect(styles_menu, SIGNAL(triggered(QAction*)), SLOT(ChangeStyle(QAction*))); + QObject::connect(styles_menu, &QMenu::triggered, this, &MoodbarProxyStyle::ChangeStyle); } // Update the currently selected style - for (QAction* action : style_action_group_->actions()) { + for (QAction *action : style_action_group_->actions()) { if (MoodbarRenderer::MoodbarStyle(action->data().toInt()) == moodbar_style_) { action->setChecked(true); break; @@ -403,7 +404,7 @@ void MoodbarProxyStyle::ShowContextMenu(const QPoint& pos) { } -void MoodbarProxyStyle::ChangeStyle(QAction* action) { +void MoodbarProxyStyle::ChangeStyle(QAction *action) { QSettings s; s.beginGroup(MoodbarSettingsPage::kSettingsGroup); diff --git a/src/moodbar/moodbarproxystyle.h b/src/moodbar/moodbarproxystyle.h index ab5c0164..928320ef 100644 --- a/src/moodbar/moodbarproxystyle.h +++ b/src/moodbar/moodbarproxystyle.h @@ -48,21 +48,21 @@ class MoodbarProxyStyle : public QProxyStyle { Q_OBJECT public: - explicit MoodbarProxyStyle(Application* app, QSlider* slider); + explicit MoodbarProxyStyle(Application *app, QSlider *slider); // QProxyStyle - void drawComplexControl(ComplexControl control, const QStyleOptionComplex* option, QPainter* painter, const QWidget* widget) const override; - QRect subControlRect(ComplexControl cc, const QStyleOptionComplex* opt, SubControl sc, const QWidget* widget) const override; + void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const override; + QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const override; // QObject - bool eventFilter(QObject* object, QEvent* event) override; + bool eventFilter(QObject *object, QEvent *event) override; public slots: // An empty byte array means there's no moodbar, so just show a normal slider. - void SetMoodbarData(const QByteArray& data); + void SetMoodbarData(const QByteArray &data); // If the moodbar is disabled then a normal slider will always be shown. - void SetMoodbarEnabled(bool enabled); + void SetMoodbarEnabled(const bool enabled); private: static const int kMarginSize; @@ -75,28 +75,28 @@ class MoodbarProxyStyle : public QProxyStyle { private: void NextState(); - void Render(ComplexControl control, const QStyleOptionSlider* option, QPainter* painter, const QWidget* widget); - void EnsureMoodbarRendered(const QStyleOptionSlider* opt); - void DrawArrow(const QStyleOptionSlider* option, QPainter* painter) const; - void ShowContextMenu(const QPoint& pos); + void Render(ComplexControl control, const QStyleOptionSlider *option, QPainter *painter, const QWidget *widget); + void EnsureMoodbarRendered(const QStyleOptionSlider *opt); + void DrawArrow(const QStyleOptionSlider *option, QPainter *painter) const; + void ShowContextMenu(const QPoint &pos); - QPixmap MoodbarPixmap(const ColorVector& colors, const QSize& size, const QPalette& palette, const QStyleOptionSlider* opt); + QPixmap MoodbarPixmap(const ColorVector &colors, const QSize &size, const QPalette &palette, const QStyleOptionSlider *opt); private slots: void ReloadSettings(); void FaderValueChanged(qreal value); - void ChangeStyle(QAction* action); + void ChangeStyle(QAction *action); private: - Application* app_; - QSlider* slider_; + Application *app_; + QSlider *slider_; bool enabled_; QByteArray data_; MoodbarRenderer::MoodbarStyle moodbar_style_; State state_; - QTimeLine* fade_timeline_; + QTimeLine *fade_timeline_; QPixmap fade_source_; QPixmap fade_target_; @@ -106,9 +106,9 @@ class MoodbarProxyStyle : public QProxyStyle { ColorVector moodbar_colors_; QPixmap moodbar_pixmap_; - QMenu* context_menu_; - QAction* show_moodbar_action_; - QActionGroup* style_action_group_; + QMenu *context_menu_; + QAction *show_moodbar_action_; + QActionGroup *style_action_group_; }; #endif // MOODBARPROXYSTYLE_H diff --git a/src/moodbar/moodbarrenderer.cpp b/src/moodbar/moodbarrenderer.cpp index bab241ff..dde31b29 100644 --- a/src/moodbar/moodbarrenderer.cpp +++ b/src/moodbar/moodbarrenderer.cpp @@ -34,7 +34,7 @@ const int MoodbarRenderer::kNumHues = 12; -ColorVector MoodbarRenderer::Colors(const QByteArray& data, MoodbarStyle style, const QPalette& palette) { +ColorVector MoodbarRenderer::Colors(const QByteArray &data, const MoodbarStyle style, const QPalette &palette) { const int samples = data.size() / 3; @@ -65,7 +65,7 @@ ColorVector MoodbarRenderer::Colors(const QByteArray& data, MoodbarStyle style, } } - const unsigned char* data_p = reinterpret_cast(data.constData()); + const unsigned char *data_p = reinterpret_cast(data.constData()); int hue_distribution[360]; int total = 0; @@ -110,7 +110,7 @@ ColorVector MoodbarRenderer::Colors(const QByteArray& data, MoodbarStyle style, return colors; } -void MoodbarRenderer::Render(const ColorVector& colors, QPainter* p, const QRect& rect) { +void MoodbarRenderer::Render(const ColorVector &colors, QPainter *p, const QRect &rect) { // Sample the colors and map them to screen pixels. ColorVector screen_colors; @@ -153,7 +153,7 @@ void MoodbarRenderer::Render(const ColorVector& colors, QPainter* p, const QRect } } -QImage MoodbarRenderer::RenderToImage(const ColorVector& colors, const QSize& size) { +QImage MoodbarRenderer::RenderToImage(const ColorVector &colors, const QSize &size) { QImage image(size, QImage::Format_ARGB32_Premultiplied); QPainter p(&image); @@ -163,7 +163,7 @@ QImage MoodbarRenderer::RenderToImage(const ColorVector& colors, const QSize& si } -QString MoodbarRenderer::StyleName(MoodbarStyle style) { +QString MoodbarRenderer::StyleName(const MoodbarStyle style) { switch (style) { case Style_Normal: diff --git a/src/moodbar/moodbarrenderer.h b/src/moodbar/moodbarrenderer.h index 4a782fbe..4b9c4516 100644 --- a/src/moodbar/moodbarrenderer.h +++ b/src/moodbar/moodbarrenderer.h @@ -47,17 +47,17 @@ class MoodbarRenderer { static const int kNumHues; - static QString StyleName(MoodbarStyle style); + static QString StyleName(const MoodbarStyle style); - static ColorVector Colors(const QByteArray& data, MoodbarStyle style, const QPalette& palette); - static void Render(const ColorVector& colors, QPainter* p, const QRect& rect); - static QImage RenderToImage(const ColorVector& colors, const QSize& size); + static ColorVector Colors(const QByteArray &data, const MoodbarStyle style, const QPalette &palette); + static void Render(const ColorVector &colors, QPainter *p, const QRect &rect); + static QImage RenderToImage(const ColorVector &colors, const QSize &size); private: explicit MoodbarRenderer(); struct StyleProperties { - explicit StyleProperties(int threshold = 0, int range_start = 0, int range_delta = 0, int sat = 0, int val = 0) + explicit StyleProperties(const int threshold = 0, const int range_start = 0, const int range_delta = 0, const int sat = 0, const int val = 0) : threshold_(threshold), range_start_(range_start), range_delta_(range_delta), diff --git a/src/musicbrainz/acoustidclient.cpp b/src/musicbrainz/acoustidclient.cpp index b16ed45d..ae39b919 100644 --- a/src/musicbrainz/acoustidclient.cpp +++ b/src/musicbrainz/acoustidclient.cpp @@ -88,7 +88,7 @@ void AcoustidClient::Start(const int id, const QString &fingerprint, int duratio req.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); #endif QNetworkReply *reply = network_->get(req); - connect(reply, &QNetworkReply::finished, [=] { RequestFinished(reply, id); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, id]() { RequestFinished(reply, id); }); requests_[id] = reply; timeouts_->AddReply(reply); @@ -126,7 +126,7 @@ struct IdSource { void AcoustidClient::RequestFinished(QNetworkReply *reply, const int request_id) { - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); requests_.remove(request_id); diff --git a/src/musicbrainz/acoustidclient.h b/src/musicbrainz/acoustidclient.h index 2fd64a86..a0e7360a 100644 --- a/src/musicbrainz/acoustidclient.h +++ b/src/musicbrainz/acoustidclient.h @@ -58,7 +58,7 @@ class AcoustidClient : public QObject { void CancelAll(); signals: - void Finished(const int id, const QStringList &mbid_list, const QString &error = QString()); + void Finished(int id, QStringList mbid_list, QString error = QString()); private slots: void RequestFinished(QNetworkReply *reply, const int id); @@ -75,4 +75,3 @@ class AcoustidClient : public QObject { }; #endif // ACOUSTIDCLIENT_H - diff --git a/src/musicbrainz/musicbrainzclient.cpp b/src/musicbrainz/musicbrainzclient.cpp index 742917d5..efaa10ac 100644 --- a/src/musicbrainz/musicbrainzclient.cpp +++ b/src/musicbrainz/musicbrainzclient.cpp @@ -66,7 +66,7 @@ MusicBrainzClient::MusicBrainzClient(QObject *parent, QNetworkAccessManager *net timer_flush_requests_->setInterval(kRequestsDelay); timer_flush_requests_->setSingleShot(true); - connect(timer_flush_requests_, SIGNAL(timeout()), this, SLOT(FlushRequests())); + QObject::connect(timer_flush_requests_, &QTimer::timeout, this, &MusicBrainzClient::FlushRequests); } @@ -121,7 +121,7 @@ void MusicBrainzClient::Cancel(int id) { while (!requests_.isEmpty() && requests_.contains(id)) { QNetworkReply *reply = requests_.take(id); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); if (reply->isRunning()) reply->abort(); reply->deleteLater(); } @@ -167,7 +167,7 @@ void MusicBrainzClient::StartDiscIdRequest(const QString &discid) { req.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); #endif QNetworkReply *reply = network_->get(req); - connect(reply, &QNetworkReply::finished, [=] { DiscIdRequestFinished(discid, reply); }); + QObject::connect(reply, &QNetworkReply::finished, [this, discid, reply]() { DiscIdRequestFinished(discid, reply); }); timeouts_->AddReply(reply); @@ -193,7 +193,7 @@ void MusicBrainzClient::FlushRequests() { req.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); #endif QNetworkReply *reply = network_->get(req); - connect(reply, &QNetworkReply::finished, [=] { RequestFinished(reply, request.id, request.number); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { RequestFinished(reply, request.id, request.number); }); requests_.insert(request.id, reply); timeouts_->AddReply(reply); @@ -202,7 +202,7 @@ void MusicBrainzClient::FlushRequests() { void MusicBrainzClient::RequestFinished(QNetworkReply *reply, const int id, const int request_number) { - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); const int nb_removed = requests_.remove(id, reply); @@ -248,7 +248,7 @@ void MusicBrainzClient::RequestFinished(QNetworkReply *reply, const int id, cons void MusicBrainzClient::DiscIdRequestFinished(const QString &discid, QNetworkReply *reply) { - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); ResultList ret; @@ -259,7 +259,7 @@ void MusicBrainzClient::DiscIdRequestFinished(const QString &discid, QNetworkRep QString error; QByteArray data = GetReplyData(reply, error); if (data.isEmpty()) { - emit Finished(artist, album, ret, error); + emit DiscIdFinished(artist, album, ret, error); return; } @@ -323,7 +323,7 @@ void MusicBrainzClient::DiscIdRequestFinished(const QString &discid, QNetworkRep } } - emit Finished(artist, album, UniqueResults(ret, SortResults)); + emit DiscIdFinished(artist, album, UniqueResults(ret, SortResults)); } diff --git a/src/musicbrainz/musicbrainzclient.h b/src/musicbrainz/musicbrainzclient.h index 8320837c..2734ad67 100644 --- a/src/musicbrainz/musicbrainzclient.h +++ b/src/musicbrainz/musicbrainzclient.h @@ -101,9 +101,9 @@ class MusicBrainzClient : public QObject { signals: // Finished signal emitted when fechting songs tags - void Finished(const int id, const MusicBrainzClient::ResultList &result, const QString &error = QString()); + void Finished(int id, MusicBrainzClient::ResultList result, QString error = QString()); // Finished signal emitted when fechting album's songs tags using DiscId - void Finished(const QString &artist, const QString &album, const MusicBrainzClient::ResultList &result, const QString &error = QString()); + void DiscIdFinished(QString artist, QString album, MusicBrainzClient::ResultList result, QString error = QString()); private slots: void FlushRequests(); diff --git a/src/musicbrainz/tagfetcher.cpp b/src/musicbrainz/tagfetcher.cpp index 781de3a9..418c40cb 100644 --- a/src/musicbrainz/tagfetcher.cpp +++ b/src/musicbrainz/tagfetcher.cpp @@ -39,8 +39,8 @@ TagFetcher::TagFetcher(QObject *parent) acoustid_client_(new AcoustidClient(this)), musicbrainz_client_(new MusicBrainzClient(this)) { - connect(acoustid_client_, SIGNAL(Finished(int, QStringList, QString)), SLOT(PuidsFound(int, QStringList, QString))); - connect(musicbrainz_client_, SIGNAL(Finished(int, MusicBrainzClient::ResultList, QString)), SLOT(TagsFetched(int, MusicBrainzClient::ResultList, QString))); + QObject::connect(acoustid_client_, &AcoustidClient::Finished, this, &TagFetcher::PuidsFound); + QObject::connect(musicbrainz_client_, &MusicBrainzClient::Finished, this, &TagFetcher::TagsFetched); } @@ -57,7 +57,7 @@ void TagFetcher::StartFetch(const SongList &songs) { QFuture future = QtConcurrent::mapped(songs_, GetFingerprint); fingerprint_watcher_ = new QFutureWatcher(this); fingerprint_watcher_->setFuture(future); - connect(fingerprint_watcher_, SIGNAL(resultReadyAt(int)), SLOT(FingerprintFound(int))); + QObject::connect(fingerprint_watcher_, &QFutureWatcher::resultReadyAt, this, &TagFetcher::FingerprintFound); for (const Song &song : songs) { emit Progress(song, tr("Fingerprinting song")); @@ -70,7 +70,7 @@ void TagFetcher::Cancel() { if (fingerprint_watcher_) { fingerprint_watcher_->cancel(); - delete fingerprint_watcher_; + fingerprint_watcher_->deleteLater(); fingerprint_watcher_ = nullptr; } @@ -83,9 +83,7 @@ void TagFetcher::Cancel() { void TagFetcher::FingerprintFound(const int index) { QFutureWatcher* watcher = reinterpret_cast*>(sender()); - if (!watcher || index >= songs_.count()) { - return; - } + if (!watcher || index >= songs_.count()) return; const QString fingerprint = watcher->resultAt(index); const Song &song = songs_[index]; diff --git a/src/musicbrainz/tagfetcher.h b/src/musicbrainz/tagfetcher.h index c3ce6350..505e6c4a 100644 --- a/src/musicbrainz/tagfetcher.h +++ b/src/musicbrainz/tagfetcher.h @@ -47,8 +47,8 @@ class TagFetcher : public QObject { void Cancel(); signals: - void Progress(const Song &original_song, const QString &stage); - void ResultAvailable(const Song &original_song, const SongList &songs_guessed, const QString &error = QString()); + void Progress(Song original_song, QString stage); + void ResultAvailable(Song original_song, SongList songs_guessed, QString error = QString()); private slots: void FingerprintFound(const int index); diff --git a/src/organize/organize.cpp b/src/organize/organize.cpp index 98b7c445..bdccfabe 100644 --- a/src/organize/organize.cpp +++ b/src/organize/organize.cpp @@ -95,10 +95,10 @@ void Organize::Start() { task_manager_->SetTaskBlocksCollectionScans(true); thread_ = new QThread; - connect(thread_, SIGNAL(started()), SLOT(ProcessSomeFiles())); + QObject::connect(thread_, &QThread::started, this, &Organize::ProcessSomeFiles); #ifdef HAVE_GSTREAMER - connect(transcoder_, SIGNAL(JobComplete(QString, QString, bool)), SLOT(FileTranscoded(QString, QString, bool))); - connect(transcoder_, SIGNAL(LogLine(QString)), SLOT(LogLine(QString))); + QObject::connect(transcoder_, &Transcoder::JobComplete, this, &Organize::FileTranscoded); + QObject::connect(transcoder_, &Transcoder::LogLine, this, &Organize::LogLine); #endif moveToThread(thread_); @@ -257,7 +257,7 @@ void Organize::ProcessSomeFiles() { } SetSongProgress(0); - QTimer::singleShot(0, this, SLOT(ProcessSomeFiles())); + QTimer::singleShot(0, this, &Organize::ProcessSomeFiles); } @@ -345,7 +345,7 @@ void Organize::FileTranscoded(const QString &input, const QString &output, bool else { tasks_pending_ << task; } - QTimer::singleShot(0, this, SLOT(ProcessSomeFiles())); + QTimer::singleShot(0, this, &Organize::ProcessSomeFiles); } diff --git a/src/organize/organize.h b/src/organize/organize.h index 1983609b..74310c1d 100644 --- a/src/organize/organize.h +++ b/src/organize/organize.h @@ -69,9 +69,9 @@ class Organize : public QObject { void Start(); signals: - void Finished(const QStringList &files_with_errors, QStringList); + void Finished(QStringList files_with_errors, QStringList); void FileCopied(int database_id); - void SongPathChanged(const Song &song, const QFileInfo &new_file); + void SongPathChanged(Song song, QFileInfo new_file); protected: void timerEvent(QTimerEvent *e) override; diff --git a/src/organize/organizedialog.cpp b/src/organize/organizedialog.cpp index 94ff299e..ff805f1b 100644 --- a/src/organize/organizedialog.cpp +++ b/src/organize/organizedialog.cpp @@ -90,10 +90,10 @@ OrganizeDialog::OrganizeDialog(TaskManager *task_manager, CollectionBackend *bac setWindowFlags(windowFlags()|Qt::WindowMaximizeButtonHint); QPushButton *button_save = ui_->button_box->addButton("Save settings", QDialogButtonBox::ApplyRole); - connect(button_save, SIGNAL(clicked()), SLOT(SaveSettings())); + QObject::connect(button_save, &QPushButton::clicked, this, &OrganizeDialog::SaveSettings); button_save->setIcon(IconLoader::Load("document-save")); ui_->button_box->button(QDialogButtonBox::RestoreDefaults)->setIcon(IconLoader::Load("edit-undo")); - connect(ui_->button_box->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked()), SLOT(RestoreDefaults())); + QObject::connect(ui_->button_box->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, this, &OrganizeDialog::RestoreDefaults); ui_->aftercopying->setItemIcon(1, IconLoader::Load("edit-delete")); @@ -122,14 +122,14 @@ OrganizeDialog::OrganizeDialog(TaskManager *task_manager, CollectionBackend *bac // Naming scheme input field new OrganizeFormat::SyntaxHighlighter(ui_->naming); - connect(ui_->destination, SIGNAL(currentIndexChanged(int)), SLOT(UpdatePreviews())); - connect(ui_->naming, SIGNAL(textChanged()), SLOT(UpdatePreviews())); - connect(ui_->remove_problematic, SIGNAL(toggled(bool)), SLOT(UpdatePreviews())); - connect(ui_->remove_non_fat, SIGNAL(toggled(bool)), SLOT(UpdatePreviews())); - connect(ui_->remove_non_ascii, SIGNAL(toggled(bool)), SLOT(UpdatePreviews())); - connect(ui_->allow_ascii_ext, SIGNAL(toggled(bool)), SLOT(UpdatePreviews())); - connect(ui_->replace_spaces, SIGNAL(toggled(bool)), SLOT(UpdatePreviews())); - connect(ui_->remove_non_ascii, SIGNAL(toggled(bool)), SLOT(AllowExtASCII(bool))); + QObject::connect(ui_->destination, QOverload::of(&QComboBox::currentIndexChanged), this, &OrganizeDialog::UpdatePreviews); + QObject::connect(ui_->naming, &LineTextEdit::textChanged, this, &OrganizeDialog::UpdatePreviews); + QObject::connect(ui_->remove_problematic, &QCheckBox::toggled, this, &OrganizeDialog::UpdatePreviews); + QObject::connect(ui_->remove_non_fat, &QCheckBox::toggled, this, &OrganizeDialog::UpdatePreviews); + QObject::connect(ui_->remove_non_ascii, &QCheckBox::toggled, this, &OrganizeDialog::UpdatePreviews); + QObject::connect(ui_->allow_ascii_ext, &QCheckBox::toggled, this, &OrganizeDialog::UpdatePreviews); + QObject::connect(ui_->replace_spaces, &QCheckBox::toggled, this, &OrganizeDialog::UpdatePreviews); + QObject::connect(ui_->remove_non_ascii, &QCheckBox::toggled, this, &OrganizeDialog::AllowExtASCII); // Get the titles of the tags to put in the insert menu QStringList tag_titles = tags.keys(); @@ -140,7 +140,7 @@ OrganizeDialog::OrganizeDialog(TaskManager *task_manager, CollectionBackend *bac for (const QString &title : tag_titles) { QAction *action = tag_menu->addAction(title); QString tag = tags[title]; - connect(action, &QAction::triggered, [this, tag]() { InsertTag(tag); } ); + QObject::connect(action, &QAction::triggered, [this, tag]() { InsertTag(tag); } ); } ui_->insert->setMenu(tag_menu); @@ -187,10 +187,11 @@ void OrganizeDialog::accept() { // It deletes itself when it's finished. const bool copy = ui_->aftercopying->currentIndex() == 0; Organize *organize = new Organize(task_manager_, storage, format_, copy, ui_->overwrite->isChecked(), ui_->mark_as_listened->isChecked(), ui_->albumcover->isChecked(), new_songs_info_, ui_->eject_after->isChecked(), playlist_); - connect(organize, SIGNAL(Finished(QStringList, QStringList)), SLOT(OrganizeFinished(QStringList, QStringList))); - connect(organize, SIGNAL(FileCopied(int)), this, SIGNAL(FileCopied(int))); - if (backend_) - connect(organize, SIGNAL(SongPathChanged(Song, QFileInfo)), backend_, SLOT(SongPathChanged(Song, QFileInfo))); + QObject::connect(organize, &Organize::Finished, this, &OrganizeDialog::OrganizeFinished); + QObject::connect(organize, &Organize::FileCopied, this, &OrganizeDialog::FileCopied); + if (backend_) { + QObject::connect(organize, &Organize::SongPathChanged, backend_, &CollectionBackend::SongPathChanged); + } organize->Start(); @@ -387,6 +388,7 @@ bool OrganizeDialog::SetUrls(const QList &urls) { } bool OrganizeDialog::SetFilenames(const QStringList &filenames) { + #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) songs_future_ = QtConcurrent::run(&OrganizeDialog::LoadSongsBlocking, this, filenames); #else diff --git a/src/organize/organizeformat.h b/src/organize/organizeformat.h index 80117658..17d7adef 100644 --- a/src/organize/organizeformat.h +++ b/src/organize/organizeformat.h @@ -103,4 +103,3 @@ class OrganizeFormat { }; #endif // ORGANISEFORMAT_H - diff --git a/src/osd/osdbase.cpp b/src/osd/osdbase.cpp index c2458425..d79b0479 100644 --- a/src/osd/osdbase.cpp +++ b/src/osd/osdbase.cpp @@ -57,10 +57,9 @@ OSDBase::OSDBase(SystemTrayIcon *tray_icon, Application *app, QObject *parent) custom_text2_(QString()), force_show_next_(false), ignore_next_stopped_(false), - playing_(false) - { + playing_(false) { - connect(app_->current_albumcover_loader(), SIGNAL(ThumbnailLoaded(Song, QUrl, QImage)), SLOT(AlbumCoverLoaded(Song, QUrl, QImage))); + QObject::connect(app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::ThumbnailLoaded, this, &OSDBase::AlbumCoverLoaded); app_name_[0] = app_name_[0].toUpper(); diff --git a/src/osd/osddbus.cpp b/src/osd/osddbus.cpp index c2dc2caa..5e8db466 100644 --- a/src/osd/osddbus.cpp +++ b/src/osd/osddbus.cpp @@ -168,7 +168,7 @@ void OSDDBus::ShowMessageNative(const QString &summary, const QString &message, QDBusPendingReply reply = interface_->Notify(app_name(), id, icon, summary_stripped, message, QStringList(), hints, timeout_msec()); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(CallFinished(QDBusPendingCallWatcher*))); + QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &OSDDBus::CallFinished); } diff --git a/src/osd/osdpretty.cpp b/src/osd/osdpretty.cpp index d985de81..17817d41 100644 --- a/src/osd/osdpretty.cpp +++ b/src/osd/osdpretty.cpp @@ -124,13 +124,13 @@ OSDPretty::OSDPretty(Mode mode, QWidget *parent) // Timeout timeout_->setSingleShot(true); timeout_->setInterval(5000); - connect(timeout_, SIGNAL(timeout()), SLOT(hide())); + QObject::connect(timeout_, &QTimer::timeout, this, &OSDPretty::hide); ui_->icon->setMaximumSize(kMaxIconSize, kMaxIconSize); // Fader - connect(fader_, SIGNAL(valueChanged(qreal)), SLOT(FaderValueChanged(qreal))); - connect(fader_, SIGNAL(finished()), SLOT(FaderFinished())); + QObject::connect(fader_, &QTimeLine::valueChanged, this, &OSDPretty::FaderValueChanged); + QObject::connect(fader_, &QTimeLine::finished, this, &OSDPretty::FaderFinished); #ifdef Q_OS_WIN set_fading_enabled(true); @@ -155,8 +155,8 @@ OSDPretty::OSDPretty(Mode mode, QWidget *parent) margin.setRight(margin.right() + kDropShadowSize); l->setContentsMargins(margin); - connect(qApp, SIGNAL(screenAdded(QScreen*)), this, SLOT(ScreenAdded(QScreen*))); - connect(qApp, SIGNAL(screenRemoved(QScreen*)), this, SLOT(ScreenRemoved(QScreen*))); + QObject::connect(qApp, &QApplication::screenAdded, this, &OSDPretty::ScreenAdded); + QObject::connect(qApp, &QApplication::screenRemoved, this, &OSDPretty::ScreenRemoved); } @@ -410,7 +410,7 @@ void OSDPretty::FaderFinished() { } -void OSDPretty::FaderValueChanged(qreal value) { +void OSDPretty::FaderValueChanged(const qreal value) { setWindowOpacity(value); } diff --git a/src/osd/osdpretty.h b/src/osd/osdpretty.h index c88123cf..0bc8948b 100644 --- a/src/osd/osdpretty.h +++ b/src/osd/osdpretty.h @@ -134,7 +134,7 @@ class OSDPretty : public QWidget { QRect BoxBorder() const; private slots: - void FaderValueChanged(qreal value); + void FaderValueChanged(const qreal value); void FaderFinished(); void ScreenAdded(QScreen *screen); void ScreenRemoved(QScreen *screen); diff --git a/src/playlist/dynamicplaylistcontrols.cpp b/src/playlist/dynamicplaylistcontrols.cpp index ef0b9de6..eb0447aa 100644 --- a/src/playlist/dynamicplaylistcontrols.cpp +++ b/src/playlist/dynamicplaylistcontrols.cpp @@ -23,9 +23,10 @@ DynamicPlaylistControls::DynamicPlaylistControls(QWidget *parent) ui_->setupUi(this); - connect(ui_->expand, SIGNAL(clicked()), SIGNAL(Expand())); - connect(ui_->repopulate, SIGNAL(clicked()), SIGNAL(Repopulate())); - connect(ui_->off, SIGNAL(clicked()), SIGNAL(TurnOff())); + QObject::connect(ui_->expand, &QPushButton::clicked, this, &DynamicPlaylistControls::Expand); + QObject::connect(ui_->repopulate, &QPushButton::clicked, this, &DynamicPlaylistControls::Repopulate); + QObject::connect(ui_->off, &QPushButton::clicked, this, &DynamicPlaylistControls::TurnOff); + } DynamicPlaylistControls::~DynamicPlaylistControls() { delete ui_; } diff --git a/src/playlist/dynamicplaylistcontrols.h b/src/playlist/dynamicplaylistcontrols.h index 45fa1d8e..9f298326 100644 --- a/src/playlist/dynamicplaylistcontrols.h +++ b/src/playlist/dynamicplaylistcontrols.h @@ -27,7 +27,7 @@ class DynamicPlaylistControls : public QWidget { public: DynamicPlaylistControls(QWidget *parent = nullptr); - ~DynamicPlaylistControls(); + ~DynamicPlaylistControls() override; signals: void Expand(); diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index 292d2808..b5b11762 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -142,20 +142,20 @@ Playlist::Playlist(PlaylistBackend *backend, TaskManager *task_manager, Collecti undo_stack_->setUndoLimit(kUndoStackSize); - connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), SIGNAL(PlaylistChanged())); - connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)), SIGNAL(PlaylistChanged())); + QObject::connect(this, &Playlist::rowsInserted, this, &Playlist::PlaylistChanged); + QObject::connect(this, &Playlist::rowsRemoved, this, &Playlist::PlaylistChanged); Restore(); proxy_->setSourceModel(this); queue_->setSourceModel(this); - connect(queue_, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), SLOT(TracksAboutToBeDequeued(QModelIndex, int, int))); - connect(queue_, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(TracksDequeued())); + QObject::connect(queue_, &Queue::rowsAboutToBeRemoved, this, &Playlist::TracksAboutToBeDequeued); + QObject::connect(queue_, &Queue::rowsRemoved, this, &Playlist::TracksDequeued); - connect(queue_, SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(TracksEnqueued(QModelIndex, int, int))); + QObject::connect(queue_, &Queue::rowsInserted, this, &Playlist::TracksEnqueued); - connect(queue_, SIGNAL(layoutChanged()), SLOT(QueueLayoutChanged())); + QObject::connect(queue_, &Queue::layoutChanged, this, &Playlist::QueueLayoutChanged); column_alignments_ = PlaylistView::DefaultColumnAlignment(); @@ -691,8 +691,8 @@ void Playlist::set_current_row(const int i, const AutoScroll autoscroll, const b void Playlist::InsertDynamicItems(const int count) { PlaylistGeneratorInserter* inserter = new PlaylistGeneratorInserter(task_manager_, collection_, this); - connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString))); - connect(inserter, SIGNAL(PlayRequested(QModelIndex)), SIGNAL(PlayRequested(QModelIndex))); + QObject::connect(inserter, &PlaylistGeneratorInserter::Error, this, &Playlist::Error); + QObject::connect(inserter, &PlaylistGeneratorInserter::PlayRequested, this, &Playlist::PlayRequested); inserter->Load(this, -1, false, false, false, dynamic_playlist_, count); @@ -805,7 +805,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro } else if (data->hasFormat(kCddaMimeType)) { SongLoaderInserter *inserter = new SongLoaderInserter(task_manager_, collection_, backend_->app()->player()); - connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString))); + QObject::connect(inserter, &SongLoaderInserter::Error, this, &Playlist::Error); inserter->LoadAudioCD(this, row, play_now, enqueue_now, enqueue_next_now); } else if (data->hasUrls()) { @@ -820,7 +820,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro void Playlist::InsertUrls(const QList &urls, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next) { SongLoaderInserter *inserter = new SongLoaderInserter(task_manager_, collection_, backend_->app()->player()); - connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString))); + QObject::connect(inserter, &SongLoaderInserter::Error, this, &Playlist::Error); inserter->Load(this, pos, play_now, enqueue, enqueue_next, urls); @@ -834,7 +834,7 @@ void Playlist::InsertSmartPlaylist(PlaylistGeneratorPtr generator, const int pos } PlaylistGeneratorInserter *inserter = new PlaylistGeneratorInserter(task_manager_, collection_, this); - connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString))); + QObject::connect(inserter, &PlaylistGeneratorInserter::Error, this, &Playlist::Error); inserter->Load(this, pos, play_now, enqueue, enqueue_next, generator); @@ -1759,11 +1759,11 @@ void Playlist::ReloadItems(const QList &rows) { void Playlist::AddSongInsertVetoListener(SongInsertVetoListener *listener) { veto_listeners_.append(listener); - connect(listener, SIGNAL(destroyed()), this, SLOT(SongInsertVetoListenerDestroyed())); + QObject::connect(listener, &SongInsertVetoListener::destroyed, this, &Playlist::SongInsertVetoListenerDestroyed); } void Playlist::RemoveSongInsertVetoListener(SongInsertVetoListener *listener) { - disconnect(listener, SIGNAL(destroyed()), this, SLOT(SongInsertVetoListenerDestroyed())); + QObject::disconnect(listener, &SongInsertVetoListener::destroyed, this, &Playlist::SongInsertVetoListenerDestroyed); veto_listeners_.removeAll(listener); } @@ -1885,7 +1885,7 @@ void Playlist::ReshuffleIndices() { void Playlist::set_sequence(PlaylistSequence *v) { playlist_sequence_ = v; - connect(v, SIGNAL(ShuffleModeChanged(PlaylistSequence::ShuffleMode)), SLOT(ShuffleModeChanged(PlaylistSequence::ShuffleMode))); + QObject::connect(v, &PlaylistSequence::ShuffleModeChanged, this, &Playlist::ShuffleModeChanged); ShuffleModeChanged(v->shuffle_mode()); diff --git a/src/playlist/playlist.h b/src/playlist/playlist.h index a188c69e..526b2db2 100644 --- a/src/playlist/playlist.h +++ b/src/playlist/playlist.h @@ -325,6 +325,8 @@ class Playlist : public QAbstractListModel { void RepopulateDynamicPlaylist(); void TurnOffDynamicPlaylist(); + void AlbumCoverLoaded(const Song &song, const AlbumCoverLoaderResult &result); + signals: void RestoreFinished(); void PlaylistLoaded(); @@ -373,11 +375,10 @@ class Playlist : public QAbstractListModel { void TracksDequeued(); void TracksEnqueued(const QModelIndex&, const int begin, const int end); void QueueLayoutChanged(); - void SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex &index); - void ItemReloadComplete(const QPersistentModelIndex &index); + void SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex &idx); + void ItemReloadComplete(const QPersistentModelIndex &idx); void ItemsLoaded(QFuture future); void SongInsertVetoListenerDestroyed(); - void AlbumCoverLoaded(const Song &song, const AlbumCoverLoaderResult &result); private: bool is_loading_; diff --git a/src/playlist/playlistcontainer.cpp b/src/playlist/playlistcontainer.cpp index 755d5e55..05060b2d 100644 --- a/src/playlist/playlistcontainer.cpp +++ b/src/playlist/playlistcontainer.cpp @@ -107,21 +107,21 @@ PlaylistContainer::PlaylistContainer(QWidget *parent) ui_->tab_bar->setExpanding(false); ui_->tab_bar->setMovable(true); - connect(tab_bar_animation_, SIGNAL(frameChanged(int)), SLOT(SetTabBarHeight(int))); + QObject::connect(tab_bar_animation_, &QTimeLine::frameChanged, this, &PlaylistContainer::SetTabBarHeight); ui_->tab_bar->setMaximumHeight(0); // Connections - connect(ui_->tab_bar, SIGNAL(currentChanged(int)), SLOT(Save())); - connect(ui_->tab_bar, SIGNAL(Save(int)), SLOT(SavePlaylist(int))); + QObject::connect(ui_->tab_bar, &PlaylistTabBar::currentChanged, this, &PlaylistContainer::Save); + QObject::connect(ui_->tab_bar, &PlaylistTabBar::Save, this, &PlaylistContainer::SaveCurrentPlaylist); // set up timer for delayed filter updates filter_timer_->setSingleShot(true); filter_timer_->setInterval(kFilterDelayMs); - connect(filter_timer_, SIGNAL(timeout()), this, SLOT(UpdateFilter())); + QObject::connect(filter_timer_, &QTimer::timeout, this, &PlaylistContainer::UpdateFilter); // Replace playlist search filter with native search box. - connect(ui_->filter, SIGNAL(textChanged(QString)), SLOT(MaybeUpdateFilter())); - connect(ui_->playlist, SIGNAL(FocusOnFilterSignal(QKeyEvent*)), SLOT(FocusOnFilter(QKeyEvent*))); + QObject::connect(ui_->filter, &QSearchField::textChanged, this, &PlaylistContainer::MaybeUpdateFilter); + QObject::connect(ui_->playlist, &PlaylistView::FocusOnFilterSignal, this, &PlaylistContainer::FocusOnFilter); ui_->filter->installEventFilter(this); ReloadSettings(); @@ -141,13 +141,13 @@ void PlaylistContainer::SetActions(QAction *new_playlist, QAction *load_playlist ui_->tab_bar->SetActions(new_playlist, load_playlist); - connect(new_playlist, SIGNAL(triggered()), SLOT(NewPlaylist())); - connect(save_playlist, SIGNAL(triggered()), SLOT(SavePlaylist())); - connect(load_playlist, SIGNAL(triggered()), SLOT(LoadPlaylist())); - connect(clear_playlist, SIGNAL(triggered()), SLOT(ClearPlaylist())); - connect(next_playlist, SIGNAL(triggered()), SLOT(GoToNextPlaylistTab())); - connect(previous_playlist, SIGNAL(triggered()), SLOT(GoToPreviousPlaylistTab())); - connect(clear_playlist, SIGNAL(triggered()), SLOT(ClearPlaylist())); + QObject::connect(new_playlist, &QAction::triggered, this, &PlaylistContainer::NewPlaylist); + QObject::connect(save_playlist, &QAction::triggered, this, &PlaylistContainer::SavePlaylist); + QObject::connect(load_playlist, &QAction::triggered, this, &PlaylistContainer::LoadPlaylist); + QObject::connect(clear_playlist, &QAction::triggered, this, &PlaylistContainer::ClearPlaylist); + QObject::connect(next_playlist, &QAction::triggered, this, &PlaylistContainer::GoToNextPlaylistTab); + QObject::connect(previous_playlist, &QAction::triggered, this, &PlaylistContainer::GoToPreviousPlaylistTab); + QObject::connect(clear_playlist, &QAction::triggered, this, &PlaylistContainer::ClearPlaylist); } @@ -156,35 +156,35 @@ void PlaylistContainer::SetManager(PlaylistManager *manager) { manager_ = manager; ui_->tab_bar->SetManager(manager); - connect(ui_->tab_bar, SIGNAL(CurrentIdChanged(int)), manager, SLOT(SetCurrentPlaylist(int))); - connect(ui_->tab_bar, SIGNAL(Rename(int, QString)), manager, SLOT(Rename(int, QString))); - connect(ui_->tab_bar, SIGNAL(Close(int)), manager, SLOT(Close(int))); - connect(ui_->tab_bar, SIGNAL(PlaylistFavorited(int, bool)), manager, SLOT(Favorite(int, bool))); + QObject::connect(ui_->tab_bar, &PlaylistTabBar::CurrentIdChanged, manager, &PlaylistManager::SetCurrentPlaylist); + QObject::connect(ui_->tab_bar, &PlaylistTabBar::Rename, manager, &PlaylistManager::Rename); + QObject::connect(ui_->tab_bar, &PlaylistTabBar::Close, manager, &PlaylistManager::Close); + QObject::connect(ui_->tab_bar, &PlaylistTabBar::PlaylistFavorited, manager, &PlaylistManager::Favorite); - connect(ui_->tab_bar, SIGNAL(PlaylistOrderChanged(QList)), manager, SLOT(ChangePlaylistOrder(QList))); + QObject::connect(ui_->tab_bar, &PlaylistTabBar::PlaylistOrderChanged, manager, &PlaylistManager::ChangePlaylistOrder); - connect(manager, SIGNAL(CurrentChanged(Playlist*, int)), SLOT(SetViewModel(Playlist*, int))); - connect(manager, SIGNAL(PlaylistAdded(int, QString, bool)), SLOT(PlaylistAdded(int, QString, bool))); - connect(manager, SIGNAL(PlaylistManagerInitialized()), SLOT(Started())); - connect(manager, SIGNAL(PlaylistClosed(int)), SLOT(PlaylistClosed(int))); - connect(manager, SIGNAL(PlaylistRenamed(int, QString)), SLOT(PlaylistRenamed(int, QString))); + QObject::connect(manager, &PlaylistManager::CurrentChanged, this, &PlaylistContainer::SetViewModel); + QObject::connect(manager, &PlaylistManager::PlaylistAdded, this, &PlaylistContainer::PlaylistAdded); + QObject::connect(manager, &PlaylistManager::PlaylistManagerInitialized, this, &PlaylistContainer::Started); + QObject::connect(manager, &PlaylistManager::PlaylistClosed, this, &PlaylistContainer::PlaylistClosed); + QObject::connect(manager, &PlaylistManager::PlaylistRenamed, this, &PlaylistContainer::PlaylistRenamed); } void PlaylistContainer::SetViewModel(Playlist *playlist, const int scroll_position) { if (view()->selectionModel()) { - disconnect(view()->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(SelectionChanged())); + QObject::disconnect(view()->selectionModel(), &QItemSelectionModel::selectionChanged, this, &PlaylistContainer::SelectionChanged); } if (playlist_ && playlist_->proxy()) { - disconnect(playlist_->proxy(), SIGNAL(modelReset()), this, SLOT(UpdateNoMatchesLabel())); - disconnect(playlist_->proxy(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(UpdateNoMatchesLabel())); - disconnect(playlist_->proxy(), SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(UpdateNoMatchesLabel())); + QObject::disconnect(playlist_->proxy(), &QSortFilterProxyModel::modelReset, this, &PlaylistContainer::UpdateNoMatchesLabel); + QObject::disconnect(playlist_->proxy(), &QSortFilterProxyModel::rowsInserted, this, &PlaylistContainer::UpdateNoMatchesLabel); + QObject::disconnect(playlist_->proxy(), &QSortFilterProxyModel::rowsRemoved, this, &PlaylistContainer::UpdateNoMatchesLabel); } if (playlist_) { - disconnect(playlist_, SIGNAL(modelReset()), this, SLOT(UpdateNoMatchesLabel())); - disconnect(playlist_, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(UpdateNoMatchesLabel())); - disconnect(playlist_, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(UpdateNoMatchesLabel())); + QObject::disconnect(playlist_, &Playlist::modelReset, this, &PlaylistContainer::UpdateNoMatchesLabel); + QObject::disconnect(playlist_, &Playlist::rowsInserted, this, &PlaylistContainer::UpdateNoMatchesLabel); + QObject::disconnect(playlist_, &Playlist::rowsRemoved, this, &PlaylistContainer::UpdateNoMatchesLabel); } playlist_ = playlist; @@ -197,7 +197,7 @@ void PlaylistContainer::SetViewModel(Playlist *playlist, const int scroll_positi if (scroll_position != 0) view()->verticalScrollBar()->setValue(scroll_position); playlist->IgnoreSorting(false); - connect(view()->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(SelectionChanged())); + QObject::connect(view()->selectionModel(), &QItemSelectionModel::selectionChanged, this, &PlaylistContainer::SelectionChanged); emit ViewSelectionModelChanged(); // Update filter @@ -208,12 +208,12 @@ void PlaylistContainer::SetViewModel(Playlist *playlist, const int scroll_positi #endif // Update the no matches label - connect(playlist_->proxy(), SIGNAL(modelReset()), SLOT(UpdateNoMatchesLabel())); - connect(playlist_->proxy(), SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(UpdateNoMatchesLabel())); - connect(playlist_->proxy(), SIGNAL(rowsRemoved(QModelIndex, int, int)), SLOT(UpdateNoMatchesLabel())); - connect(playlist_, SIGNAL(modelReset()), SLOT(UpdateNoMatchesLabel())); - connect(playlist_, SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(UpdateNoMatchesLabel())); - connect(playlist_, SIGNAL(rowsRemoved(QModelIndex, int, int)), SLOT(UpdateNoMatchesLabel())); + QObject::connect(playlist_->proxy(), &QSortFilterProxyModel::modelReset, this, &PlaylistContainer::UpdateNoMatchesLabel); + QObject::connect(playlist_->proxy(), &QSortFilterProxyModel::rowsInserted, this, &PlaylistContainer::UpdateNoMatchesLabel); + QObject::connect(playlist_->proxy(), &QSortFilterProxyModel::rowsRemoved, this, &PlaylistContainer::UpdateNoMatchesLabel); + QObject::connect(playlist_, &Playlist::modelReset, this, &PlaylistContainer::UpdateNoMatchesLabel); + QObject::connect(playlist_, &Playlist::rowsInserted, this, &PlaylistContainer::UpdateNoMatchesLabel); + QObject::connect(playlist_, &Playlist::rowsRemoved, this, &PlaylistContainer::UpdateNoMatchesLabel); UpdateNoMatchesLabel(); // Ensure that tab is current @@ -284,7 +284,7 @@ void PlaylistContainer::UpdateActiveIcon(const QIcon &icon) { } -void PlaylistContainer::PlaylistAdded(int id, const QString &name, bool favorite) { +void PlaylistContainer::PlaylistAdded(const int id, const QString &name, const bool favorite) { const int index = ui_->tab_bar->count(); ui_->tab_bar->InsertTab(id, index, name, favorite); @@ -313,7 +313,7 @@ void PlaylistContainer::PlaylistAdded(int id, const QString &name, bool favorite void PlaylistContainer::Started() { starting_up_ = false; } -void PlaylistContainer::PlaylistClosed(int id) { +void PlaylistContainer::PlaylistClosed(const int id) { ui_->tab_bar->RemoveTab(id); @@ -321,7 +321,7 @@ void PlaylistContainer::PlaylistClosed(int id) { } -void PlaylistContainer::PlaylistRenamed(int id, const QString &new_name) { +void PlaylistContainer::PlaylistRenamed(const int id, const QString &new_name) { ui_->tab_bar->set_text_by_id(id, new_name); } @@ -340,7 +340,7 @@ void PlaylistContainer::LoadPlaylist() { } -void PlaylistContainer::SavePlaylist(int id = -1) { +void PlaylistContainer::SavePlaylist(const int id = -1) { // Use the tab name as the suggested name QString suggested_name = ui_->tab_bar->tabText(ui_->tab_bar->currentIndex()); @@ -377,7 +377,7 @@ void PlaylistContainer::Save() { } -void PlaylistContainer::SetTabBarVisible(bool visible) { +void PlaylistContainer::SetTabBarVisible(const bool visible) { if (tab_bar_visible_ == visible) return; tab_bar_visible_ = visible; @@ -387,7 +387,7 @@ void PlaylistContainer::SetTabBarVisible(bool visible) { } -void PlaylistContainer::SetTabBarHeight(int height) { +void PlaylistContainer::SetTabBarHeight(const int height) { ui_->tab_bar->setMaximumHeight(height); } @@ -457,7 +457,7 @@ void PlaylistContainer::FocusOnFilter(QKeyEvent *event) { } } -void PlaylistContainer::RepositionNoMatchesLabel(bool force) { +void PlaylistContainer::RepositionNoMatchesLabel(const bool force) { if (!force && !no_matches_label_->isVisible()) return; diff --git a/src/playlist/playlistcontainer.h b/src/playlist/playlistcontainer.h index 30582ba8..f50d7cac 100644 --- a/src/playlist/playlistcontainer.h +++ b/src/playlist/playlistcontainer.h @@ -63,7 +63,7 @@ class PlaylistContainer : public QWidget { signals: void TabChanged(int id); - void Rename(int id, const QString &new_name); + void Rename(int id, QString new_name); void UndoRedoActionsChanged(QAction *undo, QAction *redo); void ViewSelectionModelChanged(); @@ -75,27 +75,23 @@ class PlaylistContainer : public QWidget { private slots: void NewPlaylist(); void LoadPlaylist(); - void SavePlaylist() { SavePlaylist(-1); } - void SavePlaylist(int id); + void SaveCurrentPlaylist() { SavePlaylist(-1); } + void SavePlaylist(const int id); void ClearPlaylist(); void GoToNextPlaylistTab(); void GoToPreviousPlaylistTab(); void SetViewModel(Playlist *playlist, const int scroll_position); - void PlaylistAdded(int id, const QString &name, bool favorite); - void PlaylistClosed(int id); - void PlaylistRenamed(int id, const QString &new_name); + void PlaylistAdded(const int id, const QString &name, bool favorite); + void PlaylistClosed(const int id); + void PlaylistRenamed(const int id, const QString &new_name); void Started(); - void ActivePlaying(); - void ActivePaused(); - void ActiveStopped(); - void Save(); - void SetTabBarVisible(bool visible); - void SetTabBarHeight(int height); + void SetTabBarVisible(const bool visible); + void SetTabBarHeight(const int height); void SelectionChanged(); void MaybeUpdateFilter(); @@ -104,6 +100,11 @@ class PlaylistContainer : public QWidget { void UpdateNoMatchesLabel(); + public slots: + void ActivePlaying(); + void ActivePaused(); + void ActiveStopped(); + private: void UpdateActiveIcon(const QIcon &icon); void RepositionNoMatchesLabel(bool force = false); diff --git a/src/playlist/playlistdelegates.cpp b/src/playlist/playlistdelegates.cpp index 8d4978d0..08ea540f 100644 --- a/src/playlist/playlistdelegates.cpp +++ b/src/playlist/playlistdelegates.cpp @@ -90,13 +90,13 @@ const int PlaylistDelegateBase::kMinHeight = 19; QueuedItemDelegate::QueuedItemDelegate(QObject *parent, int indicator_column) : QStyledItemDelegate(parent), indicator_column_(indicator_column) {} -void QueuedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { +void QueuedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const { - QStyledItemDelegate::paint(painter, option, index); + QStyledItemDelegate::paint(painter, option, idx); - if (index.column() == indicator_column_) { + if (idx.column() == indicator_column_) { bool ok = false; - const int queue_pos = index.data(Playlist::Role_QueuePosition).toInt(&ok); + const int queue_pos = idx.data(Playlist::Role_QueuePosition).toInt(&ok); if (ok && queue_pos != -1) { float opacity = kQueueOpacitySteps - qMin(kQueueOpacitySteps, queue_pos); opacity /= kQueueOpacitySteps; @@ -155,10 +155,10 @@ void QueuedItemDelegate::DrawBox(QPainter *painter, const QRect &line_rect, cons } -int QueuedItemDelegate::queue_indicator_size(const QModelIndex &index) const { +int QueuedItemDelegate::queue_indicator_size(const QModelIndex &idx) const { - if (index.column() == indicator_column_) { - const int queue_pos = index.data(Playlist::Role_QueuePosition).toInt(); + if (idx.column() == indicator_column_) { + const int queue_pos = idx.data(Playlist::Role_QueuePosition).toInt(); if (queue_pos != -1) { return kQueueBoxLength + kQueueBoxBorder * 2; } @@ -205,23 +205,23 @@ QString PlaylistDelegateBase::displayText(const QVariant &value, const QLocale&) } -QSize PlaylistDelegateBase::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { +QSize PlaylistDelegateBase::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &idx) const { - QSize size = QueuedItemDelegate::sizeHint(option, index); + QSize size = QueuedItemDelegate::sizeHint(option, idx); if (size.height() < kMinHeight) size.setHeight(kMinHeight); return size; } -void PlaylistDelegateBase::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { +void PlaylistDelegateBase::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const { - QueuedItemDelegate::paint(painter, Adjusted(option, index), index); + QueuedItemDelegate::paint(painter, Adjusted(option, idx), idx); // Stop after indicator - if (index.column() == Playlist::Column_Title) { - if (index.data(Playlist::Role_StopAfter).toBool()) { + if (idx.column() == Playlist::Column_Title) { + if (idx.data(Playlist::Role_StopAfter).toBool()) { QRect rect(option.rect); - rect.setRight(rect.right() - queue_indicator_size(index)); + rect.setRight(rect.right() - queue_indicator_size(idx)); DrawBox(painter, rect, option.font, tr("stop")); } @@ -229,18 +229,18 @@ void PlaylistDelegateBase::paint(QPainter *painter, const QStyleOptionViewItem & } -QStyleOptionViewItem PlaylistDelegateBase::Adjusted(const QStyleOptionViewItem &option, const QModelIndex &index) const { +QStyleOptionViewItem PlaylistDelegateBase::Adjusted(const QStyleOptionViewItem &option, const QModelIndex &idx) const { if (!view_) return option; QPoint top_left(-view_->horizontalScrollBar()->value(), -view_->verticalScrollBar()->value()); - if (view_->header()->logicalIndexAt(top_left) != index.column()) + if (view_->header()->logicalIndexAt(top_left) != idx.column()) return option; QStyleOptionViewItem ret(option); - if (index.data(Playlist::Role_IsCurrent).toBool()) { + if (idx.data(Playlist::Role_IsCurrent).toBool()) { // Move the text in a bit on the first column for the song that's currently playing ret.rect.setLeft(ret.rect.left() + 20); } @@ -249,7 +249,7 @@ QStyleOptionViewItem PlaylistDelegateBase::Adjusted(const QStyleOptionViewItem & } -bool PlaylistDelegateBase::helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index) { +bool PlaylistDelegateBase::helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &idx) { // This function is copied from QAbstractItemDelegate, and changed to show displayText() in the tooltip, rather than the index's naked Qt::ToolTipRole text. @@ -258,11 +258,11 @@ bool PlaylistDelegateBase::helpEvent(QHelpEvent *event, QAbstractItemView *view, if (!event || !view) return false; QHelpEvent *he = static_cast(event); - QString text = displayText(index.data(), QLocale::system()); + QString text = displayText(idx.data(), QLocale::system()); // Special case: we want newlines in the comment tooltip - if (index.column() == Playlist::Column_Comment) { - text = index.data(Qt::ToolTipRole).toString().toHtmlEscaped(); + if (idx.column() == Playlist::Column_Comment) { + text = idx.data(Qt::ToolTipRole).toString().toHtmlEscaped(); text.replace("\\r\\n", "
"); text.replace("\\n", "
"); text.replace("\r\n", "
"); @@ -273,8 +273,8 @@ bool PlaylistDelegateBase::helpEvent(QHelpEvent *event, QAbstractItemView *view, switch (event->type()) { case QEvent::ToolTip: { - QSize real_text = sizeHint(option, index); - QRect displayed_text = view->visualRect(index); + QSize real_text = sizeHint(option, idx); + QRect displayed_text = view->visualRect(idx); bool is_elided = displayed_text.width() < real_text.width(); if (is_elided) { QToolTip::showText(he->globalPos(), text, view); diff --git a/src/playlist/playlistdelegates.h b/src/playlist/playlistdelegates.h index 1d29ec83..b8147543 100644 --- a/src/playlist/playlistdelegates.h +++ b/src/playlist/playlistdelegates.h @@ -60,10 +60,10 @@ class QueuedItemDelegate : public QStyledItemDelegate { public: explicit QueuedItemDelegate(QObject *parent, int indicator_column = Playlist::Column_Title); - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; - void DrawBox(QPainter *painter, const QRect &line_rect, const QFont &font, const QString &text, int width = -1) const; + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override; + void DrawBox(QPainter *painter, const QRect &line_rect, const QFont &font, const QString &idx, int width = -1) const; - int queue_indicator_size(const QModelIndex &index) const; + int queue_indicator_size(const QModelIndex &idx) const; private: static const int kQueueBoxBorder; @@ -83,16 +83,16 @@ class PlaylistDelegateBase : public QueuedItemDelegate { public: explicit PlaylistDelegateBase(QObject *parent, const QString &suffix = QString()); - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override; QString displayText(const QVariant &value, const QLocale &locale) const override; - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &idx) const override; - QStyleOptionViewItem Adjusted(const QStyleOptionViewItem &option, const QModelIndex &index) const; + QStyleOptionViewItem Adjusted(const QStyleOptionViewItem &option, const QModelIndex &idx) const; static const int kMinHeight; public slots: - bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index) override; + bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &idx) override; protected: QTreeView *view_; @@ -161,7 +161,7 @@ class TagCompletionItemDelegate : public PlaylistDelegateBase { public: explicit TagCompletionItemDelegate(QObject *parent, CollectionBackend *backend, Playlist::Column column) : PlaylistDelegateBase(parent), backend_(backend), column_(column) {}; - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &idx) const override; private: CollectionBackend *backend_; @@ -211,4 +211,4 @@ class RatingItemDelegate : public PlaylistDelegateBase { QModelIndexList selected_indexes_; }; -#endif // PLAYLISTDELEGATES_H +#endif // PLAYLISTDELEGATES_H diff --git a/src/playlist/playlistheader.cpp b/src/playlist/playlistheader.cpp index 85f5fe8a..686fabcd 100644 --- a/src/playlist/playlistheader.cpp +++ b/src/playlist/playlistheader.cpp @@ -53,10 +53,10 @@ PlaylistHeader::PlaylistHeader(Qt::Orientation orientation, PlaylistView *view, action_align_right_(nullptr) { - action_hide_ = menu_->addAction(tr("&Hide..."), this, SLOT(HideCurrent())); - action_stretch_ = menu_->addAction(tr("&Stretch columns to fit window"), this, SLOT(ToggleStretchEnabled())); - action_reset_ = menu_->addAction(tr("&Reset columns to default"), this, SLOT(ResetColumns())); - action_rating_lock_ = menu_->addAction(tr("&Lock rating"), this, SLOT(ToggleRatingEditStatus())); + action_hide_ = menu_->addAction(tr("&Hide..."), this, &PlaylistHeader::HideCurrent); + action_stretch_ = menu_->addAction(tr("&Stretch columns to fit window"), this, &PlaylistHeader::ToggleStretchEnabled); + action_reset_ = menu_->addAction(tr("&Reset columns to default"), this, &PlaylistHeader::ResetColumns); + action_rating_lock_ = menu_->addAction(tr("&Lock rating"), this, &PlaylistHeader::ToggleRatingEditStatus); action_rating_lock_->setCheckable(true); menu_->addSeparator(); @@ -71,7 +71,7 @@ PlaylistHeader::PlaylistHeader(Qt::Orientation orientation, PlaylistView *view, action_align_right_->setCheckable(true); align_menu->addActions(align_group->actions()); - connect(align_group, SIGNAL(triggered(QAction*)), SLOT(SetColumnAlignment(QAction*))); + QObject::connect(align_group, &QActionGroup::triggered, this, &PlaylistHeader::SetColumnAlignment); menu_->addMenu(align_menu); menu_->addSeparator(); @@ -79,7 +79,7 @@ PlaylistHeader::PlaylistHeader(Qt::Orientation orientation, PlaylistView *view, action_stretch_->setCheckable(true); action_stretch_->setChecked(is_stretch_enabled()); - connect(this, SIGNAL(StretchEnabledChanged(bool)), action_stretch_, SLOT(setChecked(bool))); + QObject::connect(this, &PlaylistHeader::StretchEnabledChanged, action_stretch_, &QAction::setChecked); QSettings s; s.beginGroup(PlaylistSettingsPage::kSettingsGroup); @@ -135,7 +135,7 @@ void PlaylistHeader::AddColumnAction(int index) { action->setChecked(!isSectionHidden(index)); show_actions_ << action; - connect(action, &QAction::triggered, [this, index]() { ToggleVisible(index); } ); + QObject::connect(action, &QAction::triggered, [this, index]() { ToggleVisible(index); } ); } @@ -157,7 +157,7 @@ void PlaylistHeader::SetColumnAlignment(QAction *action) { } -void PlaylistHeader::ToggleVisible(int section) { +void PlaylistHeader::ToggleVisible(const int section) { SetSectionHidden(section, !isSectionHidden(section)); emit SectionVisibilityChanged(section, !isSectionHidden(section)); } diff --git a/src/playlist/playlistheader.h b/src/playlist/playlistheader.h index 530a57dc..a3be2178 100644 --- a/src/playlist/playlistheader.h +++ b/src/playlist/playlistheader.h @@ -59,7 +59,7 @@ class PlaylistHeader : public StretchHeaderView { private slots: void HideCurrent(); - void ToggleVisible(int section); + void ToggleVisible(const int section); void ResetColumns(); void SetColumnAlignment(QAction *action); void ToggleRatingEditStatus(); @@ -84,4 +84,3 @@ class PlaylistHeader : public StretchHeaderView { }; #endif // PLAYLISTHEADER_H - diff --git a/src/playlist/playlistitem.h b/src/playlist/playlistitem.h index fe5fc295..9cd1c90e 100644 --- a/src/playlist/playlistitem.h +++ b/src/playlist/playlistitem.h @@ -69,7 +69,7 @@ class PlaylistItem : public std::enable_shared_from_this { virtual QList actions() { return QList(); } virtual bool InitFromQuery(const SqlRow &query) = 0; - void BindToQuery(QSqlQuery* query) const; + void BindToQuery(QSqlQuery *query) const; virtual void Reload() {} QFuture BackgroundReload(); @@ -135,4 +135,3 @@ Q_DECLARE_METATYPE(QList) Q_DECLARE_OPERATORS_FOR_FLAGS(PlaylistItem::Options) #endif // PLAYLISTITEM_H - diff --git a/src/playlist/playlistlistcontainer.cpp b/src/playlist/playlistlistcontainer.cpp index aec2b74f..dad2195c 100644 --- a/src/playlist/playlistlistcontainer.cpp +++ b/src/playlist/playlistlistcontainer.cpp @@ -109,21 +109,21 @@ PlaylistListContainer::PlaylistListContainer(QWidget *parent) ui_->remove->setDefaultAction(action_remove_); ui_->save_playlist->setDefaultAction(action_save_playlist_); - connect(action_new_folder_, SIGNAL(triggered()), SLOT(NewFolderClicked())); - connect(action_remove_, SIGNAL(triggered()), SLOT(Delete())); - connect(action_save_playlist_, SIGNAL(triggered()), SLOT(SavePlaylist())); + QObject::connect(action_new_folder_, &QAction::triggered, this, &PlaylistListContainer::NewFolderClicked); + QObject::connect(action_remove_, &QAction::triggered, this, &PlaylistListContainer::Delete); + QObject::connect(action_save_playlist_, &QAction::triggered, this, &PlaylistListContainer::SavePlaylist); #ifndef Q_OS_WIN - connect(action_copy_to_device_, SIGNAL(triggered()), SLOT(CopyToDevice())); + QObject::connect(action_copy_to_device_, &QAction::triggered, this, &PlaylistListContainer::CopyToDevice); #endif - connect(model_, SIGNAL(PlaylistPathChanged(int, QString)), SLOT(PlaylistPathChanged(int, QString))); + QObject::connect(model_, &PlaylistListModel::PlaylistPathChanged, this, &PlaylistListContainer::PlaylistPathChanged); proxy_->setSourceModel(model_); proxy_->setDynamicSortFilter(true); proxy_->sort(0); ui_->tree->setModel(proxy_); - connect(ui_->tree, SIGNAL(ItemsSelectedChanged(bool)), SLOT(ItemsSelectedChanged(bool))); - connect(ui_->tree, SIGNAL(doubleClicked(QModelIndex)), SLOT(ItemDoubleClicked(QModelIndex))); + QObject::connect(ui_->tree, &PlaylistListView::ItemsSelectedChanged, this, &PlaylistListContainer::ItemsSelectedChanged); + QObject::connect(ui_->tree, &PlaylistListView::doubleClicked, this, &PlaylistListContainer::ItemDoubleClicked); model_->invisibleRootItem()->setData(PlaylistListModel::Type_Folder, PlaylistListModel::Role_Type); @@ -139,17 +139,17 @@ void PlaylistListContainer::SetApplication(Application *app) { PlaylistManager *manager = app_->playlist_manager(); Player *player = app_->player(); - connect(manager, SIGNAL(PlaylistAdded(int, QString, bool)), SLOT(AddPlaylist(int, QString, bool))); - connect(manager, SIGNAL(PlaylistFavorited(int, bool)), SLOT(PlaylistFavoriteStateChanged(int, bool))); - connect(manager, SIGNAL(PlaylistRenamed(int, QString)), SLOT(PlaylistRenamed(int, QString))); - connect(manager, SIGNAL(CurrentChanged(Playlist*)), SLOT(CurrentChanged(Playlist*))); - connect(manager, SIGNAL(ActiveChanged(Playlist*)), SLOT(ActiveChanged(Playlist*))); + QObject::connect(manager, &PlaylistManager::PlaylistAdded, this, &PlaylistListContainer::AddPlaylist); + QObject::connect(manager, &PlaylistManager::PlaylistFavorited, this, &PlaylistListContainer::PlaylistFavoriteStateChanged); + QObject::connect(manager, &PlaylistManager::PlaylistRenamed, this, &PlaylistListContainer::PlaylistRenamed); + QObject::connect(manager, &PlaylistManager::CurrentChanged, this, &PlaylistListContainer::CurrentChanged); + QObject::connect(manager, &PlaylistManager::ActiveChanged, this, &PlaylistListContainer::ActiveChanged); - connect(model_, SIGNAL(PlaylistRenamed(int, QString)), manager, SLOT(Rename(int, QString))); + QObject::connect(model_, &PlaylistListModel::PlaylistRenamed, manager, &PlaylistManager::Rename); - connect(player, SIGNAL(Paused()), SLOT(ActivePaused())); - connect(player, SIGNAL(Playing()), SLOT(ActivePlaying())); - connect(player, SIGNAL(Stopped()), SLOT(ActiveStopped())); + QObject::connect(player, &Player::Paused, this, &PlaylistListContainer::ActivePaused); + QObject::connect(player, &Player::Playing, this, &PlaylistListContainer::ActivePlaying); + QObject::connect(player, &Player::Stopped, this, &PlaylistListContainer::ActiveStopped); // Get all playlists, even ones that are hidden in the UI. for (const PlaylistBackend::Playlist &p : app->playlist_backend()->GetAllFavoritePlaylists()) { diff --git a/src/playlist/playlistlistmodel.cpp b/src/playlist/playlistlistmodel.cpp index 98f2c57d..ce727b21 100644 --- a/src/playlist/playlistlistmodel.cpp +++ b/src/playlist/playlistlistmodel.cpp @@ -35,9 +35,9 @@ PlaylistListModel::PlaylistListModel(QObject *parent) : QStandardItemModel(parent), dropping_rows_(false) { - connect(this, SIGNAL(dataChanged(QModelIndex, QModelIndex)), SLOT(RowsChanged(QModelIndex, QModelIndex))); - connect(this, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), SLOT(RowsAboutToBeRemoved(QModelIndex, int, int))); - connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(RowsInserted(QModelIndex, int, int))); + QObject::connect(this,&PlaylistListModel::dataChanged, this, &PlaylistListModel::RowsChanged); + QObject::connect(this,&PlaylistListModel::rowsAboutToBeRemoved, this, &PlaylistListModel::RowsAboutToBeRemoved); + QObject::connect(this,&PlaylistListModel::rowsInserted, this, &PlaylistListModel::RowsInserted); } @@ -53,6 +53,7 @@ bool PlaylistListModel::dropMimeData(const QMimeData *data, Qt::DropAction actio dropping_rows_ = false; return ret; + } QString PlaylistListModel::ItemPath(const QStandardItem *item) const { @@ -75,7 +76,7 @@ void PlaylistListModel::RowsChanged(const QModelIndex &begin, const QModelIndex AddRowMappings(begin, end); } -void PlaylistListModel::RowsInserted(const QModelIndex &parent, int start, int end) { +void PlaylistListModel::RowsInserted(const QModelIndex &parent, const int start, const int end) { // RowsChanged will take care of these when dropping. if (!dropping_rows_) { @@ -120,7 +121,7 @@ void PlaylistListModel::AddRowItem(QStandardItem *item, const QString &parent_pa } -void PlaylistListModel::RowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) { +void PlaylistListModel::RowsAboutToBeRemoved(const QModelIndex &parent, const int start, const int end) { for (int i = start; i <= end; ++i) { const QModelIndex idx = index(i, 0, parent); @@ -143,7 +144,7 @@ void PlaylistListModel::RowsAboutToBeRemoved(const QModelIndex &parent, int star } -QStandardItem *PlaylistListModel::PlaylistById(int id) const { +QStandardItem *PlaylistListModel::PlaylistById(const int id) const { return playlists_by_id_[id]; } @@ -200,7 +201,7 @@ QStandardItem *PlaylistListModel::NewFolder(const QString &name) const { } -QStandardItem *PlaylistListModel::NewPlaylist(const QString &name, int id) const { +QStandardItem *PlaylistListModel::NewPlaylist(const QString &name, const int id) const { QStandardItem *ret = new QStandardItem; ret->setText(name); @@ -212,20 +213,20 @@ QStandardItem *PlaylistListModel::NewPlaylist(const QString &name, int id) const } -bool PlaylistListModel::setData(const QModelIndex &index, const QVariant &value, int role) { +bool PlaylistListModel::setData(const QModelIndex &idx, const QVariant &value, int role) { - if (!QStandardItemModel::setData(index, value, role)) { + if (!QStandardItemModel::setData(idx, value, role)) { return false; } - switch (index.data(Role_Type).toInt()) { + switch (idx.data(Role_Type).toInt()) { case Type_Playlist: - emit PlaylistRenamed(index.data(Role_PlaylistId).toInt(), value.toString()); + emit PlaylistRenamed(idx.data(Role_PlaylistId).toInt(), value.toString()); break; case Type_Folder: // Walk all the children and modify their paths. - UpdatePathsRecursive(index); + UpdatePathsRecursive(idx); break; } @@ -248,4 +249,3 @@ void PlaylistListModel::UpdatePathsRecursive(const QModelIndex &parent) { } } - diff --git a/src/playlist/playlistlistmodel.h b/src/playlist/playlistlistmodel.h index eb47559f..7c0c7eeb 100644 --- a/src/playlist/playlistlistmodel.h +++ b/src/playlist/playlistlistmodel.h @@ -63,7 +63,7 @@ class PlaylistListModel : public QStandardItemModel { QString ItemPath(const QStandardItem *item) const; // Finds the playlist with the given ID, returns 0 if it doesn't exist. - QStandardItem *PlaylistById(int id) const; + QStandardItem *PlaylistById(const int id) const; // Finds the folder with the given path, creating it (and its parents) if they // do not exist. Returns invisibleRootItem() if path is empty. @@ -75,19 +75,19 @@ class PlaylistListModel : public QStandardItemModel { // Returns a new playlist item with the given name and ID. The item isn't // added to the model yet. - QStandardItem *NewPlaylist(const QString &name, int id) const; + QStandardItem *NewPlaylist(const QString &name, const int id) const; // QStandardItemModel - bool setData(const QModelIndex &index, const QVariant &value, int role) override; + bool setData(const QModelIndex &idx, const QVariant &value, int role) override; -signals: - void PlaylistPathChanged(int id, const QString &new_path); - void PlaylistRenamed(int id, const QString &new_name); + signals: + void PlaylistPathChanged(int id, QString new_path); + void PlaylistRenamed(int id, QString new_name); private slots: void RowsChanged(const QModelIndex &begin, const QModelIndex &end); - void RowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); - void RowsInserted(const QModelIndex &parent, int start, int end); + void RowsAboutToBeRemoved(const QModelIndex &parent, const int start, const int end); + void RowsInserted(const QModelIndex &parent, const int start, const int end); private: void AddRowMappings(const QModelIndex &begin, const QModelIndex &end); diff --git a/src/playlist/playlistmanager.cpp b/src/playlist/playlistmanager.cpp index f19e873a..dcee9ed6 100644 --- a/src/playlist/playlistmanager.cpp +++ b/src/playlist/playlistmanager.cpp @@ -75,11 +75,12 @@ PlaylistManager::PlaylistManager(Application *app, QObject *parent) playlist_container_(nullptr), current_(-1), active_(-1), - playlists_loading_(0) -{ - connect(app_->player(), SIGNAL(Paused()), SLOT(SetActivePaused())); - connect(app_->player(), SIGNAL(Playing()), SLOT(SetActivePlaying())); - connect(app_->player(), SIGNAL(Stopped()), SLOT(SetActiveStopped())); + playlists_loading_(0) { + + QObject::connect(app_->player(), &Player::Paused, this, &PlaylistManager::SetActivePaused); + QObject::connect(app_->player(), &Player::Playing, this, &PlaylistManager::SetActivePlaying); + QObject::connect(app_->player(), &Player::Stopped, this, &PlaylistManager::SetActiveStopped); + } PlaylistManager::~PlaylistManager() { @@ -96,14 +97,14 @@ void PlaylistManager::Init(CollectionBackend *collection_backend, PlaylistBacken parser_ = new PlaylistParser(collection_backend, this); playlist_container_ = playlist_container; - connect(collection_backend_, SIGNAL(SongsDiscovered(SongList)), SLOT(SongsDiscovered(SongList))); - connect(collection_backend_, SIGNAL(SongsStatisticsChanged(SongList)), SLOT(SongsDiscovered(SongList))); - connect(collection_backend_, SIGNAL(SongsRatingChanged(SongList)), SLOT(SongsDiscovered(SongList))); + QObject::connect(collection_backend_, &CollectionBackend::SongsDiscovered, this, &PlaylistManager::SongsDiscovered); + QObject::connect(collection_backend_, &CollectionBackend::SongsStatisticsChanged, this, &PlaylistManager::SongsDiscovered); + QObject::connect(collection_backend_, &CollectionBackend::SongsRatingChanged, this, &PlaylistManager::SongsDiscovered); for (const PlaylistBackend::Playlist &p : playlist_backend->GetAllOpenPlaylists()) { ++playlists_loading_; Playlist *ret = AddPlaylist(p.id, p.name, p.special_type, p.ui_path, p.favorite); - connect(ret, SIGNAL(PlaylistLoaded()), SLOT(PlaylistLoaded())); + QObject::connect(ret, &Playlist::PlaylistLoaded, this, &PlaylistManager::PlaylistLoaded); } // If no playlist exists then make a new one @@ -117,7 +118,7 @@ void PlaylistManager::PlaylistLoaded() { Playlist *playlist = qobject_cast(sender()); if (!playlist) return; - disconnect(playlist, SIGNAL(PlaylistLoaded()), this, SLOT(PlaylistLoaded())); + QObject::disconnect(playlist, &Playlist::PlaylistLoaded, this, &PlaylistManager::PlaylistLoaded); --playlists_loading_; if (playlists_loading_ == 0) { emit AllPlaylistsLoaded(); @@ -148,15 +149,15 @@ Playlist *PlaylistManager::AddPlaylist(const int id, const QString &name, const ret->set_sequence(sequence_); ret->set_ui_path(ui_path); - connect(ret, SIGNAL(CurrentSongChanged(Song)), SIGNAL(CurrentSongChanged(Song))); - connect(ret, SIGNAL(SongMetadataChanged(Song)), SIGNAL(SongMetadataChanged(Song))); - connect(ret, SIGNAL(PlaylistChanged()), SLOT(OneOfPlaylistsChanged())); - connect(ret, SIGNAL(PlaylistChanged()), SLOT(UpdateSummaryText())); - connect(ret, SIGNAL(EditingFinished(QModelIndex)), SIGNAL(EditingFinished(QModelIndex))); - connect(ret, SIGNAL(Error(QString)), SIGNAL(Error(QString))); - connect(ret, SIGNAL(PlayRequested(QModelIndex, Playlist::AutoScroll)), SIGNAL(PlayRequested(QModelIndex, Playlist::AutoScroll))); - connect(playlist_container_->view(), SIGNAL(ColumnAlignmentChanged(ColumnAlignmentMap)), ret, SLOT(SetColumnAlignment(ColumnAlignmentMap))); - connect(app_->current_albumcover_loader(), SIGNAL(AlbumCoverLoaded(Song, AlbumCoverLoaderResult)), ret, SLOT(AlbumCoverLoaded(Song, AlbumCoverLoaderResult))); + QObject::connect(ret, &Playlist::CurrentSongChanged, this, &PlaylistManager::CurrentSongChanged); + QObject::connect(ret, &Playlist::SongMetadataChanged, this, &PlaylistManager::SongMetadataChanged); + QObject::connect(ret, &Playlist::PlaylistChanged, this, &PlaylistManager::OneOfPlaylistsChanged); + QObject::connect(ret, &Playlist::PlaylistChanged, this, &PlaylistManager::UpdateSummaryText); + QObject::connect(ret, &Playlist::EditingFinished, this, &PlaylistManager::EditingFinished); + QObject::connect(ret, &Playlist::Error, this, &PlaylistManager::Error); + QObject::connect(ret, &Playlist::PlayRequested, this, &PlaylistManager::PlayRequested); + QObject::connect(playlist_container_->view(), &PlaylistView::ColumnAlignmentChanged, ret, &Playlist::SetColumnAlignment); + QObject::connect(app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::AlbumCoverLoaded, ret, &Playlist::AlbumCoverLoaded); playlists_[id] = Data(ret, name); diff --git a/src/playlist/playlistmanager.h b/src/playlist/playlistmanager.h index d9cd8562..173b26bd 100644 --- a/src/playlist/playlistmanager.h +++ b/src/playlist/playlistmanager.h @@ -116,12 +116,12 @@ class PlaylistManagerInterface : public QObject { void PlaylistManagerInitialized(); void AllPlaylistsLoaded(); - void PlaylistAdded(const int id, QString name, const bool favorite); - void PlaylistDeleted(const int id); - void PlaylistClosed(const int id); - void PlaylistRenamed(const int id, QString new_name); - void PlaylistFavorited(const int id, const bool favorite); - void CurrentChanged(Playlist *new_playlist, const int scroll_position = 0); + void PlaylistAdded(int id, QString name, bool favorite); + void PlaylistDeleted(int id); + void PlaylistClosed(int id); + void PlaylistRenamed(int id, QString new_name); + void PlaylistFavorited(int id, bool favorite); + void CurrentChanged(Playlist *new_playlist, int scroll_position = 0); void ActiveChanged(Playlist *new_playlist); void Error(QString message); @@ -161,7 +161,7 @@ class PlaylistManager : public PlaylistManagerInterface { bool IsPlaylistOpen(const int id); // Returns a pretty automatic name for playlist created from the given list of songs. - static QString GetNameForNewPlaylist(const SongList& songs); + static QString GetNameForNewPlaylist(const SongList &songs); QItemSelection selection(const int id) const override; QItemSelection current_selection() const override { return selection(current_id()); } @@ -189,7 +189,7 @@ class PlaylistManager : public PlaylistManagerInterface { void Delete(const int id) override; bool Close(const int id) override; void Open(const int id) override; - void ChangePlaylistOrder(const QList& ids) override; + void ChangePlaylistOrder(const QList &ids) override; void SetCurrentPlaylist(const int id) override; void SetActivePlaylist(const int id) override; @@ -208,8 +208,8 @@ class PlaylistManager : public PlaylistManagerInterface { void SongChangeRequestProcessed(const QUrl& url, const bool valid) override; - void InsertUrls(const int id, const QList& urls, const int pos = -1, const bool play_now = false, const bool enqueue = false); - void InsertSongs(const int id, const SongList& songs, const int pos = -1, const bool play_now = false, const bool enqueue = false); + void InsertUrls(const int id, const QList &urls, const int pos = -1, const bool play_now = false, const bool enqueue = false); + void InsertSongs(const int id, const SongList &songs, const int pos = -1, const bool play_now = false, const bool enqueue = false); // Removes items with given indices from the playlist. This operation is not undoable. void RemoveItemsWithoutUndo(const int id, const QList& indices); // Remove the current playing song diff --git a/src/playlist/playlistsequence.cpp b/src/playlist/playlistsequence.cpp index 2d2d8849..2e36be73 100644 --- a/src/playlist/playlistsequence.cpp +++ b/src/playlist/playlistsequence.cpp @@ -81,8 +81,8 @@ PlaylistSequence::PlaylistSequence(QWidget *parent, SettingsProvider *settings) shuffle_menu_->addActions(shuffle_group->actions()); ui_->shuffle->setMenu(shuffle_menu_); - connect(repeat_group, SIGNAL(triggered(QAction*)), SLOT(RepeatActionTriggered(QAction*))); - connect(shuffle_group, SIGNAL(triggered(QAction*)), SLOT(ShuffleActionTriggered(QAction*))); + QObject::connect(repeat_group, &QActionGroup::triggered, this, &PlaylistSequence::RepeatActionTriggered); + QObject::connect(shuffle_group, &QActionGroup::triggered, this, &PlaylistSequence::ShuffleActionTriggered); Load(); diff --git a/src/playlist/playlistsequence.h b/src/playlist/playlistsequence.h index df46dc96..f06e6bdd 100644 --- a/src/playlist/playlistsequence.h +++ b/src/playlist/playlistsequence.h @@ -76,8 +76,8 @@ class PlaylistSequence : public QWidget { void CycleRepeatMode(); signals: - void RepeatModeChanged(const PlaylistSequence::RepeatMode mode); - void ShuffleModeChanged(const PlaylistSequence::ShuffleMode mode); + void RepeatModeChanged(PlaylistSequence::RepeatMode mode); + void ShuffleModeChanged(PlaylistSequence::ShuffleMode mode); private slots: void RepeatActionTriggered(QAction *); diff --git a/src/playlist/playlisttabbar.cpp b/src/playlist/playlisttabbar.cpp index bfa620b9..0db1bb7d 100644 --- a/src/playlist/playlisttabbar.cpp +++ b/src/playlist/playlisttabbar.cpp @@ -70,19 +70,19 @@ PlaylistTabBar::PlaylistTabBar(QWidget *parent) setUsesScrollButtons(true); setTabsClosable(true); - close_ = menu_->addAction(IconLoader::Load("list-remove"), tr("Close playlist"), this, SLOT(Close())); - rename_ = menu_->addAction(IconLoader::Load("edit-rename"), tr("Rename playlist..."), this, SLOT(Rename())); - save_ = menu_->addAction(IconLoader::Load("document-save"), tr("Save playlist..."), this, SLOT(Save())); + close_ = menu_->addAction(IconLoader::Load("list-remove"), tr("Close playlist"), this, &PlaylistTabBar::Close); + rename_ = menu_->addAction(IconLoader::Load("edit-rename"), tr("Rename playlist..."), this, &PlaylistTabBar::RenameSlot); + save_ = menu_->addAction(IconLoader::Load("document-save"), tr("Save playlist..."), this, &PlaylistTabBar::Save); menu_->addSeparator(); rename_editor_->setVisible(false); - connect(rename_editor_, SIGNAL(editingFinished()), SLOT(RenameInline())); - connect(rename_editor_, SIGNAL(EditingCanceled()), SLOT(HideEditor())); + QObject::connect(rename_editor_, &RenameTabLineEdit::editingFinished, this, &PlaylistTabBar::RenameInline); + QObject::connect(rename_editor_, &RenameTabLineEdit::EditingCanceled, this, &PlaylistTabBar::HideEditor); - connect(this, SIGNAL(currentChanged(int)), SLOT(CurrentIndexChanged(int))); - connect(this, SIGNAL(tabMoved(int, int)), SLOT(TabMoved())); + QObject::connect(this, &PlaylistTabBar::currentChanged, this, &PlaylistTabBar::CurrentIndexChanged); + QObject::connect(this, &PlaylistTabBar::tabMoved, this, &PlaylistTabBar::TabMoved); // We can't just emit Close signal, we need to extract the playlist id first - connect(this, SIGNAL(tabCloseRequested(int)), SLOT(CloseFromTabIndex(int))); + QObject::connect(this, &PlaylistTabBar::tabCloseRequested, this, &PlaylistTabBar::CloseFromTabIndex); } @@ -98,8 +98,8 @@ void PlaylistTabBar::SetActions(QAction *new_playlist, QAction *load_playlist) { void PlaylistTabBar::SetManager(PlaylistManager *manager) { manager_ = manager; - connect(manager_, SIGNAL(PlaylistFavorited(int, bool)), SLOT(PlaylistFavoritedSlot(int, bool))); - connect(manager_, SIGNAL(PlaylistManagerInitialized()), this, SLOT(PlaylistManagerInitialized())); + QObject::connect(manager_, &PlaylistManager::PlaylistFavorited, this, &PlaylistTabBar::PlaylistFavoritedSlot); + QObject::connect(manager_, &PlaylistManager::PlaylistManagerInitialized, this, &PlaylistTabBar::PlaylistManagerInitialized); } @@ -107,7 +107,7 @@ void PlaylistTabBar::PlaylistManagerInitialized() { // Signal that we are done loading and thus further changes should be committed to the db. initialized_ = true; - disconnect(manager_, SIGNAL(PlaylistManagerInitialized()), this, SLOT(PlaylistManagerInitialized())); + QObject::disconnect(manager_, &PlaylistManager::PlaylistManagerInitialized, this, &PlaylistTabBar::PlaylistManagerInitialized); } @@ -133,7 +133,7 @@ void PlaylistTabBar::mouseReleaseEvent(QMouseEvent *e) { if (e->button() == Qt::MiddleButton) { // Update menu index menu_index_ = tabAt(e->pos()); - Close(); + CloseSlot(); } QTabBar::mouseReleaseEvent(e); @@ -165,7 +165,7 @@ void PlaylistTabBar::mouseDoubleClickEvent(QMouseEvent *e) { } -void PlaylistTabBar::Rename() { +void PlaylistTabBar::RenameSlot() { if (menu_index_ == -1) return; @@ -193,7 +193,7 @@ void PlaylistTabBar::HideEditor() { } -void PlaylistTabBar::Close() { +void PlaylistTabBar::CloseSlot() { if (menu_index_ == -1) return; @@ -260,15 +260,19 @@ void PlaylistTabBar::Close() { } void PlaylistTabBar::CloseFromTabIndex(int index) { + // Update the global index menu_index_ = index; - Close(); + CloseSlot(); + } -void PlaylistTabBar::Save() { +void PlaylistTabBar::SaveSlot() { + if (menu_index_ == -1) return; emit Save(tabData(menu_index_).toInt()); + } int PlaylistTabBar::current_id() const { @@ -276,7 +280,7 @@ int PlaylistTabBar::current_id() const { return tabData(currentIndex()).toInt(); } -int PlaylistTabBar::index_of(int id) const { +int PlaylistTabBar::index_of(const int id) const { for (int i = 0; i < count(); ++i) { if (tabData(i).toInt() == id) { @@ -287,9 +291,9 @@ int PlaylistTabBar::index_of(int id) const { } -void PlaylistTabBar::set_current_id(int id) { setCurrentIndex(index_of(id)); } +void PlaylistTabBar::set_current_id(const int id) { setCurrentIndex(index_of(id)); } -int PlaylistTabBar::id_of(int index) const { +int PlaylistTabBar::id_of(const int index) const { if (index < 0 || index >= count()) { qLog(Warning) << "Playlist tab index requested is out of bounds!"; @@ -299,34 +303,32 @@ int PlaylistTabBar::id_of(int index) const { } -void PlaylistTabBar::set_icon_by_id(int id, const QIcon &icon) { +void PlaylistTabBar::set_icon_by_id(const int id, const QIcon &icon) { setTabIcon(index_of(id), icon); } -void PlaylistTabBar::RemoveTab(int id) { +void PlaylistTabBar::RemoveTab(const int id) { removeTab(index_of(id)); } -void PlaylistTabBar::set_text_by_id(int id, const QString &text) { +void PlaylistTabBar::set_text_by_id(const int id, const QString &text) { setTabText(index_of(id), text); setTabToolTip(index_of(id), text); } -void PlaylistTabBar::CurrentIndexChanged(int index) { +void PlaylistTabBar::CurrentIndexChanged(const int index) { if (!suppress_current_changed_) emit CurrentIdChanged(tabData(index).toInt()); } -void PlaylistTabBar::InsertTab(int id, int index, const QString &text, bool favorite) { +void PlaylistTabBar::InsertTab(const int id, const int index, const QString &text, const bool favorite) { suppress_current_changed_ = true; insertTab(index, text); setTabData(index, id); setTabToolTip(index, text); FavoriteWidget *widget = new FavoriteWidget(id, favorite); - widget->setToolTip( - tr("Click here to favorite this playlist so it will be saved and remain accessible" - "through the \"Playlists\" panel on the left side bar")); - connect(widget, SIGNAL(FavoriteStateChanged(int, bool)), SIGNAL(PlaylistFavorited(int, bool))); + widget->setToolTip(tr("Click here to favorite this playlist so it will be saved and remain accessible through the \"Playlists\" panel on the left side bar")); + QObject::connect(widget, &FavoriteWidget::FavoriteStateChanged, this, &PlaylistTabBar::PlaylistFavorited); setTabButton(index, QTabBar::LeftSide, widget); suppress_current_changed_ = false; @@ -337,6 +339,7 @@ void PlaylistTabBar::InsertTab(int id, int index, const QString &text, bool favo // Update playlist tab order/visibility TabMoved(); } + } void PlaylistTabBar::TabMoved() { @@ -434,7 +437,7 @@ bool PlaylistTabBar::event(QEvent *e) { } -void PlaylistTabBar::PlaylistFavoritedSlot(int id, bool favorite) { +void PlaylistTabBar::PlaylistFavoritedSlot(const int id, const bool favorite) { const int index = index_of(id); FavoriteWidget *favorite_widget = qobject_cast(tabButton(index, QTabBar::LeftSide)); diff --git a/src/playlist/playlisttabbar.h b/src/playlist/playlisttabbar.h index a982e58e..8ae3cc97 100644 --- a/src/playlist/playlisttabbar.h +++ b/src/playlist/playlisttabbar.h @@ -58,24 +58,24 @@ class PlaylistTabBar : public QTabBar { void SetManager(PlaylistManager *manager); // We use IDs to refer to tabs so the tabs can be moved around (and their indexes change). - int index_of(int id) const; + int index_of(const int id) const; int current_id() const; int id_of(int index) const; // Utility functions that use IDs rather than indexes - void set_current_id(int id); - void set_icon_by_id(int id, const QIcon &icon); - void set_text_by_id(int id, const QString &text); + void set_current_id(const int id); + void set_icon_by_id(const int id, const QIcon &icon); + void set_text_by_id(const int id, const QString &text); - void RemoveTab(int id); - void InsertTab(int id, int index, const QString &text, bool favorite); + void RemoveTab(const int id); + void InsertTab(const int id, const int index, const QString &text, const bool favorite); signals: void CurrentIdChanged(int id); - void Rename(int id, const QString &name); + void Rename(int id, QString name); void Close(int id); void Save(int id); - void PlaylistOrderChanged(const QList &ids); + void PlaylistOrderChanged(QList ids); void PlaylistFavorited(int id, bool favorite); protected: @@ -90,18 +90,18 @@ class PlaylistTabBar : public QTabBar { bool event(QEvent *e) override; private slots: - void CurrentIndexChanged(int index); - void Rename(); + void CurrentIndexChanged(const int index); + void RenameSlot(); void RenameInline(); void HideEditor(); - void Close(); - void CloseFromTabIndex(int index); + void CloseSlot(); + void CloseFromTabIndex(const int index); // Used when playlist's favorite flag isn't changed from the favorite widget (e.g. from the playlistlistcontainer): will update the favorite widget - void PlaylistFavoritedSlot(int id, bool favorite); + void PlaylistFavoritedSlot(const int id, const bool favorite); // Used to signal that the playlist manager is done starting up void PlaylistManagerInitialized(); void TabMoved(); - void Save(); + void SaveSlot(); private: PlaylistManager *manager_; diff --git a/src/playlist/playlistundocommands.h b/src/playlist/playlistundocommands.h index de44b9d9..8e413c2b 100644 --- a/src/playlist/playlistundocommands.h +++ b/src/playlist/playlistundocommands.h @@ -120,6 +120,7 @@ namespace PlaylistUndoCommands { public: explicit ShuffleItems(Playlist *playlist, const PlaylistItemList &new_items); }; -} //namespace + +} // namespace #endif // PLAYLISTUNDOCOMMANDS_H diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index 80b63d3b..70c16814 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -192,22 +192,22 @@ PlaylistView::PlaylistView(QWidget *parent) setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); #endif - connect(header_, SIGNAL(sectionResized(int, int, int)), SLOT(SetHeaderState())); - connect(header_, SIGNAL(sectionMoved(int, int, int)), SLOT(SetHeaderState())); - connect(header_, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), SLOT(SetHeaderState())); - connect(header_, SIGNAL(SectionVisibilityChanged(int, bool)), SLOT(SetHeaderState())); + QObject::connect(header_, &PlaylistHeader::sectionResized, this, &PlaylistView::SetHeaderState); + QObject::connect(header_, &PlaylistHeader::sectionMoved, this, &PlaylistView::SetHeaderState); + QObject::connect(header_, &PlaylistHeader::sortIndicatorChanged, this, &PlaylistView::SetHeaderState); + QObject::connect(header_, &PlaylistHeader::SectionVisibilityChanged, this, &PlaylistView::SetHeaderState); - connect(header_, SIGNAL(sectionResized(int, int, int)), SLOT(InvalidateCachedCurrentPixmap())); - connect(header_, SIGNAL(sectionMoved(int, int, int)), SLOT(InvalidateCachedCurrentPixmap())); - connect(header_, SIGNAL(SectionVisibilityChanged(int, bool)), SLOT(InvalidateCachedCurrentPixmap())); - connect(header_, SIGNAL(StretchEnabledChanged(bool)), SLOT(StretchChanged(bool))); + QObject::connect(header_, &PlaylistHeader::sectionResized, this, &PlaylistView::InvalidateCachedCurrentPixmap); + QObject::connect(header_, &PlaylistHeader::sectionMoved, this, &PlaylistView::InvalidateCachedCurrentPixmap); + QObject::connect(header_, &PlaylistHeader::SectionVisibilityChanged, this, &PlaylistView::InvalidateCachedCurrentPixmap); + QObject::connect(header_, &PlaylistHeader::StretchEnabledChanged, this, &PlaylistView::StretchChanged); - connect(header_, SIGNAL(SectionRatingLockStatusChanged(bool)), SLOT(SetRatingLockStatus(bool))); - connect(header_, SIGNAL(MouseEntered()), SLOT(RatingHoverOut())); + QObject::connect(header_, &PlaylistHeader::SectionRatingLockStatusChanged, this, &PlaylistView::SetRatingLockStatus); + QObject::connect(header_, &PlaylistHeader::MouseEntered, this, &PlaylistView::RatingHoverOut); inhibit_autoscroll_timer_->setInterval(kAutoscrollGraceTimeout * 1000); inhibit_autoscroll_timer_->setSingleShot(true); - connect(inhibit_autoscroll_timer_, SIGNAL(timeout()), SLOT(InhibitAutoscrollTimeout())); + QObject::connect(inhibit_autoscroll_timer_, &QTimer::timeout, this, &PlaylistView::InhibitAutoscrollTimeout); horizontalScrollBar()->installEventFilter(this); verticalScrollBar()->installEventFilter(this); @@ -218,7 +218,7 @@ PlaylistView::PlaylistView(QWidget *parent) device_pixel_ratio_ = devicePixelRatioF(); // For fading - connect(fade_animation_, SIGNAL(valueChanged(qreal)), SLOT(FadePreviousBackgroundImage(qreal))); + QObject::connect(fade_animation_, &QTimeLine::valueChanged, this, &PlaylistView::FadePreviousBackgroundImage); fade_animation_->setDirection(QTimeLine::Backward); // 1.0 -> 0.0 } @@ -234,11 +234,11 @@ void PlaylistView::Init(Application *app) { SetItemDelegates(); - connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), this, SLOT(SongChanged(Song))); - connect(app_->current_albumcover_loader(), SIGNAL(AlbumCoverLoaded(Song, AlbumCoverLoaderResult)), SLOT(AlbumCoverLoaded(Song, AlbumCoverLoaderResult))); - connect(app_->player(), SIGNAL(Playing()), SLOT(StartGlowing())); - connect(app_->player(), SIGNAL(Paused()), SLOT(StopGlowing())); - connect(app_->player(), SIGNAL(Stopped()), SLOT(Stopped())); + QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &PlaylistView::SongChanged); + QObject::connect(app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::AlbumCoverLoaded, this, &PlaylistView::AlbumCoverLoaded); + QObject::connect(app_->player(), &Player::Playing, this, &PlaylistView::StartGlowing); + QObject::connect(app_->player(), &Player::Paused, this, &PlaylistView::StopGlowing); + QObject::connect(app_->player(), &Player::Stopped, this, &PlaylistView::Stopped); } @@ -281,8 +281,8 @@ void PlaylistView::SetItemDelegates() { void PlaylistView::setModel(QAbstractItemModel *m) { if (model()) { - disconnect(model(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(InvalidateCachedCurrentPixmap())); - disconnect(model(), SIGNAL(layoutAboutToBeChanged()), this, SLOT(RatingHoverOut())); + QObject::disconnect(model(), &QAbstractItemModel::dataChanged, this, &PlaylistView::InvalidateCachedCurrentPixmap); + QObject::disconnect(model(), &QAbstractItemModel::layoutAboutToBeChanged, this, &PlaylistView::RatingHoverOut); // When changing the model, always invalidate the current pixmap. // If a remote client uses "stop after", without invaliding the stop mark would not appear. @@ -291,22 +291,22 @@ void PlaylistView::setModel(QAbstractItemModel *m) { QTreeView::setModel(m); - connect(model(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(InvalidateCachedCurrentPixmap())); - connect(model(), SIGNAL(layoutAboutToBeChanged()), this, SLOT(RatingHoverOut())); + QObject::connect(model(), &QAbstractItemModel::dataChanged, this, &PlaylistView::InvalidateCachedCurrentPixmap); + QObject::connect(model(), &QAbstractItemModel::layoutAboutToBeChanged, this, &PlaylistView::RatingHoverOut); } void PlaylistView::SetPlaylist(Playlist *playlist) { if (playlist_) { - disconnect(playlist_, SIGNAL(MaybeAutoscroll(Playlist::AutoScroll)), this, SLOT(MaybeAutoscroll(Playlist::AutoScroll))); - disconnect(playlist_, SIGNAL(destroyed()), this, SLOT(PlaylistDestroyed())); - disconnect(playlist_, SIGNAL(QueueChanged()), this, SLOT(update())); + QObject::disconnect(playlist_, &Playlist::MaybeAutoscroll, this, &PlaylistView::MaybeAutoscroll); + QObject::disconnect(playlist_, &Playlist::destroyed, this, &PlaylistView::PlaylistDestroyed); + QObject::disconnect(playlist_, &Playlist::QueueChanged, this, &PlaylistView::Update); - disconnect(playlist_, SIGNAL(DynamicModeChanged(bool)), this, SLOT(DynamicModeChanged(bool))); - disconnect(dynamic_controls_, SIGNAL(Expand()), playlist_, SLOT(ExpandDynamicPlaylist())); - disconnect(dynamic_controls_, SIGNAL(Repopulate()), playlist_, SLOT(RepopulateDynamicPlaylist())); - disconnect(dynamic_controls_, SIGNAL(TurnOff()), playlist_, SLOT(TurnOffDynamicPlaylist())); + QObject::disconnect(playlist_, &Playlist::DynamicModeChanged, this, &PlaylistView::DynamicModeChanged); + QObject::disconnect(dynamic_controls_, &DynamicPlaylistControls::Expand, playlist_, &Playlist::ExpandDynamicPlaylist); + QObject::disconnect(dynamic_controls_, &DynamicPlaylistControls::Repopulate, playlist_, &Playlist::RepopulateDynamicPlaylist); + QObject::disconnect(dynamic_controls_, &DynamicPlaylistControls::TurnOff, playlist_, &Playlist::TurnOffDynamicPlaylist); } playlist_ = playlist; @@ -316,15 +316,15 @@ void PlaylistView::SetPlaylist(Playlist *playlist) { JumpToLastPlayedTrack(); playlist->set_auto_sort(auto_sort_); - connect(playlist_, SIGNAL(RestoreFinished()), SLOT(JumpToLastPlayedTrack())); - connect(playlist_, SIGNAL(MaybeAutoscroll(Playlist::AutoScroll)), SLOT(MaybeAutoscroll(Playlist::AutoScroll))); - connect(playlist_, SIGNAL(destroyed()), SLOT(PlaylistDestroyed())); - connect(playlist_, SIGNAL(QueueChanged()), SLOT(update())); + QObject::connect(playlist_, &Playlist::RestoreFinished, this, &PlaylistView::JumpToLastPlayedTrack); + QObject::connect(playlist_, &Playlist::MaybeAutoscroll, this, &PlaylistView::MaybeAutoscroll); + QObject::connect(playlist_, &Playlist::destroyed, this, &PlaylistView::PlaylistDestroyed); + QObject::connect(playlist_, &Playlist::QueueChanged, this, &PlaylistView::Update); - connect(playlist_, SIGNAL(DynamicModeChanged(bool)), SLOT(DynamicModeChanged(bool))); - connect(dynamic_controls_, SIGNAL(Expand()), playlist_, SLOT(ExpandDynamicPlaylist())); - connect(dynamic_controls_, SIGNAL(Repopulate()), playlist_, SLOT(RepopulateDynamicPlaylist())); - connect(dynamic_controls_, SIGNAL(TurnOff()), playlist_, SLOT(TurnOffDynamicPlaylist())); + QObject::connect(playlist_, &Playlist::DynamicModeChanged, this, &PlaylistView::DynamicModeChanged); + QObject::connect(dynamic_controls_, &DynamicPlaylistControls::Expand, playlist_, &Playlist::ExpandDynamicPlaylist); + QObject::connect(dynamic_controls_, &DynamicPlaylistControls::Repopulate, playlist_, &Playlist::RepopulateDynamicPlaylist); + QObject::connect(dynamic_controls_, &DynamicPlaylistControls::TurnOff, playlist_, &Playlist::TurnOffDynamicPlaylist); } diff --git a/src/playlist/playlistview.h b/src/playlist/playlistview.h index 7c24cc96..a8d48003 100644 --- a/src/playlist/playlistview.h +++ b/src/playlist/playlistview.h @@ -165,6 +165,7 @@ class PlaylistView : public QTreeView { void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint) override; private slots: + void Update() { update(); } void SetHeaderState(); void InhibitAutoscrollTimeout(); void MaybeAutoscroll(const Playlist::AutoScroll autoscroll); diff --git a/src/playlist/songloaderinserter.cpp b/src/playlist/songloaderinserter.cpp index faece99f..fc0cd47f 100644 --- a/src/playlist/songloaderinserter.cpp +++ b/src/playlist/songloaderinserter.cpp @@ -25,7 +25,6 @@ #include #include -#include "core/closure.h" #include "core/logging.h" #include "core/songloader.h" #include "core/taskmanager.h" @@ -53,9 +52,9 @@ void SongLoaderInserter::Load(Playlist *destination, int row, bool play_now, boo enqueue_ = enqueue; enqueue_next_ = enqueue_next; - connect(destination, SIGNAL(destroyed()), SLOT(DestinationDestroyed())); - connect(this, SIGNAL(PreloadFinished()), SLOT(InsertSongs())); - connect(this, SIGNAL(EffectiveLoadFinished(SongList)), destination, SLOT(UpdateItems(SongList))); + QObject::connect(destination, &Playlist::destroyed, this, &SongLoaderInserter::DestinationDestroyed); + QObject::connect(this, &SongLoaderInserter::PreloadFinished, this, &SongLoaderInserter::InsertSongs); + QObject::connect(this, &SongLoaderInserter::EffectiveLoadFinished, destination, &Playlist::UpdateItems); for (const QUrl &url : urls) { SongLoader *loader = new SongLoader(collection_, player_, this); @@ -104,8 +103,8 @@ void SongLoaderInserter::LoadAudioCD(Playlist *destination, int row, bool play_n enqueue_next_ = enqueue_next; SongLoader *loader = new SongLoader(collection_, player_, this); - NewClosure(loader, SIGNAL(AudioCDTracksLoadFinished()), this, SLOT(AudioCDTracksLoadFinished(SongLoader*)), loader); - connect(loader, SIGNAL(LoadAudioCDFinished(bool)), SLOT(AudioCDTagsLoaded(bool))); + QObject::connect(loader, &SongLoader::AudioCDTracksLoadFinished, [this, loader]() { AudioCDTracksLoadFinished(loader); }); + QObject::connect(loader, &SongLoader::LoadAudioCDFinished, this, &SongLoaderInserter::AudioCDTagsLoaded); qLog(Info) << "Loading audio CD..."; SongLoader::Result ret = loader->LoadAudioCD(); if (ret == SongLoader::Error) { diff --git a/src/playlist/songloaderinserter.h b/src/playlist/songloaderinserter.h index 33fe26a4..1976fa76 100644 --- a/src/playlist/songloaderinserter.h +++ b/src/playlist/songloaderinserter.h @@ -47,9 +47,9 @@ class SongLoaderInserter : public QObject { void LoadAudioCD(Playlist *destination, int row, bool play_now, bool enqueue, bool enqueue_next); signals: - void Error(const QString &message); + void Error(QString message); void PreloadFinished(); - void EffectiveLoadFinished(const SongList &songs); + void EffectiveLoadFinished(SongList songs); private slots: void DestinationDestroyed(); diff --git a/src/qobuz/qobuzbaserequest.cpp b/src/qobuz/qobuzbaserequest.cpp index bba58559..c7872aa9 100644 --- a/src/qobuz/qobuzbaserequest.cpp +++ b/src/qobuz/qobuzbaserequest.cpp @@ -76,7 +76,7 @@ QNetworkReply *QobuzBaseRequest::CreateRequest(const QString &ressource_name, co if (authenticated()) req.setRawHeader("X-User-Auth-Token", user_auth_token().toUtf8()); QNetworkReply *reply = network_->get(req); - connect(reply, SIGNAL(sslErrors(QList)), this, SLOT(HandleSSLErrors(QList))); + QObject::connect(reply, &QNetworkReply::sslErrors, this, &QobuzBaseRequest::HandleSSLErrors); qLog(Debug) << "Qobuz: Sending request" << url; diff --git a/src/qobuz/qobuzfavoriterequest.cpp b/src/qobuz/qobuzfavoriterequest.cpp index c47a80f9..6f63f9f8 100644 --- a/src/qobuz/qobuzfavoriterequest.cpp +++ b/src/qobuz/qobuzfavoriterequest.cpp @@ -45,7 +45,7 @@ QobuzFavoriteRequest::~QobuzFavoriteRequest() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } @@ -131,7 +131,7 @@ void QobuzFavoriteRequest::AddFavorites(const FavoriteType type, const SongList } QNetworkReply *reply = CreateRequest("favorite/create", params); - connect(reply, &QNetworkReply::finished, [=] { AddFavoritesReply(reply, type, songs); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, type, songs]() { AddFavoritesReply(reply, type, songs); }); replies_ << reply; } @@ -233,7 +233,7 @@ void QobuzFavoriteRequest::RemoveFavorites(const FavoriteType type, const SongLi } QNetworkReply *reply = CreateRequest("favorite/delete", params); - connect(reply, &QNetworkReply::finished, [=] { RemoveFavoritesReply(reply, type, songs); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, type, songs]() { RemoveFavoritesReply(reply, type, songs); }); replies_ << reply; } diff --git a/src/qobuz/qobuzfavoriterequest.h b/src/qobuz/qobuzfavoriterequest.h index 00306796..cfa8f3be 100644 --- a/src/qobuz/qobuzfavoriterequest.h +++ b/src/qobuz/qobuzfavoriterequest.h @@ -56,17 +56,17 @@ class QobuzFavoriteRequest : public QobuzBaseRequest { void SongsRemoved(SongList); private slots: + void AddFavoritesReply(QNetworkReply *reply, const FavoriteType type, const SongList &songs); + void RemoveFavoritesReply(QNetworkReply *reply, const FavoriteType type, const SongList &songs); + + public slots: void AddArtists(const SongList &songs); void AddAlbums(const SongList &songs); void AddSongs(const SongList &songs); - void RemoveArtists(const SongList &songs); void RemoveAlbums(const SongList &songs); void RemoveSongs(const SongList &songs); - void AddFavoritesReply(QNetworkReply *reply, const FavoriteType type, const SongList &songs); - void RemoveFavoritesReply(QNetworkReply *reply, const FavoriteType type, const SongList &songs); - private: void Error(const QString &error, const QVariant &debug = QVariant()); QString FavoriteText(const FavoriteType type); diff --git a/src/qobuz/qobuzrequest.cpp b/src/qobuz/qobuzrequest.cpp index 680372d6..80c86e21 100644 --- a/src/qobuz/qobuzrequest.cpp +++ b/src/qobuz/qobuzrequest.cpp @@ -80,14 +80,14 @@ QobuzRequest::~QobuzRequest() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); if (reply->isRunning()) reply->abort(); reply->deleteLater(); } while (!album_cover_replies_.isEmpty()) { QNetworkReply *reply = album_cover_replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); if (reply->isRunning()) reply->abort(); reply->deleteLater(); } @@ -169,7 +169,7 @@ void QobuzRequest::FlushArtistsRequests() { } if (!reply) continue; replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { ArtistsReplyReceived(reply, request.limit, request.offset); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { ArtistsReplyReceived(reply, request.limit, request.offset); }); } @@ -217,7 +217,7 @@ void QobuzRequest::FlushAlbumsRequests() { } if (!reply) continue; replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { AlbumsReplyReceived(reply, request.limit, request.offset); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { AlbumsReplyReceived(reply, request.limit, request.offset); }); } @@ -265,7 +265,7 @@ void QobuzRequest::FlushSongsRequests() { } if (!reply) continue; replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { SongsReplyReceived(reply, request.limit, request.offset); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { SongsReplyReceived(reply, request.limit, request.offset); }); } @@ -317,7 +317,7 @@ void QobuzRequest::ArtistsReplyReceived(QNetworkReply *reply, const int limit_re if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QByteArray data = GetReplyData(reply); @@ -503,7 +503,7 @@ void QobuzRequest::FlushArtistAlbumsRequests() { if (request.offset > 0) params << Param("offset", QString::number(request.offset)); QNetworkReply *reply = CreateRequest(QString("artist/get"), params); - connect(reply, &QNetworkReply::finished, [=] { ArtistAlbumsReplyReceived(reply, request.artist_id, request.offset); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { ArtistAlbumsReplyReceived(reply, request.artist_id, request.offset); }); replies_ << reply; } @@ -524,7 +524,7 @@ void QobuzRequest::AlbumsReceived(QNetworkReply *reply, const QString &artist_id if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QByteArray data = GetReplyData(reply); @@ -757,7 +757,7 @@ void QobuzRequest::FlushAlbumSongsRequests() { if (request.offset > 0) params << Param("offset", QString::number(request.offset)); QNetworkReply *reply = CreateRequest(QString("album/get"), params); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { AlbumSongsReplyReceived(reply, request.artist_id, request.album_id, request.offset, request.album_artist, request.album); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request] { AlbumSongsReplyReceived(reply, request.artist_id, request.album_id, request.offset, request.album_artist, request.album); }); } @@ -1189,7 +1189,7 @@ void QobuzRequest::FlushAlbumCoverRequests() { #endif QNetworkReply *reply = network_->get(req); album_cover_replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { AlbumCoverReceived(reply, request.url, request.filename); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { AlbumCoverReceived(reply, request.url, request.filename); }); } diff --git a/src/qobuz/qobuzrequest.h b/src/qobuz/qobuzrequest.h index 1aeff0b1..ac4679e9 100644 --- a/src/qobuz/qobuzrequest.h +++ b/src/qobuz/qobuzrequest.h @@ -61,17 +61,16 @@ class QobuzRequest : public QobuzBaseRequest { signals: void Login(); - void Login(const QString &username, const QString &password, const QString &token); + void Login(QString username, QString password, QString token); void LoginSuccess(); void LoginFailure(QString failure_reason); - void Results(const int id, const SongList &songs, const QString &error); - void UpdateStatus(const int id, const QString &text); - void ProgressSetMaximum(const int id, const int max); - void UpdateProgress(const int id, const int max); - void StreamURLFinished(const QUrl original_url, const QUrl url, const Song::FileType, QString error = QString()); + void Results(int id, SongList songs, QString error); + void UpdateStatus(int id, QString text); + void ProgressSetMaximum(int id, int max); + void UpdateProgress(int id, int max); + void StreamURLFinished(QUrl original_url, QUrl url, Song::FileType, QString error = QString()); private slots: - void ArtistsReplyReceived(QNetworkReply *reply, const int limit_requested, const int offset_requested); void AlbumsReplyReceived(QNetworkReply *reply, const int limit_requested, const int offset_requested); diff --git a/src/qobuz/qobuzservice.cpp b/src/qobuz/qobuzservice.cpp index 19ac015e..d10e8246 100644 --- a/src/qobuz/qobuzservice.cpp +++ b/src/qobuz/qobuzservice.cpp @@ -146,29 +146,29 @@ QobuzService::QobuzService(Application *app, QObject *parent) // Search timer_search_delay_->setSingleShot(true); - connect(timer_search_delay_, SIGNAL(timeout()), SLOT(StartSearch())); + QObject::connect(timer_search_delay_, &QTimer::timeout, this, &QobuzService::StartSearch); timer_login_attempt_->setSingleShot(true); - connect(timer_login_attempt_, SIGNAL(timeout()), SLOT(ResetLoginAttempts())); + QObject::connect(timer_login_attempt_, &QTimer::timeout, this, &QobuzService::ResetLoginAttempts); - connect(this, SIGNAL(Login()), SLOT(SendLogin())); - connect(this, SIGNAL(Login(QString, QString, QString)), SLOT(SendLogin(QString, QString, QString))); + QObject::connect(this, &QobuzService::Login, this, &QobuzService::SendLogin); + QObject::connect(this, &QobuzService::LoginWithCredentials, this, &QobuzService::SendLoginWithCredentials); - connect(this, SIGNAL(AddArtists(SongList)), favorite_request_, SLOT(AddArtists(SongList))); - connect(this, SIGNAL(AddAlbums(SongList)), favorite_request_, SLOT(AddAlbums(SongList))); - connect(this, SIGNAL(AddSongs(SongList)), favorite_request_, SLOT(AddSongs(SongList))); + QObject::connect(this, &QobuzService::AddArtists, favorite_request_, &QobuzFavoriteRequest::AddArtists); + QObject::connect(this, &QobuzService::AddAlbums, favorite_request_, &QobuzFavoriteRequest::AddAlbums); + QObject::connect(this, &QobuzService::AddSongs, favorite_request_, &QobuzFavoriteRequest::AddSongs); - connect(this, SIGNAL(RemoveArtists(SongList)), favorite_request_, SLOT(RemoveArtists(SongList))); - connect(this, SIGNAL(RemoveAlbums(SongList)), favorite_request_, SLOT(RemoveAlbums(SongList))); - connect(this, SIGNAL(RemoveSongs(SongList)), favorite_request_, SLOT(RemoveSongs(SongList))); + QObject::connect(this, &QobuzService::RemoveArtists, favorite_request_, &QobuzFavoriteRequest::RemoveArtists); + QObject::connect(this, &QobuzService::RemoveAlbums, favorite_request_, &QobuzFavoriteRequest::RemoveAlbums); + QObject::connect(this, &QobuzService::RemoveSongs, favorite_request_, &QobuzFavoriteRequest::RemoveSongs); - connect(favorite_request_, SIGNAL(ArtistsAdded(SongList)), artists_collection_backend_, SLOT(AddOrUpdateSongs(SongList))); - connect(favorite_request_, SIGNAL(AlbumsAdded(SongList)), albums_collection_backend_, SLOT(AddOrUpdateSongs(SongList))); - connect(favorite_request_, SIGNAL(SongsAdded(SongList)), songs_collection_backend_, SLOT(AddOrUpdateSongs(SongList))); + QObject::connect(favorite_request_, &QobuzFavoriteRequest::ArtistsAdded, artists_collection_backend_, &CollectionBackend::AddOrUpdateSongs); + QObject::connect(favorite_request_, &QobuzFavoriteRequest::AlbumsAdded, albums_collection_backend_, &CollectionBackend::AddOrUpdateSongs); + QObject::connect(favorite_request_, &QobuzFavoriteRequest::SongsAdded, songs_collection_backend_, &CollectionBackend::AddOrUpdateSongs); - connect(favorite_request_, SIGNAL(ArtistsRemoved(SongList)), artists_collection_backend_, SLOT(DeleteSongs(SongList))); - connect(favorite_request_, SIGNAL(AlbumsRemoved(SongList)), albums_collection_backend_, SLOT(DeleteSongs(SongList))); - connect(favorite_request_, SIGNAL(SongsRemoved(SongList)), songs_collection_backend_, SLOT(DeleteSongs(SongList))); + QObject::connect(favorite_request_, &QobuzFavoriteRequest::ArtistsRemoved, artists_collection_backend_, &CollectionBackend::DeleteSongs); + QObject::connect(favorite_request_, &QobuzFavoriteRequest::AlbumsRemoved, albums_collection_backend_, &CollectionBackend::DeleteSongs); + QObject::connect(favorite_request_, &QobuzFavoriteRequest::SongsRemoved, songs_collection_backend_, &CollectionBackend::DeleteSongs); ReloadSettings(); @@ -178,7 +178,7 @@ QobuzService::~QobuzService() { while (!stream_url_requests_.isEmpty()) { QobuzStreamURLRequest *stream_url_req = stream_url_requests_.takeFirst(); - disconnect(stream_url_req, 0, this, 0); + QObject::disconnect(stream_url_req, nullptr, this, nullptr); stream_url_req->deleteLater(); } @@ -192,9 +192,9 @@ void QobuzService::Exit() { wait_for_exit_ << artists_collection_backend_ << albums_collection_backend_ << songs_collection_backend_; - connect(artists_collection_backend_, SIGNAL(ExitFinished()), this, SLOT(ExitReceived())); - connect(albums_collection_backend_, SIGNAL(ExitFinished()), this, SLOT(ExitReceived())); - connect(songs_collection_backend_, SIGNAL(ExitFinished()), this, SLOT(ExitReceived())); + QObject::connect(artists_collection_backend_, &CollectionBackend::ExitFinished, this, &QobuzService::ExitReceived); + QObject::connect(albums_collection_backend_, &CollectionBackend::ExitFinished, this, &QobuzService::ExitReceived); + QObject::connect(songs_collection_backend_, &CollectionBackend::ExitFinished, this, &QobuzService::ExitReceived); artists_collection_backend_->ExitAsync(); albums_collection_backend_->ExitAsync(); @@ -205,7 +205,7 @@ void QobuzService::Exit() { void QobuzService::ExitReceived() { QObject *obj = qobject_cast(sender()); - disconnect(obj, nullptr, this, nullptr); + QObject::disconnect(obj, nullptr, this, nullptr); qLog(Debug) << obj << "successfully exited."; wait_for_exit_.removeAll(obj); if (wait_for_exit_.isEmpty()) emit ExitFinished(); @@ -245,10 +245,10 @@ void QobuzService::ReloadSettings() { } void QobuzService::SendLogin() { - SendLogin(app_id_, username_, password_); + SendLoginWithCredentials(app_id_, username_, password_); } -void QobuzService::SendLogin(const QString &app_id, const QString &username, const QString &password) { +void QobuzService::SendLoginWithCredentials(const QString &app_id, const QString &username, const QString &password) { emit UpdateStatus(tr("Authenticating...")); login_errors_.clear(); @@ -282,8 +282,8 @@ void QobuzService::SendLogin(const QString &app_id, const QString &username, con QByteArray query = url_query.toString(QUrl::FullyEncoded).toUtf8(); QNetworkReply *reply = network_->post(req, query); replies_ << reply; - connect(reply, SIGNAL(sslErrors(QList)), this, SLOT(HandleLoginSSLErrors(QList))); - connect(reply, &QNetworkReply::finished, [=] { HandleAuthReply(reply); }); + QObject::connect(reply, &QNetworkReply::sslErrors, this, &QobuzService::HandleLoginSSLErrors); + QObject::connect(reply, &QNetworkReply::finished, [this, reply]() { HandleAuthReply(reply); }); qLog(Debug) << "Qobuz: Sending request" << url << query; @@ -487,8 +487,8 @@ void QobuzService::TryLogin() { void QobuzService::ResetArtistsRequest() { if (artists_request_.get()) { - disconnect(artists_request_.get(), 0, this, 0); - disconnect(this, 0, artists_request_.get(), 0); + QObject::disconnect(artists_request_.get(), nullptr, this, nullptr); + QObject::disconnect(this, nullptr, artists_request_.get(), nullptr); artists_request_.reset(); } @@ -510,10 +510,10 @@ void QobuzService::GetArtists() { artists_request_.reset(new QobuzRequest(this, url_handler_, app_, network_, QobuzBaseRequest::QueryType_Artists, this)); - connect(artists_request_.get(), SIGNAL(Results(int, SongList, QString)), SLOT(ArtistsResultsReceived(int, SongList, QString))); - connect(artists_request_.get(), SIGNAL(UpdateStatus(int, QString)), SLOT(ArtistsUpdateStatusReceived(int, QString))); - connect(artists_request_.get(), SIGNAL(ProgressSetMaximum(int, int)), SLOT(ArtistsProgressSetMaximumReceived(int, int))); - connect(artists_request_.get(), SIGNAL(UpdateProgress(int, int)), SLOT(ArtistsUpdateProgressReceived(int, int))); + QObject::connect(artists_request_.get(), &QobuzRequest::Results, this, &QobuzService::ArtistsResultsReceived); + QObject::connect(artists_request_.get(), &QobuzRequest::UpdateStatus, this, &QobuzService::ArtistsUpdateStatusReceived); + QObject::connect(artists_request_.get(), &QobuzRequest::ProgressSetMaximum, this, &QobuzService::ArtistsProgressSetMaximumReceived); + QObject::connect(artists_request_.get(), &QobuzRequest::UpdateProgress, this, &QobuzService::ArtistsUpdateProgressReceived); artists_request_->Process(); @@ -542,8 +542,8 @@ void QobuzService::ArtistsUpdateProgressReceived(const int id, const int progres void QobuzService::ResetAlbumsRequest() { if (albums_request_.get()) { - disconnect(albums_request_.get(), 0, this, 0); - disconnect(this, 0, albums_request_.get(), 0); + QObject::disconnect(albums_request_.get(), nullptr, this, nullptr); + QObject::disconnect(this, nullptr, albums_request_.get(), nullptr); albums_request_.reset(); } @@ -563,10 +563,10 @@ void QobuzService::GetAlbums() { ResetAlbumsRequest(); albums_request_.reset(new QobuzRequest(this, url_handler_, app_, network_, QobuzBaseRequest::QueryType_Albums, this)); - connect(albums_request_.get(), SIGNAL(Results(int, SongList, QString)), SLOT(AlbumsResultsReceived(int, SongList, QString))); - connect(albums_request_.get(), SIGNAL(UpdateStatus(int, QString)), SLOT(AlbumsUpdateStatusReceived(int, QString))); - connect(albums_request_.get(), SIGNAL(ProgressSetMaximum(int, int)), SLOT(AlbumsProgressSetMaximumReceived(int, int))); - connect(albums_request_.get(), SIGNAL(UpdateProgress(int, int)), SLOT(AlbumsUpdateProgressReceived(int, int))); + QObject::connect(albums_request_.get(), &QobuzRequest::Results, this, &QobuzService::AlbumsResultsReceived); + QObject::connect(albums_request_.get(), &QobuzRequest::UpdateStatus, this, &QobuzService::AlbumsUpdateStatusReceived); + QObject::connect(albums_request_.get(), &QobuzRequest::ProgressSetMaximum, this, &QobuzService::AlbumsProgressSetMaximumReceived); + QObject::connect(albums_request_.get(), &QobuzRequest::UpdateProgress, this, &QobuzService::AlbumsUpdateProgressReceived); albums_request_->Process(); @@ -595,8 +595,8 @@ void QobuzService::AlbumsUpdateProgressReceived(const int id, const int progress void QobuzService::ResetSongsRequest() { if (songs_request_.get()) { - disconnect(songs_request_.get(), 0, this, 0); - disconnect(this, 0, songs_request_.get(), 0); + QObject::disconnect(songs_request_.get(), nullptr, this, nullptr); + QObject::disconnect(this, nullptr, songs_request_.get(), nullptr); songs_request_.reset(); } @@ -616,10 +616,10 @@ void QobuzService::GetSongs() { ResetSongsRequest(); songs_request_.reset(new QobuzRequest(this, url_handler_, app_, network_, QobuzBaseRequest::QueryType_Songs, this)); - connect(songs_request_.get(), SIGNAL(Results(int, SongList, QString)), SLOT(SongsResultsReceived(int, SongList, QString))); - connect(songs_request_.get(), SIGNAL(UpdateStatus(int, QString)), SLOT(SongsUpdateStatusReceived(int, QString))); - connect(songs_request_.get(), SIGNAL(ProgressSetMaximum(int, int)), SLOT(SongsProgressSetMaximumReceived(int, int))); - connect(songs_request_.get(), SIGNAL(UpdateProgress(int, int)), SLOT(SongsUpdateProgressReceived(int, int))); + QObject::connect(songs_request_.get(), &QobuzRequest::Results, this, &QobuzService::SongsResultsReceived); + QObject::connect(songs_request_.get(), &QobuzRequest::UpdateStatus, this, &QobuzService::SongsUpdateStatusReceived); + QObject::connect(songs_request_.get(), &QobuzRequest::ProgressSetMaximum, this, &QobuzService::SongsProgressSetMaximumReceived); + QObject::connect(songs_request_.get(), &QobuzRequest::UpdateProgress, this, &QobuzService::SongsUpdateProgressReceived); songs_request_->Process(); @@ -699,10 +699,10 @@ void QobuzService::SendSearch() { search_request_.reset(new QobuzRequest(this, url_handler_, app_, network_, type, this)); - connect(search_request_.get(), SIGNAL(Results(int, SongList, QString)), SLOT(SearchResultsReceived(int, SongList, QString))); - connect(search_request_.get(), SIGNAL(UpdateStatus(int, QString)), SIGNAL(SearchUpdateStatus(int, QString))); - connect(search_request_.get(), SIGNAL(ProgressSetMaximum(int, int)), SIGNAL(SearchProgressSetMaximum(int, int))); - connect(search_request_.get(), SIGNAL(UpdateProgress(int, int)), SIGNAL(SearchUpdateProgress(int, int))); + QObject::connect(search_request_.get(), &QobuzRequest::Results, this, &QobuzService::SearchResultsReceived); + QObject::connect(search_request_.get(), &QobuzRequest::UpdateStatus, this, &QobuzService::SearchUpdateStatus); + QObject::connect(search_request_.get(), &QobuzRequest::ProgressSetMaximum, this, &QobuzService::SearchProgressSetMaximum); + QObject::connect(search_request_.get(), &QobuzRequest::UpdateProgress, this, &QobuzService::SearchUpdateProgress); search_request_->Search(search_id_, search_text_); search_request_->Process(); @@ -723,9 +723,9 @@ void QobuzService::GetStreamURL(const QUrl &url) { QobuzStreamURLRequest *stream_url_req = new QobuzStreamURLRequest(this, network_, url, this); stream_url_requests_ << stream_url_req; - connect(stream_url_req, SIGNAL(TryLogin()), this, SLOT(TryLogin())); - connect(stream_url_req, SIGNAL(StreamURLFinished(QUrl, QUrl, Song::FileType, int, int, qint64, QString)), this, SLOT(HandleStreamURLFinished(QUrl, QUrl, Song::FileType, int, int, qint64, QString))); - connect(this, SIGNAL(LoginComplete(bool, QString)), stream_url_req, SLOT(LoginComplete(bool, QString))); + QObject::connect(stream_url_req, &QobuzStreamURLRequest::TryLogin, this, &QobuzService::TryLogin); + QObject::connect(stream_url_req, &QobuzStreamURLRequest::StreamURLFinished, this, &QobuzService::HandleStreamURLFinished); + QObject::connect(this, &QobuzService::LoginComplete, stream_url_req, &QobuzStreamURLRequest::LoginComplete); stream_url_req->Process(); diff --git a/src/qobuz/qobuzservice.h b/src/qobuz/qobuzservice.h index b2ac1b86..d457d2be 100644 --- a/src/qobuz/qobuzservice.h +++ b/src/qobuz/qobuzservice.h @@ -119,7 +119,8 @@ class QobuzService : public InternetService { public slots: void ShowConfig() override; void TryLogin(); - void SendLogin(const QString &app_id, const QString &username, const QString &password); + void SendLogin(); + void SendLoginWithCredentials(const QString &app_id, const QString &username, const QString &password); void GetArtists() override; void GetAlbums() override; void GetSongs() override; @@ -129,7 +130,6 @@ class QobuzService : public InternetService { private slots: void ExitReceived(); - void SendLogin(); void HandleLoginSSLErrors(QList ssl_errors); void HandleAuthReply(QNetworkReply *reply); void ResetLoginAttempts(); diff --git a/src/qobuz/qobuzstreamurlrequest.cpp b/src/qobuz/qobuzstreamurlrequest.cpp index 355055d7..d27eb6bd 100644 --- a/src/qobuz/qobuzstreamurlrequest.cpp +++ b/src/qobuz/qobuzstreamurlrequest.cpp @@ -57,7 +57,7 @@ QobuzStreamURLRequest::QobuzStreamURLRequest(QobuzService *service, NetworkAcces QobuzStreamURLRequest::~QobuzStreamURLRequest() { if (reply_) { - disconnect(reply_, 0, this, 0); + QObject::disconnect(reply_, nullptr, this, nullptr); if (reply_->isRunning()) reply_->abort(); reply_->deleteLater(); } @@ -110,7 +110,7 @@ void QobuzStreamURLRequest::GetStreamURL() { ++tries_; if (reply_) { - disconnect(reply_, 0, this, 0); + QObject::disconnect(reply_, nullptr, this, nullptr); if (reply_->isRunning()) reply_->abort(); reply_->deleteLater(); } @@ -152,7 +152,7 @@ void QobuzStreamURLRequest::GetStreamURL() { std::sort(params.begin(), params.end()); reply_ = CreateRequest(QString("track/getFileUrl"), params); - connect(reply_, SIGNAL(finished()), this, SLOT(StreamURLReceived())); + QObject::connect(reply_, &QNetworkReply::finished, this, &QobuzStreamURLRequest::StreamURLReceived); } @@ -162,7 +162,7 @@ void QobuzStreamURLRequest::StreamURLReceived() { QByteArray data = GetReplyData(reply_); - disconnect(reply_, 0, this, 0); + QObject::disconnect(reply_, nullptr, this, nullptr); reply_->deleteLater(); reply_ = nullptr; diff --git a/src/qobuz/qobuzstreamurlrequest.h b/src/qobuz/qobuzstreamurlrequest.h index 14166cb2..04e4ffd6 100644 --- a/src/qobuz/qobuzstreamurlrequest.h +++ b/src/qobuz/qobuzstreamurlrequest.h @@ -54,12 +54,14 @@ class QobuzStreamURLRequest : public QobuzBaseRequest { signals: void TryLogin(); - void StreamURLFinished(const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration, QString error = QString()); + void StreamURLFinished(QUrl original_url, QUrl stream_url, Song::FileType filetype, int samplerate, int bit_depth, qint64 duration, QString error = QString()); private slots: - void LoginComplete(const bool success, const QString &error = QString()); void StreamURLReceived(); + public slots: + void LoginComplete(const bool success, const QString &error = QString()); + private: void Error(const QString &error, const QVariant &debug = QVariant()); diff --git a/src/qobuz/qobuzurlhandler.cpp b/src/qobuz/qobuzurlhandler.cpp index c9086aea..aaebd897 100644 --- a/src/qobuz/qobuzurlhandler.cpp +++ b/src/qobuz/qobuzurlhandler.cpp @@ -34,7 +34,7 @@ QobuzUrlHandler::QobuzUrlHandler(Application *app, QobuzService *service) : task_id_(-1) { - connect(service, SIGNAL(StreamURLFinished(QUrl, QUrl, Song::FileType, int, int, qint64, QString)), this, SLOT(GetStreamURLFinished(QUrl, QUrl, Song::FileType, int, int, qint64, QString))); + QObject::connect(service, &QobuzService::StreamURLFinished, this, &QobuzUrlHandler::GetStreamURLFinished); } diff --git a/src/qobuz/qobuzurlhandler.h b/src/qobuz/qobuzurlhandler.h index 1e0b34ff..4d8ad9c8 100644 --- a/src/qobuz/qobuzurlhandler.h +++ b/src/qobuz/qobuzurlhandler.h @@ -52,4 +52,4 @@ class QobuzUrlHandler : public UrlHandler { }; -#endif +#endif // QOBUZURLHANDLER_H diff --git a/src/queue/queue.cpp b/src/queue/queue.cpp index f018f056..2a272184 100644 --- a/src/queue/queue.cpp +++ b/src/queue/queue.cpp @@ -46,8 +46,8 @@ const char *Queue::kRowsMimetype = "application/x-strawberry-queue-rows"; Queue::Queue(Playlist *parent) : QAbstractProxyModel(parent), playlist_(parent), total_length_ns_(0) { - signal_item_count_changed_ = connect(this, SIGNAL(ItemCountChanged(int)), SLOT(UpdateTotalLength())); - connect(this, SIGNAL(TotalLengthChanged(quint64)), SLOT(UpdateSummaryText())); + signal_item_count_changed_ = QObject::connect(this, &Queue::ItemCountChanged, this, &Queue::UpdateTotalLength); + QObject::connect(this, &Queue::TotalLengthChanged, this, &Queue::UpdateSummaryText); UpdateSummaryText(); @@ -86,16 +86,16 @@ QModelIndex Queue::mapToSource(const QModelIndex &proxy_index) const { void Queue::setSourceModel(QAbstractItemModel *source_model) { if (sourceModel()) { - disconnect(sourceModel(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(SourceDataChanged(QModelIndex, QModelIndex))); - disconnect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(SourceLayoutChanged())); - disconnect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(SourceLayoutChanged())); + QObject::disconnect(sourceModel(), &QAbstractItemModel::dataChanged, this, &Queue::SourceDataChanged); + QObject::disconnect(sourceModel(), &QAbstractItemModel::rowsRemoved, this, &Queue::SourceLayoutChanged); + QObject::disconnect(sourceModel(), &QAbstractItemModel::layoutChanged, this, &Queue::SourceLayoutChanged); } QAbstractProxyModel::setSourceModel(source_model); - connect(sourceModel(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(SourceDataChanged(QModelIndex, QModelIndex))); - connect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(SourceLayoutChanged())); - connect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(SourceLayoutChanged())); + QObject::connect(sourceModel(), &QAbstractItemModel::dataChanged, this, &Queue::SourceDataChanged); + QObject::connect(sourceModel(), &QAbstractItemModel::rowsRemoved, this, &Queue::SourceLayoutChanged); + QObject::connect(sourceModel(), &QAbstractItemModel::layoutChanged, this, &Queue::SourceLayoutChanged); } @@ -113,7 +113,7 @@ void Queue::SourceDataChanged(const QModelIndex &top_left, const QModelIndex &bo void Queue::SourceLayoutChanged() { - disconnect(signal_item_count_changed_); + QObject::disconnect(signal_item_count_changed_); for (int i = 0; i < source_indexes_.count(); ++i) { if (!source_indexes_[i].isValid()) { @@ -124,7 +124,7 @@ void Queue::SourceLayoutChanged() { } } - signal_item_count_changed_ = connect(this, SIGNAL(ItemCountChanged(int)), SLOT(UpdateTotalLength())); + signal_item_count_changed_ = QObject::connect(this, &Queue::ItemCountChanged, this, &Queue::UpdateTotalLength); emit ItemCountChanged(this->ItemCount()); @@ -332,10 +332,10 @@ QMimeData *Queue::mimeData(const QModelIndexList &indexes) const { QMimeData *data = new QMimeData; QList rows; - for (const QModelIndex &index : indexes) { - if (index.column() != 0) continue; + for (const QModelIndex &idx : indexes) { + if (idx.column() != 0) continue; - rows << index.row(); + rows << idx.row(); } QBuffer buf; @@ -402,11 +402,11 @@ bool Queue::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, } -Qt::ItemFlags Queue::flags(const QModelIndex &index) const { +Qt::ItemFlags Queue::flags(const QModelIndex &idx) const { Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable; - if (index.isValid()) + if (idx.isValid()) flags |= Qt::ItemIsDragEnabled; else flags |= Qt::ItemIsDropEnabled; diff --git a/src/queue/queue.h b/src/queue/queue.h index 871f4707..699fb5b6 100644 --- a/src/queue/queue.h +++ b/src/queue/queue.h @@ -76,15 +76,15 @@ class Queue : public QAbstractProxyModel { Qt::DropActions supportedDropActions() const override; QMimeData *mimeData(const QModelIndexList &indexes) const override; bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; - Qt::ItemFlags flags(const QModelIndex &index) const override; + Qt::ItemFlags flags(const QModelIndex &idx) const override; public slots: void UpdateSummaryText(); signals: - void TotalLengthChanged(const quint64 length); - void ItemCountChanged(const int count); - void SummaryTextChanged(const QString& message); + void TotalLengthChanged(quint64 length); + void ItemCountChanged(int count); + void SummaryTextChanged(QString message); private slots: void SourceDataChanged(const QModelIndex &top_left, const QModelIndex &bottom_right); diff --git a/src/queue/queueview.cpp b/src/queue/queueview.cpp index 19e20de4..145d73d9 100644 --- a/src/queue/queueview.cpp +++ b/src/queue/queueview.cpp @@ -61,10 +61,10 @@ QueueView::QueueView(QWidget *parent) ui_->remove->setShortcut(QKeySequence::Delete); // Button connections - connect(ui_->move_down, SIGNAL(clicked()), SLOT(MoveDown())); - connect(ui_->move_up, SIGNAL(clicked()), SLOT(MoveUp())); - connect(ui_->remove, SIGNAL(clicked()), SLOT(Remove())); - connect(ui_->clear, SIGNAL(clicked()), SLOT(Clear())); + QObject::connect(ui_->move_down, &QToolButton::clicked, this, &QueueView::MoveDown); + QObject::connect(ui_->move_up, &QToolButton::clicked, this, &QueueView::MoveUp); + QObject::connect(ui_->remove, &QToolButton::clicked, this, &QueueView::Remove); + QObject::connect(ui_->clear, &QToolButton::clicked, this, &QueueView::Clear); ReloadSettings(); @@ -78,7 +78,7 @@ void QueueView::SetPlaylistManager(PlaylistManager *manager) { playlists_ = manager; - connect(playlists_, SIGNAL(CurrentChanged(Playlist*)), SLOT(CurrentPlaylistChanged(Playlist*))); + QObject::connect(playlists_, &PlaylistManager::CurrentChanged, this, &QueueView::CurrentPlaylistChanged); CurrentPlaylistChanged(playlists_->current()); } @@ -100,27 +100,27 @@ void QueueView::ReloadSettings() { void QueueView::CurrentPlaylistChanged(Playlist *playlist) { if (current_playlist_) { - disconnect(current_playlist_->queue(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(UpdateButtonState())); - disconnect(current_playlist_->queue(), SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(UpdateButtonState())); - disconnect(current_playlist_->queue(), SIGNAL(layoutChanged()), this, SLOT(UpdateButtonState())); - disconnect(current_playlist_->queue(), SIGNAL(SummaryTextChanged(QString)), ui_->summary, SLOT(setText(QString))); - disconnect(current_playlist_, SIGNAL(destroyed()), this, SLOT(PlaylistDestroyed())); + QObject::disconnect(current_playlist_->queue(), &Queue::rowsInserted, this, &QueueView::UpdateButtonState); + QObject::disconnect(current_playlist_->queue(), &Queue::rowsRemoved, this, &QueueView::UpdateButtonState); + QObject::disconnect(current_playlist_->queue(), &Queue::layoutChanged, this, &QueueView::UpdateButtonState); + QObject::disconnect(current_playlist_->queue(), &Queue::SummaryTextChanged, ui_->summary, &QLabel::setText); + QObject::disconnect(current_playlist_, &Playlist::destroyed, this, &QueueView::PlaylistDestroyed); } current_playlist_ = playlist; - connect(current_playlist_->queue(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(UpdateButtonState())); - connect(current_playlist_->queue(), SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(UpdateButtonState())); - connect(current_playlist_->queue(), SIGNAL(layoutChanged()), this, SLOT(UpdateButtonState())); - connect(current_playlist_->queue(), SIGNAL(SummaryTextChanged(QString)), ui_->summary, SLOT(setText(QString))); - connect(current_playlist_, SIGNAL(destroyed()), this, SLOT(PlaylistDestroyed())); + QObject::connect(current_playlist_->queue(), &Queue::rowsInserted, this, &QueueView::UpdateButtonState); + QObject::connect(current_playlist_->queue(), &Queue::rowsRemoved, this, &QueueView::UpdateButtonState); + QObject::connect(current_playlist_->queue(), &Queue::layoutChanged, this, &QueueView::UpdateButtonState); + QObject::connect(current_playlist_->queue(), &Queue::SummaryTextChanged, ui_->summary, &QLabel::setText); + QObject::connect(current_playlist_, &Playlist::destroyed, this, &QueueView::PlaylistDestroyed); ui_->list->setModel(current_playlist_->queue()); - connect(ui_->list->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(UpdateButtonState())); - connect(ui_->list->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), SLOT(UpdateButtonState())); + QObject::connect(ui_->list->selectionModel(), &QItemSelectionModel::currentChanged, this, &QueueView::UpdateButtonState); + QObject::connect(ui_->list->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QueueView::UpdateButtonState); - QTimer::singleShot(0, current_playlist_->queue(), SLOT(UpdateSummaryText())); + QTimer::singleShot(0, current_playlist_->queue(), &Queue::UpdateSummaryText); } @@ -131,8 +131,8 @@ void QueueView::MoveUp() { if (indexes.isEmpty() || indexes.first().row() == 0) return; - for (const QModelIndex &index : indexes) { - current_playlist_->queue()->MoveUp(index.row()); + for (const QModelIndex &idx : indexes) { + current_playlist_->queue()->MoveUp(idx.row()); } } @@ -159,8 +159,8 @@ void QueueView::Remove() { // collect the rows to be removed QList row_list; - for (const QModelIndex &index : ui_->list->selectionModel()->selectedRows()) { - if (index.isValid()) row_list << index.row(); + for (const QModelIndex &idx : ui_->list->selectionModel()->selectedRows()) { + if (idx.isValid()) row_list << idx.row(); } current_playlist_->queue()->Remove(row_list); diff --git a/src/scrobbler/audioscrobbler.cpp b/src/scrobbler/audioscrobbler.cpp index 18c85244..b380172f 100644 --- a/src/scrobbler/audioscrobbler.cpp +++ b/src/scrobbler/audioscrobbler.cpp @@ -64,7 +64,7 @@ AudioScrobbler::AudioScrobbler(Application *app, QObject *parent) : ReloadSettings(); for (ScrobblerService *service : scrobbler_services_->List()) { - connect(service, SIGNAL(ErrorMessage(QString)), SLOT(ErrorReceived(QString))); + QObject::connect(service, &ScrobblerService::ErrorMessage, this, &AudioScrobbler::ErrorReceived); } } diff --git a/src/scrobbler/lastfmimport.cpp b/src/scrobbler/lastfmimport.cpp index 6fcd036c..90b913fe 100644 --- a/src/scrobbler/lastfmimport.cpp +++ b/src/scrobbler/lastfmimport.cpp @@ -63,7 +63,7 @@ LastFMImport::LastFMImport(QObject *parent) : timer_flush_requests_->setInterval(kRequestsDelay); timer_flush_requests_->setSingleShot(false); - connect(timer_flush_requests_, SIGNAL(timeout()), this, SLOT(FlushRequests())); + QObject::connect(timer_flush_requests_, &QTimer::timeout, this, &LastFMImport::FlushRequests); } @@ -77,7 +77,7 @@ void LastFMImport::AbortAll() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } @@ -269,7 +269,7 @@ void LastFMImport::SendGetRecentTracksRequest(GetRecentTracksRequest request) { } QNetworkReply *reply = CreateRequest(params); - connect(reply, &QNetworkReply::finished, [=] { GetRecentTracksRequestFinished(reply, request.page); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { GetRecentTracksRequestFinished(reply, request.page); }); } @@ -277,7 +277,7 @@ void LastFMImport::GetRecentTracksRequestFinished(QNetworkReply *reply, const in if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QByteArray data = GetReplyData(reply); @@ -349,7 +349,7 @@ void LastFMImport::GetRecentTracksRequestFinished(QNetworkReply *reply, const in if (page == 0) { lastplayed_total_ = total; - UpdateTotal(); + UpdateTotalCheck(); AddGetRecentTracksRequest(1); } else { @@ -392,7 +392,7 @@ void LastFMImport::GetRecentTracksRequestFinished(QNetworkReply *reply, const in emit UpdateLastPlayed(artist, album, title, datetime.toSecsSinceEpoch()); } - UpdateProgress(); + UpdateProgressCheck(); } @@ -432,7 +432,7 @@ void LastFMImport::SendGetTopTracksRequest(GetTopTracksRequest request) { } QNetworkReply *reply = CreateRequest(params); - connect(reply, &QNetworkReply::finished, [=] { GetTopTracksRequestFinished(reply, request.page); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { GetTopTracksRequestFinished(reply, request.page); }); } @@ -440,7 +440,7 @@ void LastFMImport::GetTopTracksRequestFinished(QNetworkReply *reply, const int p if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QByteArray data = GetReplyData(reply); @@ -512,7 +512,7 @@ void LastFMImport::GetTopTracksRequestFinished(QNetworkReply *reply, const int p if (page == 0) { playcount_total_ = total; - UpdateTotal(); + UpdateTotalCheck(); AddGetTopTracksRequest(1); } else { @@ -547,7 +547,7 @@ void LastFMImport::GetTopTracksRequestFinished(QNetworkReply *reply, const int p if (playcount <= 0) continue; emit UpdatePlayCount(artist, title, playcount); - UpdateProgress(); + UpdateProgressCheck(); } @@ -563,14 +563,14 @@ void LastFMImport::GetTopTracksRequestFinished(QNetworkReply *reply, const int p } -void LastFMImport::UpdateTotal() { +void LastFMImport::UpdateTotalCheck() { if ((!playcount_ || playcount_total_ > 0) && (!lastplayed_ || lastplayed_total_ > 0)) emit UpdateTotal(lastplayed_total_, playcount_total_); } -void LastFMImport::UpdateProgress() { +void LastFMImport::UpdateProgressCheck() { emit UpdateProgress(lastplayed_received_, playcount_received_); } diff --git a/src/scrobbler/lastfmimport.h b/src/scrobbler/lastfmimport.h index c1aa6df3..612ec462 100644 --- a/src/scrobbler/lastfmimport.h +++ b/src/scrobbler/lastfmimport.h @@ -73,8 +73,8 @@ class LastFMImport : public QObject { void Error(const QString &error, const QVariant &debug = QVariant()); - void UpdateTotal(); - void UpdateProgress(); + void UpdateTotalCheck(); + void UpdateProgressCheck(); void FinishCheck(); diff --git a/src/scrobbler/listenbrainzscrobbler.cpp b/src/scrobbler/listenbrainzscrobbler.cpp index cebad3e1..9209efd5 100644 --- a/src/scrobbler/listenbrainzscrobbler.cpp +++ b/src/scrobbler/listenbrainzscrobbler.cpp @@ -76,7 +76,7 @@ ListenBrainzScrobbler::ListenBrainzScrobbler(Application *app, QObject *parent) timestamp_(0) { refresh_login_timer_.setSingleShot(true); - connect(&refresh_login_timer_, SIGNAL(timeout()), SLOT(RequestAccessToken())); + QObject::connect(&refresh_login_timer_, &QTimer::timeout, this, &ListenBrainzScrobbler::RequestNewAccessToken); ReloadSettings(); LoadSession(); @@ -87,13 +87,13 @@ ListenBrainzScrobbler::~ListenBrainzScrobbler() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } if (server_) { - disconnect(server_, nullptr, this, nullptr); + QObject::disconnect(server_, nullptr, this, nullptr); if (server_->isListening()) server_->close(); server_->deleteLater(); } @@ -159,7 +159,7 @@ void ListenBrainzScrobbler::Authenticate(const bool https) { server_ = nullptr; return; } - connect(server_, SIGNAL(Finished()), this, SLOT(RedirectArrived())); + QObject::connect(server_, &LocalRedirectServer::Finished, this, &ListenBrainzScrobbler::RedirectArrived); } QUrl redirect_url(kOAuthRedirectUrl); @@ -251,7 +251,7 @@ void ListenBrainzScrobbler::RequestAccessToken(const QUrl &redirect_url, const Q QByteArray query = url_query.toString(QUrl::FullyEncoded).toUtf8(); QNetworkReply *reply = network_->post(req, query); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { AuthenticateReplyFinished(reply); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply]() { AuthenticateReplyFinished(reply); }); } @@ -259,7 +259,7 @@ void ListenBrainzScrobbler::AuthenticateReplyFinished(QNetworkReply *reply) { if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QByteArray data; @@ -455,7 +455,7 @@ void ListenBrainzScrobbler::UpdateNowPlaying(const Song &song) { QUrl url(QString("%1/1/submit-listens").arg(kApiUrl)); QNetworkReply *reply = CreateRequest(url, doc); - connect(reply, &QNetworkReply::finished, [=] { UpdateNowPlayingRequestFinished(reply); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply]() { UpdateNowPlayingRequestFinished(reply); }); } @@ -463,7 +463,7 @@ void ListenBrainzScrobbler::UpdateNowPlayingRequestFinished(QNetworkReply *reply if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QByteArray data = GetReplyData(reply); @@ -580,7 +580,7 @@ void ListenBrainzScrobbler::Submit() { QUrl url(QString("%1/1/submit-listens").arg(kApiUrl)); QNetworkReply *reply = CreateRequest(url, doc); - connect(reply, &QNetworkReply::finished, [=] { ScrobbleRequestFinished(reply, list); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, list]() { ScrobbleRequestFinished(reply, list); }); } @@ -588,7 +588,7 @@ void ListenBrainzScrobbler::ScrobbleRequestFinished(QNetworkReply *reply, QList< if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QByteArray data = GetReplyData(reply); diff --git a/src/scrobbler/listenbrainzscrobbler.h b/src/scrobbler/listenbrainzscrobbler.h index 9709c6d8..1b54ae0f 100644 --- a/src/scrobbler/listenbrainzscrobbler.h +++ b/src/scrobbler/listenbrainzscrobbler.h @@ -78,7 +78,7 @@ class ListenBrainzScrobbler : public ScrobblerService { private slots: void RedirectArrived(); void AuthenticateReplyFinished(QNetworkReply *reply); - void RequestAccessToken(const QUrl &redirect_url = QUrl(), const QString &code = QString()); + void RequestNewAccessToken() { RequestAccessToken(); } void UpdateNowPlayingRequestFinished(QNetworkReply *reply); void ScrobbleRequestFinished(QNetworkReply *reply, QList); @@ -88,6 +88,7 @@ class ListenBrainzScrobbler : public ScrobblerService { void AuthError(const QString &error); void Error(const QString &error, const QVariant &debug = QVariant()) override; + void RequestAccessToken(const QUrl &redirect_url = QUrl(), const QString &code = QString()); void DoSubmit() override; void CheckScrobblePrevSong(); diff --git a/src/scrobbler/scrobblerservices.cpp b/src/scrobbler/scrobblerservices.cpp index 56448d36..d78fc0ee 100644 --- a/src/scrobbler/scrobblerservices.cpp +++ b/src/scrobbler/scrobblerservices.cpp @@ -57,7 +57,7 @@ void ScrobblerServices::RemoveService(ScrobblerService *service) { { QMutexLocker locker(&mutex_); scrobbler_services_.remove(service->name()); - disconnect(service, nullptr, this, nullptr); + QObject::disconnect(service, nullptr, this, nullptr); } qLog(Debug) << "Unregistered scrobbler service" << service->name(); diff --git a/src/scrobbler/scrobblingapi20.cpp b/src/scrobbler/scrobblingapi20.cpp index a9271128..18474e32 100644 --- a/src/scrobbler/scrobblingapi20.cpp +++ b/src/scrobbler/scrobblingapi20.cpp @@ -84,13 +84,13 @@ ScrobblingAPI20::~ScrobblingAPI20() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } if (server_) { - disconnect(server_, nullptr, this, nullptr); + QObject::disconnect(server_, nullptr, this, nullptr); if (server_->isListening()) server_->close(); server_->deleteLater(); } @@ -149,7 +149,7 @@ void ScrobblingAPI20::Authenticate(const bool https) { server_ = nullptr; return; } - connect(server_, SIGNAL(Finished()), this, SLOT(RedirectArrived())); + QObject::connect(server_, &LocalRedirectServer::Finished, this, &ScrobblingAPI20::RedirectArrived); } QUrlQuery redirect_url_query; @@ -252,7 +252,7 @@ void ScrobblingAPI20::RequestSession(const QString &token) { #endif QNetworkReply *reply = network()->get(req); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { AuthenticateReplyFinished(reply); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply]() { AuthenticateReplyFinished(reply); }); } @@ -260,7 +260,7 @@ void ScrobblingAPI20::AuthenticateReplyFinished(QNetworkReply *reply) { if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QByteArray data; @@ -479,7 +479,7 @@ void ScrobblingAPI20::UpdateNowPlaying(const Song &song) { params << Param("albumArtist", song.albumartist()); QNetworkReply *reply = CreateRequest(params); - connect(reply, &QNetworkReply::finished, [=] { UpdateNowPlayingRequestFinished(reply); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply]() { UpdateNowPlayingRequestFinished(reply); }); } @@ -487,7 +487,7 @@ void ScrobblingAPI20::UpdateNowPlayingRequestFinished(QNetworkReply *reply) { if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QByteArray data = GetReplyData(reply); @@ -601,7 +601,7 @@ void ScrobblingAPI20::Submit() { if (!batch_ || i <= 0) return; QNetworkReply *reply = CreateRequest(params); - connect(reply, &QNetworkReply::finished, [=] { ScrobbleRequestFinished(reply, list); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, list]() { ScrobbleRequestFinished(reply, list); }); } @@ -609,7 +609,7 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, QListdeleteLater(); QByteArray data = GetReplyData(reply); @@ -794,7 +794,7 @@ void ScrobblingAPI20::SendSingleScrobble(ScrobblerCacheItemPtr item) { params << Param("trackNumber", QString::number(item->track_)); QNetworkReply *reply = CreateRequest(params); - connect(reply, &QNetworkReply::finished, [=] { SingleScrobbleRequestFinished(reply, item->timestamp_); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, item]() { SingleScrobbleRequestFinished(reply, item->timestamp_); }); } @@ -802,7 +802,7 @@ void ScrobblingAPI20::SingleScrobbleRequestFinished(QNetworkReply *reply, quint6 if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); ScrobblerCacheItemPtr item = cache()->Get(timestamp); @@ -945,7 +945,7 @@ void ScrobblingAPI20::Love() { params << Param("albumArtist", song_playing_.albumartist()); QNetworkReply *reply = CreateRequest(params); - connect(reply, &QNetworkReply::finished, [=] { LoveRequestFinished(reply); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply] { LoveRequestFinished(reply); }); } @@ -953,7 +953,7 @@ void ScrobblingAPI20::LoveRequestFinished(QNetworkReply *reply) { if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QByteArray data = GetReplyData(reply); diff --git a/src/settings/appearancesettingspage.cpp b/src/settings/appearancesettingspage.cpp index 9753dc66..ec7262b6 100644 --- a/src/settings/appearancesettingspage.cpp +++ b/src/settings/appearancesettingspage.cpp @@ -104,31 +104,31 @@ AppearanceSettingsPage::AppearanceSettingsPage(SettingsDialog *dialog) ui_->combobox_backgroundimageposition->setItemData(3, BackgroundImagePosition_BottomLeft); ui_->combobox_backgroundimageposition->setItemData(4, BackgroundImagePosition_BottomRight); - connect(ui_->blur_slider, SIGNAL(valueChanged(int)), SLOT(BlurLevelChanged(int))); - connect(ui_->opacity_slider, SIGNAL(valueChanged(int)), SLOT(OpacityLevelChanged(int))); + QObject::connect(ui_->blur_slider, &QSlider::valueChanged, this, &AppearanceSettingsPage::BlurLevelChanged); + QObject::connect(ui_->opacity_slider, &QSlider::valueChanged, this, &AppearanceSettingsPage::OpacityLevelChanged); - connect(ui_->use_a_custom_color_set, SIGNAL(toggled(bool)), SLOT(UseCustomColorSetOptionChanged(bool))); - connect(ui_->select_foreground_color, SIGNAL(pressed()), SLOT(SelectForegroundColor())); - connect(ui_->select_background_color, SIGNAL(pressed()), SLOT(SelectBackgroundColor())); + QObject::connect(ui_->use_a_custom_color_set, &QRadioButton::toggled, this, &AppearanceSettingsPage::UseCustomColorSetOptionChanged); + QObject::connect(ui_->select_foreground_color, &QPushButton::pressed, this, &AppearanceSettingsPage::SelectForegroundColor); + QObject::connect(ui_->select_background_color, &QPushButton::pressed, this, &AppearanceSettingsPage::SelectBackgroundColor); - connect(ui_->use_default_background, SIGNAL(toggled(bool)), ui_->widget_custom_background_image_options, SLOT(setDisabled(bool))); - connect(ui_->use_no_background, SIGNAL(toggled(bool)), ui_->widget_custom_background_image_options, SLOT(setDisabled(bool))); - connect(ui_->use_album_cover_background, SIGNAL(toggled(bool)), ui_->widget_custom_background_image_options, SLOT(setEnabled(bool))); - connect(ui_->use_strawbs_background, SIGNAL(toggled(bool)), ui_->widget_custom_background_image_options, SLOT(setDisabled(bool))); - connect(ui_->use_custom_background_image, SIGNAL(toggled(bool)), ui_->widget_custom_background_image_options, SLOT(setEnabled(bool))); + QObject::connect(ui_->use_default_background, &QRadioButton::toggled, ui_->widget_custom_background_image_options, &AppearanceSettingsPage::setDisabled); + QObject::connect(ui_->use_no_background, &QRadioButton::toggled, ui_->widget_custom_background_image_options, &AppearanceSettingsPage::setDisabled); + QObject::connect(ui_->use_album_cover_background, &QRadioButton::toggled, ui_->widget_custom_background_image_options, &AppearanceSettingsPage::setEnabled); + QObject::connect(ui_->use_strawbs_background, &QRadioButton::toggled, ui_->widget_custom_background_image_options, &AppearanceSettingsPage::setDisabled); + QObject::connect(ui_->use_custom_background_image, &QRadioButton::toggled, ui_->widget_custom_background_image_options, &AppearanceSettingsPage::setEnabled); - connect(ui_->select_background_image_filename_button, SIGNAL(pressed()), SLOT(SelectBackgroundImage())); - connect(ui_->use_custom_background_image, SIGNAL(toggled(bool)), ui_->background_image_filename, SLOT(setEnabled(bool))); - connect(ui_->use_custom_background_image, SIGNAL(toggled(bool)), ui_->select_background_image_filename_button, SLOT(setEnabled(bool))); + QObject::connect(ui_->select_background_image_filename_button, &QPushButton::pressed, this, &AppearanceSettingsPage::SelectBackgroundImage); + QObject::connect(ui_->use_custom_background_image, &QRadioButton::toggled, ui_->background_image_filename, &AppearanceSettingsPage::setEnabled); + QObject::connect(ui_->use_custom_background_image, &QRadioButton::toggled, ui_->select_background_image_filename_button, &AppearanceSettingsPage::setEnabled); - connect(ui_->checkbox_background_image_stretch, SIGNAL(toggled(bool)), ui_->checkbox_background_image_do_not_cut, SLOT(setEnabled(bool))); - connect(ui_->checkbox_background_image_stretch, SIGNAL(toggled(bool)), ui_->checkbox_background_image_keep_aspect_ratio, SLOT(setEnabled(bool))); - connect(ui_->checkbox_background_image_stretch, SIGNAL(toggled(bool)), ui_->spinbox_background_image_maxsize, SLOT(setDisabled(bool))); + QObject::connect(ui_->checkbox_background_image_stretch, &QCheckBox::toggled, ui_->checkbox_background_image_do_not_cut, &AppearanceSettingsPage::setEnabled); + QObject::connect(ui_->checkbox_background_image_stretch, &QCheckBox::toggled, ui_->checkbox_background_image_keep_aspect_ratio, &AppearanceSettingsPage::setEnabled); + QObject::connect(ui_->checkbox_background_image_stretch, &QCheckBox::toggled, ui_->spinbox_background_image_maxsize, &AppearanceSettingsPage::setDisabled); - connect(ui_->checkbox_background_image_keep_aspect_ratio, SIGNAL(toggled(bool)), ui_->checkbox_background_image_do_not_cut, SLOT(setEnabled(bool))); + QObject::connect(ui_->checkbox_background_image_keep_aspect_ratio, &QCheckBox::toggled, ui_->checkbox_background_image_do_not_cut, &AppearanceSettingsPage::setEnabled); - connect(ui_->select_tabbar_color, SIGNAL(pressed()), SLOT(TabBarSelectBGColor())); - connect(ui_->tabbar_system_color, SIGNAL(toggled(bool)), SLOT(TabBarSystemColor(bool))); + QObject::connect(ui_->select_tabbar_color, &QPushButton::pressed, this, &AppearanceSettingsPage::TabBarSelectBGColor); + QObject::connect(ui_->tabbar_system_color, &QRadioButton::toggled, this, &AppearanceSettingsPage::TabBarSystemColor); #if defined(Q_OS_MACOS) || defined(Q_OS_WIN) ui_->checkbox_system_icons->hide(); diff --git a/src/settings/appearancesettingspage.h b/src/settings/appearancesettingspage.h index f8a77033..145ee873 100644 --- a/src/settings/appearancesettingspage.h +++ b/src/settings/appearancesettingspage.h @@ -108,7 +108,6 @@ class AppearanceSettingsPage : public SettingsPage { void TabBarSelectBGColor(); private: - // Set the widget's background to new_color void UpdateColorSelectorColor(QWidget *color_selector, const QColor &new_color); // Init (or refresh) the colorSelectors colors diff --git a/src/settings/backendsettingspage.cpp b/src/settings/backendsettingspage.cpp index c676694a..70590730 100644 --- a/src/settings/backendsettingspage.cpp +++ b/src/settings/backendsettingspage.cpp @@ -165,20 +165,20 @@ void BackendSettingsPage::Load() { configloaded_ = true; - connect(ui_->combobox_engine, SIGNAL(currentIndexChanged(int)), SLOT(EngineChanged(int))); - connect(ui_->combobox_output, SIGNAL(currentIndexChanged(int)), SLOT(OutputChanged(int))); - connect(ui_->combobox_device, SIGNAL(currentIndexChanged(int)), SLOT(DeviceSelectionChanged(int))); - connect(ui_->lineedit_device, SIGNAL(textChanged(QString)), SLOT(DeviceStringChanged())); + QObject::connect(ui_->combobox_engine, QOverload::of(&QComboBox::currentIndexChanged), this, &BackendSettingsPage::EngineChanged); + QObject::connect(ui_->combobox_output, QOverload::of(&QComboBox::currentIndexChanged), this, &BackendSettingsPage::OutputChanged); + QObject::connect(ui_->combobox_device, QOverload::of(&QComboBox::currentIndexChanged), this, &BackendSettingsPage::DeviceSelectionChanged); + QObject::connect(ui_->lineedit_device, &QLineEdit::textChanged, this, &BackendSettingsPage::DeviceStringChanged); #if defined(HAVE_ALSA) - connect(ui_->radiobutton_alsa_hw, SIGNAL(clicked(bool)), SLOT(radiobutton_alsa_hw_clicked(bool))); - connect(ui_->radiobutton_alsa_plughw, SIGNAL(clicked(bool)), SLOT(radiobutton_alsa_plughw_clicked(bool))); + QObject::connect(ui_->radiobutton_alsa_hw, &QRadioButton::clicked, this, &BackendSettingsPage::radiobutton_alsa_hw_clicked); + QObject::connect(ui_->radiobutton_alsa_plughw, &QRadioButton::clicked, this, &BackendSettingsPage::radiobutton_alsa_plughw_clicked); #endif - connect(ui_->stickslider_replaygainpreamp, SIGNAL(valueChanged(int)), SLOT(RgPreampChanged(int))); - connect(ui_->checkbox_fadeout_stop, SIGNAL(toggled(bool)), SLOT(FadingOptionsChanged())); - connect(ui_->checkbox_fadeout_cross, SIGNAL(toggled(bool)), SLOT(FadingOptionsChanged())); - connect(ui_->checkbox_fadeout_auto, SIGNAL(toggled(bool)), SLOT(FadingOptionsChanged())); - connect(ui_->checkbox_volume_control, SIGNAL(toggled(bool)), SLOT(FadingOptionsChanged())); - connect(ui_->button_buffer_defaults, SIGNAL(clicked()), SLOT(BufferDefaults())); + QObject::connect(ui_->stickslider_replaygainpreamp, &StickySlider::valueChanged, this, &BackendSettingsPage::RgPreampChanged); + QObject::connect(ui_->checkbox_fadeout_stop, &QCheckBox::toggled, this, &BackendSettingsPage::FadingOptionsChanged); + QObject::connect(ui_->checkbox_fadeout_cross, &QCheckBox::toggled, this, &BackendSettingsPage::FadingOptionsChanged); + QObject::connect(ui_->checkbox_fadeout_auto, &QCheckBox::toggled, this, &BackendSettingsPage::FadingOptionsChanged); + QObject::connect(ui_->checkbox_volume_control, &QCheckBox::toggled, this, &BackendSettingsPage::FadingOptionsChanged); + QObject::connect(ui_->button_buffer_defaults, &QPushButton::clicked, this, &BackendSettingsPage::BufferDefaults); FadingOptionsChanged(); RgPreampChanged(ui_->stickslider_replaygainpreamp->value()); diff --git a/src/settings/backendsettingspage.h b/src/settings/backendsettingspage.h index 3bf8525d..28103314 100644 --- a/src/settings/backendsettingspage.h +++ b/src/settings/backendsettingspage.h @@ -66,7 +66,7 @@ public: void FadingOptionsChanged(); void BufferDefaults(); -private: + private: #ifdef HAVE_ALSA enum alsa_plugin { alsa_hw = 1, @@ -78,8 +78,6 @@ private: bool EngineInitialized(); - void EngineChanged(Engine::EngineType enginetype); - void Load_Engine(Engine::EngineType enginetype); void Load_Output(QString output, QVariant device); void Load_Device(const QString &output, const QVariant &device); diff --git a/src/settings/behavioursettingspage.cpp b/src/settings/behavioursettingspage.cpp index 31761677..d801d5e1 100644 --- a/src/settings/behavioursettingspage.cpp +++ b/src/settings/behavioursettingspage.cpp @@ -63,7 +63,7 @@ BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog *dialog) : SettingsP ui_->setupUi(this); setWindowIcon(IconLoader::Load("strawberry")); - connect(ui_->checkbox_showtrayicon, SIGNAL(toggled(bool)), SLOT(ShowTrayIconToggled(bool))); + QObject::connect(ui_->checkbox_showtrayicon, &QCheckBox::toggled, this, &BehaviourSettingsPage::ShowTrayIconToggled); #ifdef Q_OS_MACOS ui_->checkbox_showtrayicon->hide(); diff --git a/src/settings/behavioursettingspage.h b/src/settings/behavioursettingspage.h index ad271ead..9af075dd 100644 --- a/src/settings/behavioursettingspage.h +++ b/src/settings/behavioursettingspage.h @@ -85,4 +85,4 @@ private: }; -#endif // BEHAVIOURSETTINGSPAGE_H +#endif // BEHAVIOURSETTINGSPAGE_H diff --git a/src/settings/collectionsettingspage.cpp b/src/settings/collectionsettingspage.cpp index 868b0a89..5bcc3e68 100644 --- a/src/settings/collectionsettingspage.cpp +++ b/src/settings/collectionsettingspage.cpp @@ -77,19 +77,19 @@ CollectionSettingsPage::CollectionSettingsPage(SettingsDialog *dialog) ui_->combobox_cache_size->addItems({"KB", "MB"}); ui_->combobox_disk_cache_size->addItems({"KB", "MB", "GB"}); - connect(ui_->add, SIGNAL(clicked()), SLOT(Add())); - connect(ui_->remove, SIGNAL(clicked()), SLOT(Remove())); + QObject::connect(ui_->add, &QPushButton::clicked, this, &CollectionSettingsPage::Add); + QObject::connect(ui_->remove, &QPushButton::clicked, this, &CollectionSettingsPage::Remove); - connect(ui_->checkbox_cover_album_dir, SIGNAL(toggled(bool)), SLOT(CoverSaveInAlbumDirChanged())); - connect(ui_->radiobutton_cover_hash, SIGNAL(toggled(bool)), SLOT(CoverSaveInAlbumDirChanged())); - connect(ui_->radiobutton_cover_pattern, SIGNAL(toggled(bool)), SLOT(CoverSaveInAlbumDirChanged())); + QObject::connect(ui_->checkbox_cover_album_dir, &QCheckBox::toggled, this, &CollectionSettingsPage::CoverSaveInAlbumDirChanged); + QObject::connect(ui_->radiobutton_cover_hash, &QRadioButton::toggled, this, &CollectionSettingsPage::CoverSaveInAlbumDirChanged); + QObject::connect(ui_->radiobutton_cover_pattern, &QRadioButton::toggled, this, &CollectionSettingsPage::CoverSaveInAlbumDirChanged); - connect(ui_->checkbox_disk_cache, SIGNAL(stateChanged(int)), SLOT(DiskCacheEnable(int))); - connect(ui_->button_clear_disk_cache, SIGNAL(clicked()), dialog->app(), SIGNAL(ClearPixmapDiskCache())); - connect(ui_->button_clear_disk_cache, SIGNAL(clicked()), SLOT(ClearPixmapDiskCache())); + QObject::connect(ui_->checkbox_disk_cache, &QCheckBox::stateChanged, this, &CollectionSettingsPage::DiskCacheEnable); + QObject::connect(ui_->button_clear_disk_cache, &QPushButton::clicked, dialog->app(), &Application::ClearPixmapDiskCache); + QObject::connect(ui_->button_clear_disk_cache, &QPushButton::clicked, this, &CollectionSettingsPage::ClearPixmapDiskCache); - connect(ui_->combobox_cache_size, SIGNAL(currentIndexChanged(int)), SLOT(CacheSizeUnitChanged(int))); - connect(ui_->combobox_disk_cache_size, SIGNAL(currentIndexChanged(int)), SLOT(DiskCacheSizeUnitChanged(int))); + QObject::connect(ui_->combobox_cache_size, QOverload::of(&QComboBox::currentIndexChanged), this, &CollectionSettingsPage::CacheSizeUnitChanged); + QObject::connect(ui_->combobox_disk_cache_size, QOverload::of(&QComboBox::currentIndexChanged), this, &CollectionSettingsPage::DiskCacheSizeUnitChanged); } @@ -120,8 +120,8 @@ void CollectionSettingsPage::Remove() { } -void CollectionSettingsPage::CurrentRowChanged(const QModelIndex& index) { - ui_->remove->setEnabled(index.isValid()); +void CollectionSettingsPage::CurrentRowChanged(const QModelIndex &idx) { + ui_->remove->setEnabled(idx.isValid()); } void CollectionSettingsPage::DiskCacheEnable(const int state) { @@ -140,13 +140,13 @@ void CollectionSettingsPage::Load() { if (!initialized_model_) { if (ui_->list->selectionModel()) { - disconnect(ui_->list->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), this, SLOT(CurrentRowChanged(QModelIndex))); + QObject::disconnect(ui_->list->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &CollectionSettingsPage::CurrentRowChanged); } ui_->list->setModel(dialog()->collection_directory_model()); initialized_model_ = true; - connect(ui_->list->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), SLOT(CurrentRowChanged(QModelIndex))); + QObject::connect(ui_->list->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &CollectionSettingsPage::CurrentRowChanged); } QSettings s; diff --git a/src/settings/collectionsettingspage.h b/src/settings/collectionsettingspage.h index e1669ffa..8b8b9d06 100644 --- a/src/settings/collectionsettingspage.h +++ b/src/settings/collectionsettingspage.h @@ -69,7 +69,7 @@ class CollectionSettingsPage : public SettingsPage { void Add(); void Remove(); - void CurrentRowChanged(const QModelIndex &index); + void CurrentRowChanged(const QModelIndex &idx); void DiskCacheEnable(const int state); void CoverSaveInAlbumDirChanged(); void ClearPixmapDiskCache(); diff --git a/src/settings/contextsettingspage.cpp b/src/settings/contextsettingspage.cpp index 04f11ea9..26decd02 100644 --- a/src/settings/contextsettingspage.cpp +++ b/src/settings/contextsettingspage.cpp @@ -99,19 +99,19 @@ ContextSettingsPage::ContextSettingsPage(SettingsDialog* dialog) : SettingsPage( ui_->context_exp_chooser1->setPopupMode(QToolButton::InstantPopup); ui_->context_exp_chooser2->setPopupMode(QToolButton::InstantPopup); // We need this because by default menus don't show tooltips - connect(menu, SIGNAL(hovered(QAction*)), SLOT(ShowMenuTooltip(QAction*))); + QObject::connect(menu, &QMenu::hovered, this, &ContextSettingsPage::ShowMenuTooltip); - connect(ui_->context_exp_chooser1, SIGNAL(triggered(QAction*)), SLOT(InsertVariableFirstLine(QAction*))); - connect(ui_->context_exp_chooser2, SIGNAL(triggered(QAction*)), SLOT(InsertVariableSecondLine(QAction*))); + QObject::connect(ui_->context_exp_chooser1, &QToolButton::triggered, this, &ContextSettingsPage::InsertVariableFirstLine); + QObject::connect(ui_->context_exp_chooser2, &QToolButton::triggered, this, &ContextSettingsPage::InsertVariableSecondLine); // Icons ui_->context_exp_chooser1->setIcon(IconLoader::Load("list-add")); ui_->context_exp_chooser2->setIcon(IconLoader::Load("list-add")); - connect(ui_->font_headline, SIGNAL(currentFontChanged(QFont)), SLOT(HeadlineFontChanged())); - connect(ui_->font_size_headline, SIGNAL(valueChanged(double)), SLOT(HeadlineFontChanged())); - connect(ui_->font_normal, SIGNAL(currentFontChanged(QFont)), SLOT(NormalFontChanged())); - connect(ui_->font_size_normal, SIGNAL(valueChanged(double)), SLOT(NormalFontChanged())); + QObject::connect(ui_->font_headline, &QFontComboBox::currentFontChanged, this, &ContextSettingsPage::HeadlineFontChanged); + QObject::connect(ui_->font_size_headline, QOverload::of(&QDoubleSpinBox::valueChanged), this, &ContextSettingsPage::HeadlineFontChanged); + QObject::connect(ui_->font_normal, &QFontComboBox::currentFontChanged, this, &ContextSettingsPage::NormalFontChanged); + QObject::connect(ui_->font_size_normal, QOverload::of(&QDoubleSpinBox::valueChanged), this, &ContextSettingsPage::NormalFontChanged); QFile file(":/text/ghosts.txt"); if (file.open(QIODevice::ReadOnly)) { diff --git a/src/settings/contextsettingspage.h b/src/settings/contextsettingspage.h index ef306aea..375f0b90 100644 --- a/src/settings/contextsettingspage.h +++ b/src/settings/contextsettingspage.h @@ -74,4 +74,4 @@ public: QCheckBox *checkboxes_[ContextSettingsOrder::NELEMS]; }; -#endif // CONTEXTSETTINGSPAGE_H +#endif // CONTEXTSETTINGSPAGE_H diff --git a/src/settings/coverssettingspage.cpp b/src/settings/coverssettingspage.cpp index 42979d5b..61d80661 100644 --- a/src/settings/coverssettingspage.cpp +++ b/src/settings/coverssettingspage.cpp @@ -51,14 +51,14 @@ CoversSettingsPage::CoversSettingsPage(SettingsDialog *parent) : SettingsPage(pa ui_->setupUi(this); setWindowIcon(IconLoader::Load("cdcase")); - connect(ui_->providers_up, SIGNAL(clicked()), SLOT(ProvidersMoveUp())); - connect(ui_->providers_down, SIGNAL(clicked()), SLOT(ProvidersMoveDown())); - connect(ui_->providers, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), SLOT(CurrentItemChanged(QListWidgetItem*, QListWidgetItem*))); - connect(ui_->providers, SIGNAL(itemSelectionChanged()), SLOT(ItemSelectionChanged())); - connect(ui_->providers, SIGNAL(itemChanged(QListWidgetItem*)), SLOT(ItemChanged(QListWidgetItem*))); + QObject::connect(ui_->providers_up, &QPushButton::clicked, this, &CoversSettingsPage::ProvidersMoveUp); + QObject::connect(ui_->providers_down, &QPushButton::clicked, this, &CoversSettingsPage::ProvidersMoveDown); + QObject::connect(ui_->providers, &QListWidget::currentItemChanged, this, &CoversSettingsPage::CurrentItemChanged); + QObject::connect(ui_->providers, &QListWidget::itemSelectionChanged, this, &CoversSettingsPage::ItemSelectionChanged); + QObject::connect(ui_->providers, &QListWidget::itemChanged, this, &CoversSettingsPage::ItemChanged); - connect(ui_->button_authenticate, SIGNAL(clicked()), SLOT(AuthenticateClicked())); - connect(ui_->login_state, SIGNAL(LogoutClicked()), SLOT(LogoutClicked())); + QObject::connect(ui_->button_authenticate, &QPushButton::clicked, this, &CoversSettingsPage::AuthenticateClicked); + QObject::connect(ui_->login_state, &LoginStateWidget::LogoutClicked, this, &CoversSettingsPage::LogoutClicked); ui_->login_state->AddCredentialGroup(ui_->widget_authenticate); @@ -206,8 +206,8 @@ void CoversSettingsPage::DisableAuthentication() { void CoversSettingsPage::DisconnectAuthentication(CoverProvider *provider) { - disconnect(provider, SIGNAL(AuthenticationFailure(QStringList)), this, SLOT(AuthenticationFailure(QStringList))); - disconnect(provider, SIGNAL(AuthenticationSuccess()), this, SLOT(AuthenticationSuccess())); + QObject::disconnect(provider, &CoverProvider::AuthenticationFailure, this, &CoversSettingsPage::AuthenticationFailure); + QObject::disconnect(provider, &CoverProvider::AuthenticationSuccess, this, &CoversSettingsPage::AuthenticationSuccess); } @@ -218,8 +218,8 @@ void CoversSettingsPage::AuthenticateClicked() { if (!provider) return; ui_->button_authenticate->setEnabled(false); ui_->login_state->SetLoggedIn(LoginStateWidget::LoginInProgress); - connect(provider, SIGNAL(AuthenticationFailure(QStringList)), this, SLOT(AuthenticationFailure(QStringList))); - connect(provider, SIGNAL(AuthenticationSuccess()), this, SLOT(AuthenticationSuccess())); + QObject::connect(provider, &CoverProvider::AuthenticationFailure, this, &CoversSettingsPage::AuthenticationFailure); + QObject::connect(provider, &CoverProvider::AuthenticationSuccess, this, &CoversSettingsPage::AuthenticationSuccess); provider->Authenticate(); } diff --git a/src/settings/lyricssettingspage.cpp b/src/settings/lyricssettingspage.cpp index b2140e18..fb9637eb 100644 --- a/src/settings/lyricssettingspage.cpp +++ b/src/settings/lyricssettingspage.cpp @@ -51,14 +51,14 @@ LyricsSettingsPage::LyricsSettingsPage(SettingsDialog *parent) : SettingsPage(pa ui_->setupUi(this); setWindowIcon(IconLoader::Load("view-media-lyrics")); - connect(ui_->providers_up, SIGNAL(clicked()), SLOT(ProvidersMoveUp())); - connect(ui_->providers_down, SIGNAL(clicked()), SLOT(ProvidersMoveDown())); - connect(ui_->providers, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), SLOT(CurrentItemChanged(QListWidgetItem*, QListWidgetItem*))); - connect(ui_->providers, SIGNAL(itemSelectionChanged()), SLOT(ItemSelectionChanged())); - connect(ui_->providers, SIGNAL(itemChanged(QListWidgetItem*)), SLOT(ItemChanged(QListWidgetItem*))); + QObject::connect(ui_->providers_up, &QPushButton::clicked, this, &LyricsSettingsPage::ProvidersMoveUp); + QObject::connect(ui_->providers_down, &QPushButton::clicked, this, &LyricsSettingsPage::ProvidersMoveDown); + QObject::connect(ui_->providers, &QListWidget::currentItemChanged, this, &LyricsSettingsPage::CurrentItemChanged); + QObject::connect(ui_->providers, &QListWidget::itemSelectionChanged, this, &LyricsSettingsPage::ItemSelectionChanged); + QObject::connect(ui_->providers, &QListWidget::itemChanged, this, &LyricsSettingsPage::ItemChanged); - connect(ui_->button_authenticate, SIGNAL(clicked()), SLOT(AuthenticateClicked())); - connect(ui_->login_state, SIGNAL(LogoutClicked()), SLOT(LogoutClicked())); + QObject::connect(ui_->button_authenticate, &QPushButton::clicked, this, &LyricsSettingsPage::AuthenticateClicked); + QObject::connect(ui_->login_state, &LoginStateWidget::LogoutClicked, this, &LyricsSettingsPage::LogoutClicked); ui_->login_state->AddCredentialGroup(ui_->widget_authenticate); @@ -196,8 +196,8 @@ void LyricsSettingsPage::DisableAuthentication() { void LyricsSettingsPage::DisconnectAuthentication(LyricsProvider *provider) { - disconnect(provider, SIGNAL(AuthenticationFailure(QStringList)), this, SLOT(AuthenticationFailure(QStringList))); - disconnect(provider, SIGNAL(AuthenticationSuccess()), this, SLOT(AuthenticationSuccess())); + QObject::disconnect(provider, &LyricsProvider::AuthenticationFailure, this, &LyricsSettingsPage::AuthenticationFailure); + QObject::disconnect(provider, &LyricsProvider::AuthenticationSuccess, this, &LyricsSettingsPage::AuthenticationSuccess); } @@ -208,8 +208,8 @@ void LyricsSettingsPage::AuthenticateClicked() { if (!provider) return; ui_->button_authenticate->setEnabled(false); ui_->login_state->SetLoggedIn(LoginStateWidget::LoginInProgress); - connect(provider, SIGNAL(AuthenticationFailure(QStringList)), this, SLOT(AuthenticationFailure(QStringList))); - connect(provider, SIGNAL(AuthenticationSuccess()), this, SLOT(AuthenticationSuccess())); + QObject::connect(provider, &LyricsProvider::AuthenticationFailure, this, &LyricsSettingsPage::AuthenticationFailure); + QObject::connect(provider, &LyricsProvider::AuthenticationSuccess, this, &LyricsSettingsPage::AuthenticationSuccess); provider->Authenticate(); } diff --git a/src/settings/notificationssettingspage.cpp b/src/settings/notificationssettingspage.cpp index ec8c734b..11725244 100644 --- a/src/settings/notificationssettingspage.cpp +++ b/src/settings/notificationssettingspage.cpp @@ -94,34 +94,34 @@ NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog *dialog) ui_->notifications_exp_chooser1->setPopupMode(QToolButton::InstantPopup); ui_->notifications_exp_chooser2->setPopupMode(QToolButton::InstantPopup); // We need this because by default menus don't show tooltips - connect(menu, SIGNAL(hovered(QAction*)), SLOT(ShowMenuTooltip(QAction*))); + QObject::connect(menu, &QMenu::hovered, this, &NotificationsSettingsPage::ShowMenuTooltip); - connect(ui_->notifications_none, SIGNAL(toggled(bool)), SLOT(NotificationTypeChanged())); - connect(ui_->notifications_native, SIGNAL(toggled(bool)), SLOT(NotificationTypeChanged())); - connect(ui_->notifications_tray, SIGNAL(toggled(bool)), SLOT(NotificationTypeChanged())); - connect(ui_->notifications_pretty, SIGNAL(toggled(bool)), SLOT(NotificationTypeChanged())); - connect(ui_->notifications_opacity, SIGNAL(valueChanged(int)), SLOT(PrettyOpacityChanged(int))); - connect(ui_->notifications_bg_preset, SIGNAL(activated(int)), SLOT(PrettyColorPresetChanged(int))); - connect(ui_->notifications_fg_choose, SIGNAL(clicked()), SLOT(ChooseFgColor())); - connect(ui_->notifications_font_choose, SIGNAL(clicked()), SLOT(ChooseFont())); - connect(ui_->notifications_exp_chooser1, SIGNAL(triggered(QAction*)), SLOT(InsertVariableFirstLine(QAction*))); - connect(ui_->notifications_exp_chooser2, SIGNAL(triggered(QAction*)), SLOT(InsertVariableSecondLine(QAction*))); - connect(ui_->notifications_disable_duration, SIGNAL(toggled(bool)), ui_->notifications_duration, SLOT(setDisabled(bool))); + QObject::connect(ui_->notifications_none, &QRadioButton::toggled, this, &NotificationsSettingsPage::NotificationTypeChanged); + QObject::connect(ui_->notifications_native, &QRadioButton::toggled, this, &NotificationsSettingsPage::NotificationTypeChanged); + QObject::connect(ui_->notifications_tray, &QRadioButton::toggled, this, &NotificationsSettingsPage::NotificationTypeChanged); + QObject::connect(ui_->notifications_pretty, &QRadioButton::toggled, this, &NotificationsSettingsPage::NotificationTypeChanged); + QObject::connect(ui_->notifications_opacity, &QSlider::valueChanged, this, &NotificationsSettingsPage::PrettyOpacityChanged); + QObject::connect(ui_->notifications_bg_preset, QOverload::of(&QComboBox::activated), this, &NotificationsSettingsPage::PrettyColorPresetChanged); + QObject::connect(ui_->notifications_fg_choose, &QPushButton::clicked, this, &NotificationsSettingsPage::ChooseFgColor); + QObject::connect(ui_->notifications_font_choose, &QPushButton::clicked, this, &NotificationsSettingsPage::ChooseFont); + QObject::connect(ui_->notifications_exp_chooser1, &QToolButton::triggered, this, &NotificationsSettingsPage::InsertVariableFirstLine); + QObject::connect(ui_->notifications_exp_chooser2, &QToolButton::triggered, this, &NotificationsSettingsPage::InsertVariableSecondLine); + QObject::connect(ui_->notifications_disable_duration, &QCheckBox::toggled, ui_->notifications_duration, &NotificationsSettingsPage::setDisabled); if (!dialog->osd()->SupportsNativeNotifications()) ui_->notifications_native->setEnabled(false); if (!dialog->osd()->SupportsTrayPopups()) ui_->notifications_tray->setEnabled(false); - connect(ui_->notifications_pretty, SIGNAL(toggled(bool)), SLOT(UpdatePopupVisible())); + QObject::connect(ui_->notifications_pretty, &QRadioButton::toggled, this, &NotificationsSettingsPage::UpdatePopupVisible); - connect(ui_->notifications_custom_text_enabled, SIGNAL(toggled(bool)), SLOT(NotificationCustomTextChanged(bool))); - connect(ui_->notifications_preview, SIGNAL(clicked()), SLOT(PrepareNotificationPreview())); + QObject::connect(ui_->notifications_custom_text_enabled, &QCheckBox::toggled, this, &NotificationsSettingsPage::NotificationCustomTextChanged); + QObject::connect(ui_->notifications_preview, &QPushButton::clicked, this, &NotificationsSettingsPage::PrepareNotificationPreview); // Icons ui_->notifications_exp_chooser1->setIcon(IconLoader::Load("list-add")); ui_->notifications_exp_chooser2->setIcon(IconLoader::Load("list-add")); - connect(pretty_popup_, SIGNAL(PositionChanged()), SLOT(PrettyOSDChanged())); + QObject::connect(pretty_popup_, &OSDPretty::PositionChanged, this, &NotificationsSettingsPage::PrettyOSDChanged); } diff --git a/src/settings/qobuzsettingspage.cpp b/src/settings/qobuzsettingspage.cpp index 82257622..f931db2d 100644 --- a/src/settings/qobuzsettingspage.cpp +++ b/src/settings/qobuzsettingspage.cpp @@ -51,13 +51,13 @@ QobuzSettingsPage::QobuzSettingsPage(SettingsDialog *parent) ui_->setupUi(this); setWindowIcon(IconLoader::Load("qobuz")); - connect(ui_->button_login, SIGNAL(clicked()), SLOT(LoginClicked())); - connect(ui_->login_state, SIGNAL(LogoutClicked()), SLOT(LogoutClicked())); + QObject::connect(ui_->button_login, &QPushButton::clicked, this, &QobuzSettingsPage::LoginClicked); + QObject::connect(ui_->login_state, &LoginStateWidget::LogoutClicked, this, &QobuzSettingsPage::LogoutClicked); - connect(this, SIGNAL(Login(QString, QString, QString)), service_, SLOT(SendLogin(QString, QString, QString))); + QObject::connect(this, &QobuzSettingsPage::Login, service_, &InternetService::LoginWithCredentials); - connect(service_, SIGNAL(LoginFailure(QString)), SLOT(LoginFailure(QString))); - connect(service_, SIGNAL(LoginSuccess()), SLOT(LoginSuccess())); + QObject::connect(service_, &InternetService::LoginFailure, this, &QobuzSettingsPage::LoginFailure); + QObject::connect(service_, &InternetService::LoginSuccess, this, &QobuzSettingsPage::LoginSuccess); dialog()->installEventFilter(this); diff --git a/src/settings/qobuzsettingspage.h b/src/settings/qobuzsettingspage.h index 21db0a4f..0777d39a 100644 --- a/src/settings/qobuzsettingspage.h +++ b/src/settings/qobuzsettingspage.h @@ -35,18 +35,17 @@ class QobuzSettingsPage : public SettingsPage { public: explicit QobuzSettingsPage(SettingsDialog* parent = nullptr); - ~QobuzSettingsPage(); + ~QobuzSettingsPage() override; static const char *kSettingsGroup; - void Load(); - void Save(); + void Load() override; + void Save() override; - bool eventFilter(QObject *object, QEvent *event); + bool eventFilter(QObject *object, QEvent *event) override; signals: - void Login(); - void Login(const QString &username, const QString &password, const QString &token); + void Login(QString username, QString password, QString token); private slots: void LoginClicked(); @@ -59,4 +58,4 @@ class QobuzSettingsPage : public SettingsPage { QobuzService *service_; }; -#endif +#endif // QOBUZSETTINGSPAGE_H diff --git a/src/settings/scrobblersettingspage.cpp b/src/settings/scrobblersettingspage.cpp index 2bcdab17..bf1609aa 100644 --- a/src/settings/scrobblersettingspage.cpp +++ b/src/settings/scrobblersettingspage.cpp @@ -59,24 +59,24 @@ ScrobblerSettingsPage::ScrobblerSettingsPage(SettingsDialog *parent) setWindowIcon(IconLoader::Load("scrobble")); // Last.fm - connect(lastfmscrobbler_, SIGNAL(AuthenticationComplete(bool, QString)), SLOT(LastFM_AuthenticationComplete(bool, QString))); - connect(ui_->button_lastfm_login, SIGNAL(clicked()), SLOT(LastFM_Login())); - connect(ui_->widget_lastfm_login_state, SIGNAL(LoginClicked()), SLOT(LastFM_Login())); - connect(ui_->widget_lastfm_login_state, SIGNAL(LogoutClicked()), SLOT(LastFM_Logout())); + QObject::connect(lastfmscrobbler_, &LastFMScrobbler::AuthenticationComplete, this, &ScrobblerSettingsPage::LastFM_AuthenticationComplete); + QObject::connect(ui_->button_lastfm_login, &QPushButton::clicked, this, &ScrobblerSettingsPage::LastFM_Login); + QObject::connect(ui_->widget_lastfm_login_state, &LoginStateWidget::LoginClicked, this, &ScrobblerSettingsPage::LastFM_Login); + QObject::connect(ui_->widget_lastfm_login_state, &LoginStateWidget::LogoutClicked, this, &ScrobblerSettingsPage::LastFM_Logout); ui_->widget_lastfm_login_state->AddCredentialGroup(ui_->widget_lastfm_login); // Libre.fm - connect(librefmscrobbler_, SIGNAL(AuthenticationComplete(bool, QString)), SLOT(LibreFM_AuthenticationComplete(bool, QString))); - connect(ui_->button_librefm_login, SIGNAL(clicked()), SLOT(LibreFM_Login())); - connect(ui_->widget_librefm_login_state, SIGNAL(LoginClicked()), SLOT(LibreFM_Login())); - connect(ui_->widget_librefm_login_state, SIGNAL(LogoutClicked()), SLOT(LibreFM_Logout())); + QObject::connect(librefmscrobbler_, &LibreFMScrobbler::AuthenticationComplete, this, &ScrobblerSettingsPage::LibreFM_AuthenticationComplete); + QObject::connect(ui_->button_librefm_login, &QPushButton::clicked, this, &ScrobblerSettingsPage::LibreFM_Login); + QObject::connect(ui_->widget_librefm_login_state, &LoginStateWidget::LoginClicked, this, &ScrobblerSettingsPage::LibreFM_Login); + QObject::connect(ui_->widget_librefm_login_state, &LoginStateWidget::LogoutClicked, this, &ScrobblerSettingsPage::LibreFM_Logout); ui_->widget_librefm_login_state->AddCredentialGroup(ui_->widget_librefm_login); // ListenBrainz - connect(listenbrainzscrobbler_, SIGNAL(AuthenticationComplete(bool, QString)), SLOT(ListenBrainz_AuthenticationComplete(bool, QString))); - connect(ui_->button_listenbrainz_login, SIGNAL(clicked()), SLOT(ListenBrainz_Login())); - connect(ui_->widget_listenbrainz_login_state, SIGNAL(LoginClicked()), SLOT(ListenBrainz_Login())); - connect(ui_->widget_listenbrainz_login_state, SIGNAL(LogoutClicked()), SLOT(ListenBrainz_Logout())); + QObject::connect(listenbrainzscrobbler_, &ListenBrainzScrobbler::AuthenticationComplete, this, &ScrobblerSettingsPage::ListenBrainz_AuthenticationComplete); + QObject::connect(ui_->button_listenbrainz_login, &QPushButton::clicked, this, &ScrobblerSettingsPage::ListenBrainz_Login); + QObject::connect(ui_->widget_listenbrainz_login_state, &LoginStateWidget::LoginClicked, this, &ScrobblerSettingsPage::ListenBrainz_Login); + QObject::connect(ui_->widget_listenbrainz_login_state, &LoginStateWidget::LogoutClicked, this, &ScrobblerSettingsPage::ListenBrainz_Logout); ui_->widget_listenbrainz_login_state->AddCredentialGroup(ui_->widget_listenbrainz_login); ui_->label_listenbrainz_token->setText("

" + tr("Enter your user token from") + " " + "https://listenbrainz.org/profile/

"); diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp index 3448cd82..40697bba 100644 --- a/src/settings/settingsdialog.cpp +++ b/src/settings/settingsdialog.cpp @@ -89,10 +89,10 @@ const char *SettingsDialog::kSettingsGroup = "SettingsDialog"; SettingsItemDelegate::SettingsItemDelegate(QObject *parent) : QStyledItemDelegate(parent) {} -QSize SettingsItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { +QSize SettingsItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &idx) const { - const bool is_separator = index.data(SettingsDialog::Role_IsSeparator).toBool(); - QSize ret = QStyledItemDelegate::sizeHint(option, index); + const bool is_separator = idx.data(SettingsDialog::Role_IsSeparator).toBool(); + QSize ret = QStyledItemDelegate::sizeHint(option, idx); if (is_separator) { ret.setHeight(ret.height() * 2); @@ -102,15 +102,15 @@ QSize SettingsItemDelegate::sizeHint(const QStyleOptionViewItem &option, const Q } -void SettingsItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { +void SettingsItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const { - const bool is_separator = index.data(SettingsDialog::Role_IsSeparator).toBool(); + const bool is_separator = idx.data(SettingsDialog::Role_IsSeparator).toBool(); if (is_separator) { - GroupedIconView::DrawHeader(painter, option.rect, option.font, option.palette, index.data().toString()); + GroupedIconView::DrawHeader(painter, option.rect, option.font, option.palette, idx.data().toString()); } else { - QStyledItemDelegate::paint(painter, option, index); + QStyledItemDelegate::paint(painter, option, idx); } } @@ -171,7 +171,7 @@ SettingsDialog::SettingsDialog(Application *app, OSDBase *osd, QMainWindow *main #endif // List box - connect(ui_->list, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), SLOT(CurrentItemChanged(QTreeWidgetItem*))); + QObject::connect(ui_->list, &QTreeWidget::currentItemChanged, this, &SettingsDialog::CurrentItemChanged); ui_->list->setCurrentItem(pages_[Page_Behaviour].item_); // Make sure the list is big enough to show all the items @@ -179,7 +179,7 @@ SettingsDialog::SettingsDialog(Application *app, OSDBase *osd, QMainWindow *main ui_->buttonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence::Close); - connect(ui_->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(DialogButtonClicked(QAbstractButton*))); + QObject::connect(ui_->buttonBox, &QDialogButtonBox::clicked, this, &SettingsDialog::DialogButtonClicked); } @@ -285,7 +285,7 @@ void SettingsDialog::AddPage(Page id, SettingsPage *page, QTreeWidgetItem *paren if (!parent) parent = ui_->list->invisibleRootItem(); // Connect page's signals to the settings dialog's signals - connect(page, SIGNAL(NotificationPreview(OSDBase::Behaviour, QString, QString)), SIGNAL(NotificationPreview(OSDBase::Behaviour, QString, QString))); + QObject::connect(page, &SettingsPage::NotificationPreview, this, &SettingsDialog::NotificationPreview); // Create the list item QTreeWidgetItem *item = new QTreeWidgetItem; diff --git a/src/settings/settingsdialog.h b/src/settings/settingsdialog.h index 72a003c7..540f9094 100644 --- a/src/settings/settingsdialog.h +++ b/src/settings/settingsdialog.h @@ -60,8 +60,8 @@ class Ui_SettingsDialog; class SettingsItemDelegate : public QStyledItemDelegate { public: explicit SettingsItemDelegate(QObject *parent); - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &idx) const override; + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override; }; diff --git a/src/settings/settingspage.h b/src/settings/settingspage.h index df95de0f..1f133833 100644 --- a/src/settings/settingspage.h +++ b/src/settings/settingspage.h @@ -88,4 +88,4 @@ class SettingsPage : public QWidget { QList> lineedits_; }; -#endif // SETTINGSPAGE_H +#endif // SETTINGSPAGE_H diff --git a/src/settings/shortcutssettingspage.cpp b/src/settings/shortcutssettingspage.cpp index 55901bbf..f98caffc 100644 --- a/src/settings/shortcutssettingspage.cpp +++ b/src/settings/shortcutssettingspage.cpp @@ -65,20 +65,20 @@ GlobalShortcutsSettingsPage::GlobalShortcutsSettingsPage(SettingsDialog *dialog) ui_->list->header()->setSectionResizeMode(QHeaderView::ResizeToContents); setWindowIcon(IconLoader::Load("keyboard")); - connect(ui_->list, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), SLOT(ItemClicked(QTreeWidgetItem*))); - connect(ui_->radio_none, SIGNAL(clicked()), SLOT(NoneClicked())); - connect(ui_->radio_default, SIGNAL(clicked()), SLOT(DefaultClicked())); - connect(ui_->radio_custom, SIGNAL(clicked()), SLOT(ChangeClicked())); - connect(ui_->button_change, SIGNAL(clicked()), SLOT(ChangeClicked())); + QObject::connect(ui_->list, &QTreeWidget::currentItemChanged, this, &GlobalShortcutsSettingsPage::ItemClicked); + QObject::connect(ui_->radio_none, &QRadioButton::clicked, this, &GlobalShortcutsSettingsPage::NoneClicked); + QObject::connect(ui_->radio_default, &QRadioButton::clicked, this, &GlobalShortcutsSettingsPage::DefaultClicked); + QObject::connect(ui_->radio_custom, &QRadioButton::clicked, this, &GlobalShortcutsSettingsPage::ChangeClicked); + QObject::connect(ui_->button_change, &QPushButton::clicked, this, &GlobalShortcutsSettingsPage::ChangeClicked); #if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) # ifdef HAVE_DBUS - connect(ui_->checkbox_gsd, SIGNAL(clicked(bool)), SLOT(ShortcutOptionsChanged())); - connect(ui_->checkbox_kde, SIGNAL(clicked(bool)), SLOT(ShortcutOptionsChanged())); - connect(ui_->button_gsd_open, SIGNAL(clicked()), SLOT(OpenGnomeKeybindingProperties())); + QObject::connect(ui_->checkbox_gsd, &QCheckBox::clicked, this, &GlobalShortcutsSettingsPage::ShortcutOptionsChanged); + QObject::connect(ui_->checkbox_kde, &QCheckBox::clicked, this, &GlobalShortcutsSettingsPage::ShortcutOptionsChanged); + QObject::connect(ui_->button_gsd_open, &QPushButton::clicked, this, &GlobalShortcutsSettingsPage::OpenGnomeKeybindingProperties); # endif # ifdef HAVE_X11EXTRAS - connect(ui_->checkbox_x11, SIGNAL(clicked(bool)), SLOT(ShortcutOptionsChanged())); + QObject::connect(ui_->checkbox_x11, &QCheckBox::clicked, this, &GlobalShortcutsSettingsPage::ShortcutOptionsChanged); # endif #else ui_->widget_gsd->hide(); @@ -116,7 +116,7 @@ void GlobalShortcutsSettingsPage::Load() { de_ = Utilities::DesktopEnvironment(); ui_->widget_warning->hide(); - connect(ui_->button_macos_open, SIGNAL(clicked()), manager, SLOT(ShowMacAccessibilityDialog())); + QObject::connect(ui_->button_macos_open, &QPushButton::clicked, manager, &GlobalShortcuts::ShowMacAccessibilityDialog); #if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) if (manager->IsGsdAvailable()) { diff --git a/src/settings/subsonicsettingspage.cpp b/src/settings/subsonicsettingspage.cpp index 0936c019..d7bc9390 100644 --- a/src/settings/subsonicsettingspage.cpp +++ b/src/settings/subsonicsettingspage.cpp @@ -49,12 +49,12 @@ SubsonicSettingsPage::SubsonicSettingsPage(SettingsDialog *parent) ui_->setupUi(this); setWindowIcon(IconLoader::Load("subsonic")); - connect(ui_->button_test, SIGNAL(clicked()), SLOT(TestClicked())); + QObject::connect(ui_->button_test, &QPushButton::clicked, this, &SubsonicSettingsPage::TestClicked); - connect(this, SIGNAL(Test(QUrl, QString, QString)), service_, SLOT(SendPing(QUrl, QString, QString))); + QObject::connect(this, &SubsonicSettingsPage::Test, service_, &SubsonicService::SendPingWithCredentials); - connect(service_, SIGNAL(TestFailure(QString)), SLOT(TestFailure(QString))); - connect(service_, SIGNAL(TestSuccess()), SLOT(TestSuccess())); + QObject::connect(service_, &SubsonicService::TestFailure, this, &SubsonicSettingsPage::TestFailure); + QObject::connect(service_, &SubsonicService::TestSuccess, this, &SubsonicSettingsPage::TestSuccess); dialog()->installEventFilter(this); diff --git a/src/settings/subsonicsettingspage.h b/src/settings/subsonicsettingspage.h index 5e2abd00..c3ec8ab5 100644 --- a/src/settings/subsonicsettingspage.h +++ b/src/settings/subsonicsettingspage.h @@ -48,8 +48,7 @@ class SubsonicSettingsPage : public SettingsPage { bool eventFilter(QObject *object, QEvent *event) override; signals: - void Test(); - void Test(QUrl url, const QString &username, const QString &password); + void Test(QUrl url, QString username, QString password, bool redirect = false); private slots: void TestClicked(); diff --git a/src/settings/tidalsettingspage.cpp b/src/settings/tidalsettingspage.cpp index 119c866a..29138712 100644 --- a/src/settings/tidalsettingspage.cpp +++ b/src/settings/tidalsettingspage.cpp @@ -51,15 +51,15 @@ TidalSettingsPage::TidalSettingsPage(SettingsDialog *parent) ui_->setupUi(this); setWindowIcon(IconLoader::Load("tidal")); - connect(ui_->button_login, SIGNAL(clicked()), SLOT(LoginClicked())); - connect(ui_->login_state, SIGNAL(LogoutClicked()), SLOT(LogoutClicked())); - connect(ui_->oauth, SIGNAL(toggled(bool)), SLOT(OAuthClicked(bool))); + QObject::connect(ui_->button_login, &QPushButton::clicked, this, &TidalSettingsPage::LoginClicked); + QObject::connect(ui_->login_state, &LoginStateWidget::LogoutClicked, this, &TidalSettingsPage::LogoutClicked); + QObject::connect(ui_->oauth, &QCheckBox::toggled, this, &TidalSettingsPage::OAuthClicked); - connect(this, SIGNAL(Authorize(QString)), service_, SLOT(StartAuthorization(QString))); - connect(this, SIGNAL(Login(QString, QString, QString)), service_, SLOT(SendLogin(QString, QString, QString))); + QObject::connect(this, &TidalSettingsPage::Authorize, service_, &TidalService::StartAuthorization); + QObject::connect(this, &TidalSettingsPage::Login, service_, &TidalService::SendLoginWithCredentials); - connect(service_, SIGNAL(LoginFailure(QString)), SLOT(LoginFailure(QString))); - connect(service_, SIGNAL(LoginSuccess()), SLOT(LoginSuccess())); + QObject::connect(service_, &InternetService::LoginFailure, this, &TidalSettingsPage::LoginFailure); + QObject::connect(service_, &InternetService::LoginSuccess, this, &TidalSettingsPage::LoginSuccess); dialog()->installEventFilter(this); diff --git a/src/smartplaylists/playlistgenerator.h b/src/smartplaylists/playlistgenerator.h index a637a6bc..a66f563b 100644 --- a/src/smartplaylists/playlistgenerator.h +++ b/src/smartplaylists/playlistgenerator.h @@ -85,7 +85,7 @@ class PlaylistGenerator : public QObject, public std::enable_shared_from_thisis_dynamic(); - connect(generator.get(), SIGNAL(Error(QString)), SIGNAL(Error(QString))); + QObject::connect(generator.get(), &PlaylistGenerator::Error, this, &PlaylistGeneratorInserter::Error); QFuture future = QtConcurrent::run(PlaylistGeneratorInserter::Generate, generator, dynamic_count); NewClosure(future, this, SLOT(Finished(QFuture)), future); diff --git a/src/smartplaylists/playlistgeneratorinserter.h b/src/smartplaylists/playlistgeneratorinserter.h index fdcc402b..637f33d7 100644 --- a/src/smartplaylists/playlistgeneratorinserter.h +++ b/src/smartplaylists/playlistgeneratorinserter.h @@ -48,8 +48,8 @@ class PlaylistGeneratorInserter : public QObject { static PlaylistItemList Generate(PlaylistGeneratorPtr generator, const int dynamic_count); signals: - void Error(const QString &message); - void PlayRequested(const QModelIndex &idx); + void Error(QString message); + void PlayRequested(QModelIndex idx, Playlist::AutoScroll autoscroll); private slots: void Finished(QFuture future); diff --git a/src/smartplaylists/smartplaylistquerywizardplugin.cpp b/src/smartplaylists/smartplaylistquerywizardplugin.cpp index d8f4fe95..1d3b6272 100644 --- a/src/smartplaylists/smartplaylistquerywizardplugin.cpp +++ b/src/smartplaylists/smartplaylistquerywizardplugin.cpp @@ -99,12 +99,12 @@ int SmartPlaylistQueryWizardPlugin::CreatePages(QWizard *wizard, int finish_page sort_ui_->limit_value->setValue(PlaylistGenerator::kDefaultLimit); - connect(search_page_->ui_->type, SIGNAL(currentIndexChanged(int)), SLOT(SearchTypeChanged())); + QObject::connect(search_page_->ui_->type, QOverload::of(&QComboBox::currentIndexChanged), this, &SmartPlaylistQueryWizardPlugin::SearchTypeChanged); // Create the new search term widget search_page_->new_term_ = new SmartPlaylistSearchTermWidget(collection_, search_page_); search_page_->new_term_->SetActive(false); - connect(search_page_->new_term_, SIGNAL(Clicked()), SLOT(AddSearchTerm())); + QObject::connect(search_page_->new_term_, &SmartPlaylistSearchTermWidget::Clicked, this, &SmartPlaylistQueryWizardPlugin::AddSearchTerm); // Add an empty initial term search_page_->layout_ = static_cast(search_page_->ui_->terms_scroll_area_content->layout()); @@ -112,7 +112,7 @@ int SmartPlaylistQueryWizardPlugin::CreatePages(QWizard *wizard, int finish_page AddSearchTerm(); // Ensure that the terms are scrolled to the bottom when a new one is added - connect(search_page_->ui_->terms_scroll_area->verticalScrollBar(), SIGNAL(rangeChanged(int, int)), this, SLOT(MoveTermListToBottom(int, int))); + QObject::connect(search_page_->ui_->terms_scroll_area->verticalScrollBar(), &QScrollBar::rangeChanged, this, &SmartPlaylistQueryWizardPlugin::MoveTermListToBottom); // Add the preview widget at the bottom of the search terms page QVBoxLayout *terms_page_layout = static_cast(search_page_->layout()); @@ -128,7 +128,7 @@ int SmartPlaylistQueryWizardPlugin::CreatePages(QWizard *wizard, int finish_page const QString field_name = SmartPlaylistSearchTerm::FieldName(field); sort_ui_->field_value->addItem(field_name); } - connect(sort_ui_->field_value, SIGNAL(currentIndexChanged(int)), SLOT(UpdateSortOrder())); + QObject::connect(sort_ui_->field_value, QOverload::of(&QComboBox::currentIndexChanged), this, &SmartPlaylistQueryWizardPlugin::UpdateSortOrder); UpdateSortOrder(); // Set the sort and limit radio buttons back to their defaults - they would @@ -139,13 +139,13 @@ int SmartPlaylistQueryWizardPlugin::CreatePages(QWizard *wizard, int finish_page // Set up the preview widget that's already at the bottom of the sort page sort_ui_->preview->set_application(app_); sort_ui_->preview->set_collection(collection_); - connect(sort_ui_->field, SIGNAL(toggled(bool)), SLOT(UpdateSortPreview())); - connect(sort_ui_->field_value, SIGNAL(currentIndexChanged(int)), SLOT(UpdateSortPreview())); - connect(sort_ui_->limit_limit, SIGNAL(toggled(bool)), SLOT(UpdateSortPreview())); - connect(sort_ui_->limit_none, SIGNAL(toggled(bool)), SLOT(UpdateSortPreview())); - connect(sort_ui_->limit_value, SIGNAL(valueChanged(int)), SLOT(UpdateSortPreview())); - connect(sort_ui_->order, SIGNAL(currentIndexChanged(int)), SLOT(UpdateSortPreview())); - connect(sort_ui_->random, SIGNAL(toggled(bool)), SLOT(UpdateSortPreview())); + QObject::connect(sort_ui_->field, &QRadioButton::toggled, this, &SmartPlaylistQueryWizardPlugin::UpdateSortPreview); + QObject::connect(sort_ui_->field_value, QOverload::of(&QComboBox::currentIndexChanged), this, &SmartPlaylistQueryWizardPlugin::UpdateSortPreview); + QObject::connect(sort_ui_->limit_limit, &QRadioButton::toggled, this, &SmartPlaylistQueryWizardPlugin::UpdateSortPreview); + QObject::connect(sort_ui_->limit_none, &QRadioButton::toggled, this, &SmartPlaylistQueryWizardPlugin::UpdateSortPreview); + QObject::connect(sort_ui_->limit_value, QOverload::of(&QSpinBox::valueChanged), this, &SmartPlaylistQueryWizardPlugin::UpdateSortPreview); + QObject::connect(sort_ui_->order, QOverload::of(&QComboBox::currentIndexChanged), this, &SmartPlaylistQueryWizardPlugin::UpdateSortPreview); + QObject::connect(sort_ui_->random, &QRadioButton::toggled, this, &SmartPlaylistQueryWizardPlugin::UpdateSortPreview); // Configure the page text search_page_->setTitle(tr("Search terms")); @@ -227,8 +227,8 @@ void SmartPlaylistQueryWizardPlugin::UpdateSortOrder() { void SmartPlaylistQueryWizardPlugin::AddSearchTerm() { SmartPlaylistSearchTermWidget *widget = new SmartPlaylistSearchTermWidget(collection_, search_page_); - connect(widget, SIGNAL(RemoveClicked()), SLOT(RemoveSearchTerm())); - connect(widget, SIGNAL(Changed()), SLOT(UpdateTermPreview())); + QObject::connect(widget, &SmartPlaylistSearchTermWidget::RemoveClicked, this, &SmartPlaylistQueryWizardPlugin::RemoveSearchTerm); + QObject::connect(widget, &SmartPlaylistSearchTermWidget::Changed, this, &SmartPlaylistQueryWizardPlugin::UpdateTermPreview); search_page_->layout_->insertWidget(search_page_->terms_.count(), widget); search_page_->terms_ << widget; diff --git a/src/smartplaylists/smartplaylistsearchpreview.h b/src/smartplaylists/smartplaylistsearchpreview.h index 1f7af709..b0dfa72c 100644 --- a/src/smartplaylists/smartplaylistsearchpreview.h +++ b/src/smartplaylists/smartplaylistsearchpreview.h @@ -42,7 +42,7 @@ class SmartPlaylistSearchPreview : public QWidget { public: explicit SmartPlaylistSearchPreview(QWidget *parent = nullptr); - ~SmartPlaylistSearchPreview(); + ~SmartPlaylistSearchPreview() override; void set_application(Application *app); void set_collection(CollectionBackend *backend); @@ -50,7 +50,7 @@ class SmartPlaylistSearchPreview : public QWidget { void Update(const SmartPlaylistSearch &search); protected: - void showEvent(QShowEvent*); + void showEvent(QShowEvent*) override; private: void RunSearch(const SmartPlaylistSearch &search); diff --git a/src/smartplaylists/smartplaylistsearchtermwidget.cpp b/src/smartplaylists/smartplaylistsearchtermwidget.cpp index 27d106fa..642884c0 100644 --- a/src/smartplaylists/smartplaylistsearchtermwidget.cpp +++ b/src/smartplaylists/smartplaylistsearchtermwidget.cpp @@ -85,20 +85,21 @@ SmartPlaylistSearchTermWidget::SmartPlaylistSearchTermWidget(CollectionBackend* current_field_type_(SmartPlaylistSearchTerm::Type_Invalid) { ui_->setupUi(this); - connect(ui_->field, SIGNAL(currentIndexChanged(int)), SLOT(FieldChanged(int))); - connect(ui_->op, SIGNAL(currentIndexChanged(int)), SLOT(OpChanged(int))); - connect(ui_->remove, SIGNAL(clicked()), SIGNAL(RemoveClicked())); - connect(ui_->value_date, SIGNAL(dateChanged(QDate)), SIGNAL(Changed())); - connect(ui_->value_number, SIGNAL(valueChanged(int)), SIGNAL(Changed())); - connect(ui_->value_text, SIGNAL(textChanged(QString)), SIGNAL(Changed())); - connect(ui_->value_time, SIGNAL(timeChanged(QTime)), SIGNAL(Changed())); - connect(ui_->value_date_numeric, SIGNAL(valueChanged(int)), SIGNAL(Changed())); - connect(ui_->value_date_numeric1, SIGNAL(valueChanged(int)), SLOT(RelativeValueChanged())); - connect(ui_->value_date_numeric2, SIGNAL(valueChanged(int)), SLOT(RelativeValueChanged())); - connect(ui_->date_type, SIGNAL(currentIndexChanged(int)), SIGNAL(Changed())); - connect(ui_->date_type_relative, SIGNAL(currentIndexChanged(int)), SIGNAL(Changed())); - connect(ui_->value_rating, SIGNAL(RatingChanged(float)), SIGNAL(Changed())); + QObject::connect(ui_->field, QOverload::of(&QComboBox::currentIndexChanged), this, &SmartPlaylistSearchTermWidget::FieldChanged); + QObject::connect(ui_->op, QOverload::of(&QComboBox::currentIndexChanged), this, &SmartPlaylistSearchTermWidget::OpChanged); + QObject::connect(ui_->remove, &QToolButton::clicked, this, &SmartPlaylistSearchTermWidget::RemoveClicked); + + QObject::connect(ui_->value_date, &QDateEdit::dateChanged, this, &SmartPlaylistSearchTermWidget::Changed); + QObject::connect(ui_->value_number, QOverload::of(&QSpinBox::valueChanged), this, &SmartPlaylistSearchTermWidget::Changed); + QObject::connect(ui_->value_text, &QLineEdit::textChanged, this, &SmartPlaylistSearchTermWidget::Changed); + QObject::connect(ui_->value_time, &QTimeEdit::timeChanged, this, &SmartPlaylistSearchTermWidget::Changed); + QObject::connect(ui_->value_date_numeric, QOverload::of(&QSpinBox::valueChanged), this, &SmartPlaylistSearchTermWidget::Changed); + QObject::connect(ui_->value_date_numeric1, QOverload::of(&QSpinBox::valueChanged), this, &SmartPlaylistSearchTermWidget::RelativeValueChanged); + QObject::connect(ui_->value_date_numeric2, QOverload::of(&QSpinBox::valueChanged), this, &SmartPlaylistSearchTermWidget::RelativeValueChanged); + QObject::connect(ui_->date_type, QOverload::of(&QComboBox::currentIndexChanged), this, &SmartPlaylistSearchTermWidget::Changed); + QObject::connect(ui_->date_type_relative, QOverload::of(&QComboBox::currentIndexChanged), this, &SmartPlaylistSearchTermWidget::Changed); + QObject::connect(ui_->value_rating, &RatingWidget::RatingChanged, this, &SmartPlaylistSearchTermWidget::Changed); ui_->value_date->setDate(QDate::currentDate()); @@ -292,7 +293,7 @@ void SmartPlaylistSearchTermWidget::resizeEvent(QResizeEvent* e) { QWidget::resizeEvent(e); if (overlay_ && overlay_->isVisible()) { - QTimer::singleShot(0, this, SLOT(Grab())); + QTimer::singleShot(0, this, &SmartPlaylistSearchTermWidget::Grab); } } @@ -301,7 +302,7 @@ void SmartPlaylistSearchTermWidget::showEvent(QShowEvent* e) { QWidget::showEvent(e); if (overlay_) { - QTimer::singleShot(0, this, SLOT(Grab())); + QTimer::singleShot(0, this, &SmartPlaylistSearchTermWidget::Grab); } } diff --git a/src/smartplaylists/smartplaylistsviewcontainer.cpp b/src/smartplaylists/smartplaylistsviewcontainer.cpp index 47db7708..8f9d967c 100644 --- a/src/smartplaylists/smartplaylistsviewcontainer.cpp +++ b/src/smartplaylists/smartplaylistsviewcontainer.cpp @@ -65,33 +65,34 @@ SmartPlaylistsViewContainer::SmartPlaylistsViewContainer(Application *app, QWidg model_->Init(); - action_new_smart_playlist_ = context_menu_->addAction(IconLoader::Load("document-new"), tr("New smart playlist..."), this, SLOT(NewSmartPlaylist())); + action_new_smart_playlist_ = context_menu_->addAction(IconLoader::Load("document-new"), tr("New smart playlist..."), this, &SmartPlaylistsViewContainer::NewSmartPlaylist); - action_append_to_playlist_ = context_menu_selected_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, SLOT(AppendToPlaylist())); - action_replace_current_playlist_ = context_menu_selected_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, SLOT(ReplaceCurrentPlaylist())); - action_open_in_new_playlist_ = context_menu_selected_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, SLOT(OpenInNewPlaylist())); + action_append_to_playlist_ = context_menu_selected_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, &SmartPlaylistsViewContainer::AppendToPlaylist); + action_replace_current_playlist_ = context_menu_selected_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, &SmartPlaylistsViewContainer::ReplaceCurrentPlaylist); + action_open_in_new_playlist_ = context_menu_selected_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, &SmartPlaylistsViewContainer::OpenInNewPlaylist); context_menu_selected_->addSeparator(); - action_add_to_playlist_enqueue_ = context_menu_selected_->addAction(IconLoader::Load("go-next"), tr("Queue track"), this, SLOT(AddToPlaylistEnqueue())); - action_add_to_playlist_enqueue_next_ = context_menu_selected_->addAction(IconLoader::Load("go-next"), tr("Play next"), this, SLOT(AddToPlaylistEnqueueNext())); + action_add_to_playlist_enqueue_ = context_menu_selected_->addAction(IconLoader::Load("go-next"), tr("Queue track"), this, &SmartPlaylistsViewContainer::AddToPlaylistEnqueue); + action_add_to_playlist_enqueue_next_ = context_menu_selected_->addAction(IconLoader::Load("go-next"), tr("Play next"), this, &SmartPlaylistsViewContainer::AddToPlaylistEnqueueNext); context_menu_selected_->addSeparator(); context_menu_selected_->addSeparator(); context_menu_selected_->addActions(QList() << action_new_smart_playlist_); - action_edit_smart_playlist_ = context_menu_selected_->addAction(IconLoader::Load("edit-rename"), tr("Edit smart playlist..."), this, SLOT(EditSmartPlaylistFromContext())); - action_delete_smart_playlist_ = context_menu_selected_->addAction(IconLoader::Load("edit-delete"), tr("Delete smart playlist"), this, SLOT(DeleteSmartPlaylistFromContext())); + action_edit_smart_playlist_ = context_menu_selected_->addAction(IconLoader::Load("edit-rename"), tr("Edit smart playlist..."), this, &SmartPlaylistsViewContainer::EditSmartPlaylistFromContext); + action_delete_smart_playlist_ = context_menu_selected_->addAction(IconLoader::Load("edit-delete"), tr("Delete smart playlist"), this, &SmartPlaylistsViewContainer::DeleteSmartPlaylistFromContext); context_menu_selected_->addSeparator(); ui_->new_->setDefaultAction(action_new_smart_playlist_); ui_->edit_->setIcon(IconLoader::Load("edit-rename")); ui_->delete_->setIcon(IconLoader::Load("edit-delete")); - connect(ui_->edit_, SIGNAL(clicked()), SLOT(EditSmartPlaylistFromButton())); - connect(ui_->delete_, SIGNAL(clicked()), SLOT(DeleteSmartPlaylistFromButton())); - connect(ui_->view, SIGNAL(ItemsSelectedChanged()), SLOT(ItemsSelectedChanged())); - connect(ui_->view, SIGNAL(doubleClicked(QModelIndex)), SLOT(ItemDoubleClicked(QModelIndex))); - connect(ui_->view, SIGNAL(RightClicked(QPoint, QModelIndex)), SLOT(RightClicked(QPoint, QModelIndex))); + QObject::connect(ui_->edit_, &QToolButton::clicked, this, &SmartPlaylistsViewContainer::EditSmartPlaylistFromButton); + QObject::connect(ui_->delete_, &QToolButton::clicked, this, &SmartPlaylistsViewContainer::DeleteSmartPlaylistFromButton); + + QObject::connect(ui_->view, &SmartPlaylistsView::ItemsSelectedChanged, this, &SmartPlaylistsViewContainer::ItemsSelectedChanged); + QObject::connect(ui_->view, &SmartPlaylistsView::doubleClicked, this, &SmartPlaylistsViewContainer::ItemDoubleClicked); + QObject::connect(ui_->view, &SmartPlaylistsView::RightClicked, this, &SmartPlaylistsViewContainer::RightClicked); ReloadSettings(); @@ -193,7 +194,7 @@ void SmartPlaylistsViewContainer::NewSmartPlaylist() { SmartPlaylistWizard *wizard = new SmartPlaylistWizard(app_, app_->collection_backend(), this); wizard->setAttribute(Qt::WA_DeleteOnClose); - connect(wizard, SIGNAL(accepted()), SLOT(NewSmartPlaylistFinished())); + QObject::connect(wizard, &SmartPlaylistWizard::accepted, this, &SmartPlaylistsViewContainer::NewSmartPlaylistFinished); wizard->show(); @@ -205,7 +206,7 @@ void SmartPlaylistsViewContainer::EditSmartPlaylist(const QModelIndex &idx) { SmartPlaylistWizard *wizard = new SmartPlaylistWizard(app_, app_->collection_backend(), this); wizard->setAttribute(Qt::WA_DeleteOnClose); - connect(wizard, SIGNAL(accepted()), SLOT(EditSmartPlaylistFinished())); + QObject::connect(wizard, &SmartPlaylistWizard::accepted, this, &SmartPlaylistsViewContainer::EditSmartPlaylistFinished); wizard->show(); wizard->SetGenerator(model_->CreateGenerator(idx)); @@ -254,7 +255,7 @@ void SmartPlaylistsViewContainer::NewSmartPlaylistFinished() { SmartPlaylistWizard *wizard = qobject_cast(sender()); if (!wizard) return; - disconnect(wizard, SIGNAL(accepted()), this, SLOT(NewSmartPlaylistFinished())); + QObject::disconnect(wizard, &SmartPlaylistWizard::accepted, this, &SmartPlaylistsViewContainer::NewSmartPlaylistFinished); model_->AddGenerator(wizard->CreateGenerator()); } @@ -266,7 +267,7 @@ void SmartPlaylistsViewContainer::EditSmartPlaylistFinished() { const SmartPlaylistWizard *wizard = qobject_cast(sender()); if (!wizard) return; - disconnect(wizard, SIGNAL(accepted()), this, SLOT(EditSmartPlaylistFinished())); + QObject::disconnect(wizard, &SmartPlaylistWizard::accepted, this, &SmartPlaylistsViewContainer::EditSmartPlaylistFinished); model_->UpdateGenerator(context_menu_index_, wizard->CreateGenerator()); diff --git a/src/smartplaylists/smartplaylistsviewcontainer.h b/src/smartplaylists/smartplaylistsviewcontainer.h index 03e47576..6c515333 100644 --- a/src/smartplaylists/smartplaylistsviewcontainer.h +++ b/src/smartplaylists/smartplaylistsviewcontainer.h @@ -77,7 +77,6 @@ class SmartPlaylistsViewContainer : public QWidget { signals: void AddToPlaylist(QMimeData *data); - void ItemsSelectedChanged(bool); private: Ui_SmartPlaylistsViewContainer *ui_; diff --git a/src/smartplaylists/smartplaylistwizard.cpp b/src/smartplaylists/smartplaylistwizard.cpp index 33644fb5..76cd4bfc 100644 --- a/src/smartplaylists/smartplaylistwizard.cpp +++ b/src/smartplaylists/smartplaylistwizard.cpp @@ -46,7 +46,7 @@ class SmartPlaylistWizard::FinishPage : public QWizardPage { public: explicit FinishPage(QWidget *parent) : QWizardPage(parent), ui_(new Ui_SmartPlaylistWizardFinishPage) { ui_->setupUi(this); - connect(ui_->name, SIGNAL(textChanged(QString)), SIGNAL(completeChanged())); + QObject::connect(ui_->name, &QLineEdit::textChanged, this, &SmartPlaylistWizard::FinishPage::completeChanged); } ~FinishPage() { delete ui_; } @@ -139,7 +139,7 @@ void SmartPlaylistWizard::AddPlugin(SmartPlaylistWizardPlugin *plugin) { type_page_->layout()->addWidget(radio_button); type_page_->layout()->addWidget(description); - connect(radio_button, &QRadioButton::clicked, [this, index]() { TypeChanged(index); } ); + QObject::connect(radio_button, &QRadioButton::clicked, [this, index]() { TypeChanged(index); } ); if (index == 0) { radio_button->setChecked(true); diff --git a/src/subsonic/subsonicbaserequest.cpp b/src/subsonic/subsonicbaserequest.cpp index 148e198b..385be532 100644 --- a/src/subsonic/subsonicbaserequest.cpp +++ b/src/subsonic/subsonicbaserequest.cpp @@ -101,7 +101,7 @@ QNetworkReply *SubsonicBaseRequest::CreateGetRequest(const QString &ressource_na #endif QNetworkReply *reply = network_->get(req); - connect(reply, SIGNAL(sslErrors(QList)), this, SLOT(HandleSSLErrors(QList))); + QObject::connect(reply, &QNetworkReply::sslErrors, this, &SubsonicBaseRequest::HandleSSLErrors); //qLog(Debug) << "Subsonic: Sending request" << url; diff --git a/src/subsonic/subsonicrequest.cpp b/src/subsonic/subsonicrequest.cpp index 71eaa593..589b65b7 100644 --- a/src/subsonic/subsonicrequest.cpp +++ b/src/subsonic/subsonicrequest.cpp @@ -84,14 +84,14 @@ SubsonicRequest::~SubsonicRequest() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); if (reply->isRunning()) reply->abort(); reply->deleteLater(); } while (!album_cover_replies_.isEmpty()) { QNetworkReply *reply = album_cover_replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); if (reply->isRunning()) reply->abort(); reply->deleteLater(); } @@ -156,7 +156,7 @@ void SubsonicRequest::FlushAlbumsRequests() { QNetworkReply *reply; reply = CreateGetRequest(QString("getAlbumList2"), params); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { AlbumsReplyReceived(reply, request.offset); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { AlbumsReplyReceived(reply, request.offset); }); } @@ -166,7 +166,7 @@ void SubsonicRequest::AlbumsReplyReceived(QNetworkReply *reply, const int offset if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); --albums_requests_active_; @@ -350,7 +350,7 @@ void SubsonicRequest::FlushAlbumSongsRequests() { ParamList params = ParamList() << Param("id", request.album_id); QNetworkReply *reply = CreateGetRequest(QString("getAlbum"), params); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { AlbumSongsReplyReceived(reply, request.artist_id, request.album_id, request.album_artist); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { AlbumSongsReplyReceived(reply, request.artist_id, request.album_id, request.album_artist); }); } @@ -360,7 +360,7 @@ void SubsonicRequest::AlbumSongsReplyReceived(QNetworkReply *reply, const QStrin if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); --album_songs_requests_active_; @@ -743,7 +743,7 @@ void SubsonicRequest::FlushAlbumCoverRequests() { QNetworkReply *reply = network_->get(req); album_cover_replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { AlbumCoverReceived(reply, request.url, request.filename); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { AlbumCoverReceived(reply, request.url, request.filename); }); } @@ -753,7 +753,7 @@ void SubsonicRequest::AlbumCoverReceived(QNetworkReply *reply, const QUrl url, c if (album_cover_replies_.contains(reply)) { album_cover_replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); } else { diff --git a/src/subsonic/subsonicrequest.h b/src/subsonic/subsonicrequest.h index 1a10489f..f28e6f3b 100644 --- a/src/subsonic/subsonicrequest.h +++ b/src/subsonic/subsonicrequest.h @@ -61,10 +61,10 @@ class SubsonicRequest : public SubsonicBaseRequest { void Reset(); signals: - void Results(const SongList &songs, const QString &error); - void UpdateStatus(const QString &text); - void ProgressSetMaximum(const int max); - void UpdateProgress(const int max); + void Results(SongList songs, QString error); + void UpdateStatus(QString text); + void ProgressSetMaximum(int max); + void UpdateProgress(int max); private slots: void AlbumsReplyReceived(QNetworkReply *reply, const int offset_requested); diff --git a/src/subsonic/subsonicscrobblerequest.cpp b/src/subsonic/subsonicscrobblerequest.cpp index 83bfc5c4..4d35fc9b 100644 --- a/src/subsonic/subsonicscrobblerequest.cpp +++ b/src/subsonic/subsonicscrobblerequest.cpp @@ -51,7 +51,7 @@ SubsonicScrobbleRequest::~SubsonicScrobbleRequest() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); if (reply->isRunning()) reply->abort(); reply->deleteLater(); } @@ -84,7 +84,7 @@ void SubsonicScrobbleRequest::FlushScrobbleRequests() { QNetworkReply *reply; reply = CreateGetRequest(QString("scrobble"), params); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { ScrobbleReplyReceived(reply); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply]() { ScrobbleReplyReceived(reply); }); } @@ -94,7 +94,7 @@ void SubsonicScrobbleRequest::ScrobbleReplyReceived(QNetworkReply *reply) { if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); --scrobble_requests_active_; diff --git a/src/subsonic/subsonicservice.cpp b/src/subsonic/subsonicservice.cpp index 257078af..fc9edfba 100644 --- a/src/subsonic/subsonicservice.cpp +++ b/src/subsonic/subsonicservice.cpp @@ -107,7 +107,7 @@ SubsonicService::~SubsonicService() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); if (reply->isRunning()) reply->abort(); reply->deleteLater(); } @@ -118,7 +118,7 @@ SubsonicService::~SubsonicService() { void SubsonicService::Exit() { - connect(collection_backend_, SIGNAL(ExitFinished()), this, SIGNAL(ExitFinished())); + QObject::connect(collection_backend_, &CollectionBackend::ExitFinished, this, &SubsonicService::ExitFinished); collection_backend_->ExitAsync(); } @@ -146,10 +146,10 @@ void SubsonicService::ReloadSettings() { } void SubsonicService::SendPing() { - SendPing(server_url_, username_, password_); + SendPingWithCredentials(server_url_, username_, password_, false); } -void SubsonicService::SendPing(QUrl url, const QString &username, const QString &password, const bool redirect) { +void SubsonicService::SendPingWithCredentials(QUrl url, const QString &username, const QString &password, const bool redirect) { if (!redirect) { network_.reset(new QNetworkAccessManager); @@ -199,8 +199,8 @@ void SubsonicService::SendPing(QUrl url, const QString &username, const QString errors_.clear(); QNetworkReply *reply = network_->get(req); replies_ << reply; - connect(reply, SIGNAL(sslErrors(QList)), this, SLOT(HandlePingSSLErrors(QList))); - connect(reply, &QNetworkReply::finished, [=] { HandlePingReply(reply, url, username, password); }); + QObject::connect(reply, &QNetworkReply::sslErrors, this, &SubsonicService::HandlePingSSLErrors); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, url, username, password]() { HandlePingReply(reply, url, username, password); }); //qLog(Debug) << "Subsonic: Sending request" << url << query; @@ -220,7 +220,7 @@ void SubsonicService::HandlePingReply(QNetworkReply *reply, const QUrl &url, con if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); if (reply->error() != QNetworkReply::NoError || reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) { @@ -246,7 +246,7 @@ void SubsonicService::HandlePingReply(QNetworkReply *reply, const QUrl &url, con if (!redirect_url.isEmpty()) { ++ping_redirects_; qLog(Debug) << "Redirecting ping request to" << redirect_url.toString(QUrl::RemoveQuery); - SendPing(redirect_url, username, password, true); + SendPingWithCredentials(redirect_url, username, password, true); return; } } @@ -399,8 +399,8 @@ void SubsonicService::Scrobble(const QString &song_id, const bool submission, co void SubsonicService::ResetSongsRequest() { if (songs_request_.get()) { - disconnect(songs_request_.get(), nullptr, this, nullptr); - disconnect(this, nullptr, songs_request_.get(), nullptr); + QObject::disconnect(songs_request_.get(), nullptr, this, nullptr); + QObject::disconnect(this, nullptr, songs_request_.get(), nullptr); songs_request_.reset(); } @@ -420,10 +420,10 @@ void SubsonicService::GetSongs() { ResetSongsRequest(); songs_request_.reset(new SubsonicRequest(this, url_handler_, app_, this)); - connect(songs_request_.get(), SIGNAL(Results(SongList, QString)), SLOT(SongsResultsReceived(SongList, QString))); - connect(songs_request_.get(), SIGNAL(UpdateStatus(QString)), SIGNAL(SongsUpdateStatus(QString))); - connect(songs_request_.get(), SIGNAL(ProgressSetMaximum(int)), SIGNAL(SongsProgressSetMaximum(int))); - connect(songs_request_.get(), SIGNAL(UpdateProgress(int)), SIGNAL(SongsUpdateProgress(int))); + QObject::connect(songs_request_.get(), &SubsonicRequest::Results, this, &SubsonicService::SongsResultsReceived); + QObject::connect(songs_request_.get(), &SubsonicRequest::UpdateStatus, this, &SubsonicService::SongsUpdateStatus); + QObject::connect(songs_request_.get(), &SubsonicRequest::ProgressSetMaximum, this, &SubsonicService::SongsProgressSetMaximum); + QObject::connect(songs_request_.get(), &SubsonicRequest::UpdateProgress, this, &SubsonicService::SongsUpdateProgress); songs_request_->GetAlbums(); diff --git a/src/subsonic/subsonicservice.h b/src/subsonic/subsonicservice.h index 452b4b7a..24460910 100644 --- a/src/subsonic/subsonicservice.h +++ b/src/subsonic/subsonicservice.h @@ -86,7 +86,7 @@ class SubsonicService : public InternetService { public slots: void ShowConfig() override; void SendPing(); - void SendPing(QUrl url, const QString &username, const QString &password, const bool redirect = false); + void SendPingWithCredentials(QUrl url, const QString &username, const QString &password, const bool redirect = false); void GetSongs() override; void ResetSongsRequest() override; diff --git a/src/tidal/tidalbaserequest.cpp b/src/tidal/tidalbaserequest.cpp index ab296bcf..e8b9c9af 100644 --- a/src/tidal/tidalbaserequest.cpp +++ b/src/tidal/tidalbaserequest.cpp @@ -71,7 +71,7 @@ QNetworkReply *TidalBaseRequest::CreateRequest(const QString &ressource_name, co if (!session_id().isEmpty()) req.setRawHeader("X-Tidal-SessionId", session_id().toUtf8()); QNetworkReply *reply = network_->get(req); - connect(reply, SIGNAL(sslErrors(QList)), this, SLOT(HandleSSLErrors(QList))); + QObject::connect(reply, &QNetworkReply::sslErrors, this, &TidalBaseRequest::HandleSSLErrors); //qLog(Debug) << "Tidal: Sending request" << url; diff --git a/src/tidal/tidalbaserequest.h b/src/tidal/tidalbaserequest.h index 1d0e6ad7..84b32311 100644 --- a/src/tidal/tidalbaserequest.h +++ b/src/tidal/tidalbaserequest.h @@ -98,7 +98,6 @@ class TidalBaseRequest : public QObject { void HandleSSLErrors(QList ssl_errors); private: - static const char *kApiUrl; TidalService *service_; diff --git a/src/tidal/tidalfavoriterequest.cpp b/src/tidal/tidalfavoriterequest.cpp index 305da765..cddb9ca6 100644 --- a/src/tidal/tidalfavoriterequest.cpp +++ b/src/tidal/tidalfavoriterequest.cpp @@ -51,7 +51,7 @@ TidalFavoriteRequest::~TidalFavoriteRequest() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } @@ -145,7 +145,7 @@ void TidalFavoriteRequest::AddFavorites(const FavoriteType type, const SongList if (!session_id().isEmpty()) req.setRawHeader("X-Tidal-SessionId", session_id().toUtf8()); QByteArray query = url_query.toString(QUrl::FullyEncoded).toUtf8(); QNetworkReply *reply = network_->post(req, query); - connect(reply, &QNetworkReply::finished, [=] { AddFavoritesReply(reply, type, songs); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, type, songs]() { AddFavoritesReply(reply, type, songs); }); replies_ << reply; qLog(Debug) << "Tidal: Sending request" << url << query; @@ -156,7 +156,7 @@ void TidalFavoriteRequest::AddFavoritesReply(QNetworkReply *reply, const Favorit if (replies_.contains(reply)) { replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); } else { @@ -252,7 +252,7 @@ void TidalFavoriteRequest::RemoveFavorites(const FavoriteType type, const QStrin if (!access_token().isEmpty()) req.setRawHeader("authorization", "Bearer " + access_token().toUtf8()); if (!session_id().isEmpty()) req.setRawHeader("X-Tidal-SessionId", session_id().toUtf8()); QNetworkReply *reply = network_->deleteResource(req); - connect(reply, &QNetworkReply::finished, [=] { RemoveFavoritesReply(reply, type, songs); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, type, songs]() { RemoveFavoritesReply(reply, type, songs); }); replies_ << reply; qLog(Debug) << "Tidal: Sending request" << url << "with" << songs.count() << "songs"; @@ -263,7 +263,7 @@ void TidalFavoriteRequest::RemoveFavoritesReply(QNetworkReply *reply, const Favo if (replies_.contains(reply)) { replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); } else { diff --git a/src/tidal/tidalfavoriterequest.h b/src/tidal/tidalfavoriterequest.h index f41d7d1d..959d2193 100644 --- a/src/tidal/tidalfavoriterequest.h +++ b/src/tidal/tidalfavoriterequest.h @@ -52,14 +52,18 @@ class TidalFavoriteRequest : public TidalBaseRequest { void NeedLogin() override { need_login_ = true; } signals: - void ArtistsAdded(const SongList &songs); - void AlbumsAdded(const SongList &songs); - void SongsAdded(const SongList &songs); - void ArtistsRemoved(const SongList &songs); - void AlbumsRemoved(const SongList &songs); - void SongsRemoved(const SongList &songs); + void ArtistsAdded(SongList); + void AlbumsAdded(SongList); + void SongsAdded(SongList); + void ArtistsRemoved(SongList); + void AlbumsRemoved(SongList); + void SongsRemoved(SongList); private slots: + void AddFavoritesReply(QNetworkReply *reply, const FavoriteType type, const SongList &songs); + void RemoveFavoritesReply(QNetworkReply *reply, const FavoriteType type, const SongList &songs); + + public slots: void AddArtists(const SongList &songs); void AddAlbums(const SongList &songs); void AddSongs(const SongList &songs); @@ -68,9 +72,6 @@ class TidalFavoriteRequest : public TidalBaseRequest { void RemoveAlbums(const SongList &songs); void RemoveSongs(const SongList &songs); - void AddFavoritesReply(QNetworkReply *reply, const FavoriteType type, const SongList &songs); - void RemoveFavoritesReply(QNetworkReply *reply, const FavoriteType type, const SongList &songs); - private: void Error(const QString &error, const QVariant &debug = QVariant()) override; QString FavoriteText(const FavoriteType type); diff --git a/src/tidal/tidalrequest.cpp b/src/tidal/tidalrequest.cpp index 054fc098..39908005 100644 --- a/src/tidal/tidalrequest.cpp +++ b/src/tidal/tidalrequest.cpp @@ -84,14 +84,14 @@ TidalRequest::~TidalRequest() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); if (reply->isRunning()) reply->abort(); reply->deleteLater(); } while (!album_cover_replies_.isEmpty()) { QNetworkReply *reply = album_cover_replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); if (reply->isRunning()) reply->abort(); reply->deleteLater(); } @@ -190,7 +190,7 @@ void TidalRequest::FlushArtistsRequests() { } if (!reply) continue; replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { ArtistsReplyReceived(reply, request.limit, request.offset); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { ArtistsReplyReceived(reply, request.limit, request.offset); }); } @@ -234,7 +234,7 @@ void TidalRequest::FlushAlbumsRequests() { } if (!reply) continue; replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { AlbumsReplyReceived(reply, request.limit, request.offset); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { AlbumsReplyReceived(reply, request.limit, request.offset); }); } @@ -278,7 +278,7 @@ void TidalRequest::FlushSongsRequests() { } if (!reply) continue; replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { SongsReplyReceived(reply, request.limit, request.offset); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { SongsReplyReceived(reply, request.limit, request.offset); }); } @@ -330,7 +330,7 @@ void TidalRequest::ArtistsReplyReceived(QNetworkReply *reply, const int limit_re if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QByteArray data = GetReplyData(reply, (offset_requested == 0)); @@ -501,7 +501,7 @@ void TidalRequest::FlushArtistAlbumsRequests() { ParamList parameters; if (request.offset > 0) parameters << Param("offset", QString::number(request.offset)); QNetworkReply *reply = CreateRequest(QString("artists/%1/albums").arg(request.artist_id), parameters); - connect(reply, &QNetworkReply::finished, [=] { ArtistAlbumsReplyReceived(reply, request.artist_id, request.offset); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { ArtistAlbumsReplyReceived(reply, request.artist_id, request.offset); }); replies_ << reply; } @@ -522,7 +522,7 @@ void TidalRequest::AlbumsReceived(QNetworkReply *reply, const QString &artist_id if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QByteArray data = GetReplyData(reply, auto_login); @@ -768,7 +768,7 @@ void TidalRequest::FlushAlbumSongsRequests() { if (request.offset > 0) parameters << Param("offset", QString::number(request.offset)); QNetworkReply *reply = CreateRequest(QString("albums/%1/tracks").arg(request.album_id), parameters); replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { AlbumSongsReplyReceived(reply, request.artist_id, request.album_id, request.offset, request.album_artist); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { AlbumSongsReplyReceived(reply, request.artist_id, request.album_id, request.offset, request.album_artist); }); } @@ -789,7 +789,7 @@ void TidalRequest::SongsReceived(QNetworkReply *reply, const QString &artist_id, if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); QByteArray data = GetReplyData(reply, auto_login); @@ -1125,7 +1125,7 @@ void TidalRequest::FlushAlbumCoverRequests() { #endif QNetworkReply *reply = network_->get(req); album_cover_replies_ << reply; - connect(reply, &QNetworkReply::finished, [=] { AlbumCoverReceived(reply, request.album_id, request.url, request.filename); }); + QObject::connect(reply, &QNetworkReply::finished, [this, reply, request]() { AlbumCoverReceived(reply, request.album_id, request.url, request.filename); }); } @@ -1135,7 +1135,7 @@ void TidalRequest::AlbumCoverReceived(QNetworkReply *reply, const QString &album if (album_cover_replies_.contains(reply)) { album_cover_replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); } else { diff --git a/src/tidal/tidalrequest.h b/src/tidal/tidalrequest.h index 5809c655..560fc432 100644 --- a/src/tidal/tidalrequest.h +++ b/src/tidal/tidalrequest.h @@ -62,18 +62,16 @@ class TidalRequest : public TidalBaseRequest { signals: void Login(); - void Login(const QString &username, const QString &password, const QString &token); + void Login(QString username, QString password, QString token); void LoginSuccess(); void LoginFailure(QString failure_reason); - void Results(const int id, const SongList &songs, const QString &error); - void UpdateStatus(const int id, const QString &text); - void ProgressSetMaximum(const int id, const int max); - void UpdateProgress(const int id, const int max); - void StreamURLFinished(const QUrl original_url, const QUrl url, const Song::FileType, QString error = QString()); + void Results(int id, SongList songs, QString error); + void UpdateStatus(int id, QString text); + void ProgressSetMaximum(int id, int max); + void UpdateProgress(int id, int max); + void StreamURLFinished(QUrl original_url, QUrl url, Song::FileType, QString error = QString()); private slots: - void LoginComplete(const bool success, QString error = QString()); - void ArtistsReplyReceived(QNetworkReply *reply, const int limit_requested, const int offset_requested); void AlbumsReplyReceived(QNetworkReply *reply, const int limit_requested, const int offset_requested); @@ -86,6 +84,9 @@ class TidalRequest : public TidalBaseRequest { void AlbumSongsReplyReceived(QNetworkReply *reply, const QString &artist_id, const QString &album_id, const int offset_requested, const QString &album_artist); void AlbumCoverReceived(QNetworkReply *reply, const QString &album_id, const QUrl &url, const QString &filename); + public slots: + void LoginComplete(const bool success, QString error = QString()); + private: struct Request { Request() : offset(0), limit(0) {} diff --git a/src/tidal/tidalservice.cpp b/src/tidal/tidalservice.cpp index 458abf9c..954e5081 100644 --- a/src/tidal/tidalservice.cpp +++ b/src/tidal/tidalservice.cpp @@ -154,33 +154,33 @@ TidalService::TidalService(Application *app, QObject *parent) // Search timer_search_delay_->setSingleShot(true); - connect(timer_search_delay_, SIGNAL(timeout()), SLOT(StartSearch())); + QObject::connect(timer_search_delay_, &QTimer::timeout, this, &TidalService::StartSearch); timer_login_attempt_->setSingleShot(true); timer_login_attempt_->setInterval(kTimeResetLoginAttempts); - connect(timer_login_attempt_, SIGNAL(timeout()), SLOT(ResetLoginAttempts())); + QObject::connect(timer_login_attempt_, &QTimer::timeout, this, &TidalService::ResetLoginAttempts); timer_refresh_login_->setSingleShot(true); - connect(timer_refresh_login_, SIGNAL(timeout()), SLOT(RequestAccessToken())); + QObject::connect(timer_refresh_login_, &QTimer::timeout, this, &TidalService::RequestNewAccessToken); - connect(this, SIGNAL(Login()), SLOT(SendLogin())); - connect(this, SIGNAL(Login(QString, QString, QString)), SLOT(SendLogin(QString, QString, QString))); + QObject::connect(this, &TidalService::Login, this, &TidalService::SendLogin); + QObject::connect(this, &TidalService::LoginWithCredentials, this, &TidalService::SendLoginWithCredentials); - connect(this, SIGNAL(AddArtists(SongList)), favorite_request_, SLOT(AddArtists(SongList))); - connect(this, SIGNAL(AddAlbums(SongList)), favorite_request_, SLOT(AddAlbums(SongList))); - connect(this, SIGNAL(AddSongs(SongList)), favorite_request_, SLOT(AddSongs(SongList))); + QObject::connect(this, &TidalService::AddArtists, favorite_request_, &TidalFavoriteRequest::AddArtists); + QObject::connect(this, &TidalService::AddAlbums, favorite_request_, &TidalFavoriteRequest::AddAlbums); + QObject::connect(this, &TidalService::AddSongs, favorite_request_, &TidalFavoriteRequest::AddSongs); - connect(this, SIGNAL(RemoveArtists(SongList)), favorite_request_, SLOT(RemoveArtists(SongList))); - connect(this, SIGNAL(RemoveAlbums(SongList)), favorite_request_, SLOT(RemoveAlbums(SongList))); - connect(this, SIGNAL(RemoveSongs(SongList)), favorite_request_, SLOT(RemoveSongs(SongList))); + QObject::connect(this, &TidalService::RemoveArtists, favorite_request_, &TidalFavoriteRequest::RemoveArtists); + QObject::connect(this, &TidalService::RemoveAlbums, favorite_request_, &TidalFavoriteRequest::RemoveAlbums); + QObject::connect(this, &TidalService::RemoveSongs, favorite_request_, &TidalFavoriteRequest::RemoveSongs); - connect(favorite_request_, SIGNAL(ArtistsAdded(SongList)), artists_collection_backend_, SLOT(AddOrUpdateSongs(SongList))); - connect(favorite_request_, SIGNAL(AlbumsAdded(SongList)), albums_collection_backend_, SLOT(AddOrUpdateSongs(SongList))); - connect(favorite_request_, SIGNAL(SongsAdded(SongList)), songs_collection_backend_, SLOT(AddOrUpdateSongs(SongList))); + QObject::connect(favorite_request_, &TidalFavoriteRequest::ArtistsAdded, artists_collection_backend_, &CollectionBackend::AddOrUpdateSongs); + QObject::connect(favorite_request_, &TidalFavoriteRequest::AlbumsAdded, albums_collection_backend_, &CollectionBackend::AddOrUpdateSongs); + QObject::connect(favorite_request_, &TidalFavoriteRequest::SongsAdded, songs_collection_backend_, &CollectionBackend::AddOrUpdateSongs); - connect(favorite_request_, SIGNAL(ArtistsRemoved(SongList)), artists_collection_backend_, SLOT(DeleteSongs(SongList))); - connect(favorite_request_, SIGNAL(AlbumsRemoved(SongList)), albums_collection_backend_, SLOT(DeleteSongs(SongList))); - connect(favorite_request_, SIGNAL(SongsRemoved(SongList)), songs_collection_backend_, SLOT(DeleteSongs(SongList))); + QObject::connect(favorite_request_, &TidalFavoriteRequest::ArtistsRemoved, artists_collection_backend_, &CollectionBackend::DeleteSongs); + QObject::connect(favorite_request_, &TidalFavoriteRequest::AlbumsRemoved, albums_collection_backend_, &CollectionBackend::DeleteSongs); + QObject::connect(favorite_request_, &TidalFavoriteRequest::SongsRemoved, songs_collection_backend_, &CollectionBackend::DeleteSongs); ReloadSettings(); LoadSession(); @@ -191,14 +191,14 @@ TidalService::~TidalService() { while (!replies_.isEmpty()) { QNetworkReply *reply = replies_.takeFirst(); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->abort(); reply->deleteLater(); } while (!stream_url_requests_.isEmpty()) { TidalStreamURLRequest *stream_url_req = stream_url_requests_.takeFirst(); - disconnect(stream_url_req, nullptr, this, nullptr); + QObject::disconnect(stream_url_req, nullptr, this, nullptr); stream_url_req->deleteLater(); } @@ -212,9 +212,9 @@ void TidalService::Exit() { wait_for_exit_ << artists_collection_backend_ << albums_collection_backend_ << songs_collection_backend_; - connect(artists_collection_backend_, SIGNAL(ExitFinished()), this, SLOT(ExitReceived())); - connect(albums_collection_backend_, SIGNAL(ExitFinished()), this, SLOT(ExitReceived())); - connect(songs_collection_backend_, SIGNAL(ExitFinished()), this, SLOT(ExitReceived())); + QObject::connect(artists_collection_backend_, &CollectionBackend::ExitFinished, this, &TidalService::ExitReceived); + QObject::connect(albums_collection_backend_, &CollectionBackend::ExitFinished, this, &TidalService::ExitReceived); + QObject::connect(songs_collection_backend_, &CollectionBackend::ExitFinished, this, &TidalService::ExitReceived); artists_collection_backend_->ExitAsync(); albums_collection_backend_->ExitAsync(); @@ -225,7 +225,7 @@ void TidalService::Exit() { void TidalService::ExitReceived() { QObject *obj = qobject_cast(sender()); - disconnect(obj, nullptr, this, nullptr); + QObject::disconnect(obj, nullptr, this, nullptr); qLog(Debug) << obj << "successfully exited."; wait_for_exit_.removeAll(obj); if (wait_for_exit_.isEmpty()) emit ExitFinished(); @@ -400,8 +400,8 @@ void TidalService::RequestAccessToken(const QString &code) { login_errors_.clear(); QNetworkReply *reply = network_->post(req, query); replies_ << reply; - connect(reply, SIGNAL(sslErrors(QList)), this, SLOT(HandleLoginSSLErrors(QList))); - connect(reply, &QNetworkReply::finished, [=] { AccessTokenRequestFinished(reply); }); + QObject::connect(reply, &QNetworkReply::sslErrors, this, &TidalService::HandleLoginSSLErrors); + QObject::connect(reply, &QNetworkReply::finished, [this, reply]() { AccessTokenRequestFinished(reply); }); } @@ -417,7 +417,7 @@ void TidalService::AccessTokenRequestFinished(QNetworkReply *reply) { if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); if (reply->error() != QNetworkReply::NoError || reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) { @@ -524,10 +524,10 @@ void TidalService::AccessTokenRequestFinished(QNetworkReply *reply) { } void TidalService::SendLogin() { - SendLogin(api_token_, username_, password_); + SendLoginWithCredentials(api_token_, username_, password_); } -void TidalService::SendLogin(const QString &api_token, const QString &username, const QString &password) { +void TidalService::SendLoginWithCredentials(const QString &api_token, const QString &username, const QString &password) { login_sent_ = true; ++login_attempts_; @@ -552,8 +552,8 @@ void TidalService::SendLogin(const QString &api_token, const QString &username, QByteArray query = url_query.toString(QUrl::FullyEncoded).toUtf8(); QNetworkReply *reply = network_->post(req, query); - connect(reply, SIGNAL(sslErrors(QList)), this, SLOT(HandleLoginSSLErrors(QList))); - connect(reply, &QNetworkReply::finished, [=] { HandleAuthReply(reply); }); + QObject::connect(reply, &QNetworkReply::sslErrors, this, &TidalService::HandleLoginSSLErrors); + QObject::connect(reply, &QNetworkReply::finished, [this, reply]() { HandleAuthReply(reply); }); replies_ << reply; //qLog(Debug) << "Tidal: Sending request" << url << query; @@ -564,7 +564,7 @@ void TidalService::HandleAuthReply(QNetworkReply *reply) { if (!replies_.contains(reply)) return; replies_.removeAll(reply); - disconnect(reply, nullptr, this, nullptr); + QObject::disconnect(reply, nullptr, this, nullptr); reply->deleteLater(); login_sent_ = false; @@ -718,8 +718,8 @@ void TidalService::TryLogin() { void TidalService::ResetArtistsRequest() { if (artists_request_.get()) { - disconnect(artists_request_.get(), nullptr, this, nullptr); - disconnect(this, nullptr, artists_request_.get(), nullptr); + QObject::disconnect(artists_request_.get(), nullptr, this, nullptr); + QObject::disconnect(this, nullptr, artists_request_.get(), nullptr); artists_request_.reset(); } @@ -744,11 +744,11 @@ void TidalService::GetArtists() { artists_request_.reset(new TidalRequest(this, url_handler_, app_, network_, TidalBaseRequest::QueryType_Artists, this)); - connect(artists_request_.get(), SIGNAL(Results(int, SongList, QString)), SLOT(ArtistsResultsReceived(int, SongList, QString))); - connect(artists_request_.get(), SIGNAL(UpdateStatus(int, QString)), SLOT(ArtistsUpdateStatusReceived(int, QString))); - connect(artists_request_.get(), SIGNAL(ProgressSetMaximum(int, int)), SLOT(ArtistsProgressSetMaximumReceived(int, int))); - connect(artists_request_.get(), SIGNAL(UpdateProgress(int, int)), SLOT(ArtistsUpdateProgressReceived(int, int))); - connect(this, SIGNAL(LoginComplete(bool, QString)), artists_request_.get(), SLOT(LoginComplete(bool, QString))); + QObject::connect(artists_request_.get(), &TidalRequest::Results, this, &TidalService::ArtistsResultsReceived); + QObject::connect(artists_request_.get(), &TidalRequest::UpdateStatus, this, &TidalService::ArtistsUpdateStatusReceived); + QObject::connect(artists_request_.get(), &TidalRequest::ProgressSetMaximum, this, &TidalService::ArtistsProgressSetMaximumReceived); + QObject::connect(artists_request_.get(), &TidalRequest::UpdateProgress, this, &TidalService::ArtistsUpdateProgressReceived); + QObject::connect(this, &TidalService::LoginComplete, artists_request_.get(), &TidalRequest::LoginComplete); artists_request_->Process(); @@ -777,8 +777,8 @@ void TidalService::ArtistsUpdateProgressReceived(const int id, const int progres void TidalService::ResetAlbumsRequest() { if (albums_request_.get()) { - disconnect(albums_request_.get(), nullptr, this, nullptr); - disconnect(this, nullptr, albums_request_.get(), nullptr); + QObject::disconnect(albums_request_.get(), nullptr, this, nullptr); + QObject::disconnect(this, nullptr, albums_request_.get(), nullptr); albums_request_.reset(); } @@ -801,11 +801,11 @@ void TidalService::GetAlbums() { ResetAlbumsRequest(); albums_request_.reset(new TidalRequest(this, url_handler_, app_, network_, TidalBaseRequest::QueryType_Albums, this)); - connect(albums_request_.get(), SIGNAL(Results(int, SongList, QString)), SLOT(AlbumsResultsReceived(int, SongList, QString))); - connect(albums_request_.get(), SIGNAL(UpdateStatus(int, QString)), SLOT(AlbumsUpdateStatusReceived(int, QString))); - connect(albums_request_.get(), SIGNAL(ProgressSetMaximum(int, int)), SLOT(AlbumsProgressSetMaximumReceived(int, int))); - connect(albums_request_.get(), SIGNAL(UpdateProgress(int, int)), SLOT(AlbumsUpdateProgressReceived(int, int))); - connect(this, SIGNAL(LoginComplete(bool, QString)), albums_request_.get(), SLOT(LoginComplete(bool, QString))); + QObject::connect(albums_request_.get(), &TidalRequest::Results, this, &TidalService::AlbumsResultsReceived); + QObject::connect(albums_request_.get(), &TidalRequest::UpdateStatus, this, &TidalService::AlbumsUpdateStatusReceived); + QObject::connect(albums_request_.get(), &TidalRequest::ProgressSetMaximum, this, &TidalService::AlbumsProgressSetMaximumReceived); + QObject::connect(albums_request_.get(), &TidalRequest::UpdateProgress, this, &TidalService::AlbumsUpdateProgressReceived); + QObject::connect(this, &TidalService::LoginComplete, albums_request_.get(), &TidalRequest::LoginComplete); albums_request_->Process(); @@ -834,8 +834,8 @@ void TidalService::AlbumsUpdateProgressReceived(const int id, const int progress void TidalService::ResetSongsRequest() { if (songs_request_.get()) { - disconnect(songs_request_.get(), nullptr, this, nullptr); - disconnect(this, nullptr, songs_request_.get(), nullptr); + QObject::disconnect(songs_request_.get(), nullptr, this, nullptr); + QObject::disconnect(this, nullptr, songs_request_.get(), nullptr); songs_request_.reset(); } @@ -858,11 +858,11 @@ void TidalService::GetSongs() { ResetSongsRequest(); songs_request_.reset(new TidalRequest(this, url_handler_, app_, network_, TidalBaseRequest::QueryType_Songs, this)); - connect(songs_request_.get(), SIGNAL(Results(int, SongList, QString)), SLOT(SongsResultsReceived(int, SongList, QString))); - connect(songs_request_.get(), SIGNAL(UpdateStatus(int, QString)), SLOT(SongsUpdateStatusReceived(int, QString))); - connect(songs_request_.get(), SIGNAL(ProgressSetMaximum(int, int)), SLOT(SongsProgressSetMaximumReceived(int, int))); - connect(songs_request_.get(), SIGNAL(UpdateProgress(int, int)), SLOT(SongsUpdateProgressReceived(int, int))); - connect(this, SIGNAL(LoginComplete(bool, QString)), songs_request_.get(), SLOT(LoginComplete(bool, QString))); + QObject::connect(songs_request_.get(), &TidalRequest::Results, this, &TidalService::SongsResultsReceived); + QObject::connect(songs_request_.get(), &TidalRequest::UpdateStatus, this, &TidalService::SongsUpdateStatusReceived); + QObject::connect(songs_request_.get(), &TidalRequest::ProgressSetMaximum, this, &TidalService::SongsProgressSetMaximumReceived); + QObject::connect(songs_request_.get(), &TidalRequest::UpdateProgress, this, &TidalService::SongsUpdateProgressReceived); + QObject::connect(this, &TidalService::LoginComplete, songs_request_.get(), &TidalRequest::LoginComplete); songs_request_->Process(); @@ -952,11 +952,11 @@ void TidalService::SendSearch() { search_request_.reset(new TidalRequest(this, url_handler_, app_, network_, type, this)); - connect(search_request_.get(), SIGNAL(Results(int, SongList, QString)), SLOT(SearchResultsReceived(int, SongList, QString))); - connect(search_request_.get(), SIGNAL(UpdateStatus(int, QString)), SIGNAL(SearchUpdateStatus(int, QString))); - connect(search_request_.get(), SIGNAL(ProgressSetMaximum(int, int)), SIGNAL(SearchProgressSetMaximum(int, int))); - connect(search_request_.get(), SIGNAL(UpdateProgress(int, int)), SIGNAL(SearchUpdateProgress(int, int))); - connect(this, SIGNAL(LoginComplete(bool, QString)), search_request_.get(), SLOT(LoginComplete(bool, QString))); + QObject::connect(search_request_.get(), &TidalRequest::Results, this, &TidalService::SearchResultsReceived); + QObject::connect(search_request_.get(), &TidalRequest::UpdateStatus, this, &TidalService::SearchUpdateStatus); + QObject::connect(search_request_.get(), &TidalRequest::ProgressSetMaximum, this, &TidalService::SearchProgressSetMaximum); + QObject::connect(search_request_.get(), &TidalRequest::UpdateProgress, this, &TidalService::SearchUpdateProgress); + QObject::connect(this, &TidalService::LoginComplete, search_request_.get(), &TidalRequest::LoginComplete); search_request_->Search(search_id_, search_text_); search_request_->Process(); @@ -983,9 +983,9 @@ void TidalService::GetStreamURL(const QUrl &url) { TidalStreamURLRequest *stream_url_req = new TidalStreamURLRequest(this, network_, url, this); stream_url_requests_ << stream_url_req; - connect(stream_url_req, SIGNAL(TryLogin()), this, SLOT(TryLogin())); - connect(stream_url_req, SIGNAL(StreamURLFinished(QUrl, QUrl, Song::FileType, int, int, qint64, QString)), this, SLOT(HandleStreamURLFinished(QUrl, QUrl, Song::FileType, int, int, qint64, QString))); - connect(this, SIGNAL(LoginComplete(bool, QString)), stream_url_req, SLOT(LoginComplete(bool, QString))); + QObject::connect(stream_url_req, &TidalStreamURLRequest::TryLogin, this, &TidalService::TryLogin); + QObject::connect(stream_url_req, &TidalStreamURLRequest::StreamURLFinished, this, &TidalService::HandleStreamURLFinished); + QObject::connect(this, &TidalService::LoginComplete, stream_url_req, &TidalStreamURLRequest::LoginComplete); stream_url_req->Process(); diff --git a/src/tidal/tidalservice.h b/src/tidal/tidalservice.h index 208ae966..9752a59b 100644 --- a/src/tidal/tidalservice.h +++ b/src/tidal/tidalservice.h @@ -123,23 +123,23 @@ class TidalService : public InternetService { public slots: void ShowConfig() override; + void StartAuthorization(const QString client_id); void TryLogin(); - void SendLogin(const QString &api_token, const QString &username, const QString &password); + void SendLogin(); + void SendLoginWithCredentials(const QString &api_token, const QString &username, const QString &password); void GetArtists() override; void GetAlbums() override; void GetSongs() override; void ResetArtistsRequest() override; void ResetAlbumsRequest() override; void ResetSongsRequest() override; + void AuthorizationUrlReceived(const QUrl &url); private slots: void ExitReceived(); - void StartAuthorization(const QString client_id); - void AuthorizationUrlReceived(const QUrl &url); - void RequestAccessToken(const QString &code = QString()); + void RequestNewAccessToken() { RequestAccessToken(); } void HandleLoginSSLErrors(QList ssl_errors); void AccessTokenRequestFinished(QNetworkReply *reply); - void SendLogin(); void HandleAuthReply(QNetworkReply *reply); void ResetLoginAttempts(); void StartSearch(); @@ -163,6 +163,7 @@ class TidalService : public InternetService { typedef QList ParamList; void LoadSession(); + void RequestAccessToken(const QString &code = QString()); void SendSearch(); void LoginError(const QString &error = QString(), const QVariant &debug = QVariant()); diff --git a/src/tidal/tidalstreamurlrequest.cpp b/src/tidal/tidalstreamurlrequest.cpp index 13079f8d..c09426b8 100644 --- a/src/tidal/tidalstreamurlrequest.cpp +++ b/src/tidal/tidalstreamurlrequest.cpp @@ -58,7 +58,7 @@ TidalStreamURLRequest::TidalStreamURLRequest(TidalService *service, NetworkAcces TidalStreamURLRequest::~TidalStreamURLRequest() { if (reply_) { - disconnect(reply_, nullptr, this, nullptr); + QObject::disconnect(reply_, nullptr, this, nullptr); if (reply_->isRunning()) reply_->abort(); reply_->deleteLater(); } @@ -115,7 +115,7 @@ void TidalStreamURLRequest::GetStreamURL() { ++tries_; if (reply_) { - disconnect(reply_, nullptr, this, nullptr); + QObject::disconnect(reply_, nullptr, this, nullptr); if (reply_->isRunning()) reply_->abort(); reply_->deleteLater(); } @@ -126,7 +126,7 @@ void TidalStreamURLRequest::GetStreamURL() { case TidalSettingsPage::StreamUrlMethod_StreamUrl: params << Param("soundQuality", quality()); reply_ = CreateRequest(QString("tracks/%1/streamUrl").arg(song_id_), params); - connect(reply_, SIGNAL(finished()), this, SLOT(StreamURLReceived())); + QObject::connect(reply_, &QNetworkReply::finished, this, &TidalStreamURLRequest::StreamURLReceived); break; case TidalSettingsPage::StreamUrlMethod_UrlPostPaywall: params << Param("audioquality", quality()); @@ -134,14 +134,14 @@ void TidalStreamURLRequest::GetStreamURL() { params << Param("assetpresentation", "FULL"); params << Param("urlusagemode", "STREAM"); reply_ = CreateRequest(QString("tracks/%1/urlpostpaywall").arg(song_id_), params); - connect(reply_, SIGNAL(finished()), this, SLOT(StreamURLReceived())); + QObject::connect(reply_, &QNetworkReply::finished, this, &TidalStreamURLRequest::StreamURLReceived); break; case TidalSettingsPage::StreamUrlMethod_PlaybackInfoPostPaywall: params << Param("audioquality", quality()); params << Param("playbackmode", "STREAM"); params << Param("assetpresentation", "FULL"); reply_ = CreateRequest(QString("tracks/%1/playbackinfopostpaywall").arg(song_id_), params); - connect(reply_, SIGNAL(finished()), this, SLOT(StreamURLReceived())); + QObject::connect(reply_, &QNetworkReply::finished, this, &TidalStreamURLRequest::StreamURLReceived); break; } @@ -150,7 +150,7 @@ void TidalStreamURLRequest::GetStreamURL() { void TidalStreamURLRequest::StreamURLReceived() { if (!reply_) return; - disconnect(reply_, nullptr, this, nullptr); + QObject::disconnect(reply_, nullptr, this, nullptr); reply_->deleteLater(); QByteArray data = GetReplyData(reply_, true); diff --git a/src/tidal/tidalstreamurlrequest.h b/src/tidal/tidalstreamurlrequest.h index 130dd2b2..1b2c0ab5 100644 --- a/src/tidal/tidalstreamurlrequest.h +++ b/src/tidal/tidalstreamurlrequest.h @@ -57,12 +57,14 @@ class TidalStreamURLRequest : public TidalBaseRequest { signals: void TryLogin(); - void StreamURLFinished(const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration, QString error = QString()); + void StreamURLFinished(QUrl original_url, QUrl stream_url, Song::FileType filetype, int samplerate, int bit_depth, qint64 duration, QString error = QString()); private slots: - void LoginComplete(const bool success, QString error = QString()); void StreamURLReceived(); + public slots: + void LoginComplete(const bool success, QString error = QString()); + private: void Error(const QString &error, const QVariant &debug = QVariant()) override; diff --git a/src/tidal/tidalurlhandler.cpp b/src/tidal/tidalurlhandler.cpp index 64089628..6e96645b 100644 --- a/src/tidal/tidalurlhandler.cpp +++ b/src/tidal/tidalurlhandler.cpp @@ -36,7 +36,7 @@ TidalUrlHandler::TidalUrlHandler(Application *app, TidalService *service) : task_id_(-1) { - connect(service, SIGNAL(StreamURLFinished(QUrl, QUrl, Song::FileType, int, int, qint64, QString)), this, SLOT(GetStreamURLFinished(QUrl, QUrl, Song::FileType, int, int, qint64, QString))); + QObject::connect(service, &TidalService::StreamURLFinished, this, &TidalUrlHandler::GetStreamURLFinished); } diff --git a/src/tidal/tidalurlhandler.h b/src/tidal/tidalurlhandler.h index a0b22f0b..9f6aa5e7 100644 --- a/src/tidal/tidalurlhandler.h +++ b/src/tidal/tidalurlhandler.h @@ -54,4 +54,4 @@ class TidalUrlHandler : public UrlHandler { }; -#endif +#endif // TIDALURLHANDLER_H diff --git a/src/transcoder/transcodedialog.cpp b/src/transcoder/transcodedialog.cpp index 7513a514..5f0a22dd 100644 --- a/src/transcoder/transcodedialog.cpp +++ b/src/transcoder/transcodedialog.cpp @@ -97,7 +97,7 @@ TranscodeDialog::TranscodeDialog(QMainWindow *mainwindow, QWidget *parent) log_ui_->setupUi(log_dialog_); QPushButton *clear_button = log_ui_->buttonBox->addButton(tr("Clear"), QDialogButtonBox::ResetRole); - connect(clear_button, SIGNAL(clicked()), log_ui_->log, SLOT(clear())); + QObject::connect(clear_button, &QPushButton::clicked, log_ui_->log, &QPlainTextEdit::clear); // Get presets QList presets = Transcoder::GetAllPresets(); @@ -133,19 +133,19 @@ TranscodeDialog::TranscodeDialog(QMainWindow *mainwindow, QWidget *parent) ui_->progress_group->hide(); // Connect stuff - connect(ui_->add, SIGNAL(clicked()), SLOT(Add())); - connect(ui_->import, SIGNAL(clicked()), SLOT(Import())); - connect(ui_->remove, SIGNAL(clicked()), SLOT(Remove())); - connect(start_button_, SIGNAL(clicked()), SLOT(Start())); - connect(cancel_button_, SIGNAL(clicked()), SLOT(Cancel())); - connect(close_button_, SIGNAL(clicked()), SLOT(hide())); - connect(ui_->details, SIGNAL(clicked()), log_dialog_, SLOT(show())); - connect(ui_->options, SIGNAL(clicked()), SLOT(Options())); - connect(ui_->select, SIGNAL(clicked()), SLOT(AddDestination())); + QObject::connect(ui_->add, &QPushButton::clicked, this, &TranscodeDialog::Add); + QObject::connect(ui_->import, &QPushButton::clicked, this, &TranscodeDialog::Import); + QObject::connect(ui_->remove, &QPushButton::clicked, this, &TranscodeDialog::Remove); + QObject::connect(start_button_, &QPushButton::clicked, this, &TranscodeDialog::Start); + QObject::connect(cancel_button_, &QPushButton::clicked, this, &TranscodeDialog::Cancel); + QObject::connect(close_button_, &QPushButton::clicked, this, &TranscodeDialog::hide); + QObject::connect(ui_->details, &QPushButton::clicked, log_dialog_, &QDialog::show); + QObject::connect(ui_->options, &QPushButton::clicked, this, &TranscodeDialog::Options); + QObject::connect(ui_->select, &QPushButton::clicked, this, &TranscodeDialog::AddDestination); - connect(transcoder_, SIGNAL(JobComplete(QString, QString, bool)), SLOT(JobComplete(QString, QString, bool))); - connect(transcoder_, SIGNAL(LogLine(QString)), SLOT(LogLine(QString))); - connect(transcoder_, SIGNAL(AllJobsComplete()), SLOT(AllJobsComplete())); + QObject::connect(transcoder_, &Transcoder::JobComplete, this, &TranscodeDialog::JobComplete); + QObject::connect(transcoder_, &Transcoder::LogLine, this, &TranscodeDialog::LogLine); + QObject::connect(transcoder_, &Transcoder::AllJobsComplete, this, &TranscodeDialog::AllJobsComplete); } diff --git a/src/transcoder/transcoder.h b/src/transcoder/transcoder.h index 4d99a4eb..bc48e6bb 100644 --- a/src/transcoder/transcoder.h +++ b/src/transcoder/transcoder.h @@ -75,8 +75,8 @@ class Transcoder : public QObject { void Cancel(); signals: - void JobComplete(const QString &input, const QString &output, bool success); - void LogLine(const QString &message); + void JobComplete(QString input, QString output, bool success); + void LogLine(QString message); void AllJobsComplete(); protected: diff --git a/src/transcoder/transcoderoptionsflac.h b/src/transcoder/transcoderoptionsflac.h index 9956db6a..0f0c5eae 100644 --- a/src/transcoder/transcoderoptionsflac.h +++ b/src/transcoder/transcoderoptionsflac.h @@ -37,7 +37,7 @@ class TranscoderOptionsFLAC : public TranscoderOptionsInterface { void Load() override; void Save() override; -private: + private: static const char *kSettingsGroup; Ui_TranscoderOptionsFLAC *ui_; diff --git a/src/transcoder/transcoderoptionsmp3.cpp b/src/transcoder/transcoderoptionsmp3.cpp index 163a6333..85814c6d 100644 --- a/src/transcoder/transcoderoptionsmp3.cpp +++ b/src/transcoder/transcoderoptionsmp3.cpp @@ -40,8 +40,8 @@ TranscoderOptionsMP3::TranscoderOptionsMP3(QWidget *parent) : TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsMP3) { ui_->setupUi(this); - connect(ui_->quality_slider, SIGNAL(valueChanged(int)), SLOT(QualitySliderChanged(int))); - connect(ui_->quality_spinbox, SIGNAL(valueChanged(double)), SLOT(QualitySpinboxChanged(double))); + QObject::connect(ui_->quality_slider, &QSlider::valueChanged, this, &TranscoderOptionsMP3::QualitySliderChanged); + QObject::connect(ui_->quality_spinbox, QOverload::of(&QDoubleSpinBox::valueChanged), this, &TranscoderOptionsMP3::QualitySpinboxChanged); } diff --git a/src/widgets/autoexpandingtreeview.cpp b/src/widgets/autoexpandingtreeview.cpp index 277abd27..83bb6845 100644 --- a/src/widgets/autoexpandingtreeview.cpp +++ b/src/widgets/autoexpandingtreeview.cpp @@ -43,9 +43,9 @@ AutoExpandingTreeView::AutoExpandingTreeView(QWidget *parent) setExpandsOnDoubleClick(true); setAnimated(true); - connect(this, SIGNAL(expanded(QModelIndex)), SLOT(ItemExpanded(QModelIndex))); - connect(this, SIGNAL(clicked(QModelIndex)), SLOT(ItemClicked(QModelIndex))); - connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(ItemDoubleClicked(QModelIndex))); + QObject::connect(this, &AutoExpandingTreeView::expanded, this, &AutoExpandingTreeView::ItemExpanded); + QObject::connect(this, &AutoExpandingTreeView::clicked, this, &AutoExpandingTreeView::ItemClicked); + QObject::connect(this, &AutoExpandingTreeView::doubleClicked, this, &AutoExpandingTreeView::ItemDoubleClicked); } @@ -54,11 +54,11 @@ void AutoExpandingTreeView::reset() { // Expand nodes in the tree until we have about 50 rows visible in the view if (auto_open_ && expand_on_reset_) { - RecursivelyExpand(rootIndex()); + RecursivelyExpandSlot(rootIndex()); } } -void AutoExpandingTreeView::RecursivelyExpand(const QModelIndex &idx) { +void AutoExpandingTreeView::RecursivelyExpandSlot(const QModelIndex &idx) { int rows = model()->rowCount(idx); RecursivelyExpand(idx, &rows); } diff --git a/src/widgets/autoexpandingtreeview.h b/src/widgets/autoexpandingtreeview.h index 8f62977a..aca8dd59 100644 --- a/src/widgets/autoexpandingtreeview.h +++ b/src/widgets/autoexpandingtreeview.h @@ -47,7 +47,7 @@ class AutoExpandingTreeView : public QTreeView { void SetAddOnDoubleClick(bool v) { add_on_double_click_ = v; } public slots: - void RecursivelyExpand(const QModelIndex &idx); + void RecursivelyExpandSlot(const QModelIndex &idx); void UpAndFocus(); void DownAndFocus(); @@ -82,4 +82,3 @@ class AutoExpandingTreeView : public QTreeView { }; #endif // AUTOEXPANDINGTREEVIEW_H - diff --git a/src/widgets/busyindicator.h b/src/widgets/busyindicator.h index a7cfdc86..30860e15 100644 --- a/src/widgets/busyindicator.h +++ b/src/widgets/busyindicator.h @@ -58,4 +58,3 @@ class BusyIndicator : public QWidget { }; #endif // BUSYINDICATOR_H - diff --git a/src/widgets/fancytabwidget.cpp b/src/widgets/fancytabwidget.cpp index b98f1976..d00d3a5f 100644 --- a/src/widgets/fancytabwidget.cpp +++ b/src/widgets/fancytabwidget.cpp @@ -459,7 +459,7 @@ FancyTabWidget::FancyTabWidget(QWidget *parent) : QTabWidget(parent), setStyle(style_); } - connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int))); + QObject::connect(tabBar, &FancyTabBar::currentChanged, this, &FancyTabWidget::currentTabChanged); } @@ -685,7 +685,7 @@ void FancyTabWidget::SetMode(FancyTabWidget::Mode mode) { updateGeometry(); // There appears to be a bug in QTabBar which causes tabSizeHint to be ignored thus the need for this second shot repaint - QTimer::singleShot(1, this, SLOT(tabBarUpdateGeometry())); + QTimer::singleShot(1, this, &FancyTabWidget::tabBarUpdateGeometry); emit ModeChanged(mode); @@ -695,7 +695,7 @@ void FancyTabWidget::addMenuItem(QActionGroup* group, const QString& text, Mode QAction* action = group->addAction(text); action->setCheckable(true); - connect(action, &QAction::triggered, [this, mode]() { SetMode(mode); } ); + QObject::connect(action, &QAction::triggered, [this, mode]() { SetMode(mode); } ); if (mode == mode_) action->setChecked(true); diff --git a/src/widgets/favoritewidget.h b/src/widgets/favoritewidget.h index 267fcb15..a6651dbb 100644 --- a/src/widgets/favoritewidget.h +++ b/src/widgets/favoritewidget.h @@ -18,6 +18,9 @@ * */ +#ifndef FAVORITEWIDGET_H +#define FAVORITEWIDGET_H + #include "config.h" #include @@ -58,3 +61,5 @@ class FavoriteWidget : public QWidget { QPixmap off_; QRect rect_; }; + +#endif // FAVORITEWIDGET_H diff --git a/src/widgets/fileview.cpp b/src/widgets/fileview.cpp index d6dc3662..cc1929a1 100644 --- a/src/widgets/fileview.cpp +++ b/src/widgets/fileview.cpp @@ -58,8 +58,7 @@ FileView::FileView(QWidget *parent) model_(nullptr), undo_stack_(new QUndoStack(this)), task_manager_(nullptr), - storage_(new FilesystemMusicStorage("/")) -{ + storage_(new FilesystemMusicStorage("/")) { ui_->setupUi(this); @@ -69,23 +68,23 @@ FileView::FileView(QWidget *parent) ui_->home->setIcon(IconLoader::Load("go-home")); ui_->up->setIcon(IconLoader::Load("go-up")); - connect(ui_->back, SIGNAL(clicked()), undo_stack_, SLOT(undo())); - connect(ui_->forward, SIGNAL(clicked()), undo_stack_, SLOT(redo())); - connect(ui_->home, SIGNAL(clicked()), SLOT(FileHome())); - connect(ui_->up, SIGNAL(clicked()), SLOT(FileUp())); - connect(ui_->path, SIGNAL(textChanged(QString)), SLOT(ChangeFilePath(QString))); + QObject::connect(ui_->back, &QToolButton::clicked, undo_stack_, &QUndoStack::undo); + QObject::connect(ui_->forward, &QToolButton::clicked, undo_stack_, &QUndoStack::redo); + QObject::connect(ui_->home, &QToolButton::clicked, this, &FileView::FileHome); + QObject::connect(ui_->up, &QToolButton::clicked, this, &FileView::FileUp); + QObject::connect(ui_->path, &QLineEdit::textChanged, this, &FileView::ChangeFilePath); - connect(undo_stack_, SIGNAL(canUndoChanged(bool)), ui_->back, SLOT(setEnabled(bool))); - connect(undo_stack_, SIGNAL(canRedoChanged(bool)), ui_->forward, SLOT(setEnabled(bool))); + QObject::connect(undo_stack_, &QUndoStack::canUndoChanged, ui_->back, &FileView::setEnabled); + QObject::connect(undo_stack_, &QUndoStack::canRedoChanged, ui_->forward, &FileView::setEnabled); - connect(ui_->list, SIGNAL(activated(QModelIndex)), SLOT(ItemActivated(QModelIndex))); - connect(ui_->list, SIGNAL(doubleClicked(QModelIndex)), SLOT(ItemDoubleClick(QModelIndex))); - connect(ui_->list, SIGNAL(AddToPlaylist(QMimeData*)), SIGNAL(AddToPlaylist(QMimeData*))); - connect(ui_->list, SIGNAL(CopyToCollection(QList)), SIGNAL(CopyToCollection(QList))); - connect(ui_->list, SIGNAL(MoveToCollection(QList)), SIGNAL(MoveToCollection(QList))); - connect(ui_->list, SIGNAL(CopyToDevice(QList)), SIGNAL(CopyToDevice(QList))); - connect(ui_->list, SIGNAL(Delete(QStringList)), SLOT(Delete(QStringList))); - connect(ui_->list, SIGNAL(EditTags(QList)), SIGNAL(EditTags(QList))); + QObject::connect(ui_->list, &FileViewList::activated, this, &FileView::ItemActivated); + QObject::connect(ui_->list, &FileViewList::doubleClicked, this, &FileView::ItemDoubleClick); + QObject::connect(ui_->list, &FileViewList::AddToPlaylist, this, &FileView::AddToPlaylist); + QObject::connect(ui_->list, &FileViewList::CopyToCollection, this, &FileView::CopyToCollection); + QObject::connect(ui_->list, &FileViewList::MoveToCollection, this, &FileView::MoveToCollection); + QObject::connect(ui_->list, &FileViewList::CopyToDevice, this, &FileView::CopyToDevice); + QObject::connect(ui_->list, &FileViewList::Delete, this, &FileView::Delete); + QObject::connect(ui_->list, &FileViewList::EditTags, this, &FileView::EditTags); QString filter(FileView::kFileFilter); filter_list_ << filter.split(" "); @@ -238,7 +237,7 @@ void FileView::Delete(const QStringList &filenames) { #endif DeleteFiles *delete_files = new DeleteFiles(task_manager_, storage_, use_trash); - connect(delete_files, SIGNAL(Finished(SongList)), SLOT(DeleteFinished(SongList))); + QObject::connect(delete_files, &DeleteFiles::Finished, this, &FileView::DeleteFinished); delete_files->Start(filenames); } diff --git a/src/widgets/fileview.h b/src/widgets/fileview.h index 4e1d931a..e786ae52 100644 --- a/src/widgets/fileview.h +++ b/src/widgets/fileview.h @@ -65,13 +65,13 @@ class FileView : public QWidget { void keyPressEvent(QKeyEvent *e) override; signals: - void PathChanged(const QString &path); + void PathChanged(QString path); void AddToPlaylist(QMimeData *data); - void CopyToCollection(const QList &urls); - void MoveToCollection(const QList &urls); - void CopyToDevice(const QList &urls); - void EditTags(const QList &urls); + void CopyToCollection(QList urls); + void MoveToCollection(QList urls); + void CopyToDevice(QList urls); + void EditTags(QList urls); private slots: void FileUp(); diff --git a/src/widgets/fileviewlist.cpp b/src/widgets/fileviewlist.cpp index 729b5d06..a9ab7c00 100644 --- a/src/widgets/fileviewlist.cpp +++ b/src/widgets/fileviewlist.cpp @@ -38,21 +38,20 @@ FileViewList::FileViewList(QWidget *parent) : QListView(parent), - menu_(new QMenu(this)) -{ + menu_(new QMenu(this)) { - menu_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, SLOT(AddToPlaylistSlot())); - menu_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, SLOT(LoadSlot())); - menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, SLOT(OpenInNewPlaylistSlot())); + menu_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, &FileViewList::AddToPlaylistSlot); + menu_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, &FileViewList::LoadSlot); + menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, &FileViewList::OpenInNewPlaylistSlot); menu_->addSeparator(); - menu_->addAction(IconLoader::Load("edit-copy"), tr("Copy to collection..."), this, SLOT(CopyToCollectionSlot())); - menu_->addAction(IconLoader::Load("go-jump"), tr("Move to collection..."), this, SLOT(MoveToCollectionSlot())); - menu_->addAction(IconLoader::Load("device"), tr("Copy to device..."), this, SLOT(CopyToDeviceSlot())); - menu_->addAction(IconLoader::Load("edit-delete"), tr("Delete from disk..."), this, SLOT(DeleteSlot())); + menu_->addAction(IconLoader::Load("edit-copy"), tr("Copy to collection..."), this, &FileViewList::CopyToCollectionSlot); + menu_->addAction(IconLoader::Load("go-jump"), tr("Move to collection..."), this, &FileViewList::MoveToCollectionSlot); + menu_->addAction(IconLoader::Load("device"), tr("Copy to device..."), this, &FileViewList::CopyToDeviceSlot); + menu_->addAction(IconLoader::Load("edit-delete"), tr("Delete from disk..."), this, &FileViewList::DeleteSlot); menu_->addSeparator(); - menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit track information..."), this, SLOT(EditTagsSlot())); - menu_->addAction(IconLoader::Load("document-open-folder"), tr("Show in file browser..."), this, SLOT(ShowInBrowser())); + menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit track information..."), this, &FileViewList::EditTagsSlot); + menu_->addAction(IconLoader::Load("document-open-folder"), tr("Show in file browser..."), this, &FileViewList::ShowInBrowser); setAttribute(Qt::WA_MacShowFocusRect, false); diff --git a/src/widgets/fileviewlist.h b/src/widgets/fileviewlist.h index 1965dcd5..7663e7bf 100644 --- a/src/widgets/fileviewlist.h +++ b/src/widgets/fileviewlist.h @@ -49,11 +49,11 @@ class FileViewList : public QListView { signals: void AddToPlaylist(QMimeData *data); - void CopyToCollection(const QList& urls); - void MoveToCollection(const QList& urls); - void CopyToDevice(const QList& urls); - void Delete(const QStringList& filenames); - void EditTags(const QList& urls); + void CopyToCollection(QList urls); + void MoveToCollection(QList urls); + void CopyToDevice(QList urls); + void Delete(QStringList filenames); + void EditTags(QList urls); void Back(); void Forward(); @@ -81,4 +81,3 @@ class FileViewList : public QListView { }; #endif // FILEVIEWLIST_H - diff --git a/src/widgets/groupediconview.cpp b/src/widgets/groupediconview.cpp index 6f608d35..1d4d731e 100644 --- a/src/widgets/groupediconview.cpp +++ b/src/widgets/groupediconview.cpp @@ -72,20 +72,22 @@ GroupedIconView::GroupedIconView(QWidget *parent) proxy_model_->AddSortSpec(Role_Group); proxy_model_->setDynamicSortFilter(true); - connect(proxy_model_, SIGNAL(modelReset()), SLOT(LayoutItems())); + QObject::connect(proxy_model_, &MultiSortFilterProxy::modelReset, this, &GroupedIconView::LayoutItems); } -void GroupedIconView::AddSortSpec(int role, Qt::SortOrder order) { +void GroupedIconView::AddSortSpec(const int role, const Qt::SortOrder order) { proxy_model_->AddSortSpec(role, order); } void GroupedIconView::setModel(QAbstractItemModel *model) { + proxy_model_->setSourceModel(model); proxy_model_->sort(0); QListView::setModel(proxy_model_); LayoutItems(); + } int GroupedIconView::header_height() const { @@ -152,9 +154,9 @@ void GroupedIconView::LayoutItems() { headers_.clear(); for (int i = 0; i < count; ++i) { - const QModelIndex index(model()->index(i, 0)); - const QString group = index.data(Role_Group).toString(); - const QSize size(rectForIndex(index).size()); + const QModelIndex idx(model()->index(i, 0)); + const QString group = idx.data(Role_Group).toString(); + const QSize size(rectForIndex(idx).size()); // Is this the first item in a new group? if (group != last_group) { @@ -209,10 +211,12 @@ void GroupedIconView::LayoutItems() { update(); } -QRect GroupedIconView::visualRect(const QModelIndex &index) const { - if (index.row() < 0 || index.row() >= visual_rects_.count()) +QRect GroupedIconView::visualRect(const QModelIndex &idx) const { + + if (idx.row() < 0 || idx.row() >= visual_rects_.count()) return QRect(); - return visual_rects_[index.row()].translated(-horizontalOffset(), -verticalOffset()); + return visual_rects_[idx.row()].translated(-horizontalOffset(), -verticalOffset()); + } QModelIndex GroupedIconView::indexAt(const QPoint &p) const { @@ -315,8 +319,8 @@ void GroupedIconView::setSelection(const QRect &rect, QItemSelectionModel::Selec QVector indexes(IntersectingItems(rect.translated(horizontalOffset(), verticalOffset()))); QItemSelection selection; - for (const QModelIndex &index : indexes) { - selection << QItemSelectionRange(index); + for (const QModelIndex &idx : indexes) { + selection << QItemSelectionRange(idx); } selectionModel()->select(selection, command); @@ -336,14 +340,17 @@ QVector GroupedIconView::IntersectingItems(const QRect &rect) const } QRegion GroupedIconView::visualRegionForSelection(const QItemSelection &selection) const { + QRegion ret; - for (const QModelIndex &index : selection.indexes()) { - ret += visual_rects_[index.row()]; + for (const QModelIndex &idx : selection.indexes()) { + ret += visual_rects_[idx.row()]; } return ret; + } QModelIndex GroupedIconView::moveCursor(CursorAction action, Qt::KeyboardModifiers) { + if (model()->rowCount() == 0) { return QModelIndex(); } @@ -367,9 +374,11 @@ QModelIndex GroupedIconView::moveCursor(CursorAction action, Qt::KeyboardModifie } return model()->index(qBound(0, ret, model()->rowCount()), 0); + } -int GroupedIconView::IndexAboveOrBelow(int index, int d) const { +int GroupedIconView::IndexAboveOrBelow(int index, const int d) const { + const QRect orig_rect(visual_rects_[index]); while (index >= 0 && index < visual_rects_.count()) { @@ -384,4 +393,5 @@ int GroupedIconView::IndexAboveOrBelow(int index, int d) const { } return index; + } diff --git a/src/widgets/groupediconview.h b/src/widgets/groupediconview.h index 99a95dab..6640d386 100644 --- a/src/widgets/groupediconview.h +++ b/src/widgets/groupediconview.h @@ -65,16 +65,16 @@ class GroupedIconView : public QListView { Role_Group = 1158300, }; - void AddSortSpec(int role, Qt::SortOrder order = Qt::AscendingOrder); + void AddSortSpec(const int role, const Qt::SortOrder order = Qt::AscendingOrder); int header_spacing() const { return header_spacing_; } int header_indent() const { return header_indent_; } int item_indent() const { return item_indent_; } const QString &header_text() const { return header_text_;} - void set_header_spacing(int value) { header_spacing_ = value; } - void set_header_indent(int value) { header_indent_ = value; } - void set_item_indent(int value) { item_indent_ = value; } + void set_header_spacing(const int value) { header_spacing_ = value; } + void set_header_indent(const int value) { header_indent_ = value; } + void set_item_indent(const int value) { item_indent_ = value; } void set_header_text(const QString &value) { header_text_ = value; } // QAbstractItemView @@ -95,7 +95,7 @@ class GroupedIconView : public QListView { QModelIndex indexAt(const QPoint &p) const override; void rowsInserted(const QModelIndex &parent, int start, int end) override; void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) override; - QRect visualRect(const QModelIndex &index) const override; + QRect visualRect(const QModelIndex &idx) const override; QRegion visualRegionForSelection(const QItemSelection &selection) const override; private slots: @@ -115,7 +115,7 @@ class GroupedIconView : public QListView { QVector IntersectingItems(const QRect &rect) const; // Returns the index of the item above (d=-1) or below (d=+1) the given item. - int IndexAboveOrBelow(int index, int d) const; + int IndexAboveOrBelow(int index, const int d) const; MultiSortFilterProxy *proxy_model_; QVector visual_rects_; diff --git a/src/widgets/lineedit.cpp b/src/widgets/lineedit.cpp index 96ef3e6f..769c78a0 100644 --- a/src/widgets/lineedit.cpp +++ b/src/widgets/lineedit.cpp @@ -72,9 +72,17 @@ ExtendedEditor::ExtendedEditor(QWidget *widget, int extra_right_padding, bool dr reset_button_->setFocusPolicy(Qt::NoFocus); reset_button_->hide(); - widget->connect(clear_button_, SIGNAL(clicked()), widget, SLOT(setFocus())); - if (qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget)) { - widget->connect(clear_button_, SIGNAL(clicked()), widget, SLOT(clear())); + if (LineEdit *lineedit = qobject_cast(widget)) { + QObject::connect(clear_button_, &QToolButton::clicked, lineedit, &LineEdit::set_focus); + QObject::connect(clear_button_, &QToolButton::clicked, lineedit, &LineEdit::clear); + } + else if (TextEdit *textedit = qobject_cast(widget)) { + QObject::connect(clear_button_, &QToolButton::clicked, textedit, &TextEdit::set_focus); + QObject::connect(clear_button_, &QToolButton::clicked, textedit, &TextEdit::clear); + } + else if (SpinBox *spinbox = qobject_cast(widget)) { + QObject::connect(clear_button_, &QToolButton::clicked, spinbox, &SpinBox::set_focus); + QObject::connect(clear_button_, &QToolButton::clicked, spinbox, &SpinBox::clear); } UpdateButtonGeometry(); @@ -160,8 +168,8 @@ void ExtendedEditor::Resize() { } LineEdit::LineEdit(QWidget *parent) : QLineEdit(parent), ExtendedEditor(this) { - connect(reset_button_, SIGNAL(clicked()), SIGNAL(Reset())); - connect(this, SIGNAL(textChanged(QString)), SLOT(text_changed(QString))); + QObject::connect(reset_button_, &QToolButton::clicked, this, &LineEdit::Reset); + QObject::connect(this, &LineEdit::textChanged, this, &LineEdit::text_changed); } void LineEdit::text_changed(const QString &text) { @@ -191,10 +199,11 @@ void LineEdit::resizeEvent(QResizeEvent *e) { TextEdit::TextEdit(QWidget *parent) : QPlainTextEdit(parent), - ExtendedEditor(this) -{ - connect(reset_button_, SIGNAL(clicked()), SIGNAL(Reset())); - connect(this, SIGNAL(textChanged()), viewport(), SLOT(update())); // To clear the hint + ExtendedEditor(this) { + + QObject::connect(reset_button_, &QToolButton::clicked, this, &TextEdit::Reset); + QObject::connect(this, &TextEdit::textChanged, [this]() { viewport()->update(); }); // To clear the hint + } void TextEdit::paintEvent(QPaintEvent *e) { @@ -212,7 +221,7 @@ SpinBox::SpinBox(QWidget *parent) : QSpinBox(parent), ExtendedEditor(this, 14, false) { - connect(reset_button_, SIGNAL(clicked()), SIGNAL(Reset())); + QObject::connect(reset_button_, &QToolButton::clicked, this, &SpinBox::Reset); } void SpinBox::paintEvent(QPaintEvent *e) { @@ -226,9 +235,10 @@ void SpinBox::resizeEvent(QResizeEvent *e) { } CheckBox::CheckBox(QWidget *parent) - : QCheckBox(parent), ExtendedEditor(this, 14, false) -{ - connect(reset_button_, SIGNAL(clicked()), SIGNAL(Reset())); + : QCheckBox(parent), ExtendedEditor(this, 14, false) { + + QObject::connect(reset_button_, &QToolButton::clicked, this, &CheckBox::Reset); + } void CheckBox::paintEvent(QPaintEvent *e) { diff --git a/src/widgets/lineedit.h b/src/widgets/lineedit.h index 90c901ef..b8adf8d6 100644 --- a/src/widgets/lineedit.h +++ b/src/widgets/lineedit.h @@ -118,12 +118,12 @@ class LineEdit : public QLineEdit, public ExtendedEditor { // ExtendedEditor void set_enabled(bool enabled) override { QLineEdit::setEnabled(enabled); } - void set_focus() override { QLineEdit::setFocus(); } QVariant value() const override { return QLineEdit::text(); } void set_value(const QVariant &value) override { QLineEdit::setText(value.toString()); } public slots: + void set_focus() override { QLineEdit::setFocus(); } void clear() override { QLineEdit::clear(); } protected: @@ -152,12 +152,12 @@ class TextEdit : public QPlainTextEdit, public ExtendedEditor { // ExtendedEditor void set_enabled(bool enabled) override { QPlainTextEdit::setEnabled(enabled); } - void set_focus() override { QPlainTextEdit::setFocus(); } QVariant value() const override { return QPlainTextEdit::toPlainText(); } void set_value(const QVariant &value) override { QPlainTextEdit::setPlainText(value.toString()); } public slots: + void set_focus() override { QPlainTextEdit::setFocus(); } void clear() override { QPlainTextEdit::clear(); } protected: @@ -182,13 +182,13 @@ class SpinBox : public QSpinBox, public ExtendedEditor { // ExtendedEditor void set_enabled(bool enabled) override { QSpinBox::setEnabled(enabled); } - void set_focus() override { QSpinBox::setFocus(); } QVariant value() const override { return QSpinBox::value(); } void set_value(const QVariant &value) override { QSpinBox::setValue(value.toInt()); } bool is_empty() const override { return text().isEmpty() || text() == "0"; } public slots: + void set_focus() override { QSpinBox::setFocus(); } void clear() override { QSpinBox::clear(); } protected: @@ -210,7 +210,6 @@ class CheckBox : public QCheckBox, public ExtendedEditor { // ExtendedEditor void set_enabled(bool enabled) override { QCheckBox::setEnabled(enabled); } - void set_focus() override { QCheckBox::setFocus(); } bool is_empty() const override { return text().isEmpty() || text() == "0"; } QVariant value() const override { return QCheckBox::isChecked(); } @@ -218,6 +217,7 @@ class CheckBox : public QCheckBox, public ExtendedEditor { void set_partially() override { QCheckBox::setCheckState(Qt::PartiallyChecked); } public slots: + void set_focus() override { QCheckBox::setFocus(); } void clear() override { QCheckBox::setChecked(false); } protected: diff --git a/src/widgets/loginstatewidget.cpp b/src/widgets/loginstatewidget.cpp index a151047e..0aa3aa4e 100644 --- a/src/widgets/loginstatewidget.cpp +++ b/src/widgets/loginstatewidget.cpp @@ -50,7 +50,7 @@ LoginStateWidget::LoginStateWidget(QWidget *parent) bold_font.setBold(true); ui_->signed_out_label->setFont(bold_font); - connect(ui_->sign_out, SIGNAL(clicked()), SLOT(Logout())); + QObject::connect(ui_->sign_out, &QPushButton::clicked, this, &LoginStateWidget::Logout); } @@ -90,7 +90,7 @@ void LoginStateWidget::SetLoggedIn(const State state, const QString &account_nam // A login just failed - give focus back to the last crediental field (usually password). // We have to do this after control gets back to the // event loop because the user might have just closed a dialog and our widget might not be active yet. - QTimer::singleShot(0, this, SLOT(FocusLastCredentialField())); + QTimer::singleShot(0, this, &LoginStateWidget::FocusLastCredentialField); } } diff --git a/src/widgets/multiloadingindicator.cpp b/src/widgets/multiloadingindicator.cpp index 98185d7b..d609dc54 100644 --- a/src/widgets/multiloadingindicator.cpp +++ b/src/widgets/multiloadingindicator.cpp @@ -44,13 +44,15 @@ const int MultiLoadingIndicator::kSpacing = 6; MultiLoadingIndicator::MultiLoadingIndicator(QWidget *parent) : QWidget(parent), task_manager_(nullptr), - spinner_(new BusyIndicator(this)) -{ + spinner_(new BusyIndicator(this)) { + spinner_->move(kHorizontalPadding, kVerticalPadding); setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); + } QSize MultiLoadingIndicator::sizeHint() const { + #if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)) const int width = kHorizontalPadding * 2 + spinner_->sizeHint().width() + kSpacing + fontMetrics().horizontalAdvance(text_); #else @@ -59,11 +61,14 @@ QSize MultiLoadingIndicator::sizeHint() const { const int height = kVerticalPadding * 2 + qMax(spinner_->sizeHint().height(), fontMetrics().height()); return QSize(width, height); + } -void MultiLoadingIndicator::SetTaskManager(TaskManager* task_manager) { +void MultiLoadingIndicator::SetTaskManager(TaskManager *task_manager) { + task_manager_ = task_manager; - connect(task_manager_, SIGNAL(TasksChanged()), SLOT(UpdateText())); + QObject::connect(task_manager_, &TaskManager::TasksChanged, this, &MultiLoadingIndicator::UpdateText); + } void MultiLoadingIndicator::UpdateText() { @@ -106,4 +111,3 @@ void MultiLoadingIndicator::paintEvent(QPaintEvent*) { p.drawText(text_rect, Qt::TextSingleLine | Qt::AlignLeft, fontMetrics().elidedText(text_, Qt::ElideRight, text_rect.width())); } - diff --git a/src/widgets/multiloadingindicator.h b/src/widgets/multiloadingindicator.h index af546a87..5b020078 100644 --- a/src/widgets/multiloadingindicator.h +++ b/src/widgets/multiloadingindicator.h @@ -51,7 +51,7 @@ class MultiLoadingIndicator : public QWidget { void TaskCountChange(int tasks); protected: - void paintEvent(QPaintEvent *) override; + void paintEvent(QPaintEvent*) override; private slots: void UpdateText(); @@ -64,4 +64,3 @@ class MultiLoadingIndicator : public QWidget { }; #endif // MULTILOADINGINDICATOR_H - diff --git a/src/widgets/playingwidget.cpp b/src/widgets/playingwidget.cpp index 085dec7c..48927412 100644 --- a/src/widgets/playingwidget.cpp +++ b/src/widgets/playingwidget.cpp @@ -106,13 +106,13 @@ PlayingWidget::PlayingWidget(QWidget *parent) fit_cover_width_action_ = menu_->addAction(tr("Fit cover to width")); fit_cover_width_action_->setCheckable(true); fit_cover_width_action_->setEnabled(true); - connect(fit_cover_width_action_, SIGNAL(toggled(bool)), SLOT(FitCoverWidth(bool))); + QObject::connect(fit_cover_width_action_, &QAction::toggled, this, &PlayingWidget::FitCoverWidth); fit_cover_width_action_->setChecked(fit_width_); menu_->addSeparator(); // Animations - connect(timeline_show_hide_, SIGNAL(frameChanged(int)), SLOT(SetHeight(int))); - connect(timeline_fade_, SIGNAL(valueChanged(qreal)), SLOT(FadePreviousTrack(qreal))); + QObject::connect(timeline_show_hide_, &QTimeLine::frameChanged, this, &PlayingWidget::SetHeight); + QObject::connect(timeline_fade_, &QTimeLine::valueChanged, this, &PlayingWidget::FadePreviousTrack); timeline_fade_->setDirection(QTimeLine::Backward); // 1.0 -> 0.0 details_->setUndoRedoEnabled(false); @@ -143,13 +143,13 @@ void PlayingWidget::Init(Application *app, AlbumCoverChoiceController *album_cov s.beginGroup(kSettingsGroup); above_statusbar_action_->setChecked(s.value("above_status_bar", false).toBool()); s.endGroup(); - connect(above_statusbar_action_, SIGNAL(toggled(bool)), SLOT(ShowAboveStatusBar(bool))); + QObject::connect(above_statusbar_action_, &QAction::toggled, this, &PlayingWidget::ShowAboveStatusBar); - connect(album_cover_choice_controller_, SIGNAL(AutomaticCoverSearchDone()), this, SLOT(AutomaticCoverSearchDone())); + QObject::connect(album_cover_choice_controller_, &AlbumCoverChoiceController::AutomaticCoverSearchDone, this, &PlayingWidget::AutomaticCoverSearchDone); } -void PlayingWidget::SetEnabled(bool enabled) { +void PlayingWidget::SetEnabled(const bool enabled) { if (enabled == enabled_) return; @@ -178,7 +178,7 @@ void PlayingWidget::SetDisabled() { } -void PlayingWidget::SetVisible(bool visible) { +void PlayingWidget::SetVisible(const bool visible) { if (timeline_show_hide_->state() == QTimeLine::Running) { if (timeline_show_hide_->direction() == QTimeLine::Backward && enabled_ && active_) { @@ -198,7 +198,7 @@ void PlayingWidget::SetVisible(bool visible) { } -void PlayingWidget::set_ideal_height(int height) { +void PlayingWidget::set_ideal_height(const int height) { small_ideal_height_ = height; UpdateHeight(); @@ -209,17 +209,17 @@ QSize PlayingWidget::sizeHint() const { return QSize(cover_loader_options_.desired_height_, total_height_); } -void PlayingWidget::CreateModeAction(Mode mode, const QString &text, QActionGroup *group) { +void PlayingWidget::CreateModeAction(const Mode mode, const QString &text, QActionGroup *group) { QAction *action = new QAction(text, group); action->setCheckable(true); - connect(action, &QAction::triggered, [this, mode]() { SetMode(mode); } ); + QObject::connect(action, &QAction::triggered, [this, mode]() { SetMode(mode); } ); if (mode == mode_) action->setChecked(true); } -void PlayingWidget::SetMode(int mode) { +void PlayingWidget::SetMode(const int mode) { mode_ = Mode(mode); @@ -236,7 +236,7 @@ void PlayingWidget::SetMode(int mode) { } -void PlayingWidget::FitCoverWidth(bool fit) { +void PlayingWidget::FitCoverWidth(const bool fit) { fit_width_ = fit; UpdateHeight(); @@ -249,7 +249,7 @@ void PlayingWidget::FitCoverWidth(bool fit) { } -void PlayingWidget::ShowAboveStatusBar(bool above) { +void PlayingWidget::ShowAboveStatusBar(const bool above) { QSettings s; s.beginGroup(kSettingsGroup); @@ -467,7 +467,7 @@ void PlayingWidget::DrawContents(QPainter *p) { } -void PlayingWidget::FadePreviousTrack(qreal value) { +void PlayingWidget::FadePreviousTrack(const qreal value) { if (!visible_) return; @@ -492,13 +492,13 @@ void PlayingWidget::resizeEvent(QResizeEvent* e) { } -void PlayingWidget::contextMenuEvent(QContextMenuEvent* e) { +void PlayingWidget::contextMenuEvent(QContextMenuEvent *e) { // show the menu menu_->popup(mapToGlobal(e->pos())); } -void PlayingWidget::mouseDoubleClickEvent(QMouseEvent* e) { +void PlayingWidget::mouseDoubleClickEvent(QMouseEvent *e) { // Same behaviour as right-click > Show Fullsize if (e->button() == Qt::LeftButton && song_.is_valid()) { @@ -531,7 +531,7 @@ void PlayingWidget::SearchCoverInProgress() { // Show a spinner animation spinner_animation_.reset(new QMovie(":/pictures/spinner.gif", QByteArray(), this)); - connect(spinner_animation_.get(), SIGNAL(updated(QRect)), SLOT(update())); + QObject::connect(spinner_animation_.get(), &QMovie::updated, this, &PlayingWidget::Update); spinner_animation_->start(); update(); diff --git a/src/widgets/playingwidget.h b/src/widgets/playingwidget.h index 4e79fc56..ab02d983 100644 --- a/src/widgets/playingwidget.h +++ b/src/widgets/playingwidget.h @@ -63,10 +63,10 @@ class PlayingWidget : public QWidget { void Init(Application *app, AlbumCoverChoiceController *album_cover_choice_controller); bool IsEnabled() { return enabled_; } - void SetEnabled(bool enabled); + void SetEnabled(const bool enabled); void SetEnabled(); void SetDisabled(); - void set_ideal_height(int height); + void set_ideal_height(const int height); QSize sizeHint() const override; bool show_above_status_bar() const { return above_statusbar_action_->isChecked(); } @@ -79,6 +79,7 @@ class PlayingWidget : public QWidget { void Error(); void SongChanged(const Song &song); void SearchCoverInProgress(); + void AlbumCoverLoaded(const Song &song, const QImage &image); protected: void paintEvent(QPaintEvent *e) override; @@ -89,15 +90,15 @@ class PlayingWidget : public QWidget { void dropEvent(QDropEvent *e) override; private slots: - void SetMode(int mode); - void ShowAboveStatusBar(bool above); - void FitCoverWidth(bool fit); + void Update() { update(); } + void SetMode(const int mode); + void ShowAboveStatusBar(const bool above); + void FitCoverWidth(const bool fit); void AutomaticCoverSearchDone(); - void AlbumCoverLoaded(const Song &song, const QImage &image); - void SetHeight(int height); - void FadePreviousTrack(qreal value); + void SetHeight(const int height); + void FadePreviousTrack(const qreal value); private: @@ -118,7 +119,7 @@ class PlayingWidget : public QWidget { AlbumCoverChoiceController *album_cover_choice_controller_; Mode mode_; QMenu *menu_; - QAction* above_statusbar_action_; + QAction *above_statusbar_action_; QAction *fit_cover_width_action_; bool enabled_; bool visible_; @@ -142,8 +143,8 @@ class PlayingWidget : public QWidget { QPixmap pixmap_previous_track_; std::unique_ptr spinner_animation_; - void SetVisible(bool visible); - void CreateModeAction(Mode mode, const QString &text, QActionGroup *group); + void SetVisible(const bool visible); + void CreateModeAction(const Mode mode, const QString &text, QActionGroup *group); void UpdateDetailsText(); void UpdateHeight(); void SetImage(const QImage &image); diff --git a/src/widgets/qsearchfield.h b/src/widgets/qsearchfield.h index c14aaa4b..21b1b1e0 100644 --- a/src/widgets/qsearchfield.h +++ b/src/widgets/qsearchfield.h @@ -29,7 +29,7 @@ class QSearchField : public QWidget { void setFocus(); signals: - void textChanged(const QString &text); + void textChanged(QString text); void editingFinished(); void returnPressed(); diff --git a/src/widgets/qsearchfield_nonmac.cpp b/src/widgets/qsearchfield_nonmac.cpp index d4068566..3ef67c40 100644 --- a/src/widgets/qsearchfield_nonmac.cpp +++ b/src/widgets/qsearchfield_nonmac.cpp @@ -64,10 +64,10 @@ class QSearchFieldPrivate : public QObject { QSearchField::QSearchField(QWidget *parent) : QWidget(parent) { QLineEdit *lineEdit = new QLineEdit(this); - connect(lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(textChanged(QString))); - connect(lineEdit, SIGNAL(editingFinished()), this, SIGNAL(editingFinished())); - connect(lineEdit, SIGNAL(returnPressed()), this, SIGNAL(returnPressed())); - connect(lineEdit, SIGNAL(textChanged(QString)), this, SLOT(setText(QString))); + QObject::connect(lineEdit, &QLineEdit::textChanged, this, &QSearchField::textChanged); + QObject::connect(lineEdit, &QLineEdit::editingFinished, this, &QSearchField::editingFinished); + QObject::connect(lineEdit, &QLineEdit::returnPressed, this, &QSearchField::returnPressed); + QObject::connect(lineEdit, &QLineEdit::textChanged, this, &QSearchField::setText); QToolButton *clearbutton = new QToolButton(this); QIcon clearIcon(IconLoader::Load("edit-clear-locationbar-ltr")); @@ -77,7 +77,7 @@ QSearchField::QSearchField(QWidget *parent) : QWidget(parent) { clearbutton->setStyleSheet("border: none; padding: 0px;"); clearbutton->resize(clearbutton->sizeHint()); - connect(clearbutton, SIGNAL(clicked()), this, SLOT(clear())); + QObject::connect(clearbutton, &QToolButton::clicked, this, &QSearchField::clear); pimpl = new QSearchFieldPrivate(this, lineEdit, clearbutton); diff --git a/src/widgets/renametablineedit.h b/src/widgets/renametablineedit.h index 66c54dbd..28b84ea6 100644 --- a/src/widgets/renametablineedit.h +++ b/src/widgets/renametablineedit.h @@ -48,4 +48,3 @@ class RenameTabLineEdit : public QLineEdit { }; #endif // RENAMETABLINEEDIT_H - diff --git a/src/widgets/stretchheaderview.cpp b/src/widgets/stretchheaderview.cpp index e3a341ff..129b5319 100644 --- a/src/widgets/stretchheaderview.cpp +++ b/src/widgets/stretchheaderview.cpp @@ -45,7 +45,7 @@ StretchHeaderView::StretchHeaderView(const Qt::Orientation orientation, QWidget stretch_enabled_(false), in_mouse_move_event_(false) { - connect(this, SIGNAL(sectionResized(int,int,int)), SLOT(SectionResized(int,int,int))); + QObject::connect(this, &StretchHeaderView::sectionResized, this, &StretchHeaderView::SectionResized); setMinimumSectionSize(kMinimumColumnWidth); } diff --git a/src/widgets/stretchheaderview.h b/src/widgets/stretchheaderview.h index 81b0122b..b4f6be08 100644 --- a/src/widgets/stretchheaderview.h +++ b/src/widgets/stretchheaderview.h @@ -77,7 +77,7 @@ class StretchHeaderView : public QHeaderView { signals: // Emitted when the stretch mode is changed. - void StretchEnabledChanged(const bool enabled); + void StretchEnabledChanged(bool enabled); protected: // QWidget diff --git a/src/widgets/trackslider.cpp b/src/widgets/trackslider.cpp index 2114d179..d1c88dda 100644 --- a/src/widgets/trackslider.cpp +++ b/src/widgets/trackslider.cpp @@ -43,7 +43,7 @@ const char* TrackSlider::kSettingsGroup = "MainWindow"; -TrackSlider::TrackSlider(QWidget* parent) +TrackSlider::TrackSlider(QWidget *parent) : QWidget(parent), ui_(new Ui_TrackSlider), #ifdef HAVE_MOODBAR @@ -51,8 +51,8 @@ TrackSlider::TrackSlider(QWidget* parent) #endif setting_value_(false), show_remaining_time_(true), - slider_maximum_value_(0) -{ + slider_maximum_value_(0) { + ui_->setupUi(this); UpdateLabelWidth(); @@ -61,14 +61,15 @@ TrackSlider::TrackSlider(QWidget* parent) QSettings s; s.beginGroup(kSettingsGroup); show_remaining_time_ = s.value("show_remaining_time").toBool(); + s.endGroup(); - connect(ui_->slider, SIGNAL(sliderMoved(int)), SIGNAL(ValueChanged(int))); - connect(ui_->slider, SIGNAL(valueChanged(int)), SLOT(ValueMaybeChanged(int))); - connect(ui_->remaining, SIGNAL(Clicked()), SLOT(ToggleTimeDisplay())); - connect(ui_->slider, SIGNAL(SeekForward()), SIGNAL(SeekForward())); - connect(ui_->slider, SIGNAL(SeekBackward()), SIGNAL(SeekBackward())); - connect(ui_->slider, SIGNAL(Previous()), SIGNAL(Previous())); - connect(ui_->slider, SIGNAL(Next()), SIGNAL(Next())); + QObject::connect(ui_->slider, &TrackSliderSlider::sliderMoved, this, &TrackSlider::ValueChanged); + QObject::connect(ui_->slider, &TrackSliderSlider::valueChanged, this, &TrackSlider::ValueMaybeChanged); + QObject::connect(ui_->remaining, &ClickableLabel::Clicked, this, &TrackSlider::ToggleTimeDisplay); + QObject::connect(ui_->slider, &TrackSliderSlider::SeekForward, this, &TrackSlider::SeekForward); + QObject::connect(ui_->slider, &TrackSliderSlider::SeekBackward, this, &TrackSlider::SeekBackward); + QObject::connect(ui_->slider, &TrackSliderSlider::Previous, this, &TrackSlider::Previous); + QObject::connect(ui_->slider, &TrackSliderSlider::Next, this, &TrackSlider::Next); } @@ -79,7 +80,7 @@ TrackSlider::~TrackSlider() { #endif } -void TrackSlider::SetApplication(Application* app) { +void TrackSlider::SetApplication(Application *app) { #ifdef HAVE_MOODBAR if (!moodbar_style_) moodbar_style_ = new MoodbarProxyStyle(app, ui_->slider); #else @@ -93,7 +94,7 @@ void TrackSlider::UpdateLabelWidth() { UpdateLabelWidth(ui_->remaining, "-0:00:00"); } -void TrackSlider::UpdateLabelWidth(QLabel* label, const QString& text) { +void TrackSlider::UpdateLabelWidth(QLabel *label, const QString &text) { QString old_text = label->text(); label->setText(text); @@ -117,7 +118,7 @@ QSize TrackSlider::sizeHint() const { } -void TrackSlider::SetValue(int elapsed, int total) { +void TrackSlider::SetValue(const int elapsed, const int total) { setting_value_ = true; // This is so we don't emit from QAbstractSlider::valueChanged ui_->slider->setMaximum(total); @@ -131,7 +132,7 @@ void TrackSlider::SetValue(int elapsed, int total) { } -void TrackSlider::UpdateTimes(int elapsed) { +void TrackSlider::UpdateTimes(const int elapsed) { ui_->elapsed->setText(Utilities::PrettyTime(elapsed)); // Update normally if showing remaining time @@ -162,23 +163,23 @@ void TrackSlider::SetStopped() { } -void TrackSlider::SetCanSeek(bool can_seek) { +void TrackSlider::SetCanSeek(const bool can_seek) { ui_->slider->setEnabled(can_seek); } -void TrackSlider::Seek(int gap) { +void TrackSlider::Seek(const int gap) { if (ui_->slider->isEnabled()) ui_->slider->setValue(ui_->slider->value() + gap * kMsecPerSec); } -void TrackSlider::ValueMaybeChanged(int value) { +void TrackSlider::ValueMaybeChanged(const int value) { if (setting_value_) return; UpdateTimes(value / kMsecPerSec); emit ValueChangedSeconds(value / kMsecPerSec); } -bool TrackSlider::event(QEvent* e) { +bool TrackSlider::event(QEvent *e) { switch (e->type()) { case QEvent::ApplicationFontChange: diff --git a/src/widgets/trackslider.h b/src/widgets/trackslider.h index dbfde9f9..6c17f3cd 100644 --- a/src/widgets/trackslider.h +++ b/src/widgets/trackslider.h @@ -59,10 +59,10 @@ class TrackSlider : public QWidget { static const char *kSettingsGroup; public slots: - void SetValue(int elapsed, int total); + void SetValue(const int elapsed, const int total); void SetStopped(); - void SetCanSeek(bool can_seek); - void Seek(int gap); + void SetCanSeek(const bool can_seek); + void Seek(const int gap); signals: void ValueChanged(int value); @@ -74,19 +74,19 @@ class TrackSlider : public QWidget { void Previous(); private slots: - void ValueMaybeChanged(int value); + void ValueMaybeChanged(const int value); void ToggleTimeDisplay(); private: - void UpdateTimes(int elapsed); + void UpdateTimes(const int elapsed); void UpdateLabelWidth(); - void UpdateLabelWidth(QLabel* label, const QString& text); + void UpdateLabelWidth(QLabel *label, const QString &text); private: - Ui_TrackSlider* ui_; + Ui_TrackSlider *ui_; #ifdef HAVE_MOODBAR - MoodbarProxyStyle* moodbar_style_; + MoodbarProxyStyle *moodbar_style_; #endif bool setting_value_; diff --git a/src/widgets/tracksliderpopup.h b/src/widgets/tracksliderpopup.h index ebbe2c74..ef9e972b 100644 --- a/src/widgets/tracksliderpopup.h +++ b/src/widgets/tracksliderpopup.h @@ -73,4 +73,4 @@ public: QPixmap background_cache_; }; -#endif // TRACKSLIDERPOPUP_H +#endif // TRACKSLIDERPOPUP_H diff --git a/src/widgets/tracksliderslider.cpp b/src/widgets/tracksliderslider.cpp index 4f15f036..78196708 100644 --- a/src/widgets/tracksliderslider.cpp +++ b/src/widgets/tracksliderslider.cpp @@ -39,22 +39,22 @@ #endif #include "tracksliderslider.h" -TrackSliderSlider::TrackSliderSlider(QWidget* parent) +TrackSliderSlider::TrackSliderSlider(QWidget *parent) : QSlider(parent), #ifndef Q_OS_MACOS popup_(new TrackSliderPopup(window())), #endif - mouse_hover_seconds_(0) { + mouse_hover_seconds_(0) { setMouseTracking(true); #ifndef Q_OS_MACOS popup_->hide(); - connect(this, SIGNAL(valueChanged(int)), SLOT(UpdateDeltaTime())); + QObject::connect(this, &TrackSliderSlider::valueChanged, this, &TrackSliderSlider::UpdateDeltaTime); #endif } -void TrackSliderSlider::mousePressEvent(QMouseEvent* e) { +void TrackSliderSlider::mousePressEvent(QMouseEvent *e) { // QSlider asks QStyle which mouse button should do what (absolute move or page step). // We force our own behaviour here because it makes more sense for a music player IMO. @@ -74,9 +74,11 @@ void TrackSliderSlider::mousePressEvent(QMouseEvent* e) { if (new_event.isAccepted()) e->accept(); + } -void TrackSliderSlider::mouseReleaseEvent(QMouseEvent* e) { +void TrackSliderSlider::mouseReleaseEvent(QMouseEvent *e) { + QSlider::mouseReleaseEvent(e); if (e->button() == Qt::XButton1) { emit Previous(); @@ -85,9 +87,11 @@ void TrackSliderSlider::mouseReleaseEvent(QMouseEvent* e) { emit Next(); } e->accept(); + } -void TrackSliderSlider::mouseMoveEvent(QMouseEvent* e) { +void TrackSliderSlider::mouseMoveEvent(QMouseEvent *e) { + QSlider::mouseMoveEvent(e); // Borrowed from QSliderPrivate::pixelPosToRangeValue @@ -107,6 +111,7 @@ void TrackSliderSlider::mouseMoveEvent(QMouseEvent* e) { UpdateDeltaTime(); popup_->SetPopupPosition(mapTo(window(), QPoint(e->pos().x(), rect().center().y()))); #endif + } void TrackSliderSlider::wheelEvent(QWheelEvent *e) { @@ -126,24 +131,29 @@ void TrackSliderSlider::enterEvent(QEnterEvent *e) { #else void TrackSliderSlider::enterEvent(QEvent *e) { #endif + QSlider::enterEvent(e); #ifndef Q_OS_MACOS if (isEnabled()) { popup_->show(); } #endif + } void TrackSliderSlider::leaveEvent(QEvent *e) { + QSlider::leaveEvent(e); #ifndef Q_OS_MACOS if (popup_->isVisible()) { popup_->hide(); } #endif + } void TrackSliderSlider::keyPressEvent(QKeyEvent *event) { + if (event->key() == Qt::Key_Left || event->key() == Qt::Key_Down) { emit SeekBackward(); event->accept(); @@ -155,13 +165,16 @@ void TrackSliderSlider::keyPressEvent(QKeyEvent *event) { else { QSlider::keyPressEvent(event); } + } void TrackSliderSlider::UpdateDeltaTime() { + #ifndef Q_OS_MACOS if (popup_->isVisible()) { int delta_seconds = mouse_hover_seconds_ - (value() / kMsecPerSec); popup_->SetSmallText(Utilities::PrettyTimeDelta(delta_seconds)); } #endif + } diff --git a/src/widgets/tracksliderslider.h b/src/widgets/tracksliderslider.h index e3c76585..2c2f736f 100644 --- a/src/widgets/tracksliderslider.h +++ b/src/widgets/tracksliderslider.h @@ -52,9 +52,9 @@ class TrackSliderSlider : public QSlider { void Next(); protected: - void mousePressEvent(QMouseEvent* e) override; - void mouseReleaseEvent(QMouseEvent* e) override; - void mouseMoveEvent(QMouseEvent* e) override; + void mousePressEvent(QMouseEvent *e) override; + void mouseReleaseEvent(QMouseEvent *e) override; + void mouseMoveEvent(QMouseEvent *e) override; void wheelEvent(QWheelEvent *e) override; #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) void enterEvent(QEnterEvent *e) override; @@ -69,7 +69,7 @@ class TrackSliderSlider : public QSlider { private: #ifndef Q_OS_MACOS - TrackSliderPopup* popup_; + TrackSliderPopup *popup_; #endif int mouse_hover_seconds_; diff --git a/src/widgets/volumeslider.cpp b/src/widgets/volumeslider.cpp index 0fefa359..3478e43c 100644 --- a/src/widgets/volumeslider.cpp +++ b/src/widgets/volumeslider.cpp @@ -224,7 +224,7 @@ VolumeSlider::VolumeSlider(QWidget* parent, uint max) setMinimumWidth(m_pixmapInset.width()); setMinimumHeight(m_pixmapInset.height()); - connect(m_animTimer, SIGNAL(timeout()), this, SLOT(slotAnimTimer())); + QObject::connect(m_animTimer, &QTimer::timeout, this, &VolumeSlider::slotAnimTimer); } diff --git a/tests/src/collectionbackend_test.cpp b/tests/src/collectionbackend_test.cpp index cd8eddeb..2826e7a4 100644 --- a/tests/src/collectionbackend_test.cpp +++ b/tests/src/collectionbackend_test.cpp @@ -75,7 +75,7 @@ TEST_F(CollectionBackendTest, EmptyDatabase) { TEST_F(CollectionBackendTest, AddDirectory) { - QSignalSpy spy(backend_.get(), SIGNAL(DirectoryDiscovered(Directory, SubdirectoryList))); + QSignalSpy spy(backend_.get(), &CollectionBackend::DirectoryDiscovered); backend_->AddDirectory("/tmp"); @@ -96,7 +96,7 @@ TEST_F(CollectionBackendTest, RemoveDirectory) { dir.path = "/tmp"; backend_->AddDirectory(dir.path); - QSignalSpy spy(backend_.get(), SIGNAL(DirectoryDeleted(Directory))); + QSignalSpy spy(backend_.get(), &CollectionBackend::DirectoryDeleted); // Remove the directory again backend_->RemoveDirectory(dir); @@ -117,7 +117,7 @@ TEST_F(CollectionBackendTest, AddInvalidSong) { //s.set_url(QUrl::fromLocalFile("foo.flac")); s.set_directory_id(1); - QSignalSpy spy(database_.get(), SIGNAL(Error(QString))); + QSignalSpy spy(database_.get(), &Database::Error); backend_->AddOrUpdateSongs(SongList() << s); //ASSERT_EQ(1, spy.count()); spy.takeFirst(); @@ -161,8 +161,8 @@ class SingleSong : public CollectionBackendTest { } void AddDummySong() { - QSignalSpy added_spy(backend_.get(), SIGNAL(SongsDiscovered(SongList))); - QSignalSpy deleted_spy(backend_.get(), SIGNAL(SongsDeleted(SongList))); + QSignalSpy added_spy(backend_.get(), &CollectionBackend::SongsDiscovered); + QSignalSpy deleted_spy(backend_.get(), &CollectionBackend::SongsDeleted); // Add the song backend_->AddOrUpdateSongs(SongList() << song_); @@ -285,8 +285,8 @@ TEST_F(SingleSong, UpdateSong) { new_song.set_id(1); new_song.set_title("A different title"); - QSignalSpy deleted_spy(backend_.get(), SIGNAL(SongsDeleted(SongList))); - QSignalSpy added_spy(backend_.get(), SIGNAL(SongsDiscovered(SongList))); + QSignalSpy deleted_spy(backend_.get(), &CollectionBackend::SongsDeleted); + QSignalSpy added_spy(backend_.get(), &CollectionBackend::SongsDiscovered); backend_->AddOrUpdateSongs(SongList() << new_song); @@ -311,7 +311,7 @@ TEST_F(SingleSong, DeleteSongs) { Song new_song(song_); new_song.set_id(1); - QSignalSpy deleted_spy(backend_.get(), SIGNAL(SongsDeleted(SongList))); + QSignalSpy deleted_spy(backend_.get(), &CollectionBackend::SongsDeleted); backend_->DeleteSongs(SongList() << new_song); @@ -343,7 +343,7 @@ TEST_F(SingleSong, MarkSongsUnavailable) { Song new_song(song_); new_song.set_id(1); - QSignalSpy deleted_spy(backend_.get(), SIGNAL(SongsDeleted(SongList))); + QSignalSpy deleted_spy(backend_.get(), &CollectionBackend::SongsDeleted); backend_->MarkSongsUnavailable(SongList() << new_song); diff --git a/tests/src/collectionmodel_test.cpp b/tests/src/collectionmodel_test.cpp index a8d1cbbf..1d49bfb0 100644 --- a/tests/src/collectionmodel_test.cpp +++ b/tests/src/collectionmodel_test.cpp @@ -253,9 +253,9 @@ TEST_F(CollectionModelTest, RemoveSongsLazyLoaded) { ASSERT_EQ(3, model_->rowCount(album_index)); // Remove the first two songs - QSignalSpy spy_preremove(model_.get(), SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy spy_remove(model_.get(), SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy spy_reset(model_.get(), SIGNAL(modelReset())); + QSignalSpy spy_preremove(model_.get(), &CollectionModel::rowsAboutToBeRemoved); + QSignalSpy spy_remove(model_.get(), &CollectionModel::rowsRemoved); + QSignalSpy spy_reset(model_.get(), &CollectionModel::modelReset); backend_->DeleteSongs(SongList() << one << two); @@ -278,9 +278,9 @@ TEST_F(CollectionModelTest, RemoveSongsNotLazyLoaded) { model_->Init(false); // Remove the first two songs - QSignalSpy spy_preremove(model_.get(), SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy spy_remove(model_.get(), SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy spy_reset(model_.get(), SIGNAL(modelReset())); + QSignalSpy spy_preremove(model_.get(), &CollectionModel::rowsAboutToBeRemoved); + QSignalSpy spy_remove(model_.get(), &CollectionModel::rowsRemoved); + QSignalSpy spy_reset(model_.get(), &CollectionModel::modelReset); backend_->DeleteSongs(SongList() << one << two); @@ -576,9 +576,9 @@ TEST_F(CollectionModelTest, TestContainerNodes) { model3->set_use_lazy_loading(false); - QSignalSpy model1_update(model1.get(), SIGNAL(rowsInserted(QModelIndex, int, int))); - QSignalSpy model2_update(model2.get(), SIGNAL(rowsInserted(QModelIndex, int, int))); - QSignalSpy model3_update(model3.get(), SIGNAL(rowsInserted(QModelIndex, int, int))); + QSignalSpy model1_update(model1.get(), &CollectionModel::rowsInserted); + QSignalSpy model2_update(model2.get(), &CollectionModel::rowsInserted); + QSignalSpy model3_update(model3.get(), &CollectionModel::rowsInserted); backend1->AddOrUpdateSongs(songs); backend2->AddOrUpdateSongs(songs); @@ -646,9 +646,9 @@ TEST_F(CollectionModelTest, TestContainerNodes) { } } - QSignalSpy database_reset_1(backend1.get(), SIGNAL(DatabaseReset())); - QSignalSpy database_reset_2(backend2.get(), SIGNAL(DatabaseReset())); - QSignalSpy database_reset_3(backend3.get(), SIGNAL(DatabaseReset())); + QSignalSpy database_reset_1(backend1.get(), &CollectionBackend::DatabaseReset); + QSignalSpy database_reset_2(backend2.get(), &CollectionBackend::DatabaseReset); + QSignalSpy database_reset_3(backend3.get(), &CollectionBackend::DatabaseReset); backend1->DeleteAll(); backend2->DeleteAll(); diff --git a/tests/src/concurrentrun_test.cpp b/tests/src/concurrentrun_test.cpp index 731181dc..d28fb0c1 100644 --- a/tests/src/concurrentrun_test.cpp +++ b/tests/src/concurrentrun_test.cpp @@ -21,7 +21,7 @@ TEST(ConcurrentRunTest, ConcurrentRun0StartAndWait) { QFutureWatcher watcher; watcher.setFuture(future); QEventLoop loop; - QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); + QObject::connect(&watcher, &QFutureWatcher::finished, &loop, &QEventLoop::quit); loop.exec(); EXPECT_EQ(1337, watcher.result()); @@ -40,7 +40,7 @@ TEST(ConcurrentRunTest, ConcurrentRun1StartAndWait) { QFutureWatcher watcher; watcher.setFuture(future); QEventLoop loop; - QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); + QObject::connect(&watcher, &QFutureWatcher::finished, &loop, &QEventLoop::quit); loop.exec(); EXPECT_EQ(1337, watcher.result()); @@ -60,7 +60,7 @@ TEST(ConcurrentRunTest, ConcurrentRun2StartAndWait) { QFutureWatcher watcher; watcher.setFuture(future); QEventLoop loop; - QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); + QObject::connect(&watcher, &QFutureWatcher::finished, &loop, &QEventLoop::quit); loop.exec(); EXPECT_EQ(42, watcher.result()); @@ -81,7 +81,7 @@ TEST(ConcurrentRunTest, ConcurrentRun3StartAndWait) { QFutureWatcher watcher; watcher.setFuture(future); QEventLoop loop; - QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); + QObject::connect(&watcher, &QFutureWatcher::finished, &loop, &QEventLoop::quit); loop.exec(); EXPECT_EQ(102, watcher.result()); @@ -113,7 +113,7 @@ TEST(ConcurrentRunTest, ConcurrentRunVoidFunction1Start) { QFutureWatcher watcher; watcher.setFuture(future); QEventLoop loop; - QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); + QObject::connect(&watcher, &QFutureWatcher::finished, &loop, &QEventLoop::quit); loop.exec(); EXPECT_EQ(1337, n); @@ -128,7 +128,7 @@ TEST(ConcurrentRunTest, ConcurrentRunVoidFunction2Start) { QFutureWatcher watcher; watcher.setFuture(future); QEventLoop loop; - QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); + QObject::connect(&watcher, &QFutureWatcher::finished, &loop, &QEventLoop::quit); loop.exec(); EXPECT_EQ(1337, n); EXPECT_EQ(1338, m); @@ -144,7 +144,7 @@ TEST(ConcurrentRunTest, ConcurrentRunVoidFunction3Start) { QFutureWatcher watcher; watcher.setFuture(future); QEventLoop loop; - QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); + QObject::connect(&watcher, &QFutureWatcher::finished, &loop, &QEventLoop::quit); loop.exec(); EXPECT_EQ(1337, n); EXPECT_EQ(1338, m); @@ -169,7 +169,7 @@ TEST(ConcurrentRunTest, ConcurrentRunVoidBindFunctionStart) { QFutureWatcher watcher; watcher.setFuture(future); QEventLoop loop; - QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); + QObject::connect(&watcher, &QFutureWatcher::finished, &loop, &QEventLoop::quit); loop.exec(); EXPECT_EQ(11, nb); diff --git a/tests/src/mergedproxymodel_test.cpp b/tests/src/mergedproxymodel_test.cpp index 5c9fa717..03453d19 100644 --- a/tests/src/mergedproxymodel_test.cpp +++ b/tests/src/mergedproxymodel_test.cpp @@ -98,8 +98,8 @@ TEST_F(MergedProxyModelTest, Merged) { TEST_F(MergedProxyModelTest, SourceInsert) { - QSignalSpy before_spy(&merged_, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); - QSignalSpy after_spy(&merged_, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy before_spy(&merged_, &MergedProxyModel::rowsAboutToBeInserted); + QSignalSpy after_spy(&merged_, &MergedProxyModel::rowsInserted); source_.appendRow(new QStandardItem("one")); @@ -118,8 +118,8 @@ TEST_F(MergedProxyModelTest, SourceRemove) { source_.appendRow(new QStandardItem("one")); - QSignalSpy before_spy(&merged_, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy after_spy(&merged_, SIGNAL(rowsRemoved(QModelIndex,int,int))); + QSignalSpy before_spy(&merged_, &MergedProxyModel::rowsAboutToBeRemoved); + QSignalSpy after_spy(&merged_, &MergedProxyModel::rowsRemoved); source_.removeRow(0, QModelIndex()); @@ -140,8 +140,8 @@ TEST_F(MergedProxyModelTest, SubInsert) { QStandardItemModel submodel; merged_.AddSubModel(source_.index(0, 0, QModelIndex()), &submodel); - QSignalSpy before_spy(&merged_, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); - QSignalSpy after_spy(&merged_, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy before_spy(&merged_, &MergedProxyModel::rowsAboutToBeInserted); + QSignalSpy after_spy(&merged_, &MergedProxyModel::rowsInserted); submodel.appendRow(new QStandardItem("two")); @@ -164,8 +164,8 @@ TEST_F(MergedProxyModelTest, SubRemove) { submodel.appendRow(new QStandardItem("two")); - QSignalSpy before_spy(&merged_, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy after_spy(&merged_, SIGNAL(rowsRemoved(QModelIndex,int,int))); + QSignalSpy before_spy(&merged_, &MergedProxyModel::rowsAboutToBeRemoved); + QSignalSpy after_spy(&merged_, &MergedProxyModel::rowsRemoved); submodel.removeRow(0, QModelIndex());