Web: Extended openBrowserHTML to allow custom icon

This commit is contained in:
Yorik van Havre
2021-09-21 15:45:32 +02:00
parent c6d30974be
commit c942d950a9

View File

@@ -27,6 +27,7 @@
# include <QMdiArea>
# include <QMdiSubWindow>
# include <QUrl>
# include <QIcon>
#endif
#include <Base/Console.h>
@@ -63,7 +64,7 @@ public:
add_varargs_method("openBrowserWindow",&Module::openBrowserWindow
);
add_varargs_method("open",&Module::openBrowser,
"open(string)\n"
"open(htmlcode,baseurl,[title,iconpath])\n"
"Load a local (X)HTML file."
);
add_varargs_method("insert",&Module::openBrowser,
@@ -99,8 +100,9 @@ private:
{
const char* HtmlCode;
const char* BaseUrl;
const char* IconPath;
char* TabName = nullptr;
if (! PyArg_ParseTuple(args.ptr(), "ss|et", &HtmlCode, &BaseUrl, "utf-8", &TabName))
if (! PyArg_ParseTuple(args.ptr(), "ss|ets", &HtmlCode, &BaseUrl, "utf-8", &TabName, &IconPath))
throw Py::Exception();
std::string EncodedName = "Browser";
@@ -114,6 +116,8 @@ private:
pcBrowserView->resize(400, 300);
pcBrowserView->setHtml(QString::fromUtf8(HtmlCode),QUrl(QString::fromLatin1(BaseUrl)));
pcBrowserView->setWindowTitle(QString::fromUtf8(EncodedName.c_str()));
if (IconPath)
pcBrowserView->setWindowIcon(QIcon(QString::fromUtf8(IconPath)));
Gui::getMainWindow()->addWindow(pcBrowserView);
if (!Gui::getMainWindow()->activeWindow())
Gui::getMainWindow()->setActiveWindow(pcBrowserView);