WebPositive: Add default download folder location option.

Change-Id: I76e90646c5e7d9a4082cd1c237047c0eda16b9e6
Reviewed-on: https://review.haiku-os.org/786
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Rajagopalan-Gangadharan
2018-12-25 18:48:14 +00:00
committed by waddlesplash
parent 0ca55d11eb
commit 20e0f7607c
2 changed files with 56 additions and 5 deletions
+47 -5
View File
@@ -8,6 +8,7 @@
#include <Button.h>
#include <CheckBox.h>
#include <ControlLook.h>
#include <FilePanel.h>
#include <GridLayoutBuilder.h>
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
@@ -70,6 +71,9 @@ enum {
MSG_USE_PROXY_AUTH_CHANGED = 'upsa',
MSG_PROXY_USERNAME_CHANGED = 'psuc',
MSG_PROXY_PASSWORD_CHANGED = 'pswc',
MSG_CHOOSE_DOWNLOAD_FOLDER = 'swop',
MSG_HANDLE_DOWNLOAD_FOLDER = 'oprs',
};
static const int32 kDefaultFontSize = 14;
@@ -88,6 +92,8 @@ SettingsWindow::SettingsWindow(BRect frame, SettingsMessage* settings)
fRevertButton = new BButton(B_TRANSLATE("Revert"),
new BMessage(MSG_REVERT));
fOpenFilePanel = NULL;
float spacing = be_control_look->DefaultItemSpacing();
BTabView* tabView = new BTabView("settings pages", B_WIDTH_FROM_LABEL);
@@ -144,6 +150,7 @@ SettingsWindow::~SettingsWindow()
delete fSansSerifFontView;
RemoveHandler(fFixedFontView);
delete fFixedFontView;
delete fOpenFilePanel;
}
@@ -161,7 +168,12 @@ SettingsWindow::MessageReceived(BMessage* message)
case MSG_REVERT:
_RevertSettings();
break;
case MSG_CHOOSE_DOWNLOAD_FOLDER:
_ChooseDownloadFolder(message);
break;
case MSG_HANDLE_DOWNLOAD_FOLDER:
_HandleDownloadPanelResult(fOpenFilePanel, message);
break;
case MSG_STANDARD_FONT_SIZE_SELECTED:
{
int32 size = _SizesMenuValue(fStandardSizesMenu->Menu());
@@ -286,6 +298,8 @@ SettingsWindow::_CreateGeneralPage(float spacing)
fNewTabBehaviorOpenBlankItem = new BMenuItem(
B_TRANSLATE("Open blank page"),
new BMessage(MSG_NEW_TABS_BEHAVIOR_CHANGED));
fChooseButton = new BButton(B_TRANSLATE("Browse" B_UTF8_ELLIPSIS),
new BMessage(MSG_CHOOSE_DOWNLOAD_FOLDER));
fNewWindowBehaviorOpenHomeItem->SetMarked(true);
fNewTabBehaviorOpenBlankItem->SetMarked(true);
@@ -340,11 +354,12 @@ SettingsWindow::_CreateGeneralPage(float spacing)
.Add(fSearchPageControl->CreateLabelLayoutItem(), 0, 1)
.Add(fSearchPageControl->CreateTextViewLayoutItem(), 1, 1)
.Add(fDownloadFolderControl->CreateLabelLayoutItem(), 0, 2)
.Add(fDownloadFolderControl->CreateTextViewLayoutItem(), 1, 2)
.Add(fNewWindowBehaviorMenu->CreateLabelLayoutItem(), 0, 2)
.Add(fNewWindowBehaviorMenu->CreateMenuBarLayoutItem(), 1, 2)
.Add(fNewWindowBehaviorMenu->CreateLabelLayoutItem(), 0, 3)
.Add(fNewWindowBehaviorMenu->CreateMenuBarLayoutItem(), 1, 3)
.Add(fDownloadFolderControl->CreateLabelLayoutItem(), 0, 3)
.Add(fDownloadFolderControl->CreateTextViewLayoutItem(), 1, 3)
.Add(fChooseButton, 2, 3)
.Add(fNewTabBehaviorMenu->CreateLabelLayoutItem(), 0, 4)
.Add(fNewTabBehaviorMenu->CreateMenuBarLayoutItem(), 1, 4)
@@ -794,6 +809,33 @@ SettingsWindow::_RevertSettings()
}
void
SettingsWindow::_ChooseDownloadFolder(const BMessage* message)
{
if (fOpenFilePanel == NULL) {
BMessenger target(this);
fOpenFilePanel = new (std::nothrow) BFilePanel(B_OPEN_PANEL,
&target, NULL, B_DIRECTORY_NODE);
}
BMessage panelMessage(MSG_HANDLE_DOWNLOAD_FOLDER);
fOpenFilePanel->SetMessage(&panelMessage);
fOpenFilePanel->Show();
}
void
SettingsWindow:: _HandleDownloadPanelResult(BFilePanel* panel,
const BMessage* message)
{
entry_ref ref;
if (message->FindRef("refs", 0, &ref) == B_OK)
{
BPath path(&ref);
fDownloadFolderControl->SetText(path.Path());
}
}
void
SettingsWindow::_ValidateControlsEnabledStatus()
{
+9
View File
@@ -8,6 +8,7 @@
#include <Window.h>
class BButton;
class BCheckBox;
class BMenu;
@@ -17,6 +18,7 @@ class BSpinner;
class BTextControl;
class FontSelectionView;
class SettingsMessage;
class BFilePanel;
class SettingsWindow : public BWindow {
@@ -43,6 +45,10 @@ private:
bool _CanApplySettings() const;
void _ApplySettings();
void _RevertSettings();
void _ChooseDownloadFolder(const BMessage* message);
void _HandleDownloadPanelResult(BFilePanel* panel,
const BMessage* message);
void _ValidateControlsEnabledStatus();
uint32 _NewWindowPolicy() const;
@@ -94,9 +100,12 @@ private:
BButton* fApplyButton;
BButton* fCancelButton;
BButton* fRevertButton;
BButton* fChooseButton;
BMenuField* fStandardSizesMenu;
BMenuField* fFixedSizesMenu;
BFilePanel* fOpenFilePanel;
};