Locale: move "translate application names" checkbox to formatting tab

Part of #15511
This commit is contained in:
Adrien Destugues
2020-07-19 13:06:26 +02:00
parent 25f1ddecf7
commit 98e5fab3f4
4 changed files with 27 additions and 31 deletions
+16 -2
View File
@@ -59,6 +59,12 @@ FormatSettingsView::FormatSettingsView()
B_TRANSLATE("Use month/day-names from preferred language"), B_TRANSLATE("Use month/day-names from preferred language"),
new BMessage(kStringsLanguageChange)); new BMessage(kStringsLanguageChange));
fFilesystemTranslationCheckbox = new BCheckBox("filesystemTranslation",
B_TRANSLATE("Translate application and folder names"),
new BMessage(kMsgFilesystemTranslationChanged));
fFilesystemTranslationCheckbox->SetValue(
BLocaleRoster::Default()->IsFilesystemTranslationPreferred());
BStringView* fullDateLabel BStringView* fullDateLabel
= new BStringView("", B_TRANSLATE("Full format:")); = new BStringView("", B_TRANSLATE("Full format:"));
fullDateLabel->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, fullDateLabel->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
@@ -230,6 +236,7 @@ FormatSettingsView::FormatSettingsView()
SetViewUIColor(B_PANEL_BACKGROUND_COLOR); SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
BLayoutBuilder::Group<>(this, B_VERTICAL) BLayoutBuilder::Group<>(this, B_VERTICAL)
.Add(fFilesystemTranslationCheckbox)
.Add(fUseLanguageStringsCheckBox) .Add(fUseLanguageStringsCheckBox)
.Add(fDateBox) .Add(fDateBox)
.Add(fTimeBox) .Add(fTimeBox)
@@ -249,6 +256,7 @@ FormatSettingsView::~FormatSettingsView()
void void
FormatSettingsView::AttachedToWindow() FormatSettingsView::AttachedToWindow()
{ {
fFilesystemTranslationCheckbox->SetTarget(Window());
fUseLanguageStringsCheckBox->SetTarget(this); fUseLanguageStringsCheckBox->SetTarget(this);
f24HourRadioButton->SetTarget(this); f24HourRadioButton->SetTarget(this);
f12HourRadioButton->SetTarget(this); f12HourRadioButton->SetTarget(this);
@@ -315,6 +323,8 @@ FormatSettingsView::Revert()
MutableLocaleRoster::Default()->SetDefaultFormattingConventions( MutableLocaleRoster::Default()->SetDefaultFormattingConventions(
fInitialConventions); fInitialConventions);
fFilesystemTranslationCheckbox->SetValue(fInitialTranslateNames);
_UpdateExamples(); _UpdateExamples();
} }
@@ -324,8 +334,11 @@ FormatSettingsView::Refresh(bool setInitial)
{ {
BFormattingConventions conventions; BFormattingConventions conventions;
BLocale::Default()->GetFormattingConventions(&conventions); BLocale::Default()->GetFormattingConventions(&conventions);
if (setInitial) if (setInitial) {
fInitialConventions = conventions; fInitialConventions = conventions;
fInitialTranslateNames
= BLocaleRoster::Default()->IsFilesystemTranslationPreferred();
}
if (!conventions.Use24HourClock()) { if (!conventions.Use24HourClock()) {
f12HourRadioButton->SetValue(B_CONTROL_ON); f12HourRadioButton->SetValue(B_CONTROL_ON);
@@ -351,7 +364,8 @@ FormatSettingsView::IsReversible() const
BFormattingConventions conventions; BFormattingConventions conventions;
BLocale::Default()->GetFormattingConventions(&conventions); BLocale::Default()->GetFormattingConventions(&conventions);
return conventions != fInitialConventions; return (conventions != fInitialConventions)
|| (fFilesystemTranslationCheckbox->Value() != fInitialTranslateNames);
} }
@@ -23,6 +23,7 @@ class BTextControl;
static const uint32 kClockFormatChange = 'cfmc'; static const uint32 kClockFormatChange = 'cfmc';
static const uint32 kStringsLanguageChange = 'strc'; static const uint32 kStringsLanguageChange = 'strc';
static const uint32 kMsgFilesystemTranslationChanged = 'fsys';
class FormatSettingsView : public BView { class FormatSettingsView : public BView {
@@ -41,6 +42,7 @@ private:
void _UpdateExamples(); void _UpdateExamples();
private: private:
BCheckBox* fFilesystemTranslationCheckbox;
BCheckBox* fUseLanguageStringsCheckBox; BCheckBox* fUseLanguageStringsCheckBox;
BRadioButton* f24HourRadioButton; BRadioButton* f24HourRadioButton;
@@ -64,6 +66,7 @@ private:
bool fLocaleIs24Hour; bool fLocaleIs24Hour;
BFormattingConventions fInitialConventions; BFormattingConventions fInitialConventions;
bool fInitialTranslateNames;
BBox* fDateBox; BBox* fDateBox;
BBox* fTimeBox; BBox* fTimeBox;
+8 -28
View File
@@ -48,7 +48,6 @@ static const uint32 kMsgConventionsSelection = 'csel';
static const uint32 kMsgDefaults = 'dflt'; static const uint32 kMsgDefaults = 'dflt';
static const uint32 kMsgPreferredLanguagesChanged = 'lang'; static const uint32 kMsgPreferredLanguagesChanged = 'lang';
static const uint32 kMsgFilesystemTranslationChanged = 'fsys';
static int static int
@@ -71,8 +70,7 @@ LocaleWindow::LocaleWindow()
B_QUIT_ON_WINDOW_CLOSE | B_ASYNCHRONOUS_CONTROLS B_QUIT_ON_WINDOW_CLOSE | B_ASYNCHRONOUS_CONTROLS
| B_AUTO_UPDATE_SIZE_LIMITS), | B_AUTO_UPDATE_SIZE_LIMITS),
fInitialConventionsItem(NULL), fInitialConventionsItem(NULL),
fDefaultConventionsItem(NULL), fDefaultConventionsItem(NULL)
fFilesystemTranslationCheckbox(NULL)
{ {
SetLayout(new BGroupLayout(B_HORIZONTAL)); SetLayout(new BGroupLayout(B_HORIZONTAL));
@@ -185,8 +183,8 @@ LocaleWindow::LocaleWindow()
.SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING, .SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING,
B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING); B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING);
BView* countryTab = new BView(B_TRANSLATE("Formatting"), B_WILL_DRAW); BView* formattingTab = new BView(B_TRANSLATE("Formatting"), B_WILL_DRAW);
countryTab->SetLayout(new BGroupLayout(B_VERTICAL, 0)); formattingTab->SetLayout(new BGroupLayout(B_VERTICAL, 0));
fConventionsListView = new LanguageListView("formatting", fConventionsListView = new LanguageListView("formatting",
B_SINGLE_SELECTION_LIST); B_SINGLE_SELECTION_LIST);
@@ -242,12 +240,12 @@ LocaleWindow::LocaleWindow()
fInitialConventionsItem)); fInitialConventionsItem));
} }
fConventionsListView->SetExplicitMinSize(BSize(20 * be_plain_font->Size(), fConventionsListView->SetExplicitMinSize(BSize(21 * be_plain_font->Size(),
B_SIZE_UNSET)); B_SIZE_UNSET));
fFormatView = new FormatSettingsView(); fFormatView = new FormatSettingsView();
countryTab->AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, spacing) formattingTab->AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, spacing)
.AddGroup(B_VERTICAL, 3) .AddGroup(B_VERTICAL, 3)
.Add(scrollView) .Add(scrollView)
.End() .End()
@@ -255,25 +253,8 @@ LocaleWindow::LocaleWindow()
.SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING, .SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING,
B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING)); B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING));
BView* optionsTab = new BView(B_TRANSLATE("Options"), B_WILL_DRAW);
optionsTab->SetLayout(new BGroupLayout(B_VERTICAL, 0));
fFilesystemTranslationCheckbox = new BCheckBox("filesystemTranslation",
B_TRANSLATE("Translate application and folder names in Deskbar and Tracker."),
new BMessage(kMsgFilesystemTranslationChanged));
fFilesystemTranslationCheckbox->SetValue(
BLocaleRoster::Default()->IsFilesystemTranslationPreferred());
optionsTab->AddChild(BLayoutBuilder::Group<>(B_VERTICAL)
.Add(fFilesystemTranslationCheckbox)
.AddGlue()
.SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING,
B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING));
tabView->AddTab(languageTab); tabView->AddTab(languageTab);
tabView->AddTab(countryTab); tabView->AddTab(formattingTab);
tabView->AddTab(optionsTab);
BButton* button BButton* button
= new BButton(B_TRANSLATE("Defaults"), new BMessage(kMsgDefaults)); = new BButton(B_TRANSLATE("Defaults"), new BMessage(kMsgDefaults));
@@ -455,8 +436,9 @@ LocaleWindow::MessageReceived(BMessage* message)
case kMsgFilesystemTranslationChanged: case kMsgFilesystemTranslationChanged:
{ {
int32 value = message->FindInt32("be:value");
MutableLocaleRoster::Default()->SetFilesystemTranslationPreferred( MutableLocaleRoster::Default()->SetFilesystemTranslationPreferred(
fFilesystemTranslationCheckbox->Value()); value == B_CONTROL_ON);
BAlert* alert = new BAlert(B_TRANSLATE("Locale"), BAlert* alert = new BAlert(B_TRANSLATE("Locale"),
B_TRANSLATE("Deskbar and Tracker need to be restarted for this " B_TRANSLATE("Deskbar and Tracker need to be restarted for this "
@@ -664,6 +646,4 @@ LocaleWindow::_Defaults()
fDefaultConventionsItem)); fDefaultConventionsItem));
fConventionsListView->ScrollToSelection(); fConventionsListView->ScrollToSelection();
} }
fFilesystemTranslationCheckbox->SetValue(true);
} }
-1
View File
@@ -55,7 +55,6 @@ private:
LanguageListItem* fInitialConventionsItem; LanguageListItem* fInitialConventionsItem;
LanguageListItem* fDefaultConventionsItem; LanguageListItem* fDefaultConventionsItem;
BMessage fInitialPreferredLanguages; BMessage fInitialPreferredLanguages;
BCheckBox* fFilesystemTranslationCheckbox;
}; };