Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'upgrade-4.4.0'
  • Loading branch information
rainemak committed Apr 19, 2022
2 parents 47c2fc7 + 44b5786 commit 555b04b
Show file tree
Hide file tree
Showing 109 changed files with 3,278 additions and 1,550 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,3 +7,4 @@ moc_*.cpp
Makefile
*.so
RPMS/*
sailfish-browser.pro.user
355 changes: 0 additions & 355 deletions LICENSE.html

This file was deleted.

373 changes: 373 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -11,9 +11,9 @@ Maintainers
Engine and adaptation
---------------------
- Sailfish WebView - https://github.com/sailfishos/sailfish-components-webview
- QtMozEmbed - Qt bindings - https://git.sailfishos.org/mer-core/qtmozembed
- Embedlite components - https://git.sailfishos.org/mer-core/embedlite-components
- Gecko browser engine with embedlite API - https://git.sailfishos.org/mer-core/gecko-dev
- QtMozEmbed - Qt bindings - https://github.com/sailfishos/qtmozembed
- Embedlite components - https://github.com/sailfishos/embedlite-components
- Gecko browser engine with embedlite API - https://github.com/sailfishos/gecko-dev

Tools
-----
Expand Down
20 changes: 3 additions & 17 deletions apps/browser/bookmarks/bookmarkmanager.cpp
Expand Up @@ -25,22 +25,16 @@
BookmarkManager::BookmarkManager()
: QObject(nullptr)
{
m_clearBookmarksConfItem = new MGConfItem("/apps/sailfish-browser/actions/clear_bookmarks", this);

clearBookmarks();

connect(m_clearBookmarksConfItem.data(), &MGConfItem::valueChanged,
this, &BookmarkManager::clearBookmarks);
}

BookmarkManager* BookmarkManager::instance()
{
static BookmarkManager* singleton;
if (!singleton) {
static QPointer <BookmarkManager> singleton;
if (singleton.isNull()) {
singleton = new BookmarkManager();
}

return singleton;
return singleton.data();
}

void BookmarkManager::save(const QList<Bookmark*> & bookmarks)
Expand Down Expand Up @@ -152,11 +146,3 @@ QList<Bookmark*> BookmarkManager::load() {

return bookmarks;
}

void BookmarkManager::clearBookmarks()
{
if (m_clearBookmarksConfItem->value(false).toBool()) {
clear();
m_clearBookmarksConfItem->set(false);
}
}
8 changes: 2 additions & 6 deletions apps/browser/bookmarks/bookmarkmanager.h
Expand Up @@ -27,19 +27,15 @@ class BookmarkManager : public QObject
static BookmarkManager* instance();

void save(const QList<Bookmark*> & bookmarks);
void clear();
QList<Bookmark*> load();

Q_INVOKABLE void clear();

signals:
void cleared();

private slots:
void clearBookmarks();

private:
BookmarkManager();

QPointer<MGConfItem> m_clearBookmarksConfItem;
};

#endif // BOOKMARKMANAGER_H
10 changes: 10 additions & 0 deletions apps/browser/main.cpp
Expand Up @@ -37,7 +37,9 @@
#include "datafetcher.h"
#include "inputregion.h"
#include "searchenginemodel.h"
#include "secureaction.h"
#include "faviconmanager.h"
#include "bookmarkmanager.h"

#ifdef HAS_BOOSTER
#include <MDeclarativeCache>
Expand All @@ -53,6 +55,11 @@ static QObject *faviconmanager_factory(QQmlEngine *, QJSEngine *)
{
return FaviconManager::instance();
}

static QObject *bookmarkmanager_factory(QQmlEngine *, QJSEngine *)
{
return BookmarkManager::instance();
}
}

Q_DECL_EXPORT int main(int argc, char *argv[])
Expand All @@ -75,6 +82,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
QScopedPointer<QQuickView> view(new QQuickView);
#endif
app->setQuitOnLastWindowClosed(false);
app->setAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents, true);

BrowserService *service = new BrowserService(app.data());
// Handle command line launch
Expand Down Expand Up @@ -144,6 +152,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
qmlRegisterType<BookmarkFilterModel>(uri, 1, 0, "BookmarkFilterModel");
qmlRegisterType<DeclarativeLoginModel>(uri, 1, 0, "LoginModel");
qmlRegisterType<LoginFilterModel>(uri, 1, 0, "LoginFilterModel");
qmlRegisterSingletonType<BookmarkManager>(uri, 1, 0, "BookmarkManager", bookmarkmanager_factory);
}
qmlRegisterSingletonType<FaviconManager>(uri, 1, 0, "FaviconManager", faviconmanager_factory);
qmlRegisterUncreatableType<DownloadStatus>(uri, 1, 0, "DownloadStatus", "");
Expand All @@ -153,6 +162,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
qmlRegisterType<DesktopBookmarkWriter>(uri, 1, 0, "DesktopBookmarkWriter");
qmlRegisterType<DataFetcher>(uri, 1, 0, "DataFetcher");
qmlRegisterType<InputRegion>(uri, 1, 0, "InputRegion");
qmlRegisterType<SecureAction>(uri, 1, 0, "SecureAction");
qmlRegisterSingletonType<SearchEngineModel>(uri, 1, 0, "SearchEngineModel", search_model_factory);

Browser *browser = new Browser(view.data(), app.data());
Expand Down
2 changes: 1 addition & 1 deletion apps/browser/qml/browser.qml
Expand Up @@ -17,7 +17,7 @@ BrowserWindow {
id: window

function setBrowserCover(model) {
if (!model || model.count === 0) {
if (!model || model.count === 0 || !WebUtils.firstUseDone) {
cover = Qt.resolvedUrl("cover/NoTabsCover.qml")
} else {
if (cover != null && window.webView) {
Expand Down
63 changes: 32 additions & 31 deletions apps/browser/qml/pages/BrowserPage.qml
Expand Up @@ -16,6 +16,7 @@ import Sailfish.Silica 1.0
import Sailfish.Silica.private 1.0 as Private
import Sailfish.Browser 1.0
import Sailfish.Policy 1.0
import Nemo.Configuration 1.0
import "components" as Browser
import "../shared" as Shared

Expand All @@ -36,6 +37,7 @@ Page {
property alias url: webView.url
property alias title: webView.title
property alias webView: webView
property alias inputRegion: inputRegion

function load(url, title) {
webView.load(url, title)
Expand All @@ -60,23 +62,28 @@ Page {

function inputMaskForOrientation(orientation) {
// mask is in portrait window coordinates
var mask = Qt.rect(0, 0, Screen.width, Screen.height)
if (!window.opaqueBackground && webView.enabled && browserPage.active && !webView.touchBlocked && !downloadPopup.visible) {
var portraitScreen = window.QuickWindow.Screen.primaryOrientation === Qt.PortraitOrientation
var mask = Qt.rect(0, 0,
portraitScreen ? Screen.width : Screen.height,
portraitScreen ? Screen.height : Screen.width)
if (webView.enabled && browserPage.active && !webView.touchBlocked && !downloadPopup.visible) {
var overlayVisibleHeight = browserPage.height - overlay.y

switch (orientation) {
case Orientation.None:
case Orientation.Portrait:
switch (window.QuickWindow.Screen.angleBetween(orientation, window.QuickWindow.Screen.primaryOrientation)) {
case 0:
case 360:
mask.y = overlay.y
// fallthrough
case Orientation.PortraitInverted:
case 180:
case -180:
mask.height = overlayVisibleHeight
break

case Orientation.LandscapeInverted:
case 270:
case -90:
mask.x = overlay.y
// fallthrough
case Orientation.Landscape:
case 90:
case -270:
mask.width = overlayVisibleHeight
}
}
Expand Down Expand Up @@ -143,14 +150,20 @@ Page {
}
}

ConfigurationValue {
id: maxliveTabs
key: "/apps/sailfish-browser/settings/max_live_tab_count"
defaultValue: 3
}

Browser.DownloadRemorsePopup { id: downloadPopup }
Shared.WebView {
id: webView

enabled: overlay.animator.allowContentUse
fullscreenHeight: portrait ? Screen.height : Screen.width
portrait: browserPage.isPortrait
maxLiveTabCount: 3
maxLiveTabCount: maxliveTabs.value
toolbarHeight: overlay.animator.opened ? overlay.toolBar.rowHeight : 0
rotationHandler: browserPage
imOpened: virtualKeyboardObserver.opened
Expand Down Expand Up @@ -200,8 +213,6 @@ Page {
overlay.startPage(openOverlayImmediately ? PageStackAction.Immediate
: PageStackAction.Animated)
}

window.setBrowserCover(webView.tabModel)
}
}

Expand All @@ -214,11 +225,13 @@ Page {
if (webView.tabModel.count === 0) {
webView.handleModelChanges(false)
}
window.setBrowserCover(webView.tabModel)
}
onWaitingForNewTabChanged: window.opaqueBackground = webView.tabModel.waitingForNewTab
}

InputRegion {
id: inputRegion

window: webView.chromeWindow
x: inputMask.x
y: inputMask.y
Expand All @@ -229,13 +242,9 @@ Page {
Browser.DimmerEffect {
id: contentDimmer

readonly property bool canOpenContentDimmer: webView.activeTabRendered && overlay.animator.atBottom

width: browserPage.width
height: Math.ceil(overlay.y)

baseColor: overlay.baseColor
baseOpacity: overlay.baseOpacity
dimmerOpacity: overlay.animator.atBottom
? 0.0
: 0.9 - (overlay.y / (webView.fullscreenHeight - overlay.toolBar.rowHeight)) * 0.9
Expand All @@ -260,13 +269,6 @@ Page {
anchors.fill: contentDimmer
visible: webView.privateMode && !overlay.animator.allowContentUse
}

onCanOpenContentDimmerChanged: {
if (canOpenContentDimmer) {
webView.tabModel.waitingForNewTab = false
window.opaqueBackground = false
}
}
}

Label {
Expand Down Expand Up @@ -297,8 +299,6 @@ Page {
historyModel: historyModel
browserPage: browserPage

onEnteringNewTabUrlChanged: window.opaqueBackground = webView.tabModel.waitingForNewTab || enteringNewTabUrl

animator.onAtBottomChanged: {
if (!animator.atBottom) {
webView.clearSelection()
Expand All @@ -308,7 +308,7 @@ Page {
onActiveChanged: {
var isFullScreen = webView.contentItem && webView.contentItem.fullscreen
if (!isFullScreen && active && !overlay.enteringNewTabUrl) {
if (webView.tabModel.count !== 0 || webView.tabModel.waitingForNewTab || (WebUtils.homePage !== "about:blank" && WebUtils.homePage.length > 0)) {
if (webView.tabModel.count !== 0 || (WebUtils.homePage !== "about:blank" && WebUtils.homePage.length > 0)) {
overlay.animator.showChrome()
} else {
overlay.startPage()
Expand Down Expand Up @@ -385,6 +385,7 @@ Page {
overlay.enterNewTabUrl(PageStackAction.Immediate)
}

window.activate()
return
}

Expand All @@ -395,6 +396,8 @@ Page {
webView.grabActivePage()
if (webView.tabModel.activateTab(url)) {
webView.releaseActiveTabOwnership()
} else if (!webView.tabModel.loaded) {
webView.load(url)
} else {
webView.clearSelection()
webView.tabModel.newTab(url)
Expand All @@ -416,13 +419,11 @@ Page {
bringToForeground(webView.chromeWindow)
window.activate()
}
onFirstUseDoneChanged: window.setBrowserCover(webView.tabModel)
}

Component.onCompleted: {
if (!WebUtils.firstUseDone) {
window.setBrowserCover(webView.tabModel)
}

window.setBrowserCover(webView.tabModel)
if (Qt.application.arguments.indexOf("-debugMode") > 0) {
var component = Qt.createComponent(Qt.resolvedUrl("components/DebugOverlay.qml"))
if (component.status === Component.Ready) {
Expand Down
4 changes: 2 additions & 2 deletions apps/browser/qml/pages/HistoryPage.qml
Expand Up @@ -21,7 +21,7 @@ Page {
readonly property bool pendingRemorse: remorse ? remorse.pending : false

signal loadPage(string url, bool newTab)
signal saveBookmark(string url, string title)
signal saveBookmark(string url, string title, string favicon)

HistoryList {
id: view
Expand All @@ -36,7 +36,7 @@ Page {
root.loadPage(url, newTab)
}

onSaveBookmark: root.saveBookmark(url, title)
onSaveBookmark: root.saveBookmark(url, title, favicon)

Component.onCompleted: model.search("")

Expand Down

0 comments on commit 555b04b

Please sign in to comment.