Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
plasma-angelfish
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rinigus Saar
plasma-angelfish
Commits
6092d883
Commit
6092d883
authored
Mar 26, 2020
by
Marco Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first experimental "webapp mode"
parent
406693e1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
286 additions
and
0 deletions
+286
-0
src/CMakeLists.txt
src/CMakeLists.txt
+19
-0
src/contents/webapp-ui/webapp.qml
src/contents/webapp-ui/webapp.qml
+163
-0
src/webapp-resources.qrc
src/webapp-resources.qrc
+5
-0
src/webappmain.cpp
src/webappmain.cpp
+99
-0
No files found.
src/CMakeLists.txt
View file @
6092d883
...
...
@@ -16,3 +16,22 @@ add_executable(angelfish ${angelfish_SRCS} ${RESOURCES})
target_link_libraries
(
angelfish Qt5::Core Qt5::Qml Qt5::Quick Qt5::Sql Qt5::Svg Qt5::WebEngine KF5::I18n
)
install
(
TARGETS angelfish
${
KF5_INSTALL_TARGETS_DEFAULT_ARGS
}
)
set
(
angelfish_webapp_SRCS
webappmain.cpp
browsermanager.cpp
bookmarkshistorymodel.cpp
dbmanager.cpp
iconimageprovider.cpp
sqlquerymodel.cpp
urlutils.cpp
useragent.cpp
tabsmodel.cpp
)
qt5_add_resources
(
WEBAPP_RESOURCES webapp-resources.qrc
)
add_executable
(
angelfish-webapp
${
angelfish_webapp_SRCS
}
${
RESOURCES
}
${
WEBAPP_RESOURCES
}
)
target_link_libraries
(
angelfish-webapp Qt5::Core Qt5::Qml Qt5::Quick Qt5::Sql Qt5::Svg Qt5::WebEngine KF5::I18n
)
install
(
TARGETS angelfish-webapp
${
KF5_INSTALL_TARGETS_DEFAULT_ARGS
}
)
src/contents/webapp-ui/webapp.qml
0 → 100644
View file @
6092d883
/***************************************************************************
* *
* Copyright 2014-2015 Sebastian Kügler <sebas@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
* *
***************************************************************************/
import
QtQuick
2.1
import
QtWebEngine
1.6
import
QtQuick
.
Window
2.3
import
QtGraphicalEffects
1.0
import
Qt
.
labs
.
settings
1.0
as
QtSettings
import
org
.
kde
.
kirigami
2.7
as
Kirigami
import
org
.
kde
.
mobile
.
angelfish
1.0
import
QtQuick
.
Layouts
1.2
Kirigami.ApplicationWindow
{
id
:
webBrowser
title
:
webView
.
title
// Pointer to the currently active list of tabs.
//
// As there are private and normal tabs, switch between
// them according to the current mode.
property
ListWebView
tabs
:
rootPage
.
privateMode
?
privateTabs
:
regularTabs
property
WebView
currentWebView
:
webView
// Pointer to browser settings
property
Settings
settings
:
settings
// Used to determine if the window is in landscape mode
property
bool
landscape
:
width
>
height
property
int
borderWidth
:
Math
.
round
(
Kirigami
.
Units
.
gridUnit
/
18
);
property
color
borderColor
:
Kirigami
.
Theme
.
highlightColor
;
width
:
Kirigami
.
Units
.
gridUnit
*
20
height
:
Kirigami
.
Units
.
gridUnit
*
30
pageStack.globalToolBar.showNavigationButtons
:
false
// Main Page
pageStack.initialPage
:
Kirigami.Page
{
id
:
rootPage
leftPadding
:
0
rightPadding
:
0
topPadding
:
0
bottomPadding
:
0
globalToolBarStyle
:
Kirigami
.
ApplicationHeaderStyle
.
None
Kirigami.ColumnView.fillWidth
:
true
Kirigami.ColumnView.pinned
:
true
Kirigami.ColumnView.preventStealing
:
true
// Required to enforce active tab reload
// on start. As a result, mixed isMobile
// tabs will work correctly
property
bool
initialized
:
false
WebView
{
id
:
webView
anchors.fill
:
parent
url
:
BrowserManager
.
initialUrl
}
ErrorHandler
{
id
:
errorHandler
errorString
:
webView
.
errorString
errorCode
:
webView
.
errorCode
anchors.fill
:
parent
visible
:
webView
.
errorCode
!==
""
}
Loader
{
id
:
questionLoader
anchors.bottom
:
parent
.
bottom
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
}
// Container for the progress bar
Item
{
id
:
progressItem
height
:
Math
.
round
(
Kirigami
.
Units
.
gridUnit
/
6
)
z
:
99
anchors
{
bottom
:
parent
.
bottom
bottomMargin
:
-
Math
.
round
(
height
/
2
)
left
:
tabs
.
left
right
:
tabs
.
right
}
opacity
:
webView
.
loading
?
1
:
0
Behavior
on
opacity
{
NumberAnimation
{
duration
:
Kirigami
.
Units
.
longDuration
;
easing.type
:
Easing
.
InOutQuad
;
}
}
Rectangle
{
color
:
Kirigami
.
Theme
.
highlightColor
width
:
Math
.
round
((
webView
.
loadProgress
/
100
)
*
parent
.
width
)
anchors
{
top
:
parent
.
top
left
:
parent
.
left
bottom
:
parent
.
bottom
}
}
}
Loader
{
id
:
sheetLoader
}
// dealing with hiding and showing navigation bar
property
point
oldScrollPosition
:
Qt
.
point
(
0
,
0
)
}
Connections
{
target
:
webBrowser
.
pageStack
onCurrentIndexChanged
:
{
// drop all sub pages as soon as the browser window is the
// focussed one
if
(
webBrowser
.
pageStack
.
currentIndex
===
0
)
popSubPages
();
}
}
QtSettings.Settings
{
// kept separate to simplify definition of aliases
property
alias
x
:
webBrowser
.
x
property
alias
y
:
webBrowser
.
y
property
alias
width
:
webBrowser
.
width
property
alias
height
:
webBrowser
.
height
}
Settings
{
id
:
settings
}
Component.onCompleted
:
rootPage
.
initialized
=
true
function
popSubPages
()
{
while
(
webBrowser
.
pageStack
.
depth
>
1
)
webBrowser
.
pageStack
.
pop
();
}
}
src/webapp-resources.qrc
0 → 100644
View file @
6092d883
<RCC>
<qresource prefix="/">
<file alias="webapp.qml">contents/webapp-ui/webapp.qml</file>
</qresource>
</RCC>
src/webappmain.cpp
0 → 100644
View file @
6092d883
/*
Copyright (C) 2019 Jonah Brüchert <jbb.prv@gmx.de>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <QApplication>
#include <QCommandLineOption>
#include <QCommandLineParser>
#include <QQmlApplicationEngine>
#include <QUrl>
#include <QtQml>
#include <QtWebEngine>
#include <KLocalizedContext>
#include <KLocalizedString>
#include "bookmarkshistorymodel.h"
#include "browsermanager.h"
#include "iconimageprovider.h"
#include "tabsmodel.h"
#include "urlutils.h"
#include "useragent.h"
Q_DECL_EXPORT
int
main
(
int
argc
,
char
*
argv
[])
{
QGuiApplication
::
setAttribute
(
Qt
::
AA_EnableHighDpiScaling
);
QGuiApplication
::
setAttribute
(
Qt
::
AA_ShareOpenGLContexts
);
// Setup QtWebEngine
qputenv
(
"QTWEBENGINE_DIALOG_SET"
,
"QtQuickControls2"
);
#if QT_VERSION > QT_VERSION_CHECK(5, 14, 0)
QtWebEngine
::
initialize
();
#endif
QApplication
app
(
argc
,
argv
);
QCoreApplication
::
setOrganizationName
(
"KDE"
);
QCoreApplication
::
setOrganizationDomain
(
"mobile.kde.org"
);
QCoreApplication
::
setApplicationName
(
"angelfish"
);
#if QT_VERSION <= QT_VERSION_CHECK(5, 14, 0)
QtWebEngine
::
initialize
();
#endif
// Command line parser
QCommandLineParser
parser
;
parser
.
addPositionalArgument
(
"url"
,
i18n
(
"URL to open"
),
"[url]"
);
parser
.
addHelpOption
();
parser
.
process
(
app
);
// QML loading
QQmlApplicationEngine
engine
;
engine
.
rootContext
()
->
setContextObject
(
new
KLocalizedContext
(
&
engine
));
engine
.
addImageProvider
(
IconImageProvider
::
providerId
(),
new
IconImageProvider
(
&
engine
));
// initial url command line parameter
QString
initialUrl
;
if
(
!
parser
.
positionalArguments
().
isEmpty
())
initialUrl
=
QUrl
::
fromUserInput
(
parser
.
positionalArguments
().
first
()).
toString
();
// Exported types
qmlRegisterType
<
BookmarksHistoryModel
>
(
"org.kde.mobile.angelfish"
,
1
,
0
,
"BookmarksHistoryModel"
);
qmlRegisterType
<
UserAgent
>
(
"org.kde.mobile.angelfish"
,
1
,
0
,
"UserAgentGenerator"
);
qmlRegisterType
<
TabsModel
>
(
"org.kde.mobile.angelfish"
,
1
,
0
,
"TabsModel"
);
// URL utils
qmlRegisterSingletonType
<
UrlUtils
>
(
"org.kde.mobile.angelfish"
,
1
,
0
,
"UrlUtils"
,
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
return
static_cast
<
QObject
*>
(
new
UrlUtils
());
});
BrowserManager
::
instance
()
->
setInitialUrl
(
initialUrl
);
// Browser Manager
qmlRegisterSingletonType
<
BrowserManager
>
(
"org.kde.mobile.angelfish"
,
1
,
0
,
"BrowserManager"
,
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
return
static_cast
<
QObject
*>
(
BrowserManager
::
instance
());
});
// Load QML
engine
.
load
(
QUrl
(
QStringLiteral
(
"qrc:///webapp.qml"
)));
// Error handling
if
(
engine
.
rootObjects
().
isEmpty
())
{
return
-
1
;
}
return
app
.
exec
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment