Finished first pass of custom layout warning cleanup.

This commit is contained in:
casey langen 2021-01-30 14:15:14 -08:00
parent d35d8d31f7
commit b32130e9a3
27 changed files with 244 additions and 231 deletions

View File

@ -72,7 +72,7 @@ static int kMinListTitleHeight = 26;
#define DEFAULT_CATEGORY constants::Track::ARTIST
#define DEFAULT_CATEGORY_NAME FIELD_TO_TITLE[DEFAULT_CATEGORY]
static std::set<std::string> EDIT_KEYS;
static std::set<std::string> kEditKeys;
static std::map <std::string, std::string> FIELD_TO_TITLE {
std::make_pair(constants::Track::ARTIST, "browse_title_artists"),
@ -110,7 +110,7 @@ BrowseLayout::BrowseLayout(
: LayoutBase()
, playlistModified(false)
, playback(playback) {
EDIT_KEYS = {
kEditKeys = {
Hotkeys::Get(Hotkeys::PlayQueueMoveUp),
Hotkeys::Get(Hotkeys::PlayQueueMoveDown),
Hotkeys::Get(Hotkeys::PlayQueueDelete)
@ -390,7 +390,7 @@ bool BrowseLayout::ProcessPlaylistOperation(const std::string& key) {
}
bool BrowseLayout::ProcessEditOperation(const std::string& key) {
if (this->GetFocus() != this->trackList || EDIT_KEYS.find(key) == EDIT_KEYS.end()) {
if (this->GetFocus() != this->trackList || kEditKeys.find(key) == kEditKeys.end()) {
return false;
}
@ -399,7 +399,7 @@ bool BrowseLayout::ProcessEditOperation(const std::string& key) {
}
std::shared_ptr<TrackList> tracks = this->trackList->GetTrackList();
if (tracks && EDIT_KEYS.find(key) != EDIT_KEYS.end()) {
if (tracks && kEditKeys.find(key) != kEditKeys.end()) {
const size_t selected = this->trackList->GetSelectedTrackIndex();
size_t to = -1;
bool modified = this->playlistModified;

View File

@ -53,7 +53,7 @@ using Entry = IScrollAdapter::EntryPtr;
using Callback = std::function<void()>;
static std::string formattedTime() {
char buffer[128];
char buffer[128] = { 0 };
time_t rawtime;
struct tm* timeinfo;
time(&rawtime);
@ -63,7 +63,7 @@ static std::string formattedTime() {
}
static void confirmResetHotkeys(Callback cb) {
std::shared_ptr<DialogOverlay> dialog(new DialogOverlay());
auto dialog = std::make_shared<DialogOverlay>();
(*dialog)
.SetTitle(_TSTR("hotkeys_reset_all_title"))
@ -89,7 +89,7 @@ static void checkConflictAndSave(Hotkeys::Id id, const std::string& key, Callbac
}
if (existing.size()) {
std::shared_ptr<DialogOverlay> dialog(new DialogOverlay());
auto dialog = std::make_shared<DialogOverlay>();
std::string message = _TSTR("hotkeys_conflict_message");
ReplaceAll(message, "{{hotkey}}", key);
@ -122,7 +122,7 @@ static void backupAndShowDialog() {
std::string out = dir + "hotkeys-" + formattedTime() + ".json";
if (CopyFile(in, out)) {
std::shared_ptr<DialogOverlay> dialog(new DialogOverlay());
auto dialog = std::make_shared<DialogOverlay>();
std::string message = _TSTR("hotkeys_backup_success_message");
ReplaceAll(message, "{{path}}", out);
@ -135,7 +135,7 @@ static void backupAndShowDialog() {
App::Overlays().Push(dialog);
}
else {
std::shared_ptr<DialogOverlay> dialog(new DialogOverlay());
auto dialog = std::make_shared<DialogOverlay>();
std::string message = _TSTR("hotkeys_backup_failure_message");
ReplaceAll(message, "{{path}}", dir);
@ -150,7 +150,7 @@ static void backupAndShowDialog() {
}
static void showDeleteOverlay(Hotkeys::Id id, Callback cb) {
std::shared_ptr<DialogOverlay> dialog(new DialogOverlay());
auto dialog = std::make_shared<DialogOverlay>();
std::string message = _TSTR("hotkeys_delete_binding_message");
ReplaceAll(message, "{{key}}", Hotkeys::Name(id));
@ -191,12 +191,9 @@ HotkeysLayout::HotkeysLayout() {
this->listWindow->SetFocusOrder(0);
}
HotkeysLayout::~HotkeysLayout() {
}
void HotkeysLayout::OnEntryActivated(cursespp::ListWindow* list, size_t index) {
Hotkeys::Id id = static_cast<Hotkeys::Id>(index);
auto shortcuts = this->shortcuts;
const Hotkeys::Id id = static_cast<Hotkeys::Id>(index);
const auto shortcuts = this->shortcuts;
ReassignHotkeyOverlay::Show(id, [this, list, id](std::string key) {
checkConflictAndSave(id, key, [this, list]() {
@ -237,13 +234,13 @@ void HotkeysLayout::SetShortcutsWindow(ShortcutsWindow* shortcuts) {
}
bool HotkeysLayout::KeyPress(const std::string& kn) {
auto refresh = [this]() {
const auto refresh = [this]() {
this->listWindow->OnAdapterChanged();
this->SetShortcutsWindow(this->shortcuts);
};
if (kn == "KEY_DC") {
auto index = this->listWindow->GetSelectedIndex();
const auto index = this->listWindow->GetSelectedIndex();
if (index != ListWindow::NO_SELECTION) {
showDeleteOverlay(static_cast<Hotkeys::Id>(index), refresh);
return true;

View File

@ -48,9 +48,9 @@ namespace musik {
public sigslot::has_slots<>
{
public:
HotkeysLayout();
DELETE_COPY_AND_ASSIGNMENT_DEFAULTS(HotkeysLayout)
~HotkeysLayout();
HotkeysLayout();
/* ITopLevelLayout */
void SetShortcutsWindow(

View File

@ -53,20 +53,26 @@
#include "LibraryLayout.h"
using namespace musik;
using namespace musik::core;
using namespace musik::core::audio;
using namespace musik::core::library;
using namespace musik::core::library::constants;
using namespace musik::cube;
using namespace musik::core::runtime;
using namespace cursespp;
namespace keys = musik::cube::prefs::keys;
namespace components = musik::core::prefs::components;
#define SHOULD_REFOCUS(target) \
(this->visibleLayout == target) && \
(this->shortcuts && !this->shortcuts->IsFocused())
using namespace musik;
using namespace musik::core;
using namespace musik::core::audio;
using namespace musik::core::library;
using namespace musik::cube;
using namespace musik::core::runtime;
using namespace cursespp;
#define REMEMBER(key, value) { \
auto prefs = Preferences::ForComponent(components::Session); \
prefs->SetString(key, value.c_str()); this->prefs->Save(); \
}
namespace type {
const std::string CategoryFilter = "CategoryFilter";
@ -76,14 +82,6 @@ namespace type {
const std::string NowPlaying = "NowPlaying";
};
namespace keys = musik::cube::prefs::keys;
namespace components = musik::core::prefs::components;
#define REMEMBER(key, value) { \
auto prefs = Preferences::ForComponent(components::Session); \
prefs->SetString(key, value.c_str()); this->prefs->Save(); \
}
LibraryLayout::LibraryLayout(musik::core::audio::PlaybackService& playback, ILibraryPtr library)
: LayoutBase()
, playback(playback)
@ -94,19 +92,16 @@ LibraryLayout::LibraryLayout(musik::core::audio::PlaybackService& playback, ILib
this->InitializeWindows();
}
LibraryLayout::~LibraryLayout() {
}
void LibraryLayout::OnLayout() {
bool autoHideCommandBar = this->prefs->GetBool(keys::AutoHideCommandBar, false);
int x = 0, y = 0;
int cx = this->GetWidth(), cy = this->GetHeight();
const bool autoHideCommandBar = this->prefs->GetBool(keys::AutoHideCommandBar, false);
const int x = 0, y = 0;
const int cx = this->GetWidth(), cy = this->GetHeight();
#ifdef WIN32
int transportCy = 3;
const int transportCy = 3;
#else
int transportCy = (autoHideCommandBar ? 2 : 3);
const int transportCy = (autoHideCommandBar ? 2 : 3);
#endif
int mainHeight = cy - transportCy;
const int mainHeight = cy - transportCy;
this->transportView->MoveAndResize(1, mainHeight, cx - 2, transportCy);
if (this->visibleLayout) {
this->visibleLayout->MoveAndResize(x, y, cx, mainHeight);
@ -200,13 +195,13 @@ void LibraryLayout::ShowDirectories(const std::string& directory) {
}
void LibraryLayout::InitializeWindows() {
this->browseLayout.reset(new BrowseLayout(this->playback, this->library));
this->directoryLayout.reset(new DirectoryLayout(this->playback, this->library));
this->nowPlayingLayout.reset(new NowPlayingLayout(this->playback, this->library));
this->categorySearchLayout.reset(new CategorySearchLayout(this->playback, this->library));
this->browseLayout = std::make_shared<BrowseLayout>(this->playback, this->library);
this->directoryLayout = std::make_shared<DirectoryLayout>(this->playback, this->library);
this->nowPlayingLayout = std::make_shared<NowPlayingLayout>(this->playback, this->library);
this->categorySearchLayout = std::make_shared<CategorySearchLayout>(this->playback, this->library);
this->categorySearchLayout->SearchResultSelected.connect(this, &LibraryLayout::OnCategorySearchResultSelected);
this->trackSearchLayout.reset(new TrackSearchLayout(this->playback, this->library));
this->transportView.reset(new TransportWindow(this->library, this->playback));
this->trackSearchLayout = std::make_shared<TrackSearchLayout>(this->playback, this->library);
this->transportView = std::make_shared<TransportWindow>(this->library, this->playback);
this->AddWindow(this->transportView);
this->LoadLastSession();
@ -376,30 +371,33 @@ bool LibraryLayout::SetFocus(cursespp::IWindowPtr window) {
void LibraryLayout::ProcessMessage(musik::core::runtime::IMessage &message) {
switch (message.Type()) {
case message::JumpToCategory: {
static std::map<int, const char*> JUMP_TYPE_TO_COLUMN = {
{ cube::message::category::Album, constants::Track::ALBUM },
{ cube::message::category::Artist, constants::Track::ARTIST },
{ cube::message::category::AlbumArtist, constants::Track::ALBUM_ARTIST },
{ cube::message::category::Genre, constants::Track::GENRE }
};
static std::map<int, const char*> JUMP_TYPE_TO_COLUMN = {
{ cube::message::category::Album, constants::Track::ALBUM },
{ cube::message::category::Artist, constants::Track::ARTIST },
{ cube::message::category::AlbumArtist, constants::Track::ALBUM_ARTIST },
{ cube::message::category::Genre, constants::Track::GENRE }
};
auto type = JUMP_TYPE_TO_COLUMN[(int)message.UserData1()];
auto id = message.UserData2();
this->OnCategorySearchResultSelected(nullptr, type, id);
}
break;
auto type = JUMP_TYPE_TO_COLUMN[(int)message.UserData1()];
const auto id = message.UserData2();
this->OnCategorySearchResultSelected(nullptr, type, id);
}
break;
case core::message::PlaylistModified:
case core::message::PlaylistCreated:
case core::message::PlaylistRenamed:
case core::message::PlaylistDeleted: {
MessageQueue().Post(Message::Create(
this->browseLayout.get(),
message.Type(),
message.UserData1(),
message.UserData2()));
}
break;
MessageQueue().Post(Message::Create(
this->browseLayout.get(),
message.Type(),
message.UserData1(),
message.UserData2()));
}
break;
default:
break;
}
LayoutBase::ProcessMessage(message);

View File

@ -57,12 +57,12 @@ namespace musik {
public sigslot::has_slots<>
{
public:
DELETE_CLASS_DEFAULTS(LibraryLayout)
LibraryLayout(
musik::core::audio::PlaybackService& playback,
musik::core::ILibraryPtr library);
virtual ~LibraryLayout();
cursespp::IWindowPtr FocusNext() override;
cursespp::IWindowPtr FocusPrev() override;
cursespp::IWindowPtr GetFocus() override;

View File

@ -62,8 +62,8 @@ static inline std::string resolveErrorMessage(MasterLibraryPtr library) {
auto remoteLibrary = dynamic_cast<const RemoteLibrary*>(library->Wrapped().get());
if (remoteLibrary) {
auto error = remoteLibrary->WebSocketClient().LastConnectionError();
auto it = kStateToErrorString.find(error);
const auto error = remoteLibrary->WebSocketClient().LastConnectionError();
const auto it = kStateToErrorString.find(error);
if (it != kStateToErrorString.end()) {
std::string value = _TSTR(it->second);
if (error == WebSocketClient::ConnectionError::IncompatibleVersion) {
@ -110,8 +110,8 @@ LibraryNotConnectedLayout::LibraryNotConnectedLayout(MasterLibraryPtr library)
void LibraryNotConnectedLayout::OnLayout() {
LayoutBase::OnLayout();
int cx = this->GetContentWidth();
int cy = this->GetContentHeight();
const int cx = this->GetContentWidth();
const int cy = this->GetContentHeight();
this->messageText->MoveAndResize(1, (cy / 2) - 2, cx - 2, 1);
this->errorText->MoveAndResize(1, (cy / 2) - 1, cx - 2, 1);
this->helpText->MoveAndResize(1, (cy / 2) + 1, cx - 2, 1);

View File

@ -50,6 +50,8 @@ namespace musik { namespace cube {
public:
using MasterLibraryPtr = std::shared_ptr<musik::core::library::MasterLibrary>;
DELETE_CLASS_DEFAULTS(LibraryNotConnectedLayout)
LibraryNotConnectedLayout(MasterLibraryPtr library);
/* IWindow */

View File

@ -66,22 +66,19 @@ LocalLibrarySettingsLayout::LocalLibrarySettingsLayout()
: LayoutBase()
, library(LibraryFactory::Instance().DefaultLocalLibrary())
, indexer(library->Indexer()) {
this->browseAdapter.reset(new DirectoryAdapter());
this->addedPathsAdapter.reset(new SimpleScrollAdapter());
this->browseAdapter = std::make_shared<DirectoryAdapter>();
this->addedPathsAdapter = std::make_shared<SimpleScrollAdapter>();
this->SetFocusMode(FocusModeTerminating);
this->InitializeWindows();
}
LocalLibrarySettingsLayout::~LocalLibrarySettingsLayout() {
}
void LocalLibrarySettingsLayout::OnLayout() {
int cx = this->GetWidth();
int leftX = 0;
int leftWidth = cx / 3; /* 1/3 width */
int rightX = leftWidth;
int rightWidth = cx - rightX; /* remainder (~2/3) */
int pathsHeight = this->GetHeight() - 1;
const int cx = this->GetWidth();
const int leftX = 0;
const int leftWidth = cx / 3; /* 1/3 width */
const int rightX = leftWidth;
const int rightWidth = cx - rightX; /* remainder (~2/3) */
const int pathsHeight = this->GetHeight() - 1;
this->browseList->MoveAndResize(leftX, 1, leftWidth, pathsHeight);
this->addedPathsList->MoveAndResize(rightX, 1, rightWidth, pathsHeight);
}
@ -94,7 +91,7 @@ void LocalLibrarySettingsLayout::LoadPreferences() {
for (size_t i = 0; i < paths.size(); i++) {
auto v = paths.at(i);
auto e = EntryPtr(new SingleLineEntry(v));
auto e = std::make_shared<SingleLineEntry>(v);
this->addedPathsAdapter->AddEntry(e);
}
@ -110,8 +107,8 @@ Color LocalLibrarySettingsLayout::ListItemDecorator(
if (scrollable == this->addedPathsList.get() ||
scrollable == this->browseList.get())
{
ListWindow* lw = static_cast<ListWindow*>(scrollable);
if (lw->GetSelectedIndex() == index) {
ListWindow* lw = dynamic_cast<ListWindow*>(scrollable);
if (lw && lw->GetSelectedIndex() == index) {
return Color::ListItemHighlighted;
}
}
@ -121,10 +118,10 @@ Color LocalLibrarySettingsLayout::ListItemDecorator(
void LocalLibrarySettingsLayout::InitializeWindows() {
this->SetFrameVisible(false);
this->addedPathsList.reset(new cursespp::ListWindow(this->addedPathsAdapter));
this->addedPathsList = std::make_shared<ListWindow>(this->addedPathsAdapter);
this->addedPathsList->SetFrameTitle(_TSTR("settings_backspace_to_remove"));
this->browseList.reset(new cursespp::ListWindow(this->browseAdapter));
this->browseList = std::make_shared<ListWindow>(this->browseAdapter);
this->browseList->SetFrameTitle(_TSTR("settings_space_to_add"));
ScrollAdapterBase::ItemDecorator decorator =
@ -173,7 +170,7 @@ void LocalLibrarySettingsLayout::RemoveSelectedDirectory() {
std::vector<std::string> paths;
this->indexer->GetPaths(paths);
size_t index = this->addedPathsList->GetSelectedIndex();
const size_t index = this->addedPathsList->GetSelectedIndex();
if (index != ListWindow::NO_SELECTION) {
this->indexer->RemovePath(paths.at(index));
this->LoadPreferences();

View File

@ -43,8 +43,9 @@
namespace musik { namespace cube {
class LocalLibrarySettingsLayout: public cursespp::LayoutBase {
public:
DELETE_COPY_AND_ASSIGNMENT_DEFAULTS(LocalLibrarySettingsLayout)
LocalLibrarySettingsLayout();
virtual ~LocalLibrarySettingsLayout();
void ToggleShowDotFiles();
void LoadPreferences();

View File

@ -76,8 +76,8 @@ LyricsLayout::LyricsLayout(PlaybackService& playback, ILibraryPtr library)
void LyricsLayout::OnLayout() {
LayoutBase::OnLayout();
int cx = this->GetContentWidth();
int cy = this->GetContentHeight();
const int cx = this->GetContentWidth();
const int cy = this->GetContentHeight();
this->listView->MoveAndResize(0, 0, cx, cy);
this->infoText->MoveAndResize(1, cy / 2, cx - 2, 1);
}
@ -137,11 +137,12 @@ void LyricsLayout::OnVisibilityChanged(bool visible) {
void LyricsLayout::ProcessMessage(musik::core::runtime::IMessage &m) {
if (m.Type() == message::LyricsLoaded) {
if ((State) m.UserData1() == State::Loaded && this->currentLyrics.size()) {
const auto state = static_cast<State>(m.UserData1());
if (state == State::Loaded && this->currentLyrics.size()) {
this->OnLyricsLoaded();
}
else {
this->SetState((State) m.UserData1());
this->SetState(state);
}
}
else {
@ -155,20 +156,20 @@ void LyricsLayout::LoadLyricsForCurrentTrack() {
this->currentTrackId = track->GetId();
this->currentLyrics = "";
this->SetState(State::Loading);
auto trackExternalId = track->GetString("external_id");
const auto trackExternalId = track->GetString("external_id");
auto lyricsDbQuery = std::make_shared<LyricsQuery>(trackExternalId);
this->library->Enqueue(lyricsDbQuery, [this, lyricsDbQuery, track](auto q) {
auto localLyrics = lyricsDbQuery->GetResult();
if (localLyrics.size()) {
this->currentLyrics = localLyrics;
this->Post(message::LyricsLoaded, (int64_t) State::Loaded);
this->Post(message::LyricsLoaded, static_cast<int64_t>(State::Loaded));
}
else {
auddio::FindLyrics(track, [this](TrackPtr track, std::string remoteLyrics) {
if (this->currentTrackId == track->GetId()) {
this->currentLyrics = remoteLyrics;
auto state = remoteLyrics.size() ? State::Loaded : State::Failed;
this->Post(message::LyricsLoaded, (int64_t) state);
const auto state = remoteLyrics.size() ? State::Loaded : State::Failed;
this->Post(message::LyricsLoaded, static_cast<int64_t>(state));
}
});
}

View File

@ -16,6 +16,8 @@ namespace musik { namespace cube {
public sigslot::has_slots<>
{
public:
DELETE_CLASS_DEFAULTS(LyricsLayout)
LyricsLayout(
musik::core::audio::PlaybackService& playback,
musik::core::ILibraryPtr library);

View File

@ -121,7 +121,7 @@ MainLayout::MainLayout(
this->settingsLayout = std::make_shared<SettingsLayout>(app, library, playback);
this->hotkeysLayout = std::make_shared<HotkeysLayout>();
this->topBanner.reset(new TextLabel());
this->topBanner = std::make_shared<TextLabel>();
this->topBanner->SetContentColor(Color::Header);
this->topBanner->Hide();
this->AddWindow(this->topBanner);
@ -139,7 +139,7 @@ MainLayout::~MainLayout() {
}
bool MainLayout::ShowTopBanner() {
auto libraryType = this->library->GetType();
const auto libraryType = this->library->GetType();
if (libraryType == ILibrary::Type::Local) {
return this->library->Indexer()->GetState() == IIndexer::StateIndexing;
}
@ -150,7 +150,7 @@ bool MainLayout::ShowTopBanner() {
}
void MainLayout::UpdateTopBannerText() {
auto libraryType = this->library->GetType();
const auto libraryType = this->library->GetType();
if (libraryType == ILibrary::Type::Local) {
updateSyncingText(this->topBanner.get(), this->syncUpdateCount);
}
@ -161,9 +161,9 @@ void MainLayout::UpdateTopBannerText() {
void MainLayout::OnLayout() {
if (this->ShowTopBanner()) {
size_t cx = this->GetContentWidth();
const int cx = this->GetContentWidth();
this->SetPadding(1, 0, 0, 0);
this->topBanner->MoveAndResize(0, 0, (int) cx, 1);
this->topBanner->MoveAndResize(0, 0, cx, 1);
this->topBanner->Show();
this->UpdateTopBannerText();
}
@ -217,7 +217,7 @@ void MainLayout::Stop() {
}
void MainLayout::ProcessMessage(musik::core::runtime::IMessage &message) {
int type = message.Type();
const int type = message.Type();
if (type == message::JumpToConsole) {
this->SetLayout(consoleLayout);
@ -245,7 +245,7 @@ void MainLayout::ProcessMessage(musik::core::runtime::IMessage &message) {
this->Layout();
}
else if (type == message::IndexerProgress) {
this->syncUpdateCount = (int) message.UserData1();
this->syncUpdateCount = narrow_cast<int>(message.UserData1());
this->UpdateTopBannerText();
if (!topBanner->IsVisible()) {
this->Layout();
@ -280,7 +280,7 @@ void MainLayout::SwitchToPlayQueue() {
void MainLayout::SwitchToLibraryLayout() {
if (IsLibraryConnected()) {
if (!this->libraryLayout) {
this->libraryLayout.reset(new LibraryLayout(playback, library));
this->libraryLayout = std::make_shared<LibraryLayout>(playback, library);
}
this->SetLayout(libraryLayout);
}

View File

@ -55,6 +55,8 @@ namespace musik {
public:
using MasterLibraryPtr = std::shared_ptr<musik::core::library::MasterLibrary>;
DELETE_CLASS_DEFAULTS(MainLayout)
MainLayout(
cursespp::App& app,
ConsoleLogger* logger,

View File

@ -62,7 +62,7 @@ using namespace cursespp;
namespace keys = musik::cube::prefs::keys;
namespace components = musik::core::prefs::components;
static std::set<std::string> EDIT_KEYS;
static std::set<std::string> kEditKeys;
static std::string formatWithAlbum(TrackPtr track, size_t index, size_t width);
@ -82,21 +82,18 @@ NowPlayingLayout::NowPlayingLayout(
this->trackListView->SetRowRenderer(
TrackRowRenderers::Get(TrackRowRenderers::Type::NowPlaying));
EDIT_KEYS = {
kEditKeys = {
Hotkeys::Get(Hotkeys::PlayQueueMoveUp),
Hotkeys::Get(Hotkeys::PlayQueueMoveDown),
Hotkeys::Get(Hotkeys::PlayQueueDelete)
};
}
NowPlayingLayout::~NowPlayingLayout() {
}
Color NowPlayingLayout::RowDecorator(musik::core::TrackPtr track, size_t index) {
bool selected = index == trackListView->GetSelectedIndex();
const bool selected = index == trackListView->GetSelectedIndex();
Color attrs = selected ? Color::ListItemHighlighted : Color::Default;
size_t playingIndex = playback.GetIndex();
const size_t playingIndex = playback.GetIndex();
if (index == playingIndex) {
TrackPtr playing = playback.GetPlaying();
@ -128,10 +125,14 @@ void NowPlayingLayout::OnLayout() {
}
void NowPlayingLayout::InitializeWindows() {
this->trackListView.reset(new TrackListView(
this->trackListView = std::make_shared<TrackListView>(
this->playback,
this->library,
std::bind(&NowPlayingLayout::RowDecorator, this, std::placeholders::_1, std::placeholders::_2)));
std::bind(
&NowPlayingLayout::RowDecorator,
this,
std::placeholders::_1,
std::placeholders::_2));
this->trackListView->SetFrameTitle(_TSTR("playqueue_title"));
this->trackListView->Requeried.connect(this, &NowPlayingLayout::OnTrackListRequeried);
@ -162,14 +163,14 @@ void NowPlayingLayout::OnTrackListRequeried(musik::core::library::query::TrackLi
if (playback.Count()) {
/* regular logic (i.e, no edit operation) */
if (this->reselectIndex == -1) {
size_t index = playback.GetIndex();
const size_t index = playback.GetIndex();
if (index == ListWindow::NO_SELECTION) { /* not playing? */
this->trackListView->ScrollTo(0);
this->trackListView->SetSelectedIndex(0);
}
else { /* playing... */
size_t scrollToIndex = index == 0 ? index : index - 1;
const size_t scrollToIndex = index == 0 ? index : index - 1;
if (!this->trackListView->IsEntryVisible(scrollToIndex)) {
this->trackListView->ScrollTo(scrollToIndex);
}
@ -184,10 +185,10 @@ void NowPlayingLayout::OnTrackListRequeried(musik::core::library::query::TrackLi
/* ensure the correct index is selected, and that it's properly
scrolled into view */
this->reselectIndex = std::min((int) this->trackListView->TrackCount() - 1, this->reselectIndex);
this->trackListView->SetSelectedIndex((size_t)this->reselectIndex);
this->trackListView->SetSelectedIndex(narrow_cast<size_t>(this->reselectIndex));
if (!this->trackListView->IsEntryVisible((size_t) this->reselectIndex)) {
this->trackListView->ScrollTo((size_t)this->reselectIndex);
if (!this->trackListView->IsEntryVisible(narrow_cast<size_t>(this->reselectIndex))) {
this->trackListView->ScrollTo(narrow_cast<size_t>(this->reselectIndex));
}
this->reselectIndex = -1;
@ -195,7 +196,7 @@ void NowPlayingLayout::OnTrackListRequeried(musik::core::library::query::TrackLi
/* if after a bunch of monkeying around there's still nothing
selected, but we have contents, let's just select the first item */
auto sel = this->trackListView->GetSelectedIndex();
const auto sel = this->trackListView->GetSelectedIndex();
if (sel == ListWindow::NO_SELECTION || sel >= this->trackListView->TrackCount()) {
this->trackListView->SetSelectedIndex(0);
this->trackListView->ScrollTo(0);
@ -213,9 +214,7 @@ void NowPlayingLayout::RequeryTrackList() {
}
void NowPlayingLayout::OnPlaylistSelected(int64_t playlistId) {
auto query = std::shared_ptr<GetPlaylistQuery>(
new GetPlaylistQuery(library, playlistId));
auto query = std::make_shared<GetPlaylistQuery>(library, playlistId);
this->lastPlaylistQueryId = query->GetId();
this->trackListView->Requery(query);
}
@ -253,30 +252,30 @@ bool NowPlayingLayout::KeyPress(const std::string& key) {
}
bool NowPlayingLayout::ProcessEditOperation(const std::string& key) {
if (EDIT_KEYS.find(key) != EDIT_KEYS.end()) {
if (kEditKeys.find(key) != kEditKeys.end()) {
if (!playback.IsShuffled()) {
size_t selected = this->trackListView->GetSelectedIndex();
const size_t selected = this->trackListView->GetSelectedIndex();
this->reselectIndex = -1;
{
PlaybackService::Editor editor = this->playback.Edit();
if (Hotkeys::Is(Hotkeys::PlayQueueMoveUp, key)) {
if (selected > 0) {
size_t to = selected - 1;
const size_t to = selected - 1;
editor.Move(selected, to);
reselectIndex = (int)to;
reselectIndex = narrow_cast<int>(to);
}
}
else if (Hotkeys::Is(Hotkeys::PlayQueueMoveDown, key)) {
if (selected < this->playback.Count() - 1) {
size_t to = selected + 1;
const size_t to = selected + 1;
editor.Move(selected, to);
reselectIndex = (int)to;
reselectIndex = narrow_cast<int>(to);
}
}
else if (Hotkeys::Is(Hotkeys::PlayQueueDelete, key)) {
editor.Delete(selected);
reselectIndex = (int)selected;
reselectIndex = narrow_cast<int>(selected);
}
}

View File

@ -52,12 +52,12 @@ namespace musik {
public sigslot::has_slots<>
{
public:
DELETE_CLASS_DEFAULTS(NowPlayingLayout)
NowPlayingLayout(
musik::core::audio::PlaybackService& playback,
musik::core::ILibraryPtr library);
virtual ~NowPlayingLayout();
/* IWindow */
void OnVisibilityChanged(bool visible) override;
bool KeyPress(const std::string& key) override;

View File

@ -202,8 +202,8 @@ void RemoteLibrarySettingsLayout::LoadPreferences() {
this->httpTlsCheckbox->CheckChanged.disconnect(this);
auto host = prefs->GetString(core::prefs::keys::RemoteLibraryHostname, "127.0.0.1");
auto const wssPort = (unsigned short) prefs->GetInt(core::prefs::keys::RemoteLibraryWssPort, 7905);
auto const httpPort = (unsigned short) prefs->GetInt(core::prefs::keys::RemoteLibraryHttpPort, 7906);
auto const wssPort = narrow_cast<unsigned short>(prefs->GetInt(core::prefs::keys::RemoteLibraryWssPort, 7905));
auto const httpPort = narrow_cast<unsigned short>(prefs->GetInt(core::prefs::keys::RemoteLibraryHttpPort, 7906));
auto const password = prefs->GetString(core::prefs::keys::RemoteLibraryPassword, "");
auto const wssTls = prefs->GetBool(core::prefs::keys::RemoteLibraryWssTls, false);
auto const httpTls = prefs->GetBool(core::prefs::keys::RemoteLibraryHttpTls, false);

View File

@ -44,8 +44,9 @@
namespace musik { namespace cube {
class RemoteLibrarySettingsLayout: public cursespp::LayoutBase, public sigslot::has_slots<> {
public:
RemoteLibrarySettingsLayout();
DELETE_COPY_AND_ASSIGNMENT_DEFAULTS(RemoteLibrarySettingsLayout)
RemoteLibrarySettingsLayout();
virtual ~RemoteLibrarySettingsLayout();
void LoadPreferences();

View File

@ -62,8 +62,8 @@ using namespace cursespp;
namespace keys = musik::cube::prefs::keys;
namespace components = musik::core::prefs::components;
#define SEARCH_HEIGHT 3
#define REQUERY_INTERVAL_MS 300
constexpr int kSearchHeight = 3;
constexpr int kRequeryIntervalMs = 300;
static TrackSortType getDefaultTrackSort(std::shared_ptr<musik::core::Preferences> prefs) {
return (TrackSortType) prefs->GetInt(
@ -104,32 +104,32 @@ void TrackSearchLayout::SaveSession() {
}
void TrackSearchLayout::OnLayout() {
int cx = this->GetWidth(), cy = this->GetHeight();
int x = 0, y = 0;
const int cx = this->GetWidth(), cy = this->GetHeight();
const int x = 0, y = 0;
int inputWidth = cx / 2;
int inputX = x + ((cx - inputWidth) / 2);
this->input->MoveAndResize(inputX, y, cx / 2, SEARCH_HEIGHT);
const int inputWidth = cx / 2;
const int inputX = x + ((cx - inputWidth) / 2);
this->input->MoveAndResize(inputX, y, cx / 2, kSearchHeight);
bool inputIsRegex = this->matchType == MatchType::Regex;
const bool inputIsRegex = this->matchType == MatchType::Regex;
this->input->SetHint(_TSTR(inputIsRegex ? "search_regex_hint" : "search_filter_hint"));
this->input->SetFocusedFrameColor(inputIsRegex ? Color::FrameImportant : Color::FrameFocused);
this->trackList->MoveAndResize(
x,
y + SEARCH_HEIGHT,
y + kSearchHeight,
this->GetWidth(),
this->GetHeight() - SEARCH_HEIGHT);
this->GetHeight() - kSearchHeight);
}
void TrackSearchLayout::InitializeWindows() {
this->input.reset(new cursespp::TextInput());
this->input = std::make_shared<TextInput>();
this->input->TextChanged.connect(this, &TrackSearchLayout::OnInputChanged);
this->input->EnterPressed.connect(this, &TrackSearchLayout::OnEnterPressed);
this->input->SetFocusOrder(0);
this->AddWindow(this->input);
this->trackList.reset(new TrackListView(this->playback, this->library));
this->trackList = std::make_shared<TrackListView>(this->playback, this->library);
this->trackList->SetFocusOrder(1);
this->trackList->SetAllowArrowKeyPropagation();
this->trackList->Requeried.connect(this, &TrackSearchLayout::OnRequeried);
@ -157,9 +157,12 @@ void TrackSearchLayout::FocusInput() {
void TrackSearchLayout::Requery() {
const std::string& filter = this->input->GetText();
const TrackSortType sortOrder = getDefaultTrackSort(this->prefs);
this->trackList->Requery(std::shared_ptr<TrackListQueryBase>(
new SearchTrackListQuery(
this->library, this->matchType, filter, sortOrder)));
this->trackList->Requery(
std::make_shared<SearchTrackListQuery>(
this->library,
this->matchType,
filter,
sortOrder));
}
void TrackSearchLayout::PlayFromTop() {
@ -186,7 +189,7 @@ void TrackSearchLayout::OnRequeried(TrackListQueryBase* query) {
void TrackSearchLayout::OnInputChanged(cursespp::TextInput* sender, std::string value) {
if (this->IsVisible()) {
Debounce(message::RequeryTrackList, 0, 0, REQUERY_INTERVAL_MS);
Debounce(message::RequeryTrackList, 0, 0, kRequeryIntervalMs);
}
}

View File

@ -52,6 +52,8 @@ namespace musik {
public sigslot::has_slots<>
{
public:
DELETE_COPY_AND_ASSIGNMENT_DEFAULTS(TrackSearchLayout)
TrackSearchLayout(
musik::core::audio::PlaybackService& playback,
musik::core::ILibraryPtr library);

View File

@ -87,11 +87,11 @@ static inline milliseconds now() noexcept {
system_clock::now().time_since_epoch());
}
static inline bool lastOperationExpired() {
static inline bool lastOperationExpired() noexcept {
return now() > lastOperationExpiry;
}
static inline void touchOperationExpiry() {
static inline void touchOperationExpiry() noexcept {
lastOperationExpiry = now() + duration_cast<milliseconds>(Seconds(60));
}
@ -393,7 +393,7 @@ static void showAddCategorySelectionToPlaylistOverlay(
if (!lastOperationExpired() && lastPlaylistId >= 0) {
const int index = findPlaylistIndex(result, lastPlaylistId);
if (index >= 0) {
selectedIndex = (size_t) index + 1; /* +1 offsets "new..." */
selectedIndex = narrow_cast<size_t>(index) + 1; /* +1 offsets "new..." */
}
}
@ -440,7 +440,7 @@ static void showAddTrackToPlaylistOverlay(
if (!lastOperationExpired() && lastPlaylistId >= 0) {
const int index = findPlaylistIndex(result, lastPlaylistId);
if (index >= 0) {
selectedIndex = (size_t) index + 1; /* +1 offsets "new..." */
selectedIndex = narrow_cast<size_t>(index) + 1; /* +1 offsets "new..." */
}
}

View File

@ -62,19 +62,19 @@ using namespace std::chrono;
using Callback = std::function<void()>;
static const std::string kTlsInfoUrl = "https://github.com/clangen/musikcube/wiki/ssl-server-setup";
static const int64_t kTlsWarningCooldownMs = 20000;
constexpr int64_t kTlsWarningCooldownMs = 20000;
int64_t lastTlsWarningTime = 0;
static const std::vector<std::string> kTranscoderFormats = { "mp3", "opus", "ogg", "flac", "aac" };
static const std::string kDefaultTranscoderFormat = "ogg";
static const int kDefaultTranscoderFormatOverlayWidth = 24;
constexpr int kDefaultTranscoderFormatOverlayWidth = 24;
static const std::vector<int> kTranscoderBitrates = { 64, 96, 128, 192, 256, 320 };
static const int kDefaultTranscoderBitrate = 192;
static const int kDefaultTranscoderBitrateOverlayWidth = 24;
constexpr int kDefaultTranscoderBitrate = 192;
constexpr int kDefaultTranscoderBitrateOverlayWidth = 24;
static void showNeedsRestart(Callback cb = Callback()) {
std::shared_ptr<DialogOverlay> dialog(new DialogOverlay());
auto dialog = std::make_shared<DialogOverlay>();
(*dialog)
.SetTitle(_TSTR("default_overlay_title"))
@ -99,18 +99,18 @@ void musik::cube::SettingsOverlays::ShowLocaleOverlay(std::function<void()> call
std::string currentLocale = locale.GetSelectedLocale();
allLocales = locale.GetLocales();
std::shared_ptr<Adapter> adapter(new Adapter());
auto adapter = std::make_shared<Adapter>();
adapter->SetSelectable(true);
int selectedIndex = 0;
for (size_t i = 0; i < allLocales.size(); i++) {
adapter->AddEntry(allLocales[i]);
if (allLocales[i] == currentLocale) {
selectedIndex = (int)i;
selectedIndex = narrow_cast<int>(i);
}
}
std::shared_ptr<ListOverlay> dialog(new ListOverlay());
auto dialog = std::make_shared<ListOverlay>();
dialog->SetAdapter(adapter)
.SetTitle(_TSTR("locale_overlay_select_title"))
@ -130,20 +130,20 @@ void musik::cube::SettingsOverlays::ShowLocaleOverlay(std::function<void()> call
void musik::cube::SettingsOverlays::ShowLibraryTypeOverlay(std::function<void()> callback) {
auto prefs = Preferences::ForComponent(core::prefs::components::Settings);
const auto libraryType = (ILibrary::Type) prefs->GetInt(
core::prefs::keys::LibraryType, (int) ILibrary::Type::Local);
const auto libraryType = static_cast<ILibrary::Type>(prefs->GetInt(
core::prefs::keys::LibraryType, (int) ILibrary::Type::Local));
using Adapter = cursespp::SimpleScrollAdapter;
using ListOverlay = cursespp::ListOverlay;
std::shared_ptr<Adapter> adapter(new Adapter());
auto adapter = std::make_shared<Adapter>();
adapter->SetSelectable(true);
adapter->AddEntry(_TSTR("settings_library_type_local"));
adapter->AddEntry(_TSTR("settings_library_type_remote"));
int selectedIndex = libraryType == ILibrary::Type::Local ? 0 : 1;
const int selectedIndex = libraryType == ILibrary::Type::Local ? 0 : 1;
std::shared_ptr<ListOverlay> dialog(new ListOverlay());
auto dialog = std::make_shared<ListOverlay>();
dialog->SetAdapter(adapter)
.SetTitle(_TSTR("settings_library_type_overlay_title"))
@ -151,8 +151,8 @@ void musik::cube::SettingsOverlays::ShowLibraryTypeOverlay(std::function<void()>
.SetItemSelectedCallback(
[prefs, callback]
(ListOverlay* overlay, IScrollAdapterPtr adapter, size_t index) {
auto updatedType = index == 0 ? ILibrary::Type::Local : ILibrary::Type::Remote;
prefs->SetInt(core::prefs::keys::LibraryType, (int)updatedType);
const auto updatedType = index == 0 ? ILibrary::Type::Local : ILibrary::Type::Remote;
prefs->SetInt(core::prefs::keys::LibraryType, narrow_cast<int>(updatedType));
callback();
});
@ -232,7 +232,7 @@ void musik::cube::SettingsOverlays::CheckShowTlsWarningDialog() {
void musik::cube::SettingsOverlays::ShowTranscoderBitrateOverlay(std::function<void()> callback) {
auto prefs = Preferences::ForComponent(core::prefs::components::Settings);
int currentBitrate = prefs->GetInt(
const int currentBitrate = prefs->GetInt(
core::prefs::keys::RemoteLibraryTranscoderBitrate,
kDefaultTranscoderBitrate);

View File

@ -43,6 +43,8 @@ namespace musik {
namespace cube {
class GlobalHotkeys {
public:
DELETE_CLASS_DEFAULTS(GlobalHotkeys)
GlobalHotkeys(
musik::core::audio::PlaybackService& playback,
musik::core::ILibraryPtr library);

View File

@ -50,7 +50,7 @@ using Id = Hotkeys::Id;
/* sigh: http://stackoverflow.com/a/24847480 */
struct EnumHasher {
template <typename T>
std::size_t operator()(T t) const {
std::size_t operator()(T t) const noexcept {
return static_cast<std::size_t>(t);
}
};
@ -256,7 +256,7 @@ static void loadPreferences() {
std::vector<std::string> names;
preferences->GetKeys(names);
for (auto n : names) {
auto it = NAME_TO_ID.find(n);
const auto it = NAME_TO_ID.find(n);
if (it != NAME_TO_ID.end()) {
customIdToKey[it->second] = preferences->GetString(n);
}
@ -273,21 +273,18 @@ static void loadPreferences() {
}
}
Hotkeys::Hotkeys() {
}
bool Hotkeys::Is(Id id, const std::string& kn) {
ENSURE_LOADED()
/* see if the user has specified a custom value for this hotkey. if
they have, compare it to the custom value. */
auto custom = customIdToKey.find(id);
const auto custom = customIdToKey.find(id);
if (custom != customIdToKey.end()) {
return (custom->second == kn);
}
/* otherwise, let's compare against the default key */
auto it = ID_TO_DEFAULT.find(id);
const auto it = ID_TO_DEFAULT.find(id);
if (it != ID_TO_DEFAULT.end() && it->second == kn) {
return true;
}
@ -297,7 +294,7 @@ bool Hotkeys::Is(Id id, const std::string& kn) {
template <typename T>
std::string find(Id id, T& map) {
auto it = map.find(id);
const auto it = map.find(id);
if (it != map.end()) {
return it->second;
}
@ -365,31 +362,31 @@ std::string Hotkeys::Name(Id id) {
class NavigationKeysImpl : public cursespp::INavigationKeys {
public:
virtual bool Up(const std::string& key) override { return Up() == key; }
virtual bool Down(const std::string& key) override { return Down() == key; }
virtual bool Left(const std::string& key) override { return Left() == key; }
virtual bool Right(const std::string& key) override { return Right() == key; }
virtual bool PageUp(const std::string& key) override { return PageUp() == key; }
virtual bool PageDown(const std::string& key) override { return PageDown() == key; }
virtual bool Home(const std::string& key) override { return Home() == key; }
virtual bool End(const std::string& key) override { return End() == key; }
virtual bool Next(const std::string& key) override { return Next() == key; }
virtual bool Prev(const std::string& key) override { return Prev() == key; }
virtual bool Mode(const std::string& key) override { return Mode() == key; }
bool Up(const std::string& key) override { return Up() == key; }
bool Down(const std::string& key) override { return Down() == key; }
bool Left(const std::string& key) override { return Left() == key; }
bool Right(const std::string& key) override { return Right() == key; }
bool PageUp(const std::string& key) override { return PageUp() == key; }
bool PageDown(const std::string& key) override { return PageDown() == key; }
bool Home(const std::string& key) override { return Home() == key; }
bool End(const std::string& key) override { return End() == key; }
bool Next(const std::string& key) override { return Next() == key; }
bool Prev(const std::string& key) override { return Prev() == key; }
bool Mode(const std::string& key) override { return Mode() == key; }
virtual std::string Up() override { return Hotkeys::Get(Hotkeys::Up); }
virtual std::string Down() override { return Hotkeys::Get(Hotkeys::Down); }
virtual std::string Left() override { return Hotkeys::Get(Hotkeys::Left); }
virtual std::string Right() override { return Hotkeys::Get(Hotkeys::Right); }
virtual std::string PageUp() override { return Hotkeys::Get(Hotkeys::PageUp); }
virtual std::string PageDown() override { return Hotkeys::Get(Hotkeys::PageDown); }
virtual std::string Home() override { return Hotkeys::Get(Hotkeys::Home); }
virtual std::string End() override { return Hotkeys::Get(Hotkeys::End); }
virtual std::string Next() override { return "KEY_TAB"; }
virtual std::string Prev() override { return "KEY_BTAB"; }
virtual std::string Mode() override { return "^["; }
std::string Up() override { return Hotkeys::Get(Hotkeys::Up); }
std::string Down() override { return Hotkeys::Get(Hotkeys::Down); }
std::string Left() override { return Hotkeys::Get(Hotkeys::Left); }
std::string Right() override { return Hotkeys::Get(Hotkeys::Right); }
std::string PageUp() override { return Hotkeys::Get(Hotkeys::PageUp); }
std::string PageDown() override { return Hotkeys::Get(Hotkeys::PageDown); }
std::string Home() override { return Hotkeys::Get(Hotkeys::Home); }
std::string End() override { return Hotkeys::Get(Hotkeys::End); }
std::string Next() override { return "KEY_TAB"; }
std::string Prev() override { return "KEY_BTAB"; }
std::string Mode() override { return "^["; }
};
std::shared_ptr<cursespp::INavigationKeys> Hotkeys::NavigationKeys() {
return std::shared_ptr<cursespp::INavigationKeys>(new NavigationKeysImpl());
return std::make_shared<NavigationKeysImpl>();
}

View File

@ -147,7 +147,7 @@ namespace musik {
static std::shared_ptr<cursespp::INavigationKeys> NavigationKeys();
private:
Hotkeys();
DELETE_CLASS_DEFAULTS(Hotkeys)
};
}
}

View File

@ -53,10 +53,10 @@ using namespace cursespp;
#define DIGITS(x) (x > 9 ? (int) log10((double) x) + 1 : 1)
static const bool kEnableSkeletonRows = true;
constexpr bool kEnableSkeletonRows = true;
constexpr int kDurationColWidth = 5; /* 00:00 */
constexpr int kRatingBreakpointWidth = 90;
static const std::string kSkeletonChar = "-"; // "░";
static const int kDurationColWidth = 5; /* 00:00 */
static const int kRatingBreakpointWidth = 90;
/* this method does a couple things slower than it probably should, but it
shouldn't cause any issues. TODO: make this better? does it matter? */
@ -81,9 +81,9 @@ static std::string placeholder(int width) {
}
namespace AlbumSort {
static const int kTrackColWidth = 3;
static const int kArtistColWidth = 17;
static const int kRatingColumnWidth = 5;
constexpr int kTrackColWidth = 3;
constexpr int kArtistColWidth = 17;
constexpr int kRatingColumnWidth = 5;
static std::string skeleton(TrackPtr track, size_t width) {
auto const id = track->GetId();
@ -94,16 +94,19 @@ namespace AlbumSort {
std::string artist = text::Align(placeholder(1 + (id % (kArtistColWidth - 2))), text::AlignLeft, kArtistColWidth);
int titleWidth =
(int) width -
(int) kTrackColWidth -
narrow_cast<int>(width) -
narrow_cast<int>(kTrackColWidth) -
kDurationColWidth -
kArtistColWidth -
(int) u8len(rating) -
narrow_cast<int>(u8len(rating)) -
(3 * 3); /* 3 = spacing */
titleWidth = std::max(0, titleWidth);
std::string title = text::Align(placeholder(1 + (id % ((int64_t) titleWidth - 2))), text::AlignLeft, (int) titleWidth);
std::string title = text::Align(placeholder(
1 + (id % (static_cast<int64_t>(titleWidth) - 2))),
text::AlignLeft,
narrow_cast<int>(titleWidth));
return u8fmt(
"%s %s%s %s %s",
@ -148,11 +151,11 @@ namespace AlbumSort {
int titleWidth = 0;
titleWidth =
(int) width -
(int) trackColWidth -
narrow_cast<int>(width) -
narrow_cast<int>(trackColWidth) -
kDurationColWidth -
kArtistColWidth -
(int) u8len(rating) -
narrow_cast<int>(u8len(rating)) -
(3 * 3); /* 3 = spacing */
titleWidth = std::max(0, titleWidth);
@ -160,7 +163,7 @@ namespace AlbumSort {
std::string title = text::Align(
track->GetString(constants::Track::TITLE),
text::AlignLeft,
(int) titleWidth);
narrow_cast<int>(titleWidth));
return u8fmt(
"%s %s%s %s %s",
@ -173,9 +176,9 @@ namespace AlbumSort {
}
namespace NowPlaying {
static const int kTrackColWidth = 3;
static const int kArtistColWidth = 14;
static const int kAlbumColWidth = 14;
constexpr int kTrackColWidth = 3;
constexpr int kArtistColWidth = 14;
constexpr int kAlbumColWidth = 14;
static std::string skeleton(TrackPtr track, size_t width) {
auto const id = track->GetId();
@ -187,17 +190,20 @@ namespace NowPlaying {
std::string artist = text::Align(placeholder(1 + (id % (kArtistColWidth - 2))), text::AlignLeft, kArtistColWidth);
int titleWidth =
(int)width -
(int)kTrackColWidth -
narrow_cast<int>(width) -
narrow_cast<int>(kTrackColWidth) -
kDurationColWidth -
kAlbumColWidth -
kArtistColWidth -
(int)u8len(rating) -
narrow_cast<int>(u8len(rating)) -
(4 * 3); /* 3 = spacing */
titleWidth = std::max(0, titleWidth);
std::string title = text::Align(placeholder(1 + (id % ((int64_t) titleWidth - 2))), text::AlignLeft, (int) titleWidth);
std::string title = text::Align(placeholder(
1 + (id % (static_cast<int64_t>(titleWidth) - 2))),
text::AlignLeft,
narrow_cast<int>(titleWidth));
return u8fmt(
"%s %s%s %s %s %s",
@ -234,12 +240,12 @@ namespace NowPlaying {
kArtistColWidth);
int titleWidth =
(int) width -
(int) trackColWidth -
narrow_cast<int>(width) -
narrow_cast<int>(trackColWidth) -
kDurationColWidth -
kAlbumColWidth -
kArtistColWidth -
(int) u8cols(rating) -
narrow_cast<int>(u8cols(rating)) -
(4 * 3); /* 3 = spacing */
titleWidth = std::max(0, titleWidth);

View File

@ -75,7 +75,7 @@ static const std::string PLATFORM = "openbsd";
static const std::string PLATFORM = "linux";
#endif
static inline int64_t versionCode(short major, short minor, short patch) {
constexpr int64_t versionCode(short major, short minor, short patch) noexcept {
int64_t version = major;
version = (version << 16) | minor;
version = (version << 16) | patch;

View File

@ -52,6 +52,8 @@ namespace musik { namespace cube {
static void ShowNoUpgradeFoundOverlay();
DELETE_COPY_AND_ASSIGNMENT_DEFAULTS(UpdateCheck)
UpdateCheck();
~UpdateCheck();
@ -61,7 +63,8 @@ namespace musik { namespace cube {
private:
void Reset();
virtual void ProcessMessage(musik::core::runtime::IMessage &message);
/* IMessageHandler */
void ProcessMessage(musik::core::runtime::IMessage &message) override;
std::recursive_mutex mutex;
Callback callback;