From: <ma...@us...> - 2016-04-23 21:48:57
|
Revision: 1462 http://sourceforge.net/p/canorus/code/1462 Author: matevz Date: 2016-04-23 21:48:55 +0000 (Sat, 23 Apr 2016) Log Message: ----------- Implemented new built-in User's guide using the web engine provided by Qt. Removed QT_HELP dependency from CMakeLists. Modified Paths: -------------- trunk/src/CMakeLists.txt trunk/src/control/helpctl.cpp trunk/src/control/helpctl.h trunk/src/ui/mainwin.cpp trunk/src/widgets/helpbrowser.cpp trunk/src/widgets/helpbrowser.h Modified: trunk/src/CMakeLists.txt =================================================================== --- trunk/src/CMakeLists.txt 2016-04-23 21:46:37 UTC (rev 1461) +++ trunk/src/CMakeLists.txt 2016-04-23 21:48:55 UTC (rev 1462) @@ -199,7 +199,6 @@ # Enable needed Qt modules for Canorus SET(QT_USE_QTXML True) # Save/Load SET(QT_USE_QTSVG True) # Icons, Images etc. -SET(QT_USE_QTHELP True) # Inline help browser SET(QT_USE_QTWEBKIT True) # Inline help browser # Add all resources to Canorus_Resrcs (icons, html files etc.) @@ -578,8 +577,8 @@ INCLUDE_DIRECTORIES(${Qt5Svg_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${Qt5Xml_INCLUDE_DIRS}) -INCLUDE_DIRECTORIES(${Qt5Help_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${Qt5PrintSupport_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${Qt5WebKitWidgets_INCLUDE_DIRS}) # FIX: Qt was built with -reduce-relocations if (Qt5_POSITION_INDEPENDENT_CODE) @@ -602,7 +601,7 @@ ${Canorus_Swig_Srcs} ${CMAKE_CURRENT_SOURCE_DIR}/scripting/canorusruby.i ) - SWIG_LINK_LIBRARIES(CanorusRuby ${RUBY_LIBRARY} Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Svg Qt5::Xml Qt5::Help Qt5::PrintSupport) + SWIG_LINK_LIBRARIES(CanorusRuby ${RUBY_LIBRARY} Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Svg Qt5::Xml Qt5::PrintSupport) SET_TARGET_PROPERTIES( ${SWIG_MODULE_CanorusRuby_REAL_NAME} PROPERTIES COMPILE_FLAGS "-DSWIGCPP" ) ENDIF(USE_RUBY) @@ -617,7 +616,7 @@ ${Canorus_Swig_Srcs} ${CMAKE_CURRENT_SOURCE_DIR}/scripting/canoruspython.i ) - SWIG_LINK_LIBRARIES(CanorusPython ${PYTHON_LIBRARY} Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Svg Qt5::Xml Qt5::Help Qt5::PrintSupport) + SWIG_LINK_LIBRARIES(CanorusPython ${PYTHON_LIBRARY} Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Svg Qt5::Xml Qt5::PrintSupport) SET_TARGET_PROPERTIES( ${SWIG_MODULE_CanorusPython_REAL_NAME} PROPERTIES COMPILE_FLAGS "-DSWIGCPP" ) ENDIF(USE_PYTHON) @@ -662,7 +661,7 @@ # command. Never remove that line :-) # Add ${QT_QTTEST_LIBRARY} below to add the Qt Test library as well # Add ${POPPLERQT4_LIBRARY} ${POPPLER_LIBRARY} to reactivate poppler libraries -TARGET_LINK_LIBRARIES(canorus Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Svg Qt5::Xml Qt5::Help Qt5::PrintSupport ${RUBY_LIBRARY} ${PYTHON_LIBRARY} z pthread ) +TARGET_LINK_LIBRARIES(canorus Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Svg Qt5::Xml Qt5::PrintSupport Qt5::WebKitWidgets ${RUBY_LIBRARY} ${PYTHON_LIBRARY} z pthread ) # Duma leads to a crash on libfontconfig with Ubuntu (10.04/12.04) # duma ) @@ -760,7 +759,7 @@ IF(MINGW) # Install Qt libs - INSTALL( FILES ${QT_BIN_DIR}/Qt5Core.dll ${QT_BIN_DIR}/Qt5Gui.dll ${QT_BIN_DIR}/Qt5Widgets.dll ${QT_BIN_DIR}/Qt5Svg.dll ${QT_BIN_DIR}/Qt5Xml.dll ${QT_BIN_DIR}/Qt5Help.dll ${QT_BIN_DIR}/Qt5Sql.dll ${QT_BIN_DIR}/Qt5Network.dll ${QT_BIN_DIR}/Qt5CLucene.dll ${QT_BIN_DIR}/Qt5PrintSupport.dll DESTINATION ${CMAKE_INSTALL_PREFIX}/${CANORUS_INSTALL_BIN_DIR} ) + INSTALL( FILES ${QT_BIN_DIR}/Qt5Core.dll ${QT_BIN_DIR}/Qt5Gui.dll ${QT_BIN_DIR}/Qt5Widgets.dll ${QT_BIN_DIR}/Qt5Svg.dll ${QT_BIN_DIR}/Qt5Xml.dll ${QT_BIN_DIR}/Qt5Sql.dll ${QT_BIN_DIR}/Qt5Network.dll ${QT_BIN_DIR}/Qt5CLucene.dll ${QT_BIN_DIR}/Qt5PrintSupport.dll ${QT_BIN_DIR}/Qt5WebKitWidgets.dll DESTINATION ${CMAKE_INSTALL_PREFIX}/${CANORUS_INSTALL_BIN_DIR} ) # Install qsvg plugin for rendering SVG icons get_target_property(QSvgIcon_loc Qt5::QSvgIconPlugin LOCATION) Modified: trunk/src/control/helpctl.cpp =================================================================== --- trunk/src/control/helpctl.cpp 2016-04-23 21:46:37 UTC (rev 1461) +++ trunk/src/control/helpctl.cpp 2016-04-23 21:48:55 UTC (rev 1462) @@ -1,12 +1,11 @@ /*! - Copyright (c) 2009, Matevž Jekovec, Canorus development team + Copyright (c) 2009, 2016 Matevž Jekovec, Canorus development team All Rights Reserved. See AUTHORS for a complete list of authors. Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details. */ #include <QStringList> -#include <QHelpEngine> #include <QDockWidget> #include "canorus.h" @@ -22,60 +21,72 @@ /*! Initializes Help and loads User's guide. */ -CAHelpCtl::CAHelpCtl() - : _helpEngine(0) { - QString lang = usersGuideLanguage(); - - if (!lang.isEmpty()) { - _helpEngine = new QHelpEngine( QFileInfo("doc:usersguide/"+lang+".qhc").absoluteFilePath() ); - } +CAHelpCtl::CAHelpCtl() { + _homeUrl = detectHomeUrl(); } CAHelpCtl::~CAHelpCtl() { } /*! - Helper function which returns the existent User's guide language. + Helper function which returns the preferred User's guide language. */ -QString CAHelpCtl::usersGuideLanguage() { - if ( QFileInfo("doc:usersguide/"+QLocale::system().name()+".qhc").exists() ) { - return QLocale::system().name(); - } else - if ( QFileInfo("doc:usersguide/"+QLocale::system().name().left(2)+".qhc").exists() ) { - return QLocale::system().name().left(2); - } else - if ( QFileInfo("doc:usersguide/en.qhc").exists() ) { - return "en"; - } else { - return ""; +QUrl CAHelpCtl::detectHomeUrl() { + QUrl url; + QFileInfo i; + + i=QFileInfo("doc:usersguide2/build/"+QLocale::system().name()+"/index.html"); + + if ( !i.exists() ) { + i=QFileInfo("doc:usersguide2/"+QLocale::system().name()+"/index.html"); } + + if ( !i.exists() ) { + i=QFileInfo("doc:usersguide2/build/"+QLocale::system().name().left(2)+"/index.html"); + } + + if ( !i.exists() ) { + i=QFileInfo("doc:usersguide2/"+QLocale::system().name().left(2)+"/index.html"); + } + + if ( !i.exists() ) { + i=QFileInfo("doc:usersguide2/build/en/index.html"); + } + + if ( !i.exists() ) { + i=QFileInfo("doc:usersguide2/en/index.html"); + } + + if ( i.exists() ) { + url = QUrl::fromLocalFile(i.absoluteFilePath()); + } + + return url; } /*! - Loads user's guide file + Show user's guide at the given chapter. + + \return True, if a user's guide was found and shown; False otherwise. */ -void CAHelpCtl::showUsersGuide( QString chapter, QWidget *helpWidget ) { - QUrl url; - - if (!_helpEngine) { - return; +bool CAHelpCtl::showUsersGuide( QString chapter, QWidget *helpWidget ) { + QUrl url = _homeUrl; + + if (!chapter.isEmpty()) { + url.setFragment(chapter); } - - if (chapter.isEmpty()) { - if (!usersGuideLanguage().isEmpty()) - url = "qthelp://canorus/usersguide-"+usersGuideLanguage()+"/"+usersGuideLanguage()+".html"; - else - return; - } else { - QMap<QString, QUrl> links = _helpEngine->linksForIdentifier(chapter); - if (links.count()) { - url = links.constBegin().value(); - } + + if (!url.path().isEmpty()) { + displayHelp( url, helpWidget ); + return true; } - - displayHelp( url, helpWidget ); + + return false; } +/*! + Activates the user's guide help at the given url. + */ void CAHelpCtl::displayHelp( QUrl url, QWidget *helpWidget ) { CAHelpBrowser *browser=0; if ( !helpWidget ) { @@ -88,7 +99,6 @@ } if (browser) { - browser->setHelpEngine( _helpEngine ); - browser->setSource( url ); + browser->setUrl( url ); } } Modified: trunk/src/control/helpctl.h =================================================================== --- trunk/src/control/helpctl.h 2016-04-23 21:46:37 UTC (rev 1461) +++ trunk/src/control/helpctl.h 2016-04-23 21:48:55 UTC (rev 1462) @@ -1,5 +1,5 @@ /*! - Copyright (c) 2009, Matevž Jekovec, Canorus development team + Copyright (c) 2009, 2016 Matevž Jekovec, Canorus development team All Rights Reserved. See AUTHORS for a complete list of authors. Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details. @@ -19,13 +19,13 @@ CAHelpCtl(); virtual ~CAHelpCtl(); - void showUsersGuide( QString chapter="", QWidget *helpWidget=0 ); + bool showUsersGuide( QString chapter="", QWidget *helpWidget=0 ); private: + QUrl _homeUrl; + + QUrl detectHomeUrl(); void displayHelp( QUrl url, QWidget *helpWidget ); - QString usersGuideLanguage(); - - QHelpEngine *_helpEngine; }; #endif /* HELPCTL_H_ */ Modified: trunk/src/ui/mainwin.cpp =================================================================== --- trunk/src/ui/mainwin.cpp 2016-04-23 21:46:37 UTC (rev 1461) +++ trunk/src/ui/mainwin.cpp 2016-04-23 21:48:55 UTC (rev 1462) @@ -581,6 +581,7 @@ // User's guide and other Help uiHelpDock = new QDockWidget(tr("Help"), this); uiHelpDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); + uiHelpDock->setMaximumWidth(400); uiHelpWidget = new CAHelpBrowser( uiHelpDock ); uiHelpDock->setWidget( uiHelpWidget ); @@ -4195,7 +4196,7 @@ } void CAMainWin::on_uiUsersGuide_triggered() { - CACanorus::help()->showUsersGuide( "", this ); + CACanorus::help()->showUsersGuide( "playback", this ); } void CAMainWin::on_uiAboutQt_triggered() { Modified: trunk/src/widgets/helpbrowser.cpp =================================================================== --- trunk/src/widgets/helpbrowser.cpp 2016-04-23 21:46:37 UTC (rev 1461) +++ trunk/src/widgets/helpbrowser.cpp 2016-04-23 21:48:55 UTC (rev 1462) @@ -1,40 +1,20 @@ /*! Copyright (c) 2009, Itay Perl, Canorus development team + Copyright (c) 2016, Matevž Jekovec, Canorus development team All Rights Reserved. See AUTHORS for a complete list of authors. Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details. */ -#include <QHelpEngine> -#include <QDesktopServices> #include "widgets/helpbrowser.h" +#include <QFile> +#include <QTextStream> - -CAHelpBrowser::CAHelpBrowser(QWidget* parent, QHelpEngine *helpEngine) - : QTextBrowser(parent), _helpEngine(helpEngine) +CAHelpBrowser::CAHelpBrowser(QWidget* parent) +#if QT_VERSION >= 0x050500 + : QWebEngineView(parent) +#else + : QWebView(parent) +#endif { } - -/*! - Open network URLs in an external browser, without changing the QTextBrowser source. -*/ - -void CAHelpBrowser::setSource(const QUrl& url) -{ - if (url.scheme() == "http" || url.scheme() == "https" || url.scheme() == "mailto") - QDesktopServices::openUrl(url); - else - QTextBrowser::setSource(url); -} - -/*! - Handle qthelp URLs correctly. -*/ - -QVariant CAHelpBrowser::loadResource(int type, const QUrl& url) { - if( url.scheme() == "qthelp" && _helpEngine ) { - return QVariant(_helpEngine->fileData(url)); - } else { - return QTextBrowser::loadResource(type, url); - } -} Modified: trunk/src/widgets/helpbrowser.h =================================================================== --- trunk/src/widgets/helpbrowser.h 2016-04-23 21:46:37 UTC (rev 1461) +++ trunk/src/widgets/helpbrowser.h 2016-04-23 21:48:55 UTC (rev 1462) @@ -1,5 +1,6 @@ /*! Copyright (c) 2009, Itay Perl, Canorus development team + Copyright (c) 2016, Matevž Jekovec, Canorus development team All Rights Reserved. See AUTHORS for a complete list of authors. Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details. @@ -8,20 +9,25 @@ #ifndef HELPBROWSER_H_ #define HELPBROWSER_H_ -#include <QTextBrowser> -class QHelpEngine; +//#include <QTextBrowser> +#if QT_VERSION >= 0x050500 +#include <QWebEngineView> +#else +#include <QWebView> +#endif -class CAHelpBrowser : public QTextBrowser { +class CAHelpBrowser +#if QT_VERSION >= 0x050500 +: public QWebEngineView +#else +: public QWebView +#endif +{ +//class CAHelpBrowser : public QTextBrowser { Q_OBJECT public: - CAHelpBrowser(QWidget* parent = 0, QHelpEngine *helpEngine = 0); + CAHelpBrowser(QWidget* parent = 0); ~CAHelpBrowser() {} - QVariant loadResource(int type, const QUrl& url); - void setSource(const QUrl& url); - inline void setHelpEngine(QHelpEngine* helpEngine) { _helpEngine = helpEngine; } - inline QHelpEngine* helpEngine() { return _helpEngine; } - private: - QHelpEngine* _helpEngine; }; #endif /* HELPBROWSER_H_ */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |