diff --git a/src/Mod/Start/Gui/Workbench.cpp b/src/Mod/Start/Gui/Workbench.cpp index 4d4a9752ee..76ce96fade 100644 --- a/src/Mod/Start/Gui/Workbench.cpp +++ b/src/Mod/Start/Gui/Workbench.cpp @@ -131,7 +131,9 @@ Gui::ToolBarItem* StartGui::Workbench::setupToolBars() const // web navigation toolbar Gui::ToolBarItem* navigation = new Gui::ToolBarItem(root); navigation->setCommand("Navigation"); - *navigation << "Web_OpenWebsite" + *navigation << "Web_BrowserSetURL" + << "Separator" + << "Web_OpenWebsite" << "Start_StartPage" << "Separator" << "Web_BrowserBack" diff --git a/src/Mod/Web/Gui/BrowserView.cpp b/src/Mod/Web/Gui/BrowserView.cpp index ef938ab3e3..37260c8366 100644 --- a/src/Mod/Web/Gui/BrowserView.cpp +++ b/src/Mod/Web/Gui/BrowserView.cpp @@ -48,6 +48,7 @@ # include # include # include +# include #endif @@ -65,6 +66,7 @@ # include # include # include +# include # define QWEBVIEW QWebView # define QWEBPAGE QWebPage #endif @@ -130,6 +132,42 @@ private: }; #endif +// --------------------------------------------------------------------------------------------- +UrlWidget::UrlWidget(BrowserView *view) : + QLineEdit(view), m_view(view) +{ + setText(QLatin1String("https://")); + hide(); +} +UrlWidget::~UrlWidget() +{ +} + +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); + } +} + +void UrlWidget::display() +{ + setFixedWidth(m_view->size().width()); + show(); + setFocus(Qt::ActiveWindowFocusReason); +} + +// --------------------------------------------------------------------------------------------- + class BrowserViewPy : public Py::PythonExtension { public: @@ -344,6 +382,8 @@ BrowserView::BrowserView(QWidget* parent) setCentralWidget(view); view->setAttribute(Qt::WA_OpaquePaintEvent, true); + urlWgt = new UrlWidget(this); + #ifdef QTWEBKIT textSizeMultiplier = 1.0; @@ -548,8 +588,7 @@ void BrowserView::onViewSource(const QUrl &url) QPlainTextEdit *editorWidget = new QPlainTextEdit {}; App::TextDocument *txtDoc = new App::TextDocument; TextDocumentEditorView *textDocView = new TextDocumentEditorView { - txtDoc, - editorWidget, getMainWindow() + txtDoc, editorWidget, getMainWindow() }; editorWidget->setReadOnly(true); editorWidget->setPlainText(pageSource); @@ -568,6 +607,8 @@ void BrowserView::load(const QUrl & url) if (isLoading) stop(); + urlWgt->setText(url.toString()); + view->load(url); view->setUrl(url); if (url.scheme().size() < 2) { @@ -674,6 +715,9 @@ bool BrowserView::onMsg(const char* pMsg,const char** ) qreal factor = view->zoomFactor(); view->setZoomFactor(factor - 0.2); return true; + } else if (strcmp(pMsg,"SetURL")==0){ + urlWgt->display(); + return true; } return false; @@ -693,6 +737,7 @@ bool BrowserView::onHasMsg(const char* pMsg) const if (strcmp(pMsg,"Stop")==0) return isLoading; if (strcmp(pMsg,"ZoomIn")==0) return true; if (strcmp(pMsg,"ZoomOut")==0) return true; + if (strcmp(pMsg,"SetURL")==0) return true; return false; } diff --git a/src/Mod/Web/Gui/BrowserView.h b/src/Mod/Web/Gui/BrowserView.h index 95147f5e47..aeda103a1c 100644 --- a/src/Mod/Web/Gui/BrowserView.h +++ b/src/Mod/Web/Gui/BrowserView.h @@ -27,6 +27,7 @@ #include #include +#include #if QT_VERSION >= 0x050700 && defined(QTWEBENGINE) #include @@ -42,6 +43,7 @@ class QNetworkRequest; class QNetworkReply; namespace WebGui { +class UrlWidget; #ifdef QTWEBENGINE class WebGuiExport WebView : public QWebEngineView @@ -123,6 +125,7 @@ protected Q_SLOTS: private: WebView* view; bool isLoading; + UrlWidget *urlWgt; #ifdef QTWEBENGINE WebEngineUrlRequestInterceptor *interceptLinks; #else @@ -130,6 +133,19 @@ private: #endif }; +// the URL ardressbar lineedit +class UrlWidget : public QLineEdit +{ + Q_OBJECT + BrowserView *m_view; +public: + explicit UrlWidget(BrowserView *view); + ~UrlWidget(); + void display(); +protected: + void keyPressEvent(QKeyEvent *keyEvt); +}; + } // namespace WebGui #endif // WEBGUI_BROWSERVIEW_H diff --git a/src/Mod/Web/Gui/Command.cpp b/src/Mod/Web/Gui/Command.cpp index 49dbddbdcd..398417c947 100644 --- a/src/Mod/Web/Gui/Command.cpp +++ b/src/Mod/Web/Gui/Command.cpp @@ -237,6 +237,36 @@ bool CmdWebBrowserZoomOut::isActive(void) return getGuiApplication()->sendHasMsgToActiveView("ZoomOut"); } +//=========================================================================== +// CmdWebBrowserSetUrl +//=========================================================================== + +DEF_STD_CMD_A(CmdWebBrowserSetURL); + +CmdWebBrowserSetURL::CmdWebBrowserSetURL() + : 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"; +} + +void CmdWebBrowserSetURL::activated(int iMsg) +{ + Q_UNUSED(iMsg); + doCommand(Command::Gui,"Gui.SendMsgToActiveView('SetURL')"); +} + +bool CmdWebBrowserSetURL::isActive(void) +{ + return getGuiApplication()->sendHasMsgToActiveView("SetURL"); +} + + void CreateWebCommands(void) { @@ -249,4 +279,5 @@ void CreateWebCommands(void) rcCmdMgr.addCommand(new CmdWebBrowserStop()); rcCmdMgr.addCommand(new CmdWebBrowserZoomIn()); rcCmdMgr.addCommand(new CmdWebBrowserZoomOut()); + rcCmdMgr.addCommand(new CmdWebBrowserSetURL()); } diff --git a/src/Mod/Web/Gui/Resources/Web.qrc b/src/Mod/Web/Gui/Resources/Web.qrc index 893129d736..6356d77314 100644 --- a/src/Mod/Web/Gui/Resources/Web.qrc +++ b/src/Mod/Web/Gui/Resources/Web.qrc @@ -1,5 +1,5 @@ - - + + icons/actions/web-browser.svg icons/actions/web-home.svg icons/actions/web-next.svg @@ -9,6 +9,7 @@ icons/actions/web-zoom-in.svg icons/actions/web-zoom-out.svg icons/actions/web-sketchfab.svg + icons/actions/web-set-url.svg icons/WebWorkbench.svg translations/Web_de.qm translations/Web_af.qm diff --git a/src/Mod/Web/Gui/Resources/icons/actions/web-set-url.svg b/src/Mod/Web/Gui/Resources/icons/actions/web-set-url.svg new file mode 100644 index 0000000000..efb18db4b3 --- /dev/null +++ b/src/Mod/Web/Gui/Resources/icons/actions/web-set-url.svg @@ -0,0 +1,1483 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Jakub Steiner + + + + + Tuomas Kuosmanen + + + + http://jimmac.musichall.cz + + + globe + international + web + www + internet + network + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/Web/Gui/Workbench.cpp b/src/Mod/Web/Gui/Workbench.cpp index 163322b571..aa54f2e176 100644 --- a/src/Mod/Web/Gui/Workbench.cpp +++ b/src/Mod/Web/Gui/Workbench.cpp @@ -325,7 +325,9 @@ Gui::ToolBarItem* Workbench::setupToolBars() const // web navigation toolbar Gui::ToolBarItem* navigation = new Gui::ToolBarItem(root); navigation->setCommand("Navigation"); - *navigation << "Web_OpenWebsite" + *navigation << "Web_BrowserSetURL" + << "Separator" + << "Web_OpenWebsite" << "Separator" << "Web_BrowserBack" << "Web_BrowserNext"