source: calamares/trunk/fuentes/src/modules/webview/WebViewStep.cpp @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 17 months ago

sync with github

File size: 3.0 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2015, Rohan Garg <rohan@garg.io>
4 *   Copyright 2016, Teo Mrnjavac <teo@kde.org>
5 *
6 *   Calamares 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 *   Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "WebViewStep.h"
21
22#include <QVariant>
23
24#ifdef WEBVIEW_WITH_WEBKIT
25#include <QWebView>
26#else
27#include <QWebEngineView>
28#include <QtWebEngine>
29#endif
30
31CALAMARES_PLUGIN_FACTORY_DEFINITION( WebViewStepFactory, registerPlugin<WebViewStep>(); )
32
33WebViewStep::WebViewStep( QObject* parent )
34    : Calamares::ViewStep( parent )
35{
36    emit nextStatusChanged( true );
37#ifdef WEBVIEW_WITH_WEBENGINE
38    QtWebEngine::initialize();
39#endif
40    m_view = new C_QWEBVIEW();
41#ifdef WEBVIEW_WITH_WEBKIT
42    m_view->settings()->setFontFamily( QWebSettings::StandardFont,
43                                       m_view->settings()->
44                                       fontFamily( QWebSettings::SansSerifFont ) );
45    m_view->setRenderHints( QPainter::Antialiasing |
46                            QPainter::TextAntialiasing |
47                            QPainter::HighQualityAntialiasing |
48                            QPainter::SmoothPixmapTransform |
49                            QPainter::NonCosmeticDefaultPen );
50#endif
51}
52
53
54WebViewStep::~WebViewStep()
55{
56    if ( m_view && m_view->parent() == nullptr )
57        m_view->deleteLater();
58}
59
60
61QString
62WebViewStep::prettyName() const
63{
64    return m_prettyName;
65}
66
67
68QWidget*
69WebViewStep::widget()
70{
71    return m_view;
72}
73
74
75void
76WebViewStep::next()
77{
78    emit done();
79}
80
81
82void
83WebViewStep::back()
84{}
85
86
87bool
88WebViewStep::isNextEnabled() const
89{
90    return true;
91}
92
93
94bool
95WebViewStep::isBackEnabled() const
96{
97    return true;
98}
99
100
101bool
102WebViewStep::isAtBeginning() const
103{
104    return true;
105}
106
107
108bool
109WebViewStep::isAtEnd() const
110{
111    return true;
112}
113
114void WebViewStep::onActivate()
115{
116  m_view->load(QUrl(m_url));
117  m_view->show();
118}
119
120QList< Calamares::job_ptr >
121WebViewStep::jobs() const
122{
123    return QList< Calamares::job_ptr >();
124}
125
126
127void
128WebViewStep::setConfigurationMap( const QVariantMap& configurationMap )
129{
130  if ( configurationMap.contains("url") &&
131       configurationMap.value("url").type() == QVariant::String )
132    m_url = configurationMap.value("url").toString();
133
134  if ( configurationMap.contains("prettyName") &&
135       configurationMap.value("prettyName").type() == QVariant::String )
136    m_prettyName = configurationMap.value("prettyName").toString();
137}
Note: See TracBrowser for help on using the repository browser.