Settings layout fixes

This commit is contained in:
casey langen 2020-10-15 02:24:42 -07:00
parent 3aff937387
commit 1b0eb27fc9
2 changed files with 21 additions and 12 deletions

View File

@ -89,7 +89,7 @@ void RemoteLibrarySettingsLayout::OnLayout() {
this->httpPortInput->MoveAndResize(labelWidth + 1, y++, 5, 1); this->httpPortInput->MoveAndResize(labelWidth + 1, y++, 5, 1);
this->pwLabel->MoveAndResize(0, y, labelWidth, 1); this->pwLabel->MoveAndResize(0, y, labelWidth, 1);
this->pwInput->MoveAndResize(labelWidth + 1, y++, inputWidth, 1); this->pwInput->MoveAndResize(labelWidth + 1, y++, inputWidth, 1);
this->ipv6Cb->MoveAndResize(labelWidth - 3, y++, cx - labelWidth, 1); //this->ipv6Cb->MoveAndResize(labelWidth - 3, y++, cx - labelWidth, 1);
} }
void RemoteLibrarySettingsLayout::InitializeWindows() { void RemoteLibrarySettingsLayout::InitializeWindows() {
@ -112,8 +112,8 @@ void RemoteLibrarySettingsLayout::InitializeWindows() {
this->pwInput.reset(new TextInput(TextInput::StyleLine)); this->pwInput.reset(new TextInput(TextInput::StyleLine));
this->pwInput->SetInputMode(IInput::InputPassword); this->pwInput->SetInputMode(IInput::InputPassword);
this->ipv6Cb.reset(new Checkbox()); //this->ipv6Cb.reset(new Checkbox());
this->ipv6Cb->SetText(_TSTR("settings_server_use_ipv6")); //this->ipv6Cb->SetText(_TSTR("settings_server_use_ipv6"));
this->AddWindow(this->hostLabel); this->AddWindow(this->hostLabel);
this->AddWindow(this->hostInput); this->AddWindow(this->hostInput);
@ -125,14 +125,14 @@ void RemoteLibrarySettingsLayout::InitializeWindows() {
this->AddWindow(this->httpPortInput); this->AddWindow(this->httpPortInput);
this->AddWindow(this->pwLabel); this->AddWindow(this->pwLabel);
this->AddWindow(this->pwInput); this->AddWindow(this->pwInput);
this->AddWindow(this->ipv6Cb); //this->AddWindow(this->ipv6Cb);
int order = 0; int order = 0;
this->hostInput->SetFocusOrder(order++); this->hostInput->SetFocusOrder(order++);
this->wssPortInput->SetFocusOrder(order++); this->wssPortInput->SetFocusOrder(order++);
this->httpPortInput->SetFocusOrder(order++); this->httpPortInput->SetFocusOrder(order++);
this->pwInput->SetFocusOrder(order++); this->pwInput->SetFocusOrder(order++);
this->ipv6Cb->SetFocusOrder(order++); //this->ipv6Cb->SetFocusOrder(order++);
} }
void RemoteLibrarySettingsLayout::LoadPreferences() { void RemoteLibrarySettingsLayout::LoadPreferences() {
@ -140,12 +140,12 @@ void RemoteLibrarySettingsLayout::LoadPreferences() {
auto wssPort = (short) prefs->GetInt(core::prefs::keys::RemoteLibraryWssPort, 7905); auto wssPort = (short) prefs->GetInt(core::prefs::keys::RemoteLibraryWssPort, 7905);
auto httpPort = (short) prefs->GetInt(core::prefs::keys::RemoteLibraryHttpPort, 7906); auto httpPort = (short) prefs->GetInt(core::prefs::keys::RemoteLibraryHttpPort, 7906);
auto password = prefs->GetString(core::prefs::keys::RemoteLibraryPassword, ""); auto password = prefs->GetString(core::prefs::keys::RemoteLibraryPassword, "");
auto ipv6 = prefs->GetBool(core::prefs::keys::RemoteLibraryIpv6, false); //auto ipv6 = prefs->GetBool(core::prefs::keys::RemoteLibraryIpv6, false);
this->hostInput->SetText(host); this->hostInput->SetText(host);
this->wssPortInput->SetText(std::to_string(wssPort)); this->wssPortInput->SetText(std::to_string(wssPort));
this->httpPortInput->SetText(std::to_string(httpPort)); this->httpPortInput->SetText(std::to_string(httpPort));
this->pwInput->SetText(password); this->pwInput->SetText(password);
this->ipv6Cb->SetChecked(ipv6); //this->ipv6Cb->SetChecked(ipv6);
} }
void RemoteLibrarySettingsLayout::SavePreferences() { void RemoteLibrarySettingsLayout::SavePreferences() {
@ -153,7 +153,7 @@ void RemoteLibrarySettingsLayout::SavePreferences() {
auto wssPort = std::stoi(this->wssPortInput->GetText()); auto wssPort = std::stoi(this->wssPortInput->GetText());
auto httpPort = std::stoi(this->httpPortInput->GetText()); auto httpPort = std::stoi(this->httpPortInput->GetText());
auto password = this->pwInput->GetText(); auto password = this->pwInput->GetText();
auto ipv6 = this->ipv6Cb->IsChecked(); //auto ipv6 = this->ipv6Cb->IsChecked();
if (wssPort > 65535 || wssPort < 0) { wssPort = 7905; } if (wssPort > 65535 || wssPort < 0) { wssPort = 7905; }
if (httpPort > 65535 || httpPort < 0) { httpPort = 7905; } if (httpPort > 65535 || httpPort < 0) { httpPort = 7905; }
@ -162,7 +162,7 @@ void RemoteLibrarySettingsLayout::SavePreferences() {
prefs->SetInt(core::prefs::keys::RemoteLibraryWssPort, wssPort); prefs->SetInt(core::prefs::keys::RemoteLibraryWssPort, wssPort);
prefs->SetInt(core::prefs::keys::RemoteLibraryHttpPort, httpPort); prefs->SetInt(core::prefs::keys::RemoteLibraryHttpPort, httpPort);
prefs->SetString(core::prefs::keys::RemoteLibraryPassword, password.c_str()); prefs->SetString(core::prefs::keys::RemoteLibraryPassword, password.c_str());
prefs->SetBool(core::prefs::keys::RemoteLibraryIpv6, ipv6); //prefs->SetBool(core::prefs::keys::RemoteLibraryIpv6, ipv6);
auto library = LibraryFactory::Instance().DefaultRemoteLibrary(); auto library = LibraryFactory::Instance().DefaultRemoteLibrary();
auto remoteLibrary = std::dynamic_pointer_cast<RemoteLibrary>(library); auto remoteLibrary = std::dynamic_pointer_cast<RemoteLibrary>(library);

View File

@ -327,15 +327,24 @@ void SettingsLayout::OnLayout() {
/* top row (library config) */ /* top row (library config) */
this->libraryTypeDropdown->MoveAndResize(1, 1, cx - 1, LABEL_HEIGHT); this->libraryTypeDropdown->MoveAndResize(1, 1, cx - 1, LABEL_HEIGHT);
std::shared_ptr<LayoutBase> libraryLayout; std::shared_ptr<LayoutBase> libraryLayout;
static const int kLibraryTypePadding = 5;
if (this->library->GetType() == ILibrary::Type::Local) { if (this->library->GetType() == ILibrary::Type::Local) {
int libraryLayoutHeight = std::min(12, cy / 2); const int libraryLayoutHeight = std::min(12, cy / 2);
this->localLibraryLayout->MoveAndResize(3, 2, cx - 4, libraryLayoutHeight); this->localLibraryLayout->MoveAndResize(
kLibraryTypePadding,
2,
cx - (kLibraryTypePadding * 2),
libraryLayoutHeight);
this->remoteLibraryLayout->Hide(); this->remoteLibraryLayout->Hide();
libraryLayout = this->localLibraryLayout; libraryLayout = this->localLibraryLayout;
} }
else { else {
this->localLibraryLayout->Hide(); this->localLibraryLayout->Hide();
this->remoteLibraryLayout->MoveAndResize(2, 3, cx - 4, 5); this->remoteLibraryLayout->MoveAndResize(
kLibraryTypePadding,
3,
cx - (kLibraryTypePadding * 2),
4);
libraryLayout = this->remoteLibraryLayout; libraryLayout = this->remoteLibraryLayout;
} }
libraryLayout->Show(); libraryLayout->Show();