├── Api ├── tools │ ├── blank │ │ ├── qmldir │ │ └── main.qml │ ├── error │ │ ├── qmldir │ │ └── main.qml │ ├── downloads │ │ ├── qmldir │ │ └── icon_clear.svg │ ├── settings │ │ ├── qmldir │ │ └── main.qml │ ├── common │ │ ├── qmldir │ │ ├── palette.js │ │ ├── qbbutton.qml │ │ ├── MomentumAnimation.qml │ │ └── SortFilterModel.qml │ ├── install │ │ ├── qmldir │ │ └── main.qml │ ├── history │ │ └── qmldir │ ├── bookmarks │ │ ├── qmldir │ │ ├── main.qml │ │ └── FolderForm.qml │ └── index.qml ├── Api.pri ├── icons │ ├── icon_file.png │ ├── topbar_button_close.png │ ├── icon_expand_less.svg │ ├── icon_clear.svg │ └── icon_more_vert.svg ├── qmlvalue.cpp ├── dynamicobject.h ├── bookmarkitem.h ├── bookmarklinkitem.h ├── qmlvalue.h ├── dynamicobject.cpp ├── api.cpp ├── location.cpp ├── document.cpp ├── api.h ├── bookmarkdb.h ├── Api_global.h ├── bookmarkitem.cpp ├── historyitem.cpp ├── locationurl.cpp ├── tools.h ├── document.h ├── downloaddb.h ├── apiweb.cpp ├── bookmarklinkitem.cpp ├── locationurl.h ├── bookmarkitemmodel.h ├── historydb.h ├── log.cpp ├── accessrights.h ├── downloadbutton.h ├── bookmarklinkmodel.h ├── log.h ├── downloadmanagerwidget.h ├── window.cpp ├── downloaditemmodel.h ├── Api.pro ├── tools.cpp ├── location.h ├── window.h ├── apiweb.h ├── historyitemmodel.h ├── apicommon.h ├── historyitem.h ├── downloadbutton.cpp └── downloadmanagerwidget.cpp ├── App ├── App.pri ├── App.pro ├── app.cpp ├── app.h ├── App_global.h ├── mainapplication.h ├── appdb.h ├── settings.h ├── apppaths.h └── settings.cpp ├── Net ├── Net.pri ├── net.cpp ├── net.h ├── Net_global.h ├── semver.h ├── Net.pro ├── urlhelper.h ├── networkaccessmanagerfactory.cpp ├── networkaccessmanagerfactory.h ├── internalnetworkreply.h ├── httpmanager.h ├── downloaditem_p.h ├── networkdiskcache.h ├── networkdiskcache_p.h ├── internalnetworkreply.cpp └── downloaditem.h ├── .gitignore ├── preview.png ├── Browser ├── icons │ ├── cross.png │ ├── left.png │ ├── menu.png │ ├── ninja.png │ ├── plus.png │ ├── qbq256.png │ ├── qbq32.png │ ├── qbqb3.ico │ ├── qbqb3.png │ ├── qbqb32.png │ ├── reload.png │ ├── right.png │ ├── star-a.png │ ├── star.png │ ├── x-mark-16.png │ ├── left_disabled.png │ ├── right_disabled.png │ ├── icon_expand_less.svg │ ├── icon_more_vert.svg │ ├── bookmark.svg │ ├── star.svg │ ├── star-a.svg │ └── download.svg ├── aboutdialog.h ├── qbcommon.cpp ├── qbcommon.h ├── completerrow.h ├── urllineedit.h ├── completerheader.h ├── completermodel.h ├── searchengine.h ├── completerrow.cpp ├── browser.h ├── webpopupwindow.h ├── qmldevtools.h ├── browserpaths.h ├── downloaditemproxy.h ├── browsersettings.h ├── browsersettings.cpp ├── searchengine.cpp ├── baseview.h ├── mainwindow.h ├── navigationbar.h ├── browserpaths.cpp ├── downloaditemproxy.cpp ├── htmlview.h ├── qmldevtools.cpp ├── webpopupwindow.cpp ├── completermodel.cpp ├── aboutdialog.cpp ├── completerheader.cpp ├── tabview.h ├── urllineedit.cpp ├── browser.cpp ├── Browser.pro └── styles.qss ├── .gitmodules ├── QmlBrowser.pro ├── CONTRIBUTING.md └── README.md /Api/tools/blank/qmldir: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Api/tools/error/qmldir: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Api/tools/downloads/qmldir: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Api/tools/settings/qmldir: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /App/App.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD/ 2 | -------------------------------------------------------------------------------- /Api/Api.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD/ 2 | 3 | -------------------------------------------------------------------------------- /Net/Net.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD/ 2 | 3 | -------------------------------------------------------------------------------- /Api/tools/common/qmldir: -------------------------------------------------------------------------------- 1 | singleton Palette 1.0 Palette.js 2 | -------------------------------------------------------------------------------- /Api/tools/install/qmldir: -------------------------------------------------------------------------------- 1 | QbButton ../common/qbbutton.qml 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | QmlBrowser.pro.user 2 | /_ 3 | CQtDeployer.json 4 | /build 5 | -------------------------------------------------------------------------------- /Api/tools/history/qmldir: -------------------------------------------------------------------------------- 1 | SortFilterModel ../common/SortFilterModel.qml 2 | -------------------------------------------------------------------------------- /preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/preview.png -------------------------------------------------------------------------------- /Api/icons/icon_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Api/icons/icon_file.png -------------------------------------------------------------------------------- /Browser/icons/cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Browser/icons/cross.png -------------------------------------------------------------------------------- /Browser/icons/left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Browser/icons/left.png -------------------------------------------------------------------------------- /Browser/icons/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Browser/icons/menu.png -------------------------------------------------------------------------------- /Browser/icons/ninja.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Browser/icons/ninja.png -------------------------------------------------------------------------------- /Browser/icons/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Browser/icons/plus.png -------------------------------------------------------------------------------- /Browser/icons/qbq256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Browser/icons/qbq256.png -------------------------------------------------------------------------------- /Browser/icons/qbq32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Browser/icons/qbq32.png -------------------------------------------------------------------------------- /Browser/icons/qbqb3.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Browser/icons/qbqb3.ico -------------------------------------------------------------------------------- /Browser/icons/qbqb3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Browser/icons/qbqb3.png -------------------------------------------------------------------------------- /Browser/icons/qbqb32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Browser/icons/qbqb32.png -------------------------------------------------------------------------------- /Browser/icons/reload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Browser/icons/reload.png -------------------------------------------------------------------------------- /Browser/icons/right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Browser/icons/right.png -------------------------------------------------------------------------------- /Browser/icons/star-a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Browser/icons/star-a.png -------------------------------------------------------------------------------- /Browser/icons/star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Browser/icons/star.png -------------------------------------------------------------------------------- /Browser/icons/x-mark-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Browser/icons/x-mark-16.png -------------------------------------------------------------------------------- /Browser/icons/left_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Browser/icons/left_disabled.png -------------------------------------------------------------------------------- /Api/icons/topbar_button_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Api/icons/topbar_button_close.png -------------------------------------------------------------------------------- /Api/qmlvalue.cpp: -------------------------------------------------------------------------------- 1 | #include "qmlvalue.h" 2 | 3 | QmlValue::QmlValue(QObject *parent) 4 | : QObject{parent} 5 | {} 6 | -------------------------------------------------------------------------------- /Browser/icons/right_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Toorion/qml-browser/HEAD/Browser/icons/right_disabled.png -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "3rdparty/libgit2"] 2 | path = 3rdparty/libgit2 3 | url = https://github.com/libgit2/libgit2.git 4 | -------------------------------------------------------------------------------- /Api/icons/icon_expand_less.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Browser/icons/icon_expand_less.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Api/tools/common/palette.js: -------------------------------------------------------------------------------- 1 | .pragma library 2 | 3 | var colorGreen = "#198754"; 4 | var colorGreenHover = "#107246"; 5 | 6 | var bgSuccess = colorGreen; 7 | var bgSuccessHover = colorGreenHover; 8 | -------------------------------------------------------------------------------- /Api/icons/icon_clear.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Api/tools/downloads/icon_clear.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Api/icons/icon_more_vert.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Browser/icons/icon_more_vert.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Browser/aboutdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef ABOUTDIALOG_H 2 | #define ABOUTDIALOG_H 3 | 4 | #include 5 | 6 | class AboutDialog : public QDialog 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit AboutDialog(QWidget* parent = nullptr); 11 | }; 12 | 13 | #endif // ABOUTDIALOG_H 14 | -------------------------------------------------------------------------------- /QmlBrowser.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | # https://wiki.qt.io/SUBDIRS_-_handling_dependencies 4 | SUBDIRS += \ 5 | App \ 6 | Net \ 7 | Api \ 8 | Browser 9 | 10 | CONFIG += ordered 11 | 12 | # unix:{ 13 | # QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN\'" 14 | # } 15 | 16 | -------------------------------------------------------------------------------- /Api/tools/bookmarks/qmldir: -------------------------------------------------------------------------------- 1 | TreeFilterModel ../common/TreeFilterModel.qml 2 | SortFilterModel ../common/SortFilterModel.qml 3 | QbButton ../common/qbbutton.qml 4 | MomentumAnimation ../common/MomentumAnimation.qml 5 | ResizableBox ../common/ResizableBox.qml 6 | FolderForm FolderForm.qml 7 | LinksView LinksView.qml 8 | FoldersView FoldersView.qml 9 | -------------------------------------------------------------------------------- /Browser/qbcommon.cpp: -------------------------------------------------------------------------------- 1 | #include "qbcommon.h" 2 | 3 | namespace Qb 4 | { 5 | const char *APPNAME = "QmlBrowser"; 6 | const char *VERSION = "0.1.6"; 7 | const char *AUTHOR = "Denis Solomatin"; 8 | const char *COPYRIGHT = "2023"; 9 | const char *WWWADDRESS = ""; 10 | const char *BUGSADDRESS = ""; 11 | const char *WIKIADDRESS = ""; 12 | } 13 | -------------------------------------------------------------------------------- /Api/tools/error/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | import QtQuick.Controls 2.12 3 | import QtQuick.Layouts 1.15 4 | 5 | Item { 6 | anchors.fill: parent 7 | property string title: 'Error page' 8 | Text { 9 | anchors.verticalCenter: parent.verticalCenter 10 | anchors.horizontalCenter: parent.horizontalCenter 11 | text: "Error page" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Browser/qbcommon.h: -------------------------------------------------------------------------------- 1 | #ifndef QBCOMMON_H 2 | #define QBCOMMON_H 3 | 4 | #include 5 | 6 | namespace Qb 7 | { 8 | extern const char *APPNAME; 9 | extern const char *VERSION; 10 | extern const char *AUTHOR; 11 | extern const char *COPYRIGHT; 12 | extern const char *WWWADDRESS; 13 | extern const char *BUGSADDRESS; 14 | extern const char *WIKIADDRESS; 15 | 16 | }; 17 | 18 | #endif // QBCOMMON_H 19 | -------------------------------------------------------------------------------- /Api/tools/blank/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 6.3 2 | 3 | 4 | Item { 5 | anchors.fill: parent 6 | property string title: 'Blank' 7 | Text { 8 | anchors.verticalCenter: parent.verticalCenter 9 | anchors.horizontalCenter: parent.horizontalCenter 10 | text: "Blank" 11 | font.pixelSize: window.height / 3 12 | font.weight: Font.DemiBold 13 | color: "#EEE" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Browser/icons/bookmark.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Api/dynamicobject.h: -------------------------------------------------------------------------------- 1 | #ifndef DYNAMICOBJECT_H 2 | #define DYNAMICOBJECT_H 3 | 4 | #include 5 | #include "Api_global.h" 6 | 7 | class API_EXPORT DynamicObject : public QQmlPropertyMap 8 | { 9 | public: 10 | explicit DynamicObject(QObject *baseObject, QObject *parent = nullptr); 11 | 12 | private: 13 | void changeValue(const QString &key, const QVariant &value); 14 | QObject *m_baseObject; 15 | }; 16 | 17 | #endif // DYNAMICOBJECT_H 18 | -------------------------------------------------------------------------------- /Browser/completerrow.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPLETERROW_H 2 | #define COMPLETERROW_H 3 | 4 | #include 5 | 6 | class CompleterRow : public QStyledItemDelegate 7 | { 8 | public: 9 | explicit CompleterRow(QObject *parent = nullptr); 10 | 11 | void paint(QPainter *painter, const QStyleOptionViewItem &option, 12 | const QModelIndex &index) const override; 13 | 14 | bool eventFilter(QObject *obj, QEvent *ev) override; 15 | }; 16 | 17 | #endif // COMPLETERROW_H 18 | -------------------------------------------------------------------------------- /Api/bookmarkitem.h: -------------------------------------------------------------------------------- 1 | #ifndef BOOKMARKITEM_H 2 | #define BOOKMARKITEM_H 3 | 4 | #include 5 | #include "Api_global.h" 6 | 7 | class API_EXPORT BookmarkItem 8 | { 9 | 10 | public: 11 | explicit BookmarkItem(QVariantMap data); 12 | 13 | static const QList fields(); 14 | 15 | QVariant data(int column) const; 16 | bool setData(int column, const QVariant &value); 17 | 18 | QVariant value(const QByteArray &key) const; 19 | 20 | void setValue(const QByteArray &key, const QVariant &value); 21 | 22 | int id(); 23 | 24 | void setId(int id); 25 | 26 | signals: 27 | 28 | private: 29 | 30 | QVariantMap m_itemData; 31 | 32 | }; 33 | 34 | #endif // BOOKMARKITEM_H 35 | -------------------------------------------------------------------------------- /Api/bookmarklinkitem.h: -------------------------------------------------------------------------------- 1 | #ifndef BOOKMARKLINKITEM_H 2 | #define BOOKMARKLINKITEM_H 3 | 4 | #include "Api_global.h" 5 | #include 6 | 7 | class API_EXPORT BookmarkLinkItem 8 | { 9 | public: 10 | explicit BookmarkLinkItem(QVariantMap data); 11 | static const QList fields(); 12 | 13 | QVariant data(int column) const; 14 | bool setData(int column, const QVariant &value); 15 | 16 | QVariant value(const QByteArray &key) const; 17 | 18 | void setValue(const QByteArray &key, const QVariant &value); 19 | 20 | int id(); 21 | 22 | void setId(int id); 23 | 24 | 25 | private: 26 | 27 | QVariantMap m_itemData; 28 | 29 | }; 30 | 31 | #endif // BOOKMARKLINKITEM_H 32 | -------------------------------------------------------------------------------- /Api/qmlvalue.h: -------------------------------------------------------------------------------- 1 | #ifndef QMLVALUE_H 2 | #define QMLVALUE_H 3 | 4 | #include 5 | #include 6 | 7 | class QmlValue : public QObject 8 | { 9 | Q_OBJECT 10 | Q_PROPERTY(QVariant *value READ value WRITE setValue NOTIFY valueChanged) 11 | public: 12 | explicit QmlValue(QObject *parent = nullptr); 13 | 14 | QVariant *value() { 15 | return m_value; 16 | } 17 | 18 | void setValue(QVariant *value) { 19 | if(value == m_value) { 20 | return; 21 | } 22 | m_value = value; 23 | emit valueChanged(*value); 24 | } 25 | 26 | signals: 27 | void valueChanged(const QVariant &value); 28 | 29 | private: 30 | QVariant *m_value; 31 | }; 32 | 33 | #endif // QMLVALUE_H 34 | -------------------------------------------------------------------------------- /App/App.pro: -------------------------------------------------------------------------------- 1 | QT += widgets sql 2 | 3 | TEMPLATE = lib 4 | 5 | CONFIG += c++11 6 | DEFINES += APP_LIBRARY 7 | CONFIG -= debug_and_release 8 | 9 | # You can make your code fail to compile if it uses deprecated APIs. 10 | # In order to do so, uncomment the following line. 11 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 12 | 13 | SOURCES += \ 14 | app.cpp \ 15 | appdb.cpp \ 16 | apppaths.cpp \ 17 | mainapplication.cpp \ 18 | settings.cpp 19 | 20 | HEADERS += \ 21 | App_global.h \ 22 | app.h \ 23 | appdb.h \ 24 | apppaths.h \ 25 | mainapplication.h \ 26 | settings.h 27 | 28 | # Default rules for deployment. 29 | unix { 30 | target.path = $$[QT_INSTALL_PLUGINS]/generic 31 | } 32 | !isEmpty(target.path): INSTALLS += target 33 | -------------------------------------------------------------------------------- /Browser/urllineedit.h: -------------------------------------------------------------------------------- 1 | #ifndef URLLINEEDIT_H 2 | #define URLLINEEDIT_H 3 | 4 | #include 5 | #include 6 | #include "completermodel.h" 7 | #include "completerheader.h" 8 | #include 9 | #include "completerrow.h" 10 | 11 | class UrlLineEdit : public QLineEdit 12 | { 13 | public: 14 | explicit UrlLineEdit(QWidget *parent = nullptr); 15 | 16 | QAction *installAction; 17 | 18 | protected: 19 | void contextMenuEvent(QContextMenuEvent *event) override; 20 | //void focusOutEvent(QFocusEvent* event) override; 21 | void updateCompleter(); 22 | 23 | private: 24 | QCompleter *m_completer; 25 | CompleterModel *m_completerModel; 26 | CompleterHeader *m_completerHeader; 27 | QTableView *m_completerPopup; 28 | CompleterRow *m_completerRow; 29 | 30 | int m_completerHeaderHeight = 60; 31 | }; 32 | 33 | #endif // URLLINEEDIT_H 34 | -------------------------------------------------------------------------------- /Api/dynamicobject.cpp: -------------------------------------------------------------------------------- 1 | #include "dynamicobject.h" 2 | #include 3 | 4 | 5 | DynamicObject::DynamicObject(QObject *baseObject, QObject *parent) 6 | : QQmlPropertyMap{parent}, 7 | m_baseObject(baseObject) 8 | { 9 | const QMetaObject *metaObject = baseObject->metaObject(); 10 | int count = metaObject->propertyCount(); 11 | for (int i=0; iproperty(i); 13 | const char *name = metaProperty.name(); 14 | QVariant value = baseObject->property(name); 15 | insert(name, value); 16 | } 17 | 18 | connect(this, &DynamicObject::valueChanged, this, &DynamicObject::changeValue); 19 | } 20 | 21 | void DynamicObject::changeValue(const QString &key, const QVariant &value) 22 | { 23 | QByteArray bKey = key.toLocal8Bit(); 24 | m_baseObject->setProperty(bKey.data(), value); 25 | } 26 | -------------------------------------------------------------------------------- /Api/tools/common/qbbutton.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 6.3 2 | import QtQuick.Controls 6.3 3 | import QtQuick.Layouts 6.3 4 | import "palette.js" as Palette 5 | 6 | Button { 7 | property var onClick; 8 | Layout.alignment: Qt.AlignHCenter 9 | text: "Ok" 10 | background: Rectangle { 11 | implicitWidth: 100 12 | implicitHeight: 40 13 | opacity: enabled ? 1 : 0.3 14 | color:Palette.bgSuccess 15 | } 16 | 17 | MouseArea { 18 | anchors.fill: parent 19 | cursorShape: Qt.PointingHandCursor 20 | hoverEnabled: true 21 | onEntered: { 22 | if(parent.enabled) { 23 | parent.background.color = Palette.bgSuccessHover 24 | } 25 | } 26 | onExited: { 27 | if(parent.enabled) { 28 | parent.background.color = Palette.bgSuccess 29 | } 30 | } 31 | onClicked: {onClick();} 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Api/api.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "api.h" 20 | 21 | Api::Api() 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /Api/tools/common/MomentumAnimation.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 3 | 4 | import QtQuick 5 | 6 | ParallelAnimation { 7 | id: root 8 | property Item target: null 9 | property int duration: 500 10 | property vector2d velocity: Qt.vector2d(0,0) 11 | 12 | function restart(vel) { 13 | stop() 14 | velocity = vel 15 | start() 16 | } 17 | 18 | NumberAnimation { 19 | id: xAnim 20 | target: root.target 21 | property: "x" 22 | to: target.x + velocity.x / duration * 100 23 | duration: root.duration 24 | easing.type: Easing.OutQuad 25 | } 26 | NumberAnimation { 27 | id: yAnim 28 | target: root.target 29 | property: "y" 30 | to: target.y + velocity.y / duration * 100 31 | duration: root.duration 32 | easing.type: Easing.OutQuad 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /App/app.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "app.h" 20 | 21 | App::App() 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /Net/net.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "net.h" 20 | 21 | Net::Net() 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /Api/location.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "location.h" 20 | 21 | Location::Location() 22 | { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Api/document.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "document.h" 20 | 21 | Document::Document(QObject *parent) : QObject(parent) 22 | { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Browser/completerheader.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPLETERHEADER_H 2 | #define COMPLETERHEADER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "completermodel.h" 8 | 9 | class CompleterHeader : public QHeaderView 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit CompleterHeader(QWidget *parent = nullptr); 14 | 15 | public slots: 16 | void btnAllClicked(bool checked = false); 17 | void btnBookmarkClicked(bool checked = false); 18 | void btnHistoryClicked(bool checked = false); 19 | CompleterItem::Type filterType() { 20 | return m_type; 21 | }; 22 | 23 | signals: 24 | void typeChanged(CompleterItem::Type &activeType); 25 | 26 | 27 | protected: 28 | void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const override; 29 | 30 | private: 31 | mutable QWidget *m_widget; 32 | QHBoxLayout *m_layout; 33 | QPushButton *m_btnAll; 34 | QPushButton *m_btnBookmark; 35 | QPushButton *m_btnHistory; 36 | CompleterItem::Type m_type; 37 | 38 | }; 39 | 40 | #endif // COMPLETERHEADER_H 41 | -------------------------------------------------------------------------------- /Api/api.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef API_H 20 | #define API_H 21 | 22 | #include "Api_global.h" 23 | 24 | class API_EXPORT Api 25 | { 26 | public: 27 | Api(); 28 | }; 29 | 30 | #endif // API_H 31 | -------------------------------------------------------------------------------- /App/app.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef APP_H 20 | #define APP_H 21 | 22 | #include "App_global.h" 23 | 24 | class APP_EXPORT App 25 | { 26 | public: 27 | App(); 28 | }; 29 | 30 | #endif // APP_H 31 | -------------------------------------------------------------------------------- /Net/net.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef NET_H 20 | #define NET_H 21 | 22 | #include "Net_global.h" 23 | 24 | class NET_EXPORT Net 25 | { 26 | public: 27 | Net(); 28 | }; 29 | 30 | #endif // NET_H 31 | -------------------------------------------------------------------------------- /Api/bookmarkdb.h: -------------------------------------------------------------------------------- 1 | #ifndef BOOKMARKDB_H 2 | #define BOOKMARKDB_H 3 | 4 | #include 5 | #include "Api_global.h" 6 | #include "bookmarkitem.h" 7 | #include "bookmarklinkitem.h" 8 | #include 9 | 10 | class API_EXPORT BookmarkDb : public AppDb 11 | { 12 | public: 13 | BookmarkDb(); 14 | 15 | bool create() override; 16 | 17 | static int insert(const BookmarkItem &item); 18 | static int insertLink(const BookmarkLinkItem &item); 19 | 20 | static bool update(const BookmarkItem &item); 21 | static bool updateLink(const BookmarkLinkItem &item); 22 | 23 | static bool remove(const int id); 24 | static bool removeLink(const int id); 25 | 26 | static int count(QString const queryType, QVariantMap args); 27 | 28 | static int update(QString const queryType, QVariantMap const args, QVariantMap const values); 29 | 30 | static QList* list(); 31 | static QList* listLinks(); 32 | 33 | static BookmarkLinkItem *findLinkByLink(const QUrl &link); 34 | 35 | static QList *findLinkByText(const QString &text); 36 | }; 37 | 38 | #endif // BOOKMARKDB_H 39 | -------------------------------------------------------------------------------- /Browser/completermodel.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPLETERMODEL_H 2 | #define COMPLETERMODEL_H 3 | 4 | #include 5 | #include 6 | 7 | struct CompleterItem { 8 | int id; 9 | 10 | enum Type { 11 | AllType = 0, 12 | BookmarkType, 13 | HistoryType 14 | }; 15 | 16 | Type typeId; 17 | 18 | QString title; 19 | 20 | QUrl url; 21 | 22 | QString description; 23 | }; 24 | 25 | 26 | class CompleterModel : public QAbstractTableModel 27 | { 28 | Q_OBJECT 29 | public: 30 | explicit CompleterModel(QObject *parent = nullptr); 31 | 32 | int rowCount(const QModelIndex &) const override; 33 | int columnCount(const QModelIndex &) const override; 34 | QVariant data(const QModelIndex& index, int role) const override; 35 | QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 36 | bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; 37 | 38 | bool applyFilter(const QString &text, const CompleterItem::Type &type); 39 | 40 | static QString typeName(const int &typeId); 41 | 42 | private: 43 | QList m_items; 44 | }; 45 | 46 | #endif // COMPLETERMODEL_H 47 | -------------------------------------------------------------------------------- /Api/Api_global.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef API_GLOBAL_H 20 | #define API_GLOBAL_H 21 | 22 | #include 23 | 24 | #if defined(API_LIBRARY) 25 | # define API_EXPORT Q_DECL_EXPORT 26 | #else 27 | # define API_EXPORT Q_DECL_IMPORT 28 | #endif 29 | 30 | #endif // API_GLOBAL_H 31 | -------------------------------------------------------------------------------- /Net/Net_global.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef NET_GLOBAL_H 20 | #define NET_GLOBAL_H 21 | 22 | #include 23 | 24 | #if defined(NET_LIBRARY) 25 | # define NET_EXPORT Q_DECL_EXPORT 26 | #else 27 | # define NET_EXPORT Q_DECL_IMPORT 28 | #endif 29 | 30 | #endif // NET_GLOBAL_H 31 | -------------------------------------------------------------------------------- /Api/bookmarkitem.cpp: -------------------------------------------------------------------------------- 1 | #include "bookmarkitem.h" 2 | #include 3 | 4 | BookmarkItem::BookmarkItem(QVariantMap data) 5 | : m_itemData(std::move(data)) 6 | {} 7 | 8 | const QList BookmarkItem::fields() 9 | { 10 | return QList{ 11 | "id", 12 | "parentId", 13 | "name", 14 | "color", 15 | "icon", 16 | "idx", 17 | "pin", 18 | "expanded", 19 | "depth", 20 | "childsCount", 21 | "visible", 22 | "links" 23 | }; 24 | } 25 | 26 | QVariant BookmarkItem::data(int column) const 27 | { 28 | return m_itemData.value(fields()[column]); 29 | } 30 | 31 | bool BookmarkItem::setData(int column, const QVariant &value) 32 | { 33 | m_itemData[fields()[column]].setValue(value); 34 | return true; 35 | } 36 | 37 | QVariant BookmarkItem::value(const QByteArray &key) const 38 | { 39 | return m_itemData.value(key); 40 | } 41 | 42 | void BookmarkItem::setValue(const QByteArray &key, const QVariant &value) 43 | { 44 | m_itemData[key].setValue(value); 45 | } 46 | 47 | int BookmarkItem::id() 48 | { 49 | return value("id").toUInt(); 50 | } 51 | 52 | void BookmarkItem::setId(int id) 53 | { 54 | setValue("id", id); 55 | } 56 | 57 | -------------------------------------------------------------------------------- /App/App_global.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef APP_GLOBAL_H 20 | #define APP_GLOBAL_H 21 | 22 | #include 23 | 24 | #if defined(APP_LIBRARY) 25 | # define APP_EXPORT Q_DECL_EXPORT 26 | #else 27 | # define APP_EXPORT Q_DECL_IMPORT 28 | #endif 29 | 30 | #endif // APP_GLOBAL_H 31 | -------------------------------------------------------------------------------- /Api/historyitem.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "historyitem.h" 20 | 21 | HistoryItem::HistoryItem(const QUrl &url, const int &type, const QString &title, const QUrl &iconUrl, const QString &description) : 22 | m_url(url), 23 | m_type(type), 24 | m_title(title), 25 | m_iconUrl(iconUrl), 26 | m_description(description) 27 | { 28 | m_added = QDateTime::currentDateTime(); 29 | } 30 | -------------------------------------------------------------------------------- /Api/locationurl.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "locationurl.h" 20 | 21 | LocationUrl::LocationUrl(QObject *parent) : QObject(parent) 22 | { 23 | 24 | } 25 | 26 | bool LocationUrl::setRawUrl(const QString rawUrl) 27 | { 28 | m_url = QUrl::fromUserInput(rawUrl); 29 | if(m_url.isValid()) { 30 | emit urlChanged(m_url); 31 | return true; 32 | } 33 | return false; 34 | } 35 | -------------------------------------------------------------------------------- /Api/tools.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef TOOLS_H 20 | #define TOOLS_H 21 | 22 | #include 23 | #include "Api_global.h" 24 | #include 25 | #include 26 | 27 | class API_EXPORT Tools 28 | { 29 | public: 30 | Tools(); 31 | 32 | QString static bytesToText(double bytes); 33 | 34 | QVariantMap static QJSValueToMap(QJSValue obj); 35 | }; 36 | 37 | #endif // TOOLS_H 38 | -------------------------------------------------------------------------------- /Browser/searchengine.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef SEARCHENGINE_H 20 | #define SEARCHENGINE_H 21 | 22 | #include 23 | #include 24 | 25 | class SearchEngine : public QObject 26 | { 27 | Q_OBJECT 28 | public: 29 | explicit SearchEngine(QObject *parent = nullptr); 30 | 31 | static QUrl searchUrl(QString text); 32 | 33 | static QStringList engineList; 34 | 35 | signals: 36 | 37 | }; 38 | 39 | #endif // SEARCHENGINE_H 40 | -------------------------------------------------------------------------------- /Browser/icons/star.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 16 | 17 | -------------------------------------------------------------------------------- /Api/document.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef DOCUMENT_H 20 | #define DOCUMENT_H 21 | 22 | #include 23 | #include "location.h" 24 | #include "Api_global.h" 25 | 26 | class API_EXPORT Document : public QObject 27 | { 28 | Q_OBJECT 29 | Q_PROPERTY(Location location MEMBER location) 30 | public: 31 | explicit Document(QObject *parent = nullptr); 32 | 33 | Location location; 34 | 35 | signals: 36 | 37 | }; 38 | 39 | #endif // DOCUMENT_H 40 | -------------------------------------------------------------------------------- /Api/tools/bookmarks/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2 | import QtQuick.Layouts 3 | 4 | Item { 5 | 6 | property string title: 'Bookmarks' 7 | property string defaultFolderColor: "#ADBFBF" 8 | 9 | id: mainItem 10 | anchors.fill: parent 11 | 12 | Rectangle { 13 | anchors.fill: parent 14 | color: '#e5f2f2' 15 | GridLayout { 16 | anchors.fill: parent 17 | columnSpacing: 0 18 | rowSpacing: 0 19 | 20 | LinksView { 21 | id: linksView 22 | z: 2 23 | Layout.column: 2 24 | Layout.preferredWidth: parent.width * 0.8 25 | Layout.fillHeight: true 26 | } 27 | 28 | Rectangle { 29 | z: 1 30 | Layout.column: 1 31 | Layout.preferredWidth: parent.width * 0.2 32 | Layout.fillHeight: true 33 | color: '#D5E9E9' 34 | FoldersView { 35 | implicitWidth: parent.width 36 | implicitHeight: parent.height 37 | id: foldersView 38 | defaultColor: mainItem.defaultFolderColor 39 | } 40 | } 41 | } 42 | } 43 | 44 | Component.onCompleted: { 45 | let model = foldersView.model.findModelById(1); 46 | linksView.refresh(model); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Net/semver.h: -------------------------------------------------------------------------------- 1 | #ifndef SEMVER_H 2 | #define SEMVER_H 3 | 4 | #include 5 | #include 6 | 7 | struct Semver 8 | { 9 | Semver() {} 10 | 11 | Semver(std::string versionStr) 12 | { 13 | name = versionStr; 14 | auto numericPos = std::find_if(versionStr.begin(), versionStr.end(), [](char c) { 15 | return std::isdigit(c); 16 | }); 17 | 18 | std::string str = versionStr.substr(numericPos - versionStr.begin()); 19 | 20 | sscanf(str.c_str(), "%d.%d.%d-%[^.].%d", &major, &minor, &patch, &pre, &build); 21 | if(pre == '\0') { 22 | sscanf(str.c_str(), "%d.%d.%d.%d", &major, &minor, &patch, &build); 23 | } 24 | isEmpty = false; 25 | } 26 | 27 | bool operator<(const Semver &otherVersion) 28 | { 29 | if(major < otherVersion.major) 30 | return true; 31 | if(minor < otherVersion.minor) 32 | return true; 33 | if(patch < otherVersion.patch) 34 | return true; 35 | if(pre != '\0' && otherVersion.pre == '\0') 36 | return true; 37 | if(pre < otherVersion.pre) 38 | return true; 39 | if(build < otherVersion.build) 40 | return true; 41 | return false; 42 | } 43 | 44 | std::string name; 45 | int major, minor, patch, build; 46 | char pre = '\0'; 47 | bool isEmpty = true; 48 | }; 49 | 50 | 51 | 52 | #endif // SEMVER_H 53 | -------------------------------------------------------------------------------- /Api/tools/install/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 6.3 2 | import QtQuick.Layouts 6.3 3 | import QtQuick.Controls 6.3 4 | 5 | Item { 6 | anchors.fill: parent 7 | property string title: 'Install' 8 | 9 | ColumnLayout { 10 | spacing: 20 11 | width: parent.width 12 | Text { 13 | Layout.alignment: Qt.AlignHCenter 14 | text: qi.progressInfo.url 15 | font.pixelSize: 20 16 | font.weight: Font.DemiBold 17 | } 18 | Text { 19 | Layout.alignment: Qt.AlignHCenter 20 | text: "Installing..." 21 | font.pixelSize: 20 22 | font.weight: Font.DemiBold 23 | } 24 | ProgressBar { 25 | Layout.alignment: Qt.AlignHCenter 26 | value: qi.progress / 100 27 | } 28 | Text { 29 | Layout.alignment: Qt.AlignHCenter 30 | text: qi.progress 31 | font.pixelSize: 20 32 | font.weight: Font.DemiBold 33 | } 34 | Text { 35 | Layout.alignment: Qt.AlignHCenter 36 | text: qi.progressStatus 37 | font.pixelSize: 20 38 | font.weight: Font.DemiBold 39 | } 40 | QbButton { 41 | enabled: qi.progress == 100 42 | onClick: function() { 43 | console.log('click'); 44 | document.location.href = qi.progressInfo.dappUrl; 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Browser/icons/star-a.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Api/downloaddb.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef DOWNLOADDB_H 20 | #define DOWNLOADDB_H 21 | 22 | #include "appdb.h" 23 | #include 24 | #include 25 | #include "Api_global.h" 26 | 27 | class API_EXPORT DownloadDb : public AppDb 28 | { 29 | public: 30 | explicit DownloadDb(); 31 | 32 | bool create() override; 33 | 34 | int static insert(const DownloadItem &item); 35 | 36 | bool static remove(const int id); 37 | 38 | QList static list(); 39 | 40 | 41 | 42 | }; 43 | 44 | #endif // DOWNLOADDB_H 45 | -------------------------------------------------------------------------------- /Api/apiweb.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "apiweb.h" 20 | 21 | ApiWeb::ApiWeb(NetworkAccessManagerFactory *networkManagerFactory, QObject *parent) : ApiCommon(networkManagerFactory, parent) 22 | { 23 | m_window = new Window(this); 24 | 25 | m_document = new Document(this); 26 | 27 | m_locationUrl = new LocationUrl(); 28 | 29 | m_window->location.setLocationUrl(m_locationUrl); 30 | 31 | m_document->location.setLocationUrl(m_locationUrl); 32 | 33 | m_navInput = new QmlValue(this); 34 | m_navInput->setValue(new QVariant("")); 35 | } 36 | -------------------------------------------------------------------------------- /Api/bookmarklinkitem.cpp: -------------------------------------------------------------------------------- 1 | #include "bookmarklinkitem.h" 2 | #include 3 | 4 | BookmarkLinkItem::BookmarkLinkItem(QVariantMap data) 5 | : m_itemData(std::move(data)) 6 | { 7 | if (!m_itemData.contains("bookmarkId") || m_itemData.value("bookmarkId").toInt() < 1) { 8 | m_itemData.insert("bookmarkId", 1); 9 | } 10 | } 11 | 12 | 13 | const QList BookmarkLinkItem::fields() 14 | { 15 | return QList{ 16 | "id", 17 | "bookmarkId", 18 | "title", 19 | "link", 20 | "icon", 21 | "description", 22 | "idx", 23 | "added", 24 | "updated", 25 | "pin", 26 | "shortcut", 27 | "hotkey", 28 | "html", 29 | "text" 30 | }; 31 | } 32 | 33 | QVariant BookmarkLinkItem::data(int column) const 34 | { 35 | return m_itemData.value(fields()[column]); 36 | } 37 | 38 | bool BookmarkLinkItem::setData(int column, const QVariant &value) 39 | { 40 | m_itemData[fields()[column]].setValue(value); 41 | return true; 42 | } 43 | 44 | QVariant BookmarkLinkItem::value(const QByteArray &key) const 45 | { 46 | return m_itemData.value(key); 47 | } 48 | 49 | void BookmarkLinkItem::setValue(const QByteArray &key, const QVariant &value) 50 | { 51 | m_itemData[key].setValue(value); 52 | } 53 | 54 | int BookmarkLinkItem::id() 55 | { 56 | return value("id").toUInt(); 57 | } 58 | 59 | void BookmarkLinkItem::setId(int id) 60 | { 61 | setValue("id", id); 62 | } 63 | 64 | -------------------------------------------------------------------------------- /Browser/completerrow.cpp: -------------------------------------------------------------------------------- 1 | #include "completerrow.h" 2 | #include 3 | #include "completermodel.h" 4 | #include 5 | 6 | CompleterRow::CompleterRow(QObject *parent) : QStyledItemDelegate(parent) 7 | { 8 | } 9 | 10 | void CompleterRow::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const 11 | { 12 | QVariantMap data = qvariant_cast(index.data()); 13 | 14 | auto typeRect = QRect(option.rect); 15 | typeRect.setY(option.rect.y()+5); 16 | typeRect.setX(5); 17 | 18 | painter->save(); 19 | if(option.state & QStyle::State_MouseOver) { 20 | painter->fillRect(option.rect, option.palette.highlight()); 21 | QApplication::setOverrideCursor(QCursor(Qt::PointingHandCursor)); 22 | } else { 23 | QApplication::restoreOverrideCursor(); 24 | } 25 | 26 | QPen typePen(QColor("#0e5a77")); 27 | painter->setPen(typePen); 28 | painter->drawText(typeRect, CompleterModel::typeName(data["typeId"].toInt()) + ": "); 29 | painter->restore(); 30 | 31 | auto titleRect = QRect(option.rect); 32 | titleRect.setY(option.rect.y()+5); 33 | titleRect.setX(70); 34 | 35 | painter->drawText(titleRect, data["title"].toString()); 36 | } 37 | 38 | bool CompleterRow::eventFilter(QObject *obj, QEvent *ev) 39 | { 40 | if (ev->type() == QEvent::Leave || ev->type() == QEvent::Hide) { 41 | QApplication::restoreOverrideCursor(); 42 | } 43 | return obj->eventFilter(obj, ev); 44 | } 45 | 46 | -------------------------------------------------------------------------------- /Browser/browser.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef BROWSER_H 20 | #define BROWSER_H 21 | 22 | #define mainBrowser Browser::instance() 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | class MainWindow; 29 | 30 | class Browser : public QObject 31 | { 32 | public: 33 | explicit Browser(); 34 | 35 | static Browser &instance(); 36 | 37 | MainWindow *createWindow(bool offTheRecord = false); 38 | 39 | private: 40 | QVector mainWindows; 41 | 42 | QScopedPointer m_profile; 43 | 44 | }; 45 | 46 | #endif // BROWSER_H 47 | -------------------------------------------------------------------------------- /Net/Net.pro: -------------------------------------------------------------------------------- 1 | QT -= gui 2 | QT += core network core-private network-private widgets qml concurrent 3 | 4 | TEMPLATE = lib 5 | DEFINES += NET_LIBRARY 6 | 7 | CONFIG += c++11 8 | CONFIG -= debug_and_release 9 | 10 | # You can make your code fail to compile if it uses deprecated APIs. 11 | # In order to do so, uncomment the following line. 12 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 13 | 14 | SOURCES += \ 15 | dappinstaller.cpp \ 16 | downloaditem.cpp \ 17 | httpmanager.cpp \ 18 | internalnetworkreply.cpp \ 19 | net.cpp \ 20 | networkaccessmanagerfactory.cpp \ 21 | networkdiskcache.cpp \ 22 | urlhelper.cpp 23 | 24 | HEADERS += \ 25 | Net_global.h \ 26 | dappinstaller.h \ 27 | downloaditem.h \ 28 | downloaditem_p.h \ 29 | httpmanager.h \ 30 | internalnetworkreply.h \ 31 | net.h \ 32 | networkaccessmanagerfactory.h \ 33 | networkdiskcache.h \ 34 | networkdiskcache_p.h \ 35 | semver.h \ 36 | urlhelper.h 37 | 38 | INCLUDEPATH += $$PWD/App 39 | DEPENDPATH += $$PWD/App 40 | INCLUDEPATH += $$PWD/../3rdparty/libgit2/include 41 | DEPENDPATH += $$PWD/../3rdparty/libgit2/include 42 | 43 | include(../App/App.pri) 44 | 45 | LIBS += -L$$OUT_PWD/../App/ -lApp 46 | win32 { 47 | LIBS += -L$$PWD/../3rdparty/libgit2/build/Release -lgit2 48 | } 49 | 50 | # Default rules for deployment. 51 | unix { 52 | target.path = /usr/lib 53 | LIBS += -L$$PWD/../3rdparty/libgit2/build -lgit2 54 | } 55 | !isEmpty(target.path): INSTALLS += target 56 | 57 | -------------------------------------------------------------------------------- /App/mainapplication.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef MAINAPPLICATION_H 20 | #define MAINAPPLICATION_H 21 | 22 | #define mainApp MainApplication::instance() 23 | 24 | #include 25 | #include "App_global.h" 26 | 27 | 28 | class APP_EXPORT MainApplication : public QApplication 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit MainApplication(int &argc, char** argv); 33 | ~MainApplication(); 34 | 35 | static MainApplication* instance(); 36 | 37 | bool authDialog(QString &user, QString &password, const QString title, const QString header, QWidget *parent); 38 | 39 | }; 40 | 41 | #endif // MAINAPPLICATION_H 42 | -------------------------------------------------------------------------------- /Api/locationurl.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef LOCATIONURL_H 20 | #define LOCATIONURL_H 21 | 22 | #include 23 | #include 24 | #include "Api_global.h" 25 | 26 | class API_EXPORT LocationUrl : public QObject 27 | { 28 | Q_OBJECT 29 | public: 30 | explicit LocationUrl(QObject *parent = nullptr); 31 | 32 | QUrl url() {return m_url;} 33 | 34 | void setUrl(const QUrl url) { 35 | m_url = url; 36 | } 37 | 38 | bool setRawUrl(const QString rawUrl); 39 | 40 | signals: 41 | 42 | void urlChanged(const QUrl &url); 43 | 44 | private: 45 | 46 | QUrl m_url; 47 | 48 | }; 49 | 50 | #endif // LOCATIONURL_H 51 | -------------------------------------------------------------------------------- /Browser/icons/download.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Api/bookmarkitemmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef BOOKMARKITEMMODEL_H 2 | #define BOOKMARKITEMMODEL_H 3 | 4 | #include 5 | #include "bookmarkitem.h" 6 | #include "Api_global.h" 7 | 8 | class API_EXPORT BookmarkItemModel : public QAbstractListModel 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit BookmarkItemModel(QObject *parent = nullptr); 13 | ~BookmarkItemModel(); 14 | static BookmarkItemModel& instance(QObject *parent = nullptr); 15 | 16 | void populate(); 17 | 18 | void addItem(BookmarkItem *item); 19 | 20 | Q_INVOKABLE void add(const QVariantMap &data); 21 | Q_INVOKABLE void insert(int row, const QVariantMap &data); 22 | 23 | void updateItem(BookmarkItem *item); 24 | 25 | bool removeItem(qint64 const index); 26 | 27 | int rowCount(const QModelIndex & parent = QModelIndex()) const override; 28 | 29 | QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override; 30 | 31 | bool setData(const QModelIndex &index, const QVariant &value, int role) override; 32 | 33 | Q_INVOKABLE QVariantMap get(int row) const; 34 | 35 | Q_INVOKABLE void save(const QVariantMap &data); 36 | 37 | Q_INVOKABLE void remove(const int id); 38 | 39 | Q_INVOKABLE bool setProperty(const int idx, const QString name, const QVariant value); 40 | 41 | QHash roleNames() const override; 42 | protected: 43 | 44 | private: 45 | BookmarkItemModel(const BookmarkItemModel&other); 46 | BookmarkItemModel& operator=(const BookmarkItemModel&other); 47 | 48 | QList m_items; 49 | 50 | }; 51 | 52 | #endif // BOOKMARKITEMMODEL_H 53 | -------------------------------------------------------------------------------- /Api/historydb.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef HISTORYDB_H 20 | #define HISTORYDB_H 21 | 22 | #include "historyitem.h" 23 | #include "appdb.h" 24 | #include "Api_global.h" 25 | 26 | class API_EXPORT HistoryDb : public AppDb 27 | { 28 | public: 29 | HistoryDb(); 30 | 31 | bool create() override; 32 | 33 | int static insert(const HistoryItem &item); 34 | 35 | bool static update(const HistoryItem &item); 36 | 37 | bool static remove(const int id); 38 | 39 | QList static list(); 40 | 41 | static QList *findByText(const QString &text); 42 | 43 | static HistoryItem *findByUrl(const QUrl &url); 44 | 45 | }; 46 | 47 | #endif // HISTORYDB_H 48 | -------------------------------------------------------------------------------- /Api/tools/common/SortFilterModel.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2 | import QtQml.Models 2.3 3 | 4 | DelegateModel { 5 | id: delegateModel 6 | 7 | property var lessThan: function(left, right) { return true; } 8 | property var filterAcceptsItem: function(item) { return true; } 9 | 10 | function update() { 11 | if (items.count > 0) { 12 | items.setGroups(0, items.count, "items"); 13 | } 14 | 15 | // Filter items 16 | let visible = []; 17 | let item; 18 | for (let i = 0; i < items.count; ++i) { 19 | item = items.get(i); 20 | if (filterAcceptsItem(item.model)) { 21 | visible.push(item); 22 | } 23 | } 24 | 25 | // Sort the list of visible items 26 | visible.sort(function(a, b) { 27 | return lessThan(a.model, b.model) ? -1 : 1; 28 | }); 29 | 30 | // Add all items to the visible group: 31 | for (let i = 0; i < visible.length; ++i) { 32 | item = visible[i]; 33 | item.inVisible = true; 34 | if (item.visibleIndex !== i) { 35 | visibleItems.move(item.visibleIndex, i, 1); 36 | } 37 | } 38 | } 39 | 40 | function modelByIndex(idx) { 41 | return model.get(idx); 42 | } 43 | 44 | items.onChanged: update() 45 | onLessThanChanged: update() 46 | onFilterAcceptsItemChanged: update() 47 | 48 | groups: DelegateModelGroup { 49 | id: visibleItems 50 | 51 | name: "visible" 52 | includeByDefault: false 53 | } 54 | 55 | filterOnGroup: "visible" 56 | } 57 | -------------------------------------------------------------------------------- /Browser/webpopupwindow.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef WEBPOPUPWINDOW_H 20 | #define WEBPOPUPWINDOW_H 21 | 22 | #include 23 | #include "htmlview.h" 24 | 25 | QT_BEGIN_NAMESPACE 26 | class QLineEdit; 27 | class QWebEngineProfile; 28 | class QWebEngineView; 29 | QT_END_NAMESPACE 30 | 31 | class WebPopupWindow : public QWidget 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | WebPopupWindow(QWebEngineProfile *profile); 37 | HtmlView *view() const; 38 | 39 | private slots: 40 | void handleGeometryChangeRequested(const QRect &newGeometry); 41 | 42 | private: 43 | QLineEdit *m_urlLineEdit; 44 | QAction *m_favAction; 45 | HtmlView *m_view; 46 | }; 47 | #endif // WEBPOPUPWINDOW_H 48 | -------------------------------------------------------------------------------- /Api/log.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "log.h" 20 | 21 | Log::Log(QObject *parent) : QObject(parent) 22 | { 23 | 24 | } 25 | 26 | void Log::debug(const QString message) 27 | { 28 | write(message, lineType::L_DEBUG); 29 | } 30 | 31 | 32 | void Log::error(const QString message) 33 | { 34 | write(message, lineType::L_ERROR); 35 | } 36 | 37 | void Log::clear() 38 | { 39 | logList.clear(); 40 | emit cleared(); 41 | } 42 | 43 | QList Log::logRecords() 44 | { 45 | return logList; 46 | } 47 | 48 | void Log::write(const QString message, const Log::lineType type) 49 | { 50 | logLine line = logLine{message, type}; 51 | logList << line; 52 | emit append(&line); 53 | } 54 | 55 | -------------------------------------------------------------------------------- /Api/accessrights.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef ACCESSRIGHTS_H 20 | #define ACCESSRIGHTS_H 21 | 22 | #include "Api_global.h" 23 | 24 | class API_EXPORT AccessRights 25 | { 26 | 27 | public: 28 | explicit AccessRights() {}; 29 | 30 | virtual ~AccessRights() {}; 31 | 32 | bool allowDownloadsHistory = false; 33 | 34 | bool allowVisitHitory = false; 35 | 36 | bool allowSetings = false; 37 | 38 | bool allowBookmark = false; 39 | 40 | void allowAllInternalAccess() { 41 | allowDownloadsHistory = true; 42 | allowVisitHitory = true; 43 | allowSetings = true; 44 | allowBookmark = true; 45 | }; 46 | 47 | 48 | 49 | }; 50 | 51 | 52 | #endif // ACCESSRIGHTS_H 53 | -------------------------------------------------------------------------------- /Browser/qmldevtools.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef QMLDEVTOOLS_H 20 | #define QMLDEVTOOLS_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | class QmlDevTools : public QWidget 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit QmlDevTools(Log *log, QWidget *parent = nullptr); 33 | 34 | public Q_SLOTS: 35 | void writeLogLine(const Log::logLine *line); 36 | 37 | void clearLog(); 38 | 39 | private: 40 | QVBoxLayout *layout; 41 | 42 | Log *log; 43 | 44 | QListView *logView; 45 | 46 | QStandardItemModel *logModel; 47 | 48 | bool autoScrollToBottom = false; 49 | 50 | }; 51 | 52 | #endif // QMLDEVTOOLS_H 53 | -------------------------------------------------------------------------------- /Api/downloadbutton.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef DOWNLOADBUTTON_H 20 | #define DOWNLOADBUTTON_H 21 | 22 | #include 23 | #include "downloaditem.h" 24 | #include 25 | #include "Api_global.h" 26 | 27 | class API_EXPORT DownloadButton : public QToolButton 28 | { 29 | public: 30 | explicit DownloadButton(DownloadItem *downloadItem, QWidget *parent = nullptr); 31 | 32 | void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); 33 | 34 | 35 | protected: 36 | void paintEvent(QPaintEvent *p) override; 37 | private: 38 | QAction *openAction; 39 | 40 | QAction *cancelAction; 41 | 42 | DownloadItem *m_downloadItem; 43 | 44 | QString m_underInfo = nullptr; 45 | 46 | QString m_totalInfo = nullptr; 47 | 48 | }; 49 | 50 | #endif // DOWNLOADBUTTON_H 51 | -------------------------------------------------------------------------------- /Api/bookmarklinkmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef BOOKMARKLINKMODEL_H 2 | #define BOOKMARKLINKMODEL_H 3 | 4 | #include 5 | #include "bookmarklinkitem.h" 6 | #include "Api_global.h" 7 | 8 | class API_EXPORT BookmarkLinkModel : public QAbstractListModel 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit BookmarkLinkModel(QObject *parent = nullptr); 13 | ~BookmarkLinkModel(); 14 | static BookmarkLinkModel& instance(QObject *parent = nullptr); 15 | 16 | void populate(); 17 | 18 | Q_INVOKABLE void addItem(BookmarkLinkItem *item); 19 | 20 | static bool addNewItem(const QString title, const QUrl link, const QUrl icon, const QString html, const QString description); 21 | 22 | Q_INVOKABLE void updateItem(BookmarkLinkItem *item); 23 | 24 | Q_INVOKABLE bool removeItem(qint64 const index); 25 | 26 | Q_INVOKABLE int count(QString const queryType, QVariantMap const args); 27 | 28 | Q_INVOKABLE int updateLinksBookmark(int const oldBookmarkId, int const newBookmarkId); 29 | 30 | int rowCount(const QModelIndex & parent = QModelIndex()) const override; 31 | 32 | QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override; 33 | 34 | bool setData(const QModelIndex &index, const QVariant &value, int role) override; 35 | 36 | Q_INVOKABLE QVariantMap get(int row) const; 37 | 38 | Q_INVOKABLE void save(const QVariantMap &data); 39 | 40 | protected: 41 | QHash roleNames() const override; 42 | private: 43 | BookmarkLinkModel(const BookmarkLinkModel&other); 44 | BookmarkLinkModel& operator=(const BookmarkLinkModel&other); 45 | 46 | QList m_items; 47 | 48 | int m_changedRow = 0; 49 | }; 50 | 51 | #endif // BOOKMARKLINKMODEL_H 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Browser/browserpaths.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef BROWSERPATHS_H 20 | #define BROWSERPATHS_H 21 | 22 | #include 23 | #include 24 | 25 | class BrowserPaths : public AppPaths 26 | { 27 | public: 28 | BrowserPaths(); 29 | 30 | QLatin1String const static historyManagerName; 31 | QLatin1String const static downloadManagerName; 32 | QLatin1String const static bookmarksManagerName; 33 | QLatin1String const static settingsManagerName; 34 | QLatin1String const static blankPageName; 35 | QLatin1String const static errorPageName; 36 | QString const static installPageName; 37 | 38 | QString static historyManagerPath(); 39 | QString static downloadManagerPath(); 40 | QString static settingsManagerPath(); 41 | 42 | QUrl static installPageUrl(); 43 | 44 | }; 45 | 46 | #endif // BROWSERPATHS_H 47 | -------------------------------------------------------------------------------- /Net/urlhelper.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef URLHELPER_H 20 | #define URLHELPER_H 21 | 22 | #include 23 | #include "Net_global.h" 24 | 25 | #define INTERNAL_URL_SCHEME QLatin1String("internal") 26 | #define DAPP_URL_SCHEME QLatin1String("dapp") 27 | #define QML_MAIN_FILE QString("main.qml") 28 | #define HTML_MAIN_FILE QString("main.html") 29 | #define DIR_ALTER_SP QLatin1Char('@') 30 | 31 | class NET_EXPORT UrlHelper 32 | { 33 | public: 34 | UrlHelper(); 35 | 36 | bool static isLocalSource(const QUrl &url); 37 | 38 | QUrl static urlToLocalPath(const QUrl &url, bool toDir = false); 39 | 40 | QUrl static assertFilename(const QUrl &url); 41 | 42 | QString static urlLocalPath(const QUrl &url); 43 | 44 | QString static urlLocalDataPath(const QUrl &url); 45 | 46 | QUrl static gitToDappUrl(const QUrl &url); 47 | 48 | 49 | }; 50 | 51 | #endif // URLHELPER_H 52 | -------------------------------------------------------------------------------- /Browser/downloaditemproxy.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef DOWNLOADITEMPROXY_H 20 | #define DOWNLOADITEMPROXY_H 21 | 22 | #include 23 | #include 24 | 25 | class DownloadItemProxy : public DownloadItem 26 | { 27 | Q_OBJECT 28 | public: 29 | explicit DownloadItemProxy(QWebEngineDownloadRequest *item, QObject *parent = nullptr); 30 | 31 | void sync(); 32 | 33 | DownloadState state() const override; 34 | 35 | QString downloadDirectory() const override; 36 | 37 | QString downloadFileName() const override; 38 | void setDownloadFileName(QString fileName) override; 39 | 40 | public Q_SLOTS: 41 | void accept() override; 42 | void cancel() override; 43 | void pause() override; 44 | void resume() override; 45 | void receivedBytesChanged(); 46 | 47 | private: 48 | QWebEngineDownloadRequest *m_item; 49 | }; 50 | 51 | #endif // DOWNLOADITEMPROXY_H 52 | -------------------------------------------------------------------------------- /Net/networkaccessmanagerfactory.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "networkaccessmanagerfactory.h" 20 | #include 21 | #include "httpmanager.h" 22 | 23 | QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent) 24 | { 25 | auto httpManager = new HttpManager(parent); 26 | 27 | if(m_cache) { 28 | httpManager->setCache(m_cache); 29 | } 30 | httpManager->setUserAgent(m_userAgent); 31 | httpManager->setReloading(m_reloading); 32 | 33 | return httpManager; 34 | } 35 | 36 | void NetworkAccessManagerFactory::setMaxCacheSize(qint64 size) 37 | { 38 | m_cache->setMaximumCacheSize(size); 39 | } 40 | 41 | void NetworkAccessManagerFactory::enableCache(QString cacheDir, QObject *parent) 42 | { 43 | m_cache = new NetworkDiskCache(cacheDir, parent); 44 | } 45 | 46 | void NetworkAccessManagerFactory::setUserAgent(const QString userAgent) 47 | { 48 | m_userAgent = userAgent; 49 | } 50 | -------------------------------------------------------------------------------- /Browser/browsersettings.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef BROWSERSETTINGS_H 20 | #define BROWSERSETTINGS_H 21 | 22 | #define browserSettings BrowserSettings::instance() 23 | 24 | #include 25 | #include 26 | 27 | class BrowserSettings : public Settings 28 | { 29 | Q_OBJECT 30 | Q_PROPERTY(QString browserSearchEngine READ searchEngine WRITE setSearchEngine NOTIFY searchEngineChanged) 31 | Q_PROPERTY(QStringList browserSearchEngineList READ searchEngineList CONSTANT) 32 | public: 33 | 34 | static BrowserSettings *instance(const QString &fileName = nullptr, QObject *parent = nullptr); 35 | 36 | void setSearchEngine(QString value); 37 | QString searchEngine(); 38 | 39 | QStringList searchEngineList(); 40 | 41 | signals: 42 | 43 | void searchEngineChanged(QString); 44 | 45 | private: 46 | 47 | explicit BrowserSettings(const QString &fileName, Format format, QObject *parent); 48 | 49 | }; 50 | 51 | #endif // BROWSERSETTINGS_H 52 | -------------------------------------------------------------------------------- /Api/log.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef LOG_H 20 | #define LOG_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include "Api_global.h" 27 | 28 | class API_EXPORT Log : public QObject 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit Log(QObject *parent = nullptr); 33 | 34 | Q_INVOKABLE void debug(const QString message); 35 | 36 | Q_INVOKABLE void error(const QString message); 37 | 38 | void clear(); 39 | 40 | enum lineType { 41 | L_DEBUG, 42 | L_ERROR 43 | }; 44 | Q_ENUM(lineType); 45 | 46 | struct logLine { 47 | QString text; 48 | lineType type; 49 | }; 50 | 51 | 52 | QList logRecords(); 53 | 54 | signals: 55 | 56 | void append(Log::logLine *line); 57 | void cleared(); 58 | 59 | 60 | private: 61 | 62 | void write(const QString message, const lineType type); 63 | 64 | QList logList; 65 | 66 | }; 67 | 68 | #endif // LOG_H 69 | -------------------------------------------------------------------------------- /Api/downloadmanagerwidget.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef DOWNLOADMANAGERWIDGET_H 20 | #define DOWNLOADMANAGERWIDGET_H 21 | 22 | #include 23 | #include "downloaditem.h" 24 | #include 25 | #include "downloadbutton.h" 26 | #include 27 | #include "downloaditemmodel.h" 28 | #include "Api_global.h" 29 | 30 | class API_EXPORT DownloadManagerWidget : public QToolBar 31 | { 32 | Q_OBJECT 33 | public: 34 | explicit DownloadManagerWidget(QWidget *parent = nullptr); 35 | 36 | void downloadRequested(DownloadItem *downloadItem); 37 | 38 | DownloadItemModel *downloadItemModel() {return m_downloadItemModel;}; 39 | 40 | QAction *showAllAction; 41 | 42 | QAction *closeAction; 43 | 44 | signals: 45 | void closeManager(); 46 | void showAllTriggered(); 47 | 48 | private: 49 | void add(DownloadButton *downloadButton); 50 | void remove(DownloadButton *downloadButton); 51 | 52 | int m_numDownloads; 53 | 54 | DownloadItemModel *m_downloadItemModel; 55 | }; 56 | 57 | #endif // DOWNLOADMANAGERWIDGET_H 58 | -------------------------------------------------------------------------------- /Net/networkaccessmanagerfactory.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef NETWORKACCESSMANAGERFACTORY_H 20 | #define NETWORKACCESSMANAGERFACTORY_H 21 | 22 | #include "Net_global.h" 23 | #include 24 | #include "networkdiskcache.h" 25 | 26 | class NET_EXPORT NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory 27 | { 28 | public: 29 | 30 | QNetworkAccessManager *create(QObject *parent) override; 31 | 32 | void setMaxCacheSize(qint64 size); 33 | 34 | void enableCache(QString cacheDir, QObject *parent); 35 | 36 | void setUserAgent(const QString userAgent); 37 | 38 | void setReloading(const bool reloading) { 39 | m_reloading = reloading; 40 | } 41 | 42 | bool reloading() { 43 | return m_reloading; 44 | } 45 | 46 | private: 47 | 48 | QObject *m_parent; 49 | 50 | static qint64 m_maxCacheSize; 51 | 52 | QString m_userAgent; 53 | 54 | bool m_reloading = false; 55 | 56 | NetworkDiskCache *m_cache = nullptr; 57 | }; 58 | 59 | #endif // NETWORKACCESSMANAGERFACTORY_H 60 | -------------------------------------------------------------------------------- /Net/internalnetworkreply.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef INTERNALNETWORKREPLY_H 20 | #define INTERNALNETWORKREPLY_H 21 | 22 | #include 23 | 24 | class InternalNetworkReply : public QNetworkReply 25 | { 26 | Q_OBJECT 27 | public: 28 | explicit InternalNetworkReply(QObject *parent = nullptr); 29 | ~InternalNetworkReply(); 30 | 31 | void setHttpStatusCode( int code, const QByteArray &statusText = QByteArray() ); 32 | void setHeader( QNetworkRequest::KnownHeaders header, const QVariant &value ); 33 | void setContentType( const QByteArray &contentType ); 34 | 35 | void setContent( const QString &content ); 36 | void setContent( const QByteArray &content ); 37 | void setUrl(const QUrl &url); 38 | 39 | void abort(); 40 | qint64 bytesAvailable() const; 41 | bool isSequential() const; 42 | 43 | protected: 44 | qint64 readData(char *data, qint64 maxSize); 45 | 46 | private: 47 | struct InternalNetworkReplyPrivate *d; 48 | }; 49 | 50 | #endif // INTERNALNETWORKREPLY_H 51 | -------------------------------------------------------------------------------- /App/appdb.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef APPDB_H 20 | #define APPDB_H 21 | 22 | #include 23 | #include 24 | #include "App_global.h" 25 | 26 | class APP_EXPORT AppDb : public QObject 27 | { 28 | Q_OBJECT 29 | public: 30 | explicit AppDb(); 31 | 32 | const QString dbFullName(); 33 | static const QVariantMap queryToMap(QSqlQuery *query); 34 | 35 | bool connect(); 36 | bool open(); 37 | void close(); 38 | virtual bool create() = 0; 39 | 40 | bool queryError(const QString command, const QString error); 41 | bool queryError(const QLatin1String tableName, const QString command, const QString error); 42 | bool removeRecord(const int id); 43 | bool removeRecord(const QLatin1String tableName, const int id); 44 | 45 | QLatin1String dbName; 46 | 47 | 48 | signals: 49 | 50 | 51 | protected: 52 | 53 | QLatin1String m_dbName; 54 | 55 | QLatin1String m_tableName; 56 | 57 | QSqlDatabase m_db; 58 | 59 | private: 60 | 61 | static QMap m_dbs; 62 | 63 | }; 64 | 65 | #endif // APPDB_H 66 | -------------------------------------------------------------------------------- /Api/window.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "window.h" 20 | #include 21 | #include 22 | 23 | Window::Window(QObject *parent) : QObject(parent) 24 | { 25 | 26 | } 27 | 28 | bool Window::open(const QString url) 29 | { 30 | emit newTabRequested(url); 31 | return true; 32 | } 33 | 34 | bool Window::open(const QString url, const QString windowName) 35 | { 36 | if(windowName == "_blank") { 37 | emit newTabRequested(url); 38 | } else { 39 | emit newWindowRequested(url, windowName, ""); 40 | } 41 | return true; 42 | } 43 | 44 | bool Window::open(const QString url, const QString windowName, const QString windowFeatures) 45 | { 46 | emit newWindowRequested(url, windowName, windowFeatures); 47 | return true; 48 | } 49 | 50 | void Window::setWidth(int width) 51 | { 52 | if(m_width != width) { 53 | m_width = width; 54 | emit widthChanged(); 55 | } 56 | } 57 | 58 | void Window::setHeight(int height) 59 | { 60 | if(m_height != height) { 61 | m_height = height; 62 | emit heightChanged(); 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /Browser/browsersettings.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "browsersettings.h" 20 | #include "searchengine.h" 21 | 22 | #define BROWSER_GROUP QLatin1String("Browser") 23 | 24 | BrowserSettings::BrowserSettings(const QString &fileName, Format format, QObject *parent) 25 | : Settings(fileName, format, parent) 26 | { 27 | 28 | } 29 | 30 | BrowserSettings *BrowserSettings::instance(const QString &fileName, QObject *parent) 31 | { 32 | static BrowserSettings instance(fileName, QSettings::IniFormat, parent); 33 | return &instance; 34 | } 35 | 36 | void BrowserSettings::setSearchEngine(QString value) 37 | { 38 | beginGroup(BROWSER_GROUP); 39 | setValue("SearchEngine", value); 40 | endGroup(); 41 | 42 | } 43 | 44 | QString BrowserSettings::searchEngine() 45 | { 46 | beginGroup(BROWSER_GROUP); 47 | QString v = value("SearchEngine").toString(); 48 | if(v.isEmpty()) { 49 | v = QString("google.com"); 50 | } 51 | endGroup(); 52 | return v; 53 | } 54 | 55 | QStringList BrowserSettings::searchEngineList() 56 | { 57 | return SearchEngine::engineList; 58 | } 59 | 60 | -------------------------------------------------------------------------------- /Api/downloaditemmodel.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef DOWNLOADITEMMODEL_H 20 | #define DOWNLOADITEMMODEL_H 21 | 22 | #include 23 | #include 24 | #include "downloaditem.h" 25 | #include "Api_global.h" 26 | 27 | class API_EXPORT DownloadItemModel : public QAbstractListModel 28 | { 29 | Q_OBJECT 30 | public: 31 | DownloadItemModel(QObject *parent = 0); 32 | DownloadItemModel(QList items, QObject *parent = 0); 33 | 34 | enum ItemRoles { 35 | IndexRole = Qt::UserRole + 1, 36 | IdRole, 37 | NameRole, 38 | UrlRole, 39 | PathRole, 40 | ReceivedRole 41 | }; 42 | 43 | void addDownloadItem(DownloadItem *item); 44 | 45 | Q_INVOKABLE bool removeDownloadItem(qint64 const index); 46 | 47 | int rowCount(const QModelIndex & parent = QModelIndex()) const override; 48 | 49 | QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override; 50 | 51 | signals: 52 | 53 | void removeItem(const QString &id); 54 | 55 | protected: 56 | QHash roleNames() const override; 57 | 58 | private: 59 | QList m_items; 60 | }; 61 | 62 | #endif // DOWNLOADITEMMODEL_H 63 | -------------------------------------------------------------------------------- /Browser/searchengine.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "searchengine.h" 20 | #include 21 | #include "browsersettings.h" 22 | 23 | #define ENGINE_GOOGLE QLatin1String("google.com") 24 | #define ENGINE_DUCKDUCKGO QLatin1String("duckduckgo.com") 25 | #define ENGINE_YAHOO QLatin1String("yahoo.com") 26 | 27 | QStringList SearchEngine::engineList = { 28 | ENGINE_GOOGLE, 29 | ENGINE_DUCKDUCKGO, 30 | ENGINE_YAHOO 31 | }; 32 | 33 | SearchEngine::SearchEngine(QObject *parent) 34 | : QObject{parent} 35 | { 36 | 37 | } 38 | 39 | QUrl SearchEngine::searchUrl(QString text) 40 | { 41 | QString engineName = browserSettings->searchEngine(); 42 | QUrl url; 43 | QUrlQuery query; 44 | if(engineName == ENGINE_DUCKDUCKGO) { 45 | url.setUrl("https://duckduckgo.com/"); 46 | query.addQueryItem(QLatin1String("q"), text); 47 | } else if( engineName == ENGINE_YAHOO) { 48 | url.setUrl("https://search.yahoo.com/search"); 49 | query.addQueryItem(QLatin1String("p"), text); 50 | } else { 51 | url.setUrl("https://www.google.com/search"); 52 | query.addQueryItem(QLatin1String("q"), text); 53 | } 54 | url.setQuery(query); 55 | return url; 56 | } 57 | -------------------------------------------------------------------------------- /Api/Api.pro: -------------------------------------------------------------------------------- 1 | QT -= gui 2 | QT += qml widgets widgets-private sql 3 | 4 | TEMPLATE = lib 5 | DEFINES += API_LIBRARY 6 | 7 | CONFIG += c++11 8 | CONFIG -= debug_and_release 9 | 10 | # You can make your code fail to compile if it uses deprecated APIs. 11 | # In order to do so, uncomment the following line. 12 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 13 | 14 | SOURCES += \ 15 | api.cpp \ 16 | apicommon.cpp \ 17 | apiweb.cpp \ 18 | bookmarkdb.cpp \ 19 | bookmarkitem.cpp \ 20 | bookmarkitemmodel.cpp \ 21 | bookmarklinkitem.cpp \ 22 | bookmarklinkmodel.cpp \ 23 | document.cpp \ 24 | downloadbutton.cpp \ 25 | downloaddb.cpp \ 26 | downloaditemmodel.cpp \ 27 | downloadmanagerwidget.cpp \ 28 | dynamicobject.cpp \ 29 | historydb.cpp \ 30 | historyitem.cpp \ 31 | historyitemmodel.cpp \ 32 | location.cpp \ 33 | locationurl.cpp \ 34 | log.cpp \ 35 | qi.cpp \ 36 | qmlvalue.cpp \ 37 | tools.cpp \ 38 | window.cpp 39 | 40 | HEADERS += \ 41 | Api_global.h \ 42 | accessrights.h \ 43 | api.h \ 44 | apicommon.h \ 45 | apiweb.h \ 46 | bookmarkdb.h \ 47 | bookmarkitem.h \ 48 | bookmarkitemmodel.h \ 49 | bookmarklinkitem.h \ 50 | bookmarklinkmodel.h \ 51 | document.h \ 52 | downloadbutton.h \ 53 | downloaddb.h \ 54 | downloaditemmodel.h \ 55 | downloadmanagerwidget.h \ 56 | dynamicobject.h \ 57 | historydb.h \ 58 | historyitem.h \ 59 | historyitemmodel.h \ 60 | location.h \ 61 | locationurl.h \ 62 | log.h \ 63 | qi.h \ 64 | qmlvalue.h \ 65 | tools.h \ 66 | window.h 67 | 68 | INCLUDEPATH += $$PWD/../Net 69 | INCLUDEPATH += $$PWD/../App 70 | 71 | include(../App/App.pri) 72 | include(../Net/Net.pri) 73 | 74 | # Default rules for deployment. 75 | unix { 76 | target.path = /usr/lib 77 | } 78 | !isEmpty(target.path): INSTALLS += target 79 | 80 | DISTFILES += \ 81 | Api.pri \ 82 | tools/downloads/main.qml \ 83 | tools/error/main.qml 84 | 85 | LIBS += -L$$OUT_PWD/../App/ -lApp 86 | LIBS += -L$$OUT_PWD/../Net/ -lNet 87 | 88 | 89 | -------------------------------------------------------------------------------- /Browser/baseview.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef BASEVIEW_H 20 | #define BASEVIEW_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | class BaseView 28 | { 29 | 30 | public: 31 | explicit BaseView(QSplitter *splitter) { 32 | m_splitter = splitter; 33 | }; 34 | 35 | virtual ~BaseView() {}; 36 | 37 | static const int TYPE_HTML = 1; 38 | 39 | static const int TYPE_QML = 2; 40 | 41 | virtual void setContent(const QByteArray &content, const QString &mimeType, const QUrl &baseUrl) = 0; 42 | 43 | virtual qreal zoomFactor() = 0; 44 | 45 | virtual void setZoomFactor(const qreal factor) = 0; 46 | 47 | virtual void toggleDevTools() = 0; 48 | 49 | virtual void setUrl(const QUrl &url) = 0; 50 | 51 | virtual const QString title() = 0; 52 | 53 | virtual const QUrl iconUrl() = 0; 54 | 55 | virtual const QString description() = 0; 56 | 57 | virtual int viewType() = 0; 58 | 59 | virtual void reload() = 0; 60 | 61 | virtual void navTyped(const QString &text) = 0; 62 | 63 | virtual bool addToBookmark() = 0; 64 | 65 | protected: 66 | 67 | QSplitter *m_splitter; 68 | 69 | }; 70 | 71 | #endif // BASEVIEW_H 72 | -------------------------------------------------------------------------------- /App/settings.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef SETTINGS_H 20 | #define SETTINGS_H 21 | 22 | #include "App_global.h" 23 | #include 24 | 25 | class APP_EXPORT Settings : public QSettings 26 | { 27 | Q_OBJECT 28 | Q_PROPERTY(QString appUserAgent READ appUserAgent WRITE setAppUserAgent NOTIFY appUserAgentChanged) 29 | Q_PROPERTY(QString appCacheMaxSize READ appCacheMaxSize WRITE setAppCacheMaxSize NOTIFY appCacheMaxSizeChanged) 30 | Q_PROPERTY(QString appStyle READ appStyle WRITE setAppStyle NOTIFY appStyleChanged) 31 | public: 32 | explicit Settings(const QString &fileName, QSettings::Format format, QObject *parent = nullptr); 33 | 34 | void setAppUserAgent(QString value); 35 | QString appUserAgent(); 36 | 37 | void setAppCacheMaxSize(QString value); 38 | QString appCacheMaxSize(); 39 | 40 | void setAppStyle(QString value); 41 | QString appStyle(); 42 | 43 | void initDefaultUserAgent(QString userAgent); 44 | QString defaultUserAgent(); 45 | 46 | signals: 47 | void appUserAgentChanged(QString userAgent); 48 | void appStyleChanged(QString style); 49 | void appCacheMaxSizeChanged(qint8 appCacheMaxSize); 50 | private: 51 | QString m_defaultUserAgent; 52 | }; 53 | 54 | #endif // SETTINGS_H 55 | -------------------------------------------------------------------------------- /Api/tools.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "tools.h" 20 | 21 | Tools::Tools() 22 | { 23 | 24 | } 25 | 26 | QString Tools::bytesToText(double bytes) 27 | { 28 | if(bytes) { 29 | if(bytes > 1024 * 1024 * 1024) { 30 | return QString::asprintf("%.2fGb", bytes / 1024 / 1024 / 1024); 31 | } else if(bytes > 1024 * 1024) { 32 | return QString::asprintf("%.2fMb", bytes / 1024 / 1024); 33 | } else if(bytes > 1024) { 34 | return QString::asprintf("%.2fKb", bytes / 1024); 35 | } 36 | 37 | return QString::asprintf("%d", (int) bytes); 38 | } 39 | return QString(""); 40 | } 41 | 42 | QVariantMap Tools::QJSValueToMap(QJSValue obj) 43 | { 44 | QVariantMap map; 45 | 46 | // JS Object 47 | if(obj.prototype().hasOwnProperty("__proto__")) { 48 | QJSValueIterator it(obj); 49 | while (it.hasNext()) { 50 | it.next(); 51 | map.insert(it.name(), it.value().toVariant()); 52 | } 53 | } else { // QAbstractItemModel 54 | QJSValueIterator it(obj.prototype()); 55 | while (it.hasNext()) { 56 | it.next(); 57 | map.insert(it.name(), obj.property(it.name()).toVariant()); 58 | } 59 | } 60 | 61 | return map; 62 | } 63 | -------------------------------------------------------------------------------- /Browser/mainwindow.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef MAINWINDOW_H 20 | #define MAINWINDOW_H 21 | 22 | #include 23 | #include "tabwidget.h" 24 | #include "navigationbar.h" 25 | #include 26 | #include 27 | #include "../Api/downloadmanagerwidget.h" 28 | #include 29 | 30 | 31 | class MainWindow : public QMainWindow 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | MainWindow(QWebEngineProfile *profile); 37 | ~MainWindow(); 38 | 39 | NavigationBar *navigationBar; 40 | 41 | QSize sizeHint() const override; 42 | 43 | TabWidget *tabWidget; 44 | 45 | void htmlDownloadRequested(QWebEngineDownloadRequest *item); 46 | void closeDownloadManager(); 47 | 48 | DownloadManagerWidget *downloadManagerWidget() { 49 | return m_downloadManagerWidget; 50 | }; 51 | 52 | 53 | public Q_SLOT: 54 | void handleLoadProgress(int progress); 55 | 56 | protected: 57 | void closeEvent(QCloseEvent *event) override; 58 | 59 | private: 60 | QWebEngineProfile *m_profile; 61 | 62 | DownloadManagerWidget *m_downloadManagerWidget = nullptr; 63 | 64 | void handleWebViewTitleChanged(const QString &title); 65 | 66 | QProgressBar *m_progressBar = nullptr; 67 | 68 | }; 69 | #endif // MAINWINDOW_H 70 | -------------------------------------------------------------------------------- /Api/location.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef LOCATION_H 20 | #define LOCATION_H 21 | 22 | #include 23 | #include 24 | #include "locationurl.h" 25 | #include "Api_global.h" 26 | 27 | class API_EXPORT Location 28 | { 29 | Q_GADGET 30 | Q_PROPERTY(QString href READ href WRITE setHref) 31 | 32 | public: 33 | explicit Location(); 34 | 35 | void setLocationUrl(LocationUrl * locationUrl) 36 | { 37 | m_locationUrl = locationUrl; 38 | }; 39 | 40 | QString href() 41 | { 42 | return m_locationUrl->url().toString(); 43 | }; 44 | 45 | bool setHref(QString href) 46 | { 47 | return m_locationUrl->setRawUrl(href); 48 | } 49 | 50 | QString toString() const 51 | { 52 | return m_locationUrl->url().toString(); 53 | } 54 | 55 | friend inline bool operator!=(const Location& lhs, const Location& rhs) 56 | { 57 | 58 | return !(lhs.m_locationUrl == rhs.m_locationUrl); 59 | } 60 | 61 | friend inline bool operator==(const Location& lhs, const Location& rhs) 62 | { 63 | return (lhs.m_locationUrl == rhs.m_locationUrl); // Reqursive call 64 | } 65 | 66 | signals: 67 | 68 | private: 69 | LocationUrl *m_locationUrl; 70 | }; 71 | 72 | Q_DECLARE_METATYPE(Location) 73 | 74 | 75 | #endif // LOCATION_H 76 | -------------------------------------------------------------------------------- /Net/httpmanager.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef HTTPMANAGER_H 20 | #define HTTPMANAGER_H 21 | 22 | #include 23 | #include "downloaditem.h" 24 | #include 25 | #include "Net_global.h" 26 | 27 | #define QML_MIME QLatin1String("text/qml") 28 | #define HTML_MIME QLatin1String("text/html") 29 | #define HTML_EXT QLatin1String("html") 30 | 31 | class NET_EXPORT HttpManager : public QNetworkAccessManager 32 | { 33 | Q_OBJECT 34 | public: 35 | 36 | explicit HttpManager(QObject *parent = Q_NULLPTR); 37 | 38 | void authentication(const QUrl &url, QAuthenticator *auth, QWidget *parent = Q_NULLPTR); 39 | void proxyAuthentication(const QString &proxyHost, QAuthenticator *auth, QWidget *parent = Q_NULLPTR); 40 | 41 | QFileInfo uniqueFileName(QString path, QUrl url); 42 | DownloadItem *download(QUrl url); 43 | void setUserAgent(const QString userAgent); 44 | 45 | void setReloading(const bool reloading) { 46 | m_reloading = reloading; 47 | }; 48 | 49 | protected: 50 | QNetworkReply *createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData) override; 51 | private: 52 | 53 | QString m_userAgent; 54 | 55 | QList m_downloadItems; 56 | 57 | bool m_reloading = false; 58 | }; 59 | 60 | #endif // HTTPMANAGER_H 61 | -------------------------------------------------------------------------------- /Api/window.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef WINDOW_H 20 | #define WINDOW_H 21 | 22 | #include 23 | #include 24 | #include "location.h" 25 | #include "Api_global.h" 26 | 27 | class API_EXPORT Window : public QObject 28 | { 29 | Q_OBJECT 30 | Q_PROPERTY(Location location MEMBER location) 31 | Q_PROPERTY(int width READ width NOTIFY widthChanged) 32 | Q_PROPERTY(int height READ height NOTIFY heightChanged) 33 | 34 | public: 35 | explicit Window(QObject *parent = nullptr); 36 | 37 | Q_INVOKABLE bool open(const QString url); 38 | Q_INVOKABLE bool open(const QString url, const QString windowName); 39 | Q_INVOKABLE bool open(const QString url, const QString windowName, const QString windowFeatures); 40 | 41 | Location location; 42 | 43 | void setWidth(int width); 44 | void setHeight(int width); 45 | 46 | int width() { 47 | return m_width; 48 | } 49 | 50 | int height() { 51 | return m_height; 52 | } 53 | 54 | 55 | signals: 56 | 57 | void newTabRequested(const QString url); 58 | void newWindowRequested(const QString url, const QString windowName, const QString windowFeatures); 59 | void widthChanged(); 60 | void heightChanged(); 61 | 62 | private: 63 | 64 | int m_width; 65 | int m_height; 66 | 67 | }; 68 | 69 | #endif // WINDOW_H 70 | -------------------------------------------------------------------------------- /Net/downloaditem_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef DOWNLOADITEM_P_H 20 | #define DOWNLOADITEM_P_H 21 | 22 | #include "downloaditem.h" 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | 30 | class DownloadItemPrivate : public QObjectPrivate { 31 | DownloadItem *q_ptr; 32 | 33 | public: 34 | Q_DECLARE_PUBLIC(DownloadItem) 35 | DownloadItemPrivate(const QUrl &url); 36 | ~DownloadItemPrivate(); 37 | 38 | bool downloadFinished; 39 | quint32 downloadId; 40 | DownloadItem::DownloadState downloadState; 41 | // DownloadItem::SavePageFormat savePageFormat; 42 | // DownloadItem::DownloadType type; 43 | // DownloadItem::DownloadInterruptReason interruptReason; 44 | QString downloadPath; 45 | const QUrl downloadUrl; 46 | QString mimeType; 47 | bool downloadPaused; 48 | QString suggestedFileName; 49 | QString downloadDirectory; 50 | QString downloadFileName; 51 | qint64 totalBytes; 52 | qint64 receivedBytes; 53 | 54 | QNetworkReply *reply; 55 | 56 | QFile *file; 57 | 58 | QDateTime startDownloadAt; 59 | 60 | void updateProgress(qint64 bytesReceived, qint64 bytesTotal); 61 | 62 | void setFinished(); 63 | 64 | QString id; 65 | 66 | }; 67 | 68 | #endif // DOWNLOADITEM_P_H 69 | -------------------------------------------------------------------------------- /Browser/navigationbar.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef NAVIGATIONBAR_H 20 | #define NAVIGATIONBAR_H 21 | 22 | #include "urllineedit.h" 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | 33 | class NavigationBar : public QToolBar 34 | { 35 | Q_OBJECT 36 | public: 37 | explicit NavigationBar(QWidget *parent = nullptr); 38 | 39 | void connectTab(TabView *tabView); 40 | 41 | void setBookmarkActive(bool isActive); 42 | 43 | QAction *historyBackAction; 44 | QAction *historyForwardAction; 45 | QAction *stopReloadAction; 46 | 47 | UrlLineEdit *urlLineEdit; 48 | 49 | QAction *favAction; 50 | QAction *bookmarkAction; 51 | 52 | QAction *newTabAction; 53 | QAction *newWindowAction; 54 | QAction *newIncognitoAction; 55 | 56 | QAction *historyAction; 57 | QAction *downloadsAction; 58 | QAction *bookmarksAction; 59 | 60 | QAction *settingsAction; 61 | 62 | TabView *activeTabView = nullptr; 63 | 64 | public slots: 65 | void changeUrl(const QUrl url); 66 | void handleLoadProgress(int progress); 67 | 68 | signals: 69 | void loadProgress(int progress); 70 | 71 | private: 72 | QShortcut *m_closeTabShortcut; 73 | 74 | }; 75 | 76 | #endif // NAVIGATIONBAR_H 77 | -------------------------------------------------------------------------------- /Api/tools/index.qml: -------------------------------------------------------------------------------- 1 | import QtCore 2 | 3 | import QtQuick 4 | import QtQuick.Controls 5 | import QtQuick.Dialogs 6 | import QtQuick.Layouts 7 | // import QtQuick.LocalStorage 8 | import QtQuick.Pdf 9 | import QtQuick.Particles 10 | import QtQuick.Shapes 11 | import QtQuick.Templates 12 | import QtQuick.Timeline 13 | // import QtQuick.VirtualKeyboard 14 | // import QtQuick.VirtualKeyboard.Components ? 15 | // import QtQuick.VirtualKeyboard.Settings ? 16 | // import QtQuick.VirtualKeyboard.Styles ? 17 | 18 | import QtTest 19 | 20 | // import QtRemoteObjects 21 | import QtScxml 22 | // import QtSensors not for PC 23 | // import QtQml.StateMachine 24 | // import QtWebChannel 1.4 ? 25 | 26 | 27 | /* 28 | * Unsupported by build 29 | */ 30 | // import QtWayland.Compositor 31 | // import QtWayland.Compositor.IviApplication 32 | // import QtWayland.Compositor.PresentationTime 33 | // import QtWayland.Compositor.IviApplication 34 | // import QtWayland.Compositor.WlShell 35 | // import QtWayland.Compositor.XdgShell 36 | 37 | // import QtWebEngine - Unsupported as unnecessary 38 | // import QtOpcUa - Unnecessary 39 | 40 | import QtWebSockets 1.4 41 | import QtWebView 42 | import QtQml.XmlListModel 43 | 44 | 45 | import QtQuick3D 46 | import QtQuick3D.Effects 47 | import QtQuick3D.AssetUtils 48 | import QtQuick3D.Helpers 49 | import QtQuick3D.Particles3D 50 | import QtQuick3D.Physics 51 | 52 | import QtQuick3D.Audio 53 | import QtQuick3D.SpatialAudio 54 | 55 | 56 | import QtQuick.Window 57 | 58 | import Qt3D.Core 2.4 59 | import Qt3D.Render 2.4 60 | import Qt3D.Input 2.4 61 | import Qt3D.Logic 2.4 62 | import Qt3D.Extras 2.4 63 | import Qt3D.Animation 2.4 64 | import QtQuick.Scene2D 2.4 65 | import QtQuick.Scene3D 2.4 66 | 67 | import Qt5Compat.GraphicalEffects 68 | 69 | import QtCharts 70 | import Qt.labs.folderlistmodel 71 | import Qt.labs.platform 72 | import Qt.labs.settings 73 | import Qt.labs.wavefrontmesh 74 | import Qt.labs.lottieqt 75 | // import Qt.labs.sharedimage - not secure 76 | import Qt.labs.animation 77 | 78 | 79 | 80 | import QtMultimedia 81 | 82 | // import QtDataVisualization - unstable 83 | 84 | import QtPositioning 85 | 86 | import QtQml 87 | import QtQml.Models 88 | import Qt.labs.qmlmodels 89 | import QtQml.WorkerScript 90 | 91 | import QtTextToSpeech 92 | import QtQuick3D.Physics.Helpers 93 | -------------------------------------------------------------------------------- /App/apppaths.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef APPPATHS_H 20 | #define APPPATHS_H 21 | 22 | #include 23 | #include "App_global.h" 24 | #include 25 | 26 | #define DIR_SP QLatin1Char('/') 27 | 28 | class APP_EXPORT AppPaths 29 | { 30 | public: 31 | explicit AppPaths(); 32 | ~AppPaths(); 33 | 34 | void static init(const QString &dataPath); 35 | 36 | QString static rootPath(); 37 | 38 | QUrl static resolved(const QString path); 39 | 40 | QUrl static iconsPath(); 41 | 42 | QUrl static toolsPath(); 43 | 44 | QUrl static toolPath(QUrl url); 45 | 46 | QString static currentProfilePath(); 47 | 48 | QString static cachePath(); 49 | 50 | QString static dataPath(); 51 | 52 | QString static dbPath(); 53 | 54 | QUrl static dappsPath(); 55 | 56 | QString static downloadPath(); 57 | 58 | QString static webAppPath(const QUrl &url); 59 | 60 | QUrl static dappPath(const QUrl &url); 61 | 62 | QString const iconsDir = QLatin1String("icons"); 63 | 64 | QString const toolsDir = QLatin1String("tools/"); 65 | 66 | QString const dappsDir = QLatin1String("dapps/"); 67 | 68 | private: 69 | 70 | QUrl m_appPath; 71 | 72 | QUrl m_dataPath; 73 | 74 | QString m_currentProfilePath; 75 | 76 | QString m_cachePath; 77 | 78 | QString m_downloadPath; 79 | }; 80 | 81 | #endif // APPPATHS_H 82 | -------------------------------------------------------------------------------- /Api/apiweb.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef APIWEB_H 20 | #define APIWEB_H 21 | 22 | #include 23 | #include "apicommon.h" 24 | #include "window.h" 25 | #include "document.h" 26 | #include "locationurl.h" 27 | #include "Api_global.h" 28 | #include "qmlvalue.h" 29 | 30 | class API_EXPORT ApiWeb : public ApiCommon 31 | { 32 | Q_OBJECT 33 | Q_PROPERTY(Document *document READ document CONSTANT) 34 | Q_PROPERTY(Window *window READ window CONSTANT) 35 | Q_PROPERTY(QmlValue *navInput READ navInput CONSTANT) 36 | 37 | public: 38 | 39 | explicit ApiWeb(NetworkAccessManagerFactory *networkManagerFactory, QObject *parent = nullptr); 40 | 41 | Window *window() {return m_window;} 42 | 43 | Document *document() {return m_document;} 44 | 45 | LocationUrl *locationUrl() 46 | { 47 | return m_locationUrl; 48 | } 49 | 50 | void setLocationUrl(const QUrl url) 51 | { 52 | m_locationUrl->setUrl(url); 53 | m_baseUrl = url; 54 | } 55 | 56 | QmlValue *navInput() 57 | { 58 | return m_navInput; 59 | } 60 | 61 | void setNavInput(const QString &text) { 62 | m_navInput->setValue(new QVariant(text)); 63 | } 64 | 65 | signals: 66 | 67 | private: 68 | 69 | Document *m_document; 70 | 71 | Window *m_window; 72 | 73 | LocationUrl *m_locationUrl; 74 | 75 | QmlValue *m_navInput; 76 | 77 | }; 78 | 79 | #endif // APIWEB_H 80 | -------------------------------------------------------------------------------- /Api/historyitemmodel.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef HISTORYITEMMODEL_H 20 | #define HISTORYITEMMODEL_H 21 | 22 | #include 23 | #include "historyitem.h" 24 | #include "Api_global.h" 25 | 26 | class API_EXPORT HistoryItemModel : public QAbstractListModel 27 | { 28 | Q_OBJECT 29 | public: 30 | static HistoryItemModel& instance(QObject *parent = nullptr); 31 | explicit HistoryItemModel(QObject *parent = nullptr); 32 | ~HistoryItemModel(); 33 | 34 | void fill(QList items); 35 | 36 | enum ItemRoles { 37 | IdxRole = Qt::UserRole + 1, 38 | IdRole, 39 | UrlRole, 40 | TitleRole, 41 | IconUrlRole, 42 | AddedRole, 43 | TypeRole, 44 | HostRole 45 | }; 46 | 47 | void addHistoryItem(HistoryItem *item); 48 | 49 | void updateHistoryItem(HistoryItem *item); 50 | 51 | Q_INVOKABLE bool removeHistoryItem(qint64 const index); 52 | 53 | int rowCount(const QModelIndex & parent = QModelIndex()) const override; 54 | 55 | QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override; 56 | 57 | Q_INVOKABLE QVariantMap get(int row) const; 58 | 59 | protected: 60 | QHash roleNames() const override; 61 | 62 | private: 63 | HistoryItemModel(const HistoryItemModel&other); 64 | HistoryItemModel& operator=(const HistoryItemModel&other); 65 | 66 | QList m_items; 67 | 68 | }; 69 | 70 | #endif // HISTORYITEMMODEL_H 71 | -------------------------------------------------------------------------------- /Api/apicommon.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef APICOMMON_H 20 | #define APICOMMON_H 21 | 22 | #include 23 | #include "log.h" 24 | #include "qi.h" 25 | #include "downloaditem.h" 26 | #include "accessrights.h" 27 | #include "httpmanager.h" 28 | #include "Api_global.h" 29 | #include "networkaccessmanagerfactory.h" 30 | 31 | class API_EXPORT ApiCommon : public QObject 32 | { 33 | Q_OBJECT 34 | Q_PROPERTY(Log *log READ log CONSTANT) 35 | Q_PROPERTY(Qi *qi READ qi CONSTANT) 36 | 37 | public: 38 | explicit ApiCommon(NetworkAccessManagerFactory *networkManagerFactory, QObject *parent = nullptr); 39 | 40 | Log *log() {return m_log;} 41 | 42 | Qi *qi() {return m_qi;} 43 | 44 | Q_INVOKABLE void alert(const QString message, const QString title = ""); 45 | 46 | Q_INVOKABLE bool confirm(const QString message, const QString title = ""); 47 | 48 | Q_INVOKABLE DownloadItem *download(const QString url); 49 | 50 | Q_INVOKABLE QString preload(const QString url); 51 | 52 | void setAccessRights(AccessRights *accessRights); 53 | 54 | AccessRights *accessRights(); 55 | 56 | HttpManager *httpManager(); 57 | 58 | signals: 59 | void requestDownload(const QString url); 60 | 61 | protected: 62 | QUrl m_baseUrl; 63 | 64 | private: 65 | Log *m_log; 66 | 67 | Qi *m_qi; 68 | 69 | AccessRights *m_accessRights; 70 | 71 | NetworkAccessManagerFactory *m_networkManagerFactory; 72 | 73 | HttpManager *m_httpManager = nullptr; 74 | 75 | }; 76 | 77 | 78 | #endif // APICOMMON_H 79 | -------------------------------------------------------------------------------- /Browser/browserpaths.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "browserpaths.h" 20 | #include 21 | #include "urlhelper.h" 22 | 23 | Q_GLOBAL_STATIC(BrowserPaths, gs_browser_paths) 24 | 25 | QLatin1String const BrowserPaths::downloadManagerName = QLatin1String("downloads"); 26 | QLatin1String const BrowserPaths::historyManagerName = QLatin1String("history"); 27 | QLatin1String const BrowserPaths::bookmarksManagerName = QLatin1String("bookmarks"); 28 | QLatin1String const BrowserPaths::settingsManagerName = QLatin1String("settings"); 29 | QLatin1String const BrowserPaths::blankPageName = QLatin1String("blank"); 30 | QLatin1String const BrowserPaths::errorPageName = QLatin1String("error"); 31 | QString const BrowserPaths::installPageName = QLatin1String("install"); 32 | 33 | 34 | 35 | BrowserPaths::BrowserPaths() 36 | { 37 | 38 | } 39 | 40 | QString BrowserPaths::historyManagerPath() 41 | { 42 | BrowserPaths* p = gs_browser_paths(); 43 | return p->toolsPath().toLocalFile() + DIR_SP + historyManagerName; 44 | } 45 | 46 | QString BrowserPaths::downloadManagerPath() 47 | { 48 | BrowserPaths* p = gs_browser_paths(); 49 | return p->toolsPath().toLocalFile() + DIR_SP + downloadManagerName; 50 | } 51 | 52 | QString BrowserPaths::settingsManagerPath() 53 | { 54 | BrowserPaths* p = gs_browser_paths(); 55 | return p->toolsPath().toLocalFile() + DIR_SP + settingsManagerName; 56 | } 57 | 58 | QUrl BrowserPaths::installPageUrl() 59 | { 60 | QUrl url; 61 | url.setScheme(INTERNAL_URL_SCHEME); 62 | url.setHost(installPageName); 63 | return url; 64 | } 65 | 66 | -------------------------------------------------------------------------------- /Browser/downloaditemproxy.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "downloaditemproxy.h" 20 | #include "downloaditem_p.h" 21 | 22 | DownloadItemProxy::DownloadItemProxy(QWebEngineDownloadRequest *item, QObject *parent) : DownloadItem(item->url(), parent), 23 | m_item(item) 24 | { 25 | connect(item, &QWebEngineDownloadRequest::receivedBytesChanged, this, &DownloadItemProxy::receivedBytesChanged); 26 | connect(item, &QWebEngineDownloadRequest::stateChanged, this, [=](QWebEngineDownloadRequest::DownloadState state){ 27 | emit DownloadItem::stateChanged((DownloadItem::DownloadState) state); 28 | }); 29 | } 30 | 31 | void DownloadItemProxy::sync() 32 | { 33 | setDownloadFileName(m_item->downloadFileName()); 34 | } 35 | 36 | DownloadItem::DownloadState DownloadItemProxy::state() const 37 | { 38 | return (DownloadState)m_item->state(); 39 | } 40 | 41 | QString DownloadItemProxy::downloadDirectory() const 42 | { 43 | return m_item->downloadDirectory(); 44 | } 45 | 46 | QString DownloadItemProxy::downloadFileName() const 47 | { 48 | return m_item->downloadFileName(); 49 | } 50 | 51 | void DownloadItemProxy::setDownloadFileName(QString fileName) 52 | { 53 | m_item->setDownloadFileName(fileName); 54 | } 55 | 56 | void DownloadItemProxy::accept() 57 | { 58 | m_item->accept(); 59 | } 60 | 61 | void DownloadItemProxy::cancel() 62 | { 63 | m_item->cancel(); 64 | } 65 | 66 | void DownloadItemProxy::pause() 67 | { 68 | m_item->pause(); 69 | } 70 | 71 | void DownloadItemProxy::resume() 72 | { 73 | m_item->resume(); 74 | } 75 | 76 | void DownloadItemProxy::receivedBytesChanged() 77 | { 78 | updateDownloadProgress(m_item->receivedBytes(),m_item->totalBytes()); 79 | } 80 | -------------------------------------------------------------------------------- /Browser/htmlview.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef HTMLVIEW_H 20 | #define HTMLVIEW_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | class HtmlView : public QWebEngineView, public BaseView 30 | { 31 | Q_OBJECT 32 | public: 33 | explicit HtmlView(QSplitter *splitter, QWidget *parent, QWebEngineProfile *profile); 34 | 35 | ~HtmlView(); 36 | 37 | void setContent(const QByteArray &content, const QString &mimeType, const QUrl &baseUrl) override; 38 | 39 | qreal zoomFactor() override; 40 | 41 | void setZoomFactor(const qreal factor) override; 42 | 43 | void toggleDevTools() override; 44 | 45 | void setUrl(const QUrl &url) override; 46 | 47 | int viewType() override {return BaseView::TYPE_HTML;}; 48 | 49 | const QString title() override; 50 | 51 | const QUrl iconUrl() override; 52 | 53 | const QString description() override; 54 | 55 | void navTyped(const QString &text) override { 56 | Q_UNUSED(text); 57 | }; 58 | 59 | bool addToBookmark() override; 60 | 61 | public Q_SLOTS: 62 | void reload() override; 63 | 64 | signals: 65 | void clickEmitted(const QUrl url); 66 | void devToolsRequested(QWebEnginePage *source); 67 | 68 | protected: 69 | void contextMenuEvent(QContextMenuEvent *event) override; 70 | 71 | void devToolsRequest(QWebEnginePage *source); 72 | 73 | QWebEngineView *createWindow(QWebEnginePage::WebWindowType type) override; 74 | 75 | private: 76 | QSplitter *layout; 77 | 78 | QWebEngineView *devView = nullptr; 79 | 80 | QString m_description; 81 | 82 | }; 83 | 84 | #endif // HTMLVIEW_H 85 | -------------------------------------------------------------------------------- /Browser/qmldevtools.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "qmldevtools.h" 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | QmlDevTools::QmlDevTools(Log *log, QWidget *parent) : QWidget(parent), 28 | log(log) 29 | { 30 | layout = new QVBoxLayout(this); 31 | layout->setSpacing(0); 32 | layout->setContentsMargins(0, 0, 0, 0); 33 | setLayout(layout); 34 | 35 | logModel = new QStandardItemModel; 36 | QList records = log->logRecords(); 37 | for (int i = 0; i < records.count(); ++i) { 38 | writeLogLine(&records.at(i)); 39 | } 40 | 41 | logView = new QListView(this); 42 | logView->setModel(logModel); 43 | logView->scrollToBottom(); 44 | 45 | autoScrollToBottom = true; 46 | 47 | connect(log, &Log::append, this, &QmlDevTools::writeLogLine); 48 | connect(log, &Log::cleared, this, &QmlDevTools::clearLog); 49 | 50 | layout->addWidget(logView); 51 | } 52 | 53 | 54 | void QmlDevTools::writeLogLine(const Log::logLine *line) 55 | { 56 | QList listItem; 57 | QStandardItem *item = new QStandardItem(); 58 | item->setText(line->text); 59 | 60 | if(Log::lineType::L_DEBUG == line->type) { 61 | item->setForeground(QBrush(QColor(140,140,140))); 62 | } else if(Log::lineType::L_ERROR == line->type) { 63 | item->setForeground(QBrush(QColor(255,0,0))); 64 | } 65 | 66 | listItem << item; 67 | logModel->appendRow(listItem); 68 | 69 | if(autoScrollToBottom) { 70 | logView->scrollToBottom(); 71 | } 72 | } 73 | 74 | void QmlDevTools::clearLog() 75 | { 76 | logModel->clear(); 77 | } 78 | -------------------------------------------------------------------------------- /Net/networkdiskcache.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | * This library baset on QT5 QNetworkDiskCache source code 20 | ****************************************************************************/ 21 | 22 | #ifndef NETWORKDISKCACHE_H 23 | #define NETWORKDISKCACHE_H 24 | 25 | #define httpDiskCache NetworkDiskCache::instance() 26 | 27 | #include 28 | #include 29 | #include "Net_global.h" 30 | 31 | QT_REQUIRE_CONFIG(networkdiskcache); 32 | 33 | class NetworkDiskCachePrivate; 34 | class NET_EXPORT NetworkDiskCache : public QAbstractNetworkCache 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | explicit NetworkDiskCache(QString cacheDir, QObject *parent = nullptr); 40 | ~NetworkDiskCache(); 41 | 42 | QString cacheDirectory(const QUrl &url); 43 | QString dataDirectory(const QUrl &url); 44 | 45 | qint64 maximumCacheSize() const; 46 | void setMaximumCacheSize(qint64 size); 47 | 48 | qint64 cacheSize() const override; 49 | QNetworkCacheMetaData metaData(const QUrl &url) override; 50 | void updateMetaData(const QNetworkCacheMetaData &metaData) override; 51 | QIODevice *data(const QUrl &url) override; 52 | bool remove(const QUrl &url) override; 53 | QIODevice *prepare(const QNetworkCacheMetaData &metaData) override; 54 | void insert(QIODevice *device) override; 55 | 56 | QNetworkCacheMetaData fileMetaData(const QString &fileName) const; 57 | 58 | QString filePath(const QUrl &url); 59 | 60 | static NetworkDiskCache *self; 61 | 62 | public Q_SLOTS: 63 | void clear() override; 64 | 65 | protected: 66 | // virtual qint64 expire(); 67 | 68 | private: 69 | 70 | QString m_cacheDir; 71 | 72 | Q_DECLARE_PRIVATE(NetworkDiskCache) 73 | Q_DISABLE_COPY(NetworkDiskCache) 74 | }; 75 | 76 | #endif // NETWORKDISKCACHE_H 77 | -------------------------------------------------------------------------------- /Api/historyitem.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef HISTORYITEM_H 20 | #define HISTORYITEM_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include "Api_global.h" 26 | 27 | class API_EXPORT HistoryItem : public QObject 28 | { 29 | Q_OBJECT 30 | Q_PROPERTY(int id READ id CONSTANT) 31 | Q_PROPERTY(QString iconUrl READ iconUrlString CONSTANT) 32 | 33 | public: 34 | 35 | explicit HistoryItem(const QUrl &url, const int &type, const QString &title, const QUrl &iconUrl, const QString &description); 36 | 37 | void setId(const int id) { 38 | m_id = id; 39 | }; 40 | 41 | void setIconUrl(const QUrl iconUrl) { 42 | m_iconUrl = iconUrl; 43 | }; 44 | 45 | void setAdded(const QDateTime added) { 46 | m_added = added; 47 | }; 48 | 49 | int id() const { 50 | return m_id; 51 | } 52 | 53 | QUrl url() const { 54 | return m_url; 55 | } 56 | 57 | int type() const { 58 | return m_type; 59 | } 60 | 61 | QString title() const { 62 | return m_title; 63 | } 64 | 65 | QUrl iconUrl() const { 66 | return m_iconUrl; 67 | } 68 | 69 | QString description() const { 70 | return m_description; 71 | } 72 | 73 | QString iconUrlString() const { 74 | return m_iconUrl.toString(); 75 | } 76 | 77 | QDateTime added() const { 78 | return m_added; 79 | } 80 | 81 | private: 82 | 83 | int m_id; 84 | 85 | QUrl m_url; 86 | 87 | int m_type; 88 | 89 | QString m_title; 90 | 91 | QUrl m_iconUrl; 92 | 93 | QDateTime m_added; 94 | 95 | QString m_description; 96 | 97 | }; 98 | 99 | #endif // HISTORYITEM_H 100 | -------------------------------------------------------------------------------- /Browser/webpopupwindow.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "webpopupwindow.h" 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "htmlview.h" 25 | #include 26 | 27 | 28 | WebPopupWindow::WebPopupWindow(QWebEngineProfile *profile) 29 | : m_urlLineEdit(new QLineEdit(this)) 30 | , m_favAction(new QAction(this)) 31 | , m_view(new HtmlView(nullptr, this, profile)) 32 | { 33 | setAttribute(Qt::WA_DeleteOnClose); 34 | setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); 35 | 36 | QVBoxLayout *layout = new QVBoxLayout; 37 | layout->setContentsMargins(0, 0, 0, 0); 38 | setLayout(layout); 39 | layout->addWidget(m_urlLineEdit); 40 | layout->addWidget(m_view); 41 | 42 | m_view->setPage(new QWebEnginePage(profile, m_view)); 43 | m_view->setFocus(); 44 | 45 | m_urlLineEdit->setReadOnly(true); 46 | m_urlLineEdit->addAction(m_favAction, QLineEdit::LeadingPosition); 47 | 48 | connect(m_view, &QWebEngineView::titleChanged, this, &QWidget::setWindowTitle); 49 | connect(m_view, &QWebEngineView::urlChanged, [this](const QUrl &url) { 50 | m_urlLineEdit->setText(url.toDisplayString()); 51 | }); 52 | connect(m_view, &HtmlView::iconChanged, m_favAction, &QAction::setIcon); 53 | connect(m_view->page(), &QWebEnginePage::geometryChangeRequested, this, &WebPopupWindow::handleGeometryChangeRequested); 54 | connect(m_view->page(), &QWebEnginePage::windowCloseRequested, this, &QWidget::close); 55 | } 56 | 57 | HtmlView *WebPopupWindow::view() const 58 | { 59 | return m_view; 60 | } 61 | 62 | void WebPopupWindow::handleGeometryChangeRequested(const QRect &newGeometry) 63 | { 64 | if (QWindow *window = windowHandle()) 65 | setGeometry(newGeometry.marginsRemoved(window->frameMargins())); 66 | show(); 67 | m_view->setFocus(); 68 | } 69 | -------------------------------------------------------------------------------- /Browser/completermodel.cpp: -------------------------------------------------------------------------------- 1 | #include "completermodel.h" 2 | #include "bookmarkdb.h" 3 | #include "bookmarklinkitem.h" 4 | #include "historydb.h" 5 | #include "historyitem.h" 6 | 7 | CompleterModel::CompleterModel(QObject *parent) 8 | : QAbstractTableModel{parent} 9 | { 10 | } 11 | 12 | int CompleterModel::rowCount(const QModelIndex &) const 13 | { 14 | return m_items.count(); 15 | } 16 | 17 | int CompleterModel::columnCount(const QModelIndex &) const 18 | { 19 | return 1; 20 | } 21 | 22 | QVariant CompleterModel::data(const QModelIndex &index, int role) const 23 | { 24 | if (index.row() < 0 || index.row() >= m_items.count()) 25 | return QVariant(); 26 | 27 | auto *item = m_items[index.row()]; 28 | 29 | if (role == 0) 30 | return QVariantMap{ 31 | {"title", item->title}, 32 | {"id", item->id}, 33 | {"typeId", item->typeId}, 34 | {"url", item->url}, 35 | {"description", item->description} 36 | }; 37 | if (role == 2) { 38 | return QVariant(item->url); 39 | } 40 | 41 | return QVariant(); 42 | } 43 | 44 | QVariant CompleterModel::headerData(int section, Qt::Orientation orientation, int role) const 45 | { 46 | Q_UNUSED(section); 47 | Q_UNUSED(orientation); 48 | Q_UNUSED(role); 49 | return QVariant(""); 50 | } 51 | 52 | bool CompleterModel::setData(const QModelIndex &index, const QVariant &value, int role) 53 | { 54 | return false; 55 | } 56 | 57 | bool CompleterModel::applyFilter(const QString &text, const CompleterItem::Type &type) 58 | { 59 | beginResetModel(); 60 | m_items.clear(); 61 | 62 | if (text.length() > 2) { 63 | if (type == CompleterItem::Type::AllType || type == CompleterItem::Type::HistoryType) { 64 | auto hrows = HistoryDb::findByText(text); 65 | HistoryItem* hrow; 66 | foreach (hrow, *hrows) { 67 | m_items.append(new CompleterItem{hrow->id(), CompleterItem::Type::HistoryType, hrow->title(), hrow->url()}); 68 | } 69 | } 70 | 71 | if (type == CompleterItem::Type::AllType || type == CompleterItem::Type::BookmarkType) { 72 | auto rows = BookmarkDb::findLinkByText(text); 73 | BookmarkLinkItem* row; 74 | foreach (row, *rows) { 75 | m_items.append(new CompleterItem{row->id(), CompleterItem::Type::BookmarkType, row->value("title").toString(), row->value("link").toString()}); 76 | } 77 | } 78 | } 79 | endResetModel(); 80 | return true; 81 | } 82 | 83 | QString CompleterModel::typeName(const int &typeId) 84 | { 85 | if (typeId == CompleterItem::Type::BookmarkType) { 86 | return "Bookmark"; 87 | } else if (typeId == CompleterItem::Type::HistoryType) { 88 | return "History"; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Browser/aboutdialog.cpp: -------------------------------------------------------------------------------- 1 | #include "aboutdialog.h" 2 | #include "qbcommon.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "browsersettings.h" 8 | #include 9 | 10 | 11 | AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent) 12 | { 13 | setWindowTitle(tr("About QbqBrowser")); 14 | setFixedWidth(400); 15 | 16 | auto layout = new QVBoxLayout(this); 17 | 18 | auto logoLabel = new QLabel(this); 19 | 20 | logoLabel->setTextFormat(Qt::RichText); 21 | logoLabel->setText("
QbqBrowser
"); 22 | layout->addWidget(logoLabel, 0, Qt::AlignHCenter); 23 | 24 | QString gApiName("Unknown"); 25 | auto gApi = QQuickWindow::graphicsApi(); 26 | if(QSGRendererInterface::GraphicsApi::Direct3D11 == gApi) { 27 | gApiName = "Direct3D 11"; 28 | } else if(QSGRendererInterface::GraphicsApi::Metal == gApi) { 29 | gApiName = "Metal"; 30 | } else if(QSGRendererInterface::GraphicsApi::Null == gApi) { 31 | gApiName = "No graphic API"; 32 | } else if(QSGRendererInterface::GraphicsApi::OpenGL == gApi) { 33 | gApiName = "OpenGL"; 34 | } else if(QSGRendererInterface::GraphicsApi::OpenVG == gApi) { 35 | gApiName = "OpenVG"; 36 | } else if(QSGRendererInterface::GraphicsApi::Vulkan == gApi) { 37 | gApiName = "Vulkan"; 38 | } else if(QSGRendererInterface::GraphicsApi::Software == gApi) { 39 | gApiName = "Software"; 40 | } 41 | 42 | QString aboutHtml; 43 | aboutHtml += "
"; 44 | aboutHtml += tr("

Application version %1
").arg(Qb::VERSION); 45 | aboutHtml += tr("QtWebEngine version %1

").arg(qVersion()); 46 | aboutHtml += QString("

© %1 %2
").arg(Qb::COPYRIGHT, Qb::AUTHOR); 47 | aboutHtml += QString("%1

").arg(Qb::WWWADDRESS); 48 | aboutHtml += "

" + BrowserSettings::instance()->defaultUserAgent() + "

"; 49 | aboutHtml += "

" + QString("Graphics API: ") + gApiName + "

"; 50 | if(!QQuickWindow::sceneGraphBackend().isEmpty()) { 51 | aboutHtml += "

" + QString("Graphics Backend: ") + QQuickWindow::sceneGraphBackend() + "

"; 52 | } 53 | aboutHtml += "
"; 54 | 55 | auto label = new QLabel(this); 56 | label->setWordWrap(true); 57 | label->setText(aboutHtml); 58 | layout->addWidget(label, 0, Qt::AlignHCenter); 59 | 60 | QPushButton *closeButton = new QPushButton("Close", this); 61 | closeButton->setFixedWidth(100); 62 | 63 | connect(closeButton, &QAbstractButton::clicked, this, &QWidget::close); 64 | layout->addWidget(closeButton, 0, Qt::AlignHCenter); 65 | 66 | setLayout(layout); 67 | } 68 | -------------------------------------------------------------------------------- /Browser/completerheader.cpp: -------------------------------------------------------------------------------- 1 | #include "completerheader.h" 2 | #include 3 | #include 4 | #include 5 | 6 | CompleterHeader::CompleterHeader(QWidget *parent) : QHeaderView (Qt::Orientation::Horizontal, parent) { 7 | m_widget = new QWidget(qobject_cast(parent)); 8 | m_widget->setStyleSheet("QPushButton:checked { background-color : red; color : blue; }"); 9 | 10 | m_layout = new QHBoxLayout(m_widget); 11 | m_layout->setContentsMargins(5, 5, 5, 5); 12 | m_layout->setSpacing(10); 13 | m_widget->setLayout(m_layout); 14 | 15 | m_btnAll = new QPushButton("All", m_widget); 16 | m_btnAll->setCursor(Qt::PointingHandCursor); 17 | m_btnAll->setCheckable(true); 18 | m_btnAll->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); 19 | connect(m_btnAll, &QPushButton::clicked, this, &CompleterHeader::btnAllClicked); 20 | m_layout->addWidget(m_btnAll); 21 | 22 | m_btnBookmark = new QPushButton("Bookmark", m_widget); 23 | m_btnBookmark->setCursor(Qt::PointingHandCursor); 24 | m_btnBookmark->setCheckable(true); 25 | m_btnBookmark->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); 26 | connect(m_btnBookmark, &QPushButton::clicked, this, &CompleterHeader::btnBookmarkClicked); 27 | m_layout->addWidget(m_btnBookmark); 28 | 29 | m_btnHistory = new QPushButton("History", m_widget); 30 | m_btnHistory->setCursor(Qt::PointingHandCursor); 31 | m_btnHistory->setCheckable(true); 32 | m_btnHistory->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); 33 | connect(m_btnHistory, &QPushButton::clicked, this, &CompleterHeader::btnHistoryClicked); 34 | m_layout->addWidget(m_btnHistory); 35 | 36 | m_btnAll->setChecked(true); 37 | m_type = CompleterItem::Type::AllType; 38 | } 39 | 40 | void CompleterHeader::btnAllClicked(bool checked) 41 | { 42 | Q_UNUSED(checked); 43 | m_btnAll->setChecked(true); 44 | m_btnBookmark->setChecked(false); 45 | m_btnHistory->setChecked(false); 46 | m_type = CompleterItem::Type::AllType; 47 | emit typeChanged(m_type); 48 | } 49 | 50 | void CompleterHeader::btnBookmarkClicked(bool checked) 51 | { 52 | Q_UNUSED(checked); 53 | m_btnBookmark->setChecked(true); 54 | m_btnAll->setChecked(false); 55 | m_btnHistory->setChecked(false); 56 | m_type = CompleterItem::Type::BookmarkType; 57 | emit typeChanged(m_type); 58 | } 59 | 60 | void CompleterHeader::btnHistoryClicked(bool checked) 61 | { 62 | Q_UNUSED(checked); 63 | m_btnHistory->setChecked(true); 64 | m_btnAll->setChecked(false); 65 | m_btnBookmark->setChecked(false); 66 | m_type = CompleterItem::Type::HistoryType; 67 | emit typeChanged(m_type); 68 | } 69 | 70 | 71 | void CompleterHeader::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const 72 | { 73 | QRect widgetRect = rect.adjusted(5, 5, -5, -5); 74 | m_widget->setGeometry(widgetRect); 75 | m_widget->show(); 76 | } 77 | 78 | -------------------------------------------------------------------------------- /Api/downloadbutton.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "downloadbutton.h" 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "tools.h" 26 | 27 | DownloadButton::DownloadButton(DownloadItem *downloadItem, QWidget *parent) 28 | : QToolButton{parent}, 29 | m_downloadItem(downloadItem) 30 | { 31 | setText(downloadItem->downloadFileName()); 32 | setPopupMode(QToolButton::InstantPopup); 33 | setToolTip(downloadItem->downloadFileName()); 34 | 35 | QMenu *popMenu=new QMenu(this); 36 | setMenu(popMenu); 37 | 38 | // Open file 39 | openAction = new QAction("Open", this); 40 | popMenu->addAction(openAction); 41 | 42 | connect(openAction, &QAction::triggered, [this](){ 43 | QDesktopServices::openUrl(QUrl::fromLocalFile(m_downloadItem->path())); 44 | }); 45 | 46 | // Cancel download 47 | cancelAction = new QAction("Cancel", this); 48 | popMenu->addAction(cancelAction); 49 | 50 | connect(cancelAction, &QAction::triggered, [this](){ 51 | m_downloadItem->cancel(); 52 | m_underInfo = tr("canceled"); 53 | repaint(); 54 | }); 55 | 56 | connect(downloadItem, &DownloadItem::downloadProgress, this, &DownloadButton::downloadProgress); 57 | connect(downloadItem, &DownloadItem::stateChanged, [this](DownloadItem::DownloadState state) { 58 | cancelAction->setEnabled(state == DownloadItem::DownloadInProgress); 59 | }); 60 | 61 | } 62 | 63 | void DownloadButton::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) 64 | { 65 | m_underInfo = Tools::bytesToText(bytesReceived); 66 | m_totalInfo = Tools::bytesToText(bytesTotal); 67 | repaint(); 68 | } 69 | 70 | void DownloadButton::paintEvent(QPaintEvent *p) 71 | { 72 | QToolButton::paintEvent(p); 73 | if(nullptr != m_underInfo) { 74 | QPainter paint(this); 75 | paint.setFont(QFont(paint.font().family(), paint.font().pointSize()-1)); 76 | paint.drawText(rect(),Qt::AlignCenter | Qt::AlignBottom, m_underInfo); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to QmlBrowser 2 | 3 | Thank you for your interest in contributing to QmlBrowser! Your contributions are highly appreciated. Here are some guidelines to help you get started. 4 | 5 | ## How to Contribute 6 | 7 | ### Reporting Bugs 8 | 9 | If you encounter any bugs while using QmlBrowser, please report them by opening an issue in the [issue tracker](https://github.com/Toorion/qml-browser/issues). Include as much detail as possible to help us diagnose and fix the issue quickly. 10 | 11 | ### Feature Requests 12 | 13 | We welcome suggestions for new features! If you have an idea for a feature, please check the [open issues](https://github.com/Toorion/qml-browser/issues) to see if it has already been suggested. If not, feel free to open a new issue to discuss your idea. 14 | 15 | ### Submitting Changes 16 | 17 | 1. **Fork the repository**: Click on the "Fork" button at the top of this page to create a copy of the repository in your GitHub account. 18 | 2. **Clone the repository**: Clone the forked repository to your local machine using the following command: 19 | ```sh 20 | git clone https://github.com/your-username/qml-browser.git 21 | ``` 22 | 3. **Create a new branch**: Create a new branch for your changes using the following command: 23 | ```sh 24 | git checkout -b feature-branch 25 | ``` 26 | 4. **Make your changes**: Make your changes to the codebase. 27 | 5. **Commit your changes**: Commit your changes with a descriptive commit message using the following command: 28 | ```sh 29 | git commit -m "Description of your changes" 30 | ``` 31 | 6. **Push your changes**: Push your changes to your forked repository using the following command: 32 | ```sh 33 | git push origin feature-branch 34 | ``` 35 | 7. **Create a pull request**: Open a pull request from your forked repository to the main repository. Describe your changes and the problem they solve. 36 | 37 | ### Code Style 38 | 39 | Please follow the existing code style and conventions in the project. This helps maintain consistency and readability throughout the codebase. 40 | 41 | ### Documentation 42 | 43 | If your changes include new features or modifications, please update the relevant documentation in the `README.md` file or the [wiki](https://github.com/Toorion/qml-browser/wiki). 44 | 45 | ## Building the Project 46 | 47 | Before building the browser core, you need to build the `libgit2` library: 48 | ```sh 49 | git submodule init 50 | git submodule update 51 | cd BROWSER_SRC/3rdparty/libgit2 52 | mkdir build && cd build 53 | cmake .. 54 | cmake --build . --config Release 55 | ``` 56 | 57 | ### Linux 58 | ```sh 59 | mkdir build && cd build 60 | qmake .. 61 | make && make install 62 | ``` 63 | 64 | ### Windows 65 | Use QtCreator to build with the following kit: 66 | - Qt + MSVC2019 67 | 68 | ## Contact 69 | 70 | If you have any questions or need further assistance, feel free to reach out to us: 71 | - **Email**: 72 | - **Telegram**: [@qmlbrowser](https://t.me/qmlbrowser) 73 | 74 | Thank you for contributing to QmlBrowser! 75 | -------------------------------------------------------------------------------- /Browser/tabview.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef TABVIEW_H 20 | #define TABVIEW_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include "historyitem.h" 33 | 34 | class TabView : public QWidget 35 | { 36 | Q_OBJECT 37 | public: 38 | explicit TabView(QWebEngineProfile *profile, QWidget *parent = nullptr); 39 | ~TabView(); 40 | 41 | BaseView *pageView() { 42 | return m_pageView; 43 | }; 44 | 45 | void loadUrl(const QString &rawUrl); 46 | 47 | void installUrl(const QString &rawUrl); 48 | 49 | void reload(); 50 | 51 | void setUrl(const QUrl &url); 52 | 53 | void loadFinished(); 54 | 55 | void navTyped(const QString &text); 56 | 57 | bool addToBookmark(); 58 | 59 | QUrl currentUrl() { 60 | return m_currentUrl; 61 | }; 62 | 63 | QWebEngineView *createHtmlView(); 64 | 65 | QStack historyBack; 66 | 67 | QStack historyForward; 68 | 69 | 70 | public Q_SLOTS: 71 | void back(); 72 | void forward(); 73 | void tabUrlChanged(const QUrl url); 74 | void tabLoadFinished(bool ok); 75 | void tabIconUrlChanged(const QUrl iconUrl); 76 | void navigationRequested(const QUrl url); 77 | 78 | signals: 79 | void titleChanged(const QString &title); 80 | void iconChanged(const QIcon &icon); 81 | void urlChanged(const QUrl url); 82 | void loadProgress(int progress); 83 | 84 | 85 | private: 86 | 87 | BaseView *m_pageView = nullptr; 88 | 89 | QUrl m_currentUrl; 90 | 91 | QNetworkReply *m_reply; 92 | 93 | HistoryItem *m_historyItem = nullptr; 94 | 95 | QWebEngineProfile *m_profile; 96 | 97 | QSplitter *m_splitter; 98 | 99 | bool m_reload = false; 100 | 101 | QUrl *m_installationUrl = nullptr; 102 | 103 | }; 104 | 105 | #endif // TABVIEW_H 106 | -------------------------------------------------------------------------------- /Browser/urllineedit.cpp: -------------------------------------------------------------------------------- 1 | #include "urllineedit.h" 2 | #include "qabstractitemview.h" 3 | #include "qevent.h" 4 | #include 5 | #include 6 | 7 | UrlLineEdit::UrlLineEdit(QWidget *parent) : QLineEdit(parent) 8 | { 9 | installAction = new QAction(this); 10 | installAction->setIcon(QIcon(QStringLiteral("icons:download.svg"))); 11 | installAction->setText("Insatll DAPP"); 12 | 13 | m_completer = new QCompleter(this); 14 | m_completerModel = new CompleterModel(this); 15 | m_completer->setModel(m_completerModel); 16 | m_completer->setCompletionMode(QCompleter::UnfilteredPopupCompletion); 17 | 18 | m_completerPopup = new QTableView(this); 19 | 20 | m_completerHeader = new CompleterHeader(m_completerPopup); 21 | m_completerHeader->setStretchLastSection(true); 22 | m_completerHeader->setMinimumHeight(m_completerHeaderHeight); 23 | m_completerPopup->setHorizontalHeader(m_completerHeader); 24 | m_completerPopup->setMouseTracking(true); 25 | 26 | m_completerRow = new CompleterRow(m_completerPopup); 27 | 28 | m_completer->setPopup(m_completerPopup); 29 | setCompleter(m_completer); 30 | 31 | m_completerPopup->setItemDelegate(m_completerRow); 32 | m_completerPopup->installEventFilter(m_completerRow); 33 | 34 | connect(this, &UrlLineEdit::textEdited, this, [=](const QString text) { 35 | if (m_completerPopup->isHidden()) { 36 | m_completerHeader->btnAllClicked(true); 37 | } 38 | m_completerModel->applyFilter(text, m_completerHeader->filterType()); 39 | updateCompleter(); 40 | }); 41 | 42 | connect(m_completerHeader, &CompleterHeader::typeChanged, this, [=](const CompleterItem::Type &type) { 43 | m_completerModel->applyFilter(this->text(), m_completerHeader->filterType()); 44 | updateCompleter(); 45 | }); 46 | 47 | connect(m_completer, static_cast(&QCompleter::activated), [=](const QModelIndex& index) { 48 | emit returnPressed(); 49 | }); 50 | 51 | } 52 | 53 | void UrlLineEdit::contextMenuEvent(QContextMenuEvent *event) 54 | { 55 | QMenu *menu = createStandardContextMenu(); 56 | 57 | menu->insertAction(menu->actions().at(0), installAction); 58 | //... 59 | menu->exec(event->globalPos()); 60 | delete menu; 61 | } 62 | /* 63 | void UrlLineEdit::focusOutEvent(QFocusEvent *event) 64 | { 65 | m_completer->popup()->hide(); 66 | QLineEdit::focusOutEvent(event); 67 | } 68 | */ 69 | void UrlLineEdit::updateCompleter() 70 | { 71 | int height = m_completerHeaderHeight; 72 | 73 | int rowCount = m_completerPopup->verticalHeader()->count(); 74 | for (int i = 0; i < rowCount; ++i) { 75 | if (!m_completerPopup->verticalHeader()->isSectionHidden(i)) { 76 | height += m_completerPopup->verticalHeader()->sectionSize(i); 77 | } 78 | } 79 | 80 | height += m_completerPopup->frameWidth() * 2; 81 | height = qMin(height, int(window()->height() * 0.666)); 82 | m_completerPopup->setMinimumHeight(height); 83 | m_completerPopup->setMaximumHeight(height); 84 | } 85 | -------------------------------------------------------------------------------- /App/settings.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "settings.h" 20 | #include 21 | 22 | 23 | #define APP_GROUP QLatin1String("App") 24 | #define APP_DEFAULT_STYLE QLatin1String("Basic") 25 | 26 | Settings::Settings(const QString &fileName, Format format, QObject *parent) 27 | : QSettings(fileName, format, parent) 28 | { 29 | 30 | } 31 | 32 | void Settings::setAppUserAgent(QString value) 33 | { 34 | beginGroup(APP_GROUP); 35 | setValue("UserAgent", value); 36 | endGroup(); 37 | //emit appUserAgentChanged(value); 38 | } 39 | 40 | QString Settings::appUserAgent() 41 | { 42 | beginGroup(APP_GROUP); 43 | QString v = value("UserAgent").toString(); 44 | if(v.isEmpty()) { 45 | v = m_defaultUserAgent; 46 | } 47 | endGroup(); 48 | return v; 49 | } 50 | 51 | void Settings::setAppCacheMaxSize(QString value) 52 | { 53 | beginGroup(APP_GROUP); 54 | setValue("CacheMaxSize", value); 55 | endGroup(); 56 | } 57 | 58 | QString Settings::appCacheMaxSize() 59 | { 60 | beginGroup(APP_GROUP); 61 | QString v = value("CacheMaxSize").toString(); 62 | if(v.toInt() < 50) { 63 | v = "50"; 64 | } 65 | endGroup(); 66 | return v; 67 | } 68 | 69 | void Settings::setAppStyle(QString value) 70 | { 71 | beginGroup(APP_GROUP); 72 | setValue("Style", value); 73 | endGroup(); 74 | } 75 | 76 | QString Settings::appStyle() 77 | { 78 | beginGroup(APP_GROUP); 79 | QString v = value("Style").toString(); 80 | if(v.isEmpty()) { 81 | v = APP_DEFAULT_STYLE; 82 | } 83 | endGroup(); 84 | return v; 85 | } 86 | 87 | 88 | 89 | void Settings::initDefaultUserAgent(QString userAgent) 90 | { 91 | // Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.15.2 Chrome/83.0.4103.122 Safari/537.36 92 | QString browser = userAgent.mid(userAgent.indexOf("QtWebEngine")); 93 | browser = browser.mid(0, browser.indexOf(" ")); 94 | m_defaultUserAgent = userAgent.replace(browser, "QBQBrowser/1.0.0"); 95 | } 96 | 97 | QString Settings::defaultUserAgent() 98 | { 99 | return m_defaultUserAgent; 100 | } 101 | 102 | -------------------------------------------------------------------------------- /Browser/browser.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "browser.h" 20 | #include "mainwindow.h" 21 | #include 22 | #include 23 | #include "historydb.h" 24 | #include "historyitemmodel.h" 25 | #include "browsersettings.h" 26 | #include "bookmarkdb.h" 27 | #include "bookmarkitemmodel.h" 28 | 29 | 30 | Browser::Browser() 31 | { 32 | HistoryItemModel::instance().fill(HistoryDb::list()); 33 | 34 | QObject::connect(QWebEngineProfile::defaultProfile(), &QWebEngineProfile::downloadRequested, 35 | this, [=] (QWebEngineDownloadRequest *item) { 36 | MainWindow *window = qobject_cast(QApplication::activeWindow()); 37 | if(window) { 38 | window->htmlDownloadRequested(item); 39 | } 40 | }); 41 | } 42 | 43 | 44 | Browser &Browser::instance() 45 | { 46 | static Browser instance; 47 | return instance; 48 | } 49 | 50 | 51 | MainWindow *Browser::createWindow(bool offTheRecord) 52 | { 53 | if (!m_profile) { 54 | m_profile.reset(new QWebEngineProfile( 55 | QString::fromLatin1("qbqbrowser.%1").arg(qWebEngineChromiumVersion()))); 56 | 57 | QObject::connect(m_profile.get(), &QWebEngineProfile::downloadRequested, this, [] (QWebEngineDownloadRequest *item) { 58 | MainWindow *window = qobject_cast(QApplication::activeWindow()); 59 | if(window) { 60 | window->htmlDownloadRequested(item); 61 | } 62 | }); 63 | } 64 | auto profile = offTheRecord ? QWebEngineProfile::defaultProfile() : m_profile.get(); 65 | profile->setHttpUserAgent(browserSettings->appUserAgent()); 66 | 67 | auto mainWindow = new MainWindow(profile); 68 | 69 | connect(mainWindow->navigationBar->newWindowAction, &QAction::triggered, this, &Browser::createWindow); 70 | connect(mainWindow->navigationBar->newIncognitoAction, &QAction::triggered, this, [this]() { 71 | this->createWindow(true); 72 | }); 73 | 74 | mainWindows.append(mainWindow); 75 | QObject::connect(mainWindow, &QObject::destroyed, this, [this, mainWindow]() { 76 | mainWindows.removeOne(mainWindow); 77 | }); 78 | mainWindow->show(); 79 | return mainWindow; 80 | } 81 | 82 | -------------------------------------------------------------------------------- /Api/tools/bookmarks/FolderForm.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2 | import QtQuick.Controls 3 | import QtQuick.Layouts 4 | import Qt.labs.platform 5 | 6 | Popup { 7 | 8 | property string defaultFolderColor 9 | property int parentId 10 | property var model 11 | property var modelIndex 12 | property string formAction 13 | property var treeView 14 | 15 | id: folderForm 16 | width: 300; 17 | height: 200 18 | x: (mainItem.width - width) / 2 19 | y: (mainItem.height - height) / 2 20 | closePolicy: Popup.CloseOnEscape 21 | modal: true 22 | 23 | 24 | function add(_parentId) { 25 | parentId = _parentId; 26 | itemName.text = ""; 27 | colorDialog.color = defaultFolderColor; 28 | formAction = "add"; 29 | folderForm.open(); 30 | } 31 | 32 | function edit(_model) { 33 | model = _model; 34 | itemName.text = model.name; 35 | colorDialog.color = model.color ? model.color : defaultFolderColor; 36 | formAction = "edit"; 37 | folderForm.open(); 38 | } 39 | 40 | GridLayout { 41 | anchors.fill: parent 42 | columns: 2 43 | rows: 3 44 | Label { 45 | Layout.columnSpan: 2 46 | Layout.alignment: Qt.AlignCenter 47 | font.pixelSize: 22 48 | text: "Add folder" 49 | } 50 | 51 | Label { text: "Name" } 52 | TextField { 53 | id: itemName 54 | objectName: "itemName" 55 | Layout.fillWidth: true 56 | } 57 | 58 | ColorDialog { 59 | id: colorDialog 60 | currentColor: itemColor.color 61 | } 62 | 63 | Label { text: "Color" } 64 | Rectangle { 65 | id: itemColor 66 | implicitWidth: 40 67 | implicitHeight: 40 68 | color: colorDialog.color 69 | MouseArea { 70 | anchors.fill: parent 71 | onPressed: { 72 | colorDialog.open(); 73 | } 74 | } 75 | } 76 | 77 | Rectangle { 78 | Layout.columnSpan: 2 79 | Layout.preferredWidth: parent.width 80 | Layout.preferredHeight: parent.height * 0.3 81 | Button { 82 | text: 'Cancel' 83 | onClicked: { 84 | folderForm.close(); 85 | } 86 | } 87 | 88 | QbButton { 89 | anchors.right: parent.right 90 | text: "Save" 91 | onClick: function() { 92 | var item; 93 | if(folderForm.formAction === 'add') { 94 | qi.bookmarkModel().add({parentId: parentId, name: itemName.text, color: itemColor.color, depth: 0, idx: 0}); 95 | } else { 96 | model.name = itemName.text; 97 | model.color = itemColor.color; 98 | qi.bookmarkModel().save(model); 99 | } 100 | folderForm.close(); 101 | } 102 | } 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Net/networkdiskcache_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | * This library baset on QT5 QNetworkDiskCache source code 20 | ****************************************************************************/ 21 | 22 | #ifndef NETWORKDISKCACHE_P_H 23 | #define NETWORKDISKCACHE_P_H 24 | 25 | #include "networkdiskcache.h" 26 | #include 27 | #include 28 | #include "private/qabstractnetworkcache_p.h" 29 | #include 30 | 31 | class CacheItem 32 | { 33 | public: 34 | CacheItem() : file(nullptr) 35 | { 36 | } 37 | ~CacheItem() 38 | { 39 | reset(); 40 | } 41 | 42 | QNetworkCacheMetaData metaData; 43 | QBuffer data; 44 | QBuffer headerData; 45 | QTemporaryFile *file; 46 | QTemporaryFile *headerFile = nullptr; 47 | inline qint64 size() const 48 | { return (file ? file->size() : data.size()) + (headerFile ? headerFile->size() : headerData.size()); } 49 | 50 | inline void reset() { 51 | metaData = QNetworkCacheMetaData(); 52 | headerData.close(); 53 | data.close(); 54 | headerData.close(); 55 | if(headerFile) { 56 | delete headerFile; 57 | headerFile = nullptr; 58 | } 59 | delete file; 60 | file = nullptr; 61 | } 62 | void writeHeader(QFile *device) const; 63 | void write(QFile *device) const; 64 | void writeCompressedData(QFile *device) const; 65 | bool read(QFile *device, bool readData); 66 | 67 | bool canCompress() const; 68 | }; 69 | 70 | 71 | class NetworkDiskCachePrivate : public QAbstractNetworkCachePrivate 72 | { 73 | public: 74 | NetworkDiskCachePrivate() 75 | : QAbstractNetworkCachePrivate() 76 | , maximumCacheSize(1024 * 1024 * 50) 77 | {} 78 | 79 | static QString uniqueFileName(const QUrl &url, const QString &extension); 80 | QString cacheHeaderFileName(const QUrl &url); 81 | QString cacheFileName(const QUrl &url); 82 | QString tmpHeaderFileName(const QUrl &url); 83 | QString tmpCacheFileName(const QUrl &url); 84 | bool removeFile(const QString &file); 85 | void storeItem(CacheItem *item); 86 | static quint32 crc32(const char *data, uint len); 87 | 88 | mutable CacheItem lastItem; 89 | qint64 maximumCacheSize; 90 | 91 | QHash inserting; 92 | Q_DECLARE_PUBLIC(NetworkDiskCache) 93 | }; 94 | 95 | 96 | 97 | #endif // NETWORKDISKCACHE_P_H 98 | -------------------------------------------------------------------------------- /Browser/Browser.pro: -------------------------------------------------------------------------------- 1 | QT += core gui network widgets widgets-private quick webenginewidgets sql quickcontrols2 quick3d quickwidgets 2 | 3 | CONFIG += c++11 # ordered 4 | CONFIG -= debug_and_release 5 | 6 | Api.depends = App Net 7 | Net.depends = App 8 | 9 | # You can make your code fail to compile if it uses deprecated APIs. 10 | # In order to do so, uncomment the following line. 11 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 12 | 13 | SOURCES += \ 14 | aboutdialog.cpp \ 15 | browser.cpp \ 16 | browserpaths.cpp \ 17 | browsersettings.cpp \ 18 | completerheader.cpp \ 19 | completermodel.cpp \ 20 | completerrow.cpp \ 21 | downloaditemproxy.cpp \ 22 | htmlview.cpp \ 23 | main.cpp \ 24 | mainwindow.cpp \ 25 | navigationbar.cpp \ 26 | qbcommon.cpp \ 27 | qmldevtools.cpp \ 28 | qmlview.cpp \ 29 | searchengine.cpp \ 30 | tabview.cpp \ 31 | tabwidget.cpp \ 32 | urllineedit.cpp \ 33 | webpopupwindow.cpp 34 | 35 | HEADERS += \ 36 | aboutdialog.h \ 37 | baseview.h \ 38 | browser.h \ 39 | browserpaths.h \ 40 | browsersettings.h \ 41 | completerheader.h \ 42 | completermodel.h \ 43 | completerrow.h \ 44 | downloaditemproxy.h \ 45 | htmlview.h \ 46 | mainwindow.h \ 47 | navigationbar.h \ 48 | qbcommon.h \ 49 | qmldevtools.h \ 50 | qmlview.h \ 51 | searchengine.h \ 52 | tabview.h \ 53 | tabwidget.h \ 54 | urllineedit.h \ 55 | webpopupwindow.h 56 | 57 | # PWD expands to directory where project_a.pri placed. 58 | # INCLUDEPATH += $$PWD/ 59 | INCLUDEPATH += $$PWD/App 60 | INCLUDEPATH += $$PWD/Net 61 | INCLUDEPATH += $$PWD/Api 62 | DEPENDPATH += $$PWD/App 63 | DEPENDPATH += $$PWD/Net 64 | DEPENDPATH += $$PWD/Api 65 | INCLUDEPATH += $$PWD/../3rdparty/libgit2/include 66 | DEPENDPATH += $$PWD/../3rdparty/libgit2/include 67 | 68 | 69 | include(../App/App.pri) 70 | include(../Net/Net.pri) 71 | include(../Api/Api.pri) 72 | 73 | TRANSLATIONS += \ 74 | q1_ru_RU.ts 75 | 76 | # Default rules for deployment. 77 | qnx: target.path = /tmp/$${TARGET}/bin 78 | else: unix:!android: target.path = /opt/$${TARGET}/bin 79 | !isEmpty(target.path): INSTALLS += target 80 | 81 | LIBS += -L$$OUT_PWD/../App/ -lApp 82 | LIBS += -L$$OUT_PWD/../Net/ -lNet 83 | LIBS += -L$$OUT_PWD/../Api/ -lApi 84 | unix { 85 | target.path = /usr/lib 86 | LIBS += -L$$PWD/../3rdparty/libgit2/build -lgit2 87 | } 88 | 89 | win32 { 90 | PWD_WIN = $${PWD} 91 | OUT_WIN = $${OUT_PWD} 92 | PWD_WIN ~= s,/,\\,g 93 | OUT_WIN ~= s,/,\\,g 94 | copyfiles.commands = $$quote(cmd /c xcopy /S /I /Y $${PWD_WIN}\\..\\3rdparty\\libgit2\\build\\Release\git2.dll $${OUT_WIN} && xcopy /S /I /Y $${PWD_WIN}\\styles.qss $${OUT_WIN} && xcopy /S /I /Y $${PWD_WIN}\\icons $${OUT_WIN}\\icons && xcopy /S /I /Y $${PWD_WIN}\\..\\Api\\tools $${OUT_WIN}\\tools) 95 | } 96 | linux { 97 | copyfiles.commands = cp $$PWD/styles.qss $$OUT_PWD/../ && cp -r $$PWD/icons $$OUT_PWD/../ && cp -r $$PWD/../Api/tools $$OUT_PWD/../ 98 | } 99 | first.depends = $(first) copyfiles 100 | export(first.depends) 101 | export(copyfiles.commands) 102 | QMAKE_EXTRA_TARGETS += first copyfiles 103 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QmlBrowser 2 | 3 | [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/toorion) 4 | 5 | QmlBrowser is the next generation Web 3.0 browser with QML support, enabling the creation of SDAPPS (serverless decentralized applications) and Hybrid Client 6 | 7 | **Key features:** 8 | 9 | * Accepts QML pages (modern QML language) in the same way as HTML 10 | * Unrestricted local storage per APP 11 | * Ability to install APP locally without being bound to a Web server. 12 | * An alternative security principle without the use of Cookies and CORS, which allows the application to interact with the Internet without restrictions. 13 | * Support for 3D functionality directly in the core 14 | 15 | 16 | ![QmlBrowser is full-featured Chromium based open-source web browser with QML pages support](preview.png) 17 | 18 | 19 | ## Downloads 20 | 21 | Available on [Release](https://github.com/Toorion/qml-browser/releases) page 22 | 23 | ## Building 24 | 25 | Before build browser core libgit2 should be builded: 26 | 27 | ```sh 28 | git submodule init 29 | git submodule update 30 | cd BROWSER_SRC/3rdparty/libgit2 31 | mkdir build && cd build 32 | cmake .. 33 | cmake --build . --config Release 34 | ``` 35 | 36 | ### Linux 37 | ```sh 38 | mkdir build && cd build 39 | qmake .. 40 | make && make install 41 | ``` 42 | 43 | ### Windows 44 | 45 | Use QtCreator to build 46 | 47 | Kit QT + MSVC2019 48 | 49 | ## Demo 50 | 51 | http[]()://demo.qbqsoft.com * 52 | 53 | [QML Demo source](https://github.com/Toorion/qml-browser-demo) 54 | 55 | \* Can only be opened using QmlBrowser 56 | 57 | ## Open QML pages 58 | 59 | For opening QML pages from Web it should have 60 | 61 | Content-Type: text/qml 62 | 63 | ## Install and use SDAPPS 64 | 65 | For installing SDAPPS read 66 | [SDAPPS installation instruction](https://github.com/Toorion/qml-browser/wiki/SDAPPS) 67 | in the Wiki 68 | 69 | (in testing feature) 70 | 71 | ## 3D Advanced Configuration 72 | 73 | For advanced 3d configuration read 74 | [Advanced 3D configuration](https://github.com/Toorion/qml-browser/wiki/3D-Config) 75 | in the Wiki 76 | 77 | ## QML advantages over HTML 78 | 79 | | |QML | HTML | 80 | |:----------|:---------------:|:-------:| 81 | | Oriented to | 2D / 3D | Text markup | 82 | | Extendable | Yes | No | 83 | | Reusable | Yes | No | 84 | | Flexibility | High | Low | 85 | | 3D performance | Fast | Slow | 86 | | Development time | Low | High | 87 | 88 | 89 | * HTML describes how to structure text documents and links on the web. Overtime it was extended with JS and CSS to let you do much more but at it's core it is a text document rendering technology. 90 | * QML was designed to describe how 2D and 3D spacial elements relate and interact with each other. It can still render text but that is not it's focus. QML is much more concerned with creating a user experience rather than presenting textual information. 91 | 92 | ## Contact 93 | 94 | Email: 95 | 96 | Telegram: [@qmlbrowser](https://t.me/qmlbrowser) 97 | 98 | ## ToDo 99 | 100 | - SDAPPS manager 101 | - SDAPPS access controll 102 | - Network adapter for QML mode 103 | - Expand API model for QML pages 104 | - IPFS Support 105 | - Lot of revolution features and external integrations 106 | 107 | -------------------------------------------------------------------------------- /Browser/styles.qss: -------------------------------------------------------------------------------- 1 | MainWindow#QUI-BrowserWindow { 2 | background-color:#d3d3d3; 3 | } 4 | 5 | /* 6 | * TabWidget 7 | */ 8 | TabWidget::pane { 9 | background: white; 10 | border-bottom: 0px solid; 11 | } 12 | TabWidget QTabBar::tab:disabled { 13 | padding: 0px 0px 0px 0px; 14 | margin: 0px 0px 0px 0px; 15 | background-color:#d3d3d3; 16 | width: 34px; 17 | height:26px; 18 | } 19 | TabWidget QPushButton { 20 | height:24px; 21 | width:24px; 22 | border-radius:12px 23 | } 24 | 25 | TabWidget QTabBar::tab { 26 | padding: 0px 0px 0px 10px; 27 | background-color:#d3d3d3; 28 | height:30px; 29 | border-top-left-radius: 6px; 30 | border-top-right-radius: 6px; 31 | border-left: 1px solid #C4C4C3; 32 | max-width:160px; 33 | } 34 | 35 | TabWidget QTabBar::tab:selected { 36 | background-color:#ffffff; 37 | } 38 | 39 | TabWidget QTabBar::tab:!selected { 40 | height:28px; 41 | } 42 | 43 | TabWidget QPushButton:hover { 44 | background-color: #C0C3C8; 45 | } 46 | 47 | 48 | TabWidget QTabBar::close-button { 49 | image: url(icons:cross.png); 50 | padding: 2px 2px 2px 2px; 51 | margin: 3px 3px 3px 3px; 52 | border-radius:6px; 53 | } 54 | TabWidget QTabBar::close-button:hover { 55 | background-color: #C0C3C8; 56 | } 57 | 58 | /* 59 | * QProgressBar 60 | */ 61 | QProgressBar { 62 | border: 0px; 63 | } 64 | QProgressBar::chunk { 65 | background-color: #41cd52; 66 | } 67 | 68 | 69 | /* 70 | * NavigationBar 71 | */ 72 | NavigationBar QToolButton { 73 | padding: 6px 6px 6px 6px; 74 | width:14px; 75 | height:14px; 76 | border-radius:13px; 77 | } 78 | 79 | NavigationBar QToolButton:hover { 80 | background-color: #EEEEEE; 81 | } 82 | 83 | NavigationBar QPushButton:hover { 84 | background-color: #EEEEEE; 85 | } 86 | 87 | NavigationBar QLineEdit { 88 | border: 2px; 89 | border-radius: 13px; 90 | background-color: #EEEEEE; 91 | height:28px; 92 | } 93 | 94 | NavigationBar QPushButton#BookmarkButton { 95 | padding: 3px 3px 3px 3px; 96 | width:18px; 97 | height:18px; 98 | border-radius:13px; 99 | } 100 | 101 | NavigationBar QPushButton#BookmarkButton { 102 | image: url(icons:bookmark.svg); 103 | } 104 | 105 | NavigationBar QToolButton#MenuButton { 106 | padding: 3px 3px 3px 3px; 107 | width:18px; 108 | height:18px; 109 | border-radius:13px; 110 | } 111 | 112 | NavigationBar QToolButton#MenuButton::menu-indicator { 113 | image: none 114 | } 115 | 116 | NavigationBar QToolButton#MenuButton { 117 | image: url(icons:icon_more_vert.svg); 118 | } 119 | 120 | 121 | 122 | 123 | /* 124 | * API 125 | */ 126 | 127 | /* 128 | * DownloadTab 129 | */ 130 | DownloadManagerWidget { 131 | background: #ffffff 132 | } 133 | 134 | DownloadManagerWidget QToolButton { 135 | height: 60px; 136 | min-width: 120px; 137 | } 138 | 139 | QToolButton::menu-indicator { 140 | image: url(icons:icon_expand_less.svg); 141 | subcontrol-position: right center; 142 | } 143 | 144 | DownloadManagerWidget QToolButton#ShowAll { 145 | height: 18px; 146 | width: 80px; 147 | min-width: 80px; 148 | } 149 | 150 | DownloadManagerWidget QToolButton#Close { 151 | min-width: 18px; 152 | width: 18px; 153 | height: 18px; 154 | } 155 | 156 | 157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /Net/internalnetworkreply.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "internalnetworkreply.h" 20 | #include 21 | #include 22 | #include 23 | 24 | struct InternalNetworkReplyPrivate 25 | { 26 | QByteArray content; 27 | qint64 offset; 28 | }; 29 | 30 | InternalNetworkReply::InternalNetworkReply(QObject *parent) 31 | : QNetworkReply{parent} 32 | { 33 | d = new InternalNetworkReplyPrivate(); 34 | } 35 | 36 | InternalNetworkReply::~InternalNetworkReply() 37 | { 38 | delete d; 39 | } 40 | 41 | void InternalNetworkReply::setHttpStatusCode(int code, const QByteArray &statusText) 42 | { 43 | setAttribute( QNetworkRequest::HttpStatusCodeAttribute, code ); 44 | if ( statusText.isNull() ) 45 | return; 46 | 47 | setAttribute( QNetworkRequest::HttpReasonPhraseAttribute, statusText ); 48 | } 49 | 50 | void InternalNetworkReply::setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value) 51 | { 52 | QNetworkReply::setHeader( header, value ); 53 | } 54 | 55 | void InternalNetworkReply::setContentType(const QByteArray &contentType) 56 | { 57 | setHeader(QNetworkRequest::ContentTypeHeader, contentType); 58 | } 59 | 60 | void InternalNetworkReply::setContent(const QString &content) 61 | { 62 | setContent(content.toUtf8()); 63 | } 64 | 65 | void InternalNetworkReply::setContent(const QByteArray &content) 66 | { 67 | d->offset = 0; 68 | d->content = content; 69 | 70 | open(ReadOnly | Unbuffered); 71 | setHeader(QNetworkRequest::ContentLengthHeader, QVariant(content.size())); 72 | 73 | QTimer::singleShot( 0, this, SIGNAL(readyRead()) ); 74 | QTimer::singleShot( 0, this, SIGNAL(finished()) ); 75 | } 76 | 77 | void InternalNetworkReply::setUrl(const QUrl &url) 78 | { 79 | QNetworkReply::setUrl(url); 80 | } 81 | 82 | 83 | void InternalNetworkReply::abort() 84 | { 85 | 86 | } 87 | 88 | qint64 InternalNetworkReply::bytesAvailable() const 89 | { 90 | return d->content.size() - d->offset + QIODevice::bytesAvailable(); 91 | } 92 | 93 | bool InternalNetworkReply::isSequential() const 94 | { 95 | return true; 96 | } 97 | 98 | qint64 InternalNetworkReply::readData(char *data, qint64 maxSize) 99 | { 100 | if (d->offset >= d->content.size()) 101 | return -1; 102 | 103 | qint64 number = qMin(maxSize, d->content.size() - d->offset); 104 | memcpy(data, d->content.constData() + d->offset, number); 105 | d->offset += number; 106 | 107 | return number; 108 | } 109 | 110 | -------------------------------------------------------------------------------- /Api/tools/settings/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2 | import QtQuick.Controls 3 | import QtQuick.Layouts 4 | 5 | Item { 6 | 7 | property string title: 'Settings' 8 | property int pixelSize: 16 9 | 10 | ListModel { 11 | id: styleList 12 | ListElement { name: "Basic" } 13 | ListElement { name: "Fusion" } 14 | ListElement { name: "Imagine" } 15 | ListElement { name: "Material" } 16 | ListElement { name: "Universal" } 17 | } 18 | 19 | anchors.fill: parent 20 | 21 | GridLayout { 22 | id: mainLayout 23 | columns: 2 24 | rowSpacing: 5 25 | columnSpacing: 5 26 | anchors { 27 | top: parent.top 28 | left: parent.left 29 | right: parent.right 30 | margins: 10 31 | } 32 | 33 | Text { 34 | text: "Settings" 35 | font.pixelSize: 20 36 | anchors.bottomMargin: 100 37 | } 38 | Text {} 39 | 40 | Label { 41 | text: "UI Style" 42 | font.pixelSize: pixelSize 43 | } 44 | ComboBox { 45 | id: comboUIS 46 | currentIndex: find(qi.settingsModel().appStyle) 47 | model: styleList 48 | onCurrentIndexChanged: { 49 | if(qi.settingsModel().appStyle != model.get(currentIndex).name) { 50 | qi.settingsModel().appStyle = model.get(currentIndex).name 51 | alert("Restart the browser for the changes to take affect") 52 | } 53 | 54 | } 55 | Component.onCompleted: { 56 | currentIndex = find(qi.settingsModel().appStyle); 57 | } 58 | font.pixelSize: pixelSize 59 | implicitWidth: 200 60 | } 61 | 62 | 63 | Label { 64 | id: uaLabel 65 | text: "User Agent" 66 | font.pixelSize: pixelSize 67 | } 68 | TextField { 69 | id: appUserAgent 70 | text: qi.settingsModel().appUserAgent 71 | implicitWidth: parent.parent.width - uaLabel.width - 120 72 | onTextChanged: qi.settingsModel().appUserAgent = text 73 | font.pixelSize: pixelSize 74 | } 75 | 76 | Label { 77 | text: "Search Engine" 78 | font.pixelSize: pixelSize 79 | } 80 | ComboBox { 81 | id: comboSE 82 | currentIndex: find(qi.settingsModel().browserSearchEngine) 83 | model: qi.settingsModel().browserSearchEngineList 84 | onCurrentIndexChanged: qi.settingsModel().browserSearchEngine = model[currentIndex] 85 | Component.onCompleted: { 86 | currentIndex = find(qi.settingsModel().browserSearchEngine); 87 | } 88 | font.pixelSize: pixelSize 89 | implicitWidth: 200 90 | } 91 | 92 | Label { 93 | text: "Cache Maximum Size" 94 | font.pixelSize: pixelSize 95 | } 96 | TextField { 97 | id: appCacheMaxSize 98 | text: qi.settingsModel().appCacheMaxSize 99 | onTextChanged: qi.settingsModel().appCacheMaxSize = text 100 | validator: IntValidator {bottom: 50; top: 10240} 101 | font.pixelSize: pixelSize 102 | implicitWidth: 200 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Net/downloaditem.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #ifndef DOWNLOADITEM_H 20 | #define DOWNLOADITEM_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include "Net_global.h" 27 | 28 | class DownloadItemPrivate; 29 | 30 | class NET_EXPORT DownloadItem : public QObject 31 | { 32 | Q_OBJECT 33 | public: 34 | 35 | enum DownloadState { 36 | DownloadRequested, 37 | DownloadInProgress, 38 | DownloadCompleted, 39 | DownloadCancelled, 40 | DownloadInterrupted, 41 | }; 42 | Q_ENUM(DownloadState) 43 | 44 | DownloadItem(const QUrl url, QObject *parent = Q_NULLPTR); 45 | ~DownloadItem(); 46 | 47 | Q_INVOKABLE virtual DownloadItem::DownloadState state() const; 48 | 49 | Q_INVOKABLE virtual QString downloadDirectory() const; 50 | void setDownloadDirectory(QString directory); 51 | Q_INVOKABLE virtual QString downloadFileName() const; 52 | virtual void setDownloadFileName(QString fileName); 53 | Q_INVOKABLE bool isFinished() const; 54 | 55 | Q_INVOKABLE QString path() const; 56 | 57 | Q_INVOKABLE QUrl url() const; 58 | 59 | Q_INVOKABLE QDateTime startDownloadAt() const; 60 | 61 | Q_INVOKABLE qint64 receivedBytes() const; 62 | 63 | QString id() const; 64 | 65 | bool openFile(); 66 | 67 | void setReply(QNetworkReply *reply); 68 | 69 | void setReceivedBytes(const qint64 bytes); 70 | 71 | void setId(const QString id); 72 | 73 | public Q_SLOTS: 74 | virtual void accept(); 75 | virtual void cancel(); 76 | virtual void pause(); 77 | virtual void resume(); 78 | 79 | void updateDownloadProgress(qint64 bytesReceived, qint64 bytesTotal); 80 | 81 | Q_SIGNALS: 82 | void finished(); 83 | void stateChanged(DownloadItem::DownloadState state); 84 | void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); 85 | void isPausedChanged(bool isPaused); 86 | 87 | void callAccept(); 88 | void callCancel(); 89 | void callPause(); 90 | void callResume(); 91 | 92 | 93 | private: 94 | 95 | void doCancel(); 96 | 97 | QScopedPointer d_ptr; 98 | 99 | Q_DECLARE_PRIVATE(DownloadItem) 100 | Q_DISABLE_COPY(DownloadItem) 101 | 102 | private slots: 103 | 104 | // Slot for gradual reading of downloaded data 105 | void onReadyRead(); 106 | // Slot for processing request completion 107 | void onReply(); 108 | 109 | 110 | }; 111 | 112 | Q_DECLARE_METATYPE(DownloadItem*) 113 | 114 | #endif // DOWNLOADITEM_H 115 | -------------------------------------------------------------------------------- /Api/downloadmanagerwidget.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * QmlBrowser - Web browser with QML page support 4 | * Copyright (C) 2022 Denis Solomatin 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | ****************************************************************************/ 19 | #include "downloadmanagerwidget.h" 20 | #include "downloaditem.h" 21 | #include 22 | #include 23 | #include 24 | #include "downloadbutton.h" 25 | #include "downloaditemmodel.h" 26 | #include "downloaddb.h" 27 | 28 | DownloadManagerWidget::DownloadManagerWidget(QWidget *parent) : QToolBar(parent) 29 | { 30 | setVisible(false); 31 | setMovable(false); 32 | toggleViewAction()->setEnabled(false); 33 | 34 | setFixedHeight(60); 35 | 36 | QWidget *spacer = new QWidget(this); 37 | spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); 38 | addWidget(spacer); 39 | 40 | showAllAction = new QAction(this); 41 | showAllAction->setText(tr("Show all")); 42 | addAction(showAllAction); 43 | (qobject_cast(widgetForAction(showAllAction)))->setObjectName("ShowAll"); 44 | connect(showAllAction, &QAction::triggered, this, &DownloadManagerWidget::showAllTriggered); 45 | 46 | 47 | closeAction = new QAction(this); 48 | closeAction->setIcon(QIcon("icons:cross.png")); 49 | addAction(closeAction); 50 | (qobject_cast(widgetForAction(closeAction)))->setObjectName("Close"); 51 | connect(closeAction, &QAction::triggered, this, &DownloadManagerWidget::closeManager); 52 | 53 | m_downloadItemModel = new DownloadItemModel(DownloadDb::list()); 54 | connect(m_downloadItemModel, &DownloadItemModel::removeItem, [](const QString &id){ 55 | DownloadDb::remove(id.toInt()); 56 | }); 57 | } 58 | 59 | void DownloadManagerWidget::downloadRequested(DownloadItem *downloadItem) 60 | { 61 | Q_ASSERT(downloadItem && downloadItem->state() == DownloadItem::DownloadRequested); 62 | 63 | downloadItem->accept(); 64 | 65 | downloadItem->setId(QString::number(DownloadDb::insert(*downloadItem))); 66 | 67 | m_downloadItemModel->addDownloadItem(downloadItem); 68 | 69 | add(new DownloadButton(downloadItem, this)); 70 | } 71 | 72 | 73 | void DownloadManagerWidget::add(DownloadButton *downloadButton) 74 | { 75 | // connect(downloadWidget, &DownloadWidget::removeClicked, this, &DownloadManagerWidget::remove); 76 | // m_itemsLayout->insertWidget(0, downloadWidget, 0, Qt::AlignTop); 77 | // if (m_numDownloads++ == 0) 78 | // m_zeroItemsLabel->hide(); 79 | 80 | insertWidget(actions().at(0), downloadButton); 81 | m_numDownloads++; 82 | } 83 | 84 | void DownloadManagerWidget::remove(DownloadButton *downloadButton) 85 | { 86 | layout()->removeWidget(downloadButton); 87 | downloadButton->deleteLater(); 88 | // if (--m_numDownloads == 0) 89 | // m_zeroItemsLabel->show(); 90 | } 91 | --------------------------------------------------------------------------------