diff --git a/src/analyzer/blockanalyzer.cpp b/src/analyzer/blockanalyzer.cpp index 45212e704..d36ffebb5 100644 --- a/src/analyzer/blockanalyzer.cpp +++ b/src/analyzer/blockanalyzer.cpp @@ -36,12 +36,14 @@ #include "analyzerbase.h" #include "fht.h" -const int BlockAnalyzer::kHeight = 2; -const int BlockAnalyzer::kWidth = 4; -const int BlockAnalyzer::kMinRows = 3; // arbitrary -const int BlockAnalyzer::kMinColumns = 32; // arbitrary -const int BlockAnalyzer::kMaxColumns = 256; // must be 2**n -const int BlockAnalyzer::kFadeSize = 90; +namespace { +constexpr int kHeight = 2; +constexpr int kWidth = 4; +constexpr int kMinRows = 3; // arbitrary +constexpr int kMinColumns = 32; // arbitrary +constexpr int kMaxColumns = 256; // must be 2**n +constexpr int kFadeSize = 90; +} // namespace const char *BlockAnalyzer::kName = QT_TRANSLATE_NOOP("AnalyzerContainer", "Block analyzer"); diff --git a/src/analyzer/blockanalyzer.h b/src/analyzer/blockanalyzer.h index 4dbabf36e..df911d647 100644 --- a/src/analyzer/blockanalyzer.h +++ b/src/analyzer/blockanalyzer.h @@ -43,13 +43,6 @@ class BlockAnalyzer : public AnalyzerBase { public: Q_INVOKABLE explicit BlockAnalyzer(QWidget*); - static const int kHeight; - static const int kWidth; - static const int kMinRows; - static const int kMinColumns; - static const int kMaxColumns; - static const int kFadeSize; - static const char *kName; protected: diff --git a/src/collection/collectionfilterwidget.cpp b/src/collection/collectionfilterwidget.cpp index c7bb8e56c..e257374d3 100644 --- a/src/collection/collectionfilterwidget.cpp +++ b/src/collection/collectionfilterwidget.cpp @@ -61,6 +61,10 @@ #include "settings/collectionsettingspage.h" #include "settings/appearancesettingspage.h" +namespace { +constexpr int kFilterDelay = 500; // msec +} + CollectionFilterWidget::CollectionFilterWidget(QWidget *parent) : QWidget(parent), ui_(new Ui_CollectionFilterWidget), diff --git a/src/collection/collectionfilterwidget.h b/src/collection/collectionfilterwidget.h index 3ae9fa901..2d010b929 100644 --- a/src/collection/collectionfilterwidget.h +++ b/src/collection/collectionfilterwidget.h @@ -51,8 +51,6 @@ class CollectionFilterWidget : public QWidget { explicit CollectionFilterWidget(QWidget *parent = nullptr); ~CollectionFilterWidget() override; - static const int kFilterDelay = 500; // msec - enum class DelayBehaviour { AlwaysInstant, DelayedOnLargeLibraries, diff --git a/src/context/contextview.cpp b/src/context/contextview.cpp index 5c8fc4b01..df2383ced 100644 --- a/src/context/contextview.cpp +++ b/src/context/contextview.cpp @@ -65,7 +65,9 @@ #include "contextview.h" #include "contextalbum.h" -const int ContextView::kWidgetSpacing = 50; +namespace { +constexpr int kWidgetSpacing = 50; +} ContextView::ContextView(QWidget *parent) : QWidget(parent), diff --git a/src/context/contextview.h b/src/context/contextview.h index afea0d9f0..ff53d11de 100644 --- a/src/context/contextview.h +++ b/src/context/contextview.h @@ -101,8 +101,6 @@ class ContextView : public QWidget { void AlbumCoverLoaded(const Song &song, const QImage &image); private: - static const int kWidgetSpacing; - Application *app_; CollectionView *collectionview_; AlbumCoverChoiceController *album_cover_choice_controller_; diff --git a/src/core/commandlineoptions.cpp b/src/core/commandlineoptions.cpp index a3f422dc5..fef154c3d 100644 --- a/src/core/commandlineoptions.cpp +++ b/src/core/commandlineoptions.cpp @@ -46,7 +46,9 @@ #include -const char *CommandlineOptions::kHelpText = +namespace { + +constexpr char kHelpText[] = "%1: strawberry [%2] [%3]\n" "\n" "%4:\n" @@ -83,7 +85,9 @@ const char *CommandlineOptions::kHelpText = " --log-levels %33\n" " --version %34\n"; -const char *CommandlineOptions::kVersionText = "Strawberry %1"; +constexpr char kVersionText[] = "Strawberry %1"; + +} // namespace CommandlineOptions::CommandlineOptions(int argc, char **argv) : argc_(argc), diff --git a/src/core/commandlineoptions.h b/src/core/commandlineoptions.h index c289ab136..0cfc98dab 100644 --- a/src/core/commandlineoptions.h +++ b/src/core/commandlineoptions.h @@ -41,9 +41,6 @@ class CommandlineOptions { public: explicit CommandlineOptions(int argc = 0, char **argv = nullptr); - static const char *kHelpText; - static const char *kVersionText; - // Don't change the values or order, these get serialised and sent to // possibly a different version of Strawberry enum class UrlListAction { diff --git a/src/core/deletefiles.cpp b/src/core/deletefiles.cpp index 3983098b1..739dfcecc 100644 --- a/src/core/deletefiles.cpp +++ b/src/core/deletefiles.cpp @@ -34,7 +34,9 @@ #include "deletefiles.h" #include "musicstorage.h" -const int DeleteFiles::kBatchSize = 50; +namespace { +constexpr int kBatchSize = 50; +} DeleteFiles::DeleteFiles(SharedPtr task_manager, SharedPtr storage, const bool use_trash, QObject *parent) : QObject(parent), diff --git a/src/core/deletefiles.h b/src/core/deletefiles.h index b1c117de7..4bd319143 100644 --- a/src/core/deletefiles.h +++ b/src/core/deletefiles.h @@ -41,8 +41,6 @@ class DeleteFiles : public QObject { explicit DeleteFiles(SharedPtr task_manager, SharedPtr storage, const bool use_trash, QObject *parent = nullptr); ~DeleteFiles() override; - static const int kBatchSize; - void Start(const SongList &songs); void Start(const QStringList &filenames); diff --git a/src/core/songloader.cpp b/src/core/songloader.cpp index 5d6977f41..fb8e42f0a 100644 --- a/src/core/songloader.cpp +++ b/src/core/songloader.cpp @@ -62,8 +62,11 @@ # include "device/cddasongloader.h" #endif +namespace { +constexpr int kDefaultTimeout = 5000; +} + QSet SongLoader::sRawUriSchemes; -const int SongLoader::kDefaultTimeout = 5000; SongLoader::SongLoader(SharedPtr collection_backend, const SharedPtr player, QObject *parent) : QObject(parent), diff --git a/src/core/songloader.h b/src/core/songloader.h index 5ccceae57..31eb73060 100644 --- a/src/core/songloader.h +++ b/src/core/songloader.h @@ -68,8 +68,6 @@ class SongLoader : public QObject { BlockingLoadRequired }; - static const int kDefaultTimeout; - const QUrl &url() const { return url_; } const SongList &songs() const { return songs_; } diff --git a/src/core/windows7thumbbar.cpp b/src/core/windows7thumbbar.cpp index bbb354de9..e784cacfb 100644 --- a/src/core/windows7thumbbar.cpp +++ b/src/core/windows7thumbbar.cpp @@ -37,8 +37,10 @@ extern HICON qt_pixmapToWinHICON(const QPixmap &p); #include "core/logging.h" #include "windows7thumbbar.h" -const int Windows7ThumbBar::kIconSize = 16; -const int Windows7ThumbBar::kMaxButtonCount = 7; +namespace { +constexpr int kIconSize = 16; +constexpr int kMaxButtonCount = 7; +} // namespace Windows7ThumbBar::Windows7ThumbBar(QWidget *widget) : QObject(widget), diff --git a/src/core/windows7thumbbar.h b/src/core/windows7thumbbar.h index 43fcf91ca..078709c0d 100644 --- a/src/core/windows7thumbbar.h +++ b/src/core/windows7thumbbar.h @@ -39,9 +39,6 @@ class Windows7ThumbBar : public QObject { // Creates a list of buttons in the taskbar icon for this window. explicit Windows7ThumbBar(QWidget *widget = nullptr); - static const int kIconSize; - static const int kMaxButtonCount; - // You must call this in the parent widget's constructor before returning to the event loop. If an action is nullptr it becomes a spacer. void SetActions(const QList &actions); diff --git a/src/covermanager/albumcoverloader.cpp b/src/covermanager/albumcoverloader.cpp index f4dd18331..e1f4abca3 100644 --- a/src/covermanager/albumcoverloader.cpp +++ b/src/covermanager/albumcoverloader.cpp @@ -46,6 +46,10 @@ using std::make_shared; +namespace { +constexpr int kMaxRedirects = 3; +} + AlbumCoverLoader::AlbumCoverLoader(QObject *parent) : QObject(parent), network_(new NetworkAccessManager(this)), diff --git a/src/covermanager/albumcoverloader.h b/src/covermanager/albumcoverloader.h index 73814099f..52806c5c9 100644 --- a/src/covermanager/albumcoverloader.h +++ b/src/covermanager/albumcoverloader.h @@ -123,7 +123,6 @@ class AlbumCoverLoader : public QObject { void LoadRemoteImageFinished(QNetworkReply *reply, AlbumCoverLoader::TaskPtr task, const AlbumCoverLoaderResult::Type result_type, const QUrl &cover_url); private: - static const int kMaxRedirects = 3; SharedPtr network_; bool stop_requested_; QMutex mutex_load_image_async_; diff --git a/src/device/devicedatabasebackend.cpp b/src/device/devicedatabasebackend.cpp index 9d3e44eb5..2256d4a25 100644 --- a/src/device/devicedatabasebackend.cpp +++ b/src/device/devicedatabasebackend.cpp @@ -38,7 +38,9 @@ #include "core/scopedtransaction.h" #include "devicedatabasebackend.h" -const int DeviceDatabaseBackend::kDeviceSchemaVersion = 5; +namespace { +constexpr int kDeviceSchemaVersion = 5; +} DeviceDatabaseBackend::DeviceDatabaseBackend(QObject *parent) : QObject(parent), diff --git a/src/device/devicedatabasebackend.h b/src/device/devicedatabasebackend.h index bdea60ccd..8c4e86901 100644 --- a/src/device/devicedatabasebackend.h +++ b/src/device/devicedatabasebackend.h @@ -56,8 +56,6 @@ class DeviceDatabaseBackend : public QObject { }; using DeviceList = QList; - static const int kDeviceSchemaVersion; - void Init(SharedPtr db); void Close(); void ExitAsync(); diff --git a/src/engine/chromaprinter.cpp b/src/engine/chromaprinter.cpp index 03cfc2a08..1a4f7f431 100644 --- a/src/engine/chromaprinter.cpp +++ b/src/engine/chromaprinter.cpp @@ -43,10 +43,12 @@ using u_int32_t = unsigned int; #endif -static const int kDecodeRate = 11025; -static const int kDecodeChannels = 1; -static const int kPlayLengthSecs = 30; -static const int kTimeoutSecs = 10; +namespace { +constexpr int kDecodeRate = 11025; +constexpr int kDecodeChannels = 1; +constexpr int kPlayLengthSecs = 30; +constexpr int kTimeoutSecs = 10; +} // namespace Chromaprinter::Chromaprinter(const QString &filename) : filename_(filename), diff --git a/src/engine/ebur128analysis.cpp b/src/engine/ebur128analysis.cpp index ec75dcf88..19cb113e7 100644 --- a/src/engine/ebur128analysis.cpp +++ b/src/engine/ebur128analysis.cpp @@ -47,10 +47,10 @@ using std::unique_ptr; -static const int kTimeoutSecs = 60; - namespace { +constexpr int kTimeoutSecs = 60; + struct ebur128_state_deleter { void operator()(ebur128_state *p) const { ebur128_destroy(&p); }; }; diff --git a/src/engine/gstengine.cpp b/src/engine/gstengine.cpp index 7ce63d792..46ebf33c9 100644 --- a/src/engine/gstengine.cpp +++ b/src/engine/gstengine.cpp @@ -64,21 +64,24 @@ using std::make_shared; const char *GstEngine::kAutoSink = "autoaudiosink"; const char *GstEngine::kALSASink = "alsasink"; -const char *GstEngine::kOpenALSASink = "openalsink"; -const char *GstEngine::kOSSSink = "osssink"; -const char *GstEngine::kOSS4Sink = "oss4sink"; -const char *GstEngine::kJackAudioSink = "jackaudiosink"; -const char *GstEngine::kPulseSink = "pulsesink"; -const char *GstEngine::kA2DPSink = "a2dpsink"; -const char *GstEngine::kAVDTPSink = "avdtpsink"; -const char *GstEngine::InterAudiosink = "interaudiosink"; -const char *GstEngine::kDirectSoundSink = "directsoundsink"; -const char *GstEngine::kOSXAudioSink = "osxaudiosink"; -const char *GstEngine::kWASAPISink = "wasapisink"; -const int GstEngine::kDiscoveryTimeoutS = 10; -const qint64 GstEngine::kTimerIntervalNanosec = 1000 * kNsecPerMsec; // 1s -const qint64 GstEngine::kPreloadGapNanosec = 8000 * kNsecPerMsec; // 8s -const qint64 GstEngine::kSeekDelayNanosec = 100 * kNsecPerMsec; // 100msec + +namespace { +constexpr char kOpenALSASink[] = "openalsink"; +constexpr char kOSSSink[] = "osssink"; +constexpr char kOSS4Sink[] = "oss4sink"; +constexpr char kJackAudioSink[] = "jackaudiosink"; +constexpr char kPulseSink[] = "pulsesink"; +constexpr char kA2DPSink[] = "a2dpsink"; +constexpr char kAVDTPSink[] = "avdtpsink"; +constexpr char InterAudiosink[] = "interaudiosink"; +constexpr char kDirectSoundSink[] = "directsoundsink"; +constexpr char kOSXAudioSink[] = "osxaudiosink"; +constexpr char kWASAPISink[] = "wasapisink"; +constexpr int kDiscoveryTimeoutS = 10; +constexpr qint64 kTimerIntervalNanosec = 1000 * kNsecPerMsec; // 1s +constexpr qint64 kPreloadGapNanosec = 8000 * kNsecPerMsec; // 8s +constexpr qint64 kSeekDelayNanosec = 100 * kNsecPerMsec; // 100msec +} // namespace GstEngine::GstEngine(SharedPtr task_manager, QObject *parent) : EngineBase(parent), diff --git a/src/engine/gstengine.h b/src/engine/gstengine.h index c23930ce1..5b7cbb95c 100644 --- a/src/engine/gstengine.h +++ b/src/engine/gstengine.h @@ -56,6 +56,7 @@ class GstEngine : public EngineBase, public GstBufferConsumer { ~GstEngine() override; static const char *kAutoSink; + static const char *kALSASink; Type type() const override { return Type::GStreamer; } bool Init() override; @@ -142,23 +143,6 @@ class GstEngine : public EngineBase, public GstBufferConsumer { static QString GSTdiscovererErrorMessage(GstDiscovererResult result); private: - static const char *kALSASink; - static const char *kOpenALSASink; - static const char *kOSSSink; - static const char *kOSS4Sink; - static const char *kJackAudioSink; - static const char *kPulseSink; - static const char *kA2DPSink; - static const char *kAVDTPSink; - static const char *InterAudiosink; - static const char *kDirectSoundSink; - static const char *kOSXAudioSink; - static const char *kWASAPISink; - static const int kDiscoveryTimeoutS; - static const qint64 kTimerIntervalNanosec; - static const qint64 kPreloadGapNanosec; - static const qint64 kSeekDelayNanosec; - SharedPtr task_manager_; GstStartup *gst_startup_; GstDiscoverer *discoverer_; diff --git a/src/engine/gstenginepipeline.cpp b/src/engine/gstenginepipeline.cpp index f16d79127..c36a72422 100644 --- a/src/engine/gstenginepipeline.cpp +++ b/src/engine/gstenginepipeline.cpp @@ -62,11 +62,15 @@ #include "gstenginepipeline.h" #include "gstbufferconsumer.h" -constexpr int GstEnginePipeline::kGstStateTimeoutNanosecs = 10000000; -constexpr int GstEnginePipeline::kFaderFudgeMsec = 2000; +namespace { -constexpr int GstEnginePipeline::kEqBandCount = 10; -constexpr int GstEnginePipeline::kEqBandFrequencies[] = { 60, 170, 310, 600, 1000, 3000, 6000, 12000, 14000, 16000 }; +constexpr int kGstStateTimeoutNanosecs = 10000000; +constexpr int kFaderFudgeMsec = 2000; + +constexpr int kEqBandCount = 10; +constexpr int kEqBandFrequencies[] = { 60, 170, 310, 600, 1000, 3000, 6000, 12000, 14000, 16000 }; + +} // namespace int GstEnginePipeline::sId = 1; diff --git a/src/engine/gstenginepipeline.h b/src/engine/gstenginepipeline.h index 03ef0eeb4..aa4aaf097 100644 --- a/src/engine/gstenginepipeline.h +++ b/src/engine/gstenginepipeline.h @@ -193,11 +193,6 @@ class GstEnginePipeline : public QObject { void FaderTimelineFinished(); private: - static const int kGstStateTimeoutNanosecs; - static const int kFaderFudgeMsec; - static const int kEqBandCount; - static const int kEqBandFrequencies[]; - // Using == to compare two pipelines is a bad idea, because new ones often get created in the same address as old ones. This ID will be unique for each pipeline. // Threading warning: access to the static ID field isn't protected by a mutex because all pipeline creation is currently done in the main thread. static int sId; diff --git a/src/equalizer/equalizer.cpp b/src/equalizer/equalizer.cpp index b0f4b6633..f79e70e6e 100644 --- a/src/equalizer/equalizer.cpp +++ b/src/equalizer/equalizer.cpp @@ -49,9 +49,10 @@ #include "equalizerslider.h" #include "ui_equalizer.h" -const char *Equalizer::kGainText[] = { "60", "170", "310", "600", "1k", "3k", "6k", "12k", "14k", "16k" }; - -const char *Equalizer::kSettingsGroup = "Equalizer"; +namespace { +constexpr char kSettingsGroup[] = "Equalizer"; +const char *kGainText[] = { "60", "170", "310", "600", "1k", "3k", "6k", "12k", "14k", "16k" }; +} // namespace Equalizer::Equalizer(QWidget *parent) : QDialog(parent), diff --git a/src/equalizer/equalizer.h b/src/equalizer/equalizer.h index b71a237b0..48ba8bc57 100644 --- a/src/equalizer/equalizer.h +++ b/src/equalizer/equalizer.h @@ -44,9 +44,7 @@ class Equalizer : public QDialog { explicit Equalizer(QWidget *parent = nullptr); ~Equalizer() override; - static const int kBands = 10; - static const char *kGainText[kBands]; - static const char *kSettingsGroup; + static constexpr int kBands = 10; struct Params { Params(); diff --git a/src/lyrics/lyricsfetcher.cpp b/src/lyrics/lyricsfetcher.cpp index ab3e0ff34..021e1b6cf 100644 --- a/src/lyrics/lyricsfetcher.cpp +++ b/src/lyrics/lyricsfetcher.cpp @@ -35,7 +35,9 @@ using namespace std::chrono_literals; -const int LyricsFetcher::kMaxConcurrentRequests = 5; +namespace { +constexpr int kMaxConcurrentRequests = 5; +} LyricsFetcher::LyricsFetcher(SharedPtr lyrics_providers, QObject *parent) : QObject(parent), diff --git a/src/lyrics/lyricsfetcher.h b/src/lyrics/lyricsfetcher.h index b214af2b3..73af6956a 100644 --- a/src/lyrics/lyricsfetcher.h +++ b/src/lyrics/lyricsfetcher.h @@ -69,8 +69,6 @@ class LyricsFetcher : public QObject { void StartRequests(); private: - static const int kMaxConcurrentRequests; - SharedPtr lyrics_providers_; quint64 next_id_; diff --git a/src/lyrics/lyricsfetchersearch.cpp b/src/lyrics/lyricsfetchersearch.cpp index eeabf5666..c5276bb16 100644 --- a/src/lyrics/lyricsfetchersearch.cpp +++ b/src/lyrics/lyricsfetchersearch.cpp @@ -34,9 +34,11 @@ #include "lyricsprovider.h" #include "lyricsproviders.h" -const int LyricsFetcherSearch::kSearchTimeoutMs = 3000; -const int LyricsFetcherSearch::kGoodLyricsLength = 60; -const float LyricsFetcherSearch::kHighScore = 2.5; +namespace { +constexpr int kSearchTimeoutMs = 3000; +constexpr int kGoodLyricsLength = 60; +constexpr float kHighScore = 2.5; +} // namespace LyricsFetcherSearch::LyricsFetcherSearch(const quint64 id, const LyricsSearchRequest &request, QObject *parent) : QObject(parent), diff --git a/src/lyrics/lyricsfetchersearch.h b/src/lyrics/lyricsfetchersearch.h index f20367e0b..5af5179c3 100644 --- a/src/lyrics/lyricsfetchersearch.h +++ b/src/lyrics/lyricsfetchersearch.h @@ -57,10 +57,6 @@ class LyricsFetcherSearch : public QObject { static bool LyricsSearchResultCompareScore(const LyricsSearchResult &a, const LyricsSearchResult &b); private: - static const int kSearchTimeoutMs; - static const int kGoodLyricsLength; - static const float kHighScore; - quint64 id_; LyricsSearchRequest request_; LyricsSearchResults results_; diff --git a/src/moodbar/moodbarpipeline.cpp b/src/moodbar/moodbarpipeline.cpp index 664a32329..1849d9a9a 100644 --- a/src/moodbar/moodbarpipeline.cpp +++ b/src/moodbar/moodbarpipeline.cpp @@ -41,7 +41,9 @@ using std::make_unique; -const int MoodbarPipeline::kBands = 128; +namespace { +constexpr int kBands = 128; +} MoodbarPipeline::MoodbarPipeline(const QUrl &url, QObject *parent) : QObject(parent), diff --git a/src/moodbar/moodbarpipeline.h b/src/moodbar/moodbarpipeline.h index bedbd9d98..9c752dfec 100644 --- a/src/moodbar/moodbarpipeline.h +++ b/src/moodbar/moodbarpipeline.h @@ -63,8 +63,6 @@ class MoodbarPipeline : public QObject { static GstBusSyncReply BusCallbackSync(GstBus*, GstMessage *msg, gpointer data); private: - static const int kBands; - QUrl url_; GstElement *pipeline_; GstElement *convert_element_; diff --git a/src/organize/organize.cpp b/src/organize/organize.cpp index 42b2b39d1..c8696217b 100644 --- a/src/organize/organize.cpp +++ b/src/organize/organize.cpp @@ -51,10 +51,10 @@ using namespace std::chrono_literals; class OrganizeFormat; -const int Organize::kBatchSize = 10; -#ifdef HAVE_GSTREAMER -const int Organize::kTranscodeProgressInterval = 500; -#endif +namespace { +constexpr int kBatchSize = 10; +constexpr int kTranscodeProgressInterval = 500; +} // namespace Organize::Organize(SharedPtr task_manager, SharedPtr destination, const OrganizeFormat &format, const bool copy, const bool overwrite, const bool albumcover, const NewSongInfoList &songs_info, const bool eject_after, const QString &playlist, QObject *parent) : QObject(parent), diff --git a/src/organize/organize.h b/src/organize/organize.h index 7868a35e9..e822a7d3d 100644 --- a/src/organize/organize.h +++ b/src/organize/organize.h @@ -66,11 +66,6 @@ class Organize : public QObject { explicit Organize(SharedPtr task_manager, SharedPtr destination, const OrganizeFormat &format, const bool copy, const bool overwrite, const bool albumcover, const NewSongInfoList &songs, const bool eject_after, const QString &playlist = QString(), QObject *parent = nullptr); ~Organize() override; - static const int kBatchSize; -#ifdef HAVE_GSTREAMER - static const int kTranscodeProgressInterval; -#endif - void Start(); signals: diff --git a/src/playlist/playlistbackend.cpp b/src/playlist/playlistbackend.cpp index adba1609d..5cd4be5bd 100644 --- a/src/playlist/playlistbackend.cpp +++ b/src/playlist/playlistbackend.cpp @@ -55,7 +55,9 @@ using std::make_shared; -const int PlaylistBackend::kSongTableJoins = 2; +namespace { +constexpr int kSongTableJoins = 2; +} PlaylistBackend::PlaylistBackend(Application *app, QObject *parent) : QObject(parent), diff --git a/src/playlist/playlistbackend.h b/src/playlist/playlistbackend.h index 82e4cc2cb..ffe599d0c 100644 --- a/src/playlist/playlistbackend.h +++ b/src/playlist/playlistbackend.h @@ -64,8 +64,6 @@ class PlaylistBackend : public QObject { }; using PlaylistList = QList; - static const int kSongTableJoins; - void Close(); void ExitAsync(); diff --git a/src/playlist/playlistcontainer.cpp b/src/playlist/playlistcontainer.cpp index 880abb8be..af1cd56ac 100644 --- a/src/playlist/playlistcontainer.cpp +++ b/src/playlist/playlistcontainer.cpp @@ -61,9 +61,11 @@ #include "widgets/qsearchfield.h" #include "settings/appearancesettingspage.h" -const char *PlaylistContainer::kSettingsGroup = "Playlist"; -const int PlaylistContainer::kFilterDelayMs = 100; -const int PlaylistContainer::kFilterDelayPlaylistSizeThreshold = 5000; +namespace { +constexpr char kSettingsGroup[] = "Playlist"; +constexpr int kFilterDelayMs = 100; +constexpr int kFilterDelayPlaylistSizeThreshold = 5000; +} // namespace PlaylistContainer::PlaylistContainer(QWidget *parent) : QWidget(parent), diff --git a/src/playlist/playlistcontainer.h b/src/playlist/playlistcontainer.h index d993d9609..8270fc6aa 100644 --- a/src/playlist/playlistcontainer.h +++ b/src/playlist/playlistcontainer.h @@ -54,8 +54,6 @@ class PlaylistContainer : public QWidget { explicit PlaylistContainer(QWidget *parent = nullptr); ~PlaylistContainer() override; - static const char *kSettingsGroup; - void SetActions(QAction *new_playlist, QAction *load_playlist, QAction *save_playlist, QAction *clear_playlist, QAction *next_playlist, QAction *previous_playlist, QAction *save_all_playlists); void SetManager(SharedPtr manager); void ReloadSettings(); @@ -113,9 +111,6 @@ class PlaylistContainer : public QWidget { void RepositionNoMatchesLabel(bool force = false); private: - static const int kFilterDelayMs; - static const int kFilterDelayPlaylistSizeThreshold; - Ui_PlaylistContainer *ui_; SharedPtr manager_; diff --git a/src/playlist/playlistdelegates.cpp b/src/playlist/playlistdelegates.cpp index f031a400b..0b1799bf5 100644 --- a/src/playlist/playlistdelegates.cpp +++ b/src/playlist/playlistdelegates.cpp @@ -71,13 +71,15 @@ #include "playlist/playlist.h" #include "playlistdelegates.h" -const int QueuedItemDelegate::kQueueBoxBorder = 1; -const int QueuedItemDelegate::kQueueBoxCornerRadius = 3; -const int QueuedItemDelegate::kQueueBoxLength = 30; -const QRgb QueuedItemDelegate::kQueueBoxGradientColor1 = qRgb(102, 150, 227); -const QRgb QueuedItemDelegate::kQueueBoxGradientColor2 = qRgb(77, 121, 200); -const int QueuedItemDelegate::kQueueOpacitySteps = 10; -const float QueuedItemDelegate::kQueueOpacityLowerBound = 0.4F; +namespace { +constexpr int kQueueBoxBorder = 1; +constexpr int kQueueBoxCornerRadius = 3; +constexpr int kQueueBoxLength = 30; +constexpr QRgb kQueueBoxGradientColor1 = qRgb(102, 150, 227); +constexpr QRgb kQueueBoxGradientColor2 = qRgb(77, 121, 200); +constexpr int kQueueOpacitySteps = 10; +constexpr float kQueueOpacityLowerBound = 0.4F; +} // namespace const int PlaylistDelegateBase::kMinHeight = 19; diff --git a/src/playlist/playlistdelegates.h b/src/playlist/playlistdelegates.h index d58cb9995..e60eb855a 100644 --- a/src/playlist/playlistdelegates.h +++ b/src/playlist/playlistdelegates.h @@ -66,14 +66,6 @@ class QueuedItemDelegate : public QStyledItemDelegate { int queue_indicator_size(const QModelIndex &idx) const; private: - static const int kQueueBoxBorder; - static const int kQueueBoxCornerRadius; - static const int kQueueBoxLength; - static const QRgb kQueueBoxGradientColor1; - static const QRgb kQueueBoxGradientColor2; - static const int kQueueOpacitySteps; - static const float kQueueOpacityLowerBound; - int indicator_column_; }; diff --git a/src/playlist/playlistlistview.cpp b/src/playlist/playlistlistview.cpp index 85fb6cd70..51ec83bed 100644 --- a/src/playlist/playlistlistview.cpp +++ b/src/playlist/playlistlistview.cpp @@ -33,6 +33,10 @@ #include "playlistlistview.h" #include "playlist.h" +namespace { +constexpr int kDragHoverTimeout = 500; +} + PlaylistListView::PlaylistListView(QWidget *parent) : AutoExpandingTreeView(parent) {} void PlaylistListView::paintEvent(QPaintEvent *event) { diff --git a/src/playlist/playlistlistview.h b/src/playlist/playlistlistview.h index 89847f2e4..29830db25 100644 --- a/src/playlist/playlistlistview.h +++ b/src/playlist/playlistlistview.h @@ -62,8 +62,6 @@ class PlaylistListView : public AutoExpandingTreeView { void timerEvent(QTimerEvent *e) override; private: - static const int kDragHoverTimeout = 500; - QBasicTimer drag_hover_timer_; }; diff --git a/src/playlist/playlisttabbar.cpp b/src/playlist/playlisttabbar.cpp index c3e09ee6d..7684cf5f3 100644 --- a/src/playlist/playlisttabbar.cpp +++ b/src/playlist/playlisttabbar.cpp @@ -54,7 +54,10 @@ #include "playlistmanager.h" #include "playlisttabbar.h" -const char *PlaylistTabBar::kSettingsGroup = "PlaylistTabBar"; +namespace { +constexpr char kSettingsGroup[] = "PlaylistTabBar"; +constexpr int kDragHoverTimeout = 500; +} // namespace PlaylistTabBar::PlaylistTabBar(QWidget *parent) : QTabBar(parent), diff --git a/src/playlist/playlisttabbar.h b/src/playlist/playlisttabbar.h index 589e52e22..7657cf1bf 100644 --- a/src/playlist/playlisttabbar.h +++ b/src/playlist/playlisttabbar.h @@ -54,9 +54,6 @@ class PlaylistTabBar : public QTabBar { public: explicit PlaylistTabBar(QWidget *parent = nullptr); - static const int kDragHoverTimeout = 500; - static const char *kSettingsGroup; - void SetActions(QAction *new_playlist, QAction *load_playlist); void SetManager(SharedPtr manager); diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index 7258bcfde..e8b3385e5 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -81,10 +81,12 @@ # include "moodbar/moodbaritemdelegate.h" #endif -const int PlaylistView::kGlowIntensitySteps = 24; -const int PlaylistView::kAutoscrollGraceTimeout = 30; // seconds -const int PlaylistView::kDropIndicatorWidth = 2; -const int PlaylistView::kDropIndicatorGradientWidth = 5; +namespace { +constexpr int kGlowIntensitySteps = 24; +constexpr int kAutoscrollGraceTimeout = 30; // seconds +constexpr int kDropIndicatorWidth = 2; +constexpr int kDropIndicatorGradientWidth = 5; +} // namespace PlaylistView::PlaylistView(QWidget *parent) : QTreeView(parent), diff --git a/src/playlist/playlistview.h b/src/playlist/playlistview.h index f28b0a824..dbed1dd2d 100644 --- a/src/playlist/playlistview.h +++ b/src/playlist/playlistview.h @@ -186,11 +186,6 @@ class PlaylistView : public QTreeView { void GlowIntensityChanged(); private: - static const int kGlowIntensitySteps; - static const int kAutoscrollGraceTimeout; - static const int kDropIndicatorWidth; - static const int kDropIndicatorGradientWidth; - QList GetEditableColumns(); QModelIndex NextEditableIndex(const QModelIndex ¤t); QModelIndex PrevEditableIndex(const QModelIndex ¤t); diff --git a/src/qobuz/qobuzservice.h b/src/qobuz/qobuzservice.h index e9a46e903..03ddaa0a0 100644 --- a/src/qobuz/qobuzservice.h +++ b/src/qobuz/qobuzservice.h @@ -72,7 +72,7 @@ class QobuzService : public StreamingService { int Search(const QString &text, StreamingSearchView::SearchType type) override; void CancelSearch() override; - int max_login_attempts() { return kLoginAttempts; } + int max_login_attempts() const { return kLoginAttempts; } Application *app() const { return app_; } QString app_id() const { return app_id_; } diff --git a/src/radios/radiomodel.cpp b/src/radios/radiomodel.cpp index c22d9441f..5d657cc91 100644 --- a/src/radios/radiomodel.cpp +++ b/src/radios/radiomodel.cpp @@ -39,7 +39,9 @@ #include "radiomimedata.h" #include "radiochannel.h" -const int RadioModel::kTreeIconSize = 22; +namespace { +constexpr int kTreeIconSize = 22; +} RadioModel::RadioModel(Application *app, QObject *parent) : SimpleTreeModel(new RadioItem(this), parent), diff --git a/src/radios/radiomodel.h b/src/radios/radiomodel.h index 275eacd6a..f5e4e886c 100644 --- a/src/radios/radiomodel.h +++ b/src/radios/radiomodel.h @@ -86,7 +86,6 @@ class RadioModel : public SimpleTreeModel { void AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderResult &result); private: - static const int kTreeIconSize; using ItemAndCacheKey = QPair; Application *app_; diff --git a/src/streaming/streamingsearchview.cpp b/src/streaming/streamingsearchview.cpp index ed63bb0fc..b63755378 100644 --- a/src/streaming/streamingsearchview.cpp +++ b/src/streaming/streamingsearchview.cpp @@ -86,9 +86,11 @@ using std::make_unique; -const int StreamingSearchView::kSwapModelsTimeoutMsec = 250; -const int StreamingSearchView::kDelayedSearchTimeoutMs = 200; -const int StreamingSearchView::kArtHeight = 32; +namespace { +constexpr int kSwapModelsTimeoutMsec = 250; +constexpr int kDelayedSearchTimeoutMs = 200; +constexpr int kArtHeight = 32; +} // namespace StreamingSearchView::StreamingSearchView(QWidget *parent) : QWidget(parent), diff --git a/src/streaming/streamingsearchview.h b/src/streaming/streamingsearchview.h index ee3d3fc0d..363bdb723 100644 --- a/src/streaming/streamingsearchview.h +++ b/src/streaming/streamingsearchview.h @@ -176,11 +176,6 @@ class StreamingSearchView : public QWidget { public slots: void ReloadSettings(); - private: - static const int kSwapModelsTimeoutMsec; - static const int kDelayedSearchTimeoutMs; - static const int kArtHeight; - private: Application *app_; SharedPtr service_; diff --git a/src/widgets/autoexpandingtreeview.cpp b/src/widgets/autoexpandingtreeview.cpp index f46b9c3fb..5c112e4a0 100644 --- a/src/widgets/autoexpandingtreeview.cpp +++ b/src/widgets/autoexpandingtreeview.cpp @@ -29,7 +29,9 @@ #include "autoexpandingtreeview.h" #include "core/mimedata.h" -const int AutoExpandingTreeView::kRowsToShow = 50; +namespace { +constexpr int kRowsToShow = 50; +} AutoExpandingTreeView::AutoExpandingTreeView(QWidget *parent) : QTreeView(parent), diff --git a/src/widgets/autoexpandingtreeview.h b/src/widgets/autoexpandingtreeview.h index 752386f95..0fb9cb51f 100644 --- a/src/widgets/autoexpandingtreeview.h +++ b/src/widgets/autoexpandingtreeview.h @@ -39,8 +39,6 @@ class AutoExpandingTreeView : public QTreeView { public: explicit AutoExpandingTreeView(QWidget *parent = nullptr); - static const int kRowsToShow; - void SetAutoOpen(bool v) { auto_open_ = v; } void SetExpandOnReset(bool v) { expand_on_reset_ = v; } void SetAddOnDoubleClick(bool v) { add_on_double_click_ = v; } diff --git a/src/widgets/favoritewidget.cpp b/src/widgets/favoritewidget.cpp index e421908bc..a5a5a86a5 100644 --- a/src/widgets/favoritewidget.cpp +++ b/src/widgets/favoritewidget.cpp @@ -30,7 +30,9 @@ #include "favoritewidget.h" -const int FavoriteWidget::kStarSize = 15; +namespace { +constexpr int kStarSize = 15; +} FavoriteWidget::FavoriteWidget(const int tab_index, const bool favorite, QWidget *parent) : QWidget(parent), diff --git a/src/widgets/favoritewidget.h b/src/widgets/favoritewidget.h index 9b06f2d5c..89e424f14 100644 --- a/src/widgets/favoritewidget.h +++ b/src/widgets/favoritewidget.h @@ -51,8 +51,6 @@ class FavoriteWidget : public QWidget { void mouseDoubleClickEvent(QMouseEvent*) override; private: - static const int kStarSize; - // The playlist's id this widget belongs to int tab_index_; bool favorite_; diff --git a/src/widgets/freespacebar.cpp b/src/widgets/freespacebar.cpp index 772ef01d4..a7f720ef7 100644 --- a/src/widgets/freespacebar.cpp +++ b/src/widgets/freespacebar.cpp @@ -44,20 +44,23 @@ class QPaintEvent; -const int FreeSpaceBar::kBarHeight = 20; -const int FreeSpaceBar::kBarBorderRadius = 8; -const int FreeSpaceBar::kMarkerSpacing = 32; -const int FreeSpaceBar::kLabelBoxSize = 12; -const int FreeSpaceBar::kLabelBoxPadding = 4; -const int FreeSpaceBar::kLabelSpacing = 16; +namespace { +constexpr int kBarHeight = 20; +constexpr int kBarBorderRadius = 8; +constexpr int kMarkerSpacing = 32; +constexpr int kLabelBoxSize = 12; +constexpr int kLabelBoxPadding = 4; +constexpr int kLabelSpacing = 16; -const QRgb FreeSpaceBar::kColorBg1 = qRgb(214, 207, 200); -const QRgb FreeSpaceBar::kColorBg2 = qRgb(234, 226, 218); -const QRgb FreeSpaceBar::kColorAdd1 = qRgb(136, 180, 229); -const QRgb FreeSpaceBar::kColorAdd2 = qRgb(72, 146, 229); -const QRgb FreeSpaceBar::kColorBar1 = qRgb(250, 148, 76); -const QRgb FreeSpaceBar::kColorBar2 = qRgb(214, 102, 24); -const QRgb FreeSpaceBar::kColorBorder = qRgb(174, 168, 162); +constexpr QRgb kColorBg1 = qRgb(214, 207, 200); +constexpr QRgb kColorBg2 = qRgb(234, 226, 218); +constexpr QRgb kColorAdd1 = qRgb(136, 180, 229); +constexpr QRgb kColorAdd2 = qRgb(72, 146, 229); +constexpr QRgb kColorBar1 = qRgb(250, 148, 76); +constexpr QRgb kColorBar2 = qRgb(214, 102, 24); +constexpr QRgb kColorBorder = qRgb(174, 168, 162); + +} // namespace FreeSpaceBar::FreeSpaceBar(QWidget *parent) : QWidget(parent), diff --git a/src/widgets/freespacebar.h b/src/widgets/freespacebar.h index 3a43ae00d..8d85a8d2b 100644 --- a/src/widgets/freespacebar.h +++ b/src/widgets/freespacebar.h @@ -39,21 +39,6 @@ class FreeSpaceBar : public QWidget { public: explicit FreeSpaceBar(QWidget *parent = nullptr); - static const int kBarHeight; - static const int kBarBorderRadius; - static const int kMarkerSpacing; - static const int kLabelBoxSize; - static const int kLabelBoxPadding; - static const int kLabelSpacing; - - static const QRgb kColorBg1; - static const QRgb kColorBg2; - static const QRgb kColorAdd1; - static const QRgb kColorAdd2; - static const QRgb kColorBar1; - static const QRgb kColorBar2; - static const QRgb kColorBorder; - void set_free_bytes(const quint64 bytes) { free_ = bytes; update(); } void set_additional_bytes(const quint64 bytes) { additional_ = bytes; update(); } void set_total_bytes(const quint64 bytes) { total_ = bytes; update(); } diff --git a/src/widgets/groupediconview.cpp b/src/widgets/groupediconview.cpp index ffbb769f8..71911a7ba 100644 --- a/src/widgets/groupediconview.cpp +++ b/src/widgets/groupediconview.cpp @@ -47,8 +47,10 @@ #include "core/multisortfilterproxy.h" #include "groupediconview.h" -const int GroupedIconView::kBarThickness = 2; -const int GroupedIconView::kBarMarginTop = 3; +namespace { +constexpr int kBarThickness = 2; +constexpr int kBarMarginTop = 3; +} // namespace GroupedIconView::GroupedIconView(QWidget *parent) : QListView(parent), diff --git a/src/widgets/groupediconview.h b/src/widgets/groupediconview.h index 20aa0343a..6d097d1cc 100644 --- a/src/widgets/groupediconview.h +++ b/src/widgets/groupediconview.h @@ -100,9 +100,6 @@ class GroupedIconView : public QListView { void LayoutItems(); private: - static const int kBarThickness; - static const int kBarMarginTop; - struct Header { int y; int first_row; diff --git a/src/widgets/multiloadingindicator.cpp b/src/widgets/multiloadingindicator.cpp index 6986714ce..a7c998507 100644 --- a/src/widgets/multiloadingindicator.cpp +++ b/src/widgets/multiloadingindicator.cpp @@ -34,9 +34,11 @@ #include "multiloadingindicator.h" #include "widgets/busyindicator.h" -const int MultiLoadingIndicator::kVerticalPadding = 4; -const int MultiLoadingIndicator::kHorizontalPadding = 6; -const int MultiLoadingIndicator::kSpacing = 6; +namespace { +constexpr int kVerticalPadding = 4; +constexpr int kHorizontalPadding = 6; +constexpr int kSpacing = 6; +} MultiLoadingIndicator::MultiLoadingIndicator(QWidget *parent) : QWidget(parent), diff --git a/src/widgets/multiloadingindicator.h b/src/widgets/multiloadingindicator.h index 9cc06d0f2..a2f6e2fa3 100644 --- a/src/widgets/multiloadingindicator.h +++ b/src/widgets/multiloadingindicator.h @@ -39,10 +39,6 @@ class MultiLoadingIndicator : public QWidget { public: explicit MultiLoadingIndicator(QWidget *parent = nullptr); - static const int kVerticalPadding; - static const int kHorizontalPadding; - static const int kSpacing; - void SetTaskManager(SharedPtr task_manager); QSize sizeHint() const override; diff --git a/src/widgets/playingwidget.cpp b/src/widgets/playingwidget.cpp index 70c2f31b9..01d966456 100644 --- a/src/widgets/playingwidget.cpp +++ b/src/widgets/playingwidget.cpp @@ -47,21 +47,25 @@ using std::make_unique; -const char *PlayingWidget::kSettingsGroup = "PlayingWidget"; +namespace { + +constexpr char kSettingsGroup[] = "PlayingWidget"; // Space between the cover and the details in small mode -const int PlayingWidget::kPadding = 2; +constexpr int kPadding = 2; // Width of the transparent to black gradient above and below the text in large mode -const int PlayingWidget::kGradientHead = 40; -const int PlayingWidget::kGradientTail = 20; +constexpr int kGradientHead = 40; +constexpr int kGradientTail = 20; // Maximum height of the cover in large mode, and offset between the bottom of the cover and bottom of the widget -const int PlayingWidget::kMaxCoverSize = 260; -const int PlayingWidget::kBottomOffset = 0; +constexpr int kMaxCoverSize = 260; +constexpr int kBottomOffset = 0; // Border for large mode -const int PlayingWidget::kTopBorder = 4; +constexpr int kTopBorder = 4; + +} // namespace PlayingWidget::PlayingWidget(QWidget *parent) : QWidget(parent), diff --git a/src/widgets/playingwidget.h b/src/widgets/playingwidget.h index 820791215..8ae27e880 100644 --- a/src/widgets/playingwidget.h +++ b/src/widgets/playingwidget.h @@ -102,14 +102,6 @@ class PlayingWidget : public QWidget { void FadePreviousTrack(const qreal value); private: - static const char *kSettingsGroup; - static const int kPadding; - static const int kGradientHead; - static const int kGradientTail; - static const int kMaxCoverSize; - static const int kBottomOffset; - static const int kTopBorder; - Application *app_; AlbumCoverChoiceController *album_cover_choice_controller_; Mode mode_; diff --git a/src/widgets/trackslider.cpp b/src/widgets/trackslider.cpp index e03ec6375..5ffc33911 100644 --- a/src/widgets/trackslider.cpp +++ b/src/widgets/trackslider.cpp @@ -41,7 +41,9 @@ # include "moodbar/moodbarproxystyle.h" #endif -const char *TrackSlider::kSettingsGroup = "MainWindow"; +namespace { +constexpr char kSettingsGroup[] = "MainWindow"; +} TrackSlider::TrackSlider(QWidget *parent) : QWidget(parent), diff --git a/src/widgets/trackslider.h b/src/widgets/trackslider.h index a435d564e..562ac913c 100644 --- a/src/widgets/trackslider.h +++ b/src/widgets/trackslider.h @@ -56,8 +56,6 @@ class TrackSlider : public QWidget { MoodbarProxyStyle *moodbar_style() const { return moodbar_style_; } #endif - static const char *kSettingsGroup; - public slots: void SetValue(const int elapsed, const int total); void SetStopped(); diff --git a/src/widgets/tracksliderpopup.cpp b/src/widgets/tracksliderpopup.cpp index 063f8225e..4b5c5141c 100644 --- a/src/widgets/tracksliderpopup.cpp +++ b/src/widgets/tracksliderpopup.cpp @@ -36,11 +36,13 @@ #include "core/qt_blurimage.h" #include "tracksliderpopup.h" -const int TrackSliderPopup::kTextMargin = 4; -const int TrackSliderPopup::kPointLength = 16; -const int TrackSliderPopup::kPointWidth = 4; -const int TrackSliderPopup::kBorderRadius = 4; -const qreal TrackSliderPopup::kBlurRadius = 20.0; +namespace { +constexpr int kTextMargin = 4; +constexpr int kPointLength = 16; +constexpr int kPointWidth = 4; +constexpr int kBorderRadius = 4; +constexpr qreal kBlurRadius = 20.0; +} // namespace TrackSliderPopup::TrackSliderPopup(QWidget *parent) : QWidget(parent), diff --git a/src/widgets/tracksliderpopup.h b/src/widgets/tracksliderpopup.h index 3cdbc6ede..e458880eb 100644 --- a/src/widgets/tracksliderpopup.h +++ b/src/widgets/tracksliderpopup.h @@ -48,12 +48,6 @@ class TrackSliderPopup : public QWidget { void paintEvent(QPaintEvent*) override; private: - static const int kTextMargin; - static const int kPointLength; - static const int kPointWidth; - static const int kBorderRadius; - static const qreal kBlurRadius; - void UpdatePixmap(); void UpdatePosition(); void SendMouseEventToParent(QMouseEvent *e);