+ translatable tab name of Start page

This commit is contained in:
wmayer
2016-04-13 19:05:31 +02:00
parent df6eb69f56
commit 88e987dd86
2 changed files with 13 additions and 25 deletions

View File

@@ -24,7 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <qobject.h>
# include <QCoreApplication>
#endif
#include "Workbench.h"
@@ -60,20 +60,23 @@ StartGui::Workbench::~Workbench()
void StartGui::Workbench::activated()
{
// Ensure that we don't open the Start page multiple times
QString title = QCoreApplication::translate("Workbench", "Start page");
QList<QWidget*> ch = Gui::getMainWindow()->windows();
for (QList<QWidget*>::const_iterator c = ch.begin(); c != ch.end(); c++)
if ((*c)->windowTitle() == QObject::tr("Start page"))
for (QList<QWidget*>::const_iterator c = ch.begin(); c != ch.end(); ++c) {
if ((*c)->windowTitle() == title)
return;
}
try {
QByteArray utf8Title = title.toUtf8();
Gui::Command::doCommand(Gui::Command::Gui,"import WebGui");
Gui::Command::doCommand(Gui::Command::Gui,"from StartPage import StartPage");
#if defined(FC_OS_WIN32)
Gui::Command::doCommand(Gui::Command::Gui,"WebGui.openBrowserHTML"
"(StartPage.handle(),App.getResourceDir() + 'Mod/Start/StartPage/','Start page')");
"(StartPage.handle(),App.getResourceDir() + 'Mod/Start/StartPage/','%s')", utf8Title.data());
#else
Gui::Command::doCommand(Gui::Command::Gui,"WebGui.openBrowserHTML"
"(StartPage.handle(),'file://' + App.getResourceDir() + 'Mod/Start/StartPage/','Start page')");
"(StartPage.handle(),'file://' + App.getResourceDir() + 'Mod/Start/StartPage/','%s')", utf8Title.data());
#endif
}
catch (const Base::Exception& e) {

View File

@@ -91,26 +91,11 @@ private:
if (! PyArg_ParseTuple(args.ptr(), "ss|s",&HtmlCode,&BaseUrl,&TabName))
throw Py::Exception();
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);
}
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();
}