QTXML_CPPFLAGS=`$PKG_CONFIG --cflags "QtXml >= $QT_REQUIRED_VERSION"`
QTASSISTANT_CPPFLAGS=`$PKG_CONFIG --cflags "QtAssistant >= $QT_REQUIRED_VERSION"`
QTNETWORK_CPPFLAGS=`$PKG_CONFIG --cflags "QtNetwork >= $QT_REQUIRED_VERSION"`
+ QTWEBKIT_CPPFLAGS=`$PKG_CONFIG --cflags "QtWebKit >= $QT_REQUIRED_VERSION"`
QTCORE_LDFLAGS=`$PKG_CONFIG --libs "QtCore >= $QT_REQUIRED_VERSION"`
QTGUI_LDFLAGS=`$PKG_CONFIG --libs "QtGui >= $QT_REQUIRED_VERSION"`
QTXML_LDFLAGS=`$PKG_CONFIG --libs "QtXml >= $QT_REQUIRED_VERSION"`
QTASSISTANT_LDFLAGS=`$PKG_CONFIG --libs "QtAssistant >= $QT_REQUIRED_VERSION"`
QTNETWORK_LDFLAGS=`$PKG_CONFIG --libs "QtNetwork >= $QT_REQUIRED_VERSION"`
+ QTWEBKIT_LDFLAGS=`$PKG_CONFIG --libs "QtWebKit >= $QT_REQUIRED_VERSION"`
else
AC_MSG_WARN(Qt not found)
fi
QTCORE_CPPFLAGS="${QT_BASE}/QtCore"
QTGUI_CPPFLAGS="${QT_BASE}/QtGui"
QTOPENGL_CPPFLAGS="${QT_BASE}/QtOpenGL"
+ QTWEBKIT_CPPFLAGS="${QT_BASE}/QtWebKit"
QTXML_CPPFLAGS="${QT_BASE}/QtXml"
QTASSISTANT_CPPFLAGS="${QT_BASE}/QtAssistant"
QTNETWORK_CPPFLAGS="${QT_BASE}/QtNetwork"
fi
- QT_INCLUDES="$QT_BASE $QTCORE_CPPFLAGS $QTGUI_CPPFLAGS $QTOPENGL_CPPFLAGS $QTXML_CPPFLAGS"
+ QT_INCLUDES="$QT_BASE $QTCORE_CPPFLAGS $QTGUI_CPPFLAGS $QTOPENGL_CPPFLAGS $QTXML_CPPFLAGS $QTWEBKIT_CPPFLAGS"
QT_ASSISANT_INCLUDES="$QTASSISTANT_CPPFLAGS $QTNETWORK_CPPFLAGS"
QT_MT_INCLUDES="${QT_INCLUDES}"
if test "x$QT_USING_PKGCONFIG" = "xyes"
then
QT_CORE_LIBS="$QTCORE_LDFLAGS $QTXML_LDFLAGS"
- QT_GUI_LIBS="$QTGUI_LDFLAGS $QTOPENGL_LDFLAGS"
+ QT_GUI_LIBS="$QTGUI_LDFLAGS $QTOPENGL_LDFLAGS $QTWEBKIT_LDFLAGS"
QT_ASSISTANT_LIBS="$QTASSISTANT_LDFLAGS $QTNETWORK_LDFLAGS"
else
QT_CORE_LIBS="$QT_LIB_DIR -lQtCore -lQtXml"
# gui libs
- QT_GUI_LIBS="$QT_LIB_DIR -lQtGui -lQtOpenGL"
+ QT_GUI_LIBS="$QT_LIB_DIR -lQtGui -lQtOpenGL -lQtWebKit"
# other libs (currently not used)
QT_OTHER_LIBS="$QT_LIB_DIR"
# other libs (can be used if necessary)
#include <QtxSearchTool.h>
#include <QtxWorkstack.h>
#include <QtxMap.h>
+#include <QtxWebBrowser.h>
#include <LogWindow.h>
/*! \var global preferences of LightApp */
LightApp_Preferences* LightApp_Application::_prefs_ = 0;
+
+static inline QString getFile(){
+#ifdef WIN32
+ return QString( "file://" );
+#else
+ return QString( "file:" );
+#endif
+}
+
+
/*!
\class LightApp_Application
Application containing LightApp module
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
+
+ QtxWebBrowser::setData("BROWSER_ICON", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_ICON" )));
+ QtxWebBrowser::setData("BROWSER_TITLE", tr("BROWSER_TITLE"));
+ QtxWebBrowser::setData("BROWSER_FILEMENU", tr("BROWSER_FILEMENU"));
+ QtxWebBrowser::setData("BROWSER_EXIT", tr("BROWSER_EXIT"));
desktop()->setWindowIcon( aLogo );
desktop()->setDockableMenuBar( false );
const QString& theContext = QString() )
: myApp( theApp ),
myParams( theParams ),
-#ifdef WIN32
- myHelpFile( "file://" + theHelpFile ),
-#else
- myHelpFile( "file:" + theHelpFile ),
-#endif
+ myHelpFile( getFile() + theHelpFile ),
myContext( theContext ),
myStatus(0),
myLApp( app )
anApp.append( quote );
#endif
QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
+ bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
- if ( !anApp.isEmpty() )
- {
- RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
- rs->start();
- }
- else
- {
- if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
- SUIT_MessageBox::Yes | SUIT_MessageBox::No,
- SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
-
- showPreferences( tr( "PREF_APP" ) );
+ if( useExtBrowser ) {
+ if ( !anApp.isEmpty() )
+ {
+ RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
+ rs->start();
+ }
+ else
+ {
+ if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+ SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
+
+ showPreferences( tr( "PREF_APP" ) );
+ }
+ } else {
+ QtxWebBrowser::loadUrl(getFile() + helpFile);
}
}
anApp.prepend( quote );
anApp.append( quote );
#endif
- QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
- if ( !anApp.isEmpty() )
- {
- RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, theContext );
- rs->start();
- }
- else
- {
- if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
- SUIT_MessageBox::Yes | SUIT_MessageBox::No,
- SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
- showPreferences( tr( "PREF_APP" ) );
+ bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
+
+ if(useExtBrowser) {
+ QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
+
+ if ( !anApp.isEmpty() )
+ {
+ RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, theContext );
+ rs->start();
+ }
+ else
+ {
+ if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+ SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
+ showPreferences( tr( "PREF_APP" ) );
+ }
+ } else {
+ QtxWebBrowser::loadUrl(getFile() + helpFile, theContext );
}
}
pref->setItemProperty( "max", 1440, autoSaveInterval );
pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
- int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
+ int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
QString platform;
#ifdef WIN32
platform = "winapplication";
if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
}
+
+ if ( sec == "ExternalBrowser" && param == "use_external_browser" ) {
+ if ( resMgr->booleanValue("ExternalBrowser", "use_external_browser", false ) )
+ {
+ if(QtxWebBrowser::webBrowser())
+ QtxWebBrowser::webBrowser()->close();
+ }
+ }
}
/*!
<section name="ExternalBrowser" >
<!-- External HELP browser settings -->
<parameter value="C:\Program Files\Internet Explorer\iexplore.exe" name="winapplication" />
+ <parameter value="false" name="use_external_browser" />
<parameter value="/usr/bin/mozilla" name="application" />
</section>
</document>
<source>APP_MODULE_ICO</source>
<translation>icon_module.png</translation>
</message>
+ <message>
+ <source>BROWSER_ICON</source>
+ <translation>icon_default.png</translation>
+ </message>
</context>
</TS>
<source>ENTRY_COLUMN</source>
<translation>Entry</translation>
</message>
+ <message>
+ <source>BROWSER_TITLE</source>
+ <translation>SALOME Help Browser</translation>
+ </message>
+ <message>
+ <source>BROWSER_FILEMENU</source>
+ <translation>&File</translation>
+ </message>
+ <message>
+ <source>BROWSER_EXIT</source>
+ <translation>&Exit</translation>
+ </message>
</context>
<context>
<name>LightApp_Application</name>
QtxWorkspace.h \
QtxWorkspaceAction.h \
QtxWorkstack.h \
- QtxWorkstackAction.h
+ QtxWorkstackAction.h \
+ QtxWebBrowser.h
#VSR: not yet migrated to Qt4 files
# \
QtxWorkspace.cxx \
QtxWorkspaceAction.cxx \
QtxWorkstack.cxx \
- QtxWorkstackAction.cxx
+ QtxWorkstackAction.cxx \
+ QtxWebBrowser.cxx
#VSR: not yet migrated to Qt4 files
# \
QtxWorkspace_moc.cxx \
QtxWorkspaceAction_moc.cxx \
QtxWorkstack_moc.cxx \
- QtxWorkstackAction_moc.cxx
+ QtxWorkstackAction_moc.cxx \
+ QtxWebBrowser_moc.cxx
#VSR: not yet migrated to Qt4 files
# \
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library 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 Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File: QtxWebBrowser.cxx
+// Author: Roman NIKOLAEV
+//
+#include "QtxWebBrowser.h"
+
+#include <QApplication>
+#include <QWebView>
+#include <QMenuBar>
+#include <QToolBar>
+#include <QMenu>
+
+//! The only one instance of web browser
+QtxWebBrowser* QtxWebBrowser::myBrowser = 0;
+
+//!Internal data map to store resources of the browser.
+QMap<QString, QVariant> QtxWebBrowser::myData;
+
+/*!
+ \class QtxWebBrowser
+
+ \brief The QtxWebBrowser provides a window that can display a html pages.
+
+ Only one instance of the QtxWebBrowser class can be created. To access the browser
+ window, use static method QtxWebBrowser::webBrowser(), which creates an
+ instance of the QtxWebBrowser widget (if it is not yet creaed) and returns a
+ pointer to it.
+
+ You should not destroy this instance - it is done automatically after
+ closing of the browser window. To closing window programmatically use
+ method close().
+
+ To set visual properties of the browser use static method setData().
+
+ Following code demonstrate how to use web browser:
+
+ \code
+ int main(int argc, char *argv[])
+ {
+ QApplication app(argc, argv);
+
+ //Set icon, title and menu items.
+ QtxWebBrowser::setData("BROWSER_TITLE", tr("Web Browser"));
+
+ QPixmap pixmap(":/icon.png");
+ QtxWebBrowser::setData("BROWSER_ICON", pixmap);
+
+ QtxWebBrowser::setData("BROWSER_FILEMENU", tr("&File"));
+ QtxWebBrowser::setData("BROWSER_EXIT", tr("&Exit"));
+
+
+ //Show web page
+ QtxWebBrowser::loadUrl("file:///data/index.html", "anchor1");
+
+ return app.exec();
+ }
+
+ \endcode
+
+ This code will create the browser window and open /data/index.html
+ file in "anchor1" context.
+*/
+
+/*!
+ \brief Constructor.
+
+ Construct the web browser.
+*/
+QtxWebBrowser::QtxWebBrowser()
+: QMainWindow(0)
+{
+ setAttribute( Qt::WA_DeleteOnClose );
+ myWebView = new QWebView(this);
+
+ QToolBar *toolBar = addToolBar(tr("Navigation"));
+ toolBar->addAction(myWebView->pageAction(QWebPage::Back));
+ toolBar->addAction(myWebView->pageAction(QWebPage::Forward));
+
+ QString title = getStringValue("BROWSER_TITLE");
+ if(!title.isEmpty())
+ setWindowTitle(title);
+
+ QIcon icon = getIconValue("BROWSER_ICON");
+ if(!icon.isNull())
+ setWindowIcon(icon);
+
+ QString fmenu = getStringValue("BROWSER_FILEMENU");
+ if ( fmenu.isEmpty() ) {
+ fmenu = tr("&File");
+ }
+ QMenu *menu = menuBar()->addMenu(fmenu);
+
+ QString item = getStringValue("BROWSER_EXIT");
+ if ( item.isEmpty() ) {
+ item = tr("&Exit");
+ }
+ menu->addAction( item, this, SLOT(close()));
+
+ connect(myWebView, SIGNAL(titleChanged(QString)), SLOT(adjustTitle()));
+ setCentralWidget(myWebView);
+}
+
+/*!
+ \brief Destructor.
+*/
+QtxWebBrowser::~QtxWebBrowser()
+{
+ myBrowser = 0;
+}
+
+/*!
+ \brief Create instance of the QtxWebBrowser.
+ \return instance of the QtxWebBrowser.
+*/
+QtxWebBrowser* QtxWebBrowser::webBrowser() {
+ if( myBrowser == 0 )
+ myBrowser = new QtxWebBrowser();
+ return myBrowser;
+}
+
+/*!
+ \brief Load given url addres and context.
+ \param theUlr url address to load.
+ \param theContext url context to load.
+*/
+void QtxWebBrowser::loadUrl(const QString& theUrl , const QString theContext ) {
+ QString anUrl = theUrl;
+ if( !theContext.isEmpty() )
+ anUrl += "#" + theContext;
+
+ Qtx::alignWidget(webBrowser(), (QWidget*)QApplication::desktop(),Qtx::AlignHCenter);
+ webBrowser()->show();
+ webBrowser()->myWebView->load(QUrl(anUrl));
+ webBrowser()->setFocus();
+ webBrowser()->activateWindow();
+ webBrowser()->raise();
+}
+
+/*!
+ \brief Set browser settings from.
+
+ This method can be used to setup the browser look-n-feel.
+
+ All the browser parameters can be defined via resources file:
+ - \c "BROWSER_TITLE" : title of the browser
+ - \c "BROWSER_ICON" : icon of the browser
+ - \c "BROWSER_FILEMENU" : name of the browser menu
+ - \c "BROWSER_EXIT" : name of the browser menu item
+
+ \param key name of the property
+ \param val value of the property
+
+*/
+void QtxWebBrowser::setData( const QString& key, const QVariant& val ) {
+ myData.insert(key, val);
+}
+
+/*!
+ \brief Get string by name from the internal data map.
+ \internal
+*/
+QString QtxWebBrowser::getStringValue(const QString& key) {
+ QString val;
+ if(myData.contains(key)) {
+ QVariant v = myData[key];
+ if( v.type() == QVariant::String ) {
+ val = v.toString();
+ }
+ }
+ return val;
+}
+
+/*!
+ \brief Get icon by name from the internal data map.
+ \internal
+*/
+QIcon QtxWebBrowser::getIconValue(const QString& key) {
+ QIcon val;
+ if(myData.contains(key)) {
+ QVariant v = myData[key];
+ if( v.type() == QVariant::Pixmap ) {
+ val = v.value<QPixmap>();
+ }
+ }
+ return val;
+}
+
+/*!
+ \brief Update title of the window.
+ \internal
+*/
+void QtxWebBrowser::adjustTitle()
+{
+ QString title = getStringValue("BROWSER_TITLE");
+ title.isEmpty() ? title = myWebView->title() : title += " : " + myWebView->title();
+ setWindowTitle(title);
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library 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 Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File: QtxWebBrowser.h
+// Author: Roman NIKOLAEV
+//
+
+#ifndef QTXWEBBROWSER_H
+#define QTXWEBBROWSER_H
+
+#include "Qtx.h"
+
+#include <QMainWindow>
+#include <QWebView>
+#include <QMap>
+
+
+class QTX_EXPORT QtxWebBrowser : public QMainWindow
+{
+ Q_OBJECT
+
+private:
+ QtxWebBrowser();
+
+public:
+ virtual ~QtxWebBrowser();
+
+ static QtxWebBrowser* webBrowser();
+ static void loadUrl( const QString& theUrl, const QString theContext = QString() );
+ static void setData( const QString& key, const QVariant& val );
+
+private:
+ QString getStringValue(const QString& key);
+ QIcon getIconValue(const QString& key);
+
+private slots:
+ void adjustTitle();
+
+private:
+ static QtxWebBrowser* myBrowser;
+ QWebView* myWebView;
+ static QMap<QString, QVariant> myData;
+
+};
+
+#endif // QTXWEBBROWSER_H