blob: 1e3ac64653acff86195d3276915d2ab55f274c4e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/*
* 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 <QHash>
#include <QUrl>
#include <QString>
#include <QWebEngineProfile>
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<QString, QString> &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
|