diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 7 | ||||
-rw-r--r-- | src/application.cpp | 177 | ||||
-rw-r--r-- | src/application.h | 110 | ||||
-rw-r--r-- | src/main.cpp | 99 | ||||
-rw-r--r-- | src/rekonq_defines.h | 76 | ||||
-rw-r--r-- | src/rview.cpp | 12 | ||||
-rw-r--r-- | src/rview.h | 25 | ||||
-rw-r--r-- | src/webengine/webview.cpp | 25 | ||||
-rw-r--r-- | src/webengine/webview.h | 25 |
9 files changed, 267 insertions, 289 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 20798790..4aa141c9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,7 +10,6 @@ add_definitions(-DQT_STATICPLUGIN) # src files set(rekonq_KDEINIT_SRCS #---------------------------------------- - application.cpp autosaver.cpp searchengine.cpp sessionmanager.cpp @@ -214,7 +213,11 @@ ADD_DEFINITIONS ( ${KDE4_DEFINITIONS} ) ### --------------- ADDING EXECUTABLE... #KDE4_ADD_KDEINIT_EXECUTABLE( rekonq ${rekonq_KDEINIT_SRCS} main.cpp ) -add_executable(rekonq EXCLUDE_FROM_ALL ${rekonq_KDEINIT_SRCS} main.cpp) +add_executable(rekonq + main.cpp application.cpp application.h + # ---------------------------------------- + rview.cpp rview.h webengine/webview.cpp webengine/webview.h +) ### --------------- TARGETTING LINK LIBRARIES... diff --git a/src/application.cpp b/src/application.cpp index 41cf1dab..54a7db88 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -6,103 +6,46 @@ * SPDX-License-Identifier: GPL-3.0-only * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net> * ============================================================ - * Description: Application Entry Point + * Description: Application Main Class * ============================================================ */ #include "application.h" -#include "rekonq.hpp" - -// Ui Includes -#include "ui_webappcreation.h" - -// Local Includes -#include "searchengine.h" - -#include "tabbar.h" -#include "rekonqwindow.h" - -#include "webwindow.h" -#include "webtab.h" -#include "webpage.h" - -#include "urlresolver.h" - -// Local Manager(s) Includes -#include "adblockmanager.h" -#include "downloadmanager.h" -#include "historymanager.h" -#include "iconmanager.h" -#include "sessionmanager.h" - -// Ui Includes -#include "ui_cleardata.h" - -// KDE Includes -#include <KCmdLineArgs> - -#include <KDialog> -#include <KProcess> -#include <KPushButton> -#include <KStandardDirs> -#include <KWindowSystem> -#include <KWindowInfo> -#include <KStartupInfo> - -#include <KMessageBox> - -#include <config-kactivities.h> -#ifdef HAVE_KACTIVITIES -#include <KActivities/Consumer> -#endif - -// Qt Includes -#include <QDBusInterface> -#include <QDBusReply> -#include <QDir> -#include <QTimer> +#include "rview.h" +#include "webengine/webview.h" // --------------------------------------------------------------------------------------------------------------- // Ctor and Dtor -Application::Application(int argc, char **argv) : SingleApplication(argc, argv) +Application::Application(int &argc, char *argv[]) : SingleApplication(argc, argv) { // updating rekonq configuration - updateConfiguration(); + // updateConfiguration(); - setWindowIcon(KIcon("rekonq")); + // setWindowIcon(KIcon("rekonq")); // just create History Manager... - HistoryManager::self(); + // HistoryManager::self(); } Application::~Application() { - // ok, we are closing well: don't recover on next load.. - ReKonfig::setRecoverOnCrash(0); - saveConfiguration(); - -#ifdef HAVE_KACTIVITIES - delete m_activityConsumer; -#endif - - // Destroy all windows... - Q_FOREACH(QWeakPointer<RekonqWindow> pointer, m_rekonqWindows) - { - delete pointer.data(); - pointer.clear(); - } - - // Destroy all web apps - Q_FOREACH(WebTab *tab, m_webApps) - { - delete tab; - } - - kDebug() << "Bye bye (k)baby..."; + // ok, we are closing well: don't recover on next load.. + // ReKonfig::setRecoverOnCrash(0); + // saveConfiguration(); + + // Destroy all windows... + /*Q_FOREACH(QWeakPointer<RekonqWindow> pointer, m_rekonqWindows) + { + delete pointer.data(); + pointer.clear(); + }*/ + + // Destroy all web apps + for (auto *webApp : m_webApps) delete webApp; } // --------------------------------------------------------------------------------------------------------------- - +/* int Application::newInstance() { KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); @@ -179,7 +122,7 @@ int Application::newInstance() if (isFirstLoad) { bool restoreOk = false; - + switch(ReKonfig::startupBehaviour()) { case 2: @@ -188,11 +131,11 @@ int Application::newInstance() else restoreOk = SessionManager::self()->restoreSessionFromScratch(); break; - + case 3: SessionManager::self()->manageSessions(); break; - + default: restoreOk = SessionManager::self()->restoreJustThePinnedTabs(); break; @@ -332,8 +275,9 @@ int Application::newInstance() SessionManager::self()->setSessionManagementEnabled(true); } - if (ReKonfig::checkDefaultSearchEngine() && !hasToBeRecoveredFromCrash && SearchEngine::defaultEngine().isNull()) - QTimer::singleShot(2000, rekonqWindow()->currentWebWindow()->tabView(), SLOT(showSearchEngineBar())); + if (ReKonfig::checkDefaultSearchEngine() && !hasToBeRecoveredFromCrash && +SearchEngine::defaultEngine().isNull()) QTimer::singleShot(2000, rekonqWindow()->currentWebWindow()->tabView(), +SLOT(showSearchEngineBar())); ReKonfig::setRecoverOnCrash(ReKonfig::recoverOnCrash() + 1); saveConfiguration(); @@ -364,10 +308,10 @@ RekonqWindow *Application::rekonqWindow(const QString & activityID) #ifdef HAVE_KACTIVITIES wList = tabsForActivity(activityID); #endif - + if (wList.isEmpty()) return 0; - + Q_FOREACH(const QWeakPointer<RekonqWindow> &pointer, wList) { if (KWindowInfo(pointer.data()->effectiveWinId(), NET::WMDesktop, 0).isOnCurrentDesktop()) @@ -385,7 +329,7 @@ RekonqWindowList Application::tabsForActivity(const QString & activityID) QString id = activityID; if ( id.isEmpty() ) id = m_activityConsumer->currentActivity(); - + return m_activityRekonqWindowsMap[id]; #else return m_rekonqWindows; @@ -418,7 +362,7 @@ RekonqWindow *Application::newWindow(WebPage *pg) setWindowInfo(w); w->show(); - return w; + return w; } @@ -432,30 +376,28 @@ void Application::setWindowInfo(RekonqWindow *w) w->installEventFilter(this); m_rekonqWindows.prepend(w); - + #ifdef HAVE_KACTIVITIES QString currentActivity = m_activityConsumer->currentActivity(); m_activityRekonqWindowsMap[currentActivity].prepend(w); -#endif -} - +#endif +}*/ // ----------------------------------------------------------------------------------------------------------- +// Slots - -WebTab *Application::newWebApp() +rView *Application::newWebApp(const QUrl &url) { - WebTab *tab = new WebTab; - - tab->installEventFilter(this); - m_webApps.prepend(tab); + auto *view = new WebView(url); - tab->show(); + // tab->installEventFilter(this); + m_webApps.append(view); - return tab; + view->show(); + return view; } - +/* RekonqWindowList Application::rekonqWindowList() { return m_rekonqWindows; @@ -480,8 +422,8 @@ bool Application::eventFilter(QObject* watched, QEvent* event) RekonqWindow *window = qobject_cast<RekonqWindow*>(watched); if (window) { - if (!m_rekonqWindows.isEmpty() - && m_rekonqWindows.at(0) + if (!m_rekonqWindows.isEmpty() + && m_rekonqWindows.at(0) && m_rekonqWindows.at(0).data() != window) { int index = m_rekonqWindows.indexOf(QWeakPointer<RekonqWindow>(window)); @@ -506,7 +448,7 @@ bool Application::eventFilter(QObject* watched, QEvent* event) m_activityRekonqWindowsMap[currentActivity].removeOne(window); #endif } - + WebTab *webApp = qobject_cast<WebTab*>(watched); m_webApps.removeOne(webApp); @@ -536,7 +478,7 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) tab->view()->load(url); return; } - + Rekonq::OpenType newType = type; // Don't open useless tabs or windows for actions in rekonq: pages if (url.url().contains("rekonq:") && url.url().contains("/")) @@ -582,7 +524,7 @@ void Application::updateConfiguration() defaultSettings->setFontSize(QWebSettings::DefaultFontSize, ReKonfig::defaultFontSize()); defaultSettings->setFontSize(QWebSettings::MinimumFontSize, ReKonfig::minFontSize()); - + // encodings QString enc = ReKonfig::defaultEncoding(); defaultSettings->setDefaultTextEncoding(enc); @@ -607,10 +549,11 @@ void Application::updateConfiguration() defaultSettings->setMaximumPagesInCache(3); // ===== HTML 5 features WebKit support ====== - defaultSettings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, ReKonfig::offlineStorageDatabaseEnabled()); - defaultSettings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, ReKonfig::offlineWebApplicationCacheEnabled()); - defaultSettings->setAttribute(QWebSettings::LocalStorageEnabled, ReKonfig::localStorageEnabled()); - if (ReKonfig::localStorageEnabled()) + defaultSettings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, +ReKonfig::offlineStorageDatabaseEnabled()); + defaultSettings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, +ReKonfig::offlineWebApplicationCacheEnabled()); defaultSettings->setAttribute(QWebSettings::LocalStorageEnabled, +ReKonfig::localStorageEnabled()); if (ReKonfig::localStorageEnabled()) { QString path = KStandardDirs::locateLocal("cache", QString("WebkitLocalStorage/rekonq"), true); path.remove("rekonq"); @@ -629,10 +572,10 @@ void Application::updateConfiguration() HistoryManager::self()->loadSettings(); defaultSettings = 0; - + if (!rekonqWindow()) return; - + // ============== Tabs ================== bool b = ReKonfig::closeTabSelectPrevious(); Q_FOREACH(const QWeakPointer<RekonqWindow> &w, m_rekonqWindows) @@ -670,7 +613,8 @@ void Application::updateConfiguration() case 2: // url previews for (int i = 0; i < rekonqWindow()->tabBar()->count(); i++) { - rekonqWindow()->tabBar()->setTabToolTip(i, rekonqWindow()->tabWidget()->webWindow(i)->url().toMimeDataString()); + rekonqWindow()->tabBar()->setTabToolTip(i, +rekonqWindow()->tabWidget()->webWindow(i)->url().toMimeDataString()); } break; @@ -716,7 +660,7 @@ void Application::queryQuit() } } - SessionManager::self()->setSessionManagementEnabled(false); + SessionManager::self()->setSessionManagementEnabled(false); quit(); } @@ -832,7 +776,7 @@ void Application::createWebAppShortcut(const QString & urlString, const QString webAppTitle = titleString; } webAppTitle = webAppTitle.remove('&'); - + wAppWidget.nameLineEdit->setText(webAppTitle); wAppWidget.kcfg_createDesktopAppShortcut->setChecked(ReKonfig::createDesktopAppShortcut()); wAppWidget.kcfg_createMenuAppShortcut->setChecked(ReKonfig::createMenuAppShortcut()); @@ -882,8 +826,8 @@ void Application::createWebAppShortcut(const QString & urlString, const QString out.setCodec("UTF-8"); out << shortcutString; - wAppFile.setPermissions(QFile::ReadUser | QFile::WriteUser | QFile::ExeUser | QFile::ReadGroup | QFile::ReadOther); - wAppFile.close(); + wAppFile.setPermissions(QFile::ReadUser | QFile::WriteUser | QFile::ExeUser | QFile::ReadGroup | +QFile::ReadOther); wAppFile.close(); } if (ReKonfig::createMenuAppShortcut()) @@ -937,3 +881,4 @@ void Application::pageCreated(WebPage *pg) tw->activateWindow(); tw->raise(); } +*/ diff --git a/src/application.h b/src/application.h index 307e2fd6..761bc89b 100644 --- a/src/application.h +++ b/src/application.h @@ -6,27 +6,28 @@ * SPDX-License-Identifier: GPL-3.0-only * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net> * ============================================================ - * Description: Application Entry Point + * Description: Application Main Class * ============================================================ */ #pragma once #include "rekonq.hpp" +#include <QUrl> +#include <QWidget> #include <SingleApplication> // Forward Declarations -class RekonqWindow; +class rView; +// class RekonqWindow; -class WebTab; -class WebPage; +// class WebTab; +// class WebPage; -typedef QList< QWeakPointer<RekonqWindow> > RekonqWindowList; -typedef QList<WebTab *> WebAppList; +// typedef QList< QWeakPointer<RekonqWindow> > RekonqWindowList; +// typedef QList<WebTab *> WebAppList; // --------------------------------------------------------------------------------------------------------------- -#define rApp Application::instance() - /** * Rekonq Application class */ @@ -34,86 +35,81 @@ class Application : public SingleApplication { Q_OBJECT public: - Application(int argc, char **argv); + Application(int &argc, char *argv[]); ~Application() override; - int newInstance(); + // int newInstance(); static Application *instance() { return (qobject_cast<Application *>(QCoreApplication::instance())); } - RekonqWindow *rekonqWindow(const QString &activityID = QString()); - RekonqWindowList rekonqWindowList(); + // RekonqWindow *rekonqWindow(const QString &activityID = QString()); + // RekonqWindowList rekonqWindowList(); /** * @returns the list of windows associated with activity whose id is @param activityID * @param activityID the ID of the activity (if empty, it is interpreted as the current activity) * @note If activities are disabled, returns the function returns the list of all tabs. */ - RekonqWindowList tabsForActivity(const QString &activityID = QString()); + // RekonqWindowList tabsForActivity(const QString &activityID = QString()); /** * @returns the true if there are windows associated with activity whose id is @param activityID * @param activityID the ID of the activity (if empty, it is interpreted as the current activity) * @note If activities are disabled, returns true if there are any tabs. */ - bool haveWindowsForActivity(const QString &activityID = QString()); - - WebAppList webAppList(); + // bool haveWindowsForActivity(const QString &activityID = QString()); - void bookmarksToolbarToggled(bool); + // WebAppList webAppList(); -public Q_SLOTS: - /** - * Save application's configuration - * - * @see ReKonfig::self()->writeConfig(); - */ - void saveConfiguration() const; + // void bookmarksToolbarToggled(bool); - /** - * @short load url - * - * @param url The url to load - * @param type the type where loading the url. @see Rekonq::OpenType - */ - void loadUrl(const KUrl& url, - const Rekonq::OpenType& type = Rekonq::CurrentTab - ); +public slots: + /** + * Save application's configuration + * + * @see ReKonfig::self()->writeConfig(); + */ + // void saveConfiguration() const; - RekonqWindow *newWindow(bool withTab = true, bool PrivateBrowsingMode = false); - RekonqWindow *newWindow(WebPage *pg); + /** + * @short load url + * + * @param url The url to load + * @param type the type where loading the url. @see Rekonq::OpenType + */ + // void loadUrl(const KUrl& url, const Rekonq::OpenType& type = Rekonq::CurrentTab); - WebTab *newWebApp(); + // RekonqWindow *newWindow(bool withTab = true, bool PrivateBrowsingMode = false); + // RekonqWindow *newWindow(WebPage *pg); + rView *newWebApp(const QUrl &url = QUrl()); - void createWebAppShortcut(const QString & urlString = QString(), const QString & titleString = QString()); + // void createWebAppShortcut(const QString & urlString = QString(), const QString & titleString = QString()); protected: - // This is used to track which window was activated most recently - bool eventFilter(QObject *watched, QEvent *event); + // This is used to track which window was activated most recently + // bool eventFilter(QObject *watched, QEvent *event); -Q_SIGNALS: - void toggleBookmarksToolbar(bool); +signals: + void toggleBookmarksToolbar(bool); private: - void setWindowInfo(RekonqWindow *); - -private Q_SLOTS: - void updateConfiguration(); + // void setWindowInfo(RekonqWindow *); - // clear private data - void clearPrivateData(); +private slots: + // void updateConfiguration(); - void queryQuit(); + // clear private data + // void clearPrivateData(); - void newPrivateBrowsingWindow(); + // void queryQuit(); - void pageCreated(WebPage *); + // void newPrivateBrowsingWindow(); + + // void pageCreated(WebPage *); private: - RekonqWindowList m_rekonqWindows; - WebAppList m_webApps; - -#ifdef HAVE_KACTIVITIES - ActivityTabsMap m_activityRekonqWindowsMap; - KActivities::Consumer *m_activityConsumer; -#endif + // RekonqWindowList m_rekonqWindows; + QList<rView *> m_webApps; }; + +[[deprecated]] static inline auto *rApp_f() { return Application::instance(); } +#define rApp rApp_f() diff --git a/src/main.cpp b/src/main.cpp index a483078b..20c30c68 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,71 +9,58 @@ * Description: Application Entry Point * ============================================================ */ -// version include -#include <config-version.h> - -// Local Includes #include "application.h" -#include "sessionmanager.h" -#include "rekonqwindow.h" -#include "urlresolver.h" - -// KDE Includes -#include <KDE/KCmdLineArgs> -#include <KDE/KUniqueApplication> - -// Qt Includes -#include <QDir> -#include <QUrl> +//#include "sessionmanager.h" +//#include "rekonqwindow.h" +//#include "urlresolver.h" +#include <QCommandLineParser> +static const char *description = "A lightweight Web Browser based on Qt WebEngine"; -static const char description[] = - I18N_NOOP("A lightweight Web Browser for KDE based on WebKit"); - - -extern "C" KDE_EXPORT int kdemain(int argc, char **argv) +int main(int argc, char **argv) { + Application app(argc, argv); + // Set application data + QCoreApplication::setApplicationName(QL1S("rekonq")); + QCoreApplication::setApplicationVersion(REKONQ_VERSION); + // Initialize command line args - KCmdLineArgs::init(argc, argv, &about); + QCommandLineParser parser; + parser.setApplicationDescription(description); + parser.addHelpOption(); + parser.addVersionOption(); - // Define the command line options using KCmdLineOptions - KCmdLineOptions options; + // Define the command line options + QCommandLineOption options_incognito("incognito", QCoreApplication::translate("main", "Open in incognito mode")); + QCommandLineOption options_webapp("webapp", + QCoreApplication::translate("main", "Open URL as web app (in a simple window)")); + parser.addOptions({options_incognito, options_webapp}); - // adding options - options.add("incognito", ki18n("Open in incognito mode")); - options.add("webapp", ki18n("Open URL as web app (in a simple window)")); - options.add("+[URL]", ki18n("Location to open")); + // Define the positional arguments + parser.addPositionalArgument("URL", QCoreApplication::translate("main", "Location to open")); - // Register the supported options - KCmdLineArgs::addCmdLineOptions(options); + parser.process(app); - if (!Application::start()) { + const auto positionalArguments = parser.positionalArguments(); + if (parser.isSet(options_webapp)) + positionalArguments.isEmpty() ? app.newWebApp() : app.newWebApp(QUrl::fromUserInput(positionalArguments.first())); + + /*if (!Application::start()) { kWarning() << "rekonq is already running!"; return 0; - } - -#if defined(Q_WS_X11) - // On X11, the raster engine gives better performance than native. - QApplication::setGraphicsSystem(QLatin1String("raster")); -#endif - - KCmdLineArgs::setCwd(QDir::currentPath().toUtf8()); - - Application app; - - // set application data - QCoreApplication::setApplicationName(QLatin1String("rekonq")); - QCoreApplication::setApplicationVersion(REKONQ_VERSION); - - if (app.isSessionRestored()) - { - for (int i = 1; RekonqWindow::canBeRestored(i); i++) - { - RekonqWindow * newRekonqWindow = app.newWindow(false); - if (newRekonqWindow->restore(i)) - SessionManager::self()->restoreWindow(newRekonqWindow); - } - } - - return app.exec(); + }*/ + + /* + + if (app.isSessionRestored()) + { + for (int i = 1; RekonqWindow::canBeRestored(i); i++) + { + RekonqWindow * newRekonqWindow = app.newWindow(false); + if (newRekonqWindow->restore(i)) + SessionManager::self()->restoreWindow(newRekonqWindow); + } + } + */ + return Application::exec(); } diff --git a/src/rekonq_defines.h b/src/rekonq_defines.h index 814e7599..629d59bc 100644 --- a/src/rekonq_defines.h +++ b/src/rekonq_defines.h @@ -1,52 +1,25 @@ /* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2007 David Faure <faure@kde.org> -* Copyright (C) 2009-2012 by Andrea Diamantini <adjam7 at gmail dot com> -* -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation; either version 2 of -* the License or (at your option) version 3 or any later version -* accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy -* defined in Section 14 of version 3 of the license. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. -* -* ============================================================ */ - - -#ifndef REKONQ_DEFINES_H -#define REKONQ_DEFINES_H - + * The rekonq project + * ============================================================ + * SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2007 David Faure <faure@kde.org> + * Copyright (C) 2009-2012 by Andrea Diamantini <adjam7 at gmail dot com> + * SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net> + * ============================================================ + * Description: rekonq bookmarks system interface + * ============================================================ */ + +#pragma once // ---------------------------------------------------------------------------------------------------- // UNIT TESTS NEED - -/* needed for KDE_EXPORT and KDE_IMPORT macros */ -#include <kdemacros.h> - -/* Classes from the rekonq application, which are exported only for unit tests */ -#ifndef REKONQ_TESTS_EXPORT -/* We are building this library */ -#define REKONQ_TESTS_EXPORT KDE_EXPORT -#else -/* We are using this library */ -#define REKONQ_TESTS_EXPORT KDE_IMPORT +#ifndef REKONQ_TEST_EXPORT +#define REKONQ_TEST_EXPORT __attribute__((visibility("hidden"))) #endif - // ---------------------------------------------------------------------------------------------------- -// DEFINES +// Defines #define QL1S(x) QLatin1String(x) #define QL1C(x) QLatin1Char(x) @@ -59,13 +32,10 @@ # endif #endif //ASSERT_NOT_REACHED - // -------------------------------------------------------------------------------------- -// ENUMS - +// Enums -namespace Rekonq -{ +namespace rekonq { /** * @short Open link options @@ -93,16 +63,6 @@ enum SyncData Passwords }; -} - - -// ---------------------------------------------------------------------------------------------------- -// INCLUDES - -#include <KDebug> - - +} // namespace rekonq // ---------------------------------------------------------------------------------------------------- - -#endif // REKONQ_DEFINES_H diff --git a/src/rview.cpp b/src/rview.cpp new file mode 100644 index 00000000..2da3096c --- /dev/null +++ b/src/rview.cpp @@ -0,0 +1,12 @@ +/* ============================================================ + * The rekonq project + * ============================================================ + * SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net> + * ============================================================ + * Description: View Interface + * ============================================================ */ + +#include "rview.h" + +rView::rView(const QUrl &url, QWidget *parent) : QWidget(parent) {} diff --git a/src/rview.h b/src/rview.h new file mode 100644 index 00000000..4f4cc897 --- /dev/null +++ b/src/rview.h @@ -0,0 +1,25 @@ +/* ============================================================ + * The rekonq project + * ============================================================ + * SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net> + * ============================================================ + * Description: View Interface + * ============================================================ */ + +#pragma once + +#include <QUrl> +#include <QWidget> + +class rView : public QWidget { + Q_OBJECT + +public: + explicit rView(const QUrl &url = QUrl(), QWidget *parent = nullptr); + +signals: + void iconChanged(const QIcon &); + void urlChanged(const QUrl &); + void titleChanged(const QString &); +}; diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp new file mode 100644 index 00000000..1aef01e2 --- /dev/null +++ b/src/webengine/webview.cpp @@ -0,0 +1,25 @@ +/* ============================================================ + * The rekonq project + * ============================================================ + * SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net> + * ============================================================ + * Description: Qt WebEngine View + * ============================================================ */ + +#include "webview.h" +#include <QVBoxLayout> +#include <QWebEngineView> + +WebView::WebView(const QUrl &url, QWidget *parent) : rView(url, parent), view(new QWebEngineView(this)) +{ + auto *layout = new QVBoxLayout; + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(view); + setLayout(layout); + + connect(view, &QWebEngineView::iconChanged, this, [this](const QIcon &icon) { emit iconChanged(icon); }); + connect(view, &QWebEngineView::urlChanged, this, [this](const QUrl &url) { emit urlChanged(url); }); + connect(view, &QWebEngineView::titleChanged, this, [this](const QString &title) { emit titleChanged(title); }); + view->load(url); +} diff --git a/src/webengine/webview.h b/src/webengine/webview.h new file mode 100644 index 00000000..b838c5ac --- /dev/null +++ b/src/webengine/webview.h @@ -0,0 +1,25 @@ +/* ============================================================ + * The rekonq project + * ============================================================ + * SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net> + * ============================================================ + * Description: Qt WebEngine View + * ============================================================ */ + +#pragma once + +#include "rview.h" + +class QWebEngineView; + +class WebView final : public rView { + Q_OBJECT + +public: + explicit WebView(const QUrl &url = QUrl(), QWidget *parent = nullptr); + ~WebView() final = default; + +private: + QWebEngineView *view; +}; |