bool ViewerChangeUsernameWindow::changeUsername(const std::string &host) { HostProfileList *profiles = ViewerServerManager::GetClientAtts(); if(!instance) instance = new ViewerChangeUsernameWindow(); // Enter the local event loop for the dialog. #if !defined(_WIN32) viewerSubject->BlockSocketSignals(true); #endif VisItChangeUsernameWindow::ReturnCode status = VisItChangeUsernameWindow::UW_Rejected; instance->username = ""; QString name = instance->getUsername(host.c_str(), status); #if !defined(_WIN32) viewerSubject->BlockSocketSignals(false); #endif if (status == UW_Accepted) { // Accepted; hit return or Okay. std::string new_username(name.toStdString()); if (new_username.empty()) return false; instance->username = new_username; MachineProfile *mp = profiles->GetMachineProfileForHost(host); if (mp != NULL) mp->SetUserName(new_username); profiles->SelectAll(); profiles->Notify(); return true; } // Rejected or cancelled. return false; }
void ConfigureSystem::applyConfiguration() { if (!enabled) return; bool modified = false; // apply username // TODO(wwylele): Use this when we move to Qt 5.5 // std::u16string new_username = ui->edit_username->text().toStdU16String(); std::u16string new_username( reinterpret_cast<const char16_t*>(ui->edit_username->text().utf16())); if (new_username != username) { Service::CFG::SetUsername(new_username); modified = true; } // apply birthday int new_birthmonth = ui->combo_birthmonth->currentIndex() + 1; int new_birthday = ui->combo_birthday->currentIndex() + 1; if (birthmonth != new_birthmonth || birthday != new_birthday) { Service::CFG::SetBirthday(new_birthmonth, new_birthday); modified = true; } // apply language int new_language = ui->combo_language->currentIndex(); if (language_index != new_language) { Service::CFG::SetSystemLanguage(static_cast<Service::CFG::SystemLanguage>(new_language)); modified = true; } // apply sound int new_sound = ui->combo_sound->currentIndex(); if (sound_index != new_sound) { Service::CFG::SetSoundOutputMode(static_cast<Service::CFG::SoundOutputMode>(new_sound)); modified = true; } // update the config savegame if any item is modified. if (modified) Service::CFG::UpdateConfigNANDSavegame(); }