WebPositive: Add support to show/hide bookmark bar
Default is shown, a menu option in the View menu allows you to show or hide the bar. Also move the bookmark bar below the tab frame, it looks better here I think and matches other browsers (e.g. Firefox.)
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 2010 Stephan Aßmus <[email protected]>
|
||||
* Copyright (C) 2010 Michael Lotz <[email protected]>
|
||||
* Copyright (C) 2010 Rene Gollent <[email protected]>
|
||||
* Copyright 2013 Haiku, Inc. All rights reserved.
|
||||
* Copyright 2013-2014 Haiku, Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -101,6 +101,7 @@ enum {
|
||||
HOME = 'home',
|
||||
GOTO_URL = 'goul',
|
||||
RELOAD = 'reld',
|
||||
SHOW_HIDE_BOOKMARK_BAR = 'shbb',
|
||||
CLEAR_HISTORY = 'clhs',
|
||||
|
||||
CREATE_BOOKMARK = 'crbm',
|
||||
@@ -572,6 +573,10 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
|
||||
menu = new BMenu(B_TRANSLATE("View"));
|
||||
menu->AddItem(new BMenuItem(B_TRANSLATE("Reload"), new BMessage(RELOAD),
|
||||
'R'));
|
||||
// the label will be replaced with the appropriate text later on
|
||||
fBookmarkBarMenuItem = new BMenuItem("Show/Hide bookmark bar",
|
||||
new BMessage(SHOW_HIDE_BOOKMARK_BAR));
|
||||
menu->AddItem(fBookmarkBarMenuItem);
|
||||
menu->AddSeparatorItem();
|
||||
menu->AddItem(new BMenuItem(B_TRANSLATE("Increase size"),
|
||||
new BMessage(ZOOM_FACTOR_INCREASE), '+'));
|
||||
@@ -715,15 +720,23 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
|
||||
.Add(toggleFullscreenButton, 0.0f)
|
||||
;
|
||||
|
||||
fBookmarkBar = new BookmarkBar("Bookmarks", this, &bookmarkRef);
|
||||
if (fAppSettings->GetValue(kSettingsShowBookmarkBar, true)) {
|
||||
// We need to hide the bookmark bar and then show it again
|
||||
// to save the setting and set the menu item label.
|
||||
fBookmarkBar->Hide();
|
||||
_ShowBookmarkBar(true);
|
||||
} else
|
||||
_ShowBookmarkBar(false);
|
||||
|
||||
// Layout
|
||||
AddChild(BLayoutBuilder::Group<>(B_VERTICAL, 0.0)
|
||||
#if !INTEGRATE_MENU_INTO_TAB_BAR
|
||||
.Add(menuBarGroup)
|
||||
#endif
|
||||
.Add(new BookmarkBar(B_TRANSLATE("Bookmarks"), this,
|
||||
&bookmarkRef))
|
||||
.Add(fTabManager->TabGroup())
|
||||
.Add(navigationGroup)
|
||||
.Add(fBookmarkBar)
|
||||
.Add(fTabManager->ContainerView())
|
||||
.Add(findGroup)
|
||||
.Add(statusGroup)
|
||||
@@ -917,6 +930,10 @@ BrowserWindow::MessageReceived(BMessage* message)
|
||||
CurrentWebView()->Reload();
|
||||
break;
|
||||
|
||||
case SHOW_HIDE_BOOKMARK_BAR:
|
||||
_ShowBookmarkBar(fBookmarkBar->IsHidden());
|
||||
break;
|
||||
|
||||
case GOTO_URL:
|
||||
{
|
||||
BString url;
|
||||
@@ -1229,6 +1246,9 @@ BrowserWindow::MessageReceived(BMessage* message)
|
||||
fHomeButton->Show();
|
||||
else
|
||||
fHomeButton->Hide();
|
||||
} else if (name == kSettingsShowBookmarkBar
|
||||
&& message->FindBool("value", &flag) == B_OK) {
|
||||
_ShowBookmarkBar(flag);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2627,3 +2647,21 @@ BrowserWindow::_HandlePageSourceResult(const BMessage* message)
|
||||
alert->Go(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BrowserWindow::_ShowBookmarkBar(bool show)
|
||||
{
|
||||
if (fBookmarkBar == NULL || fBookmarkBar->IsHidden() != show)
|
||||
return;
|
||||
|
||||
fAppSettings->SetValue(kSettingsShowBookmarkBar, show);
|
||||
|
||||
fBookmarkBarMenuItem->SetLabel(show
|
||||
? B_TRANSLATE("Hide bookmark bar")
|
||||
: B_TRANSLATE("Show bookmark bar"));
|
||||
if (show)
|
||||
fBookmarkBar->Show();
|
||||
else
|
||||
fBookmarkBar->Hide();
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
* Copyright (C) 2007 Ryan Leavengood <[email protected]>
|
||||
* Copyright (C) 2009 Maxime Simon <[email protected]>
|
||||
* Copyright (C) 2010 Stephan Aßmus <[email protected]>
|
||||
*
|
||||
* All rights reserved.
|
||||
* Copyright 2013-2014 Haiku, Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -48,6 +47,8 @@ class BStringView;
|
||||
class BTextControl;
|
||||
class BUrlContext;
|
||||
class BWebView;
|
||||
|
||||
class BookmarkBar;
|
||||
class SettingsMessage;
|
||||
class TabManager;
|
||||
class URLInputGroup;
|
||||
@@ -209,6 +210,8 @@ private:
|
||||
void _HandlePageSourceResult(
|
||||
const BMessage* message);
|
||||
|
||||
void _ShowBookmarkBar(bool show);
|
||||
|
||||
private:
|
||||
BMenu* fHistoryMenu;
|
||||
int32 fHistoryMenuFixedItemCount;
|
||||
@@ -266,6 +269,9 @@ private:
|
||||
uint32 fNewTabPolicy;
|
||||
BString fStartPageURL;
|
||||
BString fSearchPageURL;
|
||||
|
||||
BMenuItem* fBookmarkBarMenuItem;
|
||||
BookmarkBar* fBookmarkBar;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Stephan Aßmus <[email protected]>
|
||||
* Coptright 2014 Haiku, Inc. All rights reserved.
|
||||
*
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Stephan Aßmus, [email protected]
|
||||
* John Scipione, [email protected]
|
||||
*/
|
||||
|
||||
|
||||
#include "SettingsKeys.h"
|
||||
|
||||
|
||||
const char* kSettingsKeyDownloadPath = "download path";
|
||||
const char* kSettingsKeyShowTabsIfSinglePageOpen
|
||||
= "show tabs if single page open";
|
||||
@@ -31,3 +38,5 @@ const char* kSettingsKeyProxyPort = "http proxy port";
|
||||
const char* kSettingsKeyUseProxyAuth = "use http proxy authentication";
|
||||
const char* kSettingsKeyProxyUsername = "http proxy username";
|
||||
const char* kSettingsKeyProxyPassword = "http proxy password";
|
||||
|
||||
const char* kSettingsShowBookmarkBar = "show bookmarks bar";
|
||||
@@ -1,11 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Stephan Aßmus <[email protected]>
|
||||
* Coptright 2014 Haiku, Inc. All rights reserved.
|
||||
*
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Stephan Aßmus, [email protected]
|
||||
* John Scipione, [email protected]
|
||||
*/
|
||||
#ifndef SETTINGS_KEYS_H
|
||||
#define SETTINGS_KEYS_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
@@ -31,4 +37,6 @@ extern const char* kSettingsKeyUseProxyAuth;
|
||||
extern const char* kSettingsKeyProxyUsername;
|
||||
extern const char* kSettingsKeyProxyPassword;
|
||||
|
||||
extern const char* kSettingsShowBookmarkBar;
|
||||
|
||||
#endif // SETTINGS_KEYS_H
|
||||
|
||||
Reference in New Issue
Block a user