Example #1
0
static PyObject * 
openBrowserHTML(PyObject *self, PyObject *args) 
{
    const char* HtmlCode;
    const char* BaseUrl;
    const char* TabName = "Browser";
    if (! PyArg_ParseTuple(args, "ss|s",&HtmlCode,&BaseUrl,&TabName))
        return NULL; 
    
    PY_TRY {
        QMdiSubWindow* browserView = 0;
        QMdiArea* mdiArea = Gui::getMainWindow()->findChild<QMdiArea*>();
        QList<QMdiSubWindow *> mdiViews = mdiArea->subWindowList();
        for (QList<QMdiSubWindow *>::iterator it = mdiViews.begin(); it != mdiViews.end(); ++it) {
            if (qobject_cast<WebGui::BrowserView*>((*it)->widget())) {
                browserView = *it;
                break;
            }
        }

        if (!browserView) {
            WebGui::BrowserView* pcBrowserView = 0;
            pcBrowserView = new WebGui::BrowserView(Gui::getMainWindow());
            pcBrowserView->resize(400, 300);
            pcBrowserView->setHtml(QString::fromUtf8(HtmlCode),QUrl(QString::fromLatin1(BaseUrl)),QString::fromUtf8(TabName));
            Gui::getMainWindow()->addWindow(pcBrowserView);
        }
        else {
            mdiArea->setActiveSubWindow(browserView);
        }
    } PY_CATCH;

    Py_Return; 
}
Example #2
0
    Py::Object openBrowserHTML(const Py::Tuple& args)
    {
        const char* HtmlCode;
        const char* BaseUrl;
        char* TabName = nullptr;
        if (! PyArg_ParseTuple(args.ptr(), "ss|et", &HtmlCode, &BaseUrl, "utf-8", &TabName))
            throw Py::Exception();

        std::string EncodedName = "Browser";
        if (TabName) {
            EncodedName = std::string(TabName);
            PyMem_Free(TabName);
        }

        WebGui::BrowserView* pcBrowserView = 0;
        pcBrowserView = new WebGui::BrowserView(Gui::getMainWindow());
        pcBrowserView->resize(400, 300);
        pcBrowserView->setHtml(QString::fromUtf8(HtmlCode),QUrl(QString::fromLatin1(BaseUrl)));
        pcBrowserView->setWindowTitle(QString::fromUtf8(EncodedName.c_str()));
        Gui::getMainWindow()->addWindow(pcBrowserView);
        if (!Gui::getMainWindow()->activeWindow())
            Gui::getMainWindow()->setActiveWindow(pcBrowserView);

        return Py::None();
    }
Example #3
0
    Py::Object openBrowserHTML(const Py::Tuple& args)
    {
        const char* HtmlCode;
        const char* BaseUrl;
        const char* TabName = "Browser";
        if (! PyArg_ParseTuple(args.ptr(), "ss|s",&HtmlCode,&BaseUrl,&TabName))
            throw Py::Exception();

        WebGui::BrowserView* pcBrowserView = 0;
        pcBrowserView = new WebGui::BrowserView(Gui::getMainWindow());
        pcBrowserView->resize(400, 300);
        pcBrowserView->setHtml(QString::fromUtf8(HtmlCode),QUrl(QString::fromLatin1(BaseUrl)),QString::fromUtf8(TabName));
        Gui::getMainWindow()->addWindow(pcBrowserView);

        return Py::None();
    }