diff --git a/Mainpage.dox b/Mainpage.dox --- a/Mainpage.dox +++ b/Mainpage.dox @@ -24,7 +24,7 @@ have the following components: \li \ref Shell - \li \ref Part + \li \ref Okular::Part \li \ref Okular::Document Class \li \ref Okular::Generator @@ -52,8 +52,9 @@ \li FictionBook Format \li Plucker Format \li OpenDocument Text Format - \li Microsofts CHM Format - \li Microsofts XML Document Format + \li Microsoft's CHM Format + \li Microsoft's XML Document Format + \li Markdown Format Now the questions is how can these various formats be represented in a unified way? Okular provides features like rotation, text search and extraction, zooming and many more, so how @@ -197,14 +198,7 @@ #include "magicgenerator.h" -static KAboutData createAboutData() -{ - KAboutData aboutData(...); - // fill the about data - return aboutData; -} - -OKULAR_EXPORT_PLUGIN(MagicGenerator, createAboutData()) +OKULAR_EXPORT_PLUGIN(MagicGenerator, "libokularGenerator_magic.json") MagicGenerator::MagicGenerator( QObject *parent, const QVariantList &args ) : Okular::Generator( parent, args ) @@ -282,99 +276,160 @@ So now you have the code of a working Okular Generator, the next step is to tell Okular about the new plugin. Like in other places in KDE that is done by .desktop files, which are installed to the services directory. -Every Generator needs 3 .desktop files: +Every Generator needs 1 .json, 3 .desktop files, and 1 .xml file: - \li libokularGenerator_<name>.desktop + \li libokularGenerator_<name>.json \li okularApplication_<name>.desktop \li okular<name>.desktop + \li org.kde.mobile.okular_<name>.desktop + \li org.kde.okular-<name>.metainfo.xml where <name> should be the name of the document format. So for our Magic Document Generator we -create the following 3 files: +create the following 4 files: - \li libokularGenerator_magic.desktop + \li libokularGenerator_magic.json \li okularApplication_magic.desktop \li okularMagic.desktop + \li org.kde.mobile.okular_magic.desktop + \li org.kde.okular-magic.metainfo.xml -with the following content: +where libokularGenerator_magic.json has the following content something like this \verbatim -[Desktop Entry] -Type=Service -Name=Magic Document -Comment=Magic Document backend for okular -ServiceTypes=okular/Generator -MimeType=application/x-magic; -X-KDE-Library=okularGenerator_magic -X-KDE-Priority=1 -X-KDE-okularAPIVersion=1 -X-KDE-okularHasInternalSettings=false +{ + "KPlugin": { + "Authors": [ + { + "Email": "author@hosting.suffix", + "Name": "Proud Author", + } + ], + "Copyright": "© 2042 Proud Author", + "Id": "okular_magic", + "License": "GPL", + "MimeTypes": [ + "text/magic", + "text/x-magic" + ], + "Name": "Magic Backend", + "ServiceTypes": [ + "okular/Generator" + ], + "Version": "0.1.0" + }, + "X-KDE-Priority": 1, + "X-KDE-okularAPIVersion": 1, + "X-KDE-okularHasInternalSettings": true +} \endverbatim -The first 6 fields are standard .desktop entries, the fields afterwards have a special meaning to Okular +The last five fields has the special meaning to Okular \li ServiceType Must be 'okular/Generator' for all Okular Generator Plugins \li MimeType The mimetype or list of mimetypes of the supported document format(s) - \li X-KDE-Library The name of the plugin library \li X-KDE-Priority When multiple Generators for the same mimetype exists, the one with the highest priority is used \li X-KDE-okularAPIVersion The version of the Generator Plugin API ('1' currently) \li X-KDE-okularHasInternalSettings Is 'true' when the Generator provides configuration dialogs -The second .desktop file has the following content: +The first .desktop file has the following content: \verbatim [Desktop Entry] MimeType=application/x-magic; Terminal=false Name=okular GenericName=Document Viewer -Exec=okular %U %i +Exec=okular %U Icon=okular Type=Application InitialPreference=7 Categories=Qt;KDE;Graphics;Viewer; NoDisplay=true +X-KDE-Keywords=Magic \endverbatim You can use the file as it is, you just have to adapt the mimetype. This file is needed to allow Okular to handle multiple mimetypes. -The third .desktop file looks like this: +The second .desktop file looks like this: \verbatim [Desktop Entry] Icon=okular Name=okular -ServiceTypes=KParts/ReadOnlyPart +X-KDE-ServiceTypes=KParts/ReadOnlyPart X-KDE-Library=okularpart Type=Service MimeType=application/x-magic; \endverbatim +where + + \li X-KDE-Library The name of the plugin library + You can use the file as it is as well, you just have to adapt the mimetype. This file is needed to allow the Okular part to handle multiple mimetypes. +The third .desktop file contains data for the mobile version + +\verbatim +[Desktop Entry] +MimeType=application/x-magic; +Name=Reader +GenericName=Document viewer +Comment=Viewer for various types of documents +TryExec=kpackagelauncherqml -a org.kde.mobile.okular +Exec=kpackagelauncherqml -a org.kde.mobile.okular %u +Terminal=false +Icon=okular +Type=Application +Categories=Qt;KDE;Graphics;Office;Viewer; +InitialPreference=2 +NoDisplay=true +X-KDE-Keywords=Magic +\endverbatim + +And the last .xml file has the following content + +\verbatim + + + org.kde.okular-md + org.kde.okular.desktop + CC0-1.0 + GPL-2.0+ and GFDL-1.3 + Magic + Adds support for reading Magic documents + + application/magic + + https://okular.kde.org + +\endverbatim + The last piece you need for a complete Generator is a CMakeLists.txt which compiles and installs the Generator. Our CMakeLists.txt looks like the following: \verbatim +add_definitions(-DTRANSLATION_DOMAIN="okular_magic") + macro_optional_find_package(Okular) -include_directories( ${OKULAR_INCLUDE_DIR} ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} ) +include_directories( ${OKULAR_INCLUDE_DIR} ${KF5_INCLUDE_DIR} ${QT_INCLUDES} ) ########### next target ############### -set( okularGenerator_magic_SRCS generator_magic.cpp ) - -kde4_add_plugin( okularGenerator_magic ${okularGenerator_magic_SRCS} ) +set( okularGenerator_magic_PART_SRCS generator_magic.cpp ) -target_link_libraries( okularGenerator_magic ${OKULAR_LIBRARIES} ${KDE4_KDEUI_LIBS} ) +target_link_libraries( okularGenerator_magic PRIVATE okularcore KF5::I18n KF5::KIOCore ) install( TARGETS okularGenerator_magic DESTINATION ${PLUGIN_INSTALL_DIR} ) ########### install files ############### -install( FILES libokularGenerator_magic.desktop okularMagic.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) -install( FILES okularApplication_magic.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) +install( FILES okularMagic.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) +install( PROGRAMS okularApplication_magic.desktop org.kde.mobile.okular_magic.desktop DESTINATION ${KDE_INSTALL_APPDIR} ) +install( FILES org.kde.okular-magic.metainfo.xml DESTINATION ${KDE_INSTALL_METAINFODIR} ) \endverbatim The macro_optional_find_package(Okular) call is required to make the ${OKULAR_INCLUDE_DIR} and ${OKULAR_LIBRARIES} @@ -676,7 +731,7 @@ \endcode The Generator doesn't support text search and selection, as the code would be quite complex, we'll show -how to do it in the next chapter \ref okular_generators_textdocument anyway. +how to do it in the next chapter (not yet written) anyway. As you can see we have 5 new methods in the class: @@ -693,22 +748,16 @@ \code #include #include - #include #include #include #include "htmlgenerator.h" -static KAboutData createAboutData() -{ - KAboutData aboutData(...); - // fill the about data - return aboutData; -} +#include -OKULAR_EXPORT_PLUGIN(HTMLGenerator, createAboutData()) +OKULAR_EXPORT_PLUGIN(HTMLGenerator, "libokularGenerator_html.json") HTMLGenerator::HTMLGenerator( QObject *parent, const QVariantList &args ) : Okular::Generator( parent, args ), diff --git a/core/generator.h b/core/generator.h --- a/core/generator.h +++ b/core/generator.h @@ -205,7 +205,7 @@ */ enum GeneratorFeature { - Threaded, + Threaded, ///< Whether the Generator supports asynchronous generation of pictures or text pages TextExtraction, ///< Whether the Generator can extract text from the document in the form of TextPage's ReadRawData, ///< Whether the Generator can read a document directly from its raw data. FontInfo, ///< Whether the Generator can provide information about the fonts used in the document @@ -379,7 +379,7 @@ /** * Returns whether the given @p action is allowed in the document. - * @see @ref Permission + * @see @ref Okular::Permission */ virtual bool isAllowed( Permission action ) const; diff --git a/core/global.h b/core/global.h --- a/core/global.h +++ b/core/global.h @@ -12,6 +12,12 @@ #include +/** + * \namespace Okular global.h + * + * \brief The documentation to the global Okular namespace. + */ + namespace Okular { /** diff --git a/ui/bookmarklist.cpp b/ui/bookmarklist.cpp --- a/ui/bookmarklist.cpp +++ b/ui/bookmarklist.cpp @@ -124,6 +124,7 @@ m_searchLine = new KTreeWidgetSearchLine( this ); mainlay->addWidget( m_searchLine ); + m_searchLine->setPlaceholderText(i18n( "Filter bookmarks..." )); m_tree = new QTreeWidget( this ); mainlay->addWidget( m_tree ); diff --git a/ui/searchwidget.cpp b/ui/searchwidget.cpp --- a/ui/searchwidget.cpp +++ b/ui/searchwidget.cpp @@ -37,6 +37,7 @@ // 2. text line m_lineEdit = new SearchLineEdit( this, document ); m_lineEdit->setClearButtonEnabled( true ); + m_lineEdit->setPlaceholderText(i18n( "Filter pages..." )); m_lineEdit->setToolTip(i18n( "Enter at least 3 letters to filter pages" )); m_lineEdit->setSearchCaseSensitivity( Qt::CaseInsensitive ); m_lineEdit->setSearchMinimumLength( 3 ); diff --git a/ui/side_reviews.cpp b/ui/side_reviews.cpp --- a/ui/side_reviews.cpp +++ b/ui/side_reviews.cpp @@ -117,6 +117,7 @@ m_view->setModel( m_authorProxy ); m_searchLine = new KTreeViewSearchLine( this, m_view ); + m_searchLine->setPlaceholderText(i18n( "Filter annotations..." )); m_searchLine->setCaseSensitivity( Okular::Settings::self()->reviewsSearchCaseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive ); m_searchLine->setRegularExpression( Okular::Settings::self()->reviewsSearchRegularExpression() ); connect(m_searchLine, &KTreeViewSearchLine::searchOptionsChanged, this, &Reviews::saveSearchOptions); diff --git a/ui/toc.cpp b/ui/toc.cpp --- a/ui/toc.cpp +++ b/ui/toc.cpp @@ -17,6 +17,7 @@ #include #include +#include // local includes #include "ktreeviewsearchline.h" @@ -34,6 +35,7 @@ m_searchLine = new KTreeViewSearchLine( this ); mainlay->addWidget( m_searchLine ); + m_searchLine->setPlaceholderText(i18n( "Filter table of contents..." )); m_searchLine->setCaseSensitivity( Okular::Settings::self()->contentsSearchCaseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive ); m_searchLine->setRegularExpression( Okular::Settings::self()->contentsSearchRegularExpression() ); connect(m_searchLine, &KTreeViewSearchLine::searchOptionsChanged, this, &TOC::saveSearchOptions);