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:
committed by
waddlesplash
parent
0ca55d11eb
commit
20e0f7607c
@@ -8,6 +8,7 @@
|
|||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <CheckBox.h>
|
#include <CheckBox.h>
|
||||||
#include <ControlLook.h>
|
#include <ControlLook.h>
|
||||||
|
#include <FilePanel.h>
|
||||||
#include <GridLayoutBuilder.h>
|
#include <GridLayoutBuilder.h>
|
||||||
#include <GroupLayout.h>
|
#include <GroupLayout.h>
|
||||||
#include <GroupLayoutBuilder.h>
|
#include <GroupLayoutBuilder.h>
|
||||||
@@ -70,6 +71,9 @@ enum {
|
|||||||
MSG_USE_PROXY_AUTH_CHANGED = 'upsa',
|
MSG_USE_PROXY_AUTH_CHANGED = 'upsa',
|
||||||
MSG_PROXY_USERNAME_CHANGED = 'psuc',
|
MSG_PROXY_USERNAME_CHANGED = 'psuc',
|
||||||
MSG_PROXY_PASSWORD_CHANGED = 'pswc',
|
MSG_PROXY_PASSWORD_CHANGED = 'pswc',
|
||||||
|
|
||||||
|
MSG_CHOOSE_DOWNLOAD_FOLDER = 'swop',
|
||||||
|
MSG_HANDLE_DOWNLOAD_FOLDER = 'oprs',
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int32 kDefaultFontSize = 14;
|
static const int32 kDefaultFontSize = 14;
|
||||||
@@ -88,6 +92,8 @@ SettingsWindow::SettingsWindow(BRect frame, SettingsMessage* settings)
|
|||||||
fRevertButton = new BButton(B_TRANSLATE("Revert"),
|
fRevertButton = new BButton(B_TRANSLATE("Revert"),
|
||||||
new BMessage(MSG_REVERT));
|
new BMessage(MSG_REVERT));
|
||||||
|
|
||||||
|
fOpenFilePanel = NULL;
|
||||||
|
|
||||||
float spacing = be_control_look->DefaultItemSpacing();
|
float spacing = be_control_look->DefaultItemSpacing();
|
||||||
|
|
||||||
BTabView* tabView = new BTabView("settings pages", B_WIDTH_FROM_LABEL);
|
BTabView* tabView = new BTabView("settings pages", B_WIDTH_FROM_LABEL);
|
||||||
@@ -144,6 +150,7 @@ SettingsWindow::~SettingsWindow()
|
|||||||
delete fSansSerifFontView;
|
delete fSansSerifFontView;
|
||||||
RemoveHandler(fFixedFontView);
|
RemoveHandler(fFixedFontView);
|
||||||
delete fFixedFontView;
|
delete fFixedFontView;
|
||||||
|
delete fOpenFilePanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -161,7 +168,12 @@ SettingsWindow::MessageReceived(BMessage* message)
|
|||||||
case MSG_REVERT:
|
case MSG_REVERT:
|
||||||
_RevertSettings();
|
_RevertSettings();
|
||||||
break;
|
break;
|
||||||
|
case MSG_CHOOSE_DOWNLOAD_FOLDER:
|
||||||
|
_ChooseDownloadFolder(message);
|
||||||
|
break;
|
||||||
|
case MSG_HANDLE_DOWNLOAD_FOLDER:
|
||||||
|
_HandleDownloadPanelResult(fOpenFilePanel, message);
|
||||||
|
break;
|
||||||
case MSG_STANDARD_FONT_SIZE_SELECTED:
|
case MSG_STANDARD_FONT_SIZE_SELECTED:
|
||||||
{
|
{
|
||||||
int32 size = _SizesMenuValue(fStandardSizesMenu->Menu());
|
int32 size = _SizesMenuValue(fStandardSizesMenu->Menu());
|
||||||
@@ -286,6 +298,8 @@ SettingsWindow::_CreateGeneralPage(float spacing)
|
|||||||
fNewTabBehaviorOpenBlankItem = new BMenuItem(
|
fNewTabBehaviorOpenBlankItem = new BMenuItem(
|
||||||
B_TRANSLATE("Open blank page"),
|
B_TRANSLATE("Open blank page"),
|
||||||
new BMessage(MSG_NEW_TABS_BEHAVIOR_CHANGED));
|
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);
|
fNewWindowBehaviorOpenHomeItem->SetMarked(true);
|
||||||
fNewTabBehaviorOpenBlankItem->SetMarked(true);
|
fNewTabBehaviorOpenBlankItem->SetMarked(true);
|
||||||
@@ -340,11 +354,12 @@ SettingsWindow::_CreateGeneralPage(float spacing)
|
|||||||
.Add(fSearchPageControl->CreateLabelLayoutItem(), 0, 1)
|
.Add(fSearchPageControl->CreateLabelLayoutItem(), 0, 1)
|
||||||
.Add(fSearchPageControl->CreateTextViewLayoutItem(), 1, 1)
|
.Add(fSearchPageControl->CreateTextViewLayoutItem(), 1, 1)
|
||||||
|
|
||||||
.Add(fDownloadFolderControl->CreateLabelLayoutItem(), 0, 2)
|
.Add(fNewWindowBehaviorMenu->CreateLabelLayoutItem(), 0, 2)
|
||||||
.Add(fDownloadFolderControl->CreateTextViewLayoutItem(), 1, 2)
|
.Add(fNewWindowBehaviorMenu->CreateMenuBarLayoutItem(), 1, 2)
|
||||||
|
|
||||||
.Add(fNewWindowBehaviorMenu->CreateLabelLayoutItem(), 0, 3)
|
.Add(fDownloadFolderControl->CreateLabelLayoutItem(), 0, 3)
|
||||||
.Add(fNewWindowBehaviorMenu->CreateMenuBarLayoutItem(), 1, 3)
|
.Add(fDownloadFolderControl->CreateTextViewLayoutItem(), 1, 3)
|
||||||
|
.Add(fChooseButton, 2, 3)
|
||||||
|
|
||||||
.Add(fNewTabBehaviorMenu->CreateLabelLayoutItem(), 0, 4)
|
.Add(fNewTabBehaviorMenu->CreateLabelLayoutItem(), 0, 4)
|
||||||
.Add(fNewTabBehaviorMenu->CreateMenuBarLayoutItem(), 1, 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
|
void
|
||||||
SettingsWindow::_ValidateControlsEnabledStatus()
|
SettingsWindow::_ValidateControlsEnabledStatus()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
class BButton;
|
class BButton;
|
||||||
class BCheckBox;
|
class BCheckBox;
|
||||||
class BMenu;
|
class BMenu;
|
||||||
@@ -17,6 +18,7 @@ class BSpinner;
|
|||||||
class BTextControl;
|
class BTextControl;
|
||||||
class FontSelectionView;
|
class FontSelectionView;
|
||||||
class SettingsMessage;
|
class SettingsMessage;
|
||||||
|
class BFilePanel;
|
||||||
|
|
||||||
|
|
||||||
class SettingsWindow : public BWindow {
|
class SettingsWindow : public BWindow {
|
||||||
@@ -43,6 +45,10 @@ private:
|
|||||||
bool _CanApplySettings() const;
|
bool _CanApplySettings() const;
|
||||||
void _ApplySettings();
|
void _ApplySettings();
|
||||||
void _RevertSettings();
|
void _RevertSettings();
|
||||||
|
void _ChooseDownloadFolder(const BMessage* message);
|
||||||
|
|
||||||
|
void _HandleDownloadPanelResult(BFilePanel* panel,
|
||||||
|
const BMessage* message);
|
||||||
void _ValidateControlsEnabledStatus();
|
void _ValidateControlsEnabledStatus();
|
||||||
|
|
||||||
uint32 _NewWindowPolicy() const;
|
uint32 _NewWindowPolicy() const;
|
||||||
@@ -94,9 +100,12 @@ private:
|
|||||||
BButton* fApplyButton;
|
BButton* fApplyButton;
|
||||||
BButton* fCancelButton;
|
BButton* fCancelButton;
|
||||||
BButton* fRevertButton;
|
BButton* fRevertButton;
|
||||||
|
BButton* fChooseButton;
|
||||||
|
|
||||||
BMenuField* fStandardSizesMenu;
|
BMenuField* fStandardSizesMenu;
|
||||||
BMenuField* fFixedSizesMenu;
|
BMenuField* fFixedSizesMenu;
|
||||||
|
|
||||||
|
BFilePanel* fOpenFilePanel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user