void TSScriptJS::GetWebConfig(std::string& Adapter_Ip, int& Adapter_Port) { ScriptingCore* sc = ScriptingCore::getInstance(); sc->runScript("Config/Config.js"); JSObject* pObj; jsval obj; JS_GetProperty(sc->getGlobalContext(),sc->getGlobalObject(),"IP", &obj); JS_ValueToObject(sc->getGlobalContext(),obj,&pObj); jsval AdaptServerIP; JS_GetProperty(sc->getGlobalContext(),pObj,"AdaptServerIP", &AdaptServerIP); JSString* pS = JS_ValueToString(sc->getGlobalContext(), AdaptServerIP); JSStringWrapper pW(pS); Adapter_Ip = pW.get().c_str(); TSLog("AdapteServer Ip = %s", pW.get().c_str()); jsval ip_port; JS_GetProperty(sc->getGlobalContext(),pObj,"AdaptServerPort", &ip_port); JSString* pS_port = JS_ValueToString(sc->getGlobalContext(), ip_port); JSStringWrapper pWs(pS_port); Adapter_Port = atoi(pWs.get().c_str()); TSLog("AdapteServer Port = %s",pWs.get().c_str()); }
void UIVMPreviewWindow::repaintBGImages() { /* Delete the old images: */ if (m_pbgImage) { delete m_pbgImage; m_pbgImage = 0; } if (m_pGlossyImg) { delete m_pGlossyImg; m_pGlossyImg = 0; } /* Check that there is enough room for our fancy stuff. * If not we just draw nothing (the border and the blur radius). */ QRect cr = contentsRect(); if (cr.width() < 41 || cr.height() < 41) return; QPalette pal = palette(); m_wRect = cr.adjusted(10, 10, -10, -10); m_vRect = m_wRect.adjusted(m_vMargin, m_vMargin, -m_vMargin, -m_vMargin).adjusted(-3, -3, 3, 3); /* First draw the shadow. Its a rounded rectangle which get blurred: */ QImage imageW(cr.size(), QImage::Format_ARGB32); QColor bg = pal.color(QPalette::Base); bg.setAlpha(0); /* We want blur to transparent _and_ whatever the base color is. */ imageW.fill(bg.rgba()); QPainter pW(&imageW); pW.setBrush(QColor(30, 30, 30)); /* Dark gray */ pW.setPen(Qt::NoPen); pW.drawRoundedRect(QRect(QPoint(0, 0), cr.size()).adjusted(10, 10, -10, -10), m_vMargin, m_vMargin); pW.end(); /* Blur the rectangle */ QImage imageO(cr.size(), QImage::Format_ARGB32); blurImage(imageW, imageO, 10); QPainter pO(&imageO); /* Now paint the border with a gradient to get a look of a monitor: */ QRect rr = QRect(QPoint(0, 0), cr.size()).adjusted(10, 10, -10, -10); QLinearGradient lg(0, rr.y(), 0, rr.height()); QColor base(200, 200, 200); /* light variant */ // QColor base(80, 80, 80); /* Dark variant */ lg.setColorAt(0, base); lg.setColorAt(0.4, base.darker(300)); lg.setColorAt(0.5, base.darker(400)); lg.setColorAt(0.7, base.darker(300)); lg.setColorAt(1, base); pO.setBrush(lg); pO.setPen(QPen(base.darker(150), 1)); pO.drawRoundedRect(rr, m_vMargin, m_vMargin); pO.end(); /* Make a copy of the new bg image: */ m_pbgImage = new QImage(imageO); /* Now the glossy overlay has to be created. * Start with defining a nice looking painter path. */ QRect gRect = QRect(QPoint(0, 0), m_vRect.size()); QPainterPath glossyPath(QPointF(gRect.x(), gRect.y())); glossyPath.lineTo(gRect.x() + gRect.width(), gRect.y()); glossyPath.lineTo(gRect.x() + gRect.width(), gRect.y() + gRect.height() * 1.0/3.0); glossyPath.cubicTo(gRect.x() + gRect.width() / 2.0, gRect.y() + gRect.height() * 1.0/3.0, gRect.x() + gRect.width() / 2.0, gRect.y() + gRect.height() * 2.0/3.0, gRect.x(), gRect.y() + gRect.height() * 2.0/3.0); glossyPath.closeSubpath(); /* Paint the glossy path on a QImage: */ QImage image(m_vRect.size(), QImage::Format_ARGB32); QColor bg1(Qt::white); /* We want blur to transparent _and_ white. */ bg1.setAlpha(0); image.fill(bg1.rgba()); QPainter painter(&image); painter.fillPath(glossyPath, QColor(255, 255, 255, 80)); painter.end(); /* Blur the image to get a much more smooth feeling */ QImage image1(m_vRect.size(), QImage::Format_ARGB32); blurImage(image, image1, 7); m_pGlossyImg = new QImage(image1); /* Repaint: */ update(); }