mirror of
https://github.com/clangen/musikcube.git
synced 2025-02-06 03:39:50 +00:00
More annoying boilerplate for library selection.
This commit is contained in:
parent
87acc20506
commit
173fef5e62
@ -65,6 +65,10 @@ namespace musik { namespace core { namespace prefs {
|
||||
const std::string keys::LastFmUsername = "LastFmUsername";
|
||||
const std::string keys::DisableAlbumArtistFallback = "DisableAlbumArtistFallback";
|
||||
const std::string keys::AuddioApiToken = "AuddioApiToken";
|
||||
const std::string keys::LibraryType = "LibraryType";
|
||||
const std::string keys::RemoteLibraryHostname = "RemoteLibraryHostname";
|
||||
const std::string keys::RemoteLibraryPort = "RemoteLibraryPort";
|
||||
const std::string keys::RemoteLibraryPassword = "RemoteLibraryPassword";
|
||||
|
||||
} } }
|
||||
|
||||
|
@ -59,7 +59,6 @@ namespace musik { namespace core { namespace prefs {
|
||||
extern const std::string IndexerLogEnabled;
|
||||
extern const std::string IndexerThreadCount;
|
||||
extern const std::string IndexerTransactionInterval;
|
||||
|
||||
extern const std::string ReplayGainMode;
|
||||
extern const std::string PreampDecibels;
|
||||
extern const std::string SaveSessionOnExit;
|
||||
@ -70,6 +69,10 @@ namespace musik { namespace core { namespace prefs {
|
||||
extern const std::string LastFmUsername;
|
||||
extern const std::string DisableAlbumArtistFallback;
|
||||
extern const std::string AuddioApiToken;
|
||||
extern const std::string LibraryType;
|
||||
extern const std::string RemoteLibraryHostname;
|
||||
extern const std::string RemoteLibraryPort;
|
||||
extern const std::string RemoteLibraryPassword;
|
||||
}
|
||||
|
||||
} } }
|
||||
|
@ -118,8 +118,8 @@ int main(int argc, char* argv[]) {
|
||||
musik::debug::Start({ fileLogger, consoleLogger });
|
||||
|
||||
LibraryFactory::Initialize(Window::MessageQueue());
|
||||
ILibraryPtr library = LibraryFactory::Instance().Default();
|
||||
// ILibraryPtr library = LibraryFactory::Instance().CreateLibrary("remote", ILibrary::Type::Remote);
|
||||
//ILibraryPtr library = LibraryFactory::Instance().Default();
|
||||
ILibraryPtr library = LibraryFactory::Instance().CreateLibrary("remote", ILibrary::Type::Remote);
|
||||
|
||||
{
|
||||
auto prefs = Preferences::ForComponent(
|
||||
|
@ -56,7 +56,7 @@
|
||||
#include <app/util/UpdateCheck.h>
|
||||
#include <app/overlay/ColorThemeOverlay.h>
|
||||
#include <app/overlay/LastFmOverlay.h>
|
||||
#include <app/overlay/LocaleOverlay.h>
|
||||
#include <app/overlay/SettingsOverlays.h>
|
||||
#include <app/overlay/PlaybackOverlays.h>
|
||||
#include <app/overlay/PluginOverlay.h>
|
||||
#include <app/overlay/ServerOverlay.h>
|
||||
@ -214,8 +214,12 @@ void SettingsLayout::OnCheckboxChanged(cursespp::Checkbox* cb, bool checked) {
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsLayout::OnLibraryTypeDropdownActivated(cursespp::TextLabel* label) {
|
||||
SettingsOverlays::ShowLibraryTypeOverlay([this]() { this->LoadPreferences(); });
|
||||
}
|
||||
|
||||
void SettingsLayout::OnLocaleDropdownActivate(cursespp::TextLabel* label) {
|
||||
LocaleOverlay::Show([this](){ this->LoadPreferences(); });
|
||||
SettingsOverlays::ShowLocaleOverlay([this](){ this->LoadPreferences(); });
|
||||
}
|
||||
|
||||
void SettingsLayout::OnOutputDriverDropdownActivated(cursespp::TextLabel* label) {
|
||||
@ -317,15 +321,16 @@ void SettingsLayout::OnLayout() {
|
||||
int cx = this->GetWidth(), cy = this->GetHeight();
|
||||
|
||||
/* top row (library config) */
|
||||
int libraryLayoutHeight = cy / 2;
|
||||
this->localLibraryLayout->MoveAndResize(0, 0, cx, libraryLayoutHeight);
|
||||
this->libraryTypeDropdown->MoveAndResize(1, 1, cx - 1, LABEL_HEIGHT);
|
||||
int libraryLayoutHeight = std::min(12, cy / 2);
|
||||
this->localLibraryLayout->MoveAndResize(2, 2, cx - 3, libraryLayoutHeight);
|
||||
|
||||
/* bottom row (dropdowns, checkboxes) */
|
||||
int columnCx = (cx - 5) / 2; /* 3 = left + right + middle padding */
|
||||
int column1 = 1;
|
||||
int column2 = columnCx + 3;
|
||||
|
||||
y = BOTTOM(this->localLibraryLayout);
|
||||
y = BOTTOM(this->localLibraryLayout) + 1;
|
||||
this->localeDropdown->MoveAndResize(column1, y++, columnCx, LABEL_HEIGHT);
|
||||
this->outputDriverDropdown->MoveAndResize(column1, y++, columnCx, LABEL_HEIGHT);
|
||||
this->outputDeviceDropdown->MoveAndResize(column1, y++, columnCx, LABEL_HEIGHT);
|
||||
@ -342,7 +347,7 @@ void SettingsLayout::OnLayout() {
|
||||
this->serverDropdown->MoveAndResize(column1, y++, columnCx, LABEL_HEIGHT);
|
||||
}
|
||||
|
||||
y = BOTTOM(this->localLibraryLayout);
|
||||
y = BOTTOM(this->localLibraryLayout) + 1;
|
||||
#ifdef ENABLE_UNIX_TERMINAL_OPTIONS
|
||||
this->paletteCheckbox->MoveAndResize(column2, y++, columnCx, LABEL_HEIGHT);
|
||||
this->enableTransparencyCheckbox->MoveAndResize(column2, y++, columnCx, LABEL_HEIGHT);
|
||||
@ -363,6 +368,9 @@ void SettingsLayout::OnLayout() {
|
||||
void SettingsLayout::InitializeWindows() {
|
||||
this->SetFrameVisible(false);
|
||||
|
||||
this->libraryTypeDropdown.reset(new TextLabel());
|
||||
this->libraryTypeDropdown->Activated.connect(this, &SettingsLayout::OnLibraryTypeDropdownActivated);
|
||||
|
||||
this->localLibraryLayout.reset(new LocalLibrarySettingsLayout(this->library, this->playback));
|
||||
|
||||
this->localeDropdown.reset(new TextLabel());
|
||||
@ -424,6 +432,7 @@ void SettingsLayout::InitializeWindows() {
|
||||
CREATE_CHECKBOX(this->saveSessionCheckbox, _TSTR("settings_save_session_on_exit"));
|
||||
|
||||
int order = 0;
|
||||
this->libraryTypeDropdown->SetFocusOrder(order++);
|
||||
this->localLibraryLayout->SetFocusOrder(order++);
|
||||
this->localeDropdown->SetFocusOrder(order++);
|
||||
this->outputDriverDropdown->SetFocusOrder(order++);
|
||||
@ -453,6 +462,7 @@ void SettingsLayout::InitializeWindows() {
|
||||
this->advancedDropdown->SetFocusOrder(order++);
|
||||
this->updateDropdown->SetFocusOrder(order++);
|
||||
|
||||
this->AddWindow(this->libraryTypeDropdown);
|
||||
this->AddWindow(this->localLibraryLayout);
|
||||
this->AddWindow(this->localeDropdown);
|
||||
this->AddWindow(this->outputDriverDropdown);
|
||||
@ -612,7 +622,15 @@ void SettingsLayout::LoadPreferences() {
|
||||
? _TSTR("settings_transport_type_gapless")
|
||||
: _TSTR("settings_transport_type_crossfade");
|
||||
|
||||
this->transportDropdown->SetText(arrow + _TSTR("settings_transport_type") + transportName);
|
||||
this->transportDropdown->SetText(arrow + _TSTR("settings_transport_type") + transportName);
|
||||
|
||||
/* library type */
|
||||
std::string libraryType =
|
||||
(ILibrary::Type) prefs->GetInt(core::prefs::keys::LibraryType, (int) ILibrary::Type::Local) == ILibrary::Type::Local
|
||||
? _TSTR("settings_library_type_local")
|
||||
: _TSTR("settings_library_type_remote");
|
||||
|
||||
this->libraryTypeDropdown->SetText(arrow + _TSTR("settings_library_type") + libraryType);
|
||||
}
|
||||
|
||||
void SettingsLayout::UpdateServerAvailability() {
|
||||
|
@ -91,6 +91,7 @@ namespace musik { namespace cube {
|
||||
|
||||
void OnCheckboxChanged(cursespp::Checkbox* checkbox, bool checked);
|
||||
|
||||
void OnLibraryTypeDropdownActivated(cursespp::TextLabel* label);
|
||||
void OnOutputDriverDropdownActivated(cursespp::TextLabel* label);
|
||||
void OnOutputDeviceDropdownActivated(cursespp::TextLabel* label);
|
||||
void OnReplayGainDropdownActivated(cursespp::TextLabel* label);
|
||||
@ -112,6 +113,7 @@ namespace musik { namespace cube {
|
||||
std::shared_ptr<musik::core::Preferences> prefs;
|
||||
|
||||
using Text = std::shared_ptr<cursespp::TextLabel>;
|
||||
Text libraryTypeDropdown;
|
||||
Text localeDropdown;
|
||||
Text outputDriverDropdown;
|
||||
Text outputDeviceDropdown;
|
||||
|
@ -34,9 +34,12 @@
|
||||
|
||||
#include <stdafx.h>
|
||||
|
||||
#include "LocaleOverlay.h"
|
||||
#include "SettingsOverlays.h"
|
||||
|
||||
#include <core/i18n/Locale.h>
|
||||
#include <core/support/Preferences.h>
|
||||
#include <core/support/PreferenceKeys.h>
|
||||
#include <core/library/ILibrary.h>
|
||||
|
||||
#include <cursespp/App.h>
|
||||
#include <cursespp/SimpleScrollAdapter.h>
|
||||
@ -46,6 +49,7 @@
|
||||
using namespace musik;
|
||||
using namespace musik::core;
|
||||
using namespace musik::cube;
|
||||
using namespace musik::cube::SettingsOverlays;
|
||||
using namespace cursespp;
|
||||
|
||||
using Callback = std::function<void()>;
|
||||
@ -65,12 +69,9 @@ static void showNeedsRestart(Callback cb = Callback()) {
|
||||
App::Overlays().Push(dialog);
|
||||
}
|
||||
|
||||
LocaleOverlay::LocaleOverlay() {
|
||||
}
|
||||
|
||||
static std::vector<std::string> allLocales;
|
||||
|
||||
void LocaleOverlay::Show(std::function<void()> callback) {
|
||||
void musik::cube::SettingsOverlays::ShowLocaleOverlay(std::function<void()> callback) {
|
||||
auto locale = i18n::Locale::Instance();
|
||||
|
||||
using Adapter = cursespp::SimpleScrollAdapter;
|
||||
@ -86,7 +87,7 @@ void LocaleOverlay::Show(std::function<void()> callback) {
|
||||
for (size_t i = 0; i < allLocales.size(); i++) {
|
||||
adapter->AddEntry(allLocales[i]);
|
||||
if (allLocales[i] == currentLocale) {
|
||||
selectedIndex = (int) i;
|
||||
selectedIndex = (int)i;
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,5 +105,37 @@ void LocaleOverlay::Show(std::function<void()> callback) {
|
||||
}
|
||||
});
|
||||
|
||||
cursespp::App::Overlays().Push(dialog);
|
||||
}
|
||||
|
||||
void musik::cube::SettingsOverlays::ShowLibraryTypeOverlay(std::function<void()> callback) {
|
||||
auto prefs = Preferences::ForComponent(prefs::components::Settings);
|
||||
|
||||
auto libraryType = (ILibrary::Type) prefs->GetInt(
|
||||
prefs::keys::LibraryType, (int) ILibrary::Type::Local);
|
||||
|
||||
using Adapter = cursespp::SimpleScrollAdapter;
|
||||
using ListOverlay = cursespp::ListOverlay;
|
||||
|
||||
std::shared_ptr<Adapter> adapter(new 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;
|
||||
|
||||
std::shared_ptr<ListOverlay> dialog(new ListOverlay());
|
||||
|
||||
dialog->SetAdapter(adapter)
|
||||
.SetTitle(_TSTR("settings_library_type_overlay_title"))
|
||||
.SetSelectedIndex(selectedIndex)
|
||||
.SetItemSelectedCallback(
|
||||
[prefs, callback]
|
||||
(ListOverlay* overlay, IScrollAdapterPtr adapter, size_t index) {
|
||||
auto updatedType = index == 0 ? ILibrary::Type::Local : ILibrary::Type::Remote;
|
||||
prefs->SetInt(prefs::keys::LibraryType, (int)updatedType);
|
||||
callback();
|
||||
});
|
||||
|
||||
cursespp::App::Overlays().Push(dialog);
|
||||
}
|
@ -36,14 +36,13 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace musik {
|
||||
namespace cube {
|
||||
class LocaleOverlay {
|
||||
public:
|
||||
static void Show(std::function<void()> callback);
|
||||
namespace musik { namespace cube {
|
||||
|
||||
namespace SettingsOverlays {
|
||||
|
||||
void ShowLocaleOverlay(std::function<void()> callback);
|
||||
|
||||
void ShowLibraryTypeOverlay(std::function<void()> callback);
|
||||
|
||||
private:
|
||||
LocaleOverlay();
|
||||
};
|
||||
}
|
||||
}
|
||||
} }
|
@ -105,6 +105,14 @@
|
||||
"settings_server_use_ipv6": "use ipv6",
|
||||
"settings_enable_transparency": "enable transparency support",
|
||||
|
||||
"settings_library_type": "library type: ",
|
||||
"settings_library_type_local": "local",
|
||||
"settings_library_type_remote": "remote",
|
||||
"settings_library_type_remote_hostname": "hostname",
|
||||
"settings_library_type_remote_port": "port",
|
||||
"settings_library_type_remote_password": "password",
|
||||
"settings_library_type_overlay_title": "library type",
|
||||
|
||||
"settings_preamp": "preamp and replaygain",
|
||||
"settings_preamp_label": "preamp gain (dB):",
|
||||
"settings_preamp_invalid_gain_title": "invalid gain",
|
||||
|
@ -804,13 +804,13 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
|
||||
<ClCompile Include="app\overlay\ColorThemeOverlay.cpp" />
|
||||
<ClCompile Include="app\overlay\EqualizerOverlay.cpp" />
|
||||
<ClCompile Include="app\overlay\LastFmOverlay.cpp" />
|
||||
<ClCompile Include="app\overlay\LocaleOverlay.cpp" />
|
||||
<ClCompile Include="app\overlay\PlaybackOverlays.cpp" />
|
||||
<ClCompile Include="app\overlay\PlayQueueOverlays.cpp" />
|
||||
<ClCompile Include="app\overlay\PluginOverlay.cpp" />
|
||||
<ClCompile Include="app\overlay\PreampOverlay.cpp" />
|
||||
<ClCompile Include="app\overlay\ReassignHotkeyOverlay.cpp" />
|
||||
<ClCompile Include="app\overlay\ServerOverlay.cpp" />
|
||||
<ClCompile Include="app\overlay\SettingsOverlays.cpp" />
|
||||
<ClCompile Include="app\overlay\TrackOverlays.cpp" />
|
||||
<ClCompile Include="app\overlay\VisualizerOverlay.cpp" />
|
||||
<ClCompile Include="app\util\ConsoleLogger.cpp" />
|
||||
@ -888,13 +888,13 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
|
||||
<ClInclude Include="app\overlay\ColorThemeOverlay.h" />
|
||||
<ClInclude Include="app\overlay\EqualizerOverlay.h" />
|
||||
<ClInclude Include="app\overlay\LastFmOverlay.h" />
|
||||
<ClInclude Include="app\overlay\LocaleOverlay.h" />
|
||||
<ClInclude Include="app\overlay\PlaybackOverlays.h" />
|
||||
<ClInclude Include="app\overlay\PlayQueueOverlays.h" />
|
||||
<ClInclude Include="app\overlay\PluginOverlay.h" />
|
||||
<ClInclude Include="app\overlay\PreampOverlay.h" />
|
||||
<ClInclude Include="app\overlay\ReassignHotkeyOverlay.h" />
|
||||
<ClInclude Include="app\overlay\ServerOverlay.h" />
|
||||
<ClInclude Include="app\overlay\SettingsOverlays.h" />
|
||||
<ClInclude Include="app\overlay\TrackOverlays.h" />
|
||||
<ClInclude Include="app\overlay\VisualizerOverlay.h" />
|
||||
<ClInclude Include="app\util\ConsoleLogger.h" />
|
||||
|
@ -60,9 +60,6 @@
|
||||
<ClCompile Include="app\overlay\ColorThemeOverlay.cpp">
|
||||
<Filter>app\overlay</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="app\overlay\LocaleOverlay.cpp">
|
||||
<Filter>app\overlay</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="app\overlay\ServerOverlay.cpp">
|
||||
<Filter>app\overlay</Filter>
|
||||
</ClCompile>
|
||||
@ -201,6 +198,9 @@
|
||||
<ClCompile Include="app\layout\LocalLibrarySettingsLayout.cpp">
|
||||
<Filter>app\layout</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="app\overlay\SettingsOverlays.cpp">
|
||||
<Filter>app\overlay</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h" />
|
||||
@ -265,9 +265,6 @@
|
||||
<ClInclude Include="app\overlay\ColorThemeOverlay.h">
|
||||
<Filter>app\overlay</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="app\overlay\LocaleOverlay.h">
|
||||
<Filter>app\overlay</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="app\util\Messages.h">
|
||||
<Filter>app\util</Filter>
|
||||
</ClInclude>
|
||||
@ -457,6 +454,9 @@
|
||||
<ClInclude Include="app\layout\LocalLibrarySettingsLayout.h">
|
||||
<Filter>app\layout</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="app\overlay\SettingsOverlays.h">
|
||||
<Filter>app\overlay</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="cursespp">
|
||||
|
Loading…
x
Reference in New Issue
Block a user