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
|
/* Copyright (c) MediaArea.net SARL. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license that can
* be found in the License.html file in the root of the source tree.
*/
#include "commonwebwindow.h"
#include "mainwindow.h"
#include "WebView.h"
#include "WebPage.h"
#include "progressbar.h"
#include <QFile>
#include <QProgressBar>
namespace MediaConch {
//***************************************************************************
// Constructor / Desructor
//***************************************************************************
CommonWebWindow::CommonWebWindow(MainWindow *p) : main_window(p)
{
}
CommonWebWindow::~CommonWebWindow()
{
}
//***************************************************************************
// Visual elements
//***************************************************************************
//---------------------------------------------------------------------------
void CommonWebWindow::display_html()
{
QFile template_html(":/base.html");
template_html.open(QIODevice::ReadOnly | QIODevice::Text);
QString html(template_html.readAll());
template_html.close();
create_html(html);
QUrl url;
#if QT_VERSION < 0x050700 || defined(WEB_MACHINE_ENGINE)
url = QUrl("qrc:/html"); //Without it, it works sometimes, depending of engine and version, so let it as before for Qt<5.7 as it is always working for Qt<5.7 and never for Qt>=5.7
if (!url.isValid())
return;
#endif
#if defined(WEB_MACHINE_ENGINE)
main_window->web_view->setHtml(html.toUtf8(), url);
#endif
#if defined(WEB_MACHINE_KIT)
main_window->web_view->setContent(html.toUtf8(), "text/html", url); //If we use setHtml(), HTML is parsed with local codepage instead of UTF-8
#endif
}
//---------------------------------------------------------------------------
void CommonWebWindow::use_javascript(const QString& script)
{
if (main_window->web_view)
{
WebPage* page = (WebPage*)main_window->web_view->page();
if (page)
page->use_javascript(script);
}
}
}
|