WebPositive: Use BSpinner to set days of history setting

Also rename fDaysInHistoryMenuControl to just fDaysInHistory
This commit is contained in:
John Scipione
2015-08-22 15:15:04 -07:00
parent 4f11457556
commit 49a4e7f685
2 changed files with 19 additions and 40 deletions
+17 -38
View File
@@ -19,6 +19,7 @@
#include <ScrollView.h> #include <ScrollView.h>
#include <SeparatorView.h> #include <SeparatorView.h>
#include <SpaceLayoutItem.h> #include <SpaceLayoutItem.h>
#include <Spinner.h>
#include <TabView.h> #include <TabView.h>
#include <TextControl.h> #include <TextControl.h>
#include <debugger.h> #include <debugger.h>
@@ -303,18 +304,14 @@ SettingsWindow::_CreateGeneralPage(float spacing)
fNewTabBehaviorMenu = new BMenuField("new tab behavior", fNewTabBehaviorMenu = new BMenuField("new tab behavior",
B_TRANSLATE("New tabs:"), newTabBehaviorMenu); B_TRANSLATE("New tabs:"), newTabBehaviorMenu);
fDaysInHistoryMenuControl = new BTextControl("days in history", fDaysInHistory = new BSpinner("days in history",
B_TRANSLATE("Number of days to keep links in History menu:"), "", B_TRANSLATE("Number of days to keep links in History menu:"),
new BMessage(MSG_HISTORY_MENU_DAYS_CHANGED)); new BMessage(MSG_HISTORY_MENU_DAYS_CHANGED));
fDaysInHistoryMenuControl->SetModificationMessage( fDaysInHistory->SetPrecision(0);
new BMessage(MSG_HISTORY_MENU_DAYS_CHANGED)); fDaysInHistory->SetRange(1, 35);
BString maxHistoryAge; fDaysInHistory->SetStep(1);
maxHistoryAge << BrowsingHistory::DefaultInstance()->MaxHistoryItemAge(); fDaysInHistory->SetValue(
fDaysInHistoryMenuControl->SetText(maxHistoryAge.String()); BrowsingHistory::DefaultInstance()->MaxHistoryItemAge());
for (uchar i = 0; i < '0'; i++)
fDaysInHistoryMenuControl->TextView()->DisallowChar(i);
for (uchar i = '9' + 1; i <= 128; i++)
fDaysInHistoryMenuControl->TextView()->DisallowChar(i);
fShowTabsIfOnlyOnePage = new BCheckBox("show tabs if only one page", fShowTabsIfOnlyOnePage = new BCheckBox("show tabs if only one page",
B_TRANSLATE("Show tabs if only one page is open"), B_TRANSLATE("Show tabs if only one page is open"),
@@ -360,7 +357,7 @@ SettingsWindow::_CreateGeneralPage(float spacing)
.Add(fAutoHideInterfaceInFullscreenMode) .Add(fAutoHideInterfaceInFullscreenMode)
.Add(fAutoHidePointer) .Add(fAutoHidePointer)
.Add(fShowHomeButton) .Add(fShowHomeButton)
.Add(fDaysInHistoryMenuControl) .Add(fDaysInHistory)
.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing)) .Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing))
.SetInsets(spacing, spacing, spacing, spacing) .SetInsets(spacing, spacing, spacing, spacing)
@@ -580,7 +577,7 @@ SettingsWindow::_CanApplySettings() const
canApply = canApply || ((fShowHomeButton->Value() == B_CONTROL_ON) canApply = canApply || ((fShowHomeButton->Value() == B_CONTROL_ON)
!= fSettings->GetValue(kSettingsKeyShowHomeButton, true)); != fSettings->GetValue(kSettingsKeyShowHomeButton, true));
canApply = canApply || (_MaxHistoryAge() canApply = canApply || (fDaysInHistory->Value()
!= BrowsingHistory::DefaultInstance()->MaxHistoryItemAge()); != BrowsingHistory::DefaultInstance()->MaxHistoryItemAge());
// New window policy // New window policy
@@ -639,12 +636,8 @@ void
SettingsWindow::_ApplySettings() SettingsWindow::_ApplySettings()
{ {
// Store general settings // Store general settings
int32 maxHistoryAge = _MaxHistoryAge(); BrowsingHistory::DefaultInstance()->SetMaxHistoryItemAge(
BString text; (uint32)fDaysInHistory->Value());
text << maxHistoryAge;
fDaysInHistoryMenuControl->SetText(text.String());
BrowsingHistory::DefaultInstance()->SetMaxHistoryItemAge(maxHistoryAge);
fSettings->SetValue(kSettingsKeyStartPageURL, fStartPageControl->Text()); fSettings->SetValue(kSettingsKeyStartPageURL, fStartPageControl->Text());
fSettings->SetValue(kSettingsKeySearchPageURL, fSearchPageControl->Text()); fSettings->SetValue(kSettingsKeySearchPageURL, fSearchPageControl->Text());
fSettings->SetValue(kSettingsKeyDownloadPath, fDownloadFolderControl->Text()); fSettings->SetValue(kSettingsKeyDownloadPath, fDownloadFolderControl->Text());
@@ -712,7 +705,6 @@ SettingsWindow::_ApplySettings()
// the default values, unless the page settings have local overrides. // the default values, unless the page settings have local overrides.
BWebSettings::Default()->Apply(); BWebSettings::Default()->Apply();
_ValidateControlsEnabledStatus(); _ValidateControlsEnabledStatus();
} }
@@ -738,9 +730,8 @@ SettingsWindow::_RevertSettings()
fShowHomeButton->SetValue( fShowHomeButton->SetValue(
fSettings->GetValue(kSettingsKeyShowHomeButton, true)); fSettings->GetValue(kSettingsKeyShowHomeButton, true));
BString text; fDaysInHistory->SetValue(
text << BrowsingHistory::DefaultInstance()->MaxHistoryItemAge(); BrowsingHistory::DefaultInstance()->MaxHistoryItemAge());
fDaysInHistoryMenuControl->SetText(text.String());
// New window policy // New window policy
uint32 newWindowPolicy = fSettings->GetValue(kSettingsKeyNewWindowPolicy, uint32 newWindowPolicy = fSettings->GetValue(kSettingsKeyNewWindowPolicy,
@@ -800,9 +791,9 @@ SettingsWindow::_RevertSettings()
false)); false));
fProxyAddressControl->SetText(fSettings->GetValue(kSettingsKeyProxyAddress, fProxyAddressControl->SetText(fSettings->GetValue(kSettingsKeyProxyAddress,
"")); ""));
text = ""; BString keyProxyPort;
text << fSettings->GetValue(kSettingsKeyProxyPort, (uint32)0); keyProxyPort << fSettings->GetValue(kSettingsKeyProxyPort, (uint32)0);
fProxyPortControl->SetText(text.String()); fProxyPortControl->SetText(keyProxyPort.String());
fUseProxyAuthCheckBox->SetValue(fSettings->GetValue(kSettingsKeyUseProxyAuth, fUseProxyAuthCheckBox->SetValue(fSettings->GetValue(kSettingsKeyUseProxyAuth,
false)); false));
fProxyUsernameControl->SetText(fSettings->GetValue(kSettingsKeyProxyUsername, fProxyUsernameControl->SetText(fSettings->GetValue(kSettingsKeyProxyUsername,
@@ -865,18 +856,6 @@ SettingsWindow::_NewTabPolicy() const
} }
int32
SettingsWindow::_MaxHistoryAge() const
{
int32 maxHistoryAge = atoi(fDaysInHistoryMenuControl->Text());
if (maxHistoryAge <= 0)
maxHistoryAge = 1;
if (maxHistoryAge >= 35)
maxHistoryAge = 35;
return maxHistoryAge;
}
void void
SettingsWindow::_SetSizesMenuValue(BMenu* menu, int32 value) SettingsWindow::_SetSizesMenuValue(BMenu* menu, int32 value)
{ {
+2 -2
View File
@@ -13,6 +13,7 @@ class BCheckBox;
class BMenu; class BMenu;
class BMenuField; class BMenuField;
class BMenuItem; class BMenuItem;
class BSpinner;
class BTextControl; class BTextControl;
class FontSelectionView; class FontSelectionView;
class SettingsMessage; class SettingsMessage;
@@ -46,7 +47,6 @@ private:
uint32 _NewWindowPolicy() const; uint32 _NewWindowPolicy() const;
uint32 _NewTabPolicy() const; uint32 _NewTabPolicy() const;
int32 _MaxHistoryAge() const;
void _SetSizesMenuValue(BMenu* menu, int32 value); void _SetSizesMenuValue(BMenu* menu, int32 value);
int32 _SizesMenuValue(BMenu* menu) const; int32 _SizesMenuValue(BMenu* menu) const;
@@ -73,7 +73,7 @@ private:
BMenuItem* fNewTabBehaviorOpenSearchItem; BMenuItem* fNewTabBehaviorOpenSearchItem;
BMenuItem* fNewTabBehaviorOpenBlankItem; BMenuItem* fNewTabBehaviorOpenBlankItem;
BTextControl* fDaysInHistoryMenuControl; BSpinner* fDaysInHistory;
BCheckBox* fShowTabsIfOnlyOnePage; BCheckBox* fShowTabsIfOnlyOnePage;
BCheckBox* fAutoHideInterfaceInFullscreenMode; BCheckBox* fAutoHideInterfaceInFullscreenMode;
BCheckBox* fAutoHidePointer; BCheckBox* fAutoHidePointer;