Use anonymous namespace for constants

This commit is contained in:
Jonas Kvinge 2024-08-07 00:52:58 +02:00
parent c69777ca39
commit 819463a865
67 changed files with 186 additions and 240 deletions

View File

@ -36,12 +36,14 @@
#include "analyzerbase.h" #include "analyzerbase.h"
#include "fht.h" #include "fht.h"
const int BlockAnalyzer::kHeight = 2; namespace {
const int BlockAnalyzer::kWidth = 4; constexpr int kHeight = 2;
const int BlockAnalyzer::kMinRows = 3; // arbitrary constexpr int kWidth = 4;
const int BlockAnalyzer::kMinColumns = 32; // arbitrary constexpr int kMinRows = 3; // arbitrary
const int BlockAnalyzer::kMaxColumns = 256; // must be 2**n constexpr int kMinColumns = 32; // arbitrary
const int BlockAnalyzer::kFadeSize = 90; constexpr int kMaxColumns = 256; // must be 2**n
constexpr int kFadeSize = 90;
} // namespace
const char *BlockAnalyzer::kName = QT_TRANSLATE_NOOP("AnalyzerContainer", "Block analyzer"); const char *BlockAnalyzer::kName = QT_TRANSLATE_NOOP("AnalyzerContainer", "Block analyzer");

View File

@ -43,13 +43,6 @@ class BlockAnalyzer : public AnalyzerBase {
public: public:
Q_INVOKABLE explicit BlockAnalyzer(QWidget*); 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; static const char *kName;
protected: protected:

View File

@ -61,6 +61,10 @@
#include "settings/collectionsettingspage.h" #include "settings/collectionsettingspage.h"
#include "settings/appearancesettingspage.h" #include "settings/appearancesettingspage.h"
namespace {
constexpr int kFilterDelay = 500; // msec
}
CollectionFilterWidget::CollectionFilterWidget(QWidget *parent) CollectionFilterWidget::CollectionFilterWidget(QWidget *parent)
: QWidget(parent), : QWidget(parent),
ui_(new Ui_CollectionFilterWidget), ui_(new Ui_CollectionFilterWidget),

View File

@ -51,8 +51,6 @@ class CollectionFilterWidget : public QWidget {
explicit CollectionFilterWidget(QWidget *parent = nullptr); explicit CollectionFilterWidget(QWidget *parent = nullptr);
~CollectionFilterWidget() override; ~CollectionFilterWidget() override;
static const int kFilterDelay = 500; // msec
enum class DelayBehaviour { enum class DelayBehaviour {
AlwaysInstant, AlwaysInstant,
DelayedOnLargeLibraries, DelayedOnLargeLibraries,

View File

@ -65,7 +65,9 @@
#include "contextview.h" #include "contextview.h"
#include "contextalbum.h" #include "contextalbum.h"
const int ContextView::kWidgetSpacing = 50; namespace {
constexpr int kWidgetSpacing = 50;
}
ContextView::ContextView(QWidget *parent) ContextView::ContextView(QWidget *parent)
: QWidget(parent), : QWidget(parent),

View File

@ -101,8 +101,6 @@ class ContextView : public QWidget {
void AlbumCoverLoaded(const Song &song, const QImage &image); void AlbumCoverLoaded(const Song &song, const QImage &image);
private: private:
static const int kWidgetSpacing;
Application *app_; Application *app_;
CollectionView *collectionview_; CollectionView *collectionview_;
AlbumCoverChoiceController *album_cover_choice_controller_; AlbumCoverChoiceController *album_cover_choice_controller_;

View File

@ -46,7 +46,9 @@
#include <getopt.h> #include <getopt.h>
const char *CommandlineOptions::kHelpText = namespace {
constexpr char kHelpText[] =
"%1: strawberry [%2] [%3]\n" "%1: strawberry [%2] [%3]\n"
"\n" "\n"
"%4:\n" "%4:\n"
@ -83,7 +85,9 @@ const char *CommandlineOptions::kHelpText =
" --log-levels <levels> %33\n" " --log-levels <levels> %33\n"
" --version %34\n"; " --version %34\n";
const char *CommandlineOptions::kVersionText = "Strawberry %1"; constexpr char kVersionText[] = "Strawberry %1";
} // namespace
CommandlineOptions::CommandlineOptions(int argc, char **argv) CommandlineOptions::CommandlineOptions(int argc, char **argv)
: argc_(argc), : argc_(argc),

View File

@ -41,9 +41,6 @@ class CommandlineOptions {
public: public:
explicit CommandlineOptions(int argc = 0, char **argv = nullptr); 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 // Don't change the values or order, these get serialised and sent to
// possibly a different version of Strawberry // possibly a different version of Strawberry
enum class UrlListAction { enum class UrlListAction {

View File

@ -34,7 +34,9 @@
#include "deletefiles.h" #include "deletefiles.h"
#include "musicstorage.h" #include "musicstorage.h"
const int DeleteFiles::kBatchSize = 50; namespace {
constexpr int kBatchSize = 50;
}
DeleteFiles::DeleteFiles(SharedPtr<TaskManager> task_manager, SharedPtr<MusicStorage> storage, const bool use_trash, QObject *parent) DeleteFiles::DeleteFiles(SharedPtr<TaskManager> task_manager, SharedPtr<MusicStorage> storage, const bool use_trash, QObject *parent)
: QObject(parent), : QObject(parent),

View File

@ -41,8 +41,6 @@ class DeleteFiles : public QObject {
explicit DeleteFiles(SharedPtr<TaskManager> task_manager, SharedPtr<MusicStorage> storage, const bool use_trash, QObject *parent = nullptr); explicit DeleteFiles(SharedPtr<TaskManager> task_manager, SharedPtr<MusicStorage> storage, const bool use_trash, QObject *parent = nullptr);
~DeleteFiles() override; ~DeleteFiles() override;
static const int kBatchSize;
void Start(const SongList &songs); void Start(const SongList &songs);
void Start(const QStringList &filenames); void Start(const QStringList &filenames);

View File

@ -62,8 +62,11 @@
# include "device/cddasongloader.h" # include "device/cddasongloader.h"
#endif #endif
namespace {
constexpr int kDefaultTimeout = 5000;
}
QSet<QString> SongLoader::sRawUriSchemes; QSet<QString> SongLoader::sRawUriSchemes;
const int SongLoader::kDefaultTimeout = 5000;
SongLoader::SongLoader(SharedPtr<CollectionBackendInterface> collection_backend, const SharedPtr<Player> player, QObject *parent) SongLoader::SongLoader(SharedPtr<CollectionBackendInterface> collection_backend, const SharedPtr<Player> player, QObject *parent)
: QObject(parent), : QObject(parent),

View File

@ -68,8 +68,6 @@ class SongLoader : public QObject {
BlockingLoadRequired BlockingLoadRequired
}; };
static const int kDefaultTimeout;
const QUrl &url() const { return url_; } const QUrl &url() const { return url_; }
const SongList &songs() const { return songs_; } const SongList &songs() const { return songs_; }

View File

@ -37,8 +37,10 @@ extern HICON qt_pixmapToWinHICON(const QPixmap &p);
#include "core/logging.h" #include "core/logging.h"
#include "windows7thumbbar.h" #include "windows7thumbbar.h"
const int Windows7ThumbBar::kIconSize = 16; namespace {
const int Windows7ThumbBar::kMaxButtonCount = 7; constexpr int kIconSize = 16;
constexpr int kMaxButtonCount = 7;
} // namespace
Windows7ThumbBar::Windows7ThumbBar(QWidget *widget) Windows7ThumbBar::Windows7ThumbBar(QWidget *widget)
: QObject(widget), : QObject(widget),

View File

@ -39,9 +39,6 @@ class Windows7ThumbBar : public QObject {
// Creates a list of buttons in the taskbar icon for this window. // Creates a list of buttons in the taskbar icon for this window.
explicit Windows7ThumbBar(QWidget *widget = nullptr); 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. // 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<QAction*> &actions); void SetActions(const QList<QAction*> &actions);

View File

@ -46,6 +46,10 @@
using std::make_shared; using std::make_shared;
namespace {
constexpr int kMaxRedirects = 3;
}
AlbumCoverLoader::AlbumCoverLoader(QObject *parent) AlbumCoverLoader::AlbumCoverLoader(QObject *parent)
: QObject(parent), : QObject(parent),
network_(new NetworkAccessManager(this)), network_(new NetworkAccessManager(this)),

View File

@ -123,7 +123,6 @@ class AlbumCoverLoader : public QObject {
void LoadRemoteImageFinished(QNetworkReply *reply, AlbumCoverLoader::TaskPtr task, const AlbumCoverLoaderResult::Type result_type, const QUrl &cover_url); void LoadRemoteImageFinished(QNetworkReply *reply, AlbumCoverLoader::TaskPtr task, const AlbumCoverLoaderResult::Type result_type, const QUrl &cover_url);
private: private:
static const int kMaxRedirects = 3;
SharedPtr<NetworkAccessManager> network_; SharedPtr<NetworkAccessManager> network_;
bool stop_requested_; bool stop_requested_;
QMutex mutex_load_image_async_; QMutex mutex_load_image_async_;

View File

@ -38,7 +38,9 @@
#include "core/scopedtransaction.h" #include "core/scopedtransaction.h"
#include "devicedatabasebackend.h" #include "devicedatabasebackend.h"
const int DeviceDatabaseBackend::kDeviceSchemaVersion = 5; namespace {
constexpr int kDeviceSchemaVersion = 5;
}
DeviceDatabaseBackend::DeviceDatabaseBackend(QObject *parent) DeviceDatabaseBackend::DeviceDatabaseBackend(QObject *parent)
: QObject(parent), : QObject(parent),

View File

@ -56,8 +56,6 @@ class DeviceDatabaseBackend : public QObject {
}; };
using DeviceList = QList<Device>; using DeviceList = QList<Device>;
static const int kDeviceSchemaVersion;
void Init(SharedPtr<Database> db); void Init(SharedPtr<Database> db);
void Close(); void Close();
void ExitAsync(); void ExitAsync();

View File

@ -43,10 +43,12 @@
using u_int32_t = unsigned int; using u_int32_t = unsigned int;
#endif #endif
static const int kDecodeRate = 11025; namespace {
static const int kDecodeChannels = 1; constexpr int kDecodeRate = 11025;
static const int kPlayLengthSecs = 30; constexpr int kDecodeChannels = 1;
static const int kTimeoutSecs = 10; constexpr int kPlayLengthSecs = 30;
constexpr int kTimeoutSecs = 10;
} // namespace
Chromaprinter::Chromaprinter(const QString &filename) Chromaprinter::Chromaprinter(const QString &filename)
: filename_(filename), : filename_(filename),

View File

@ -47,10 +47,10 @@
using std::unique_ptr; using std::unique_ptr;
static const int kTimeoutSecs = 60;
namespace { namespace {
constexpr int kTimeoutSecs = 60;
struct ebur128_state_deleter { struct ebur128_state_deleter {
void operator()(ebur128_state *p) const { ebur128_destroy(&p); }; void operator()(ebur128_state *p) const { ebur128_destroy(&p); };
}; };

View File

@ -64,21 +64,24 @@ using std::make_shared;
const char *GstEngine::kAutoSink = "autoaudiosink"; const char *GstEngine::kAutoSink = "autoaudiosink";
const char *GstEngine::kALSASink = "alsasink"; const char *GstEngine::kALSASink = "alsasink";
const char *GstEngine::kOpenALSASink = "openalsink";
const char *GstEngine::kOSSSink = "osssink"; namespace {
const char *GstEngine::kOSS4Sink = "oss4sink"; constexpr char kOpenALSASink[] = "openalsink";
const char *GstEngine::kJackAudioSink = "jackaudiosink"; constexpr char kOSSSink[] = "osssink";
const char *GstEngine::kPulseSink = "pulsesink"; constexpr char kOSS4Sink[] = "oss4sink";
const char *GstEngine::kA2DPSink = "a2dpsink"; constexpr char kJackAudioSink[] = "jackaudiosink";
const char *GstEngine::kAVDTPSink = "avdtpsink"; constexpr char kPulseSink[] = "pulsesink";
const char *GstEngine::InterAudiosink = "interaudiosink"; constexpr char kA2DPSink[] = "a2dpsink";
const char *GstEngine::kDirectSoundSink = "directsoundsink"; constexpr char kAVDTPSink[] = "avdtpsink";
const char *GstEngine::kOSXAudioSink = "osxaudiosink"; constexpr char InterAudiosink[] = "interaudiosink";
const char *GstEngine::kWASAPISink = "wasapisink"; constexpr char kDirectSoundSink[] = "directsoundsink";
const int GstEngine::kDiscoveryTimeoutS = 10; constexpr char kOSXAudioSink[] = "osxaudiosink";
const qint64 GstEngine::kTimerIntervalNanosec = 1000 * kNsecPerMsec; // 1s constexpr char kWASAPISink[] = "wasapisink";
const qint64 GstEngine::kPreloadGapNanosec = 8000 * kNsecPerMsec; // 8s constexpr int kDiscoveryTimeoutS = 10;
const qint64 GstEngine::kSeekDelayNanosec = 100 * kNsecPerMsec; // 100msec constexpr qint64 kTimerIntervalNanosec = 1000 * kNsecPerMsec; // 1s
constexpr qint64 kPreloadGapNanosec = 8000 * kNsecPerMsec; // 8s
constexpr qint64 kSeekDelayNanosec = 100 * kNsecPerMsec; // 100msec
} // namespace
GstEngine::GstEngine(SharedPtr<TaskManager> task_manager, QObject *parent) GstEngine::GstEngine(SharedPtr<TaskManager> task_manager, QObject *parent)
: EngineBase(parent), : EngineBase(parent),

View File

@ -56,6 +56,7 @@ class GstEngine : public EngineBase, public GstBufferConsumer {
~GstEngine() override; ~GstEngine() override;
static const char *kAutoSink; static const char *kAutoSink;
static const char *kALSASink;
Type type() const override { return Type::GStreamer; } Type type() const override { return Type::GStreamer; }
bool Init() override; bool Init() override;
@ -142,23 +143,6 @@ class GstEngine : public EngineBase, public GstBufferConsumer {
static QString GSTdiscovererErrorMessage(GstDiscovererResult result); static QString GSTdiscovererErrorMessage(GstDiscovererResult result);
private: 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<TaskManager> task_manager_; SharedPtr<TaskManager> task_manager_;
GstStartup *gst_startup_; GstStartup *gst_startup_;
GstDiscoverer *discoverer_; GstDiscoverer *discoverer_;

View File

@ -62,11 +62,15 @@
#include "gstenginepipeline.h" #include "gstenginepipeline.h"
#include "gstbufferconsumer.h" #include "gstbufferconsumer.h"
constexpr int GstEnginePipeline::kGstStateTimeoutNanosecs = 10000000; namespace {
constexpr int GstEnginePipeline::kFaderFudgeMsec = 2000;
constexpr int GstEnginePipeline::kEqBandCount = 10; constexpr int kGstStateTimeoutNanosecs = 10000000;
constexpr int GstEnginePipeline::kEqBandFrequencies[] = { 60, 170, 310, 600, 1000, 3000, 6000, 12000, 14000, 16000 }; 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; int GstEnginePipeline::sId = 1;

View File

@ -193,11 +193,6 @@ class GstEnginePipeline : public QObject {
void FaderTimelineFinished(); void FaderTimelineFinished();
private: 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. // 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. // 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; static int sId;

View File

@ -49,9 +49,10 @@
#include "equalizerslider.h" #include "equalizerslider.h"
#include "ui_equalizer.h" #include "ui_equalizer.h"
const char *Equalizer::kGainText[] = { "60", "170", "310", "600", "1k", "3k", "6k", "12k", "14k", "16k" }; namespace {
constexpr char kSettingsGroup[] = "Equalizer";
const char *Equalizer::kSettingsGroup = "Equalizer"; const char *kGainText[] = { "60", "170", "310", "600", "1k", "3k", "6k", "12k", "14k", "16k" };
} // namespace
Equalizer::Equalizer(QWidget *parent) Equalizer::Equalizer(QWidget *parent)
: QDialog(parent), : QDialog(parent),

View File

@ -44,9 +44,7 @@ class Equalizer : public QDialog {
explicit Equalizer(QWidget *parent = nullptr); explicit Equalizer(QWidget *parent = nullptr);
~Equalizer() override; ~Equalizer() override;
static const int kBands = 10; static constexpr int kBands = 10;
static const char *kGainText[kBands];
static const char *kSettingsGroup;
struct Params { struct Params {
Params(); Params();

View File

@ -35,7 +35,9 @@
using namespace std::chrono_literals; using namespace std::chrono_literals;
const int LyricsFetcher::kMaxConcurrentRequests = 5; namespace {
constexpr int kMaxConcurrentRequests = 5;
}
LyricsFetcher::LyricsFetcher(SharedPtr<LyricsProviders> lyrics_providers, QObject *parent) LyricsFetcher::LyricsFetcher(SharedPtr<LyricsProviders> lyrics_providers, QObject *parent)
: QObject(parent), : QObject(parent),

View File

@ -69,8 +69,6 @@ class LyricsFetcher : public QObject {
void StartRequests(); void StartRequests();
private: private:
static const int kMaxConcurrentRequests;
SharedPtr<LyricsProviders> lyrics_providers_; SharedPtr<LyricsProviders> lyrics_providers_;
quint64 next_id_; quint64 next_id_;

View File

@ -34,9 +34,11 @@
#include "lyricsprovider.h" #include "lyricsprovider.h"
#include "lyricsproviders.h" #include "lyricsproviders.h"
const int LyricsFetcherSearch::kSearchTimeoutMs = 3000; namespace {
const int LyricsFetcherSearch::kGoodLyricsLength = 60; constexpr int kSearchTimeoutMs = 3000;
const float LyricsFetcherSearch::kHighScore = 2.5; constexpr int kGoodLyricsLength = 60;
constexpr float kHighScore = 2.5;
} // namespace
LyricsFetcherSearch::LyricsFetcherSearch(const quint64 id, const LyricsSearchRequest &request, QObject *parent) LyricsFetcherSearch::LyricsFetcherSearch(const quint64 id, const LyricsSearchRequest &request, QObject *parent)
: QObject(parent), : QObject(parent),

View File

@ -57,10 +57,6 @@ class LyricsFetcherSearch : public QObject {
static bool LyricsSearchResultCompareScore(const LyricsSearchResult &a, const LyricsSearchResult &b); static bool LyricsSearchResultCompareScore(const LyricsSearchResult &a, const LyricsSearchResult &b);
private: private:
static const int kSearchTimeoutMs;
static const int kGoodLyricsLength;
static const float kHighScore;
quint64 id_; quint64 id_;
LyricsSearchRequest request_; LyricsSearchRequest request_;
LyricsSearchResults results_; LyricsSearchResults results_;

View File

@ -41,7 +41,9 @@
using std::make_unique; using std::make_unique;
const int MoodbarPipeline::kBands = 128; namespace {
constexpr int kBands = 128;
}
MoodbarPipeline::MoodbarPipeline(const QUrl &url, QObject *parent) MoodbarPipeline::MoodbarPipeline(const QUrl &url, QObject *parent)
: QObject(parent), : QObject(parent),

View File

@ -63,8 +63,6 @@ class MoodbarPipeline : public QObject {
static GstBusSyncReply BusCallbackSync(GstBus*, GstMessage *msg, gpointer data); static GstBusSyncReply BusCallbackSync(GstBus*, GstMessage *msg, gpointer data);
private: private:
static const int kBands;
QUrl url_; QUrl url_;
GstElement *pipeline_; GstElement *pipeline_;
GstElement *convert_element_; GstElement *convert_element_;

View File

@ -51,10 +51,10 @@ using namespace std::chrono_literals;
class OrganizeFormat; class OrganizeFormat;
const int Organize::kBatchSize = 10; namespace {
#ifdef HAVE_GSTREAMER constexpr int kBatchSize = 10;
const int Organize::kTranscodeProgressInterval = 500; constexpr int kTranscodeProgressInterval = 500;
#endif } // namespace
Organize::Organize(SharedPtr<TaskManager> task_manager, SharedPtr<MusicStorage> 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) Organize::Organize(SharedPtr<TaskManager> task_manager, SharedPtr<MusicStorage> 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), : QObject(parent),

View File

@ -66,11 +66,6 @@ class Organize : public QObject {
explicit Organize(SharedPtr<TaskManager> task_manager, SharedPtr<MusicStorage> 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); explicit Organize(SharedPtr<TaskManager> task_manager, SharedPtr<MusicStorage> 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; ~Organize() override;
static const int kBatchSize;
#ifdef HAVE_GSTREAMER
static const int kTranscodeProgressInterval;
#endif
void Start(); void Start();
signals: signals:

View File

@ -55,7 +55,9 @@
using std::make_shared; using std::make_shared;
const int PlaylistBackend::kSongTableJoins = 2; namespace {
constexpr int kSongTableJoins = 2;
}
PlaylistBackend::PlaylistBackend(Application *app, QObject *parent) PlaylistBackend::PlaylistBackend(Application *app, QObject *parent)
: QObject(parent), : QObject(parent),

View File

@ -64,8 +64,6 @@ class PlaylistBackend : public QObject {
}; };
using PlaylistList = QList<Playlist>; using PlaylistList = QList<Playlist>;
static const int kSongTableJoins;
void Close(); void Close();
void ExitAsync(); void ExitAsync();

View File

@ -61,9 +61,11 @@
#include "widgets/qsearchfield.h" #include "widgets/qsearchfield.h"
#include "settings/appearancesettingspage.h" #include "settings/appearancesettingspage.h"
const char *PlaylistContainer::kSettingsGroup = "Playlist"; namespace {
const int PlaylistContainer::kFilterDelayMs = 100; constexpr char kSettingsGroup[] = "Playlist";
const int PlaylistContainer::kFilterDelayPlaylistSizeThreshold = 5000; constexpr int kFilterDelayMs = 100;
constexpr int kFilterDelayPlaylistSizeThreshold = 5000;
} // namespace
PlaylistContainer::PlaylistContainer(QWidget *parent) PlaylistContainer::PlaylistContainer(QWidget *parent)
: QWidget(parent), : QWidget(parent),

View File

@ -54,8 +54,6 @@ class PlaylistContainer : public QWidget {
explicit PlaylistContainer(QWidget *parent = nullptr); explicit PlaylistContainer(QWidget *parent = nullptr);
~PlaylistContainer() override; ~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 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<PlaylistManager> manager); void SetManager(SharedPtr<PlaylistManager> manager);
void ReloadSettings(); void ReloadSettings();
@ -113,9 +111,6 @@ class PlaylistContainer : public QWidget {
void RepositionNoMatchesLabel(bool force = false); void RepositionNoMatchesLabel(bool force = false);
private: private:
static const int kFilterDelayMs;
static const int kFilterDelayPlaylistSizeThreshold;
Ui_PlaylistContainer *ui_; Ui_PlaylistContainer *ui_;
SharedPtr<PlaylistManager> manager_; SharedPtr<PlaylistManager> manager_;

View File

@ -71,13 +71,15 @@
#include "playlist/playlist.h" #include "playlist/playlist.h"
#include "playlistdelegates.h" #include "playlistdelegates.h"
const int QueuedItemDelegate::kQueueBoxBorder = 1; namespace {
const int QueuedItemDelegate::kQueueBoxCornerRadius = 3; constexpr int kQueueBoxBorder = 1;
const int QueuedItemDelegate::kQueueBoxLength = 30; constexpr int kQueueBoxCornerRadius = 3;
const QRgb QueuedItemDelegate::kQueueBoxGradientColor1 = qRgb(102, 150, 227); constexpr int kQueueBoxLength = 30;
const QRgb QueuedItemDelegate::kQueueBoxGradientColor2 = qRgb(77, 121, 200); constexpr QRgb kQueueBoxGradientColor1 = qRgb(102, 150, 227);
const int QueuedItemDelegate::kQueueOpacitySteps = 10; constexpr QRgb kQueueBoxGradientColor2 = qRgb(77, 121, 200);
const float QueuedItemDelegate::kQueueOpacityLowerBound = 0.4F; constexpr int kQueueOpacitySteps = 10;
constexpr float kQueueOpacityLowerBound = 0.4F;
} // namespace
const int PlaylistDelegateBase::kMinHeight = 19; const int PlaylistDelegateBase::kMinHeight = 19;

View File

@ -66,14 +66,6 @@ class QueuedItemDelegate : public QStyledItemDelegate {
int queue_indicator_size(const QModelIndex &idx) const; int queue_indicator_size(const QModelIndex &idx) const;
private: 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_; int indicator_column_;
}; };

View File

@ -33,6 +33,10 @@
#include "playlistlistview.h" #include "playlistlistview.h"
#include "playlist.h" #include "playlist.h"
namespace {
constexpr int kDragHoverTimeout = 500;
}
PlaylistListView::PlaylistListView(QWidget *parent) : AutoExpandingTreeView(parent) {} PlaylistListView::PlaylistListView(QWidget *parent) : AutoExpandingTreeView(parent) {}
void PlaylistListView::paintEvent(QPaintEvent *event) { void PlaylistListView::paintEvent(QPaintEvent *event) {

View File

@ -62,8 +62,6 @@ class PlaylistListView : public AutoExpandingTreeView {
void timerEvent(QTimerEvent *e) override; void timerEvent(QTimerEvent *e) override;
private: private:
static const int kDragHoverTimeout = 500;
QBasicTimer drag_hover_timer_; QBasicTimer drag_hover_timer_;
}; };

View File

@ -54,7 +54,10 @@
#include "playlistmanager.h" #include "playlistmanager.h"
#include "playlisttabbar.h" #include "playlisttabbar.h"
const char *PlaylistTabBar::kSettingsGroup = "PlaylistTabBar"; namespace {
constexpr char kSettingsGroup[] = "PlaylistTabBar";
constexpr int kDragHoverTimeout = 500;
} // namespace
PlaylistTabBar::PlaylistTabBar(QWidget *parent) PlaylistTabBar::PlaylistTabBar(QWidget *parent)
: QTabBar(parent), : QTabBar(parent),

View File

@ -54,9 +54,6 @@ class PlaylistTabBar : public QTabBar {
public: public:
explicit PlaylistTabBar(QWidget *parent = nullptr); explicit PlaylistTabBar(QWidget *parent = nullptr);
static const int kDragHoverTimeout = 500;
static const char *kSettingsGroup;
void SetActions(QAction *new_playlist, QAction *load_playlist); void SetActions(QAction *new_playlist, QAction *load_playlist);
void SetManager(SharedPtr<PlaylistManager> manager); void SetManager(SharedPtr<PlaylistManager> manager);

View File

@ -81,10 +81,12 @@
# include "moodbar/moodbaritemdelegate.h" # include "moodbar/moodbaritemdelegate.h"
#endif #endif
const int PlaylistView::kGlowIntensitySteps = 24; namespace {
const int PlaylistView::kAutoscrollGraceTimeout = 30; // seconds constexpr int kGlowIntensitySteps = 24;
const int PlaylistView::kDropIndicatorWidth = 2; constexpr int kAutoscrollGraceTimeout = 30; // seconds
const int PlaylistView::kDropIndicatorGradientWidth = 5; constexpr int kDropIndicatorWidth = 2;
constexpr int kDropIndicatorGradientWidth = 5;
} // namespace
PlaylistView::PlaylistView(QWidget *parent) PlaylistView::PlaylistView(QWidget *parent)
: QTreeView(parent), : QTreeView(parent),

View File

@ -186,11 +186,6 @@ class PlaylistView : public QTreeView {
void GlowIntensityChanged(); void GlowIntensityChanged();
private: private:
static const int kGlowIntensitySteps;
static const int kAutoscrollGraceTimeout;
static const int kDropIndicatorWidth;
static const int kDropIndicatorGradientWidth;
QList<int> GetEditableColumns(); QList<int> GetEditableColumns();
QModelIndex NextEditableIndex(const QModelIndex &current); QModelIndex NextEditableIndex(const QModelIndex &current);
QModelIndex PrevEditableIndex(const QModelIndex &current); QModelIndex PrevEditableIndex(const QModelIndex &current);

View File

@ -72,7 +72,7 @@ class QobuzService : public StreamingService {
int Search(const QString &text, StreamingSearchView::SearchType type) override; int Search(const QString &text, StreamingSearchView::SearchType type) override;
void CancelSearch() override; void CancelSearch() override;
int max_login_attempts() { return kLoginAttempts; } int max_login_attempts() const { return kLoginAttempts; }
Application *app() const { return app_; } Application *app() const { return app_; }
QString app_id() const { return app_id_; } QString app_id() const { return app_id_; }

View File

@ -39,7 +39,9 @@
#include "radiomimedata.h" #include "radiomimedata.h"
#include "radiochannel.h" #include "radiochannel.h"
const int RadioModel::kTreeIconSize = 22; namespace {
constexpr int kTreeIconSize = 22;
}
RadioModel::RadioModel(Application *app, QObject *parent) RadioModel::RadioModel(Application *app, QObject *parent)
: SimpleTreeModel<RadioItem>(new RadioItem(this), parent), : SimpleTreeModel<RadioItem>(new RadioItem(this), parent),

View File

@ -86,7 +86,6 @@ class RadioModel : public SimpleTreeModel<RadioItem> {
void AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderResult &result); void AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderResult &result);
private: private:
static const int kTreeIconSize;
using ItemAndCacheKey = QPair<RadioItem*, QString>; using ItemAndCacheKey = QPair<RadioItem*, QString>;
Application *app_; Application *app_;

View File

@ -86,9 +86,11 @@
using std::make_unique; using std::make_unique;
const int StreamingSearchView::kSwapModelsTimeoutMsec = 250; namespace {
const int StreamingSearchView::kDelayedSearchTimeoutMs = 200; constexpr int kSwapModelsTimeoutMsec = 250;
const int StreamingSearchView::kArtHeight = 32; constexpr int kDelayedSearchTimeoutMs = 200;
constexpr int kArtHeight = 32;
} // namespace
StreamingSearchView::StreamingSearchView(QWidget *parent) StreamingSearchView::StreamingSearchView(QWidget *parent)
: QWidget(parent), : QWidget(parent),

View File

@ -176,11 +176,6 @@ class StreamingSearchView : public QWidget {
public slots: public slots:
void ReloadSettings(); void ReloadSettings();
private:
static const int kSwapModelsTimeoutMsec;
static const int kDelayedSearchTimeoutMs;
static const int kArtHeight;
private: private:
Application *app_; Application *app_;
SharedPtr<StreamingService> service_; SharedPtr<StreamingService> service_;

View File

@ -29,7 +29,9 @@
#include "autoexpandingtreeview.h" #include "autoexpandingtreeview.h"
#include "core/mimedata.h" #include "core/mimedata.h"
const int AutoExpandingTreeView::kRowsToShow = 50; namespace {
constexpr int kRowsToShow = 50;
}
AutoExpandingTreeView::AutoExpandingTreeView(QWidget *parent) AutoExpandingTreeView::AutoExpandingTreeView(QWidget *parent)
: QTreeView(parent), : QTreeView(parent),

View File

@ -39,8 +39,6 @@ class AutoExpandingTreeView : public QTreeView {
public: public:
explicit AutoExpandingTreeView(QWidget *parent = nullptr); explicit AutoExpandingTreeView(QWidget *parent = nullptr);
static const int kRowsToShow;
void SetAutoOpen(bool v) { auto_open_ = v; } void SetAutoOpen(bool v) { auto_open_ = v; }
void SetExpandOnReset(bool v) { expand_on_reset_ = v; } void SetExpandOnReset(bool v) { expand_on_reset_ = v; }
void SetAddOnDoubleClick(bool v) { add_on_double_click_ = v; } void SetAddOnDoubleClick(bool v) { add_on_double_click_ = v; }

View File

@ -30,7 +30,9 @@
#include "favoritewidget.h" #include "favoritewidget.h"
const int FavoriteWidget::kStarSize = 15; namespace {
constexpr int kStarSize = 15;
}
FavoriteWidget::FavoriteWidget(const int tab_index, const bool favorite, QWidget *parent) FavoriteWidget::FavoriteWidget(const int tab_index, const bool favorite, QWidget *parent)
: QWidget(parent), : QWidget(parent),

View File

@ -51,8 +51,6 @@ class FavoriteWidget : public QWidget {
void mouseDoubleClickEvent(QMouseEvent*) override; void mouseDoubleClickEvent(QMouseEvent*) override;
private: private:
static const int kStarSize;
// The playlist's id this widget belongs to // The playlist's id this widget belongs to
int tab_index_; int tab_index_;
bool favorite_; bool favorite_;

View File

@ -44,20 +44,23 @@
class QPaintEvent; class QPaintEvent;
const int FreeSpaceBar::kBarHeight = 20; namespace {
const int FreeSpaceBar::kBarBorderRadius = 8; constexpr int kBarHeight = 20;
const int FreeSpaceBar::kMarkerSpacing = 32; constexpr int kBarBorderRadius = 8;
const int FreeSpaceBar::kLabelBoxSize = 12; constexpr int kMarkerSpacing = 32;
const int FreeSpaceBar::kLabelBoxPadding = 4; constexpr int kLabelBoxSize = 12;
const int FreeSpaceBar::kLabelSpacing = 16; constexpr int kLabelBoxPadding = 4;
constexpr int kLabelSpacing = 16;
const QRgb FreeSpaceBar::kColorBg1 = qRgb(214, 207, 200); constexpr QRgb kColorBg1 = qRgb(214, 207, 200);
const QRgb FreeSpaceBar::kColorBg2 = qRgb(234, 226, 218); constexpr QRgb kColorBg2 = qRgb(234, 226, 218);
const QRgb FreeSpaceBar::kColorAdd1 = qRgb(136, 180, 229); constexpr QRgb kColorAdd1 = qRgb(136, 180, 229);
const QRgb FreeSpaceBar::kColorAdd2 = qRgb(72, 146, 229); constexpr QRgb kColorAdd2 = qRgb(72, 146, 229);
const QRgb FreeSpaceBar::kColorBar1 = qRgb(250, 148, 76); constexpr QRgb kColorBar1 = qRgb(250, 148, 76);
const QRgb FreeSpaceBar::kColorBar2 = qRgb(214, 102, 24); constexpr QRgb kColorBar2 = qRgb(214, 102, 24);
const QRgb FreeSpaceBar::kColorBorder = qRgb(174, 168, 162); constexpr QRgb kColorBorder = qRgb(174, 168, 162);
} // namespace
FreeSpaceBar::FreeSpaceBar(QWidget *parent) FreeSpaceBar::FreeSpaceBar(QWidget *parent)
: QWidget(parent), : QWidget(parent),

View File

@ -39,21 +39,6 @@ class FreeSpaceBar : public QWidget {
public: public:
explicit FreeSpaceBar(QWidget *parent = nullptr); 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_free_bytes(const quint64 bytes) { free_ = bytes; update(); }
void set_additional_bytes(const quint64 bytes) { additional_ = bytes; update(); } void set_additional_bytes(const quint64 bytes) { additional_ = bytes; update(); }
void set_total_bytes(const quint64 bytes) { total_ = bytes; update(); } void set_total_bytes(const quint64 bytes) { total_ = bytes; update(); }

View File

@ -47,8 +47,10 @@
#include "core/multisortfilterproxy.h" #include "core/multisortfilterproxy.h"
#include "groupediconview.h" #include "groupediconview.h"
const int GroupedIconView::kBarThickness = 2; namespace {
const int GroupedIconView::kBarMarginTop = 3; constexpr int kBarThickness = 2;
constexpr int kBarMarginTop = 3;
} // namespace
GroupedIconView::GroupedIconView(QWidget *parent) GroupedIconView::GroupedIconView(QWidget *parent)
: QListView(parent), : QListView(parent),

View File

@ -100,9 +100,6 @@ class GroupedIconView : public QListView {
void LayoutItems(); void LayoutItems();
private: private:
static const int kBarThickness;
static const int kBarMarginTop;
struct Header { struct Header {
int y; int y;
int first_row; int first_row;

View File

@ -34,9 +34,11 @@
#include "multiloadingindicator.h" #include "multiloadingindicator.h"
#include "widgets/busyindicator.h" #include "widgets/busyindicator.h"
const int MultiLoadingIndicator::kVerticalPadding = 4; namespace {
const int MultiLoadingIndicator::kHorizontalPadding = 6; constexpr int kVerticalPadding = 4;
const int MultiLoadingIndicator::kSpacing = 6; constexpr int kHorizontalPadding = 6;
constexpr int kSpacing = 6;
}
MultiLoadingIndicator::MultiLoadingIndicator(QWidget *parent) MultiLoadingIndicator::MultiLoadingIndicator(QWidget *parent)
: QWidget(parent), : QWidget(parent),

View File

@ -39,10 +39,6 @@ class MultiLoadingIndicator : public QWidget {
public: public:
explicit MultiLoadingIndicator(QWidget *parent = nullptr); explicit MultiLoadingIndicator(QWidget *parent = nullptr);
static const int kVerticalPadding;
static const int kHorizontalPadding;
static const int kSpacing;
void SetTaskManager(SharedPtr<TaskManager> task_manager); void SetTaskManager(SharedPtr<TaskManager> task_manager);
QSize sizeHint() const override; QSize sizeHint() const override;

View File

@ -47,21 +47,25 @@
using std::make_unique; using std::make_unique;
const char *PlayingWidget::kSettingsGroup = "PlayingWidget"; namespace {
constexpr char kSettingsGroup[] = "PlayingWidget";
// Space between the cover and the details in small mode // 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 // Width of the transparent to black gradient above and below the text in large mode
const int PlayingWidget::kGradientHead = 40; constexpr int kGradientHead = 40;
const int PlayingWidget::kGradientTail = 20; 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 // 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; constexpr int kMaxCoverSize = 260;
const int PlayingWidget::kBottomOffset = 0; constexpr int kBottomOffset = 0;
// Border for large mode // Border for large mode
const int PlayingWidget::kTopBorder = 4; constexpr int kTopBorder = 4;
} // namespace
PlayingWidget::PlayingWidget(QWidget *parent) PlayingWidget::PlayingWidget(QWidget *parent)
: QWidget(parent), : QWidget(parent),

View File

@ -102,14 +102,6 @@ class PlayingWidget : public QWidget {
void FadePreviousTrack(const qreal value); void FadePreviousTrack(const qreal value);
private: 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_; Application *app_;
AlbumCoverChoiceController *album_cover_choice_controller_; AlbumCoverChoiceController *album_cover_choice_controller_;
Mode mode_; Mode mode_;

View File

@ -41,7 +41,9 @@
# include "moodbar/moodbarproxystyle.h" # include "moodbar/moodbarproxystyle.h"
#endif #endif
const char *TrackSlider::kSettingsGroup = "MainWindow"; namespace {
constexpr char kSettingsGroup[] = "MainWindow";
}
TrackSlider::TrackSlider(QWidget *parent) TrackSlider::TrackSlider(QWidget *parent)
: QWidget(parent), : QWidget(parent),

View File

@ -56,8 +56,6 @@ class TrackSlider : public QWidget {
MoodbarProxyStyle *moodbar_style() const { return moodbar_style_; } MoodbarProxyStyle *moodbar_style() const { return moodbar_style_; }
#endif #endif
static const char *kSettingsGroup;
public slots: public slots:
void SetValue(const int elapsed, const int total); void SetValue(const int elapsed, const int total);
void SetStopped(); void SetStopped();

View File

@ -36,11 +36,13 @@
#include "core/qt_blurimage.h" #include "core/qt_blurimage.h"
#include "tracksliderpopup.h" #include "tracksliderpopup.h"
const int TrackSliderPopup::kTextMargin = 4; namespace {
const int TrackSliderPopup::kPointLength = 16; constexpr int kTextMargin = 4;
const int TrackSliderPopup::kPointWidth = 4; constexpr int kPointLength = 16;
const int TrackSliderPopup::kBorderRadius = 4; constexpr int kPointWidth = 4;
const qreal TrackSliderPopup::kBlurRadius = 20.0; constexpr int kBorderRadius = 4;
constexpr qreal kBlurRadius = 20.0;
} // namespace
TrackSliderPopup::TrackSliderPopup(QWidget *parent) TrackSliderPopup::TrackSliderPopup(QWidget *parent)
: QWidget(parent), : QWidget(parent),

View File

@ -48,12 +48,6 @@ class TrackSliderPopup : public QWidget {
void paintEvent(QPaintEvent*) override; void paintEvent(QPaintEvent*) override;
private: private:
static const int kTextMargin;
static const int kPointLength;
static const int kPointWidth;
static const int kBorderRadius;
static const qreal kBlurRadius;
void UpdatePixmap(); void UpdatePixmap();
void UpdatePosition(); void UpdatePosition();
void SendMouseEventToParent(QMouseEvent *e); void SendMouseEventToParent(QMouseEvent *e);