/* * This file is part of smolbote. It's copyrighted by the contributors recorded * in the version control history of the file, available from its original * location: https://neueland.iserlohn-fortress.net/smolbote.hg * * SPDX-License-Identifier: GPL-3.0 */ #ifndef SMOLBOTE_WEBENGINEPROFILE_H #define SMOLBOTE_WEBENGINEPROFILE_H #include #include #include #include class WebProfile : public QWebEngineProfile { Q_OBJECT Q_PROPERTY(QString search READ search WRITE setSearch) Q_PROPERTY(QUrl homepage READ homepage WRITE setHomepage) Q_PROPERTY(QUrl newtab READ newtab WRITE setNewtab) public: explicit WebProfile(const QHash &defaults, QObject *parent = nullptr); explicit WebProfile(const QString &name, QObject *parent = nullptr); ~WebProfile() override; static void setDefaultProfile(WebProfile *profile) { Q_CHECK_PTR(profile); WebProfile::profile = profile; } static WebProfile *defaultProfile() { Q_CHECK_PTR(WebProfile::profile); return WebProfile::profile; } QString name() const { return m_name; } QString search() const { return m_search; } void setSearch(const QString &url) { m_search = url; } QUrl homepage() const { return m_homepage; } void setHomepage(const QUrl &url) { m_homepage = url; } QUrl newtab() const { return m_newtab; } void setNewtab(const QUrl &url) { m_newtab = url; } void addBookmark(const QString &title, const QString &url) { if(!title.isEmpty() && !url.isEmpty()) emit addBookmarkRequested(title, url); } signals: void addBookmarkRequested(const QString &title, const QString &url); private: static WebProfile *profile; QString m_name; QString m_search = QString("about:blank"); QUrl m_homepage = QUrl("about:blank"); QUrl m_newtab = QUrl("about:blank"); }; void loadProfile(WebProfile *profile, const QString &path); //WebProfile *saveProfile(WebProfile *profile, const QString &path); #endif // SMOLBOTE_WEBENGINEPROFILE_H