Skip to content

Commit

Permalink
Start: [skip ci] replace QTextStream and its manipulators with string…
Browse files Browse the repository at this point in the history
…stream to avoid deprecation warnings with Qt 5.15
  • Loading branch information
wwmayer committed Sep 24, 2020
1 parent 3e3006d commit a3cd010
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions src/Mod/Start/Gui/Workbench.cpp
Expand Up @@ -25,7 +25,6 @@

#ifndef _PreComp_
# include <QCoreApplication>
# include <QTextStream>
#endif

#include "Workbench.h"
Expand Down Expand Up @@ -83,39 +82,38 @@ void StartGui::Workbench::loadStartPage()
try {
QByteArray utf8Title = title.toUtf8();
std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(utf8Title);
QByteArray cmd;
QTextStream str(&cmd);
str << "import WebGui,sys,Start" << endl;
str << "from StartPage import StartPage" << endl;
str << endl;
str << "class WebPage(object):" << endl;
str << " def __init__(self):" << endl;
str << " self.browser=WebGui.openBrowserWindow(u'" << escapedstr.c_str() << "')" << endl;
std::stringstream str;
str << "import WebGui,sys,Start" << std::endl;
str << "from StartPage import StartPage" << std::endl;
str << std::endl;
str << "class WebPage(object):" << std::endl;
str << " def __init__(self):" << std::endl;
str << " self.browser=WebGui.openBrowserWindow(u'" << escapedstr.c_str() << "')" << std::endl;
#if defined(FC_OS_WIN32)
str << " self.browser.setHtml(StartPage.handle(), App.getResourceDir() + 'Mod/Start/StartPage/')" << endl;
str << " self.browser.setHtml(StartPage.handle(), App.getResourceDir() + 'Mod/Start/StartPage/')" << std::endl;
#else
str << " self.browser.setHtml(StartPage.handle(), 'file://' + App.getResourceDir() + 'Mod/Start/StartPage/')" << endl;
str << " self.browser.setHtml(StartPage.handle(), 'file://' + App.getResourceDir() + 'Mod/Start/StartPage/')" << std::endl;
#endif
str << " def onChange(self, par, reason):" << endl;
str << " if reason == 'RecentFiles':" << endl;
str << " def onChange(self, par, reason):" << std::endl;
str << " if reason == 'RecentFiles':" << std::endl;
#if defined(FC_OS_WIN32)
str << " self.browser.setHtml(StartPage.handle(), App.getResourceDir() + 'Mod/Start/StartPage/')" << endl;
str << " self.browser.setHtml(StartPage.handle(), App.getResourceDir() + 'Mod/Start/StartPage/')" << std::endl;
#else
str << " self.browser.setHtml(StartPage.handle(), 'file://' + App.getResourceDir() + 'Mod/Start/StartPage/')" << endl;
str << " self.browser.setHtml(StartPage.handle(), 'file://' + App.getResourceDir() + 'Mod/Start/StartPage/')" << std::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;
str << "StartPage.checkPostOpenStartPage()" << endl;

Base::Interpreter().runString(cmd);
str << std::endl;
str << "class WebView(object):" << std::endl;
str << " def __init__(self):" << std::endl;
str << " self.pargrp = FreeCAD.ParamGet('User parameter:BaseApp/Preferences/RecentFiles')" << std::endl;
str << " self.webPage = WebPage()" << std::endl;
str << " self.pargrp.Attach(self.webPage)" << std::endl;
str << " def __del__(self):" << std::endl;
str << " self.pargrp.Detach(self.webPage)" << std::endl;
str << std::endl;
str << "webView=WebView()" << std::endl;
str << "StartPage.checkPostOpenStartPage()" << std::endl;

Base::Interpreter().runString(str.str().c_str());
// Gui::Command::runCommand(Gui::Command::Gui, cmd);
}
catch (const Base::Exception& e) {
Expand Down

0 comments on commit a3cd010

Please sign in to comment.