Commit 2a30387e authored by Ivan Ilin's avatar Ivan Ilin

Sankore284

parent ff90ddf3
<html>
<head>
<title>ololo</title>
<style>
html,body{
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
div{
text-align: center;
border: 5px #ccc outset;
}
</style>
<script type="text/javascript">
window.onload = function(){
var div = document.getElementById("freezed");
div.style.width = getDocWidth() - 10;
div.style.height = getDocHeight()/2 - 10;
div.style.paddingTop = getDocHeight()/2
function getDocHeight() {
var D = document;
return Math.max(
Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
Math.max(D.body.clientHeight, D.documentElement.clientHeight)
);
}
function getDocWidth() {
var D = document;
return Math.max(
Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
Math.max(D.body.clientWidth, D.documentElement.clientWidth)
);
}
}
</script>
</head>
<body>
<div id="freezed">Widget freezed.</div>
</body>
</html>
\ No newline at end of file
...@@ -365,7 +365,7 @@ void UBBoardController::connectToolbar() ...@@ -365,7 +365,7 @@ void UBBoardController::connectToolbar()
void UBBoardController::startScript() void UBBoardController::startScript()
{ {
freezeW3CWidgets(false); freezeW3CWidgets(true);
} }
void UBBoardController::stopScript() void UBBoardController::stopScript()
...@@ -2160,16 +2160,15 @@ void UBBoardController::freezeW3CWidgets(bool freeze) ...@@ -2160,16 +2160,15 @@ void UBBoardController::freezeW3CWidgets(bool freeze)
void UBBoardController::freezeW3CWidget(QGraphicsItem *item, bool freeze) void UBBoardController::freezeW3CWidget(QGraphicsItem *item, bool freeze)
{ {
if(item->type() == UBGraphicsW3CWidgetItem::Type) if(item->type() == UBGraphicsW3CWidgetItem::Type)
{ {
QString scriptString; UBGraphicsW3CWidgetItem* item_casted = dynamic_cast<UBGraphicsW3CWidgetItem*>(item);
if (freeze) if (0 == item_casted)
scriptString = "setfreezed(true);"; return;
else
scriptString = "setfreezed(false);"; if (freeze) {
UBGraphicsW3CWidgetItem* item_casted = dynamic_cast<UBGraphicsW3CWidgetItem*>(item); item_casted->widgetWebView()->page()->mainFrame()->setContent(UBW3CWidget::freezedWidgetPage().toAscii());
if (0 == item_casted) } else
return; item_casted->widgetWebView()->loadMainHtml();
item_casted->widgetWebView()->page()->mainFrame()->evaluateJavaScript(scriptString); }
} }
}
\ No newline at end of file
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include "core/memcheck.h" #include "core/memcheck.h"
const QString freezedWidgetDefaultContentFilePath = "./etc/freezedWidgetWrapper.html";
bool UBW3CWidget::sTemplateLoaded = false; bool UBW3CWidget::sTemplateLoaded = false;
QMap<QString, QString> UBW3CWidget::sNPAPIWrapperTemplates; QMap<QString, QString> UBW3CWidget::sNPAPIWrapperTemplates;
QString UBW3CWidget::sNPAPIWrappperConfigTemplate; QString UBW3CWidget::sNPAPIWrappperConfigTemplate;
...@@ -416,6 +418,29 @@ QString UBW3CWidget::createHtmlWrapperInDir(const QString& html, const QDir& pDi ...@@ -416,6 +418,29 @@ QString UBW3CWidget::createHtmlWrapperInDir(const QString& html, const QDir& pDi
} }
QString UBW3CWidget::freezedWidgetPage()
{
static QString defaultcontent;
if (defaultcontent.isNull()) {
QFile wrapperFile(freezedWidgetDefaultContentFilePath);
if (!wrapperFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "can't open wrapper file " + freezedWidgetDefaultContentFilePath;
defaultcontent = "";
} else {
QByteArray arr = wrapperFile.readAll();
if (!arr.isEmpty()) {
defaultcontent = QString(arr);
} else {
qDebug() << "content of " + freezedWidgetDefaultContentFilePath + "is empty";
defaultcontent = "";
}
}
}
return defaultcontent;
}
void UBW3CWidget::loadNPAPIWrappersTemplates() void UBW3CWidget::loadNPAPIWrappersTemplates()
{ {
if (!sTemplateLoaded) if (!sTemplateLoaded)
......
...@@ -48,6 +48,8 @@ class UBW3CWidget : public UBAbstractWidget ...@@ -48,6 +48,8 @@ class UBW3CWidget : public UBAbstractWidget
static QString createHtmlWrapperInDir(const QString& html, const QDir& pDir, static QString createHtmlWrapperInDir(const QString& html, const QDir& pDir,
const QSize& sizeHint, const QString& pName); const QSize& sizeHint, const QString& pName);
static QString freezedWidgetPage();
static bool hasNPAPIWrapper(const QString& pMimeType); static bool hasNPAPIWrapper(const QString& pMimeType);
class PreferenceValue class PreferenceValue
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment