Fix several issues in Screen preflet.
- Always initialize other menu item data member. - Always use refresh_rate_to_string() to generate item labels. - When searching for the item matching the selected refresh rate, look for it by the actual refresh rate stored in the item's message rather than by string comparisons of the label. - Don't assume the Other menu item exists, since it doesn't in cases where the refresh rate constraints only allow a single rate. - Update copyright year. Fixes #8431.
This commit is contained in:
parent
1674a53a45
commit
7e44de362f
@ -1,11 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2011, Haiku.
|
* Copyright 2001-2012, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Rafael Romo
|
* Rafael Romo
|
||||||
* Stefano Ceccherini (burton666@libero.it)
|
* Stefano Ceccherini (burton666@libero.it)
|
||||||
* Andrew Bachmann
|
* Andrew Bachmann
|
||||||
|
* Rene Gollent, rene@gollent.com
|
||||||
* Thomas Kurschel
|
* Thomas Kurschel
|
||||||
* Axel Dörfler, axeld@pinc-software.de
|
* Axel Dörfler, axeld@pinc-software.de
|
||||||
* Stephan Aßmus <superstippi@gmx.de>
|
* Stephan Aßmus <superstippi@gmx.de>
|
||||||
@ -171,6 +172,7 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings)
|
|||||||
fIsVesa(false),
|
fIsVesa(false),
|
||||||
fBootWorkspaceApplied(false),
|
fBootWorkspaceApplied(false),
|
||||||
fScreenMode(this),
|
fScreenMode(this),
|
||||||
|
fOtherRefresh(NULL),
|
||||||
fUndoScreenMode(this),
|
fUndoScreenMode(this),
|
||||||
fModified(false)
|
fModified(false)
|
||||||
{
|
{
|
||||||
@ -315,11 +317,7 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings)
|
|||||||
// This is a special case for drivers that only support a single
|
// This is a special case for drivers that only support a single
|
||||||
// frequency, like the VESA driver
|
// frequency, like the VESA driver
|
||||||
BString name;
|
BString name;
|
||||||
name << min << " " << B_TRANSLATE("Hz");
|
refresh_rate_to_string(min, name);
|
||||||
|
|
||||||
message = new BMessage(POP_REFRESH_MSG);
|
|
||||||
message->AddFloat("refresh", min);
|
|
||||||
|
|
||||||
fRefreshMenu->AddItem(item = new BMenuItem(name.String(), message));
|
fRefreshMenu->AddItem(item = new BMenuItem(name.String(), message));
|
||||||
item->SetEnabled(false);
|
item->SetEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
@ -663,29 +661,29 @@ ScreenWindow::_CheckRefreshMenu()
|
|||||||
void
|
void
|
||||||
ScreenWindow::_UpdateRefreshControl()
|
ScreenWindow::_UpdateRefreshControl()
|
||||||
{
|
{
|
||||||
BString string;
|
for (int32 i = 0; i < fRefreshMenu->CountItems(); i++) {
|
||||||
refresh_rate_to_string(fSelected.refresh, string);
|
BMenuItem* item = fRefreshMenu->ItemAt(i);
|
||||||
|
if (item->Message()->FindFloat("refresh") == fSelected.refresh) {
|
||||||
BMenuItem* item = fRefreshMenu->FindItem(string.String());
|
|
||||||
if (item) {
|
|
||||||
if (!item->IsMarked())
|
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
|
|
||||||
// "Other" items only contains a refresh rate when active
|
// "Other" items only contains a refresh rate when active
|
||||||
fOtherRefresh->SetLabel(B_TRANSLATE("Other" B_UTF8_ELLIPSIS));
|
fOtherRefresh->SetLabel(B_TRANSLATE("Other" B_UTF8_ELLIPSIS));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// this is a non-standard refresh rate
|
// this is a non-standard refresh rate
|
||||||
|
if (fOtherRefresh != NULL) {
|
||||||
fOtherRefresh->Message()->ReplaceFloat("refresh", fSelected.refresh);
|
fOtherRefresh->Message()->ReplaceFloat("refresh", fSelected.refresh);
|
||||||
fOtherRefresh->SetMarked(true);
|
fOtherRefresh->SetMarked(true);
|
||||||
|
|
||||||
|
BString string;
|
||||||
|
refresh_rate_to_string(fSelected.refresh, string);
|
||||||
fRefreshMenu->Superitem()->SetLabel(string.String());
|
fRefreshMenu->Superitem()->SetLabel(string.String());
|
||||||
|
|
||||||
string.Append(B_TRANSLATE("/other" B_UTF8_ELLIPSIS));
|
string.Append(B_TRANSLATE("/other" B_UTF8_ELLIPSIS));
|
||||||
fOtherRefresh->SetLabel(string.String());
|
fOtherRefresh->SetLabel(string.String());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user