added info + error messages;
fixed the behavior of the Cancel button
This commit is contained in:
parent
5835587c0a
commit
c498a95b4d
3 changed files with 59 additions and 2 deletions
|
@ -159,6 +159,7 @@ OptionsWindow :: OptionsWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||||
void
|
void
|
||||||
OptionsWindow :: onCancelButtonClicked(void) throw ()
|
OptionsWindow :: onCancelButtonClicked(void) throw ()
|
||||||
{
|
{
|
||||||
|
resetEntries();
|
||||||
onCloseButtonClicked(false);
|
onCloseButtonClicked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,6 +173,7 @@ OptionsWindow :: onApplyButtonClicked(void) throw ()
|
||||||
Ptr<OptionsContainer>::Ref
|
Ptr<OptionsContainer>::Ref
|
||||||
optionsContainer = gLiveSupport->getOptionsContainer();
|
optionsContainer = gLiveSupport->getOptionsContainer();
|
||||||
|
|
||||||
|
bool changed = false;
|
||||||
StringEntryListType::const_iterator it;
|
StringEntryListType::const_iterator it;
|
||||||
for (it = stringEntryList.begin(); it != stringEntryList.end(); ++it) {
|
for (it = stringEntryList.begin(); it != stringEntryList.end(); ++it) {
|
||||||
|
|
||||||
|
@ -186,9 +188,27 @@ OptionsWindow :: onApplyButtonClicked(void) throw ()
|
||||||
if (*oldValue != *newValue) {
|
if (*oldValue != *newValue) {
|
||||||
try {
|
try {
|
||||||
optionsContainer->setOptionItem(optionItem, newValue);
|
optionsContainer->setOptionItem(optionItem, newValue);
|
||||||
|
changed = true;
|
||||||
|
} catch (std::invalid_argument &e) {
|
||||||
|
Ptr<Glib::ustring>::Ref
|
||||||
|
errorMessage(new Glib::ustring(
|
||||||
|
*getResourceUstring("errorMsg") ));
|
||||||
|
errorMessage->append(e.what());
|
||||||
|
gLiveSupport->displayMessageWindow(errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
|
try {
|
||||||
|
Ptr<Glib::ustring>::Ref
|
||||||
|
restartMessage(new Glib::ustring(
|
||||||
|
*getResourceUstring("needToRestartMsg") ));
|
||||||
|
gLiveSupport->displayMessageWindow(restartMessage);
|
||||||
} catch (std::invalid_argument &e) {
|
} catch (std::invalid_argument &e) {
|
||||||
// TODO: signal error
|
// TODO: signal error
|
||||||
}
|
std::cerr << e.what() << std::endl;
|
||||||
|
std::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,6 +233,7 @@ OptionsWindow :: onCloseButtonClicked(bool needConfirm) throw ()
|
||||||
{
|
{
|
||||||
if (needConfirm) {
|
if (needConfirm) {
|
||||||
// TODO: add confirmation dialog
|
// TODO: add confirmation dialog
|
||||||
|
// and either save changes or cancel them
|
||||||
}
|
}
|
||||||
gLiveSupport->putWindowPosition(shared_from_this());
|
gLiveSupport->putWindowPosition(shared_from_this());
|
||||||
hide();
|
hide();
|
||||||
|
@ -495,3 +516,28 @@ OptionsWindow :: constructAboutSection(void) throw ()
|
||||||
return section;
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Reset all user entries to their saved state.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
OptionsWindow :: resetEntries() throw ()
|
||||||
|
{
|
||||||
|
Ptr<OptionsContainer>::Ref optionsContainer
|
||||||
|
= gLiveSupport->getOptionsContainer();
|
||||||
|
|
||||||
|
StringEntryListType::iterator it;
|
||||||
|
for (it = stringEntryList.begin(); it != stringEntryList.end(); ++it) {
|
||||||
|
OptionsContainer::OptionItemString optionItem = it->first;
|
||||||
|
EntryBin * entry = it->second;
|
||||||
|
|
||||||
|
try {
|
||||||
|
entry->set_text(*optionsContainer->getOptionItem(optionItem));
|
||||||
|
|
||||||
|
} catch (std::invalid_argument &e) {
|
||||||
|
// TODO: signal error?
|
||||||
|
entry->set_text("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,12 @@ class OptionsWindow : public WhiteWindow, public LocalizedObject
|
||||||
createEntry(OptionsContainer::OptionItemString optionItem)
|
createEntry(OptionsContainer::OptionItemString optionItem)
|
||||||
throw ();
|
throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset all user entries to their saved state.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
resetEntries(void) throw ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the "Sound" section.
|
* Construct the "Sound" section.
|
||||||
*
|
*
|
||||||
|
|
|
@ -221,6 +221,11 @@ root:table
|
||||||
{
|
{
|
||||||
windowTitle:string { "LiveSupport Options Window" }
|
windowTitle:string { "LiveSupport Options Window" }
|
||||||
|
|
||||||
|
needToRestartMsg:string { "You will need to restart the "
|
||||||
|
"application\nfor the new settings "
|
||||||
|
"to take effect." }
|
||||||
|
errorMsg:string { "Could not save the options: " }
|
||||||
|
|
||||||
soundSectionLabel:string { "Sound" }
|
soundSectionLabel:string { "Sound" }
|
||||||
serversSectionLabel:string { "Servers" }
|
serversSectionLabel:string { "Servers" }
|
||||||
aboutSectionLabel:string { "About" }
|
aboutSectionLabel:string { "About" }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue