2017-12-20 14:39:09 +01:00
|
|
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
2015-08-14 17:18:17 +02:00
|
|
|
*
|
2020-08-22 01:19:58 +02:00
|
|
|
* SPDX-FileCopyrightText: 2015 Rohan Garg <rohan@garg.io>
|
|
|
|
* SPDX-FileCopyrightText: 2016 Teo Mrnjavac <teo@kde.org>
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2015-08-14 17:18:17 +02:00
|
|
|
*
|
|
|
|
* Calamares 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-08-24 17:36:18 +02:00
|
|
|
#include "WebViewConfig.h"
|
2015-08-14 17:18:17 +02:00
|
|
|
#include "WebViewStep.h"
|
|
|
|
|
|
|
|
#include <QVariant>
|
2016-03-29 10:22:58 +02:00
|
|
|
|
|
|
|
#ifdef WEBVIEW_WITH_WEBKIT
|
2016-03-24 16:53:18 +01:00
|
|
|
#include <QWebView>
|
2016-03-29 10:22:58 +02:00
|
|
|
#else
|
|
|
|
#include <QWebEngineView>
|
2016-12-21 21:20:05 +01:00
|
|
|
#include <QtWebEngine>
|
2016-03-29 10:22:58 +02:00
|
|
|
#endif
|
2015-08-14 17:18:17 +02:00
|
|
|
|
2020-08-22 01:19:58 +02:00
|
|
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( WebViewStepFactory, registerPlugin< WebViewStep >(); )
|
2015-09-09 18:46:37 +02:00
|
|
|
|
2015-08-14 17:18:17 +02:00
|
|
|
WebViewStep::WebViewStep( QObject* parent )
|
|
|
|
: Calamares::ViewStep( parent )
|
|
|
|
{
|
|
|
|
emit nextStatusChanged( true );
|
2016-12-22 13:52:33 +01:00
|
|
|
#ifdef WEBVIEW_WITH_WEBENGINE
|
|
|
|
QtWebEngine::initialize();
|
|
|
|
#endif
|
2016-03-29 10:22:58 +02:00
|
|
|
m_view = new C_QWEBVIEW();
|
|
|
|
#ifdef WEBVIEW_WITH_WEBKIT
|
|
|
|
m_view->settings()->setFontFamily( QWebSettings::StandardFont,
|
2020-08-22 01:19:58 +02:00
|
|
|
m_view->settings()->fontFamily( QWebSettings::SansSerifFont ) );
|
|
|
|
m_view->setRenderHints( QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::HighQualityAntialiasing
|
|
|
|
| QPainter::SmoothPixmapTransform | QPainter::NonCosmeticDefaultPen );
|
2016-03-29 10:22:58 +02:00
|
|
|
#endif
|
2015-08-14 17:18:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WebViewStep::~WebViewStep()
|
|
|
|
{
|
|
|
|
if ( m_view && m_view->parent() == nullptr )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2015-08-14 17:18:17 +02:00
|
|
|
m_view->deleteLater();
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2015-08-14 17:18:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString
|
|
|
|
WebViewStep::prettyName() const
|
|
|
|
{
|
|
|
|
return m_prettyName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QWidget*
|
|
|
|
WebViewStep::widget()
|
|
|
|
{
|
|
|
|
return m_view;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
WebViewStep::isNextEnabled() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
WebViewStep::isBackEnabled() const
|
|
|
|
{
|
2015-08-14 18:48:35 +02:00
|
|
|
return true;
|
2015-08-14 17:18:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
WebViewStep::isAtBeginning() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
WebViewStep::isAtEnd() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-08-22 01:19:58 +02:00
|
|
|
void
|
|
|
|
WebViewStep::onActivate()
|
2015-08-14 17:18:17 +02:00
|
|
|
{
|
2020-08-22 01:19:58 +02:00
|
|
|
m_view->load( QUrl( m_url ) );
|
|
|
|
m_view->show();
|
2015-08-14 17:18:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QList< Calamares::job_ptr >
|
|
|
|
WebViewStep::jobs() const
|
|
|
|
{
|
|
|
|
return QList< Calamares::job_ptr >();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
WebViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|
|
|
{
|
2020-08-22 01:19:58 +02:00
|
|
|
if ( configurationMap.contains( "url" ) && configurationMap.value( "url" ).type() == QVariant::String )
|
|
|
|
{
|
|
|
|
m_url = configurationMap.value( "url" ).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( configurationMap.contains( "prettyName" )
|
|
|
|
&& configurationMap.value( "prettyName" ).type() == QVariant::String )
|
|
|
|
{
|
|
|
|
m_prettyName = configurationMap.value( "prettyName" ).toString();
|
|
|
|
}
|
2015-08-14 17:18:17 +02:00
|
|
|
}
|