fixes #0002323: Workbench Start recent list of 3 files is - after a crash - not sync with recent list in File Menu Recent list of 4 files

This commit is contained in:
wmayer
2017-10-05 10:38:42 +02:00
parent ef11efce55
commit 67b990c2b5
6 changed files with 130 additions and 31 deletions

View File

@@ -25,6 +25,7 @@
#ifndef _PreComp_
# include <QCoreApplication>
# include <QTextStream>
#endif
#include "Workbench.h"
@@ -69,15 +70,39 @@ void StartGui::Workbench::activated()
try {
QByteArray utf8Title = title.toUtf8();
Gui::Command::doCommand(Gui::Command::Gui,"import WebGui");
Gui::Command::doCommand(Gui::Command::Gui,"from StartPage import StartPage");
QByteArray cmd;
QTextStream str(&cmd);
str << "import WebGui" << endl;
str << "from StartPage import StartPage" << endl;
str << endl;
str << "class WebPage(object):" << endl;
str << " def __init__(self):" << endl;
str << " self.browser=WebGui.openBrowserWindow('" << utf8Title << "')" << endl;
#if defined(FC_OS_WIN32)
Gui::Command::doCommand(Gui::Command::Gui,"WebGui.openBrowserHTML"
"(StartPage.handle(),App.getResourceDir() + 'Mod/Start/StartPage/','%s')", utf8Title.data());
str << " self.browser.setHtml(StartPage.handle(), App.getResourceDir() + 'Mod/Start/StartPage/')" << endl;
#else
Gui::Command::doCommand(Gui::Command::Gui,"WebGui.openBrowserHTML"
"(StartPage.handle(),'file://' + App.getResourceDir() + 'Mod/Start/StartPage/','%s')", utf8Title.data());
str << " self.browser.setHtml(StartPage.handle(), 'file://' + App.getResourceDir() + 'Mod/Start/StartPage/')" << endl;
#endif
str << " def onChange(self, par, reason):" << endl;
str << " if reason == 'RecentFiles':" << endl;
#if defined(FC_OS_WIN32)
str << " self.browser.setHtml(StartPage.handle(), App.getResourceDir() + 'Mod/Start/StartPage/')" << endl;
#else
str << " self.browser.setHtml(StartPage.handle(), 'file://' + App.getResourceDir() + 'Mod/Start/StartPage/')" << endl;
#endif
str << endl;
str << "class WebView(object):" << endl;
str << " def __init__(self):" << endl;
str << " self.pargrp = FreeCAD.ParamGet('User parameter:BaseApp/Preferences/RecentFiles')" << endl;
str << " self.webPage = WebPage()" << endl;
str << " self.pargrp.Attach(self.webPage)" << endl;
str << " def __del__(self):" << endl;
str << " self.pargrp.Detach(self.webPage)" << endl;
str << endl;
str << "webView=WebView()" << endl;
Gui::Command::runCommand(Gui::Command::Gui, cmd);
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());