Web: apply clang format
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <sstream>
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
@@ -58,34 +58,37 @@ client(ip, port, b"import FreeCAD\nFreeCAD.newDocument()")
|
||||
|
||||
*/
|
||||
|
||||
namespace Web {
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
namespace Web
|
||||
{
|
||||
class Module: public Py::ExtensionModule<Module>
|
||||
{
|
||||
public:
|
||||
Module() : Py::ExtensionModule<Module>("Web")
|
||||
Module()
|
||||
: Py::ExtensionModule<Module>("Web")
|
||||
{
|
||||
add_varargs_method("startServer",&Module::startServer,
|
||||
"startServer(address=127.0.0.1,port=0) -- Start a server."
|
||||
);
|
||||
add_varargs_method("waitForConnection", &Module::waitForConnection,
|
||||
"waitForConnection(address=127.0.0.1,port=0,timeout=0)\n"
|
||||
"Start a server, wait for connection and close server.\n"
|
||||
"Its use is disadvised in a the GUI version, since it will\n"
|
||||
"stop responding until the function returns."
|
||||
);
|
||||
add_varargs_method("registerServerFirewall", &Module::registerServerFirewall,
|
||||
"registerServerFirewall(callable(string)) -- Register a firewall."
|
||||
);
|
||||
initialize("This module is the Web module."); // register with Python
|
||||
add_varargs_method("startServer",
|
||||
&Module::startServer,
|
||||
"startServer(address=127.0.0.1,port=0) -- Start a server.");
|
||||
add_varargs_method("waitForConnection",
|
||||
&Module::waitForConnection,
|
||||
"waitForConnection(address=127.0.0.1,port=0,timeout=0)\n"
|
||||
"Start a server, wait for connection and close server.\n"
|
||||
"Its use is disadvised in a the GUI version, since it will\n"
|
||||
"stop responding until the function returns.");
|
||||
add_varargs_method("registerServerFirewall",
|
||||
&Module::registerServerFirewall,
|
||||
"registerServerFirewall(callable(string)) -- Register a firewall.");
|
||||
initialize("This module is the Web module.");// register with Python
|
||||
}
|
||||
|
||||
private:
|
||||
Py::Object startServer(const Py::Tuple& args)
|
||||
{
|
||||
const char* addr = "127.0.0.1";
|
||||
int port=0;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "|si", &addr, &port))
|
||||
int port = 0;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "|si", &addr, &port)) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
if (port > USHRT_MAX) {
|
||||
throw Py::OverflowError("port number is greater than maximum");
|
||||
}
|
||||
@@ -115,8 +118,9 @@ private:
|
||||
const char* addr = "127.0.0.1";
|
||||
int port = 0;
|
||||
int timeout = 0;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "|sii",&addr,&port, &timeout))
|
||||
if (!PyArg_ParseTuple(args.ptr(), "|sii", &addr, &port, &timeout)) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
if (port > USHRT_MAX) {
|
||||
throw Py::OverflowError("port number is greater than maximum");
|
||||
}
|
||||
@@ -150,14 +154,17 @@ private:
|
||||
Py::Object registerServerFirewall(const Py::Tuple& args)
|
||||
{
|
||||
PyObject* obj;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "O",&obj))
|
||||
if (!PyArg_ParseTuple(args.ptr(), "O", &obj)) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
Py::Object pyobj(obj);
|
||||
if (pyobj.isNone())
|
||||
if (pyobj.isNone()) {
|
||||
Web::Firewall::setInstance(nullptr);
|
||||
else
|
||||
}
|
||||
else {
|
||||
Web::Firewall::setInstance(new Web::FirewallPython(pyobj));
|
||||
}
|
||||
|
||||
return Py::None();
|
||||
}
|
||||
@@ -168,11 +175,12 @@ PyObject* initModule()
|
||||
return Base::Interpreter().addModule(new Module);
|
||||
}
|
||||
|
||||
} // namespace Web
|
||||
}// namespace Web
|
||||
|
||||
|
||||
/* Python entry */
|
||||
PyMOD_INIT_FUNC(Web) {
|
||||
PyMOD_INIT_FUNC(Web)
|
||||
{
|
||||
|
||||
// ADD YOUR CODE HERE
|
||||
//
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QTcpSocket>
|
||||
|
||||
#endif //_PreComp_
|
||||
#endif//_PreComp_
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <memory>
|
||||
# include <stdexcept>
|
||||
# include <QCoreApplication>
|
||||
# include <QTcpSocket>
|
||||
#include <QCoreApplication>
|
||||
#include <QTcpSocket>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#endif
|
||||
|
||||
#include <Base/Exception.h>
|
||||
@@ -61,9 +61,8 @@ bool Firewall::filter(const QByteArray&) const
|
||||
}
|
||||
|
||||
FirewallPython::FirewallPython(const Py::Object& o)
|
||||
: obj(o)
|
||||
{
|
||||
}
|
||||
: obj(o)
|
||||
{}
|
||||
|
||||
FirewallPython::~FirewallPython() = default;
|
||||
|
||||
@@ -86,9 +85,10 @@ bool FirewallPython::filter(const QByteArray& msg) const
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
ServerEvent::ServerEvent(QTcpSocket* sock, const QByteArray& msg)
|
||||
: QEvent(QEvent::User), sock(sock), text(msg)
|
||||
{
|
||||
}
|
||||
: QEvent(QEvent::User)
|
||||
, sock(sock)
|
||||
, text(msg)
|
||||
{}
|
||||
|
||||
ServerEvent::~ServerEvent() = default;
|
||||
|
||||
@@ -104,9 +104,9 @@ const QByteArray& ServerEvent::request() const
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
AppServer::AppServer( bool direct, QObject* parent)
|
||||
: QTcpServer(parent)
|
||||
, direct(direct)
|
||||
AppServer::AppServer(bool direct, QObject* parent)
|
||||
: QTcpServer(parent)
|
||||
, direct(direct)
|
||||
{
|
||||
PyObject* mod = PyImport_ImportModule("__main__");
|
||||
if (mod) {
|
||||
@@ -139,10 +139,10 @@ void AppServer::readClient()
|
||||
QCoreApplication::postEvent(this, event.release());
|
||||
}
|
||||
}
|
||||
// if (socket->state() == QTcpSocket::UnconnectedState) {
|
||||
// //mark the socket for deletion but do not destroy immediately
|
||||
// socket->deleteLater();
|
||||
// }
|
||||
// if (socket->state() == QTcpSocket::UnconnectedState) {
|
||||
// //mark the socket for deletion but do not destroy immediately
|
||||
// socket->deleteLater();
|
||||
// }
|
||||
}
|
||||
|
||||
void AppServer::discardClient()
|
||||
@@ -159,8 +159,9 @@ void AppServer::customEvent(QEvent* e)
|
||||
|
||||
std::string str = handleRequest(msg);
|
||||
socket->write(str.c_str());
|
||||
if (direct)
|
||||
if (direct) {
|
||||
socket->waitForBytesWritten();
|
||||
}
|
||||
socket->close();
|
||||
}
|
||||
|
||||
@@ -188,7 +189,7 @@ std::string AppServer::getRequest(const std::string& str) const
|
||||
Py::Object attr = module.getAttr(std::string("GET"));
|
||||
return attr.as_string();
|
||||
}
|
||||
catch (Py::Exception &e) {
|
||||
catch (Py::Exception& e) {
|
||||
e.clear();
|
||||
return str;
|
||||
}
|
||||
@@ -200,23 +201,25 @@ std::string AppServer::runPython(const QByteArray& msg)
|
||||
|
||||
try {
|
||||
Firewall* fw = Firewall::getInstance();
|
||||
if (!fw || fw->filter(msg))
|
||||
if (!fw || fw->filter(msg)) {
|
||||
str = Base::Interpreter().runString(msg);
|
||||
else
|
||||
}
|
||||
else {
|
||||
str = "Command blocked";
|
||||
}
|
||||
}
|
||||
catch (Base::PyException &e) {
|
||||
catch (Base::PyException& e) {
|
||||
str = e.what();
|
||||
str += "\n\n";
|
||||
str += e.getStackTrace();
|
||||
}
|
||||
catch (Base::SystemExitException &) {
|
||||
catch (Base::SystemExitException&) {
|
||||
throw;
|
||||
}
|
||||
catch (Base::Exception &e) {
|
||||
catch (Base::Exception& e) {
|
||||
str = e.what();
|
||||
}
|
||||
catch (std::exception &e) {
|
||||
catch (std::exception& e) {
|
||||
str = e.what();
|
||||
}
|
||||
catch (...) {
|
||||
|
||||
@@ -26,11 +26,12 @@
|
||||
#include <QByteArray>
|
||||
#include <QEvent>
|
||||
#include <QObject>
|
||||
#include <QTcpSocket>
|
||||
#include <QTcpServer>
|
||||
#include <QTcpSocket>
|
||||
|
||||
|
||||
namespace Web {
|
||||
namespace Web
|
||||
{
|
||||
|
||||
class Firewall
|
||||
{
|
||||
@@ -47,7 +48,7 @@ private:
|
||||
static Firewall* instance;
|
||||
};
|
||||
|
||||
class FirewallPython : public Firewall
|
||||
class FirewallPython: public Firewall
|
||||
{
|
||||
public:
|
||||
explicit FirewallPython(const Py::Object&);
|
||||
@@ -58,7 +59,7 @@ private:
|
||||
Py::Object obj;
|
||||
};
|
||||
|
||||
class ServerEvent : public QEvent
|
||||
class ServerEvent: public QEvent
|
||||
{
|
||||
public:
|
||||
ServerEvent(QTcpSocket* socket, const QByteArray&);
|
||||
@@ -75,7 +76,7 @@ private:
|
||||
/**
|
||||
* The Server class implements a simple TCP server.
|
||||
*/
|
||||
class AppServer : public QTcpServer
|
||||
class AppServer: public QTcpServer
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -100,6 +101,6 @@ private:
|
||||
Py::Object module;
|
||||
};
|
||||
|
||||
}
|
||||
}// namespace Web
|
||||
|
||||
#endif //Web_SERVER_H
|
||||
#endif// Web_SERVER_H
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <string>
|
||||
# include <QAbstractNativeEventFilter>
|
||||
# include <QApplication>
|
||||
# include <QIcon>
|
||||
# include <QUrl>
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <QApplication>
|
||||
#include <QIcon>
|
||||
#include <QUrl>
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
@@ -37,8 +37,8 @@
|
||||
#include <Base/Interpreter.h>
|
||||
#include <Base/PyObjectBase.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/Language/Translator.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
|
||||
#include "BrowserView.h"
|
||||
#include "Workbench.h"
|
||||
@@ -55,35 +55,35 @@ void loadWebResource()
|
||||
Gui::Translator::instance()->refresh();
|
||||
}
|
||||
|
||||
namespace WebGui {
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
namespace WebGui
|
||||
{
|
||||
class Module: public Py::ExtensionModule<Module>
|
||||
{
|
||||
public:
|
||||
Module() : Py::ExtensionModule<Module>("WebGui")
|
||||
Module()
|
||||
: Py::ExtensionModule<Module>("WebGui")
|
||||
{
|
||||
add_varargs_method("openBrowser",&Module::openBrowser
|
||||
);
|
||||
add_varargs_method("openBrowserHTML",&Module::openBrowserHTML
|
||||
);
|
||||
add_varargs_method("openBrowserWindow",&Module::openBrowserWindow
|
||||
);
|
||||
add_varargs_method("open",&Module::openBrowser,
|
||||
"open(htmlcode,baseurl,[title,iconpath])\n"
|
||||
"Load a local (X)HTML file."
|
||||
);
|
||||
add_varargs_method("insert",&Module::openBrowser,
|
||||
"insert(string)\n"
|
||||
"Load a local (X)HTML file."
|
||||
);
|
||||
initialize("This module is the WebGui module."); // register with Python
|
||||
add_varargs_method("openBrowser", &Module::openBrowser);
|
||||
add_varargs_method("openBrowserHTML", &Module::openBrowserHTML);
|
||||
add_varargs_method("openBrowserWindow", &Module::openBrowserWindow);
|
||||
add_varargs_method("open",
|
||||
&Module::openBrowser,
|
||||
"open(htmlcode,baseurl,[title,iconpath])\n"
|
||||
"Load a local (X)HTML file.");
|
||||
add_varargs_method("insert",
|
||||
&Module::openBrowser,
|
||||
"insert(string)\n"
|
||||
"Load a local (X)HTML file.");
|
||||
initialize("This module is the WebGui module.");// register with Python
|
||||
}
|
||||
|
||||
private:
|
||||
Py::Object openBrowser(const Py::Tuple& args)
|
||||
{
|
||||
const char* url;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "s",&url))
|
||||
if (!PyArg_ParseTuple(args.ptr(), "s", &url)) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
WebGui::BrowserView* pcBrowserView;
|
||||
|
||||
@@ -92,8 +92,9 @@ private:
|
||||
pcBrowserView->resize(400, 300);
|
||||
pcBrowserView->load(url);
|
||||
Gui::getMainWindow()->addWindow(pcBrowserView);
|
||||
if (!Gui::getMainWindow()->activeWindow())
|
||||
if (!Gui::getMainWindow()->activeWindow()) {
|
||||
Gui::getMainWindow()->setActiveWindow(pcBrowserView);
|
||||
}
|
||||
|
||||
return Py::None();
|
||||
}
|
||||
@@ -104,8 +105,15 @@ private:
|
||||
const char* BaseUrl;
|
||||
const char* IconPath;
|
||||
char* TabName = nullptr;
|
||||
if (! PyArg_ParseTuple(args.ptr(), "ss|ets", &HtmlCode, &BaseUrl, "utf-8", &TabName, &IconPath))
|
||||
if (!PyArg_ParseTuple(args.ptr(),
|
||||
"ss|ets",
|
||||
&HtmlCode,
|
||||
&BaseUrl,
|
||||
"utf-8",
|
||||
&TabName,
|
||||
&IconPath)) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
std::string EncodedName = "Browser";
|
||||
if (TabName) {
|
||||
@@ -116,13 +124,15 @@ private:
|
||||
WebGui::BrowserView* pcBrowserView = nullptr;
|
||||
pcBrowserView = new WebGui::BrowserView(Gui::getMainWindow());
|
||||
pcBrowserView->resize(400, 300);
|
||||
pcBrowserView->setHtml(QString::fromUtf8(HtmlCode),QUrl(QString::fromLatin1(BaseUrl)));
|
||||
pcBrowserView->setHtml(QString::fromUtf8(HtmlCode), QUrl(QString::fromLatin1(BaseUrl)));
|
||||
pcBrowserView->setWindowTitle(QString::fromUtf8(EncodedName.c_str()));
|
||||
if (IconPath)
|
||||
if (IconPath) {
|
||||
pcBrowserView->setWindowIcon(QIcon(QString::fromUtf8(IconPath)));
|
||||
}
|
||||
Gui::getMainWindow()->addWindow(pcBrowserView);
|
||||
if (!Gui::getMainWindow()->activeWindow())
|
||||
if (!Gui::getMainWindow()->activeWindow()) {
|
||||
Gui::getMainWindow()->setActiveWindow(pcBrowserView);
|
||||
}
|
||||
|
||||
return Py::None();
|
||||
}
|
||||
@@ -130,8 +140,9 @@ private:
|
||||
Py::Object openBrowserWindow(const Py::Tuple& args)
|
||||
{
|
||||
char* TabName = nullptr;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "|et", "utf-8", &TabName))
|
||||
if (!PyArg_ParseTuple(args.ptr(), "|et", "utf-8", &TabName)) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
std::string EncodedName = "Browser";
|
||||
if (TabName) {
|
||||
@@ -144,8 +155,9 @@ private:
|
||||
pcBrowserView->resize(400, 300);
|
||||
pcBrowserView->setWindowTitle(QString::fromUtf8(EncodedName.c_str()));
|
||||
Gui::getMainWindow()->addWindow(pcBrowserView);
|
||||
if (!Gui::getMainWindow()->activeWindow())
|
||||
if (!Gui::getMainWindow()->activeWindow()) {
|
||||
Gui::getMainWindow()->setActiveWindow(pcBrowserView);
|
||||
}
|
||||
|
||||
return Py::asObject(pcBrowserView->getPyObject());
|
||||
}
|
||||
@@ -156,7 +168,7 @@ PyObject* initModule()
|
||||
return Base::Interpreter().addModule(new Module);
|
||||
}
|
||||
|
||||
class NativeEventFilter : public QAbstractNativeEventFilter
|
||||
class NativeEventFilter: public QAbstractNativeEventFilter
|
||||
{
|
||||
public:
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
@@ -182,7 +194,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace WebGui
|
||||
}// namespace WebGui
|
||||
|
||||
|
||||
/* Python entry */
|
||||
@@ -205,7 +217,7 @@ PyMOD_INIT_FUNC(WebGui)
|
||||
qApp->installNativeEventFilter(new WebGui::NativeEventFilter);
|
||||
#endif
|
||||
|
||||
// add resources and reloads the translators
|
||||
// add resources and reloads the translators
|
||||
loadWebResource();
|
||||
|
||||
PyMOD_Return(mod);
|
||||
|
||||
@@ -22,53 +22,53 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <vector>
|
||||
#include <vector>
|
||||
|
||||
# include <QApplication>
|
||||
# include <QDesktopServices>
|
||||
# include <QFileInfo>
|
||||
# include <QLatin1String>
|
||||
# include <QLineEdit>
|
||||
# include <QMenu>
|
||||
# include <QMessageBox>
|
||||
# include <QMouseEvent>
|
||||
# include <QNetworkRequest>
|
||||
# include <QRegularExpression>
|
||||
# include <QRegularExpressionMatch>
|
||||
# include <QSignalMapper>
|
||||
# include <QStatusBar>
|
||||
#include <QApplication>
|
||||
#include <QDesktopServices>
|
||||
#include <QFileInfo>
|
||||
#include <QLatin1String>
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QMouseEvent>
|
||||
#include <QNetworkRequest>
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionMatch>
|
||||
#include <QSignalMapper>
|
||||
#include <QStatusBar>
|
||||
#endif
|
||||
|
||||
#if defined(QTWEBENGINE)
|
||||
# if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
||||
# include <QWebEngineContextMenuData>
|
||||
# else
|
||||
# include <QWebEngineContextMenuRequest>
|
||||
# endif
|
||||
# include <QWebEnginePage>
|
||||
# include <QWebEngineProfile>
|
||||
# include <QWebEngineSettings>
|
||||
# include <QWebEngineUrlRequestInfo>
|
||||
# include <QWebEngineUrlRequestInterceptor>
|
||||
# include <QWebEngineView>
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QWebEngineContextMenuData>
|
||||
#else
|
||||
#include <QWebEngineContextMenuRequest>
|
||||
#endif
|
||||
#include <QWebEnginePage>
|
||||
#include <QWebEngineProfile>
|
||||
#include <QWebEngineSettings>
|
||||
#include <QWebEngineUrlRequestInfo>
|
||||
#include <QWebEngineUrlRequestInterceptor>
|
||||
#include <QWebEngineView>
|
||||
#elif defined(QTWEBKIT)
|
||||
# include <QWebFrame>
|
||||
# include <QNetworkAccessManager>
|
||||
# include <QWebSettings>
|
||||
# include <QWebView>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QWebFrame>
|
||||
#include <QWebSettings>
|
||||
#include <QWebView>
|
||||
using QWebEngineView = QWebView;
|
||||
using QWebEnginePage = QWebPage;
|
||||
#endif
|
||||
|
||||
#include <App/Document.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/DownloadManager.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/MDIViewPy.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/ProgressBar.h>
|
||||
#include <Gui/TextDocumentEditorView.h>
|
||||
|
||||
@@ -79,35 +79,38 @@ using QWebEnginePage = QWebPage;
|
||||
using namespace WebGui;
|
||||
using namespace Gui;
|
||||
|
||||
namespace WebGui {
|
||||
enum WebAction {
|
||||
namespace WebGui
|
||||
{
|
||||
enum WebAction
|
||||
{
|
||||
OpenLink = 0,
|
||||
OpenLinkInNewWindow = 1,
|
||||
ViewSource = 2 // QWebView doesn't have a ViewSource option
|
||||
ViewSource = 2// QWebView doesn't have a ViewSource option
|
||||
};
|
||||
|
||||
#ifdef QTWEBENGINE
|
||||
class WebEngineUrlRequestInterceptor : public QWebEngineUrlRequestInterceptor
|
||||
class WebEngineUrlRequestInterceptor: public QWebEngineUrlRequestInterceptor
|
||||
{
|
||||
public:
|
||||
explicit WebEngineUrlRequestInterceptor(BrowserView *parent) :
|
||||
QWebEngineUrlRequestInterceptor(parent),
|
||||
m_parent(parent)
|
||||
{
|
||||
}
|
||||
explicit WebEngineUrlRequestInterceptor(BrowserView* parent)
|
||||
: QWebEngineUrlRequestInterceptor(parent)
|
||||
, m_parent(parent)
|
||||
{}
|
||||
|
||||
void interceptRequest(QWebEngineUrlRequestInfo &info) override
|
||||
void interceptRequest(QWebEngineUrlRequestInfo& info) override
|
||||
{
|
||||
// do something with this resource, click or get img for example
|
||||
if (info.navigationType() == QWebEngineUrlRequestInfo::NavigationTypeLink) {
|
||||
// wash out windows file:///C:/something ->file://C:/something
|
||||
QUrl url = info.requestUrl();
|
||||
QRegularExpression re(QLatin1String("^/([a-zA-Z]\\:.*)")); // match & catch drive letter forward
|
||||
// match & catch drive letter forward
|
||||
QRegularExpression re(QLatin1String("^/([a-zA-Z]\\:.*)"));
|
||||
QRegularExpressionMatch match = re.match(url.path());
|
||||
|
||||
if (url.host().isEmpty() && url.isLocalFile() && match.hasMatch())
|
||||
if (url.host().isEmpty() && url.isLocalFile() && match.hasMatch()) {
|
||||
// clip / in file urs ie /C:/something -> C:/something
|
||||
url.setPath(match.captured(1));
|
||||
}
|
||||
|
||||
// invoke thread safe.
|
||||
QMetaObject::invokeMethod(m_parent, "urlFilter", Q_ARG(QUrl, url));
|
||||
@@ -115,13 +118,14 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
BrowserView *m_parent;
|
||||
BrowserView* m_parent;
|
||||
};
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
UrlWidget::UrlWidget(BrowserView *view) :
|
||||
QLineEdit(view), m_view(view)
|
||||
UrlWidget::UrlWidget(BrowserView* view)
|
||||
: QLineEdit(view)
|
||||
, m_view(view)
|
||||
{
|
||||
setText(QLatin1String("https://"));
|
||||
hide();
|
||||
@@ -129,19 +133,19 @@ UrlWidget::UrlWidget(BrowserView *view) :
|
||||
|
||||
UrlWidget::~UrlWidget() = default;
|
||||
|
||||
void UrlWidget::keyPressEvent(QKeyEvent *keyEvt)
|
||||
void UrlWidget::keyPressEvent(QKeyEvent* keyEvt)
|
||||
{
|
||||
switch (keyEvt->key()) {
|
||||
case Qt::Key_Escape:
|
||||
hide();
|
||||
break;
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Enter:
|
||||
m_view->load(text().toLatin1());
|
||||
hide();
|
||||
break;
|
||||
default:
|
||||
QLineEdit::keyPressEvent(keyEvt);
|
||||
case Qt::Key_Escape:
|
||||
hide();
|
||||
break;
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Enter:
|
||||
m_view->load(text().toLatin1());
|
||||
hide();
|
||||
break;
|
||||
default:
|
||||
QLineEdit::keyPressEvent(keyEvt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,17 +159,17 @@ void UrlWidget::display()
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
class BrowserViewPy : public Py::PythonExtension<BrowserViewPy>
|
||||
class BrowserViewPy: public Py::PythonExtension<BrowserViewPy>
|
||||
{
|
||||
public:
|
||||
using BaseType = Py::PythonExtension<BrowserViewPy>;
|
||||
static void init_type(); // announce properties and methods
|
||||
static void init_type();// announce properties and methods
|
||||
|
||||
explicit BrowserViewPy(BrowserView* view);
|
||||
~BrowserViewPy() override;
|
||||
|
||||
Py::Object repr() override;
|
||||
Py::Object getattr(const char *) override;
|
||||
Py::Object getattr(const char*) override;
|
||||
Py::Object cast_to_base(const Py::Tuple&);
|
||||
|
||||
Py::Object setHtml(const Py::Tuple&);
|
||||
@@ -189,16 +193,18 @@ void BrowserViewPy::init_type()
|
||||
behaviors().supportSetattr();
|
||||
behaviors().readyType();
|
||||
|
||||
add_varargs_method("setHtml",&BrowserViewPy::setHtml,"setHtml(str)");
|
||||
add_varargs_method("load",&BrowserViewPy::load,"load(url)");
|
||||
add_varargs_method("stop",&BrowserViewPy::stop,"stop()");
|
||||
add_varargs_method("url",&BrowserViewPy::url,"url()");
|
||||
add_varargs_method("cast_to_base", &BrowserViewPy::cast_to_base, "cast_to_base() cast to MDIView class");
|
||||
add_varargs_method("setHtml", &BrowserViewPy::setHtml, "setHtml(str)");
|
||||
add_varargs_method("load", &BrowserViewPy::load, "load(url)");
|
||||
add_varargs_method("stop", &BrowserViewPy::stop, "stop()");
|
||||
add_varargs_method("url", &BrowserViewPy::url, "url()");
|
||||
add_varargs_method("cast_to_base",
|
||||
&BrowserViewPy::cast_to_base,
|
||||
"cast_to_base() cast to MDIView class");
|
||||
}
|
||||
|
||||
BrowserViewPy::BrowserViewPy(BrowserView* view) : base(view)
|
||||
{
|
||||
}
|
||||
BrowserViewPy::BrowserViewPy(BrowserView* view)
|
||||
: base(view)
|
||||
{}
|
||||
|
||||
BrowserViewPy::~BrowserViewPy() = default;
|
||||
|
||||
@@ -223,14 +229,14 @@ Py::Object BrowserViewPy::repr()
|
||||
// a trick is to use MDIViewPy as class member and override getattr() to
|
||||
// join the attributes of both classes. This way all methods of MDIViewPy
|
||||
// appear for SheetViewPy, too.
|
||||
Py::Object BrowserViewPy::getattr(const char * attr)
|
||||
Py::Object BrowserViewPy::getattr(const char* attr)
|
||||
{
|
||||
if (!getBrowserViewPtr()) {
|
||||
std::ostringstream s_out;
|
||||
s_out << "Cannot access attribute '" << attr << "' of deleted object";
|
||||
throw Py::RuntimeError(s_out.str());
|
||||
}
|
||||
std::string name( attr );
|
||||
std::string name(attr);
|
||||
if (name == "__dict__" || name == "__class__") {
|
||||
Py::Dict dict_self(BaseType::getattr("__dict__"));
|
||||
Py::Dict dict_base(base.getattr("__dict__"));
|
||||
@@ -253,21 +259,24 @@ Py::Object BrowserViewPy::setHtml(const Py::Tuple& args)
|
||||
{
|
||||
char* HtmlCode;
|
||||
char* BaseUrl;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "et|s","utf-8",&HtmlCode,&BaseUrl))
|
||||
if (!PyArg_ParseTuple(args.ptr(), "et|s", "utf-8", &HtmlCode, &BaseUrl)) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
std::string EncodedHtml = std::string(HtmlCode);
|
||||
PyMem_Free(HtmlCode);
|
||||
|
||||
getBrowserViewPtr()->setHtml(QString::fromUtf8(EncodedHtml.c_str()), QUrl(QString::fromUtf8(BaseUrl)));
|
||||
getBrowserViewPtr()->setHtml(QString::fromUtf8(EncodedHtml.c_str()),
|
||||
QUrl(QString::fromUtf8(BaseUrl)));
|
||||
return Py::None();
|
||||
}
|
||||
|
||||
Py::Object BrowserViewPy::load(const Py::Tuple& args)
|
||||
{
|
||||
char* BaseUrl;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "s", &BaseUrl))
|
||||
if (!PyArg_ParseTuple(args.ptr(), "s", &BaseUrl)) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
getBrowserViewPtr()->load(BaseUrl);
|
||||
return Py::None();
|
||||
@@ -275,8 +284,9 @@ Py::Object BrowserViewPy::load(const Py::Tuple& args)
|
||||
|
||||
Py::Object BrowserViewPy::stop(const Py::Tuple& args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||
if (!PyArg_ParseTuple(args.ptr(), "")) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
getBrowserViewPtr()->stop();
|
||||
return Py::None();
|
||||
@@ -284,33 +294,34 @@ Py::Object BrowserViewPy::stop(const Py::Tuple& args)
|
||||
|
||||
Py::Object BrowserViewPy::url(const Py::Tuple& args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||
if (!PyArg_ParseTuple(args.ptr(), "")) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
QUrl url = getBrowserViewPtr()->url();
|
||||
return Py::String(url.toString().toStdString());
|
||||
}
|
||||
|
||||
}
|
||||
}// namespace WebGui
|
||||
|
||||
/**
|
||||
* Constructs a WebView widget which can be zoomed with Ctrl+Mousewheel
|
||||
*
|
||||
*/
|
||||
|
||||
WebView::WebView(QWidget *parent)
|
||||
WebView::WebView(QWidget* parent)
|
||||
: QWebEngineView(parent)
|
||||
{
|
||||
#ifdef QTWEBKIT
|
||||
// Increase html font size for high DPI displays
|
||||
QRect mainScreenSize = QApplication::primaryScreen()->geometry();
|
||||
if (mainScreenSize.width() > 1920){
|
||||
setTextSizeMultiplier (mainScreenSize.width()/1920.0);
|
||||
if (mainScreenSize.width() > 1920) {
|
||||
setTextSizeMultiplier(mainScreenSize.width() / 1920.0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void WebView::mousePressEvent(QMouseEvent *event)
|
||||
void WebView::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
#ifdef QTWEBKIT
|
||||
if (event->button() == Qt::MiddleButton) {
|
||||
@@ -324,7 +335,7 @@ void WebView::mousePressEvent(QMouseEvent *event)
|
||||
QWebEngineView::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void WebView::wheelEvent(QWheelEvent *event)
|
||||
void WebView::wheelEvent(QWheelEvent* event)
|
||||
{
|
||||
if (QApplication::keyboardModifiers() & Qt::ControlModifier) {
|
||||
qreal factor = zoomFactor() + (-event->angleDelta().y() / 800.0);
|
||||
@@ -335,16 +346,16 @@ void WebView::wheelEvent(QWheelEvent *event)
|
||||
QWebEngineView::wheelEvent(event);
|
||||
}
|
||||
|
||||
void WebView::contextMenuEvent(QContextMenuEvent *event)
|
||||
void WebView::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
#ifdef QTWEBENGINE
|
||||
# if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
const QWebEngineContextMenuData r = page()->contextMenuData();
|
||||
QUrl linkUrl = r.linkUrl();
|
||||
# else
|
||||
#else
|
||||
const QWebEngineContextMenuRequest* r = this->lastContextMenuRequest();
|
||||
QUrl linkUrl = r->linkUrl();
|
||||
# endif
|
||||
#endif
|
||||
#else
|
||||
QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());
|
||||
QUrl linkUrl = r.linkUrl();
|
||||
@@ -353,7 +364,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
|
||||
QMenu menu(this);
|
||||
|
||||
// building a custom signal for external browser action
|
||||
QSignalMapper* signalMapper = new QSignalMapper (&menu);
|
||||
QSignalMapper* signalMapper = new QSignalMapper(&menu);
|
||||
signalMapper->setProperty("url", QVariant(linkUrl));
|
||||
|
||||
QAction* extAction = menu.addAction(tr("Open in External Browser"));
|
||||
@@ -362,8 +373,11 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
|
||||
QAction* newAction = menu.addAction(tr("Open in new window"));
|
||||
signalMapper->setMapping(newAction, WebAction::OpenLinkInNewWindow);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5,15,0)
|
||||
connect(signalMapper, qOverload<int>(&QSignalMapper::mapped), this, &WebView::triggerContextMenuAction);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
connect(signalMapper,
|
||||
qOverload<int>(&QSignalMapper::mapped),
|
||||
this,
|
||||
&WebView::triggerContextMenuAction);
|
||||
#else
|
||||
connect(signalMapper, &QSignalMapper::mappedInt, this, &WebView::triggerContextMenuAction);
|
||||
#endif
|
||||
@@ -376,43 +390,51 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
|
||||
return;
|
||||
}
|
||||
#if defined(QTWEBENGINE)
|
||||
else { // for view source
|
||||
else {// for view source
|
||||
// QWebEngine caches standardContextMenu, guard so we only add signalmapper once
|
||||
static bool firstRun = true;
|
||||
if (firstRun) {
|
||||
firstRun = false;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
||||
QMenu *menu = page()->createStandardContextMenu();
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QMenu* menu = page()->createStandardContextMenu();
|
||||
#else
|
||||
QMenu *menu = this->createStandardContextMenu();
|
||||
QMenu* menu = this->createStandardContextMenu();
|
||||
#endif
|
||||
QList<QAction *> actions = menu->actions();
|
||||
for(QAction *ac : actions) {
|
||||
QList<QAction*> actions = menu->actions();
|
||||
for (QAction* ac : actions) {
|
||||
if (ac->data().toInt() == WebAction::ViewSource) {
|
||||
QSignalMapper* signalMapper = new QSignalMapper (this);
|
||||
QSignalMapper* signalMapper = new QSignalMapper(this);
|
||||
signalMapper->setProperty("url", QVariant(linkUrl));
|
||||
signalMapper->setMapping(ac, WebAction::ViewSource);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5,15,0)
|
||||
connect(signalMapper, qOverload<int>(&QSignalMapper::mapped), this, &WebView::triggerContextMenuAction);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
connect(signalMapper,
|
||||
qOverload<int>(&QSignalMapper::mapped),
|
||||
this,
|
||||
&WebView::triggerContextMenuAction);
|
||||
#else
|
||||
connect(signalMapper, &QSignalMapper::mappedInt, this, &WebView::triggerContextMenuAction);
|
||||
connect(signalMapper,
|
||||
&QSignalMapper::mappedInt,
|
||||
this,
|
||||
&WebView::triggerContextMenuAction);
|
||||
#endif
|
||||
connect(ac, &QAction::triggered, signalMapper, qOverload<>(&QSignalMapper::map));
|
||||
connect(ac,
|
||||
&QAction::triggered,
|
||||
signalMapper,
|
||||
qOverload<>(&QSignalMapper::map));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
else {
|
||||
QMenu *menu = page()->createStandardContextMenu();
|
||||
QAction *ac = menu->addAction(tr("View source"));
|
||||
QMenu* menu = page()->createStandardContextMenu();
|
||||
QAction* ac = menu->addAction(tr("View source"));
|
||||
ac->setData(WebAction::ViewSource);
|
||||
QSignalMapper* signalMapper = new QSignalMapper (this);
|
||||
QSignalMapper* signalMapper = new QSignalMapper(this);
|
||||
signalMapper->setProperty("url", QVariant(linkUrl));
|
||||
signalMapper->setMapping(ac, WebAction::ViewSource);
|
||||
connect(signalMapper, SIGNAL(mapped(int)),
|
||||
this, SLOT(triggerContextMenuAction(int)));
|
||||
connect (ac, SIGNAL(triggered()), signalMapper, SLOT(map()));
|
||||
connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(triggerContextMenuAction(int)));
|
||||
connect(ac, SIGNAL(triggered()), signalMapper, SLOT(map()));
|
||||
menu->exec(event->globalPos());
|
||||
}
|
||||
#endif
|
||||
@@ -425,17 +447,17 @@ void WebView::triggerContextMenuAction(int id)
|
||||
QUrl url = s->property("url").toUrl();
|
||||
|
||||
switch (id) {
|
||||
case WebAction::OpenLink:
|
||||
Q_EMIT openLinkInExternalBrowser(url);
|
||||
break;
|
||||
case WebAction::OpenLinkInNewWindow:
|
||||
Q_EMIT openLinkInNewWindow(url);
|
||||
break;
|
||||
case WebAction::ViewSource:
|
||||
Q_EMIT viewSource(url);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case WebAction::OpenLink:
|
||||
Q_EMIT openLinkInExternalBrowser(url);
|
||||
break;
|
||||
case WebAction::OpenLinkInNewWindow:
|
||||
Q_EMIT openLinkInNewWindow(url);
|
||||
break;
|
||||
case WebAction::ViewSource:
|
||||
Q_EMIT viewSource(url);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,13 +472,13 @@ TYPESYSTEM_SOURCE_ABSTRACT(WebGui::BrowserView, Gui::MDIView)
|
||||
* name 'name'.
|
||||
*/
|
||||
BrowserView::BrowserView(QWidget* parent)
|
||||
: MDIView(nullptr,parent,Qt::WindowFlags()),
|
||||
WindowParameter( "Browser" ),
|
||||
isLoading(false)
|
||||
: MDIView(nullptr, parent, Qt::WindowFlags())
|
||||
, WindowParameter("Browser")
|
||||
, isLoading(false)
|
||||
{
|
||||
#if defined(QTWEBENGINE)
|
||||
// Otherwise cause crash on exit, probably due to double deletion
|
||||
setAttribute(Qt::WA_DeleteOnClose,false);
|
||||
setAttribute(Qt::WA_DeleteOnClose, false);
|
||||
#endif
|
||||
|
||||
view = new WebView(this);
|
||||
@@ -478,27 +500,34 @@ BrowserView::BrowserView(QWidget* parent)
|
||||
// enable local storage so we can store stuff across sessions (startpage)
|
||||
QWebSettings* settings = view->settings();
|
||||
settings->setAttribute(QWebSettings::LocalStorageEnabled, true);
|
||||
settings->setLocalStoragePath(QString::fromUtf8((App::Application::getUserAppDataDir()+"webdata").c_str()));
|
||||
settings->setLocalStoragePath(
|
||||
QString::fromUtf8((App::Application::getUserAppDataDir() + "webdata").c_str()));
|
||||
|
||||
// setting background to white
|
||||
QPalette palette = view->palette();
|
||||
palette.setBrush(QPalette::Base, Qt::white);
|
||||
view->page()->setPalette(palette);
|
||||
|
||||
connect(view->page(), SIGNAL(linkHovered(const QString &, const QString &, const QString &)),
|
||||
this, SLOT(onLinkHovered(const QString &, const QString &, const QString &)));
|
||||
connect(view, SIGNAL(linkClicked(const QUrl &)),
|
||||
this, SLOT(urlFilter(const QUrl &)));
|
||||
connect(view->page(), SIGNAL(downloadRequested(const QNetworkRequest &)),
|
||||
this, SLOT(onDownloadRequested(const QNetworkRequest &)));
|
||||
connect(view->page(), SIGNAL(unsupportedContent(QNetworkReply*)),
|
||||
this, SLOT(onUnsupportedContent(QNetworkReply*)));
|
||||
connect(view->page(),
|
||||
SIGNAL(linkHovered(const QString&, const QString&, const QString&)),
|
||||
this,
|
||||
SLOT(onLinkHovered(const QString&, const QString&, const QString&)));
|
||||
connect(view, SIGNAL(linkClicked(const QUrl&)), this, SLOT(urlFilter(const QUrl&)));
|
||||
connect(view->page(),
|
||||
SIGNAL(downloadRequested(const QNetworkRequest&)),
|
||||
this,
|
||||
SLOT(onDownloadRequested(const QNetworkRequest&)));
|
||||
connect(view->page(),
|
||||
SIGNAL(unsupportedContent(QNetworkReply*)),
|
||||
this,
|
||||
SLOT(onUnsupportedContent(QNetworkReply*)));
|
||||
|
||||
#else // QTWEBENGINE
|
||||
#else// QTWEBENGINE
|
||||
// QWebEngine doesn't support direct access to network
|
||||
// nor rendering access
|
||||
QWebEngineProfile *profile = view->page()->profile();
|
||||
QString basePath = QString::fromStdString(App::Application::getUserAppDataDir()) + QLatin1String("webdata/");
|
||||
QWebEngineProfile* profile = view->page()->profile();
|
||||
QString basePath =
|
||||
QString::fromStdString(App::Application::getUserAppDataDir()) + QLatin1String("webdata/");
|
||||
profile->setPersistentStoragePath(basePath + QLatin1String("persistent"));
|
||||
profile->setCachePath(basePath + QLatin1String("cache"));
|
||||
|
||||
@@ -511,47 +540,42 @@ BrowserView::BrowserView(QWidget* parent)
|
||||
#endif
|
||||
|
||||
view->settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, true);
|
||||
view->settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled,false);
|
||||
view->settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, false);
|
||||
|
||||
connect(view->page()->profile(), &QWebEngineProfile::downloadRequested,
|
||||
this, &BrowserView::onDownloadRequested);
|
||||
connect(view->page(), &QWebEnginePage::iconChanged,
|
||||
this, &BrowserView::setWindowIcon);
|
||||
connect(view->page(), &QWebEnginePage::linkHovered,
|
||||
this, &BrowserView::onLinkHovered);
|
||||
connect(view->page()->profile(),
|
||||
&QWebEngineProfile::downloadRequested,
|
||||
this,
|
||||
&BrowserView::onDownloadRequested);
|
||||
connect(view->page(), &QWebEnginePage::iconChanged, this, &BrowserView::setWindowIcon);
|
||||
connect(view->page(), &QWebEnginePage::linkHovered, this, &BrowserView::onLinkHovered);
|
||||
#endif
|
||||
connect(view, &WebView::viewSource,
|
||||
this, &BrowserView::onViewSource);
|
||||
connect(view, &WebView::loadStarted,
|
||||
this, &BrowserView::onLoadStarted);
|
||||
connect(view, &WebView::loadProgress,
|
||||
this, &BrowserView::onLoadProgress);
|
||||
connect(view, &WebView::loadFinished,
|
||||
this, &BrowserView::onLoadFinished);
|
||||
connect(view, &WebView::openLinkInExternalBrowser,
|
||||
this, &BrowserView::onOpenLinkInExternalBrowser);
|
||||
connect(view, &WebView::openLinkInNewWindow,
|
||||
this, &BrowserView::onOpenLinkInNewWindow);
|
||||
connect(view, &WebView::loadStarted,
|
||||
this, &BrowserView::onUpdateBrowserActions);
|
||||
connect(view, &WebView::loadFinished,
|
||||
this, &BrowserView::onUpdateBrowserActions);
|
||||
connect(view, &WebView::viewSource, this, &BrowserView::onViewSource);
|
||||
connect(view, &WebView::loadStarted, this, &BrowserView::onLoadStarted);
|
||||
connect(view, &WebView::loadProgress, this, &BrowserView::onLoadProgress);
|
||||
connect(view, &WebView::loadFinished, this, &BrowserView::onLoadFinished);
|
||||
connect(view,
|
||||
&WebView::openLinkInExternalBrowser,
|
||||
this,
|
||||
&BrowserView::onOpenLinkInExternalBrowser);
|
||||
connect(view, &WebView::openLinkInNewWindow, this, &BrowserView::onOpenLinkInNewWindow);
|
||||
connect(view, &WebView::loadStarted, this, &BrowserView::onUpdateBrowserActions);
|
||||
connect(view, &WebView::loadFinished, this, &BrowserView::onUpdateBrowserActions);
|
||||
}
|
||||
|
||||
/** Destroys the object and frees any allocated resources */
|
||||
BrowserView::~BrowserView()
|
||||
{
|
||||
#ifdef QTWEBENGINE
|
||||
delete interceptLinks; // cleanup not handled implicitly
|
||||
delete interceptLinks;// cleanup not handled implicitly
|
||||
#endif
|
||||
delete view;
|
||||
}
|
||||
|
||||
void BrowserView::urlFilter(const QUrl & url)
|
||||
void BrowserView::urlFilter(const QUrl& url)
|
||||
{
|
||||
QString scheme = url.scheme();
|
||||
QString host = url.host();
|
||||
//QString username = url.userName();
|
||||
QString scheme = url.scheme();
|
||||
QString host = url.host();
|
||||
// QString username = url.userName();
|
||||
|
||||
// path handling
|
||||
QString path = url.path();
|
||||
@@ -559,66 +583,90 @@ void BrowserView::urlFilter(const QUrl & url)
|
||||
|
||||
// query
|
||||
QString q;
|
||||
if (url.hasQuery())
|
||||
if (url.hasQuery()) {
|
||||
q = url.query();
|
||||
}
|
||||
|
||||
//QString fragment = url. fragment();
|
||||
// QString fragment = url. fragment();
|
||||
|
||||
#ifdef QTWEBKIT
|
||||
if (scheme==QString::fromLatin1("http") || scheme==QString::fromLatin1("https")) {
|
||||
if (scheme == QString::fromLatin1("http") || scheme == QString::fromLatin1("https")) {
|
||||
load(url);
|
||||
}
|
||||
#endif
|
||||
// Small trick to force opening a link in an external browser: use exthttp or exthttps
|
||||
// Write your URL as exthttp://www.example.com
|
||||
else if (scheme==QString::fromLatin1("exthttp")) {
|
||||
else if (scheme == QString::fromLatin1("exthttp")) {
|
||||
exturl.setScheme(QString::fromLatin1("http"));
|
||||
QDesktopServices::openUrl(exturl);
|
||||
stop();// stop qwebengine, should do nothing in qwebkit at this point
|
||||
}
|
||||
else if (scheme==QString::fromLatin1("exthttps")) {
|
||||
else if (scheme == QString::fromLatin1("exthttps")) {
|
||||
exturl.setScheme(QString::fromLatin1("https"));
|
||||
QDesktopServices::openUrl(exturl);
|
||||
stop();// stop qwebengine, should do nothing in qwebkit at this point
|
||||
}
|
||||
// run scripts if not from somewhere else!
|
||||
if ((scheme.size() < 2 || scheme==QString::fromLatin1("file"))&& host.isEmpty()) {
|
||||
if ((scheme.size() < 2 || scheme == QString::fromLatin1("file")) && host.isEmpty()) {
|
||||
QFileInfo fi(path);
|
||||
if (fi.exists()) {
|
||||
QString ext = fi.completeSuffix();
|
||||
if (ext == QString::fromLatin1("py")) {
|
||||
stop(); // stop qwebengine, should do nothing in qwebkit at this point
|
||||
stop();// stop qwebengine, should do nothing in qwebkit at this point
|
||||
|
||||
try {
|
||||
if (!q.isEmpty()) {
|
||||
// encapsulate the value in quotes
|
||||
q = q.replace(QString::fromLatin1("="),QString::fromLatin1("=\""))+QString::fromLatin1("\"");
|
||||
q = q.replace(QString::fromLatin1("%"),QString::fromLatin1("%%"));
|
||||
// url queries in the form of somescript.py?key=value, the first key=value will be printed in the py console as key="value"
|
||||
Gui::Command::doCommand(Gui::Command::Gui,q.toStdString().c_str());
|
||||
q = q.replace(QString::fromLatin1("="), QString::fromLatin1("=\""))
|
||||
+ QString::fromLatin1("\"");
|
||||
q = q.replace(QString::fromLatin1("%"), QString::fromLatin1("%%"));
|
||||
// url queries in the form of somescript.py?key=value, the first key=value
|
||||
// will be printed in the py console as key="value"
|
||||
Gui::Command::doCommand(Gui::Command::Gui, q.toStdString().c_str());
|
||||
}
|
||||
// Gui::Command::doCommand(Gui::Command::Gui,"execfile('%s')",(const char*) fi.absoluteFilePath(). toLocal8Bit());
|
||||
// Gui::Command::doCommand(Gui::Command::Gui,"execfile('%s')",(const char*)
|
||||
// fi.absoluteFilePath(). toLocal8Bit());
|
||||
QString filename = Base::Tools::escapeEncodeFilename(fi.absoluteFilePath());
|
||||
// Set flag indicating that this load/restore has been initiated by the user (not by a macro)
|
||||
Gui::Application::Instance->setStatus(Gui::Application::UserInitiatedOpenDocument, true);
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"with open('%s') as file:\n\texec(file.read())",(const char*) filename.toUtf8());
|
||||
Gui::Application::Instance->setStatus(Gui::Application::UserInitiatedOpenDocument, false);
|
||||
// Set flag indicating that this load/restore has been initiated by the user
|
||||
// (not by a macro)
|
||||
Gui::Application::Instance->setStatus(
|
||||
Gui::Application::UserInitiatedOpenDocument,
|
||||
true);
|
||||
Gui::Command::doCommand(Gui::Command::Gui,
|
||||
"with open('%s') as file:\n\texec(file.read())",
|
||||
(const char*)filename.toUtf8());
|
||||
Gui::Application::Instance->setStatus(
|
||||
Gui::Application::UserInitiatedOpenDocument,
|
||||
false);
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::critical(this, tr("Error"), QString::fromUtf8(e.what()));
|
||||
}
|
||||
|
||||
App::Document *doc = BaseView::getAppDocument();
|
||||
if(doc && doc->testStatus(App::Document::PartialRestore))
|
||||
QMessageBox::critical(this, tr("Error"), tr("There were errors while loading the file. Some data might have been modified or not recovered at all. Look in the report view for more specific information about the objects involved."));
|
||||
App::Document* doc = BaseView::getAppDocument();
|
||||
if (doc && doc->testStatus(App::Document::PartialRestore)) {
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr("Error"),
|
||||
tr("There were errors while loading the file. Some data might have been "
|
||||
"modified or not recovered at all. Look in the report view for more "
|
||||
"specific information about the objects involved."));
|
||||
}
|
||||
|
||||
if(doc && doc->testStatus(App::Document::RestoreError))
|
||||
QMessageBox::critical(this, tr("Error"), tr("There were serious errors while loading the file. Some data might have been modified or not recovered at all. Saving the project will most likely result in loss of data."));
|
||||
if (doc && doc->testStatus(App::Document::RestoreError)) {
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr("Error"),
|
||||
tr("There were serious errors while loading the file. Some data might have "
|
||||
"been modified or not recovered at all. Saving the project will most "
|
||||
"likely result in loss of data."));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("File does not exist!"),
|
||||
fi.absoluteFilePath ());
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
QObject::tr("File does not exist!"),
|
||||
fi.absoluteFilePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -630,10 +678,10 @@ bool BrowserView::chckHostAllowed(const QString& host)
|
||||
}
|
||||
|
||||
#ifdef QTWEBENGINE
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
||||
void BrowserView::onDownloadRequested(QWebEngineDownloadItem *request)
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
void BrowserView::onDownloadRequested(QWebEngineDownloadItem* request)
|
||||
#else
|
||||
void BrowserView::onDownloadRequested(QWebEngineDownloadRequest *request)
|
||||
void BrowserView::onDownloadRequested(QWebEngineDownloadRequest* request)
|
||||
#endif
|
||||
{
|
||||
QUrl url = request->url();
|
||||
@@ -643,11 +691,12 @@ void BrowserView::onDownloadRequested(QWebEngineDownloadRequest *request)
|
||||
}
|
||||
else {
|
||||
request->cancel();
|
||||
Gui::getMainWindow()->loadUrls(App::GetApplication().getActiveDocument(), QList<QUrl>() << url);
|
||||
Gui::getMainWindow()->loadUrls(App::GetApplication().getActiveDocument(),
|
||||
QList<QUrl>() << url);
|
||||
}
|
||||
}
|
||||
|
||||
void BrowserView::setWindowIcon(const QIcon &icon)
|
||||
void BrowserView::setWindowIcon(const QIcon& icon)
|
||||
{
|
||||
Gui::MDIView::setWindowIcon(icon);
|
||||
}
|
||||
@@ -657,29 +706,29 @@ void BrowserView::onLinkHovered(const QString& url)
|
||||
Gui::getMainWindow()->statusBar()->showMessage(url);
|
||||
}
|
||||
|
||||
void BrowserView::onViewSource(const QUrl &url)
|
||||
void BrowserView::onViewSource(const QUrl& url)
|
||||
{
|
||||
Q_UNUSED(url);
|
||||
view->page()->toHtml([=](const QString &pageSource){
|
||||
QPlainTextEdit *editorWidget = new QPlainTextEdit {};
|
||||
App::TextDocument *txtDoc = new App::TextDocument;
|
||||
TextDocumentEditorView *textDocView = new TextDocumentEditorView {
|
||||
txtDoc,
|
||||
editorWidget, getMainWindow()};
|
||||
view->page()->toHtml([=](const QString& pageSource) {
|
||||
QPlainTextEdit* editorWidget = new QPlainTextEdit {};
|
||||
App::TextDocument* txtDoc = new App::TextDocument;
|
||||
TextDocumentEditorView* textDocView =
|
||||
new TextDocumentEditorView {txtDoc, editorWidget, getMainWindow()};
|
||||
editorWidget->setReadOnly(true);
|
||||
editorWidget->setPlainText(pageSource);
|
||||
getMainWindow()->addWindow(textDocView);
|
||||
});
|
||||
}
|
||||
#else
|
||||
void BrowserView::onDownloadRequested(const QNetworkRequest & request)
|
||||
void BrowserView::onDownloadRequested(const QNetworkRequest& request)
|
||||
{
|
||||
QUrl url = request.url();
|
||||
if (!url.isLocalFile()) {
|
||||
Gui::Dialog::DownloadManager::getInstance()->download(request);
|
||||
}
|
||||
else {
|
||||
Gui::getMainWindow()->loadUrls(App::GetApplication().getActiveDocument(), QList<QUrl>() << url);
|
||||
Gui::getMainWindow()->loadUrls(App::GetApplication().getActiveDocument(),
|
||||
QList<QUrl>() << url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -694,7 +743,9 @@ void BrowserView::onUnsupportedContent(QNetworkReply* reply)
|
||||
view->reload();
|
||||
}
|
||||
|
||||
void BrowserView::onLinkHovered(const QString& link, const QString& title, const QString& textContent)
|
||||
void BrowserView::onLinkHovered(const QString& link,
|
||||
const QString& title,
|
||||
const QString& textContent)
|
||||
{
|
||||
Q_UNUSED(title)
|
||||
Q_UNUSED(textContent)
|
||||
@@ -703,17 +754,17 @@ void BrowserView::onLinkHovered(const QString& link, const QString& title, const
|
||||
Gui::getMainWindow()->statusBar()->showMessage(str);
|
||||
}
|
||||
|
||||
void BrowserView::onViewSource(const QUrl &url)
|
||||
void BrowserView::onViewSource(const QUrl& url)
|
||||
{
|
||||
Q_UNUSED(url);
|
||||
if (!view->page() || !view->page()->currentFrame())
|
||||
if (!view->page() || !view->page()->currentFrame()) {
|
||||
return;
|
||||
}
|
||||
QString pageSource = view->page()->currentFrame()->toHtml();
|
||||
QPlainTextEdit *editorWidget = new QPlainTextEdit {};
|
||||
App::TextDocument *txtDoc = new App::TextDocument;
|
||||
TextDocumentEditorView *textDocView = new TextDocumentEditorView {
|
||||
txtDoc, editorWidget, getMainWindow()
|
||||
};
|
||||
QPlainTextEdit* editorWidget = new QPlainTextEdit {};
|
||||
App::TextDocument* txtDoc = new App::TextDocument;
|
||||
TextDocumentEditorView* textDocView =
|
||||
new TextDocumentEditorView {txtDoc, editorWidget, getMainWindow()};
|
||||
editorWidget->setReadOnly(true);
|
||||
editorWidget->setPlainText(pageSource);
|
||||
getMainWindow()->addWindow(textDocView);
|
||||
@@ -726,17 +777,18 @@ void BrowserView::load(const char* URL)
|
||||
load(url);
|
||||
}
|
||||
|
||||
void BrowserView::load(const QUrl & url)
|
||||
void BrowserView::load(const QUrl& url)
|
||||
{
|
||||
if (isLoading)
|
||||
if (isLoading) {
|
||||
stop();
|
||||
}
|
||||
|
||||
urlWgt->setText(url.toString());
|
||||
|
||||
view->load(url);
|
||||
view->setUrl(url);
|
||||
if (url.scheme().size() < 2) {
|
||||
QString path = url.path();
|
||||
QString path = url.path();
|
||||
QFileInfo fi(path);
|
||||
QString name = fi.baseName();
|
||||
|
||||
@@ -751,10 +803,11 @@ void BrowserView::load(const QUrl & url)
|
||||
#endif
|
||||
}
|
||||
|
||||
void BrowserView::setHtml(const QString& HtmlCode,const QUrl & BaseUrl)
|
||||
void BrowserView::setHtml(const QString& HtmlCode, const QUrl& BaseUrl)
|
||||
{
|
||||
if (isLoading)
|
||||
if (isLoading) {
|
||||
stop();
|
||||
}
|
||||
|
||||
view->setHtml(HtmlCode, BaseUrl);
|
||||
#ifdef QTWEBKIT
|
||||
@@ -819,16 +872,22 @@ void BrowserView::onOpenLinkInNewWindow(const QUrl& url)
|
||||
void BrowserView::onUpdateBrowserActions()
|
||||
{
|
||||
CommandManager& mgr = Application::Instance->commandManager();
|
||||
std::vector<const char*> cmds = {"Web_BrowserBack", "Web_BrowserNext", "Web_BrowserRefresh", "Web_BrowserStop",
|
||||
"Web_BrowserZoomIn", "Web_BrowserZoomOut", "Web_BrowserSetURL"};
|
||||
std::vector<const char*> cmds = {"Web_BrowserBack",
|
||||
"Web_BrowserNext",
|
||||
"Web_BrowserRefresh",
|
||||
"Web_BrowserStop",
|
||||
"Web_BrowserZoomIn",
|
||||
"Web_BrowserZoomOut",
|
||||
"Web_BrowserSetURL"};
|
||||
for (const auto& it : cmds) {
|
||||
Gui::Command* cmd = mgr.getCommandByName(it);
|
||||
if (cmd)
|
||||
if (cmd) {
|
||||
cmd->testActive();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BrowserView::OnChange(Base::Subject<const char*> &rCaller,const char* rcReason)
|
||||
void BrowserView::OnChange(Base::Subject<const char*>& rCaller, const char* rcReason)
|
||||
{
|
||||
Q_UNUSED(rCaller);
|
||||
Q_UNUSED(rcReason);
|
||||
@@ -837,33 +896,41 @@ void BrowserView::OnChange(Base::Subject<const char*> &rCaller,const char* rcRea
|
||||
/**
|
||||
* Runs the action specified by \a pMsg.
|
||||
*/
|
||||
bool BrowserView::onMsg(const char* pMsg,const char** )
|
||||
bool BrowserView::onMsg(const char* pMsg, const char**)
|
||||
{
|
||||
if (strcmp(pMsg,"Back")==0){
|
||||
if (strcmp(pMsg, "Back") == 0) {
|
||||
view->back();
|
||||
return true;
|
||||
} else if (strcmp(pMsg,"Next")==0){
|
||||
}
|
||||
else if (strcmp(pMsg, "Next") == 0) {
|
||||
view->forward();
|
||||
return true;
|
||||
} else if (strcmp(pMsg,"Refresh")==0){
|
||||
}
|
||||
else if (strcmp(pMsg, "Refresh") == 0) {
|
||||
view->reload();
|
||||
return true;
|
||||
} else if (strcmp(pMsg,"Stop")==0){
|
||||
}
|
||||
else if (strcmp(pMsg, "Stop") == 0) {
|
||||
stop();
|
||||
return true;
|
||||
} else if (strcmp(pMsg,"ZoomIn")==0){
|
||||
}
|
||||
else if (strcmp(pMsg, "ZoomIn") == 0) {
|
||||
qreal factor = view->zoomFactor();
|
||||
view->setZoomFactor(factor + 0.2);
|
||||
return true;
|
||||
} else if (strcmp(pMsg,"ZoomOut")==0){
|
||||
}
|
||||
else if (strcmp(pMsg, "ZoomOut") == 0) {
|
||||
qreal factor = view->zoomFactor();
|
||||
view->setZoomFactor(factor - 0.2);
|
||||
return true;
|
||||
} else if (strcmp(pMsg,"SetURL")==0){
|
||||
if (urlWgt->isVisible())
|
||||
}
|
||||
else if (strcmp(pMsg, "SetURL") == 0) {
|
||||
if (urlWgt->isVisible()) {
|
||||
urlWgt->hide();
|
||||
else
|
||||
}
|
||||
else {
|
||||
urlWgt->display();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -876,20 +943,27 @@ bool BrowserView::onMsg(const char* pMsg,const char** )
|
||||
*/
|
||||
bool BrowserView::onHasMsg(const char* pMsg) const
|
||||
{
|
||||
if (strcmp(pMsg,"Back")==0)
|
||||
if (strcmp(pMsg, "Back") == 0) {
|
||||
return view->page()->action(QWebEnginePage::Back)->isEnabled();
|
||||
if (strcmp(pMsg,"Next")==0)
|
||||
}
|
||||
if (strcmp(pMsg, "Next") == 0) {
|
||||
return view->page()->action(QWebEnginePage::Forward)->isEnabled();
|
||||
if (strcmp(pMsg,"Refresh")==0)
|
||||
}
|
||||
if (strcmp(pMsg, "Refresh") == 0) {
|
||||
return !isLoading;
|
||||
if (strcmp(pMsg,"Stop")==0)
|
||||
}
|
||||
if (strcmp(pMsg, "Stop") == 0) {
|
||||
return isLoading;
|
||||
if (strcmp(pMsg,"ZoomIn")==0)
|
||||
}
|
||||
if (strcmp(pMsg, "ZoomIn") == 0) {
|
||||
return true;
|
||||
if (strcmp(pMsg,"ZoomOut")==0)
|
||||
}
|
||||
if (strcmp(pMsg, "ZoomOut") == 0) {
|
||||
return true;
|
||||
if (strcmp(pMsg,"SetURL")==0)
|
||||
}
|
||||
if (strcmp(pMsg, "SetURL") == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -911,4 +985,3 @@ PyObject* BrowserView::getPyObject()
|
||||
return new BrowserViewPy(this);
|
||||
}
|
||||
#include "moc_BrowserView.cpp"
|
||||
|
||||
|
||||
@@ -26,12 +26,13 @@
|
||||
#include <QLineEdit>
|
||||
#include <QPointer>
|
||||
#if defined(QTWEBENGINE)
|
||||
# include <QWebEngineView>
|
||||
namespace WebGui {
|
||||
class WebEngineUrlRequestInterceptor;
|
||||
#include <QWebEngineView>
|
||||
namespace WebGui
|
||||
{
|
||||
class WebEngineUrlRequestInterceptor;
|
||||
}
|
||||
#elif defined(QTWEBKIT)
|
||||
# include <QWebView>
|
||||
#include <QWebView>
|
||||
#endif
|
||||
|
||||
#include <Gui/MDIView.h>
|
||||
@@ -42,24 +43,25 @@ class QNetworkReply;
|
||||
class QNetworkRequest;
|
||||
class QUrl;
|
||||
|
||||
namespace WebGui {
|
||||
namespace WebGui
|
||||
{
|
||||
class UrlWidget;
|
||||
|
||||
#ifdef QTWEBENGINE
|
||||
class WebGuiExport WebView : public QWebEngineView
|
||||
class WebGuiExport WebView: public QWebEngineView
|
||||
#else
|
||||
class WebGuiExport WebView : public QWebView
|
||||
class WebGuiExport WebView: public QWebView
|
||||
#endif
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WebView(QWidget *parent = nullptr);
|
||||
explicit WebView(QWidget* parent = nullptr);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
void contextMenuEvent(QContextMenuEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void wheelEvent(QWheelEvent* event) override;
|
||||
void contextMenuEvent(QContextMenuEvent* event) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void triggerContextMenuAction(int);
|
||||
@@ -74,8 +76,7 @@ Q_SIGNALS:
|
||||
* A special view class which sends the messages from the application to
|
||||
* the editor and embeds it in a window.
|
||||
*/
|
||||
class WebGuiExport BrowserView : public Gui::MDIView,
|
||||
public Gui::WindowParameter
|
||||
class WebGuiExport BrowserView: public Gui::MDIView, public Gui::WindowParameter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -86,24 +87,27 @@ public:
|
||||
~BrowserView() override;
|
||||
|
||||
void load(const char* URL);
|
||||
void load(const QUrl & url);
|
||||
void setHtml(const QString& HtmlCode,const QUrl & BaseUrl);
|
||||
void load(const QUrl& url);
|
||||
void setHtml(const QString& HtmlCode, const QUrl& BaseUrl);
|
||||
void stop();
|
||||
QUrl url() const;
|
||||
|
||||
void OnChange(Base::Subject<const char*> &rCaller,const char* rcReason) override;
|
||||
void OnChange(Base::Subject<const char*>& rCaller, const char* rcReason) override;
|
||||
|
||||
const char *getName() const override {return "BrowserView";}
|
||||
PyObject *getPyObject() override;
|
||||
const char* getName() const override
|
||||
{
|
||||
return "BrowserView";
|
||||
}
|
||||
PyObject* getPyObject() override;
|
||||
|
||||
bool onMsg(const char* pMsg,const char** ppReturn) override;
|
||||
bool onMsg(const char* pMsg, const char** ppReturn) override;
|
||||
bool onHasMsg(const char* pMsg) const override;
|
||||
|
||||
bool canClose () override;
|
||||
bool canClose() override;
|
||||
|
||||
#ifdef QTWEBENGINE
|
||||
public Q_SLOTS:
|
||||
void setWindowIcon(const QIcon &icon);
|
||||
void setWindowIcon(const QIcon& icon);
|
||||
#endif
|
||||
|
||||
protected Q_SLOTS:
|
||||
@@ -111,12 +115,12 @@ protected Q_SLOTS:
|
||||
void onLoadProgress(int);
|
||||
void onLoadFinished(bool);
|
||||
bool chckHostAllowed(const QString& host);
|
||||
void urlFilter(const QUrl &url);
|
||||
void urlFilter(const QUrl& url);
|
||||
#ifdef QTWEBENGINE
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
||||
void onDownloadRequested(QWebEngineDownloadItem *request);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
void onDownloadRequested(QWebEngineDownloadItem* request);
|
||||
#else
|
||||
void onDownloadRequested(QWebEngineDownloadRequest *request);
|
||||
void onDownloadRequested(QWebEngineDownloadRequest* request);
|
||||
#endif
|
||||
void onLinkHovered(const QString& url);
|
||||
#else
|
||||
@@ -124,7 +128,7 @@ protected Q_SLOTS:
|
||||
void onUnsupportedContent(QNetworkReply* reply);
|
||||
void onLinkHovered(const QString& link, const QString& title, const QString& textContent);
|
||||
#endif
|
||||
void onViewSource(const QUrl &url);
|
||||
void onViewSource(const QUrl& url);
|
||||
void onOpenLinkInExternalBrowser(const QUrl& url);
|
||||
void onOpenLinkInNewWindow(const QUrl&);
|
||||
void onUpdateBrowserActions();
|
||||
@@ -132,27 +136,29 @@ protected Q_SLOTS:
|
||||
private:
|
||||
QPointer<WebView> view;
|
||||
bool isLoading;
|
||||
UrlWidget *urlWgt;
|
||||
UrlWidget* urlWgt;
|
||||
#ifdef QTWEBENGINE
|
||||
WebEngineUrlRequestInterceptor *interceptLinks;
|
||||
WebEngineUrlRequestInterceptor* interceptLinks;
|
||||
#else
|
||||
float textSizeMultiplier;
|
||||
#endif
|
||||
};
|
||||
|
||||
// the URL ardressbar lineedit
|
||||
class UrlWidget : public QLineEdit
|
||||
class UrlWidget: public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
BrowserView *m_view;
|
||||
BrowserView* m_view;
|
||||
|
||||
public:
|
||||
explicit UrlWidget(BrowserView *view);
|
||||
explicit UrlWidget(BrowserView* view);
|
||||
~UrlWidget() override;
|
||||
void display();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *keyEvt) override;
|
||||
void keyPressEvent(QKeyEvent* keyEvt) override;
|
||||
};
|
||||
|
||||
} // namespace WebGui
|
||||
}// namespace WebGui
|
||||
|
||||
#endif // WEBGUI_BROWSERVIEW_H
|
||||
#endif// WEBGUI_BROWSERVIEW_H
|
||||
|
||||
@@ -40,23 +40,23 @@ using namespace WebGui;
|
||||
DEF_STD_CMD(CmdWebOpenWebsite)
|
||||
|
||||
CmdWebOpenWebsite::CmdWebOpenWebsite()
|
||||
: Command("Web_OpenWebsite")
|
||||
: Command("Web_OpenWebsite")
|
||||
{
|
||||
sAppModule = "Web";
|
||||
sGroup = QT_TR_NOOP("Web");
|
||||
sMenuText = QT_TR_NOOP("Open website...");
|
||||
sToolTipText = QT_TR_NOOP("Opens a website in FreeCAD");
|
||||
sWhatsThis = "Web_OpenWebsite";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/web-browser";
|
||||
sAppModule = "Web";
|
||||
sGroup = QT_TR_NOOP("Web");
|
||||
sMenuText = QT_TR_NOOP("Open website...");
|
||||
sToolTipText = QT_TR_NOOP("Opens a website in FreeCAD");
|
||||
sWhatsThis = "Web_OpenWebsite";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/web-browser";
|
||||
}
|
||||
|
||||
|
||||
void CmdWebOpenWebsite::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
doCommand(Doc,"import WebGui");
|
||||
doCommand(Command::Gui,"WebGui.openBrowser('http://www.freecad.org/')");
|
||||
doCommand(Doc, "import WebGui");
|
||||
doCommand(Command::Gui, "WebGui.openBrowser('http://www.freecad.org/')");
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
@@ -66,21 +66,21 @@ void CmdWebOpenWebsite::activated(int iMsg)
|
||||
DEF_STD_CMD_A(CmdWebBrowserBack)
|
||||
|
||||
CmdWebBrowserBack::CmdWebBrowserBack()
|
||||
: Command("Web_BrowserBack")
|
||||
: Command("Web_BrowserBack")
|
||||
{
|
||||
sAppModule = "Web";
|
||||
sGroup = QT_TR_NOOP("Web");
|
||||
sMenuText = QT_TR_NOOP("Previous page");
|
||||
sToolTipText = QT_TR_NOOP("Go back to the previous page");
|
||||
sWhatsThis = "Web_BrowserBack";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/web-previous";
|
||||
sAppModule = "Web";
|
||||
sGroup = QT_TR_NOOP("Web");
|
||||
sMenuText = QT_TR_NOOP("Previous page");
|
||||
sToolTipText = QT_TR_NOOP("Go back to the previous page");
|
||||
sWhatsThis = "Web_BrowserBack";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/web-previous";
|
||||
}
|
||||
|
||||
void CmdWebBrowserBack::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
doCommand(Command::Gui,"Gui.SendMsgToActiveView('Back')");
|
||||
doCommand(Command::Gui, "Gui.SendMsgToActiveView('Back')");
|
||||
}
|
||||
|
||||
bool CmdWebBrowserBack::isActive()
|
||||
@@ -95,21 +95,21 @@ bool CmdWebBrowserBack::isActive()
|
||||
DEF_STD_CMD_A(CmdWebBrowserNext)
|
||||
|
||||
CmdWebBrowserNext::CmdWebBrowserNext()
|
||||
: Command("Web_BrowserNext")
|
||||
: Command("Web_BrowserNext")
|
||||
{
|
||||
sAppModule = "Web";
|
||||
sGroup = QT_TR_NOOP("Web");
|
||||
sMenuText = QT_TR_NOOP("Next page");
|
||||
sToolTipText = QT_TR_NOOP("Go to the next page");
|
||||
sWhatsThis = "Web_BrowserNext";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/web-next";
|
||||
sAppModule = "Web";
|
||||
sGroup = QT_TR_NOOP("Web");
|
||||
sMenuText = QT_TR_NOOP("Next page");
|
||||
sToolTipText = QT_TR_NOOP("Go to the next page");
|
||||
sWhatsThis = "Web_BrowserNext";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/web-next";
|
||||
}
|
||||
|
||||
void CmdWebBrowserNext::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
doCommand(Command::Gui,"Gui.SendMsgToActiveView('Next')");
|
||||
doCommand(Command::Gui, "Gui.SendMsgToActiveView('Next')");
|
||||
}
|
||||
|
||||
bool CmdWebBrowserNext::isActive()
|
||||
@@ -124,21 +124,21 @@ bool CmdWebBrowserNext::isActive()
|
||||
DEF_STD_CMD_A(CmdWebBrowserRefresh)
|
||||
|
||||
CmdWebBrowserRefresh::CmdWebBrowserRefresh()
|
||||
: Command("Web_BrowserRefresh")
|
||||
: Command("Web_BrowserRefresh")
|
||||
{
|
||||
sAppModule = "Web";
|
||||
sGroup = QT_TR_NOOP("Web");
|
||||
sMenuText = QT_TR_NOOP("Refresh web page");
|
||||
sToolTipText = QT_TR_NOOP("Refresh web page");
|
||||
sWhatsThis = "Web_BrowserRefresh";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/web-refresh";
|
||||
sAppModule = "Web";
|
||||
sGroup = QT_TR_NOOP("Web");
|
||||
sMenuText = QT_TR_NOOP("Refresh web page");
|
||||
sToolTipText = QT_TR_NOOP("Refresh web page");
|
||||
sWhatsThis = "Web_BrowserRefresh";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/web-refresh";
|
||||
}
|
||||
|
||||
void CmdWebBrowserRefresh::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
doCommand(Command::Gui,"Gui.SendMsgToActiveView('Refresh')");
|
||||
doCommand(Command::Gui, "Gui.SendMsgToActiveView('Refresh')");
|
||||
}
|
||||
|
||||
bool CmdWebBrowserRefresh::isActive()
|
||||
@@ -152,22 +152,22 @@ bool CmdWebBrowserRefresh::isActive()
|
||||
DEF_STD_CMD_A(CmdWebBrowserStop)
|
||||
|
||||
CmdWebBrowserStop::CmdWebBrowserStop()
|
||||
:Command("Web_BrowserStop")
|
||||
: Command("Web_BrowserStop")
|
||||
{
|
||||
sAppModule = "Web";
|
||||
sGroup = QT_TR_NOOP("Web");
|
||||
sMenuText = QT_TR_NOOP("Stop loading");
|
||||
sToolTipText = QT_TR_NOOP("Stop loading");
|
||||
sWhatsThis = "Web_BrowserStop";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/web-stop";
|
||||
sAppModule = "Web";
|
||||
sGroup = QT_TR_NOOP("Web");
|
||||
sMenuText = QT_TR_NOOP("Stop loading");
|
||||
sToolTipText = QT_TR_NOOP("Stop loading");
|
||||
sWhatsThis = "Web_BrowserStop";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/web-stop";
|
||||
}
|
||||
|
||||
|
||||
void CmdWebBrowserStop::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
doCommand(Command::Gui,"Gui.SendMsgToActiveView('Stop')");
|
||||
doCommand(Command::Gui, "Gui.SendMsgToActiveView('Stop')");
|
||||
}
|
||||
|
||||
bool CmdWebBrowserStop::isActive()
|
||||
@@ -182,21 +182,21 @@ bool CmdWebBrowserStop::isActive()
|
||||
DEF_STD_CMD_A(CmdWebBrowserZoomIn)
|
||||
|
||||
CmdWebBrowserZoomIn::CmdWebBrowserZoomIn()
|
||||
: Command("Web_BrowserZoomIn")
|
||||
: Command("Web_BrowserZoomIn")
|
||||
{
|
||||
sAppModule = "Web";
|
||||
sGroup = QT_TR_NOOP("Web");
|
||||
sMenuText = QT_TR_NOOP("Zoom in");
|
||||
sToolTipText = QT_TR_NOOP("Zoom in");
|
||||
sWhatsThis = "Web_BrowserZoomIn";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/web-zoom-in";
|
||||
sAppModule = "Web";
|
||||
sGroup = QT_TR_NOOP("Web");
|
||||
sMenuText = QT_TR_NOOP("Zoom in");
|
||||
sToolTipText = QT_TR_NOOP("Zoom in");
|
||||
sWhatsThis = "Web_BrowserZoomIn";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/web-zoom-in";
|
||||
}
|
||||
|
||||
void CmdWebBrowserZoomIn::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
doCommand(Command::Gui,"Gui.SendMsgToActiveView('ZoomIn')");
|
||||
doCommand(Command::Gui, "Gui.SendMsgToActiveView('ZoomIn')");
|
||||
}
|
||||
|
||||
bool CmdWebBrowserZoomIn::isActive()
|
||||
@@ -211,21 +211,21 @@ bool CmdWebBrowserZoomIn::isActive()
|
||||
DEF_STD_CMD_A(CmdWebBrowserZoomOut)
|
||||
|
||||
CmdWebBrowserZoomOut::CmdWebBrowserZoomOut()
|
||||
: Command("Web_BrowserZoomOut")
|
||||
: Command("Web_BrowserZoomOut")
|
||||
{
|
||||
sAppModule = "Web";
|
||||
sGroup = QT_TR_NOOP("Web");
|
||||
sMenuText = QT_TR_NOOP("Zoom out");
|
||||
sToolTipText = QT_TR_NOOP("Zoom out");
|
||||
sWhatsThis = "Web_BrowserZoomOut";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/web-zoom-out";
|
||||
sAppModule = "Web";
|
||||
sGroup = QT_TR_NOOP("Web");
|
||||
sMenuText = QT_TR_NOOP("Zoom out");
|
||||
sToolTipText = QT_TR_NOOP("Zoom out");
|
||||
sWhatsThis = "Web_BrowserZoomOut";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/web-zoom-out";
|
||||
}
|
||||
|
||||
void CmdWebBrowserZoomOut::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
doCommand(Command::Gui,"Gui.SendMsgToActiveView('ZoomOut')");
|
||||
doCommand(Command::Gui, "Gui.SendMsgToActiveView('ZoomOut')");
|
||||
}
|
||||
|
||||
bool CmdWebBrowserZoomOut::isActive()
|
||||
@@ -240,21 +240,21 @@ bool CmdWebBrowserZoomOut::isActive()
|
||||
DEF_STD_CMD_A(CmdWebBrowserSetURL)
|
||||
|
||||
CmdWebBrowserSetURL::CmdWebBrowserSetURL()
|
||||
: Command("Web_BrowserSetURL")
|
||||
: Command("Web_BrowserSetURL")
|
||||
{
|
||||
sAppModule = "Web";
|
||||
sGroup = QT_TR_NOOP("Web");
|
||||
sMenuText = QT_TR_NOOP("Set URL");
|
||||
sToolTipText = QT_TR_NOOP("Set URL");
|
||||
sWhatsThis = "Web_BrowserSetURL";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/web-set-url";
|
||||
sAppModule = "Web";
|
||||
sGroup = QT_TR_NOOP("Web");
|
||||
sMenuText = QT_TR_NOOP("Set URL");
|
||||
sToolTipText = QT_TR_NOOP("Set URL");
|
||||
sWhatsThis = "Web_BrowserSetURL";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/web-set-url";
|
||||
}
|
||||
|
||||
void CmdWebBrowserSetURL::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
doCommand(Command::Gui,"Gui.SendMsgToActiveView('SetURL')");
|
||||
doCommand(Command::Gui, "Gui.SendMsgToActiveView('SetURL')");
|
||||
}
|
||||
|
||||
bool CmdWebBrowserSetURL::isActive()
|
||||
@@ -263,10 +263,9 @@ bool CmdWebBrowserSetURL::isActive()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CreateWebCommands()
|
||||
{
|
||||
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
|
||||
rcCmdMgr.addCommand(new CmdWebOpenWebsite());
|
||||
rcCmdMgr.addCommand(new CmdWebBrowserBack());
|
||||
@@ -276,4 +275,4 @@ void CreateWebCommands()
|
||||
rcCmdMgr.addCommand(new CmdWebBrowserZoomIn());
|
||||
rcCmdMgr.addCommand(new CmdWebBrowserZoomOut());
|
||||
rcCmdMgr.addCommand(new CmdWebBrowserSetURL());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <QNetworkCookie>
|
||||
# include <QTextStream>
|
||||
#include <QNetworkCookie>
|
||||
#include <QTextStream>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
@@ -51,8 +51,9 @@ FcCookieJar::FcCookieJar(QObject* parent)
|
||||
connect(&m_timer, &QTimer::timeout, this, &FcCookieJar::saveToDisk);
|
||||
Base::FileInfo cookiefile(App::Application::getUserAppDataDir() + "cookies");
|
||||
m_file.setFileName(QString::fromUtf8(cookiefile.filePath().c_str()));
|
||||
if (allCookies().isEmpty())
|
||||
if (allCookies().isEmpty()) {
|
||||
loadFromDisk();
|
||||
}
|
||||
}
|
||||
|
||||
FcCookieJar::~FcCookieJar()
|
||||
@@ -64,8 +65,9 @@ FcCookieJar::~FcCookieJar()
|
||||
bool FcCookieJar::setCookiesFromUrl(const QList<QNetworkCookie>& cookieList, const QUrl& url)
|
||||
{
|
||||
bool status = QNetworkCookieJar::setCookiesFromUrl(cookieList, url);
|
||||
if (status)
|
||||
if (status) {
|
||||
scheduleSaveToDisk();
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -83,8 +85,9 @@ void FcCookieJar::extractRawCookies()
|
||||
m_rawCookies.clear();
|
||||
|
||||
for (const auto& it : cookies) {
|
||||
if (!it.isSessionCookie())
|
||||
if (!it.isSessionCookie()) {
|
||||
m_rawCookies.append(it.toRawForm());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,24 +101,30 @@ void FcCookieJar::saveToDisk()
|
||||
out << it + "\n";
|
||||
}
|
||||
m_file.close();
|
||||
} else
|
||||
}
|
||||
else {
|
||||
qWarning("IO error handling cookiejar file");
|
||||
}
|
||||
}
|
||||
|
||||
void FcCookieJar::loadFromDisk()
|
||||
{
|
||||
if (!m_file.exists())
|
||||
if (!m_file.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QList<QNetworkCookie> cookies;
|
||||
|
||||
if (m_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&m_file);
|
||||
while (!in.atEnd())
|
||||
while (!in.atEnd()) {
|
||||
cookies.append(QNetworkCookie::parseCookies(in.readLine().toUtf8()));
|
||||
}
|
||||
m_file.close();
|
||||
} else
|
||||
}
|
||||
else {
|
||||
qWarning("IO error handling cookiejar file");
|
||||
}
|
||||
|
||||
setAllCookies(cookies);
|
||||
}
|
||||
|
||||
@@ -24,39 +24,41 @@
|
||||
#ifndef WEBGUI_COOKIEJAR_H
|
||||
#define WEBGUI_COOKIEJAR_H
|
||||
|
||||
#include <Mod/Web/WebGlobal.h>
|
||||
#include <QFile>
|
||||
#include <QNetworkCookieJar>
|
||||
#include <QTimer>
|
||||
#include <Mod/Web/WebGlobal.h>
|
||||
|
||||
class QNetworkCookieJar;
|
||||
|
||||
namespace WebGui {
|
||||
namespace WebGui
|
||||
{
|
||||
|
||||
class WebGuiExport FcCookieJar : public QNetworkCookieJar {
|
||||
class WebGuiExport FcCookieJar: public QNetworkCookieJar
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FcCookieJar(QObject* parent = nullptr);
|
||||
~FcCookieJar() override;
|
||||
bool setCookiesFromUrl(const QList<QNetworkCookie>&, const QUrl&) override;
|
||||
public:
|
||||
explicit FcCookieJar(QObject* parent = nullptr);
|
||||
~FcCookieJar() override;
|
||||
bool setCookiesFromUrl(const QList<QNetworkCookie>&, const QUrl&) override;
|
||||
|
||||
public Q_SLOTS:
|
||||
void scheduleSaveToDisk();
|
||||
void loadFromDisk();
|
||||
void reset();
|
||||
public Q_SLOTS:
|
||||
void scheduleSaveToDisk();
|
||||
void loadFromDisk();
|
||||
void reset();
|
||||
|
||||
private Q_SLOTS:
|
||||
void saveToDisk();
|
||||
private Q_SLOTS:
|
||||
void saveToDisk();
|
||||
|
||||
private:
|
||||
void extractRawCookies();
|
||||
QList<QByteArray> m_rawCookies;
|
||||
QFile m_file;
|
||||
QTimer m_timer;
|
||||
};
|
||||
private:
|
||||
void extractRawCookies();
|
||||
QList<QByteArray> m_rawCookies;
|
||||
QFile m_file;
|
||||
QTimer m_timer;
|
||||
};
|
||||
|
||||
}
|
||||
}// namespace WebGui
|
||||
|
||||
#endif // WEBGUI_COOKIEJAR_H
|
||||
#endif// WEBGUI_COOKIEJAR_H
|
||||
|
||||
@@ -51,6 +51,6 @@
|
||||
#include <QTextStream>
|
||||
#include <QUrl>
|
||||
|
||||
#endif //_PreComp_
|
||||
#endif//_PreComp_
|
||||
|
||||
#endif // WEBGUI_PRECOMPILED_H
|
||||
#endif// WEBGUI_PRECOMPILED_H
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
using namespace WebGui;
|
||||
|
||||
#if 0 // needed for Qt's lupdate utility
|
||||
#if 0// needed for Qt's lupdate utility
|
||||
qApp->translate("Workbench", "Navigation");
|
||||
#endif
|
||||
|
||||
@@ -43,26 +43,28 @@ Workbench::Workbench() = default;
|
||||
|
||||
Workbench::~Workbench() = default;
|
||||
|
||||
void Workbench::setupContextMenu(const char* recipient,Gui::MenuItem* item) const
|
||||
void Workbench::setupContextMenu(const char* recipient, Gui::MenuItem* item) const
|
||||
{
|
||||
Q_UNUSED(recipient);
|
||||
Q_UNUSED(item);
|
||||
//if (strcmp(recipient,"View") == 0)
|
||||
// if (strcmp(recipient,"View") == 0)
|
||||
//{
|
||||
// Gui::MenuItem* StdViews = new Gui::MenuItem();
|
||||
// StdViews->setCommand( "Standard views" );
|
||||
// Gui::MenuItem* StdViews = new Gui::MenuItem();
|
||||
// StdViews->setCommand( "Standard views" );
|
||||
|
||||
// *StdViews << "Std_ViewAxo" << "Separator" << "Std_ViewFront" << "Std_ViewTop" << "Std_ViewRight"
|
||||
// *StdViews << "Std_ViewAxo" << "Separator" << "Std_ViewFront" << "Std_ViewTop" <<
|
||||
// "Std_ViewRight"
|
||||
// << "Std_ViewRear" << "Std_ViewBottom" << "Std_ViewLeft";
|
||||
|
||||
// *item << "Std_ViewFitAll" << "Std_ViewFitSelection" << StdViews
|
||||
// << "Separator" << "Std_ViewDockUndockFullscreen";
|
||||
|
||||
// if ( Gui::Selection().countObjectsOfType(App::DocumentObject::getClassTypeId()) > 0 )
|
||||
// *item << "Separator" << "Std_SetAppearance" << "Std_ToggleVisibility" << "Std_TreeSelection"
|
||||
// *item << "Separator" << "Std_SetAppearance" << "Std_ToggleVisibility" <<
|
||||
// "Std_TreeSelection"
|
||||
// << "Std_RandomColor" << "Separator" << "Std_Delete";
|
||||
//}
|
||||
//else if (strcmp(recipient,"Tree") == 0)
|
||||
// else if (strcmp(recipient,"Tree") == 0)
|
||||
//{
|
||||
// if ( Gui::Selection().countObjectsOfType(App::DocumentObject::getClassTypeId()) > 0 )
|
||||
// *item << "Std_SetAppearance" << "Std_ToggleVisibility"
|
||||
@@ -73,224 +75,231 @@ void Workbench::setupContextMenu(const char* recipient,Gui::MenuItem* item) cons
|
||||
Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
{
|
||||
return Gui::StdWorkbench::setupMenuBar();
|
||||
//Gui::CommandManager &mgr = Gui::Application::Instance->commandManager();
|
||||
// Gui::CommandManager &mgr = Gui::Application::Instance->commandManager();
|
||||
//// Setup the default menu bar
|
||||
//Gui::MenuItem* menuBar = new Gui::MenuItem;
|
||||
// Gui::MenuItem* menuBar = new Gui::MenuItem;
|
||||
|
||||
// // File
|
||||
// Gui::MenuItem* file = new Gui::MenuItem( menuBar );
|
||||
// file->setCommand("&File");
|
||||
// *file << "Std_New" << "Std_Open" << "Separator" << "Std_CloseActiveWindow"
|
||||
// << "Std_CloseAllWindows" << "Separator" << "Std_Save" << "Std_SaveAs"
|
||||
// << "Separator" << "Std_Import" << "Std_Export" << "Std_ProjectInfo"
|
||||
// //<< "Separator" << "Std_Print" << "Std_PrintPdf"
|
||||
// << "Separator" << "Std_RecentFiles" << "Separator" << "Std_Quit";
|
||||
//
|
||||
// // Edit
|
||||
// Gui::MenuItem* edit = new Gui::MenuItem( menuBar );
|
||||
// edit->setCommand("&Edit");
|
||||
// *edit << "Std_Undo" << "Std_Redo" << "Separator" << "Std_Cut" << "Std_Copy"
|
||||
// << "Std_Paste" << "Std_DuplicateSelection" << "Separator"
|
||||
// << "Std_Refresh" << "Std_SelectAll" << "Std_Delete" << "Std_Placement"
|
||||
// << "Separator" << "Std_DlgPreferences";
|
||||
//
|
||||
// // Standard views
|
||||
// Gui::MenuItem* stdviews = new Gui::MenuItem;
|
||||
// stdviews->setCommand("Standard views");
|
||||
// *stdviews << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_ViewAxo"
|
||||
// << "Separator" << "Std_ViewFront" << "Std_ViewRight"
|
||||
// << "Std_ViewTop" << "Separator" << "Std_ViewRear"
|
||||
// << "Std_ViewLeft" << "Std_ViewBottom";
|
||||
//
|
||||
// // stereo
|
||||
// Gui::MenuItem* view3d = new Gui::MenuItem;
|
||||
// view3d->setCommand("&Stereo");
|
||||
// *view3d << "Std_ViewIvStereoRedGreen" << "Std_ViewIvStereoQuadBuff"
|
||||
// << "Std_ViewIvStereoInterleavedRows" << "Std_ViewIvStereoInterleavedColumns"
|
||||
// << "Std_ViewIvStereoOff" << "Separator" << "Std_ViewIvIssueCamPos";
|
||||
//
|
||||
// // zoom
|
||||
// Gui::MenuItem* zoom = new Gui::MenuItem;
|
||||
// zoom->setCommand("&Zoom");
|
||||
// *zoom << "Std_ViewZoomIn" << "Std_ViewZoomOut" << "Separator" << "Std_ViewBoxZoom";
|
||||
//
|
||||
// // Visibility
|
||||
// Gui::MenuItem* visu = new Gui::MenuItem;
|
||||
// visu->setCommand("Visibility");
|
||||
// *visu << "Std_ToggleVisibility" << "Std_ShowSelection" << "Std_HideSelection"
|
||||
// << "Separator" << "Std_ToggleObjects" << "Std_ShowObjects" << "Std_HideObjects";
|
||||
//
|
||||
// // View
|
||||
// Gui::MenuItem* view = new Gui::MenuItem( menuBar );
|
||||
// view->setCommand("&View");
|
||||
// *view << "Std_ViewCreate" << "Std_OrthographicCamera" << "Std_PerspectiveCamera" << "Separator"
|
||||
// << stdviews << "Std_FreezeViews" << "Separator" << view3d << zoom
|
||||
// << "Std_ViewDockUndockFullscreen" << "Std_ToggleClipPlane" << "Separator" << visu
|
||||
// << "Std_SetAppearance" << "Std_ToggleVisibility" << "Std_RandomColor" << "Separator"
|
||||
// //<< "Std_MeasureDistance" << "Separator"
|
||||
// << "Std_Workbench" << "Std_ToolBarMenu" << "Std_DockViewMenu" << "Separator"
|
||||
// << "Std_ViewStatusBar" << "Std_UserInterface";
|
||||
//
|
||||
// // Tools
|
||||
// Gui::MenuItem* tool = new Gui::MenuItem( menuBar );
|
||||
// tool->setCommand("&Tools");
|
||||
// *tool << "Std_CommandLine" << "Std_DlgParameter" << "Separator" << "Std_DlgMacroRecord"
|
||||
// << "Std_MacroStopRecord" << "Std_DlgMacroExecute" << "Std_DlgMacroExecuteDirect"
|
||||
// << "Separator" << "Std_ViewScreenShot" << "Separator" << "Std_DlgCustomize";
|
||||
//
|
||||
// // Mesh ****************************************************************************************************
|
||||
// Gui::MenuItem* mesh = new Gui::MenuItem( menuBar );
|
||||
//
|
||||
// // submenu analyze
|
||||
// Gui::MenuItem* analyze = new Gui::MenuItem();
|
||||
// analyze->setCommand("Analyze");
|
||||
// *analyze << "Mesh_Evaluation"
|
||||
// << "Mesh_EvaluateFacet"
|
||||
// << "Mesh_CurvatureInfo"
|
||||
// << "Separator"
|
||||
// << "Mesh_EvaluateSolid"
|
||||
// << "Mesh_BoundingBox";
|
||||
//
|
||||
// // submenu boolean
|
||||
// Gui::MenuItem* boolean = new Gui::MenuItem();
|
||||
// boolean->setCommand("Boolean");
|
||||
// *boolean << "Mesh_Union"
|
||||
// << "Mesh_Intersection"
|
||||
// << "Mesh_Difference";
|
||||
//
|
||||
// mesh->setCommand("&Meshes");
|
||||
// *mesh << "Mesh_Import"
|
||||
// << "Mesh_Export"
|
||||
// << "Mesh_FromGeometry"
|
||||
// << "Separator"
|
||||
// << analyze
|
||||
// << "Mesh_HarmonizeNormals"
|
||||
// << "Mesh_FlipNormals"
|
||||
// << "Separator"
|
||||
// << "Mesh_FillupHoles"
|
||||
// << "Mesh_FillInteractiveHole"
|
||||
// << "Mesh_RemoveComponents"
|
||||
// << "Mesh_RemoveCompByHand"
|
||||
// << "Separator"
|
||||
// << "Mesh_BuildRegularSolid"
|
||||
// << boolean << "Separator"
|
||||
// << "Mesh_PolyCut"
|
||||
// << "Mesh_PolySplit"
|
||||
// << "Mesh_PolySegm"
|
||||
// << "Mesh_ToolMesh"
|
||||
// << "Mesh_VertexCurvature";
|
||||
//
|
||||
// // Part ****************************************************************************************************
|
||||
//
|
||||
// Gui::MenuItem* part = new Gui::MenuItem(menuBar);
|
||||
// part->setCommand("&Part");
|
||||
//
|
||||
// // submenu boolean
|
||||
// Gui::MenuItem* para = new Gui::MenuItem();
|
||||
// para->setCommand("Parametric");
|
||||
// *para << "Part_Box"
|
||||
// << "Part_Cylinder"
|
||||
// << "Part_Sphere"
|
||||
// << "Part_Cone"
|
||||
// << "Part_Torus"
|
||||
// << "Part_Primitives";
|
||||
// *part << para
|
||||
// << "Part_Boolean"
|
||||
// << "Part_Extrude"
|
||||
// << "Part_Revolve"
|
||||
// << "Part_Fillet";
|
||||
//
|
||||
//# ifdef WEB_SHOW_SKETCHER
|
||||
// if (mgr.getCommandByName("Sketcher_NewSketch")) {
|
||||
// Gui::MenuItem* sketch = new Gui::MenuItem(menuBar);
|
||||
// sketch->setCommand("Ske&tch");
|
||||
// *sketch
|
||||
// << "Sketcher_NewSketch"
|
||||
// << "Separator"
|
||||
// << "PartDesign_Pad"
|
||||
// << "PartDesign_Fillet"
|
||||
// ;
|
||||
// }
|
||||
//# endif
|
||||
//
|
||||
// // Drawing ****************************************************************************************************
|
||||
//
|
||||
// Gui::MenuItem* drawing = new Gui::MenuItem(menuBar);
|
||||
//
|
||||
// drawing->setCommand("&Drawing");
|
||||
// *drawing
|
||||
// << "Drawing_Open"
|
||||
// << "Separator"
|
||||
// << "Drawing_NewA3Landscape"
|
||||
// << "Drawing_NewView"
|
||||
// << "Drawing_ExportPage"
|
||||
// ;
|
||||
//
|
||||
// // Drafting ****************************************************************************************************
|
||||
//# ifdef WEB_USE_DRAFTING
|
||||
// if (mgr.getCommandByName("Draft_Line")) {
|
||||
// Gui::MenuItem* Drafting = new Gui::MenuItem(menuBar);
|
||||
//
|
||||
// Drafting->setCommand("&Drafting");
|
||||
// *Drafting
|
||||
// << "Draft_SelectPlane"
|
||||
// << "Draft_Line"
|
||||
// << "Draft_Polyline"
|
||||
// << "Draft_Circle"
|
||||
// << "Draft_Arc"
|
||||
// << "Draft_Rectangle"
|
||||
// << "Draft_Text"
|
||||
// << "Draft_Dimension"
|
||||
// << "Separator"
|
||||
// << "Draft_Move"
|
||||
// << "Draft_Rotate"
|
||||
// << "Draft_Offset"
|
||||
// << "Draft_Trimex"
|
||||
// << "Draft_Upgrade"
|
||||
// << "Draft_Downgrade"
|
||||
// << "Draft_Scale"
|
||||
// << "Separator"
|
||||
// << "Draft_ApplyStyle"
|
||||
// ;
|
||||
// }
|
||||
//# endif
|
||||
//
|
||||
// // xxx ****************************************************************************************************
|
||||
//
|
||||
//
|
||||
// // Windows
|
||||
// Gui::MenuItem* wnd = new Gui::MenuItem( menuBar );
|
||||
// wnd->setCommand("&Windows");
|
||||
// *wnd << "Std_ActivateNextWindow" << "Std_ActivatePrevWindow" << "Separator"
|
||||
// << "Std_TileWindows" << "Std_CascadeWindows" << "Separator"
|
||||
// << "Std_WindowsMenu" << "Std_Windows";
|
||||
//
|
||||
// // help ****************************************************************************************************
|
||||
// // Separator
|
||||
// Gui::MenuItem* sep = new Gui::MenuItem( menuBar );
|
||||
// sep->setCommand( "Separator" );
|
||||
//
|
||||
// // Help
|
||||
// Gui::MenuItem* helpWebsites = new Gui::MenuItem;
|
||||
// helpWebsites->setCommand("&Online-help");
|
||||
// *helpWebsites << "Std_OnlineHelpWebsite"
|
||||
// << "Std_FreeCADWebsite"
|
||||
// << "Std_PythonWebsite";
|
||||
//
|
||||
// Gui::MenuItem* help = new Gui::MenuItem( menuBar );
|
||||
// help->setCommand("&Help");
|
||||
// *help << "Std_OnlineHelp"
|
||||
// << "Std_PythonHelp"
|
||||
// << helpWebsites
|
||||
// << "Separator"
|
||||
// << "Test_Test"
|
||||
// << "Separator"
|
||||
// << "Std_About"
|
||||
// << "Std_AboutQt"
|
||||
// << "Separator"
|
||||
// << "Std_WhatsThis" ;
|
||||
//
|
||||
// return menuBar;
|
||||
// // File
|
||||
// Gui::MenuItem* file = new Gui::MenuItem( menuBar );
|
||||
// file->setCommand("&File");
|
||||
// *file << "Std_New" << "Std_Open" << "Separator" << "Std_CloseActiveWindow"
|
||||
// << "Std_CloseAllWindows" << "Separator" << "Std_Save" << "Std_SaveAs"
|
||||
// << "Separator" << "Std_Import" << "Std_Export" << "Std_ProjectInfo"
|
||||
// //<< "Separator" << "Std_Print" << "Std_PrintPdf"
|
||||
// << "Separator" << "Std_RecentFiles" << "Separator" << "Std_Quit";
|
||||
//
|
||||
// // Edit
|
||||
// Gui::MenuItem* edit = new Gui::MenuItem( menuBar );
|
||||
// edit->setCommand("&Edit");
|
||||
// *edit << "Std_Undo" << "Std_Redo" << "Separator" << "Std_Cut" << "Std_Copy"
|
||||
// << "Std_Paste" << "Std_DuplicateSelection" << "Separator"
|
||||
// << "Std_Refresh" << "Std_SelectAll" << "Std_Delete" << "Std_Placement"
|
||||
// << "Separator" << "Std_DlgPreferences";
|
||||
//
|
||||
// // Standard views
|
||||
// Gui::MenuItem* stdviews = new Gui::MenuItem;
|
||||
// stdviews->setCommand("Standard views");
|
||||
// *stdviews << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_ViewAxo"
|
||||
// << "Separator" << "Std_ViewFront" << "Std_ViewRight"
|
||||
// << "Std_ViewTop" << "Separator" << "Std_ViewRear"
|
||||
// << "Std_ViewLeft" << "Std_ViewBottom";
|
||||
//
|
||||
// // stereo
|
||||
// Gui::MenuItem* view3d = new Gui::MenuItem;
|
||||
// view3d->setCommand("&Stereo");
|
||||
// *view3d << "Std_ViewIvStereoRedGreen" << "Std_ViewIvStereoQuadBuff"
|
||||
// << "Std_ViewIvStereoInterleavedRows" << "Std_ViewIvStereoInterleavedColumns"
|
||||
// << "Std_ViewIvStereoOff" << "Separator" << "Std_ViewIvIssueCamPos";
|
||||
//
|
||||
// // zoom
|
||||
// Gui::MenuItem* zoom = new Gui::MenuItem;
|
||||
// zoom->setCommand("&Zoom");
|
||||
// *zoom << "Std_ViewZoomIn" << "Std_ViewZoomOut" << "Separator" << "Std_ViewBoxZoom";
|
||||
//
|
||||
// // Visibility
|
||||
// Gui::MenuItem* visu = new Gui::MenuItem;
|
||||
// visu->setCommand("Visibility");
|
||||
// *visu << "Std_ToggleVisibility" << "Std_ShowSelection" << "Std_HideSelection"
|
||||
// << "Separator" << "Std_ToggleObjects" << "Std_ShowObjects" << "Std_HideObjects";
|
||||
//
|
||||
// // View
|
||||
// Gui::MenuItem* view = new Gui::MenuItem( menuBar );
|
||||
// view->setCommand("&View");
|
||||
// *view << "Std_ViewCreate" << "Std_OrthographicCamera" << "Std_PerspectiveCamera" <<
|
||||
// "Separator"
|
||||
// << stdviews << "Std_FreezeViews" << "Separator" << view3d << zoom
|
||||
// << "Std_ViewDockUndockFullscreen" << "Std_ToggleClipPlane" << "Separator" << visu
|
||||
// << "Std_SetAppearance" << "Std_ToggleVisibility" << "Std_RandomColor" << "Separator"
|
||||
// //<< "Std_MeasureDistance" << "Separator"
|
||||
// << "Std_Workbench" << "Std_ToolBarMenu" << "Std_DockViewMenu" << "Separator"
|
||||
// << "Std_ViewStatusBar" << "Std_UserInterface";
|
||||
//
|
||||
// // Tools
|
||||
// Gui::MenuItem* tool = new Gui::MenuItem( menuBar );
|
||||
// tool->setCommand("&Tools");
|
||||
// *tool << "Std_CommandLine" << "Std_DlgParameter" << "Separator" << "Std_DlgMacroRecord"
|
||||
// << "Std_MacroStopRecord" << "Std_DlgMacroExecute" << "Std_DlgMacroExecuteDirect"
|
||||
// << "Separator" << "Std_ViewScreenShot" << "Separator" << "Std_DlgCustomize";
|
||||
//
|
||||
// // Mesh
|
||||
// ****************************************************************************************************
|
||||
// Gui::MenuItem* mesh = new Gui::MenuItem( menuBar );
|
||||
//
|
||||
// // submenu analyze
|
||||
// Gui::MenuItem* analyze = new Gui::MenuItem();
|
||||
// analyze->setCommand("Analyze");
|
||||
// *analyze << "Mesh_Evaluation"
|
||||
// << "Mesh_EvaluateFacet"
|
||||
// << "Mesh_CurvatureInfo"
|
||||
// << "Separator"
|
||||
// << "Mesh_EvaluateSolid"
|
||||
// << "Mesh_BoundingBox";
|
||||
//
|
||||
// // submenu boolean
|
||||
// Gui::MenuItem* boolean = new Gui::MenuItem();
|
||||
// boolean->setCommand("Boolean");
|
||||
// *boolean << "Mesh_Union"
|
||||
// << "Mesh_Intersection"
|
||||
// << "Mesh_Difference";
|
||||
//
|
||||
// mesh->setCommand("&Meshes");
|
||||
// *mesh << "Mesh_Import"
|
||||
// << "Mesh_Export"
|
||||
// << "Mesh_FromGeometry"
|
||||
// << "Separator"
|
||||
// << analyze
|
||||
// << "Mesh_HarmonizeNormals"
|
||||
// << "Mesh_FlipNormals"
|
||||
// << "Separator"
|
||||
// << "Mesh_FillupHoles"
|
||||
// << "Mesh_FillInteractiveHole"
|
||||
// << "Mesh_RemoveComponents"
|
||||
// << "Mesh_RemoveCompByHand"
|
||||
// << "Separator"
|
||||
// << "Mesh_BuildRegularSolid"
|
||||
// << boolean << "Separator"
|
||||
// << "Mesh_PolyCut"
|
||||
// << "Mesh_PolySplit"
|
||||
// << "Mesh_PolySegm"
|
||||
// << "Mesh_ToolMesh"
|
||||
// << "Mesh_VertexCurvature";
|
||||
//
|
||||
// // Part
|
||||
// ****************************************************************************************************
|
||||
//
|
||||
// Gui::MenuItem* part = new Gui::MenuItem(menuBar);
|
||||
// part->setCommand("&Part");
|
||||
//
|
||||
// // submenu boolean
|
||||
// Gui::MenuItem* para = new Gui::MenuItem();
|
||||
// para->setCommand("Parametric");
|
||||
// *para << "Part_Box"
|
||||
// << "Part_Cylinder"
|
||||
// << "Part_Sphere"
|
||||
// << "Part_Cone"
|
||||
// << "Part_Torus"
|
||||
// << "Part_Primitives";
|
||||
// *part << para
|
||||
// << "Part_Boolean"
|
||||
// << "Part_Extrude"
|
||||
// << "Part_Revolve"
|
||||
// << "Part_Fillet";
|
||||
//
|
||||
// # ifdef WEB_SHOW_SKETCHER
|
||||
// if (mgr.getCommandByName("Sketcher_NewSketch")) {
|
||||
// Gui::MenuItem* sketch = new Gui::MenuItem(menuBar);
|
||||
// sketch->setCommand("Ske&tch");
|
||||
// *sketch
|
||||
// << "Sketcher_NewSketch"
|
||||
// << "Separator"
|
||||
// << "PartDesign_Pad"
|
||||
// << "PartDesign_Fillet"
|
||||
// ;
|
||||
// }
|
||||
// # endif
|
||||
//
|
||||
// // Drawing
|
||||
// ****************************************************************************************************
|
||||
//
|
||||
// Gui::MenuItem* drawing = new Gui::MenuItem(menuBar);
|
||||
//
|
||||
// drawing->setCommand("&Drawing");
|
||||
// *drawing
|
||||
// << "Drawing_Open"
|
||||
// << "Separator"
|
||||
// << "Drawing_NewA3Landscape"
|
||||
// << "Drawing_NewView"
|
||||
// << "Drawing_ExportPage"
|
||||
// ;
|
||||
//
|
||||
// // Drafting
|
||||
// ****************************************************************************************************
|
||||
// # ifdef WEB_USE_DRAFTING
|
||||
// if (mgr.getCommandByName("Draft_Line")) {
|
||||
// Gui::MenuItem* Drafting = new Gui::MenuItem(menuBar);
|
||||
//
|
||||
// Drafting->setCommand("&Drafting");
|
||||
// *Drafting
|
||||
// << "Draft_SelectPlane"
|
||||
// << "Draft_Line"
|
||||
// << "Draft_Polyline"
|
||||
// << "Draft_Circle"
|
||||
// << "Draft_Arc"
|
||||
// << "Draft_Rectangle"
|
||||
// << "Draft_Text"
|
||||
// << "Draft_Dimension"
|
||||
// << "Separator"
|
||||
// << "Draft_Move"
|
||||
// << "Draft_Rotate"
|
||||
// << "Draft_Offset"
|
||||
// << "Draft_Trimex"
|
||||
// << "Draft_Upgrade"
|
||||
// << "Draft_Downgrade"
|
||||
// << "Draft_Scale"
|
||||
// << "Separator"
|
||||
// << "Draft_ApplyStyle"
|
||||
// ;
|
||||
// }
|
||||
// # endif
|
||||
//
|
||||
// // xxx
|
||||
// ****************************************************************************************************
|
||||
//
|
||||
//
|
||||
// // Windows
|
||||
// Gui::MenuItem* wnd = new Gui::MenuItem( menuBar );
|
||||
// wnd->setCommand("&Windows");
|
||||
// *wnd << "Std_ActivateNextWindow" << "Std_ActivatePrevWindow" << "Separator"
|
||||
// << "Std_TileWindows" << "Std_CascadeWindows" << "Separator"
|
||||
// << "Std_WindowsMenu" << "Std_Windows";
|
||||
//
|
||||
// // help
|
||||
// ****************************************************************************************************
|
||||
// // Separator
|
||||
// Gui::MenuItem* sep = new Gui::MenuItem( menuBar );
|
||||
// sep->setCommand( "Separator" );
|
||||
//
|
||||
// // Help
|
||||
// Gui::MenuItem* helpWebsites = new Gui::MenuItem;
|
||||
// helpWebsites->setCommand("&Online-help");
|
||||
// *helpWebsites << "Std_OnlineHelpWebsite"
|
||||
// << "Std_FreeCADWebsite"
|
||||
// << "Std_PythonWebsite";
|
||||
//
|
||||
// Gui::MenuItem* help = new Gui::MenuItem( menuBar );
|
||||
// help->setCommand("&Help");
|
||||
// *help << "Std_OnlineHelp"
|
||||
// << "Std_PythonHelp"
|
||||
// << helpWebsites
|
||||
// << "Separator"
|
||||
// << "Test_Test"
|
||||
// << "Separator"
|
||||
// << "Std_About"
|
||||
// << "Std_AboutQt"
|
||||
// << "Separator"
|
||||
// << "Std_WhatsThis" ;
|
||||
//
|
||||
// return menuBar;
|
||||
}
|
||||
|
||||
Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
@@ -313,7 +322,6 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
<< "Web_BrowserZoomOut";
|
||||
|
||||
return root;
|
||||
|
||||
}
|
||||
|
||||
Gui::ToolBarItem* Workbench::setupCommandBars() const
|
||||
@@ -325,7 +333,7 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
|
||||
Gui::DockWindowItems* Workbench::setupDockWindows() const
|
||||
{
|
||||
Gui::DockWindowItems* root = Gui::StdWorkbench::setupDockWindows();
|
||||
//root->setVisibility(false); // hide all dock windows by default
|
||||
//root->setVisibility("Std_ComboView",true); // except of the combo view
|
||||
// root->setVisibility(false); // hide all dock windows by default
|
||||
// root->setVisibility("Std_ComboView",true); // except of the combo view
|
||||
return root;
|
||||
}
|
||||
|
||||
@@ -26,21 +26,22 @@
|
||||
|
||||
#include <Gui/Workbench.h>
|
||||
|
||||
namespace WebGui {
|
||||
namespace WebGui
|
||||
{
|
||||
|
||||
/**
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class Workbench : public Gui::StdWorkbench
|
||||
class Workbench: public Gui::StdWorkbench
|
||||
{
|
||||
TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
||||
|
||||
public:
|
||||
Workbench();
|
||||
~Workbench() override;
|
||||
Workbench();
|
||||
~Workbench() override;
|
||||
|
||||
/** Defines the standard context menu. */
|
||||
void setupContextMenu(const char* recipient,Gui::MenuItem*) const override;
|
||||
void setupContextMenu(const char* recipient, Gui::MenuItem*) const override;
|
||||
|
||||
protected:
|
||||
/** Defines the standard menus. */
|
||||
@@ -53,7 +54,7 @@ protected:
|
||||
Gui::DockWindowItems* setupDockWindows() const override;
|
||||
|
||||
|
||||
}; // namespace WebGui
|
||||
};// namespace WebGui
|
||||
|
||||
}
|
||||
#endif // WEB_WORKBENCH_H
|
||||
}// namespace WebGui
|
||||
#endif// WEB_WORKBENCH_H
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
#***************************************************************************
|
||||
#* Copyright (c) 2001,2002 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
#* *
|
||||
#* This file is part of the FreeCAD CAx development system. *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
#* as published by the Free Software Foundation; either version 2 of *
|
||||
#* the License, or (at your option) any later version. *
|
||||
#* for detail see the LICENCE text file. *
|
||||
#* *
|
||||
#* FreeCAD is distributed in the hope that it will be useful, *
|
||||
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
#* GNU Lesser General Public License for more details. *
|
||||
#* *
|
||||
#* You should have received a copy of the GNU Library General Public *
|
||||
#* License along with FreeCAD; if not, write to the Free Software *
|
||||
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||
#* USA *
|
||||
#* *
|
||||
#***************************************************************************/
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2001,2002 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
# * This program is free software; you can redistribute it and/or modify *
|
||||
# * it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
# * as published by the Free Software Foundation; either version 2 of *
|
||||
# * the License, or (at your option) any later version. *
|
||||
# * for detail see the LICENCE text file. *
|
||||
# * *
|
||||
# * FreeCAD is distributed in the hope that it will be useful, *
|
||||
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
# * GNU Lesser General Public License for more details. *
|
||||
# * *
|
||||
# * You should have received a copy of the GNU Library General Public *
|
||||
# * License along with FreeCAD; if not, write to the Free Software *
|
||||
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||
# * USA *
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
# FreeCAD init script of the Web module
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
#***************************************************************************
|
||||
#* Copyright (c) 2002,2003 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
#* *
|
||||
#* This file is part of the FreeCAD CAx development system. *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
#* as published by the Free Software Foundation; either version 2 of *
|
||||
#* the License, or (at your option) any later version. *
|
||||
#* for detail see the LICENCE text file. *
|
||||
#* *
|
||||
#* FreeCAD is distributed in the hope that it will be useful, *
|
||||
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
#* GNU Lesser General Public License for more details. *
|
||||
#* *
|
||||
#* You should have received a copy of the GNU Library General Public *
|
||||
#* License along with FreeCAD; if not, write to the Free Software *
|
||||
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||
#* USA *
|
||||
#***************************************************************************/
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2002,2003 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
# * This program is free software; you can redistribute it and/or modify *
|
||||
# * it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
# * as published by the Free Software Foundation; either version 2 of *
|
||||
# * the License, or (at your option) any later version. *
|
||||
# * for detail see the LICENCE text file. *
|
||||
# * *
|
||||
# * FreeCAD is distributed in the hope that it will be useful, *
|
||||
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
# * GNU Lesser General Public License for more details. *
|
||||
# * *
|
||||
# * You should have received a copy of the GNU Library General Public *
|
||||
# * License along with FreeCAD; if not, write to the Free Software *
|
||||
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||
# * USA *
|
||||
# ***************************************************************************/
|
||||
|
||||
# Web gui init module
|
||||
#
|
||||
@@ -27,8 +27,9 @@
|
||||
# runs when the gui is up
|
||||
|
||||
|
||||
class WebWorkbench ( Workbench ):
|
||||
class WebWorkbench(Workbench):
|
||||
"Web workbench object"
|
||||
|
||||
def __init__(self):
|
||||
self.__class__.Icon = FreeCAD.getResourceDir() + "Mod/Web/Resources/icons/WebWorkbench.svg"
|
||||
self.__class__.MenuText = "Web"
|
||||
@@ -41,9 +42,10 @@ class WebWorkbench ( Workbench ):
|
||||
def GetClassName(self):
|
||||
return "WebGui::Workbench"
|
||||
|
||||
|
||||
Gui.addWorkbench(WebWorkbench())
|
||||
|
||||
# Append the open handler
|
||||
FreeCAD.addImportType("Web Page (*.html *.xhtml)", "WebGui")
|
||||
|
||||
FreeCAD.__unit_test__ += [ "TestWebGui" ]
|
||||
FreeCAD.__unit_test__ += ["TestWebGui"]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#**************************************************************************
|
||||
# **************************************************************************
|
||||
# Copyright (c) 2018 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
# *
|
||||
# This file is part of the FreeCAD CAx development system. *
|
||||
@@ -18,12 +18,13 @@
|
||||
# License along with FreeCAD; if not, write to the Free Software *
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||
# USA *
|
||||
#**************************************************************************
|
||||
# **************************************************************************
|
||||
|
||||
import FreeCAD, os, sys, unittest, WebGui
|
||||
|
||||
|
||||
class WebGuiTestCases(unittest.TestCase):
|
||||
def testHtmlCase(self):
|
||||
bytestr=b'<b>Fran\xc3\xa7ais</b>'
|
||||
browser=WebGui.openBrowserWindow('Browser')
|
||||
bytestr = b"<b>Fran\xc3\xa7ais</b>"
|
||||
browser = WebGui.openBrowserWindow("Browser")
|
||||
browser.setHtml(bytestr.decode("utf8"), FreeCAD.getResourceDir())
|
||||
|
||||
@@ -29,19 +29,19 @@
|
||||
// Web
|
||||
#ifndef WebExport
|
||||
#ifdef Web_EXPORTS
|
||||
# define WebExport FREECAD_DECL_EXPORT
|
||||
#define WebExport FREECAD_DECL_EXPORT
|
||||
#else
|
||||
# define WebExport FREECAD_DECL_IMPORT
|
||||
#define WebExport FREECAD_DECL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// WebGui
|
||||
#ifndef WebGuiExport
|
||||
#ifdef WebGui_EXPORTS
|
||||
# define WebGuiExport FREECAD_DECL_EXPORT
|
||||
#define WebGuiExport FREECAD_DECL_EXPORT
|
||||
#else
|
||||
# define WebGuiExport FREECAD_DECL_IMPORT
|
||||
#define WebGuiExport FREECAD_DECL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif //WEB_GLOBAL_H
|
||||
#endif// WEB_GLOBAL_H
|
||||
|
||||
Reference in New Issue
Block a user