Notifications: Fix pluralization, max/min window width font size dependend
Plus, use kWidthStep when loading/saving slider setting. Fixes #16119 Change-Id: I2c86bb008a8d9e089d9db09013c9af67b0f5e731 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2902 Reviewed-by: Kacper Kasper <kacperkasper@gmail.com>
This commit is contained in:
parent
7522ed82b8
commit
437e3c1c06
@ -27,6 +27,7 @@
|
||||
#include <Query.h>
|
||||
#include <Roster.h>
|
||||
#include <String.h>
|
||||
#include <StringFormat.h>
|
||||
#include <SymLink.h>
|
||||
#include <Volume.h>
|
||||
#include <VolumeRoster.h>
|
||||
@ -76,19 +77,16 @@ GeneralView::GeneralView(SettingsHost* host)
|
||||
box->SetLabel(fNotificationBox);
|
||||
|
||||
// Window width
|
||||
int32 minWidth = int32(kMinimumWidth / kWidthStep);
|
||||
int32 maxWidth = int32(kMaximumWidth / kWidthStep);
|
||||
fWidthSlider = new BSlider("width", B_TRANSLATE("Window width:"),
|
||||
float ratio = be_plain_font->Size() / 12.f;
|
||||
int32 minWidth = int32(kMinimumWidth / kWidthStep * ratio);
|
||||
int32 maxWidth = int32(kMaximumWidth / kWidthStep * ratio);
|
||||
fWidthSlider = new BSlider("width", B_TRANSLATE("Window width"),
|
||||
new BMessage(kWidthChanged), minWidth, maxWidth, B_HORIZONTAL);
|
||||
fWidthSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
|
||||
fWidthSlider->SetHashMarkCount(maxWidth - minWidth + 1);
|
||||
BString minWidthLabel;
|
||||
minWidthLabel << int32(kMinimumWidth);
|
||||
BString maxWidthLabel;
|
||||
maxWidthLabel << int32(kMaximumWidth);
|
||||
fWidthSlider->SetLimitLabels(
|
||||
B_TRANSLATE_COMMENT(minWidthLabel.String(), "Slider low text"),
|
||||
B_TRANSLATE_COMMENT(maxWidthLabel.String(), "Slider high text"));
|
||||
B_TRANSLATE_COMMENT("narrow", "Window width: Slider low text"),
|
||||
B_TRANSLATE_COMMENT("wide", "Window width: Slider high text"));
|
||||
|
||||
// Display time
|
||||
fDurationSlider = new BSlider("duration", B_TRANSLATE("Duration:"),
|
||||
@ -167,8 +165,6 @@ GeneralView::MessageReceived(BMessage* msg)
|
||||
break;
|
||||
}
|
||||
case kWidthChanged: {
|
||||
int32 value = fWidthSlider->Value() * 50;
|
||||
_SetWidthLabel(value);
|
||||
SettingsPane::SettingsChanged(true);
|
||||
break;
|
||||
}
|
||||
@ -238,7 +234,7 @@ GeneralView::Save(BMessage& settings)
|
||||
int32 timeout = fDurationSlider->Value();
|
||||
settings.AddInt32(kTimeoutName, timeout);
|
||||
|
||||
float width = fWidthSlider->Value() * 50;
|
||||
float width = fWidthSlider->Value() * kWidthStep;
|
||||
settings.AddFloat(kWidthName, width);
|
||||
|
||||
icon_size iconSize = B_LARGE_ICON;
|
||||
@ -256,8 +252,7 @@ GeneralView::Revert()
|
||||
fDurationSlider->SetValue(fOriginalTimeout);
|
||||
_SetTimeoutLabel(fOriginalTimeout);
|
||||
|
||||
fWidthSlider->SetValue(fOriginalWidth / 50);
|
||||
_SetWidthLabel(fOriginalWidth);
|
||||
fWidthSlider->SetValue(fOriginalWidth / kWidthStep);
|
||||
|
||||
fNewPosition = fOriginalPosition;
|
||||
BMenuItem* item = fPositionMenu->ItemAt(
|
||||
@ -276,7 +271,7 @@ GeneralView::RevertPossible()
|
||||
if (fOriginalTimeout != timeout)
|
||||
return true;
|
||||
|
||||
int32 width = fWidthSlider->Value() * 50;
|
||||
int32 width = fWidthSlider->Value() * kWidthStep;
|
||||
if (fOriginalWidth != width)
|
||||
return true;
|
||||
|
||||
@ -293,8 +288,7 @@ GeneralView::Defaults()
|
||||
fDurationSlider->SetValue(kDefaultTimeout);
|
||||
_SetTimeoutLabel(kDefaultTimeout);
|
||||
|
||||
fWidthSlider->SetValue(kDefaultWidth / 50);
|
||||
_SetWidthLabel(kDefaultWidth);
|
||||
fWidthSlider->SetValue(kDefaultWidth / kWidthStep);
|
||||
|
||||
fNewPosition = kDefaultNotificationPosition;
|
||||
BMenuItem* item = fPositionMenu->ItemAt(
|
||||
@ -313,7 +307,7 @@ GeneralView::DefaultsPossible()
|
||||
if (kDefaultTimeout != timeout)
|
||||
return true;
|
||||
|
||||
int32 width = fWidthSlider->Value() * 50;
|
||||
int32 width = fWidthSlider->Value() * kWidthStep;
|
||||
if (kDefaultWidth != width)
|
||||
return true;
|
||||
|
||||
@ -347,25 +341,15 @@ GeneralView::_EnableControls()
|
||||
void
|
||||
GeneralView::_SetTimeoutLabel(int32 value)
|
||||
{
|
||||
BString label(B_TRANSLATE("Timeout:"));
|
||||
label.Append(" ");
|
||||
label << value;
|
||||
label.Append(" ").Append(B_TRANSLATE("seconds"));
|
||||
static BStringFormat format(B_TRANSLATE("{0, plural, "
|
||||
"=1{Timeout: # second}"
|
||||
"other{Timeout: # seconds}}"));
|
||||
BString label;
|
||||
format.Format(label, value);
|
||||
fDurationSlider->SetLabel(label.String());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GeneralView::_SetWidthLabel(int32 value)
|
||||
{
|
||||
BString label(B_TRANSLATE("Width:"));
|
||||
label.Append(" ");
|
||||
label << value;
|
||||
label.Append(" ").Append(B_TRANSLATE("pixels"));
|
||||
fWidthSlider->SetLabel(label.String());
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
GeneralView::_IsServerRunning()
|
||||
{
|
||||
|
@ -51,7 +51,6 @@ private:
|
||||
uint32 fNewPosition;
|
||||
|
||||
void _EnableControls();
|
||||
void _SetWidthLabel(int32 value);
|
||||
void _SetTimeoutLabel(int32 value);
|
||||
bool _IsServerRunning();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user