Simplified quitting. Propagate settings from window to application/settings when they change instead of collecting them when quitting.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34060 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
fa1ee6d4d1
commit
34bdaab8bd
@ -52,7 +52,6 @@ public:
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void AboutRequested();
|
||||
virtual bool QuitRequested();
|
||||
|
||||
private:
|
||||
Settings fSettings;
|
||||
@ -187,19 +186,6 @@ LocalePreflet::AboutRequested()
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
LocalePreflet::QuitRequested()
|
||||
{
|
||||
if (fLocaleWindow != NULL) {
|
||||
fLocaleWindow->PostMessage(B_QUIT_REQUESTED);
|
||||
fLocaleWindow = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
|
@ -13,7 +13,7 @@ extern const char* kSignature;
|
||||
|
||||
static const uint32 kMsgCountrySelection = 'csel';
|
||||
static const uint32 kMsgSettingsChanged = 'SeCh';
|
||||
static const uint32 kMsgSelectLanguage = 'slng';
|
||||
static const uint32 kMsgPrefLanguagesChanged = 'lang';
|
||||
static const uint32 kMsgDefaults = 'dflt';
|
||||
static const uint32 kMsgRevert = 'revt';
|
||||
|
||||
|
@ -107,6 +107,7 @@ class LanguageListView: public BListView
|
||||
fDropIndex = -1;
|
||||
}
|
||||
}
|
||||
Invoke(new BMessage(kMsgPrefLanguagesChanged));
|
||||
} else BListView::MessageReceived(message);
|
||||
}
|
||||
private:
|
||||
@ -297,7 +298,8 @@ LanguageListView::MouseMoved(BPoint where, uint32 transit, const BMessage* msg)
|
||||
LocaleWindow::LocaleWindow()
|
||||
:
|
||||
BWindow(BRect(0, 0, 0, 0), "Locale", B_TITLED_WINDOW, B_NOT_RESIZABLE
|
||||
| B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
|
||||
| B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS
|
||||
| B_QUIT_ON_WINDOW_CLOSE)
|
||||
{
|
||||
BCountry* defaultCountry;
|
||||
be_locale_roster->GetDefaultCountry(&defaultCountry);
|
||||
@ -453,27 +455,6 @@ LocaleWindow::LocaleWindow()
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
LocaleWindow::QuitRequested()
|
||||
{
|
||||
BMessage update(kMsgSettingsChanged);
|
||||
update.AddPoint("window_location", Frame().LeftTop());
|
||||
int index = 0;
|
||||
while (index < fPreferredListView->CountItems()) {
|
||||
update.AddString("language", static_cast<LanguageListItem*>
|
||||
(fPreferredListView->ItemAt(index))->LanguageCode());
|
||||
index++;
|
||||
}
|
||||
// TODO also save Country tab settings
|
||||
be_app_messenger.SendMessage(&update);
|
||||
|
||||
be_app_messenger.SendMessage(B_QUIT_REQUESTED);
|
||||
be_app_messenger.SendMessage(B_QUIT_REQUESTED);
|
||||
// app eats the first message
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LocaleWindow::MessageReceived(BMessage* message)
|
||||
{
|
||||
@ -486,6 +467,19 @@ LocaleWindow::MessageReceived(BMessage* message)
|
||||
// TODO
|
||||
break;
|
||||
|
||||
case kMsgPrefLanguagesChanged:
|
||||
{
|
||||
BMessage update(kMsgSettingsChanged);
|
||||
int index = 0;
|
||||
while (index < fPreferredListView->CountItems()) {
|
||||
update.AddString("language", static_cast<LanguageListItem*>
|
||||
(fPreferredListView->ItemAt(index))->LanguageCode());
|
||||
index++;
|
||||
}
|
||||
be_app_messenger.SendMessage(&update);
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgCountrySelection:
|
||||
{
|
||||
// Country selection changed.
|
||||
@ -511,3 +505,12 @@ LocaleWindow::MessageReceived(BMessage* message)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LocaleWindow::FrameMoved(BPoint newPosition)
|
||||
{
|
||||
BMessage update(kMsgSettingsChanged);
|
||||
update.AddPoint("window_location", newPosition);
|
||||
be_app_messenger.SendMessage(&update);
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,8 @@ class LocaleWindow : public BWindow {
|
||||
public:
|
||||
LocaleWindow();
|
||||
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void FrameMoved(BPoint newPosition);
|
||||
|
||||
private:
|
||||
BButton* fRevertButton;
|
||||
|
Loading…
x
Reference in New Issue
Block a user