├── CMakeLists.txt ├── COPYING ├── ChangeLog ├── DBUS-bindings ├── FAQ ├── FindLibchm.cmake ├── README ├── build-release.sh ├── build-win32-mingw.sh ├── build-windows.bat ├── kchmviewer.pro ├── lib ├── lib.pro └── libebook │ ├── CMakeLists.txt │ ├── bitfiddle.h │ ├── ebook.cpp │ ├── ebook.h │ ├── ebook_chm.cpp │ ├── ebook_chm.h │ ├── ebook_chm_encoding.cpp │ ├── ebook_chm_encoding.h │ ├── ebook_epub.cpp │ ├── ebook_epub.h │ ├── ebook_search.cpp │ ├── ebook_search.h │ ├── ebook_url.h │ ├── helper_entitydecoder.cpp │ ├── helper_entitydecoder.h │ ├── helper_search_index.cpp │ ├── helper_search_index.h │ ├── helperxmlhandler_epubcontainer.cpp │ ├── helperxmlhandler_epubcontainer.h │ ├── helperxmlhandler_epubcontent.cpp │ ├── helperxmlhandler_epubcontent.h │ ├── helperxmlhandler_epubtoc.cpp │ ├── helperxmlhandler_epubtoc.h │ └── libebook.pro ├── nsis ├── create_installers.bat ├── installer.nsis ├── installer64.nsis ├── kchmviewer.exe.manifest └── license.txt ├── packages ├── CMakeLists.txt ├── kchmviewer.desktop ├── kchmviewer.png └── rpm.spec ├── po ├── CMakeLists.txt ├── kchmviewer.pot ├── kchmviewer_cs.po ├── kchmviewer_de.po ├── kchmviewer_fr.po ├── kchmviewer_hu.po ├── kchmviewer_it.po ├── kchmviewer_nl.po ├── kchmviewer_pt_BR.po ├── kchmviewer_ru.po ├── kchmviewer_sv.po ├── kchmviewer_tr.po ├── kchmviewer_uk.po ├── kchmviewer_zh_CN.po ├── kchmviewer_zh_TW.po └── update_translations.sh ├── portable.txt ├── src ├── CMakeLists.txt ├── checknewversion.cpp ├── checknewversion.h ├── config.cpp ├── config.h ├── dataprovider_qwebengine.cpp ├── dataprovider_qwebengine.h ├── dataprovider_qwebkit.cpp ├── dataprovider_qwebkit.h ├── dbus_interface.cpp ├── dbus_interface.h ├── dialog_about.ui ├── dialog_chooseurlfromlist.cpp ├── dialog_chooseurlfromlist.h ├── dialog_setup.cpp ├── dialog_setup.h ├── dialog_setup.ui ├── dialog_topicselector.ui ├── kchmviewerapp.cpp ├── kchmviewerapp.h ├── kde-qt.cpp ├── kde-qt.h ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── navigationpanel.cpp ├── navigationpanel.h ├── navigatorpanel.ui ├── recentfiles.cpp ├── recentfiles.h ├── resources │ ├── Info.plist │ ├── addtab.png │ ├── chm_icons │ │ ├── icon_0.png │ │ ├── icon_1.png │ │ ├── icon_10.png │ │ ├── icon_11.png │ │ ├── icon_12.png │ │ ├── icon_13.png │ │ ├── icon_14.png │ │ ├── icon_15.png │ │ ├── icon_16.png │ │ ├── icon_17.png │ │ ├── icon_18.png │ │ ├── icon_19.png │ │ ├── icon_2.png │ │ ├── icon_20.png │ │ ├── icon_21.png │ │ ├── icon_22.png │ │ ├── icon_23.png │ │ ├── icon_24.png │ │ ├── icon_25.png │ │ ├── icon_26.png │ │ ├── icon_27.png │ │ ├── icon_28.png │ │ ├── icon_29.png │ │ ├── icon_3.png │ │ ├── icon_30.png │ │ ├── icon_31.png │ │ ├── icon_32.png │ │ ├── icon_33.png │ │ ├── icon_34.png │ │ ├── icon_35.png │ │ ├── icon_36.png │ │ ├── icon_37.png │ │ ├── icon_38.png │ │ ├── icon_39.png │ │ ├── icon_4.png │ │ ├── icon_40.png │ │ ├── icon_41.png │ │ ├── icon_5.png │ │ ├── icon_6.png │ │ ├── icon_7.png │ │ ├── icon_8.png │ │ └── icon_9.png │ ├── closetab.png │ ├── dryicon_process.png │ ├── dryicons_replace.png │ ├── dryicons_save.png │ ├── dryicons_window.png │ ├── find_close.png │ ├── find_next.png │ ├── find_previous.png │ ├── find_wrap.png │ ├── icon_add_bookmark.png │ ├── icon_back.png │ ├── icon_copy.png │ ├── icon_find.png │ ├── icon_find_next.png │ ├── icon_find_prev.png │ ├── icon_font_decrease.png │ ├── icon_font_increase.png │ ├── icon_forward.png │ ├── icon_home.png │ ├── icon_locate_in_content.png │ ├── icon_next_page.png │ ├── icon_open_file.png │ ├── icon_prev_page.png │ ├── icon_print.png │ ├── icon_view_source.png │ ├── images.qrc │ ├── images.qrc~ │ ├── kchmviewer.icns │ └── kchmviewer.png ├── settings.cpp ├── settings.h ├── src.pro ├── tab_bookmarks.cpp ├── tab_bookmarks.h ├── tab_bookmarks.ui ├── tab_contents.cpp ├── tab_contents.h ├── tab_contents.ui ├── tab_index.cpp ├── tab_index.h ├── tab_index.ui ├── tab_search.cpp ├── tab_search.h ├── tab_search.ui ├── textencodings.cpp ├── textencodings.h ├── toolbareditor.cpp ├── toolbareditor.h ├── toolbareditor.ui ├── toolbarmanager.cpp ├── toolbarmanager.h ├── treeitem_index.cpp ├── treeitem_index.h ├── treeitem_toc.cpp ├── treeitem_toc.h ├── version.h ├── viewwindow.h ├── viewwindow_webengine.cpp ├── viewwindow_webengine.h ├── viewwindow_webkit.cpp ├── viewwindow_webkit.h ├── viewwindowmgr.cpp ├── viewwindowmgr.h └── window_browser.ui ├── templates ├── cpp └── h └── tests └── autotest.sh /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project name 2 | PROJECT( kchmviewer ) 3 | 4 | # Init cmake 5 | set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/") 6 | 7 | # Necessary packages 8 | FIND_PACKAGE( KDE4 REQUIRED ) 9 | FIND_PACKAGE( Libchm REQUIRED) 10 | 11 | # libzip 12 | FIND_PATH(LIBZIP_INCLUDE_DIR zip.h) 13 | FIND_LIBRARY(LIBZIP_LIBRARY NAMES zip) 14 | 15 | IF (LIBZIP_INCLUDE_DIR AND LIBZIP_LIBRARY) 16 | MESSAGE(STATUS "Found libzip: ${LIBZIP_LIBRARY}") 17 | ELSE () 18 | MESSAGE(FATAL_ERROR "Could not find libzip. Please install libzip and libzip-devel packages") 19 | ENDIF () 20 | 21 | # Set compilation params 22 | INCLUDE_DIRECTORIES( ${KDE4_INCLUDES} 23 | ${CMAKE_SOURCE_DIR}/src 24 | ${CMAKE_SOURCE_DIR}/lib/libebook ) 25 | ADD_DEFINITIONS( ${KDE4_DEFINITIONS} ) 26 | ADD_DEFINITIONS( -DUSE_KDE ) 27 | 28 | # Run in those subdirectories 29 | ADD_SUBDIRECTORY( lib/libebook ) 30 | ADD_SUBDIRECTORY( src ) 31 | ADD_SUBDIRECTORY( po ) 32 | ADD_SUBDIRECTORY( packages ) 33 | -------------------------------------------------------------------------------- /DBUS-bindings: -------------------------------------------------------------------------------- 1 | kchmviewer supports the following DBUS bindings: 2 | 3 | Interface path: net.kchmviewer.application 4 | 5 | Bingings: 6 | 7 | // Loads a CHM file filename , and opens the URL url. Use URL "/" to open default homepage 8 | void loadHelpFile( String filename, String url ); 9 | 10 | // Opens a specific url inside the loaded CHM file 11 | void openPage( String url ); 12 | 13 | // Tries to find word in index, opening the index window and scrolling it there 14 | void guiFindInIndex( String word ); 15 | 16 | // Executes a search in GUI. query contains the complete search query. 17 | void guiSearchQuery( String query ); 18 | 19 | // Executes a search; GUI is not involved and user sees nothing. 20 | // query contains the complete search query. 21 | // Returns a list of URLs, or empty array if nothing os 22 | StringList searchQuery( String query ); 23 | -------------------------------------------------------------------------------- /FAQ: -------------------------------------------------------------------------------- 1 | *** PLEASE MAKE SURE YOU HAVE THE LATEST RELEASE FROM www.kchmviewer.net BEFORE SUBMITTING A BUG! *** 2 | 3 | 4 | *** Browsing: *** 5 | 6 | Q: The book body is not shown (empty screen) although table of contents is shown. What's wrong? 7 | 8 | A: QTextBrowser is very basic browser which cannot handle HTML in some modern books. Kchmviewer tries to fix the books with 9 | known quirks, but it does not always work. If the latest release does not work for you, try to use different internal browser 10 | by changing it in Settings using KHTMLPart or WebKit instead. 11 | 12 | 13 | Q: The book file contains spaces or non-English characters and it shows without any problem using QTextWidget browser, but when 14 | I use KHTMLPart browser, I cannot open it or go through internal links: 15 | 16 | A: You have either kio_chm installed, or previous version of kio_msits. 17 | To disable kio_chm, find the file chm.protocol in your KDE directory, and remove it. Then run kdeinit to reread the configuration. 18 | To find the old kio_msits, find the file kio_msits.so in your KDE directory, and remove it. Then recompile the application. 19 | 20 | 21 | Q: The book shows without any problem using QTextWidget browser, but when I use KHTMLPart browser, I get the following error: 22 | An error occurred while loading ms-its:/home/user/Symphony?FrameWork.chm::/index.html 23 | The?file?or?folder?ms-its:/home/user/Symphony?FrameWork.chm::/index.html?does?not?exist. 24 | 25 | A: You have kio_chm installed, and because it installs itself as KIO slave for ms-its, sometime KDE uses it instead of kio_msits. 26 | To disable it, find the file chm.protocol in your KDE directory, and remove it. Then run kdeinit or kdeinit4 to reread the configuration. 27 | 28 | 29 | Q: When I open CHM document, there is no "Contents" or "Index" tab. 30 | 31 | A: The files required for Content or Index tabs are not present in chm file. Therefore it is not possible to show those tabs. 32 | 33 | 34 | Q: I use KDE. Which browser is better to use - KHTMLPart or QTextBrowser? 35 | 36 | A: QTextBrowser was reported to be faster, except for multibyte languages (Japanese/Chinese/Korean). 37 | However KHTMLPart is obviously more standard-compliant. I use KHTMLPart. 4.0 version adds WebKit as well. 38 | 39 | 40 | Q: Font size increasing button does not increase the font size, just changes the font to bold once. 41 | 42 | A: Make sure you use resizeable (true type) fonts. The described behavior is expected when bitmap fonts are used, 43 | as their size could not be changed. Check your system configuration. 44 | 45 | 46 | *** Questions about search. *** 47 | 48 | Before version 3.0 is out there was only one search engine, which is still available in Advanced settings as "search engine based 49 | on internal CHM index". The following questions are only related to the old search engine, and are fixed in a new one. 50 | 51 | Q: Why my search for "for this" found no documents even though I know there are documents containing this phrase? 52 | Q: Why my search for "C++" or "argv[0]" found no documents even though I know there are documents containing this phrase? 53 | Q: Why the search tab is not shown? 54 | 55 | A: The search does not look through all the documents. Instead it uses the previously generated index stored in CHM file. If the index 56 | is not present in the file, the search is not possible. 57 | However the indexing procedure in Microsoft HTML Help Workshop does not index the symbols (except underscore), single letters 58 | and common words like for, this, to, do, etc. Therefore those words and symbols are not in index file, so search for "C++" 59 | will not be found. 60 | Also the the indexing procedure in Microsoft HTML Help Workshop brokes the ASCII characters which are outside 7-bit ASCII table. Therefore 61 | search using European/Russian letters often produces strange results, finding the pages with no search words present, and does not work 62 | with Asian langiages. 63 | 64 | The solution is new kchmviewer search engine. It is also index-based, but the index is generated by chmviewer. Every symbol is indexed, 65 | so seach for "C++" or "argv[0]" will find the appropriate code. It uses Unicode inside, so it has no problem with any language, including 66 | Japanese, Chinese and Korean. 67 | -------------------------------------------------------------------------------- /FindLibchm.cmake: -------------------------------------------------------------------------------- 1 | # Tries to find libchm 2 | 3 | FIND_PATH(LIBCHM_INCLUDE_DIR chm_lib.h /usr/include /usr/local/include) 4 | FIND_LIBRARY(LIBCHM_LIBRARY NAMES chm PATH /usr/lib /usr/local/lib) 5 | 6 | IF (LIBCHM_INCLUDE_DIR AND LIBCHM_LIBRARY) 7 | SET(LIBCHM_FOUND TRUE) 8 | ENDIF (LIBCHM_INCLUDE_DIR AND LIBCHM_LIBRARY) 9 | 10 | 11 | IF (LIBCHM_FOUND) 12 | IF (NOT Libchm_FIND_QUIETLY) 13 | MESSAGE(STATUS "Found libchm: ${LIBCHM_LIBRARY}") 14 | ENDIF (NOT Libchm_FIND_QUIETLY) 15 | ELSE (LIBCHM_FOUND) 16 | IF (Libchm_FIND_REQUIRED) 17 | MESSAGE(FATAL_ERROR "Could not find libchm. Please install chmlib-devel package (may be also called libchm-devel)") 18 | ENDIF (Libchm_FIND_REQUIRED) 19 | ENDIF (LIBCHM_FOUND) 20 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 1. OVERVIEW 2 | 3 | KchmViewer is a chm (MS HTML help file format) viewer, written in C++. Unlike most existing CHM viewers for Unix, it uses Trolltech Qt widget library, and does not depend on KDE or GNOME. It has full KDE4 support. 4 | 5 | The main advantage of KchmViewer is extended support for non-English languages. Unlike others, KchmViewer in most cases correctly detects chm file encoding, correctly shows tables of context of Russian, Korean, Chinese and Japanese help files. It also correctly searches text in non-English help files, including Korean, Chinese and Japanese. 6 | 7 | KchmViewer is written by Georgy Yunaev (gyunaev@ulduzsoft.com), and is licensed under GNU GPL license. Please do NOT use this email for bug reporting; see below. 8 | 9 | 10 | 2. FEATURES 11 | 12 | - Standalone viewer, depends on Qt4 only. Does not require KDE, GNOME or wxWidgets toolkit. 13 | - Could be optionally built with KDE4 support, using KHTML and KDE dialogs. 14 | - Completely safe and harmless. Does not support JavaScript in any way, optionally warns you before opening an external web page, or switching to another help file. 15 | - Correctly detects and shows encoding of any valid chm file. 16 | - Correctly shows non-English chm files, including Cyrillic, Chinese, Japanese and others. 17 | - Correctly searches in non-English chm files using chm built-in search index. 18 | - Shows an appropriate image for every TOC entry. 19 | - Has complete chm index support, including multiple index entries, cross-links and parent/child entries in index. 20 | - Persistent bookmarks support. Allows to store bookmarks even if "Favorites" window was not enabled for this chm file. Also stores the screen position for every bookmark. You can also edit/delete bookmarks. 21 | - For any opened chm file, stores the last opened window, search history, bookmark history, font size and so on, so when you open this file again, everything is always on the place. 22 | - Has easy and powerful search-in-page support. 23 | - Allows to increase or decrease the font size, so physically handicapped people can read texts easily. 24 | - Has standard Back/Forward/Home navigation. 25 | - Can print the opened pages on a standard printer (usually via CUPS). 26 | - Has complex search query support. You can use search queries like "lazy people" +learn -not. 27 | 28 | 29 | 3. INSTALLATION 30 | 31 | Usually kchmviewer is distributed in source code archive, so you need to compile it first. It requires Qt version 4.4 or higher. Note that you need to install qt4-devel and qt4-tools packages (the last one might be included in qt4-devel in your distribution), not just qt package. 32 | 33 | Also make sure you have chmlib-devel (some distros have it as libchm-devel) package installed. KDE build will check for its presence, but qmake does not have necessary functionality to do so. If you are getting errors regarding missing chm_lib.h file this means chmlib-devel is not installed. 34 | 35 | 36 | 3.1. Qt-only version 37 | 38 | To compile Qt-only version of kchmviewer, follow the procedure: 39 | 40 | > tar zxf kchmviewer-.tar.gz 41 | > cd kchmviewer- 42 | > qmake 43 | > make 44 | 45 | The compiled binary is in bin/kchmviewer. You could copy it somewhere, or use it as-is. It does not require installation. 46 | 47 | If QtWebKit module is not found, you will get the following error: 48 | 49 | > kchmviewwindow_qtwebkit.h:25:21: error: QWebView: No such file or directory 50 | 51 | then you need to install the QtWebKit module. 52 | 53 | 54 | 3.2 KDE4 version 55 | 56 | To compile the version of kchmviewer with KDE4 support, follow the procedure: 57 | 58 | > tar zxf kchmviewer-.tar.gz 59 | > mkdir build 60 | > cd build 61 | > cmake .. 62 | > make 63 | > sudo make install 64 | 65 | For KDE version the installation is required, since the KHTML KIO slave cannot be used in place. 66 | 67 | 68 | 4. USAGE 69 | 70 | Usage of kchmviewer is simple: 71 | 72 | kchmviewer mychmfile.chm 73 | 74 | for the rest of command-line options, see kchmviewer --help 75 | 76 | 77 | 5. BUG REPORTING 78 | 79 | Please use kchmviewer@ulduzsoft.com for bug reporting. 80 | 81 | 82 | 6. THANKS 83 | 84 | Thanks to: 85 | - Jed Wing, the author of chmlib. This library is used by kchmviewer to access chm content. 86 | - Razvan Cojocaru, the author of xchm. I used some ideas and chm processing code from xchm. 87 | - Peter Volkov for various bug reports and improvement suggestions. 88 | - All the users, who report bugs, and suggest features. You help making kchmviewer better. 89 | 90 | 7. LICENSE 91 | 92 | kchmviewer is distributed under GNU GPL license version 3. 93 | -------------------------------------------------------------------------------- /build-release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Export the source code 4 | BUILD_RPM64=1 5 | BUILD_RPM32=1 6 | BUILD_WINDOWS=1 7 | 8 | PACKAGE=kchmviewer 9 | BINARYFILE="bin/kchmviewer" 10 | 11 | FILE_VERSION="src/version.h" 12 | RPM_OUTDIR="/home/tim/rpmbuild/RPMS" 13 | 14 | # Get current version 15 | VERSION_MAJOR=`sed -n 's/^\#define\s\+APP_VERSION_MAJOR\s\+\([0-9a-z]\+\)/\1/p' $FILE_VERSION` 16 | VERSION_MINOR=`sed -n 's/^\#define\s\+APP_VERSION_MINOR\s\+\"\?\([0-9a-z]\+\)\"\?/\1/p' $FILE_VERSION` 17 | CURRENTVER="$VERSION_MAJOR.$VERSION_MINOR" 18 | 19 | BUILDDIR="$PACKAGE-$CURRENTVER" 20 | RELEASEDIR="release-$CURRENTVER" 21 | 22 | if [ -d "$BUILDDIR" ]; then 23 | rm -rf "$BUILDDIR" 24 | fi 25 | 26 | if [ -d "$RELEASEDIR" ]; then 27 | rm -rf "$RELEASEDIR" 28 | fi 29 | 30 | mkdir "$RELEASEDIR" || exit 1 31 | 32 | 33 | # Source package 34 | svn export . "$BUILDDIR/" || exit 1 35 | tar zcf "$RELEASEDIR/$PACKAGE-$CURRENTVER.tar.gz" $BUILDDIR || exit 1 36 | 37 | 38 | # Linux RPMs 39 | for target in qt5-32 qt5-64 qt4-64; do 40 | 41 | echo "Building for $target" 42 | rm -rf "$BUILDDIR" 43 | svn export . "$BUILDDIR/" || exit 1 44 | 45 | # Get the Qt version 46 | case $target in 47 | qt4-*) 48 | QMAKE=qmake 49 | QTLIBS="QtDBus QtXml QtGui QtCore QtNetwork QtWebKit" 50 | RPMSUFFIX="qt4" 51 | ;; 52 | 53 | qt5-*) 54 | QMAKE=qmake-qt5 55 | QTLIBS="Qt5WebKitWidgets Qt5PrintSupport Qt5WebKit Qt5Widgets Qt5Xml Qt5DBus Qt5Network Qt5Gui Qt5Core GL" 56 | RPMSUFFIX="qt5" 57 | ;; 58 | 59 | *) 60 | echo "Invalid target" 61 | exit 1 62 | esac 63 | 64 | # Get the arch 65 | case $target in 66 | *-32) 67 | QMAKESPEC="linux-g++-32" 68 | RPMARCH="i586" 69 | LINKLIBS="pthread chm zip $QTLIBS" 70 | 71 | ;; 72 | 73 | *-64) 74 | QMAKESPEC="linux-g++-64" 75 | RPMARCH="x86_64" 76 | ;; 77 | 78 | *) 79 | echo "Invalid arch" 80 | exit 1 81 | esac 82 | 83 | # Hack the libs 84 | if [ -n "$LINKLIBS" ]; then 85 | pushd $BUILDDIR 86 | 87 | # Link the libraries so the linker finds the 32-bit libs instead of 64-bit ones 88 | for lib in $LINKLIBS; do 89 | 90 | libpath=`find /lib /usr/lib/ -maxdepth 1 -name lib$lib.so | sort -r | head -n1` 91 | if [ -z "$libpath" ]; then 92 | libpath=`find /lib /usr/lib/ -maxdepth 1 -name lib$lib.so\.[0-9] | sort -r | head -n1` 93 | 94 | if [ -z "$libpath" ]; then 95 | echo "No library $lib found" 96 | exit 97 | fi 98 | fi 99 | 100 | ln -s $libpath "src/lib$lib.so" 101 | done 102 | popd 103 | fi 104 | 105 | # Build it 106 | (cd "$BUILDDIR" && $QMAKE -r -spec $QMAKESPEC "CONGIF+=release" && make -j4) || exit 1 107 | 108 | # Making the RPM root 109 | rm -rf "$BUILDDIR/buildroot" 110 | mkdir -p "$BUILDDIR/buildroot/usr/bin" 111 | mkdir -p "$BUILDDIR/buildroot/usr/share/applications" 112 | mkdir -p "$BUILDDIR/buildroot/usr/share/pixmaps" 113 | cp packages/*.desktop "$BUILDDIR/buildroot/usr/share/applications" 114 | cp packages/*.png "$BUILDDIR/buildroot/usr/share/pixmaps" 115 | strip --strip-all "$BUILDDIR/bin/kchmviewer" -o "$BUILDDIR/buildroot/usr/bin/kchmviewer" || exit 1 116 | 117 | # Prepare a spec file 118 | sed "s/^Version: [0-9.]\\+/Version: $CURRENTVER/" packages/rpm.spec > $BUILDDIR/rpm.spec 119 | 120 | # Build an RPM 121 | rpmbuild -bb --target=$RPMARCH --buildroot `pwd`"/$BUILDDIR/buildroot/" $BUILDDIR/rpm.spec || exit 1 122 | mv $RPM_OUTDIR/$RPMARCH/kchmviewer-$CURRENTVER-1.$RPMARCH.rpm "$RELEASEDIR/kchmviewer-$CURRENTVER-1.${RPMARCH}-${RPMSUFFIX}.rpm" || exit 1 123 | rm -rf "$BUILDDIR" 124 | done 125 | 126 | echo "Done! Version $CURRENTVER released!" 127 | 128 | -------------------------------------------------------------------------------- /build-win32-mingw.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Path to (cross-platform) mingw compiler 4 | MINGWPATH=/usr/toolchains/windows-x86-complete 5 | 6 | # We cannot build statically because Webkit is not statically linkable 7 | #QMAKE=$MINGWPATH/x86_64-w64-mingw32.static/qt4-shared/bin/qmake 8 | QMAKE=$MINGWPATH/i686-w64-mingw32.static/qt4-shared/bin/qmake 9 | #QMAKE=$MINGWPATH/qt4-static/bin/qmake 10 | 11 | BUILDDIR="build.win32" 12 | 13 | ################################## 14 | 15 | if [ -d "$BUILDDIR" ]; then 16 | rm -rf "$BUILDDIR" 17 | fi 18 | 19 | svn export . "$BUILDDIR/" || exit 1 20 | cd "$BUILDDIR" 21 | 22 | # Compile it 23 | export PATH=$MINGWPATH/bin:$PATH 24 | $QMAKE -r "CONFIG -= release_and_debug" "CONFIG += release" && make -j4 || exit 1 25 | 26 | if [ "x$1" == "x-nsis" ]; then 27 | (cd nsis && sh create_installer.sh) || exit 1 28 | fi 29 | 30 | -------------------------------------------------------------------------------- /build-windows.bat: -------------------------------------------------------------------------------- 1 | set NSISPATH="C:\Program Files (x86)\NSIS\" 2 | set VCPATH=C:\Program Files (x86)\VC 3 | 4 | :: Stores prebuilt chmlib and libzip 5 | set EXTRALIB=C:\Users\test\Documents\builder\extralibs 6 | 7 | set OLDPATH=%PATH% 8 | set BASEINCLUDE=%VCPATH%\include\;C:\Program Files (x86)\Windows Kits\8.1\Include\um\;C:\Program Files (x86)\Windows Kits\8.1\Include\shared 9 | 10 | rd /s /q build 11 | 12 | mkdir build\x86 13 | mkdir release\x86\ 14 | 15 | :: 32-bit 16 | cd build\x86 17 | 18 | PATH=%OLDPATH%;%VCPATH%\bin\;C:\Program Files (x86)\Windows Kits\8.0\bin\x86\;C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\; 19 | set LIB=%VCPATH%\lib\;C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86\;%EXTRALIB%\x86\lib 20 | set INCLUDE=%BASEINCLUDE%;%EXTRALIB%\x86\include 21 | set QTPATH=C:\Qt\Qt5.5.1-x86\5.5\msvc2013\bin 22 | 23 | %QTPATH%\qmake.exe -r ..\.. || exit 24 | "%VCPATH%\bin\nmake.exe" > build.log || exit 25 | 26 | :: Copy release files 27 | copy src\bin\kchmviewer.exe ..\..\release\x86\ || exit 28 | 29 | 30 | :: done 32-bit build 31 | cd ..\.. 32 | 33 | :: 64-bit 34 | mkdir build\x64 35 | mkdir release\x64\ 36 | 37 | cd build\x64 38 | 39 | PATH=%OLDPATH%;%VCPATH%\bin\amd64\;C:\Program Files (x86)\Windows Kits\8.0\bin\x64\;C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\; 40 | set LIB=%VCPATH%\lib\amd64\;C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64\;%EXTRALIB%\x64\lib; 41 | set INCLUDE=%BASEINCLUDE%;%EXTRALIB%\x64\include 42 | set QTPATH=C:\Qt\Qt5.5.1-x64\5.5\msvc2013_64\bin 43 | 44 | %QTPATH%\qmake.exe -r ..\.. || exit 45 | "%VCPATH%\bin\nmake.exe" > build.log || exit 46 | 47 | :: Copy release files 48 | copy src\bin\kchmviewer.exe ..\..\release\x64\ || exit 49 | 50 | :: done 64-bit build 51 | cd ..\.. 52 | 53 | :: Create the installers 54 | cd nsis 55 | create_installers.bat 56 | -------------------------------------------------------------------------------- /kchmviewer.pro: -------------------------------------------------------------------------------- 1 | SUBDIRS += lib src 2 | TEMPLATE = subdirs 3 | CONFIG += debug 4 | src.depends = lib 5 | -------------------------------------------------------------------------------- /lib/lib.pro: -------------------------------------------------------------------------------- 1 | SUBDIRS += libebook 2 | TEMPLATE = subdirs 3 | CONFIG += xml 4 | -------------------------------------------------------------------------------- /lib/libebook/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project files 2 | SET( libebookSources 3 | ebook_chm.cpp 4 | ebook_epub.cpp 5 | ebook.cpp 6 | ebook_chm_encoding.cpp 7 | ebook_search.cpp 8 | helper_entitydecoder.cpp 9 | helper_search_index.cpp 10 | helperxmlhandler_epubcontainer.cpp 11 | helperxmlhandler_epubcontent.cpp 12 | helperxmlhandler_epubtoc.cpp 13 | ) 14 | 15 | KDE4_ADD_LIBRARY( ebook STATIC ${libebookSources} ) 16 | 17 | -------------------------------------------------------------------------------- /lib/libebook/bitfiddle.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2003 Razvan Cojocaru 4 | Most of the code in this file is a modified version of code from 5 | Pabs' GPL chmdeco project, credits and thanks go to him. 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | 22 | */ 23 | 24 | 25 | inline unsigned short UINT16ARRAY( const void * x ) 26 | { 27 | unsigned char * p = (unsigned char *) x; 28 | return p[0] | (p[1] << 8); 29 | } 30 | 31 | inline unsigned int UINT32ARRAY( const void * x ) 32 | { 33 | unsigned char * p = (unsigned char *) x; 34 | return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); 35 | } 36 | 37 | inline int INT32ARRAY( const void * x ) 38 | { 39 | char * p = (char *) x; 40 | return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); 41 | } 42 | 43 | inline unsigned int get_int32_le( void *addr) 44 | { 45 | unsigned char *p = (unsigned char*) addr; 46 | return (unsigned int) ( p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24) ); 47 | } 48 | 49 | 50 | inline quint64 be_encint(unsigned char* buffer, size_t& length) 51 | { 52 | quint64 result = 0; 53 | int shift=0; 54 | length = 0; 55 | 56 | do { 57 | result |= ((*buffer) & 0x7f) << shift; 58 | shift += 7; 59 | ++length; 60 | 61 | } while (*(buffer++) & 0x80); 62 | 63 | return result; 64 | } 65 | 66 | 67 | /* 68 | Finds the first unset bit in memory. Returns the number of set bits found. 69 | Returns -1 if the buffer runs out before we find an unset bit. 70 | */ 71 | inline int ffus(unsigned char* byte, int* bit, size_t& length) 72 | { 73 | int bits = 0; 74 | length = 0; 75 | 76 | while(*byte & (1 << *bit)){ 77 | if(*bit) 78 | --(*bit); 79 | else { 80 | ++byte; 81 | ++length; 82 | *bit = 7; 83 | } 84 | ++bits; 85 | } 86 | 87 | if(*bit) 88 | --(*bit); 89 | else { 90 | ++length; 91 | *bit = 7; 92 | } 93 | 94 | return bits; 95 | } 96 | 97 | 98 | inline quint64 sr_int(unsigned char* byte, int* bit, 99 | unsigned char s, unsigned char r, size_t& length) 100 | { 101 | quint64 ret; 102 | unsigned char mask; 103 | int n, n_bits, num_bits, base, count; 104 | length = 0; 105 | size_t fflen; 106 | 107 | if(!bit || *bit > 7 || s != 2) 108 | return ~(quint64)0; 109 | ret = 0; 110 | 111 | count = ffus(byte, bit, fflen); 112 | length += fflen; 113 | byte += length; 114 | 115 | n_bits = n = r + (count ? count-1 : 0) ; 116 | 117 | while(n > 0) { 118 | num_bits = n > *bit ? *bit : n-1; 119 | base = n > *bit ? 0 : *bit - (n-1); 120 | 121 | switch(num_bits){ 122 | case 0: 123 | mask = 1; 124 | break; 125 | case 1: 126 | mask = 3; 127 | break; 128 | case 2: 129 | mask = 7; 130 | break; 131 | case 3: 132 | mask = 0xf; 133 | break; 134 | case 4: 135 | mask = 0x1f; 136 | break; 137 | case 5: 138 | mask = 0x3f; 139 | break; 140 | case 6: 141 | mask = 0x7f; 142 | break; 143 | case 7: 144 | mask = 0xff; 145 | break; 146 | default: 147 | mask = 0xff; 148 | break; 149 | } 150 | 151 | mask <<= base; 152 | ret = (ret << (num_bits+1)) | 153 | (quint64)((*byte & mask) >> base); 154 | 155 | if( n > *bit ){ 156 | ++byte; 157 | ++length; 158 | n -= *bit+1; 159 | *bit = 7; 160 | } else { 161 | *bit -= n; 162 | n = 0; 163 | } 164 | } 165 | 166 | if(count) 167 | ret |= (quint64)1 << n_bits; 168 | 169 | return ret; 170 | } 171 | -------------------------------------------------------------------------------- /lib/libebook/ebook.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "ebook.h" 20 | #include "ebook_chm.h" 21 | #include "ebook_epub.h" 22 | 23 | const char * const INTERNAL_URL_SCHEME = "kchm"; 24 | 25 | EBook::EBook() 26 | { 27 | } 28 | 29 | 30 | EBook::~EBook() 31 | { 32 | } 33 | 34 | EBook * EBook::loadFile( const QString &archiveName ) 35 | { 36 | EBook_CHM * cbook = new EBook_CHM(); 37 | 38 | if ( cbook->load( archiveName ) ) 39 | return cbook; 40 | 41 | delete cbook; 42 | 43 | 44 | EBook_EPUB * ebook = new EBook_EPUB(); 45 | 46 | if ( ebook->load( archiveName ) ) 47 | return ebook; 48 | 49 | delete ebook; 50 | return 0; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /lib/libebook/ebook_chm_encoding.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef EBOOK_CHM_ENCODING_H 20 | #define EBOOK_CHM_ENCODING_H 21 | 22 | #include 23 | 24 | class Ebook_CHM_Encoding 25 | { 26 | public: 27 | static QString guessByLCID( unsigned short lcid ); 28 | }; 29 | 30 | #endif // EBOOK_CHM_ENCODING_H 31 | -------------------------------------------------------------------------------- /lib/libebook/ebook_search.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef EBookSearch_H 20 | #define EBookSearch_H 21 | 22 | #include 23 | #include "helper_search_index.h" 24 | 25 | class EBook; 26 | 27 | class EBookSearch : public QObject 28 | { 29 | Q_OBJECT 30 | 31 | public: 32 | EBookSearch(); 33 | ~EBookSearch(); 34 | 35 | //! Loads the search index from the data stream \param stream. 36 | //! The index should be previously saved with generateIndex(). 37 | bool loadIndex( QDataStream& stream ); 38 | 39 | //! Generates the search index from the opened CHM file \param chmFile, 40 | //! and saves it to the data stream \param stream which should be writeable. 41 | //! 42 | //! To show the progress, this procedure emits a progressStep() signal periodically 43 | //! with the value showing current progress in percentage (i.e. from 0 to 100) 44 | //! After signal emission, the following event processing function will be called: 45 | //! qApp->processEvents( QEventLoop::ExcludeUserInputEvents ) 46 | //! to make sure the dialogs (if any) are properly updated. 47 | //! 48 | //! If \param progressDls is not null, it will be used to display progress. 49 | //! Returns true if the index has been generated and saved, or false if internal 50 | //! error occurs, or (most likely) the cancelIndexGeneration() slot has been called. 51 | bool generateIndex( EBook * ebook, QDataStream& stream ); 52 | 53 | //! Executes the search query. The \param query is a string like "C++ language" class, 54 | //! \param results is a pointer to QStringList, and \param limit limits the number of 55 | //! results in case the query is too generic (like \a "a" ). 56 | //! The \param chmFile is used to get the current encoding information. 57 | //! The return value is false only if the index is not generated, or if a closing quote character 58 | //! is missing. Call hasIndex() to clarify. If search returns no results, the return value is 59 | //! true, but the \param results list will be empty. 60 | //! 61 | //! Note that the function does not clear \param results before adding search results, so if you are 62 | //! not merging search results, make sure it's empty. 63 | bool searchQuery ( const QString& query, QList< QUrl > * results, EBook * chmFile, unsigned int limit = 100 ); 64 | 65 | //! Returns true if a valid search index is present, and therefore search could be executed 66 | bool hasIndex() const; 67 | 68 | signals: 69 | void progressStep( int value, const QString& stepName ); 70 | 71 | public slots: 72 | void cancelIndexGeneration(); 73 | 74 | private slots: 75 | void updateProgress( int value, const QString& stepName ); 76 | void processEvents(); 77 | 78 | private: 79 | QStringList m_keywordDocuments; 80 | QtAs::Index * m_Index; 81 | 82 | }; 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /lib/libebook/ebook_url.h: -------------------------------------------------------------------------------- 1 | #ifndef EBOOK_URL_H 2 | #define EBOOK_URL_H 3 | 4 | #include 5 | 6 | class EbookURL : public QUrl 7 | { 8 | public: 9 | EbookURL(); 10 | EbookURL( const QString & url ); 11 | }; 12 | 13 | #endif // EBOOK_URL_H 14 | -------------------------------------------------------------------------------- /lib/libebook/helper_entitydecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef HELPER_ENTITYDECODER_H 20 | #define HELPER_ENTITYDECODER_H 21 | 22 | #include 23 | #include 24 | 25 | // 26 | // This helper class decodes the Unicode HTML entities into the Unicode characters 27 | // 28 | class HelperEntityDecoder 29 | { 30 | public: 31 | // Initialization with the specific decoder 32 | HelperEntityDecoder( QTextCodec * encoder = 0 ); 33 | 34 | // Used when the encoding changes 35 | void changeEncoding( QTextCodec * encoder = 0 ); 36 | 37 | // The decoder function 38 | QString decode( const QString& entity ) const; 39 | 40 | private: 41 | // Map to decode HTML entitles like ´ based on current encoding, initialized upon the first use 42 | QMap m_entityDecodeMap; 43 | }; 44 | 45 | #endif // HELPER_ENTITYDECODER_H 46 | -------------------------------------------------------------------------------- /lib/libebook/helper_search_index.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef EBOOK_SEARCH_INDEX_H 20 | #define EBOOK_SEARCH_INDEX_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "helper_entitydecoder.h" 29 | 30 | 31 | class EBook; 32 | 33 | // This code is based on some pretty old version of Qt Assistant 34 | namespace QtAs 35 | { 36 | 37 | struct Document 38 | { 39 | Document( int d, int f ) : docNumber( d ), frequency( f ) {} 40 | Document() : docNumber( -1 ), frequency( 0 ) {} 41 | bool operator==( const Document &doc ) const 42 | { 43 | return docNumber == doc.docNumber; 44 | } 45 | 46 | bool operator<( const Document &doc ) const 47 | { 48 | return frequency > doc.frequency; 49 | } 50 | 51 | bool operator<=( const Document &doc ) const 52 | { 53 | return frequency >= doc.frequency; 54 | } 55 | 56 | bool operator>( const Document &doc ) const 57 | { 58 | return frequency < doc.frequency; 59 | } 60 | 61 | qint16 docNumber; 62 | qint16 frequency; 63 | }; 64 | 65 | QDataStream &operator>>( QDataStream &s, Document &l ); 66 | QDataStream &operator<<( QDataStream &s, const Document &l ); 67 | 68 | class Index : public QObject 69 | { 70 | Q_OBJECT 71 | public: 72 | 73 | Index(); 74 | 75 | void writeDict( QDataStream& stream ); 76 | bool readDict( QDataStream& stream ); 77 | bool makeIndex(const QList &docs, EBook * chmFile ); 78 | QList query( const QStringList&, const QStringList&, const QStringList&, EBook * chmFile ); 79 | QString getCharsSplit() const { return m_charssplit; } 80 | QString getCharsPartOfWord() const { return m_charsword; } 81 | 82 | signals: 83 | void indexingProgress( int, const QString& ); 84 | 85 | public slots: 86 | void setLastWinClosed(); 87 | 88 | private: 89 | struct Entry 90 | { 91 | Entry( int d ) { documents.append( Document( d, 1 ) ); } 92 | Entry( QVector l ) : documents( l ) {} 93 | QVector documents; 94 | }; 95 | 96 | struct PosEntry 97 | { 98 | PosEntry( int p ) { positions.append( p ); } 99 | QList positions; 100 | }; 101 | 102 | bool parseDocumentToStringlist( EBook * chmFile, const QUrl& filename, QStringList& tokenlist ); 103 | void insertInDict( const QString&, int ); 104 | 105 | QStringList getWildcardTerms( const QString& ); 106 | QStringList split( const QString& ); 107 | QList setupDummyTerm( const QStringList& ); 108 | bool searchForPhrases(const QStringList &phrases, const QStringList &words, const QUrl &filename, EBook * chmFile ); 109 | 110 | QList< QUrl > docList; 111 | QHash dict; 112 | QHashminiDict; 113 | bool lastWindowClosed; 114 | HelperEntityDecoder entityDecoder; 115 | 116 | // Those characters are splitters (i.e. split the word), but added themselves into dictionary too. 117 | // This makes the dictionary MUCH larger, but ensure that for the piece of "window->print" both 118 | // search for "print" and "->print" will find it. 119 | QString m_charssplit; 120 | 121 | // Those characters are parts of word - for example, '_' is here, and search for _debug will find only _debug. 122 | QString m_charsword; 123 | }; 124 | 125 | }; 126 | 127 | #endif // EBOOK_SEARCH_INDEX_H 128 | -------------------------------------------------------------------------------- /lib/libebook/helperxmlhandler_epubcontainer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "helperxmlhandler_epubcontainer.h" 20 | 21 | bool HelperXmlHandler_EpubContainer::startElement(const QString &, const QString &, const QString &qName, const QXmlAttributes &atts) 22 | { 23 | if ( qName == "rootfile" ) 24 | { 25 | int idx = atts.index( "full-path" ); 26 | 27 | if ( idx == -1 ) 28 | return false; 29 | 30 | contentPath = atts.value( idx ); 31 | } 32 | 33 | return true; 34 | } 35 | -------------------------------------------------------------------------------- /lib/libebook/helperxmlhandler_epubcontainer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef HELPERXMLHANDLER_EPUBCONTAINER_H 20 | #define HELPERXMLHANDLER_EPUBCONTAINER_H 21 | 22 | #include 23 | 24 | class HelperXmlHandler_EpubContainer : public QXmlDefaultHandler 25 | { 26 | public: 27 | // Overridden members 28 | bool startElement ( const QString & namespaceURI, const QString & localName, const QString & qName, const QXmlAttributes & atts ); 29 | 30 | // The content path 31 | QString contentPath; 32 | }; 33 | 34 | #endif // HELPERXMLHANDLER_EPUBCONTAINER_H 35 | -------------------------------------------------------------------------------- /lib/libebook/helperxmlhandler_epubcontent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "helperxmlhandler_epubcontent.h" 20 | 21 | HelperXmlHandler_EpubContent::HelperXmlHandler_EpubContent() 22 | { 23 | m_state = STATE_NONE; 24 | } 25 | 26 | bool HelperXmlHandler_EpubContent::startElement(const QString &, const QString &localName, const QString &, const QXmlAttributes &atts) 27 | { 28 | // tag contains the medatada which goes into m_metadata 29 | if ( localName == "metadata" ) 30 | m_state = STATE_IN_METADATA; 31 | else if ( localName == "manifest" ) 32 | m_state = STATE_IN_MANIFEST; 33 | else if ( localName == "spine" ) 34 | m_state = STATE_IN_SPINE; 35 | // Now handle the states 36 | else if ( m_state == STATE_IN_METADATA ) // we don't need to store the first 'metadata' here 37 | m_tagname = localName; 38 | else if ( m_state == STATE_IN_MANIFEST && localName == "item" ) 39 | { 40 | int idx_id = atts.index( "id" ); 41 | int idx_href = atts.index( "href" ); 42 | int idx_mtype = atts.index( "media-type" ); 43 | 44 | if ( idx_id == -1 || idx_href == -1 || idx_mtype == -1 ) 45 | return false; 46 | 47 | manifest[ atts.value( idx_id ) ] = atts.value( idx_href ); 48 | 49 | if ( atts.value( idx_mtype ) == "application/x-dtbncx+xml" ) 50 | tocname = atts.value( idx_href ); 51 | 52 | //qDebug() << "MANIFEST: " << atts.value( idx_id ) << "->" << atts.value( idx_href ); 53 | } 54 | else if ( m_state == STATE_IN_SPINE && localName == "itemref" ) 55 | { 56 | int idx = atts.index( "idref" ); 57 | 58 | if ( idx == -1 ) 59 | return false; 60 | 61 | spine.push_back( atts.value( idx ) ); 62 | //qDebug() << "SPINE: " << atts.value( idx ); 63 | } 64 | 65 | return true; 66 | } 67 | 68 | bool HelperXmlHandler_EpubContent::characters(const QString &ch) 69 | { 70 | if ( m_state == STATE_IN_METADATA && !m_tagname.isEmpty() && !ch.trimmed().isEmpty() ) 71 | { 72 | // Some metadata may be duplicated; we concantenate them with | 73 | if ( metadata.contains( m_tagname ) ) 74 | { 75 | metadata[ m_tagname ].append( "|" ); 76 | metadata[ m_tagname ].append( ch.trimmed() ); 77 | } 78 | else 79 | metadata[ m_tagname ] = ch.trimmed(); 80 | 81 | //qDebug() << "METATAG: " << m_tagname << " " << metadata[ m_tagname ]; 82 | } 83 | 84 | return true; 85 | } 86 | 87 | bool HelperXmlHandler_EpubContent::endElement(const QString &, const QString &, const QString &qName) 88 | { 89 | if ( qName == "manifest" || qName == "metadata" || qName == "spine" ) 90 | m_state = STATE_NONE; 91 | 92 | return true; 93 | } 94 | -------------------------------------------------------------------------------- /lib/libebook/helperxmlhandler_epubcontent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef HELPERXMLHANDLER_EPUBCONTENT_H 20 | #define HELPERXMLHANDLER_EPUBCONTENT_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | class HelperXmlHandler_EpubContent : public QXmlDefaultHandler 27 | { 28 | public: 29 | HelperXmlHandler_EpubContent(); 30 | 31 | // Keep the tag-associated metadata 32 | QMap< QString, QString > metadata; 33 | 34 | // Manifest storage, id -> href 35 | QMap< QString, QString > manifest; 36 | 37 | // Spline storage 38 | QList< QString > spine; 39 | 40 | // TOC (NCX) filename 41 | QString tocname; 42 | 43 | private: 44 | enum State 45 | { 46 | STATE_NONE, 47 | STATE_IN_METADATA, 48 | STATE_IN_MANIFEST, 49 | STATE_IN_SPINE 50 | }; 51 | 52 | bool startElement ( const QString & namespaceURI, const QString & localName, const QString & qName, const QXmlAttributes & atts ); 53 | bool characters(const QString &ch); 54 | bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName); 55 | 56 | // Tracking 57 | State m_state; 58 | QString m_tagname; 59 | }; 60 | 61 | #endif // HELPERXMLHANDLER_EPUBCONTENT_H 62 | -------------------------------------------------------------------------------- /lib/libebook/helperxmlhandler_epubtoc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | #include "helperxmlhandler_epubtoc.h" 21 | 22 | HelperXmlHandler_EpubTOC::HelperXmlHandler_EpubTOC(EBook_EPUB *epub) 23 | { 24 | m_epub = epub; 25 | m_inNavMap = false; 26 | m_inText = false; 27 | m_indent = 0; 28 | } 29 | 30 | bool HelperXmlHandler_EpubTOC::startElement(const QString &, const QString &localName, const QString &, const QXmlAttributes &atts) 31 | { 32 | // qDebug() << "startElement " << " " << localName; 33 | 34 | // for ( int i = 0; i < atts.count(); i++ ) 35 | // qDebug() << " " << atts.localName(i) << " " << atts.value(i); 36 | 37 | if ( localName == "navMap" ) 38 | { 39 | m_inNavMap = true; 40 | return true; 41 | } 42 | 43 | if ( !m_inNavMap ) 44 | return true; 45 | 46 | if ( localName == "navPoint" ) 47 | m_indent++; 48 | 49 | if ( localName == "text" ) 50 | m_inText = true; 51 | 52 | if ( localName == "content" ) 53 | { 54 | int idx = atts.index( "src" ); 55 | 56 | if ( idx == -1 ) 57 | return false; 58 | 59 | m_lastId = atts.value( idx ); 60 | checkNewTocEntry(); 61 | } 62 | 63 | return true; 64 | } 65 | 66 | bool HelperXmlHandler_EpubTOC::characters(const QString &ch) 67 | { 68 | // qDebug() << "characters" << " " << ch; 69 | if ( m_inText ) 70 | m_lastTitle = ch; 71 | 72 | checkNewTocEntry(); 73 | return true; 74 | } 75 | 76 | bool HelperXmlHandler_EpubTOC::endElement(const QString& , const QString &localName, const QString &) 77 | { 78 | // qDebug() << "endElement" << " " << qName; 79 | 80 | if ( localName == "navMap" ) 81 | { 82 | m_inNavMap = false; 83 | return true; 84 | } 85 | 86 | if ( localName == "navPoint" ) 87 | m_indent--; 88 | 89 | if ( localName == "text" ) 90 | m_inText = false; 91 | 92 | return true; 93 | } 94 | 95 | void HelperXmlHandler_EpubTOC::checkNewTocEntry() 96 | { 97 | if ( !m_lastId.isEmpty() && !m_lastTitle.isEmpty() ) 98 | { 99 | EBookTocEntry entry; 100 | entry.name = m_lastTitle; 101 | entry.url = m_epub->pathToUrl( m_lastId ); 102 | entry.iconid = EBookTocEntry::IMAGE_AUTO; 103 | entry.indent = m_indent - 1; 104 | 105 | entries.push_back( entry ); 106 | 107 | //qDebug() << "TOC entry: " << m_lastId << " :" << m_lastTitle << " :" << m_indent - 1; 108 | 109 | m_lastId.clear(); 110 | m_lastTitle.clear(); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /lib/libebook/helperxmlhandler_epubtoc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef HELPERXMLHANDLER_EPUBTOC_H 20 | #define HELPERXMLHANDLER_EPUBTOC_H 21 | 22 | #include 23 | #include "ebook_epub.h" 24 | 25 | class HelperXmlHandler_EpubTOC : public QXmlDefaultHandler 26 | { 27 | public: 28 | HelperXmlHandler_EpubTOC( EBook_EPUB * epub ); 29 | 30 | QList< EBookTocEntry > entries; 31 | 32 | private: 33 | // Overridden members 34 | bool startElement ( const QString & namespaceURI, const QString & localName, const QString & qName, const QXmlAttributes & atts ); 35 | bool characters(const QString &ch); 36 | bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName); 37 | void checkNewTocEntry(); 38 | 39 | bool m_inNavMap; 40 | bool m_inText; 41 | unsigned int m_indent; 42 | QString m_lastId; 43 | QString m_lastTitle; 44 | EBook_EPUB * m_epub; 45 | }; 46 | 47 | #endif // HELPERXMLHANDLER_EPUBTOC_H 48 | -------------------------------------------------------------------------------- /lib/libebook/libebook.pro: -------------------------------------------------------------------------------- 1 | HEADERS += bitfiddle.h \ 2 | ebook_chm.h \ 3 | ebook_epub.h \ 4 | ebook.h \ 5 | ebook_chm_encoding.h \ 6 | ebook_search.h \ 7 | helper_entitydecoder.h \ 8 | helper_search_index.h \ 9 | helperxmlhandler_epubcontainer.h \ 10 | helperxmlhandler_epubcontent.h \ 11 | helperxmlhandler_epubtoc.h 12 | SOURCES += \ 13 | ebook_chm.cpp \ 14 | ebook_epub.cpp \ 15 | ebook.cpp \ 16 | ebook_chm_encoding.cpp \ 17 | ebook_search.cpp \ 18 | helper_entitydecoder.cpp \ 19 | helper_search_index.cpp \ 20 | helperxmlhandler_epubcontainer.cpp \ 21 | helperxmlhandler_epubcontent.cpp \ 22 | helperxmlhandler_epubtoc.cpp 23 | TARGET = ebook 24 | CONFIG += warn_on \ 25 | qt \ 26 | staticlib 27 | TEMPLATE = lib 28 | INCLUDEPATH += ../../src 29 | QT += widgets 30 | 31 | # Only for Creator build 32 | #INCLUDEPATH += C:/Users/Test/Documents/builder/extralibs/x64/include 33 | -------------------------------------------------------------------------------- /nsis/create_installers.bat: -------------------------------------------------------------------------------- 1 | :: This bat file is used when building on Windows to create installers 2 | set NSIS="C:\Program Files (x86)\NSIS\makensis" 3 | 4 | mkdir build 5 | copy ..\release\x64\kchmviewer.exe build 6 | xcopy C:\Users\Test\Documents\redist-kchmviewer\x64 build /S /I 7 | copy installer64.nsis build\installer.nsis 8 | copy kchmviewer.exe.manifest build 9 | copy license.txt build 10 | cd build 11 | %NSIS% installer.nsis || exit 12 | copy InstallKchmViewer.exe ..\..\InstallKchmViewer-64bit.exe || exit 13 | cd .. 14 | rd /s /q build 15 | 16 | mkdir build 17 | copy ..\release\x86\kchmviewer.exe build 18 | xcopy C:\Users\Test\Documents\redist-kchmviewer\x86 build /S /I 19 | copy installer.nsis build 20 | copy kchmviewer.exe.manifest build 21 | copy license.txt build 22 | cd build 23 | %NSIS% installer.nsis || exit 24 | copy InstallKchmViewer.exe ..\..\InstallKchmViewer-32bit.exe || exit 25 | cd .. 26 | rd /s /q build 27 | -------------------------------------------------------------------------------- /nsis/installer.nsis: -------------------------------------------------------------------------------- 1 | ; NSIS script file 2 | 3 | ;-------------------------------- 4 | ;Include Modern UI 5 | 6 | !include "MUI.nsh" 7 | 8 | ;-------------------------------- 9 | ;General 10 | 11 | ; The icon for the installer. 12 | ; MUI_ICON icon_file 13 | 14 | ; The icon for the uninstaller. 15 | ; MUI_UNICON icon_file 16 | 17 | Name "KchmViewer" 18 | OutFile "InstallKchmViewer.exe" 19 | InstallDir "$PROGRAMFILES\Ulduzsoft\KchmViewer" 20 | InstallDirRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Ulduzsoft\KchmViewer" "" 21 | SetCompressor lzma 22 | 23 | ;-------------------------------- 24 | ;Variables 25 | 26 | Var MUI_TEMP 27 | Var STARTMENU_FOLDER 28 | 29 | ;-------------------------------- 30 | ;Interface Settings 31 | 32 | !define MUI_ABORTWARNING 33 | 34 | 35 | ;-------------------------------- 36 | ;Pages 37 | 38 | !insertmacro MUI_PAGE_WELCOME 39 | !insertmacro MUI_PAGE_LICENSE "license.txt" 40 | !insertmacro MUI_PAGE_DIRECTORY 41 | 42 | ;Start Menu Folder Page Configuration 43 | !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKEY_LOCAL_MACHINE 44 | !define MUI_STARTMENUPAGE_REGISTRY_KEY "SOFTWARE\Ulduzsoft\KchmViewer" 45 | !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" 46 | !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER 47 | 48 | !insertmacro MUI_PAGE_INSTFILES 49 | !insertmacro MUI_PAGE_FINISH 50 | 51 | ; Uninstaller pages 52 | !insertmacro MUI_UNPAGE_WELCOME 53 | !insertmacro MUI_UNPAGE_CONFIRM 54 | !insertmacro MUI_UNPAGE_INSTFILES 55 | !insertmacro MUI_UNPAGE_FINISH 56 | 57 | ;-------------------------------- 58 | ;Languages 59 | 60 | !insertmacro MUI_LANGUAGE "English" 61 | 62 | 63 | ;-------------------------------- 64 | ;Installer Sections 65 | 66 | Section "General" General 67 | SetOutPath "$INSTDIR" 68 | 69 | ; Our files 70 | CreateDirectory "$INSTDIR\imageformats" 71 | CreateDirectory "$INSTDIR\platforms" 72 | CreateDirectory "$INSTDIR\printsupport" 73 | File /oname=$INSTDIR\imageformats\qgif.dll imageformats\qgif.dll 74 | File /oname=$INSTDIR\imageformats\qico.dll imageformats\qico.dll 75 | File /oname=$INSTDIR\imageformats\qjpeg.dll imageformats\qjpeg.dll 76 | File /oname=$INSTDIR\imageformats\qsvg.dll imageformats\qsvg.dll 77 | File /oname=$INSTDIR\platforms\qwindows.dll platforms\qwindows.dll 78 | File /oname=$INSTDIR\printsupport\windowsprintersupport.dll printsupport\windowsprintersupport.dll 79 | File kchmviewer.exe 80 | File icudt54.dll 81 | File Qt5Multimedia.dll 82 | File Qt5Positioning.dll 83 | File Qt5Sensors.dll 84 | File Qt5WebKitWidgets.dll 85 | File icuin54.dll 86 | File kchmviewer.exe 87 | File Qt5MultimediaWidgets.dll 88 | File Qt5PrintSupport.dll 89 | File Qt5Sql.dll 90 | File Qt5Widgets.dll 91 | File icuuc54.dll 92 | File Qt5Core.dll 93 | File Qt5Network.dll 94 | File Qt5Qml.dll 95 | File Qt5WebChannel.dll 96 | File Qt5Xml.dll 97 | File Qt5Gui.dll 98 | File Qt5OpenGL.dll 99 | File Qt5Quick.dll 100 | File Qt5WebKit.dll 101 | File kchmviewer.exe.manifest 102 | File msvcp120.dll 103 | File msvcr120.dll 104 | File vccorlib120.dll 105 | 106 | ;Store installation folder 107 | WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Ulduzsoft\KchmViewer" "" "$INSTDIR" 108 | 109 | ;Create uninstaller 110 | WriteUninstaller "$INSTDIR\uninst.exe" 111 | 112 | !insertmacro MUI_STARTMENU_WRITE_BEGIN Application 113 | ;Create shortcuts 114 | CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" 115 | CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\kchmviewer.lnk" "$INSTDIR\kchmviewer.exe" 116 | CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\uninst.exe" 117 | !insertmacro MUI_STARTMENU_WRITE_END 118 | 119 | SectionEnd 120 | 121 | ;-------------------------------- 122 | ;Uninstaller Section 123 | 124 | Section "Uninstall" 125 | 126 | ; Our files 127 | Delete "$INSTDIR\imageformats\qgif.dll" 128 | Delete "$INSTDIR\imageformats\qico.dll" 129 | Delete "$INSTDIR\imageformats\qjpeg.dll" 130 | Delete "$INSTDIR\imageformats\qsvg.dll" 131 | Delete "$INSTDIR\platforms\qwindows.dll" 132 | Delete "$INSTDIR\printsupport\windowsprintersupport.dll" 133 | Delete "$INSTDIR\kchmviewer.exe" 134 | Delete "$INSTDIR\icudt54.dll" 135 | Delete "$INSTDIR\Qt5Multimedia.dll" 136 | Delete "$INSTDIR\Qt5Positioning.dll" 137 | Delete "$INSTDIR\Qt5Sensors.dll" 138 | Delete "$INSTDIR\Qt5WebKitWidgets.dll" 139 | Delete "$INSTDIR\icuin54.dll" 140 | Delete "$INSTDIR\Qt5MultimediaWidgets.dll" 141 | Delete "$INSTDIR\Qt5PrintSupport.dll" 142 | Delete "$INSTDIR\Qt5Sql.dll" 143 | Delete "$INSTDIR\Qt5Widgets.dll" 144 | Delete "$INSTDIR\icuuc54.dll" 145 | Delete "$INSTDIR\Qt5Core.dll" 146 | Delete "$INSTDIR\Qt5Network.dll" 147 | Delete "$INSTDIR\Qt5Qml.dll" 148 | Delete "$INSTDIR\Qt5WebChannel.dll" 149 | Delete "$INSTDIR\Qt5Xml.dll" 150 | Delete "$INSTDIR\Qt5Gui.dll" 151 | Delete "$INSTDIR\Qt5OpenGL.dll" 152 | Delete "$INSTDIR\Qt5Quick.dll" 153 | Delete "$INSTDIR\Qt5WebKit.dll" 154 | Delete "$INSTDIR\kchmviewer.exe.manifest" 155 | Delete "$INSTDIR\msvcp120.dll" 156 | Delete "$INSTDIR\msvcr120.dll" 157 | Delete "$INSTDIR\vccorlib120.dll" 158 | 159 | Delete "$INSTDIR\uninst.exe" 160 | 161 | RMDir "$INSTDIR\imageformats" 162 | RMDir "$INSTDIR\platforms" 163 | RMDir "$INSTDIR\printsupport" 164 | RMDir "$INSTDIR" 165 | 166 | !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP 167 | Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" 168 | Delete "$SMPROGRAMS\$MUI_TEMP\kchmviewer.lnk" 169 | Delete "$SMPROGRAMS\$MUI_TEMP" 170 | 171 | DeleteRegKey /ifempty HKEY_LOCAL_MACHINE "SOFTWARE\Ulduzsoft\KchmViewer" 172 | DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\KchmViewer" 173 | 174 | SectionEnd 175 | -------------------------------------------------------------------------------- /nsis/installer64.nsis: -------------------------------------------------------------------------------- 1 | ; NSIS script file 2 | 3 | ;-------------------------------- 4 | ;Include Modern UI 5 | 6 | !include "MUI.nsh" 7 | 8 | ;-------------------------------- 9 | ;General 10 | 11 | ; The icon for the installer. 12 | ; MUI_ICON icon_file 13 | 14 | ; The icon for the uninstaller. 15 | ; MUI_UNICON icon_file 16 | 17 | Name "KchmViewer" 18 | OutFile "InstallKchmViewer.exe" 19 | InstallDir "$PROGRAMFILES64\Ulduzsoft\KchmViewer" 20 | InstallDirRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Ulduzsoft\KchmViewer" "" 21 | SetCompressor lzma 22 | 23 | ;-------------------------------- 24 | ;Variables 25 | 26 | Var MUI_TEMP 27 | Var STARTMENU_FOLDER 28 | 29 | ;-------------------------------- 30 | ;Interface Settings 31 | 32 | !define MUI_ABORTWARNING 33 | 34 | 35 | ;-------------------------------- 36 | ;Pages 37 | 38 | !insertmacro MUI_PAGE_WELCOME 39 | !insertmacro MUI_PAGE_LICENSE "license.txt" 40 | !insertmacro MUI_PAGE_DIRECTORY 41 | 42 | ;Start Menu Folder Page Configuration 43 | !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKEY_LOCAL_MACHINE 44 | !define MUI_STARTMENUPAGE_REGISTRY_KEY "SOFTWARE\Ulduzsoft\KchmViewer" 45 | !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" 46 | !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER 47 | 48 | !insertmacro MUI_PAGE_INSTFILES 49 | !insertmacro MUI_PAGE_FINISH 50 | 51 | ; Uninstaller pages 52 | !insertmacro MUI_UNPAGE_WELCOME 53 | !insertmacro MUI_UNPAGE_CONFIRM 54 | !insertmacro MUI_UNPAGE_INSTFILES 55 | !insertmacro MUI_UNPAGE_FINISH 56 | 57 | ;-------------------------------- 58 | ;Languages 59 | 60 | !insertmacro MUI_LANGUAGE "English" 61 | 62 | 63 | ;-------------------------------- 64 | ;Installer Sections 65 | 66 | Section "General" General 67 | SetOutPath "$INSTDIR" 68 | 69 | ; Our files 70 | CreateDirectory "$INSTDIR\imageformats" 71 | CreateDirectory "$INSTDIR\platforms" 72 | CreateDirectory "$INSTDIR\printsupport" 73 | File /oname=$INSTDIR\imageformats\qgif.dll imageformats\qgif.dll 74 | File /oname=$INSTDIR\imageformats\qico.dll imageformats\qico.dll 75 | File /oname=$INSTDIR\imageformats\qjpeg.dll imageformats\qjpeg.dll 76 | File /oname=$INSTDIR\imageformats\qsvg.dll imageformats\qsvg.dll 77 | File /oname=$INSTDIR\platforms\qwindows.dll platforms\qwindows.dll 78 | File /oname=$INSTDIR\printsupport\windowsprintersupport.dll printsupport\windowsprintersupport.dll 79 | File kchmviewer.exe 80 | File icudt54.dll 81 | File Qt5Multimedia.dll 82 | File Qt5Positioning.dll 83 | File Qt5Sensors.dll 84 | File Qt5WebKitWidgets.dll 85 | File icuin54.dll 86 | File kchmviewer.exe 87 | File Qt5MultimediaWidgets.dll 88 | File Qt5PrintSupport.dll 89 | File Qt5Sql.dll 90 | File Qt5Widgets.dll 91 | File icuuc54.dll 92 | File Qt5Core.dll 93 | File Qt5Network.dll 94 | File Qt5Qml.dll 95 | File Qt5WebChannel.dll 96 | File Qt5Xml.dll 97 | File Qt5Gui.dll 98 | File Qt5OpenGL.dll 99 | File Qt5Quick.dll 100 | File Qt5WebKit.dll 101 | File kchmviewer.exe.manifest 102 | File msvcp120.dll 103 | File msvcr120.dll 104 | File vccorlib120.dll 105 | 106 | ;Store installation folder 107 | WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Ulduzsoft\KchmViewer" "" "$INSTDIR" 108 | 109 | ;Create uninstaller 110 | WriteUninstaller "$INSTDIR\uninst.exe" 111 | 112 | !insertmacro MUI_STARTMENU_WRITE_BEGIN Application 113 | ;Create shortcuts 114 | CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" 115 | CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\kchmviewer.lnk" "$INSTDIR\kchmviewer.exe" 116 | CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\uninst.exe" 117 | !insertmacro MUI_STARTMENU_WRITE_END 118 | 119 | SectionEnd 120 | 121 | ;-------------------------------- 122 | ;Uninstaller Section 123 | 124 | Section "Uninstall" 125 | 126 | ; Our files 127 | Delete "$INSTDIR\imageformats\qgif.dll" 128 | Delete "$INSTDIR\imageformats\qico.dll" 129 | Delete "$INSTDIR\imageformats\qjpeg.dll" 130 | Delete "$INSTDIR\imageformats\qsvg.dll" 131 | Delete "$INSTDIR\platforms\qwindows.dll" 132 | Delete "$INSTDIR\printsupport\windowsprintersupport.dll" 133 | Delete "$INSTDIR\kchmviewer.exe" 134 | Delete "$INSTDIR\icudt54.dll" 135 | Delete "$INSTDIR\Qt5Multimedia.dll" 136 | Delete "$INSTDIR\Qt5Positioning.dll" 137 | Delete "$INSTDIR\Qt5Sensors.dll" 138 | Delete "$INSTDIR\Qt5WebKitWidgets.dll" 139 | Delete "$INSTDIR\icuin54.dll" 140 | Delete "$INSTDIR\Qt5MultimediaWidgets.dll" 141 | Delete "$INSTDIR\Qt5PrintSupport.dll" 142 | Delete "$INSTDIR\Qt5Sql.dll" 143 | Delete "$INSTDIR\Qt5Widgets.dll" 144 | Delete "$INSTDIR\icuuc54.dll" 145 | Delete "$INSTDIR\Qt5Core.dll" 146 | Delete "$INSTDIR\Qt5Network.dll" 147 | Delete "$INSTDIR\Qt5Qml.dll" 148 | Delete "$INSTDIR\Qt5WebChannel.dll" 149 | Delete "$INSTDIR\Qt5Xml.dll" 150 | Delete "$INSTDIR\Qt5Gui.dll" 151 | Delete "$INSTDIR\Qt5OpenGL.dll" 152 | Delete "$INSTDIR\Qt5Quick.dll" 153 | Delete "$INSTDIR\Qt5WebKit.dll" 154 | Delete "$INSTDIR\kchmviewer.exe.manifest" 155 | Delete "$INSTDIR\msvcp120.dll" 156 | Delete "$INSTDIR\msvcr120.dll" 157 | Delete "$INSTDIR\vccorlib120.dll" 158 | 159 | Delete "$INSTDIR\uninst.exe" 160 | 161 | RMDir "$INSTDIR\imageformats" 162 | RMDir "$INSTDIR\platforms" 163 | RMDir "$INSTDIR\printsupport" 164 | RMDir "$INSTDIR" 165 | 166 | !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP 167 | Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" 168 | Delete "$SMPROGRAMS\$MUI_TEMP\kchmviewer.lnk" 169 | Delete "$SMPROGRAMS\$MUI_TEMP" 170 | 171 | DeleteRegKey /ifempty HKEY_LOCAL_MACHINE "SOFTWARE\Ulduzsoft\KchmViewer" 172 | DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\KchmViewer" 173 | 174 | SectionEnd 175 | -------------------------------------------------------------------------------- /nsis/kchmviewer.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | Windows Forms Common Control manifest 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | INSTALL( FILES kchmviewer.desktop DESTINATION ${KDE4_XDG_APPS_INSTALL_DIR} ) 2 | KDE4_INSTALL_ICONS( ${KDE4_ICON_INSTALL_DIR} ) 3 | KDE4_UPDATE_ICONCACHE( ) 4 | 5 | -------------------------------------------------------------------------------- /packages/kchmviewer.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=KchmViewer 3 | Categories=Qt;KDE;Office;Viewer; 4 | Terminal=false 5 | Type=Application 6 | Exec=kchmviewer %f 7 | Icon=kchmviewer 8 | GenericName=CHM file viewer 9 | Comment=A viewer of CHM (MS-Help) files 10 | MimeType=application/chm;application/x-chm;application/vnd.ms-htmlhelp;application/epub+zip 11 | -------------------------------------------------------------------------------- /packages/kchmviewer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/packages/kchmviewer.png -------------------------------------------------------------------------------- /packages/rpm.spec: -------------------------------------------------------------------------------- 1 | Summary: Free CHM files viewer application 2 | Name: kchmviewer 3 | Version: 0.7 4 | Release: 1 5 | License: GPLv3+ 6 | Group: Applications/Office 7 | Packager: kchmviewer@ulduzsoft.com 8 | URL: http://www.kchmviewer.net 9 | %description 10 | Kchmviewer is a free, open-source chm (MS HTML help file format) viewer, 11 | which uses Qt toolkit. Its main advantage is the best support for non-English 12 | languages. Unlike other viewers, kchmviewer in most cases is able to correctly 13 | detect the chm file encoding and show it. It correctly shows the index and 14 | table of context in Russian, Spanish, Romanian, Korean, Chinese and Arabic help 15 | files, and with new search engine is able to search in any chm file no matter what 16 | language it is written. 17 | 18 | Author: 19 | ------- 20 | George Yunaev 21 | 22 | Requires: libqt4 >= 4.5.0 23 | %files 24 | %defattr(-,root,root) 25 | /usr/bin/kchmviewer 26 | %defattr(-,root,root) 27 | /usr/share/applications/kchmviewer.desktop 28 | %defattr(-,root,root) 29 | /usr/share/pixmaps/kchmviewer.png 30 | -------------------------------------------------------------------------------- /po/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FIND_PROGRAM(GETTEXT_MSGFMT_EXECUTABLE msgfmt) 2 | 3 | IF(NOT GETTEXT_MSGFMT_EXECUTABLE) 4 | 5 | MESSAGE( "------ NOTE: msgfmt not found. Translations will *not* be installed ------") 6 | 7 | ELSE(NOT GETTEXT_MSGFMT_EXECUTABLE) 8 | 9 | SET(catalogname kchmviewer) 10 | ADD_CUSTOM_TARGET(translations ALL) 11 | FILE(GLOB PO_FILES ${catalogname}*.po) 12 | 13 | FOREACH(_poFile ${PO_FILES}) 14 | GET_FILENAME_COMPONENT(_poFileName ${_poFile} NAME) 15 | STRING(REGEX REPLACE "^${catalogname}_?" "" _langCode ${_poFileName} ) 16 | STRING(REGEX REPLACE "\\.po$" "" _langCode ${_langCode} ) 17 | 18 | IF( _langCode ) 19 | GET_FILENAME_COMPONENT(_lang ${_poFile} NAME_WE) 20 | SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo) 21 | 22 | ADD_CUSTOM_COMMAND(TARGET translations 23 | COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} --check -o ${_gmoFile} ${_poFile} 24 | DEPENDS ${_poFile}) 25 | INSTALL(FILES ${_gmoFile} DESTINATION ${LOCALE_INSTALL_DIR}/${_langCode}/LC_MESSAGES/ RENAME ${catalogname}.mo) 26 | ENDIF( _langCode ) 27 | 28 | ENDFOREACH(_poFile ${PO_FILES}) 29 | 30 | ENDIF(NOT GETTEXT_MSGFMT_EXECUTABLE) 31 | -------------------------------------------------------------------------------- /po/update_translations.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | BASEDIR="../src/" # root of translatable sources 4 | PROJECT="kchmviewer" # project name 5 | BUGADDR="kchmviewer@ulduzsoft.com" # MSGID-Bugs 6 | WDIR=`pwd` # working dir 7 | 8 | echo "Preparing rc files" 9 | cd ${BASEDIR} 10 | 11 | # we use simple sorting to make sure the lines do not jump around too much from system to system 12 | # 13 | find . -name '*.rc' -o -name '*.ui' -o -name '*.kcfg' | sort > ${WDIR}/rcfiles.list 14 | xargs --arg-file=${WDIR}/rcfiles.list extractrc > ${WDIR}/rc.cpp 15 | 16 | # additional string for KAboutData 17 | echo 'i18nc("NAME OF TRANSLATORS","Your names");' >> ${WDIR}/rc.cpp 18 | echo 'i18nc("EMAIL OF TRANSLATORS","Your emails");' >> ${WDIR}/rc.cpp 19 | cd ${WDIR} 20 | echo "Done preparing rc files" 21 | 22 | # 23 | echo "Extracting messages" 24 | cd ${BASEDIR} 25 | 26 | # 27 | # see above on sorting 28 | # 29 | find . -name '*.cpp' -o -name '*.h' -o -name '*.c' | sort > ${WDIR}/infiles.list 30 | echo "rc.cpp" >> ${WDIR}/infiles.list 31 | cd ${WDIR} 32 | 33 | xgettext --from-code=UTF-8 -C -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 -ktr2i18n:1 \ 34 | -kI18N_NOOP:1 -kI18N_NOOP2:1c,2 -kaliasLocale -kki18n:1 -kki18nc:1c,2 -kki18np:1,2 -kki18ncp:1c,2,3 \ 35 | --msgid-bugs-address="${BUGADDR}" \ 36 | --files-from=infiles.list -D ${BASEDIR} -D ${WDIR} -o ${PROJECT}.pot || { echo "error while calling xgettext. aborting."; exit 1; } 37 | 38 | echo "Done extracting messages" 39 | 40 | # 41 | echo "Merging translations" 42 | catalogs=`find . -name '*.po'` 43 | 44 | for cat in $catalogs; do 45 | echo $cat 46 | msgmerge -o $cat.new $cat ${PROJECT}.pot 47 | mv $cat.new $cat 48 | done 49 | 50 | echo "Done merging translations" 51 | 52 | # 53 | echo "Cleaning up" 54 | cd ${WDIR} 55 | rm rcfiles.list 56 | rm infiles.list 57 | rm rc.cpp 58 | 59 | echo "Done" 60 | -------------------------------------------------------------------------------- /portable.txt: -------------------------------------------------------------------------------- 1 | It is possible to make kchmviewer a portable app, meaning it would keep its files in predefined location and will not write into system/user folders. 2 | 3 | To do this, please create a directory named "portable" (without quotes) in the same directory where kchmviewer binary is stored. If this directory exists: 4 | 5 | - Subdirectory "data" will be created under "portable" and will be used to store the search index and per-help file preferences; 6 | - Application settings will be stored in subdirectory "Ulduzsoft" created in "portable" 7 | - Qt-specific settings will be stored in "portable" directory 8 | - Nothing will be written into any other location on disk. 9 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR}/src ) 2 | 3 | # Project files 4 | SET( kchmviewerSources 5 | config.cpp 6 | dbus_interface.cpp 7 | dialog_chooseurlfromlist.cpp 8 | dialog_setup.cpp 9 | kde-qt.cpp 10 | main.cpp 11 | mainwindow.cpp 12 | recentfiles.cpp 13 | settings.cpp 14 | tab_bookmarks.cpp 15 | tab_contents.cpp 16 | tab_index.cpp 17 | tab_search.cpp 18 | viewwindow.cpp 19 | viewwindowmgr.cpp 20 | navigationpanel.cpp 21 | checknewversion.cpp 22 | toolbarmanager.cpp 23 | toolbareditor.cpp 24 | qwebviewnetwork.cpp 25 | textencodings.cpp 26 | treeitem_toc.cpp 27 | treeitem_index.cpp 28 | ) 29 | 30 | # UI files 31 | KDE4_ADD_UI_FILES( kchmviewerSources 32 | dialog_about.ui 33 | dialog_setup.ui 34 | dialog_topicselector.ui 35 | mainwindow.ui 36 | navigatorpanel.ui 37 | tab_bookmarks.ui 38 | tab_contents.ui 39 | tab_index.ui 40 | tab_search.ui 41 | toolbareditor.ui 42 | window_browser.ui 43 | ) 44 | 45 | # Resources 46 | QT4_ADD_RESOURCES( kchmviewerResources resources/images.qrc ) 47 | 48 | KDE4_ADD_EXECUTABLE( kchmviewer ${kchmviewerSources} ${kchmviewerResources} ) 49 | 50 | TARGET_LINK_LIBRARIES( kchmviewer 51 | ebook 52 | ${LIBCHM_LIBRARY} 53 | ${LIBZIP_LIBRARY} 54 | ${KDE4_KDEUI_LIBS} 55 | ${QT_QTWEBKIT_LIBRARY} 56 | ${KDE4_KFILE_LIBS} ) 57 | 58 | INSTALL( TARGETS kchmviewer DESTINATION ${KDE4_BIN_INSTALL_DIR} ) 59 | 60 | -------------------------------------------------------------------------------- /src/checknewversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef CHECKNEWVERSION_H 20 | #define CHECKNEWVERSION_H 21 | 22 | // This class implements checking whether a new application version is available, 23 | // and reports its availability via signal. It does not use Qt networking stuff, 24 | // and therefore avoids linking with QtNetwork (savings of 1Mb!). 25 | // All processing is done in a separate thread, so it does not block the app. 26 | // It does not use GUI stuff, so should be safe. 27 | // 28 | // The proper way to use this class: 29 | // 30 | // CheckNewVersion * pN = new CheckNewVersion(); 31 | // connect( pN, SIGNAL( newVersionAvailable( const QMap&) ), this, SLOT( newVersionAvailable( const QMap&) ) ); 32 | // 33 | // pN->setUrl( "http://www.example.com/latestversion.txt" ); 34 | // pN->setCurrentVersion( "1.12" ); 35 | // pN->start(); 36 | // 37 | // The text file must have the following format: 38 | // : 39 | // Two field names are required (Signature and Version). Any other names are optional. Any name may be added. 40 | // A multiline value string should have all line feed characters replaced by \n, and all single backlashes replaced by two 41 | // Signature must be the first field, and must contain the "CheckNewVersion1" value 42 | // 43 | // An example file with extra fields "URL" and "Changes" added: 44 | // 45 | // Signature:CheckNewVersion1 46 | // Version:1.12 47 | // URL: http://example.com/latestversion.zip 48 | // Changes: new functionality added.\nA bar function added to package foo.\n\nZeta now works. 49 | // 50 | // 51 | 52 | #include 53 | #include 54 | #include 55 | 56 | typedef QMap NewVersionMetaMap; 57 | 58 | class CheckNewVersion : public QThread 59 | { 60 | Q_OBJECT 61 | 62 | public: 63 | enum 64 | { 65 | Status_Resolving, 66 | Status_Connecting, 67 | Status_SendingRequest, 68 | Status_ReceivingResponse, 69 | Status_Proceeding, 70 | Status_Finished, 71 | }; 72 | 73 | enum 74 | { 75 | Error_URL_Invalid, 76 | Error_Name_Lookup, 77 | Error_System, 78 | Error_Connecting, 79 | Error_Sending, 80 | Error_Receiving, 81 | Error_HTTPerror, 82 | Error_InvalidFormat, 83 | Error_InvalidSignature 84 | }; 85 | 86 | CheckNewVersion(); 87 | 88 | // Sets the full URL to get the latest version information from. 89 | void setUrl( const QString& url ); 90 | 91 | // Sets the current version. newVersionAvailable() will only be emitted 92 | // if current version does not match the version in the downloaded file. 93 | // If not called, newVersionAvailable() will be always emitted. 94 | void setCurrentVersion( const QString& version ); 95 | 96 | signals: 97 | void newVersionAvailable( const NewVersionMetaMap& metadata ); 98 | void statusChanged( int newstatus ); 99 | void error( int errorcode ); 100 | 101 | private: 102 | // Reimplemented 103 | void run(); 104 | 105 | // All those functions on error generate the event, and shut down the thread. 106 | void fatalError( int code ); 107 | 108 | // Read the line from socket (or m_inputBuffer). 109 | void reportStatus( int status ); 110 | 111 | // Read the data from socket up to length. May return less than length. 112 | QString readLine(); 113 | 114 | // Closing the socket 115 | void closeSocket(); 116 | 117 | private: 118 | QString m_url; 119 | QString m_currentversion; 120 | 121 | int m_sockfd; 122 | unsigned int m_timeout; 123 | int m_inputOffset; // in m_inputBuffer 124 | QByteArray m_inputBuffer; // for socket input 125 | }; 126 | 127 | Q_DECLARE_METATYPE(NewVersionMetaMap); 128 | 129 | #endif // CHECKNEWVERSION_H 130 | -------------------------------------------------------------------------------- /src/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef CONFIG_H 20 | #define CONFIG_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "recentfiles.h" 27 | 28 | 29 | class Config 30 | { 31 | public: 32 | enum choose_action_t 33 | { 34 | ACTION_ALWAYS_OPEN, 35 | ACTION_ASK_USER, 36 | ACTION_DONT_OPEN 37 | }; 38 | 39 | enum ToolbarMode 40 | { 41 | TOOLBAR_SMALLICONS, 42 | TOOLBAR_LARGEICONS, 43 | TOOLBAR_LARGEICONSTEXT, 44 | TOOLBAR_TEXTONLY 45 | }; 46 | 47 | enum StartupMode 48 | { 49 | STARTUP_DO_NOTHING, 50 | STARTUP_LOAD_LAST_FILE, 51 | STARTUP_POPUP_OPENFILE 52 | }; 53 | 54 | Config(); 55 | void save(); 56 | 57 | // Returns the setting filename for this ebook 58 | QString getEbookSettingFile( const QString& ebookfile ) const; 59 | 60 | // Returns the index filename for this ebook 61 | QString getEbookIndexFile( const QString& ebookfile ) const; 62 | 63 | public: 64 | QString m_lastOpenedDir; 65 | 66 | StartupMode m_startupMode; 67 | choose_action_t m_onNewChmClick; 68 | choose_action_t m_onExternalLinkClick; 69 | int m_numOfRecentFiles; 70 | bool m_HistoryStoreExtra; 71 | ToolbarMode m_toolbarMode; 72 | 73 | bool m_browserEnableJS; 74 | bool m_browserEnableJava; 75 | bool m_browserEnablePlugins; 76 | bool m_browserEnableImages; 77 | bool m_browserEnableOfflineStorage; 78 | bool m_browserEnableLocalStorage; 79 | bool m_browserEnableRemoteContent; 80 | bool m_browserHighlightSearchResults; 81 | bool m_tocOpenAllEntries; 82 | bool m_tabUseSingleClick; 83 | 84 | bool m_advUseInternalEditor; 85 | QString m_advExternalEditorPath; 86 | bool m_advLayoutDirectionRL; 87 | bool m_advAutodetectEncoding; 88 | bool m_advCheckNewVersion; 89 | 90 | private: 91 | QString m_datapath; 92 | }; 93 | 94 | extern Config * pConfig; 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /src/dataprovider_qwebengine.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "mainwindow.h" 5 | #include "dataprovider_qwebengine.h" 6 | 7 | DataProvider_QWebEngine::DataProvider_QWebEngine( QObject *parent ) 8 | : QWebEngineUrlSchemeHandler( parent ) 9 | { 10 | } 11 | 12 | void DataProvider_QWebEngine::requestStarted( QWebEngineUrlRequestJob *request ) 13 | { 14 | QUrl url = request->requestUrl(); 15 | bool htmlfile = url.path().endsWith( ".html" ) || url.path().endsWith( ".htm" ) || url.path().endsWith( ".xhtml" ); 16 | 17 | // Retreive the data from ebook file 18 | QByteArray buf; 19 | 20 | if ( !::mainWindow->chmFile()->getFileContentAsBinary( buf, url ) ) 21 | { 22 | qWarning( "Could not resolve file %s\n", qPrintable( url.toString() ) ); 23 | request->fail( QWebEngineUrlRequestJob::UrlNotFound ); 24 | return; 25 | } 26 | 27 | const char * mimetype = "application/octet-stream"; 28 | 29 | // Specify the encoding in case the page content is not UTF-8 - this is ignored by WebEngine 30 | if ( htmlfile ) 31 | mimetype = "text/html"; 32 | 33 | // We will use the buffer because reply() requires the QIODevice. 34 | // This buffer must be valid until the request is deleted. 35 | QBuffer * outbuf = new QBuffer; 36 | outbuf->setData( buf ); 37 | outbuf->close(); 38 | 39 | // Only delete the buffer when the request is deleted too 40 | connect( request, SIGNAL(destroyed()), outbuf, SLOT(deleteLater()) ); 41 | 42 | // We're good to go 43 | request->reply( mimetype, outbuf ); 44 | } 45 | -------------------------------------------------------------------------------- /src/dataprovider_qwebengine.h: -------------------------------------------------------------------------------- 1 | #ifndef DATAPROVIDER_QWEBENGINE_H 2 | #define DATAPROVIDER_QWEBENGINE_H 3 | 4 | #include 5 | 6 | class DataProvider_QWebEngine : public QWebEngineUrlSchemeHandler 7 | { 8 | public: 9 | DataProvider_QWebEngine( QObject *parent ); 10 | 11 | void requestStarted( QWebEngineUrlRequestJob *request ); 12 | }; 13 | 14 | #endif // DATAPROVIDER_QWEBENGINE_H 15 | -------------------------------------------------------------------------------- /src/dataprovider_qwebkit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | #include "dataprovider_qwebkit.h" 22 | #include "viewwindow.h" 23 | #include "config.h" 24 | #include "mainwindow.h" 25 | 26 | 27 | KCHMNetworkReply::KCHMNetworkReply( const QNetworkRequest &request, const QUrl &url ) 28 | { 29 | setRequest( request ); 30 | setOpenMode( QIODevice::ReadOnly ); 31 | 32 | m_data = loadResource( url ); 33 | m_length = m_data.length(); 34 | 35 | setHeader( QNetworkRequest::ContentLengthHeader, QByteArray::number(m_data.length()) ); 36 | QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection); 37 | 38 | if ( m_length ) 39 | QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection); 40 | 41 | QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection); 42 | } 43 | 44 | qint64 KCHMNetworkReply::bytesAvailable() const 45 | { 46 | return m_data.length() + QNetworkReply::bytesAvailable(); 47 | } 48 | 49 | void KCHMNetworkReply::abort() 50 | { 51 | } 52 | 53 | qint64 KCHMNetworkReply::readData(char *buffer, qint64 maxlen) 54 | { 55 | qint64 len = qMin(qint64(m_data.length()), maxlen); 56 | 57 | if (len) 58 | { 59 | memcpy(buffer, m_data.constData(), len); 60 | m_data.remove(0, len); 61 | } 62 | 63 | return len; 64 | } 65 | 66 | QByteArray KCHMNetworkReply::loadResource( const QUrl &url ) 67 | { 68 | //qDebug("loadResource %s", qPrintable(url.toString()) ); 69 | 70 | bool htmlfile = url.path().endsWith( ".html" ) || url.path().endsWith( ".htm" ) || url.path().endsWith( ".xhtml" ); 71 | 72 | // Retreive the data from ebook file 73 | QByteArray buf; 74 | 75 | if ( !::mainWindow->chmFile()->getFileContentAsBinary( buf, url ) ) 76 | { 77 | qWarning( "Could not resolve file %s\n", qPrintable( url.toString() ) ); 78 | 79 | if ( htmlfile ) 80 | buf = (QString("Could not load file %1").arg( url.path())).toUtf8(); 81 | } 82 | 83 | if ( htmlfile ) 84 | setHeader( QNetworkRequest::ContentTypeHeader, QString( "text/html; charset=%1" ) .arg( ::mainWindow->chmFile()->currentEncoding() ) ); 85 | 86 | return buf; 87 | } 88 | 89 | 90 | KCHMNetworkAccessManager::KCHMNetworkAccessManager( QObject *parent ) 91 | : QNetworkAccessManager(parent) 92 | { 93 | } 94 | 95 | QNetworkReply * KCHMNetworkAccessManager::createRequest( Operation op, const QNetworkRequest &request, QIODevice *outgoingData ) 96 | { 97 | //qDebug("KCHMNetworkAccessManager::createRequest %s", qPrintable( request.url().toString()) ); 98 | 99 | if ( ::mainWindow->chmFile()->isSupportedUrl( request.url() ) ) 100 | return new KCHMNetworkReply( request, request.url() ); 101 | 102 | if ( pConfig->m_browserEnableRemoteContent ) 103 | return QNetworkAccessManager::createRequest( op, request, outgoingData ); 104 | else 105 | return QNetworkAccessManager::createRequest( QNetworkAccessManager::GetOperation, QNetworkRequest(QUrl()) ); 106 | } 107 | -------------------------------------------------------------------------------- /src/dataprovider_qwebkit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef QWEBVIEWNETWORK_H 20 | #define QWEBVIEWNETWORK_H 21 | 22 | #include 23 | #include 24 | 25 | // 26 | // A network reply to emulate data transfer from CHM file 27 | // 28 | class KCHMNetworkReply : public QNetworkReply 29 | { 30 | public: 31 | KCHMNetworkReply( const QNetworkRequest &request, const QUrl &url ); 32 | virtual qint64 bytesAvailable() const; 33 | virtual void abort(); 34 | 35 | protected: 36 | virtual qint64 readData(char *buffer, qint64 maxlen); 37 | QByteArray loadResource( const QUrl &url ); 38 | 39 | private: 40 | QByteArray m_data; 41 | qint64 m_length; 42 | }; 43 | 44 | 45 | // 46 | // A network manager to emulate data transfer from CHM file 47 | // 48 | class KCHMNetworkAccessManager : public QNetworkAccessManager 49 | { 50 | public: 51 | KCHMNetworkAccessManager( QObject *parent ); 52 | 53 | protected: 54 | virtual QNetworkReply *createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData = 0); 55 | }; 56 | 57 | 58 | #endif // QWEBVIEWNETWORK_H 59 | -------------------------------------------------------------------------------- /src/dbus_interface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | #include "dbus_interface.h" 22 | #include "mainwindow.h" 23 | #include "navigationpanel.h" 24 | #include "tab_search.h" 25 | 26 | 27 | DBusInterface::DBusInterface( QObject *parent ) 28 | : QObject( parent ) 29 | { 30 | QDBusConnection::sessionBus().registerObject( "/application", 31 | this, 32 | QDBusConnection::ExportScriptableSlots ); 33 | } 34 | 35 | 36 | DBusInterface::~DBusInterface() 37 | { 38 | } 39 | 40 | 41 | void DBusInterface::loadHelpFile( const QString & filename, const QString & page2open ) 42 | { 43 | QStringList args; 44 | 45 | args.push_back( filename ); 46 | args.push_back( page2open ); 47 | 48 | qApp->postEvent( ::mainWindow, new UserEvent( "loadAndOpen", args ) ); 49 | } 50 | 51 | 52 | void DBusInterface::openPage( const QString & page2open ) 53 | { 54 | QStringList args; 55 | 56 | args.push_back( page2open ); 57 | qApp->postEvent( ::mainWindow, new UserEvent( "openPage", args ) ); 58 | } 59 | 60 | 61 | void DBusInterface::guiFindInIndex( const QString & word ) 62 | { 63 | QStringList args; 64 | 65 | args.push_back( word ); 66 | qApp->postEvent( ::mainWindow, new UserEvent( "findInIndex", args ) ); 67 | } 68 | 69 | 70 | void DBusInterface::guiSearchQuery( const QString & query ) 71 | { 72 | QStringList args; 73 | 74 | args.push_back( query ); 75 | qApp->postEvent( ::mainWindow, new UserEvent( "searchQuery", args ) ); 76 | } 77 | 78 | QStringList DBusInterface::searchQuery( const QString & query ) 79 | { 80 | return ::mainWindow->navigator()->searchQuery( query ); 81 | } 82 | -------------------------------------------------------------------------------- /src/dbus_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef DBUS_INTERFACE_H 20 | #define DBUS_INTERFACE_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | #define SERVICE_NAME "net.kchmviewer.application" 28 | 29 | class DBusInterface : public QObject 30 | { 31 | Q_OBJECT 32 | Q_CLASSINFO("D-Bus Interface", "net.kchmviewer.application") 33 | 34 | public: 35 | DBusInterface( QObject *parent = 0 ); 36 | ~DBusInterface(); 37 | 38 | public Q_SLOTS: 39 | //! Loads a CHM file \a filename , and opens the URL \a url. Use URL "/" to open default homepage 40 | Q_SCRIPTABLE void loadHelpFile( const QString& filename, const QString& url ); 41 | 42 | //! Opens a specific \a url inside the loaded CHM file 43 | Q_SCRIPTABLE void openPage( const QString& url ); 44 | 45 | //! Tries to find word in index, opening the index window and scrolling it there 46 | Q_SCRIPTABLE void guiFindInIndex( const QString& word ); 47 | 48 | //! Executes a search in GUI. \a query contains the complete search query. 49 | Q_SCRIPTABLE void guiSearchQuery( const QString& query ); 50 | 51 | //! Executes a search; GUI is not involved and user sees nothing. 52 | //! \a query contains the complete search query. 53 | //! Returns a list of URLs, or empty array if nothing os 54 | Q_SCRIPTABLE QStringList searchQuery( const QString& query ); 55 | }; 56 | 57 | #endif // DBUSIFACE_H 58 | -------------------------------------------------------------------------------- /src/dialog_chooseurlfromlist.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "kde-qt.h" 20 | #include "dialog_chooseurlfromlist.h" 21 | 22 | DialogChooseUrlFromList::DialogChooseUrlFromList( QWidget* parent ) 23 | : QDialog( parent ), Ui::DialogTopicSelector() 24 | { 25 | setupUi( this ); 26 | 27 | // List doubleclick 28 | connect( list, 29 | SIGNAL( itemDoubleClicked ( QListWidgetItem * ) ), 30 | this, 31 | SLOT( onDoubleClicked( QListWidgetItem * ) ) ); 32 | } 33 | 34 | void DialogChooseUrlFromList::onDoubleClicked( QListWidgetItem * item ) 35 | { 36 | if ( item ) 37 | accept(); 38 | } 39 | 40 | 41 | QUrl DialogChooseUrlFromList::getSelectedItemUrl(const QList &urls, const QStringList & titles ) 42 | { 43 | for ( int i = 0; i < urls.size(); i++ ) 44 | list->addItem( titles[i] ); 45 | 46 | if ( exec() == QDialog::Accepted && list->currentRow() != -1 ) 47 | return urls[ list->currentRow() ]; 48 | 49 | return QUrl(); 50 | } 51 | -------------------------------------------------------------------------------- /src/dialog_chooseurlfromlist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef DIALOG_CHOOSEURLFROMLIST_H 20 | #define DIALOG_CHOOSEURLFROMLIST_H 21 | 22 | #include 23 | #include "ui_dialog_topicselector.h" 24 | 25 | 26 | class DialogChooseUrlFromList : public QDialog, public Ui::DialogTopicSelector 27 | { 28 | Q_OBJECT 29 | 30 | public: 31 | DialogChooseUrlFromList( QWidget* parent ); 32 | 33 | // Shows the dialog with titles, and let the user to select the title. 34 | // Obviously urls.size() == titles.size(). Returns the appropriate URL 35 | // for the selected title, or empty string if no title selected, or dialog canceled. 36 | QUrl getSelectedItemUrl( const QList& urls, const QStringList& titles ); 37 | 38 | private slots: 39 | void onDoubleClicked( QListWidgetItem * item ); 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/dialog_setup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef DIALOG_SETUP_H 20 | #define DIALOG_SETUP_H 21 | 22 | #include 23 | #include 24 | 25 | 26 | class DialogSetup : public QDialog, public Ui::DialogSetup 27 | { 28 | Q_OBJECT 29 | 30 | public: 31 | DialogSetup( QWidget *parent = 0 ); 32 | ~DialogSetup(); 33 | 34 | public slots: 35 | void browseExternalEditor(); 36 | void accept(); 37 | 38 | private: 39 | int m_numOfRecentFiles; 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/dialog_topicselector.ui: -------------------------------------------------------------------------------- 1 | 2 | DialogTopicSelector 3 | 4 | 5 | 6 | 0 7 | 0 8 | 218 9 | 258 10 | 11 | 12 | 13 | Multiple topics 14 | 15 | 16 | 17 | 9 18 | 19 | 20 | 6 21 | 22 | 23 | 24 | 25 | Please select the topic to open: 26 | 27 | 28 | Qt::AlignCenter 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | Qt::Horizontal 39 | 40 | 41 | QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | buttonBox 52 | accepted() 53 | DialogTopicSelector 54 | accept() 55 | 56 | 57 | 66 58 | 330 59 | 60 | 61 | -3 62 | 275 63 | 64 | 65 | 66 | 67 | buttonBox 68 | rejected() 69 | DialogTopicSelector 70 | reject() 71 | 72 | 73 | 151 74 | 327 75 | 76 | 77 | 277 78 | 293 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/kchmviewerapp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "kchmviewerapp.h" 20 | #include "mainwindow.h" 21 | 22 | KchmviewerApp::KchmviewerApp(int &argc, char **argv, int version) 23 | : QApplication(argc, argv, version) 24 | { 25 | } 26 | 27 | KchmviewerApp::~KchmviewerApp() 28 | { 29 | } 30 | 31 | bool KchmviewerApp::event(QEvent* ev) 32 | { 33 | if (ev->type() == QEvent::FileOpen) 34 | { 35 | m_nResend = 0; 36 | m_filePath = static_cast(ev)->file(); 37 | onTimer(); 38 | return true; 39 | } 40 | return QApplication::event(ev); 41 | } 42 | 43 | void KchmviewerApp::onTimer() 44 | { 45 | MainWindow *main; 46 | foreach (QWidget *widget, QApplication::topLevelWidgets()) 47 | { 48 | main = dynamic_cast(widget); 49 | if (main != 0) 50 | { 51 | break; 52 | } 53 | } 54 | if (main == 0) 55 | { 56 | qWarning("resending %s", m_filePath.toStdString().c_str()); 57 | if (m_nResend >= 30) 58 | { 59 | qWarning("aborting loading of %s", m_filePath.toStdString().c_str()); 60 | return; 61 | } 62 | QTimer::singleShot(250, this, SLOT(onTimer())); 63 | ++m_nResend; 64 | return; 65 | } 66 | main->loadFile(m_filePath); 67 | } 68 | -------------------------------------------------------------------------------- /src/kchmviewerapp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef KCHMVIEWERAPP_H 20 | #define KCHMVIEWERAPP_H 21 | 22 | #include 23 | #include 24 | 25 | class KchmviewerApp : public QApplication 26 | { 27 | Q_OBJECT 28 | public: 29 | KchmviewerApp(int &argc, char **argv, int version= QT_VERSION); 30 | virtual ~KchmviewerApp(); 31 | bool event(QEvent*); 32 | 33 | private slots: 34 | void onTimer(); 35 | 36 | private: 37 | QString m_filePath; 38 | int m_nResend; 39 | }; 40 | 41 | #endif // KCHMVIEWERAPP_H 42 | -------------------------------------------------------------------------------- /src/kde-qt.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "kde-qt.h" 20 | 21 | #if defined (USE_KDE) 22 | KQProgressModalDialog::KQProgressModalDialog ( const QString & captionText, const QString & labelText, const QString & cancelButtonText, int totalSteps, QWidget * creator ) 23 | : KProgressDialog( creator, captionText, labelText ) 24 | { 25 | setAllowCancel( true ); 26 | showCancelButton( true ); 27 | setAutoClose( true ); 28 | setButtonText( cancelButtonText ); 29 | progressBar()->setMaximum( totalSteps ); 30 | setMinimumDuration( 1 ); 31 | } 32 | #else 33 | KQProgressModalDialog::KQProgressModalDialog ( const QString & captionText, const QString & labelText, const QString & cancelButtonText, int totalSteps, QWidget * creator ) 34 | : QProgressDialog( labelText, cancelButtonText, 0, totalSteps, creator ) 35 | { 36 | setWindowTitle( captionText ); 37 | setMinimumDuration( 1 ); 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /src/kde-qt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef KDE_QT_H 20 | #define KDE_QT_H 21 | 22 | #if defined (USE_KDE) 23 | 24 | #define KQ_CLASSNAME(name) K##name 25 | #define KQ_DECLARECLASS(name) class KQ##name : public K##name 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #include 42 | 43 | #else /* !USE_KDE */ 44 | 45 | #define KQ_CLASSNAME(name) Q##name 46 | 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | 59 | #define i18n(A) tr(A) 60 | 61 | #endif /* USE_KDE */ 62 | 63 | // common non-wrapped UI classes 64 | #include 65 | #include 66 | #include 67 | #include 68 | #include 69 | #include 70 | #include 71 | #include 72 | 73 | 74 | // common utility classes 75 | #include 76 | #include 77 | #include 78 | #include 79 | #include 80 | #include 81 | #include 82 | #include 83 | #include 84 | #include 85 | #include 86 | #include 87 | #include 88 | 89 | // events 90 | #include 91 | #include 92 | #include 93 | #include 94 | 95 | 96 | class KQProgressModalDialog : public KQ_CLASSNAME(ProgressDialog) 97 | { 98 | public: 99 | KQProgressModalDialog ( const QString & captionText, const QString & labelText, const QString & cancelButtonText, int totalSteps, QWidget * creator = 0 ); 100 | 101 | // Seems like people have fun making classes incompatible 102 | #if defined (USE_KDE) 103 | void setValue( int value ) { progressBar()->setValue( value ); } 104 | #else 105 | bool wasCancelled() { return wasCanceled(); } 106 | #endif 107 | 108 | }; 109 | 110 | class KQTabWidget : public KQ_CLASSNAME(TabWidget) 111 | { 112 | public: 113 | KQTabWidget (QWidget *parent = 0 ) 114 | : KQ_CLASSNAME(TabWidget) (parent) {} 115 | }; 116 | 117 | 118 | #include 119 | #include 120 | #include 121 | #include 122 | #include 123 | #include 124 | #include 125 | #include 126 | #include 127 | #include 128 | #include 129 | #include 130 | 131 | 132 | class ShowWaitCursor 133 | { 134 | public: 135 | ShowWaitCursor() { QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) ); } 136 | ~ShowWaitCursor() { QApplication::restoreOverrideCursor(); } 137 | }; 138 | 139 | 140 | // Forward declarations 141 | class MainWindow; 142 | class ViewWindow; 143 | class TabIndex; 144 | class TabSearch; 145 | class TabBookmarks; 146 | class TabContents; 147 | class Settings; 148 | class ViewWindowMgr; 149 | class EBookUrl; 150 | 151 | 152 | #endif /* KDE_QT_H */ 153 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "kde-qt.h" 20 | 21 | #include "mainwindow.h" 22 | #include "config.h" 23 | #include "dbus_interface.h" 24 | #include "version.h" 25 | 26 | #if !defined (WIN32) 27 | #include 28 | #endif 29 | 30 | #if defined (USE_KDE) 31 | #include 32 | #endif 33 | 34 | #if defined (Q_WS_MAC) 35 | #include "kchmviewerapp.h" 36 | #else 37 | typedef QApplication KchmviewerApp; 38 | #endif 39 | 40 | MainWindow * mainWindow; 41 | 42 | 43 | int main( int argc, char ** argv ) 44 | { 45 | // See https://doc.qt.io/qt-5/qwebengineurlschemehandler.html 46 | ViewWindow::initialize(); 47 | 48 | #if defined (USE_KDE) 49 | KAboutData aboutdata ( "kchmviewer", 50 | QByteArray(), 51 | ki18n("kchmviewer"), 52 | qPrintable( QString("%1.%2") .arg(APP_VERSION_MAJOR) .arg(APP_VERSION_MINOR) ), 53 | ki18n("CHM file viewer"), 54 | KAboutData::License_GPL, 55 | ki18n("(c) 2004-2021 George Yunaev, gyunaev@ulduzsoft.com"), 56 | ki18n("Please report bugs to kchmviewer@ulduzsoft.com"), 57 | "http://www.ulduzsoft.com/kchmviewer", 58 | "kchmviewer@ulduzsoft.com"); 59 | 60 | KCmdLineArgs::init( &aboutdata ); 61 | KApplication app; 62 | #else 63 | KchmviewerApp app( argc, argv ); 64 | 65 | app.addLibraryPath ( "qt-plugins" ); 66 | #endif 67 | 68 | // Set data for QSettings 69 | QCoreApplication::setOrganizationName("Ulduzsoft"); 70 | QCoreApplication::setOrganizationDomain("kchmviewer.net"); 71 | QCoreApplication::setApplicationName("kchmviewer"); 72 | 73 | // Configuration 74 | pConfig = new Config(); 75 | 76 | #if !defined (WIN32) && !defined(Q_WS_MAC) 77 | if ( QDBusConnection::sessionBus().isConnected() ) 78 | { 79 | if ( QDBusConnection::sessionBus().registerService(SERVICE_NAME) ) 80 | { 81 | DBusInterface * dbusiface = new DBusInterface(); 82 | QDBusConnection::sessionBus().registerObject( "/", dbusiface, QDBusConnection::ExportAllSlots ); 83 | } 84 | else 85 | qWarning( "Cannot register service %s on session bus. Going without D-BUS support.", SERVICE_NAME ); 86 | } 87 | else 88 | qWarning( "Cannot connect to the D-BUS session bus. Going without D-BUS support." ); 89 | #endif 90 | 91 | #if defined (USE_KDE) 92 | // Because KDE insists of using its KCmdLineArgs class for argument processing, and does not let you just 93 | // to use QCoreApplication::arguments(), it forces us to write two different process functions. To avoid this, 94 | // we convert command-line options to arguments ourselves here. 95 | QStringList arguments; 96 | 97 | for ( int i = 0; i < argc; i++ ) 98 | arguments << argv[i]; 99 | 100 | mainWindow = new MainWindow( arguments ); 101 | #else 102 | mainWindow = new MainWindow( QCoreApplication::arguments() ); 103 | #endif 104 | 105 | // If we already have the duplicate instance, the data has been already sent to it - quit now 106 | if ( mainWindow->hasSameTokenInstance() ) 107 | return 0; 108 | 109 | mainWindow->show(); 110 | mainWindow->launch(); 111 | 112 | app.connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) ); 113 | return app.exec(); 114 | } 115 | -------------------------------------------------------------------------------- /src/navigationpanel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef NAVIGATIONPANEL_H 20 | #define NAVIGATIONPANEL_H 21 | 22 | #include 23 | #include "ui_navigatorpanel.h" 24 | #include "kde-qt.h" 25 | 26 | class EBook; 27 | 28 | // This class shows content, index, search and bookmark tabs 29 | class NavigationPanel : public QDockWidget, public Ui::NavigatorPanel 30 | { 31 | Q_OBJECT 32 | 33 | public: 34 | enum 35 | { 36 | TAB_CONTENTS, 37 | TAB_INDEX, 38 | TAB_SEARCH, 39 | TAB_BOOKMARK 40 | }; 41 | 42 | NavigationPanel( QWidget * parent ); 43 | 44 | // Sets the bookmark menu (maintained by bookmark tab) 45 | void setBookmarkMenu( QMenu * menu ); 46 | 47 | // Invalidate data in all tabs 48 | void invalidate(); 49 | 50 | // Update tabs content from CHM file data 51 | void updateTabs(EBook *file ); 52 | 53 | // Save/load current file settings 54 | void applySettings( Settings * settings ); 55 | void getSettings( Settings * settings ); 56 | 57 | // Active tab get/set 58 | int active() const; 59 | void setActive( int index ); 60 | 61 | // Refresh content and index tab contents 62 | void refresh(); 63 | 64 | // Locate URL or text in the contents tab 65 | bool findUrlInContents( const QUrl & url ); 66 | void findTextInContents( const QString & text ); 67 | 68 | // Find text in index tab 69 | void findInIndex( const QString& text ); 70 | 71 | // Find text in search tab 72 | void executeQueryInSearch( const QString& text ); 73 | 74 | // Just find text without using search tab 75 | QStringList searchQuery( const QString& text ); 76 | 77 | public slots: 78 | // Add a new bookmark 79 | void addBookmark(); 80 | 81 | // Show previous/next page in table of contents 82 | void showPrevInToc(); 83 | void showNextInToc(); 84 | 85 | private: 86 | TabContents * m_contentsTab; 87 | TabIndex * m_indexTab; 88 | TabSearch * m_searchTab; 89 | TabBookmarks * m_bookmarksTab; 90 | }; 91 | 92 | #endif // NAVIGATIONPANEL_H 93 | -------------------------------------------------------------------------------- /src/navigatorpanel.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | NavigatorPanel 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea 15 | 16 | 17 | Navigator panel 18 | 19 | 20 | 21 | 22 | 23 | 24 | 0 25 | 26 | 27 | 28 | Tab 1 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/recentfiles.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "recentfiles.h" 24 | 25 | RecentFiles::RecentFiles( QMenu * menu, QAction * before, int maxfiles, const QString& settingsname ) 26 | { 27 | if ( maxfiles < 1 ) 28 | qFatal( "RecentFiles::RecentFiles: maxfiles (%d) is < 1 ", maxfiles ); 29 | 30 | m_settingsName = settingsname.isEmpty() ? "recentFileList" : settingsname; 31 | m_actions.resize( maxfiles ); 32 | 33 | // Create the actions 34 | for ( int i = 0; i < maxfiles; ++i ) 35 | { 36 | m_actions[i] = new QAction( this ); 37 | m_actions[i]->setVisible(false); 38 | connect( m_actions[i], SIGNAL(triggered()), this, SLOT(actionRecent()) ); 39 | } 40 | 41 | // Add them to the menu 42 | for ( int i = 0; i < maxfiles; ++i ) 43 | menu->insertAction( before, m_actions[i] ); 44 | 45 | // Add a separator after the last action 46 | m_separator = menu->insertSeparator( before ); 47 | 48 | // Update the actions menu 49 | updateMenu(); 50 | } 51 | 52 | RecentFiles::~RecentFiles() 53 | { 54 | } 55 | 56 | void RecentFiles::setCurrentFile( const QString& file ) 57 | { 58 | QStringList files = loadRecentFiles(); 59 | files.removeAll( file ); 60 | files.prepend( file ); 61 | 62 | while ( files.size() > m_actions.size() ) 63 | files.removeLast(); 64 | 65 | saveRecentFiles( files ); 66 | 67 | updateMenu(); 68 | } 69 | 70 | void RecentFiles::removeRecentFile( const QString& file ) 71 | { 72 | QStringList files = loadRecentFiles(); 73 | files.removeAll( file ); 74 | saveRecentFiles( files ); 75 | 76 | updateMenu(); 77 | } 78 | 79 | void RecentFiles::actionRecent() 80 | { 81 | QAction *action = qobject_cast(sender()); 82 | 83 | if ( action ) 84 | emit openRecentFile( action->data().toString() ); 85 | } 86 | 87 | void RecentFiles::updateMenu() 88 | { 89 | QStringList files = loadRecentFiles(); 90 | int numRecentFiles = qMin( files.size(), m_actions.size() ); 91 | 92 | for ( int i = 0; i < m_actions.size(); ++i ) 93 | { 94 | if ( i < numRecentFiles ) 95 | { 96 | QString text = tr("&%1 %2").arg(i + 1).arg( QFileInfo( files[i] ).fileName() ); 97 | m_actions[i]->setText(text); 98 | m_actions[i]->setToolTip( files[i] ); 99 | m_actions[i]->setData(files[i]); 100 | m_actions[i]->setVisible(true); 101 | } 102 | else 103 | m_actions[i]->setVisible(false); 104 | } 105 | 106 | m_separator->setVisible( numRecentFiles > 0 ); 107 | } 108 | 109 | QString RecentFiles::latestFile() 110 | { 111 | QStringList files = loadRecentFiles(); 112 | 113 | if ( files.isEmpty() ) 114 | return QString::null; 115 | else 116 | return files[0]; 117 | } 118 | 119 | QStringList RecentFiles::loadRecentFiles() 120 | { 121 | QSettings settings; 122 | return settings.value( m_settingsName ).toStringList(); 123 | } 124 | 125 | void RecentFiles::saveRecentFiles( const QStringList& files ) 126 | { 127 | QSettings settings; 128 | settings.setValue( m_settingsName, files ); 129 | } 130 | -------------------------------------------------------------------------------- /src/recentfiles.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef RECENTFILES_H 20 | #define RECENTFILES_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | 28 | // This class assumes QSettings object can be created using default constructor, i.e. 29 | // QCoreApplication::setOrganizationName( ... ); 30 | // QCoreApplication::setOrganizationDomain( ... ); 31 | // QCoreApplication::setApplicationName( ... ); 32 | // have been called. 33 | // 34 | // This class is based on Qt example 35 | // 36 | class RecentFiles : public QObject 37 | { 38 | Q_OBJECT 39 | 40 | public: 41 | // A constructor specifies the menu to add recent files to, and the action to add it before. 42 | RecentFiles( QMenu * menu, QAction * before, int maxfiles = 5, const QString& settingsname = QString::null ); 43 | virtual ~RecentFiles(); 44 | 45 | signals: 46 | void openRecentFile( const QString& file ); 47 | 48 | public slots: 49 | // Sets the current file to the recent file. Does the following: 50 | // - Adds it to the top of recent files list, or moves it to the top; 51 | // - Removes the last entry, if necessary; 52 | void setCurrentFile( const QString& file ); 53 | 54 | // Removes the current file from the recent files. Useful, for example, 55 | // when attempt to open a recent project failed. 56 | void removeRecentFile( const QString& file ); 57 | 58 | // Returns the last added recent file 59 | QString latestFile(); 60 | 61 | protected: 62 | // Override those functions in a derived class to store/load the 63 | // list of recent files from a different place 64 | QStringList loadRecentFiles(); 65 | void saveRecentFiles( const QStringList& files ); 66 | 67 | private slots: 68 | void actionRecent(); 69 | void updateMenu(); 70 | 71 | private: 72 | QString m_settingsName; 73 | QAction * m_separator; 74 | QVector< QAction* > m_actions; 75 | }; 76 | 77 | #endif // RECENTFILES_H 78 | -------------------------------------------------------------------------------- /src/resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleExecutable 6 | kchmviewer 7 | CFBundleIconFile 8 | kchmviewer.icns 9 | CFBundleIdentifier 10 | www.kchmviewer.net 11 | CFBundleInfoDictionaryVersion 12 | 5.2 13 | CFBundleName 14 | kchmviewer 15 | CFBundlePackageType 16 | APPL 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 5.2 21 | SUFeedURL 22 | http://www.kchmviewer.net 23 | 24 | CFBundleDocumentTypes 25 | 26 | 27 | CFBundleTypeExtensions 28 | 29 | chm 30 | CHM 31 | 32 | CFBundleTypeIconFile 33 | kchmviewer.icns 34 | CFBundleTypeName 35 | CHM 36 | CFBundleTypeOSTypes 37 | 38 | CHM 39 | 40 | CFBundleTypeRole 41 | Viewer 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/resources/addtab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/addtab.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_0.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_1.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_10.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_11.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_12.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_13.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_14.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_15.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_16.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_17.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_18.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_19.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_2.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_20.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_21.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_22.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_23.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_24.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_25.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_26.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_27.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_28.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_29.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_3.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_30.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_31.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_32.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_33.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_34.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_35.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_36.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_37.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_38.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_39.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_4.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_40.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_41.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_5.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_6.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_7.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_8.png -------------------------------------------------------------------------------- /src/resources/chm_icons/icon_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/chm_icons/icon_9.png -------------------------------------------------------------------------------- /src/resources/closetab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/closetab.png -------------------------------------------------------------------------------- /src/resources/dryicon_process.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/dryicon_process.png -------------------------------------------------------------------------------- /src/resources/dryicons_replace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/dryicons_replace.png -------------------------------------------------------------------------------- /src/resources/dryicons_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/dryicons_save.png -------------------------------------------------------------------------------- /src/resources/dryicons_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/dryicons_window.png -------------------------------------------------------------------------------- /src/resources/find_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/find_close.png -------------------------------------------------------------------------------- /src/resources/find_next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/find_next.png -------------------------------------------------------------------------------- /src/resources/find_previous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/find_previous.png -------------------------------------------------------------------------------- /src/resources/find_wrap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/find_wrap.png -------------------------------------------------------------------------------- /src/resources/icon_add_bookmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/icon_add_bookmark.png -------------------------------------------------------------------------------- /src/resources/icon_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/icon_back.png -------------------------------------------------------------------------------- /src/resources/icon_copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/icon_copy.png -------------------------------------------------------------------------------- /src/resources/icon_find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/icon_find.png -------------------------------------------------------------------------------- /src/resources/icon_find_next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/icon_find_next.png -------------------------------------------------------------------------------- /src/resources/icon_find_prev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/icon_find_prev.png -------------------------------------------------------------------------------- /src/resources/icon_font_decrease.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/icon_font_decrease.png -------------------------------------------------------------------------------- /src/resources/icon_font_increase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/icon_font_increase.png -------------------------------------------------------------------------------- /src/resources/icon_forward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/icon_forward.png -------------------------------------------------------------------------------- /src/resources/icon_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/icon_home.png -------------------------------------------------------------------------------- /src/resources/icon_locate_in_content.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/icon_locate_in_content.png -------------------------------------------------------------------------------- /src/resources/icon_next_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/icon_next_page.png -------------------------------------------------------------------------------- /src/resources/icon_open_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/icon_open_file.png -------------------------------------------------------------------------------- /src/resources/icon_prev_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/icon_prev_page.png -------------------------------------------------------------------------------- /src/resources/icon_print.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/icon_print.png -------------------------------------------------------------------------------- /src/resources/icon_view_source.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/icon_view_source.png -------------------------------------------------------------------------------- /src/resources/images.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | addtab.png 4 | closetab.png 5 | find_close.png 6 | find_next.png 7 | find_previous.png 8 | find_wrap.png 9 | icon_add_bookmark.png 10 | icon_back.png 11 | icon_copy.png 12 | icon_find.png 13 | icon_find_next.png 14 | icon_find_prev.png 15 | icon_font_decrease.png 16 | icon_font_increase.png 17 | icon_forward.png 18 | icon_home.png 19 | icon_locate_in_content.png 20 | icon_next_page.png 21 | icon_open_file.png 22 | icon_prev_page.png 23 | icon_print.png 24 | icon_view_source.png 25 | kchmviewer.png 26 | dryicon_process.png 27 | dryicons_replace.png 28 | dryicons_save.png 29 | dryicons_window.png 30 | 31 | 32 | chm_icons/icon_0.png 33 | chm_icons/icon_1.png 34 | chm_icons/icon_2.png 35 | chm_icons/icon_3.png 36 | chm_icons/icon_4.png 37 | chm_icons/icon_5.png 38 | chm_icons/icon_6.png 39 | chm_icons/icon_7.png 40 | chm_icons/icon_8.png 41 | chm_icons/icon_9.png 42 | chm_icons/icon_17.png 43 | chm_icons/icon_18.png 44 | chm_icons/icon_19.png 45 | chm_icons/icon_20.png 46 | chm_icons/icon_21.png 47 | chm_icons/icon_22.png 48 | chm_icons/icon_23.png 49 | chm_icons/icon_24.png 50 | chm_icons/icon_25.png 51 | chm_icons/icon_10.png 52 | chm_icons/icon_11.png 53 | chm_icons/icon_12.png 54 | chm_icons/icon_26.png 55 | chm_icons/icon_27.png 56 | chm_icons/icon_28.png 57 | chm_icons/icon_29.png 58 | chm_icons/icon_13.png 59 | chm_icons/icon_14.png 60 | chm_icons/icon_15.png 61 | chm_icons/icon_16.png 62 | chm_icons/icon_30.png 63 | chm_icons/icon_31.png 64 | chm_icons/icon_32.png 65 | chm_icons/icon_33.png 66 | chm_icons/icon_34.png 67 | chm_icons/icon_35.png 68 | chm_icons/icon_36.png 69 | chm_icons/icon_37.png 70 | chm_icons/icon_38.png 71 | chm_icons/icon_39.png 72 | chm_icons/icon_40.png 73 | chm_icons/icon_41.png 74 | 75 | 76 | -------------------------------------------------------------------------------- /src/resources/images.qrc~: -------------------------------------------------------------------------------- 1 | 2 | 3 | closetab.png 4 | icon_add_bookmark.png 5 | icon_back.png 6 | icon_find_next.png 7 | icon_find_prev.png 8 | icon_font_decrease.png 9 | icon_font_increase.png 10 | icon_forward.png 11 | icon_home.png 12 | icon_locate_in_content.png 13 | icon_next_page.png 14 | icon_open_file.png 15 | icon_prev_page.png 16 | icon_print.png 17 | icon_view_source.png 18 | kchmviewer.png 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/resources/kchmviewer.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/kchmviewer.icns -------------------------------------------------------------------------------- /src/resources/kchmviewer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gyunaev/kchmviewer/869ecdf6861dbc75db1a37de5844d3e40c2b267b/src/resources/kchmviewer.png -------------------------------------------------------------------------------- /src/settings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SETTINGS_H 20 | #define SETTINGS_H 21 | 22 | #include 23 | #include 24 | 25 | 26 | class Settings 27 | { 28 | public: 29 | Settings(); 30 | 31 | bool loadSettings (const QString& filename); 32 | bool saveSettings ( ); 33 | void removeSettings ( const QString& filename ); 34 | 35 | QString searchIndexFile() const { return m_searchIndex; } 36 | 37 | class SavedBookmark 38 | { 39 | public: 40 | SavedBookmark() { scroll_y = 0; } 41 | SavedBookmark ( const QString& n, const QString& u, int y) : name(n), url(u), scroll_y(y) {}; 42 | 43 | QString name; 44 | QString url; 45 | int scroll_y; 46 | }; 47 | 48 | class SavedViewWindow 49 | { 50 | public: 51 | SavedViewWindow() { scroll_y = 0; zoom = 0.0; } 52 | SavedViewWindow ( const QString& u, int y, qreal z) : url(u), scroll_y(y), zoom(z) {}; 53 | 54 | QString url; 55 | int scroll_y; 56 | qreal zoom; 57 | }; 58 | 59 | typedef QList search_saved_settings_t; 60 | typedef QList bookmark_saved_settings_t; 61 | typedef QList viewindow_saved_settings_t; 62 | 63 | int m_window_size_x; 64 | int m_window_size_y; 65 | int m_window_size_splitter; 66 | int m_activetabsystem; 67 | int m_activetabwindow; 68 | QString m_activeEncoding; 69 | search_saved_settings_t m_searchhistory; 70 | bookmark_saved_settings_t m_bookmarks; 71 | viewindow_saved_settings_t m_viewwindows; 72 | 73 | private: 74 | unsigned int m_currentfilesize; 75 | unsigned int m_currentfiledate; 76 | QString m_settingsFile; 77 | QString m_searchIndex; 78 | }; 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /src/src.pro: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += ../lib/libebook 2 | HEADERS += config.h \ 3 | dialog_chooseurlfromlist.h \ 4 | dialog_setup.h \ 5 | kde-qt.h \ 6 | mainwindow.h \ 7 | recentfiles.h \ 8 | settings.h \ 9 | tab_bookmarks.h \ 10 | tab_contents.h \ 11 | tab_index.h \ 12 | tab_search.h \ 13 | version.h \ 14 | viewwindow.h \ 15 | viewwindowmgr.h \ 16 | navigationpanel.h \ 17 | checknewversion.h \ 18 | toolbarmanager.h \ 19 | toolbareditor.h \ 20 | textencodings.h \ 21 | treeitem_toc.h \ 22 | treeitem_index.h 23 | SOURCES += config.cpp \ 24 | dialog_chooseurlfromlist.cpp \ 25 | dialog_setup.cpp \ 26 | kde-qt.cpp \ 27 | main.cpp \ 28 | mainwindow.cpp \ 29 | recentfiles.cpp \ 30 | settings.cpp \ 31 | tab_bookmarks.cpp \ 32 | tab_contents.cpp \ 33 | tab_index.cpp \ 34 | tab_search.cpp \ 35 | viewwindowmgr.cpp \ 36 | navigationpanel.cpp \ 37 | checknewversion.cpp \ 38 | toolbarmanager.cpp \ 39 | toolbareditor.cpp \ 40 | textencodings.cpp \ 41 | treeitem_toc.cpp \ 42 | treeitem_index.cpp 43 | TARGET = ../bin/kchmviewer 44 | CONFIG += threads \ 45 | warn_on \ 46 | precompile_header \ 47 | xml 48 | TEMPLATE = app 49 | FORMS += tab_bookmarks.ui \ 50 | tab_index.ui \ 51 | tab_contents.ui \ 52 | tab_search.ui \ 53 | dialog_setup.ui \ 54 | dialog_topicselector.ui \ 55 | mainwindow.ui \ 56 | window_browser.ui \ 57 | navigatorpanel.ui \ 58 | dialog_about.ui \ 59 | toolbareditor.ui 60 | RESOURCES += resources/images.qrc 61 | 62 | QT += xml network widgets printsupport 63 | 64 | linux-g++*:{ 65 | LIBS += -lX11 66 | } 67 | 68 | # This is used by cross-build on 64-bit when building a 32-bit version 69 | linux-g++-32: { 70 | LIBS += -L. 71 | } 72 | 73 | # General per-platform settings 74 | macx: { 75 | HEADERS += kchmviewerapp.h 76 | SOURCES += kchmviewerapp.cpp 77 | QMAKE_INFO_PLIST=resources/Info.plist 78 | QMAKE_POST_LINK += cp resources/*.icns ${DESTDIR}/kchmviewer.app/Contents/Resources; 79 | LIBS += ../lib/libebook/libebook.a 80 | POST_TARGETDEPS += ../lib/libebook/libebook.a 81 | } 82 | 83 | win32-*: { 84 | 85 | # Only for Creator build; also uncomment one in libebook 86 | #LIBPATH += C:/Users/Test/Documents/builder/extralibs/x64/lib 87 | 88 | CONFIG( debug, debug|release ) { 89 | LIBS += "../lib/libebook/debug/ebook.lib" 90 | POST_TARGETDEPS += "../lib/libebook/debug/ebook.lib" 91 | } else { 92 | LIBS += "../lib/libebook/release/ebook.lib" 93 | POST_TARGETDEPS += "../lib/libebook/release/ebook.lib" 94 | } 95 | 96 | LIBS += -lwsock32 -loleaut32 97 | } 98 | 99 | unix:!macx: { 100 | 101 | QT += dbus 102 | HEADERS += dbus_interface.h 103 | SOURCES += dbus_interface.cpp 104 | CONFIG += dbus 105 | LIBS += ../lib/libebook/libebook.a 106 | POST_TARGETDEPS += ../lib/libebook/libebook.a 107 | } 108 | LIBS += -lchm -lzip 109 | 110 | greaterThan(QT_MAJOR_VERSION, 4) { 111 | # Qt 5 112 | greaterThan(QT_MINOR_VERSION, 5) { 113 | # Qt 5.6+ 114 | # error("You use Qt5.6+ - QWebEngine is not yet suitable for kchmviewer and is not supported") 115 | QT += webengine webenginewidgets 116 | DEFINES += USE_WEBENGINE 117 | SOURCES += viewwindow_webengine.cpp dataprovider_qwebengine.cpp 118 | HEADERS += dataprovider_qwebengine.h viewwindow_webengine.h 119 | } else { 120 | # Qt 5.0-5.5 121 | QT += webkit webkitwidgets 122 | DEFINES += USE_WEBKIT 123 | SOURCES += viewwindow_webkit.cpp dataprovider_qwebkit.cpp 124 | HEADERS += dataprovider_qwebkit.h viewwindow_webkit.h 125 | } 126 | } else { 127 | message("Qt4 is not supported anymore, please do not report any errors") 128 | QT += webkit webkitwidgets 129 | DEFINES += USE_WEBKIT 130 | SOURCES += viewwindow_webkit.cpp dataprovider_qwebkit.cpp 131 | HEADERS += dataprovider_qwebkit.h viewwindow_webkit.h 132 | } 133 | -------------------------------------------------------------------------------- /src/tab_bookmarks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef TAB_BOOKMARK_H 20 | #define TAB_BOOKMARK_H 21 | 22 | #include "kde-qt.h" 23 | #include "settings.h" 24 | 25 | #include "ui_tab_bookmarks.h" 26 | 27 | 28 | class TabBookmarks : public QWidget, public Ui::TabBookmarks 29 | { 30 | Q_OBJECT 31 | public: 32 | TabBookmarks( QWidget *parent ); 33 | 34 | void createMenu( QMenu * menuBookmarks ); 35 | 36 | void restoreSettings ( const Settings::bookmark_saved_settings_t& settings ); 37 | void saveSettings ( Settings::bookmark_saved_settings_t& settings ); 38 | void invalidate(); 39 | void focus(); 40 | 41 | public slots: 42 | void onAddBookmarkPressed (); 43 | 44 | private slots: 45 | void actionBookmarkActivated(); 46 | void onDelBookmarkPressed( ); 47 | void onEditBookmarkPressed( ); 48 | void onItemActivated ( QListWidgetItem* ); 49 | void onContextMenuRequested ( const QPoint &point ); 50 | 51 | private: 52 | QMenu * m_menuBookmarks; 53 | QMenu * m_contextMenu; 54 | QString m_bookmarkFileName; 55 | bool m_listChanged; 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/tab_bookmarks.ui: -------------------------------------------------------------------------------- 1 | 2 | TabBookmarks 3 | 4 | 5 | 6 | 0 7 | 0 8 | 257 9 | 296 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 9 18 | 19 | 20 | 6 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 0 29 | 30 | 31 | 6 32 | 33 | 34 | 35 | 36 | &Add 37 | 38 | 39 | 40 | 41 | 42 | 43 | Edi&t 44 | 45 | 46 | 47 | 48 | 49 | 50 | &Del 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/tab_contents.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef TAB_CONTENTS_H 20 | #define TAB_CONTENTS_H 21 | 22 | #include "kde-qt.h" 23 | #include "treeitem_toc.h" 24 | #include "ui_tab_contents.h" 25 | 26 | 27 | class TabContents : public QWidget, public Ui::TabContents 28 | { 29 | Q_OBJECT 30 | public: 31 | TabContents( QWidget *parent = 0 ); 32 | ~TabContents(); 33 | 34 | void refillTableOfContents(); 35 | void showItem( TreeItem_TOC * item ); 36 | void search( const QString& text ); 37 | void focus(); 38 | 39 | TreeItem_TOC * getTreeItem(const QUrl &url ); 40 | 41 | public slots: 42 | void onContextMenuRequested ( const QPoint &point ); 43 | void onClicked ( QTreeWidgetItem * item, int column ); 44 | 45 | private: 46 | QMenu * m_contextMenu; 47 | }; 48 | 49 | 50 | #endif /* INCLUDE_KCHMCONTENTSWINDOW_H */ 51 | -------------------------------------------------------------------------------- /src/tab_contents.ui: -------------------------------------------------------------------------------- 1 | 2 | TabContents 3 | 4 | 5 | 6 | 0 7 | 0 8 | 257 9 | 424 10 | 11 | 12 | 13 | Form1 14 | 15 | 16 | 17 | 9 18 | 19 | 20 | 6 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/tab_index.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef TAB_INDEX_H 20 | #define TAB_INDEX_H 21 | 22 | 23 | #include "kde-qt.h" 24 | #include "ui_tab_index.h" 25 | 26 | 27 | class TabIndex : public QWidget, public Ui::TabIndex 28 | { 29 | Q_OBJECT 30 | public: 31 | TabIndex( QWidget * parent = 0 ); 32 | 33 | void invalidate(); 34 | void search( const QString& index ); 35 | void focus(); 36 | 37 | private slots: 38 | void onTextChanged ( const QString & newvalue); 39 | void onReturnPressed (); 40 | void onItemActivated ( QTreeWidgetItem * item, int column ); 41 | void onContextMenuRequested ( const QPoint &point ); 42 | 43 | private: 44 | void showEvent ( QShowEvent * ); 45 | 46 | void refillIndex(); 47 | 48 | QMenu * m_contextMenu; 49 | QTreeWidgetItem * m_lastSelectedItem; 50 | bool m_indexListFilled; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/tab_index.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | TabIndex 4 | 5 | 6 | 7 | 0 8 | 0 9 | 173 10 | 382 11 | 12 | 13 | 14 | Form1 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | F&ind: 23 | 24 | 25 | text 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 10 38 | 39 | 40 | false 41 | 42 | 43 | true 44 | 45 | 46 | 1 47 | 48 | 49 | 50 | 1 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/tab_search.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef TAB_SEARCH_H 20 | #define TAB_SEARCH_H 21 | 22 | #include "kde-qt.h" 23 | #include "settings.h" 24 | #include "ui_tab_search.h" 25 | 26 | class EBookSearch; 27 | 28 | class TabSearch : public QWidget, public Ui::TabSearch 29 | { 30 | Q_OBJECT 31 | public: 32 | TabSearch( QWidget * parent = 0 ); 33 | 34 | void invalidate(); 35 | void restoreSettings (const Settings::search_saved_settings_t& settings); 36 | void saveSettings( Settings::search_saved_settings_t& settings ); 37 | void execSearchQueryInGui( const QString& query ); 38 | bool searchQuery(const QString& query, QList *results ); 39 | void focus(); 40 | 41 | private slots: 42 | void onContextMenuRequested ( const QPoint &point ); 43 | void onHelpClicked( const QString & ); 44 | void onReturnPressed (); 45 | void onItemActivated( QTreeWidgetItem * item, int ); 46 | 47 | // For index generation 48 | void onProgressStep( int value, const QString& stepName ); 49 | 50 | private: 51 | bool initSearchEngine(); 52 | 53 | private: 54 | QMenu * m_contextMenu; 55 | EBookSearch * m_searchEngine; 56 | bool m_searchEngineInitDone; 57 | 58 | // For index generation 59 | QProgressDialog * m_genIndexProgress; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/tab_search.ui: -------------------------------------------------------------------------------- 1 | 2 | TabSearch 3 | 4 | 5 | 6 | 0 7 | 0 8 | 210 9 | 409 10 | 11 | 12 | 13 | Form1 14 | 15 | 16 | 17 | 9 18 | 19 | 20 | 6 21 | 22 | 23 | 24 | 25 | 0 26 | 27 | 28 | 6 29 | 30 | 31 | 32 | 33 | Type in word(s) to search for: 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 0 42 | 0 43 | 0 44 | 0 45 | 46 | 47 | 48 | <a href="help">Help</a> 49 | 50 | 51 | Qt::RichText 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 0 61 | 62 | 63 | 6 64 | 65 | 66 | 67 | 68 | 69 | 7 70 | 0 71 | 2 72 | 0 73 | 74 | 75 | 76 | true 77 | 78 | 79 | 10 80 | 81 | 82 | 83 | 84 | 85 | 86 | &Go 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | false 96 | 97 | 98 | false 99 | 100 | 101 | false 102 | 103 | 104 | true 105 | 106 | 107 | 2 108 | 109 | 110 | 111 | Title 112 | 113 | 114 | 115 | 116 | Location 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /src/textencodings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "textencodings.h" 20 | 21 | typedef struct 22 | { 23 | const char * language; 24 | const char * qtcodec; 25 | } TextEncodingEntry; 26 | 27 | static const TextEncodingEntry text_encoding_table [] = 28 | { 29 | { 30 | "Arabic", 31 | "CP1256" 32 | }, 33 | 34 | { 35 | "Baltic", 36 | "CP1257" 37 | }, 38 | 39 | { 40 | "Central European", 41 | "CP1250" 42 | }, 43 | 44 | { 45 | "Chinese Simplified", 46 | "GB18030" 47 | }, 48 | 49 | { 50 | "Chinese Simplified", 51 | "GBK" 52 | }, 53 | 54 | { 55 | "Chinese Simplified", 56 | "GB2313" 57 | }, 58 | 59 | { 60 | "Chinese Simplified", 61 | "UTF-8/GBK" 62 | }, 63 | 64 | { 65 | "Chinese Simplified", 66 | "GBK/UTF-8" 67 | }, 68 | 69 | { 70 | "Chinese Traditional", 71 | "Big5" 72 | }, 73 | 74 | { 75 | "Chinese Traditional", 76 | "Big5-HKSCS", 77 | }, 78 | 79 | { 80 | "Cyrillic", 81 | "CP1251", 82 | }, 83 | 84 | { 85 | "Cyrillic", 86 | "KOI8-R", 87 | }, 88 | 89 | { 90 | "Cyrillic Broken", 91 | "CP1251/KOI8-R", 92 | }, 93 | 94 | { 95 | "Cyrillic Broken", 96 | "KOI8-R/CP1251", 97 | }, 98 | 99 | { 100 | "Greek", 101 | "CP1253", 102 | }, 103 | 104 | { 105 | "Hebrew", 106 | "CP1255", 107 | }, 108 | 109 | { 110 | "Japanese", 111 | "Shift-JIS", 112 | }, 113 | 114 | { 115 | "Japanese", 116 | "eucJP", 117 | }, 118 | 119 | { 120 | "Japanese", 121 | "JIS7", 122 | }, 123 | 124 | { 125 | "Korean", 126 | "eucKR", 127 | }, 128 | 129 | { 130 | "Tamil", 131 | "TSCII", 132 | }, 133 | 134 | { 135 | "Thai", 136 | "TIS-620", 137 | }, 138 | 139 | { 140 | "Ukrainian", 141 | "KOI8-U" 142 | }, 143 | 144 | { 145 | "Turkish", 146 | "CP1254" 147 | }, 148 | 149 | { 150 | "Vietnamese", 151 | "CP1258" 152 | }, 153 | 154 | { 155 | "Unicode", 156 | "UTF-8" 157 | }, 158 | 159 | { 160 | "Unicode", 161 | "UTF-16", 162 | }, 163 | 164 | { 165 | "Western", 166 | "CP1252", 167 | }, 168 | 169 | { 0, 0 } 170 | }; 171 | 172 | 173 | TextEncodings::TextEncodings() 174 | { 175 | } 176 | 177 | void TextEncodings::getSupported(QStringList &languages, QStringList &qtcodecs) 178 | { 179 | for ( const TextEncodingEntry * e = text_encoding_table; e->language; e++ ) 180 | { 181 | languages.push_back( e->language ); 182 | qtcodecs.push_back( e->qtcodec ); 183 | } 184 | } 185 | 186 | QString TextEncodings::languageForCodec(const QString &qtcodec) 187 | { 188 | for ( const TextEncodingEntry * e = text_encoding_table; e->language; e++ ) 189 | { 190 | if ( e->qtcodec == qtcodec ) 191 | return e->language; 192 | } 193 | 194 | return "Unknown"; 195 | } 196 | -------------------------------------------------------------------------------- /src/textencodings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef TEXTENCODINGS_H 20 | #define TEXTENCODINGS_H 21 | 22 | #include 23 | 24 | class TextEncodings 25 | { 26 | public: 27 | TextEncodings(); 28 | 29 | static void getSupported( QStringList& languages, QStringList& qtcodecs ); 30 | static QString languageForCodec( const QString& qtcodec ); 31 | }; 32 | 33 | #endif // TEXTENCODINGS_H 34 | -------------------------------------------------------------------------------- /src/toolbareditor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef TOOLBAREDITOR_H 20 | #define TOOLBAREDITOR_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "ui_toolbareditor.h" 30 | 31 | class ToolbarEditor : public QDialog, public Ui::ToolbarEditor 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | // Returns true if an action name in the list actionsForToolbar() is a separator 37 | static bool isSeparatorName( const QString& name ); 38 | 39 | public: 40 | ToolbarEditor( QWidget *parent = 0 ); 41 | ~ToolbarEditor(); 42 | 43 | // Add a toolbar to the list of toolbars to be editer 44 | void addToolbar( QToolBar * toolbar ); 45 | 46 | // Add toolbars to the list of toolbars to be editer 47 | void addToolbars( QList toolbars ); 48 | 49 | // Set the actions available to select in toolbars. Actions present in toolbars must be 50 | // present in this list, or they will not be shown. 51 | void setAvailableActions( QList availableActions ); 52 | 53 | // Enables or disables showing actions without icons in the available/selected lists. 54 | // Enabled by default. 55 | void setAllowActionsWithoutIcons( bool allow ); 56 | 57 | // Returns a list of selected actions for a specific toolbar 58 | QStringList actionsForToolbar( QToolBar * toolbar ); 59 | 60 | public slots: 61 | void toolbarSelected( int index ); 62 | void accept(); 63 | int exec(); 64 | 65 | private: 66 | friend class ActionListModel; 67 | QAction * findAction( const QString& objectname ) const; 68 | 69 | // Adds the existing toolbar actions into the internal storage 70 | void initToolbarActions( QToolBar * toolbar ); 71 | 72 | // Copies the changed toolbar actions from the list into the internal storage 73 | void updateToolbarActions( QToolBar * toolbar ); 74 | 75 | // Shows the current toolbar actions in views 76 | void setupViews( QToolBar * toolbar ); 77 | 78 | private: 79 | // A list of all available actions 80 | QList m_availableActions; 81 | 82 | // A vector of edited toolbars to preserve the order 83 | QList< QToolBar* > m_toolbars; 84 | 85 | // A map of edited toolbars with selected actions 86 | QMap< QToolBar*, QStringList > m_selected; 87 | 88 | // Currently shown actions for toolbar 89 | QToolBar * m_activeToolbar; 90 | 91 | // Params 92 | bool m_allowActionsWithoutIcons; 93 | }; 94 | 95 | 96 | #endif // TOOLBAREDITOR_H 97 | -------------------------------------------------------------------------------- /src/toolbareditor.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ToolbarEditor 4 | 5 | 6 | 7 | 0 8 | 0 9 | 497 10 | 386 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 20 | Select a toolbar 21 | 22 | 23 | 24 | 25 | 26 | Editing the toolbar 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 1 35 | 0 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | Drag the actions to the toolbar list to add them to the toolbar. 47 | Drag them from toolbar list to remove them from the toolbar. 48 | 49 | 50 | Qt::AlignCenter 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 0 61 | 2 62 | 63 | 64 | 65 | Available actions 66 | 67 | 68 | 69 | 70 | 71 | true 72 | 73 | 74 | QAbstractItemView::DragDrop 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 0 86 | 2 87 | 88 | 89 | 90 | Toolbar actions 91 | 92 | 93 | 94 | 95 | 96 | true 97 | 98 | 99 | QAbstractItemView::DragDrop 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | Qt::Horizontal 112 | 113 | 114 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | buttonBox 124 | accepted() 125 | ToolbarEditor 126 | accept() 127 | 128 | 129 | 248 130 | 254 131 | 132 | 133 | 157 134 | 274 135 | 136 | 137 | 138 | 139 | buttonBox 140 | rejected() 141 | ToolbarEditor 142 | reject() 143 | 144 | 145 | 316 146 | 260 147 | 148 | 149 | 286 150 | 274 151 | 152 | 153 | 154 | 155 | 156 | -------------------------------------------------------------------------------- /src/toolbarmanager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | #include "toolbareditor.h" 22 | #include "toolbarmanager.h" 23 | 24 | 25 | QString ToolbarManager::separatorName() 26 | { 27 | return ".separator."; 28 | } 29 | 30 | QString ToolbarManager::actionName( QAction * action ) 31 | { 32 | if ( action->isSeparator() ) 33 | return ToolbarManager::separatorName(); 34 | else 35 | return action->objectName(); 36 | } 37 | 38 | bool ToolbarManager::hasAction( const QList& actions, QAction* action ) 39 | { 40 | foreach ( QAction* act, actions ) 41 | if ( ToolbarManager::actionName( act ) == ToolbarManager::actionName( action ) ) 42 | return true; 43 | 44 | return false; 45 | } 46 | 47 | 48 | ToolbarManager::ToolbarManager( QObject * parent, const QString& settingpath ) 49 | : QObject( parent ) 50 | { 51 | m_settingsRoot = settingpath; 52 | } 53 | 54 | ToolbarManager::~ToolbarManager() 55 | { 56 | } 57 | 58 | void ToolbarManager::setAvailableActions( QList availableActions ) 59 | { 60 | m_availableActions = availableActions; 61 | } 62 | 63 | void ToolbarManager::queryAvailableActions( QObject * source ) 64 | { 65 | m_availableActions.clear(); 66 | 67 | // Enumerate through all available actions, and add them 68 | QObjectList objs = source->children(); 69 | 70 | for ( QObjectList::const_iterator it = objs.begin(); it != objs.end(); ++it ) 71 | if ( !strcmp( (*it)->metaObject()->className(), "QAction" ) ) 72 | m_availableActions.push_back( (QAction*) *it ); 73 | } 74 | 75 | void ToolbarManager::addManaged( QToolBar * toolbar ) 76 | { 77 | m_toolbars.push_back( toolbar ); 78 | } 79 | 80 | void ToolbarManager::applyActions( QToolBar * toolbar, const QStringList& actions ) 81 | { 82 | // Apply the actions to the toolbar 83 | toolbar->clear(); 84 | 85 | foreach( QString name, actions ) 86 | { 87 | if ( name == separatorName() ) 88 | { 89 | toolbar->addSeparator(); 90 | continue; 91 | } 92 | 93 | foreach ( QAction* action, m_availableActions ) 94 | { 95 | if ( actionName( action ) == name ) 96 | { 97 | toolbar->addAction( action ); 98 | break; 99 | } 100 | } 101 | } 102 | } 103 | 104 | void ToolbarManager::load() 105 | { 106 | if ( m_availableActions.isEmpty() ) 107 | qWarning( "ToolbarManager::load(): available action list is empty, did you forget to call setAvailableActions()?" ); 108 | 109 | QSettings settings; 110 | 111 | foreach( QToolBar * toolbar, m_toolbars ) 112 | { 113 | QString settingName = m_settingsRoot + toolbar->objectName(); 114 | 115 | // Do we have stored settings for this toolbar? 116 | if ( !settings.contains( settingName ) ) 117 | continue; 118 | 119 | applyActions( toolbar, settings.value( settingName ).toStringList() ); 120 | } 121 | } 122 | 123 | void ToolbarManager::save() 124 | { 125 | QSettings settings; 126 | 127 | foreach( QToolBar * toolbar, m_toolbars ) 128 | { 129 | QString settingName = m_settingsRoot + toolbar->objectName(); 130 | QStringList names; 131 | 132 | foreach ( QAction* action, toolbar->actions() ) 133 | { 134 | if ( action->isSeparator() ) 135 | names.push_back( separatorName() ); 136 | else if ( hasAction( m_availableActions, action ) ) 137 | names.push_back( actionName( action ) ); 138 | } 139 | 140 | settings.setValue( settingName, names ); 141 | } 142 | } 143 | 144 | void ToolbarManager::editDialog() 145 | { 146 | ToolbarEditor dlg; 147 | dlg.setAvailableActions( m_availableActions ); 148 | dlg.addToolbars( m_toolbars ); 149 | 150 | if ( dlg.exec() == QDialog::Rejected ) 151 | return; 152 | 153 | foreach( QToolBar * toolbar, m_toolbars ) 154 | applyActions( toolbar, dlg.actionsForToolbar( toolbar ) ); 155 | } 156 | -------------------------------------------------------------------------------- /src/toolbarmanager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef TOOLBARMANAGER_H 20 | #define TOOLBARMANAGER_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | // This class manages application toolbars, including the following: 29 | // - Stores and restores the toolbars, including their position and content; 30 | // - Allows toolbar editing; 31 | class ToolbarManager : public QObject 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | // Returns the name of the separator object which should be used in place 37 | // of separators where needed. 38 | static QString separatorName(); 39 | static QString actionName( QAction * action ); 40 | static bool hasAction( const QList& actions, QAction* action ); 41 | 42 | ToolbarManager( QObject * parent = 0, const QString& settingpath = "/tooolbars" ); 43 | virtual ~ToolbarManager(); 44 | 45 | // Set the actions available in all toolbars. Actions which are stored for toolbars 46 | // must be present in this list, or they will be ignored. 47 | void setAvailableActions( QList availableActions ); 48 | 49 | // Query the actions available to set in toolbar from the provided QObject as children 50 | // of this object. Typically (always for UIC-generated files) all actions have application 51 | // MainWindow as their parent. 52 | void queryAvailableActions( QObject * source ); 53 | 54 | // Adds a toolbar to the list of managed toolbars 55 | void addManaged( QToolBar * toolbar ); 56 | 57 | // Loads the managed toolbars actions; keeps toolbars intact if nothing is loaded 58 | void load(); 59 | 60 | // Saves the managed toolbars actions 61 | void save(); 62 | 63 | // Shows the edit toolbars dialog 64 | void editDialog(); 65 | 66 | private: 67 | void applyActions( QToolBar * toolbar, const QStringList& actions ); 68 | 69 | // Keeps available actions 70 | QList m_availableActions; 71 | 72 | // Keeps the managed toolbars 73 | QList< QToolBar *> m_toolbars; 74 | 75 | // Setting name 76 | QString m_settingsRoot; 77 | }; 78 | 79 | #endif // TOOLBARMANAGER_H 80 | -------------------------------------------------------------------------------- /src/treeitem_index.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "ebook.h" 20 | #include "mainwindow.h" 21 | #include "dialog_chooseurlfromlist.h" 22 | #include "treeitem_index.h" 23 | 24 | TreeItem_Index::TreeItem_Index(QTreeWidgetItem *parent, QTreeWidgetItem *after, const QString &name, const QList &urls, const QString& seealso) 25 | : QTreeWidgetItem( parent, after ) 26 | { 27 | m_name = name; 28 | m_urls = urls; 29 | m_seealso = seealso; 30 | } 31 | 32 | TreeItem_Index::TreeItem_Index(QTreeWidget *parent, QTreeWidgetItem *after, const QString &name, const QList &urls, const QString &seealso) 33 | : QTreeWidgetItem( parent, after ) 34 | { 35 | m_name = name; 36 | m_urls = urls; 37 | m_seealso = seealso; 38 | } 39 | 40 | QUrl TreeItem_Index::getUrl() const 41 | { 42 | if ( m_urls.size() == 1 ) 43 | return m_urls.front(); 44 | 45 | // Create a dialog with URLs, and show it, so user can select an URL he/she wants. 46 | QStringList titles; 47 | EBook * xchm = ::mainWindow->chmFile(); 48 | 49 | for ( int i = 0; i < m_urls.size(); i++ ) 50 | { 51 | QString title = xchm->getTopicByUrl( m_urls[i] ); 52 | 53 | if ( title.isEmpty() ) 54 | { 55 | qWarning( "Could not get item name for url '%s'", qPrintable( m_urls[i].toString() ) ); 56 | titles.push_back(QString::null); 57 | } 58 | else 59 | titles.push_back(title); 60 | } 61 | 62 | DialogChooseUrlFromList dlg( ::mainWindow ); 63 | return dlg.getSelectedItemUrl( m_urls, titles ); 64 | } 65 | 66 | bool TreeItem_Index::containstUrl(const QUrl &url) const 67 | { 68 | for ( int i = 0; i < m_urls.size(); i++ ) 69 | { 70 | if ( m_urls[i] == url ) 71 | return true; 72 | } 73 | 74 | return false; 75 | } 76 | 77 | bool TreeItem_Index::isSeeAlso() const 78 | { 79 | return !m_seealso.isEmpty(); 80 | } 81 | 82 | QString TreeItem_Index::seeAlso() const 83 | { 84 | return m_seealso; 85 | } 86 | 87 | int TreeItem_Index::columnCount() const 88 | { 89 | return 1; 90 | } 91 | 92 | QVariant TreeItem_Index::data(int column, int role) const 93 | { 94 | if ( column != 0 ) 95 | return QVariant(); 96 | 97 | switch( role ) 98 | { 99 | // Item name 100 | case Qt::DisplayRole: 101 | return m_name; 102 | 103 | // Item foreground color 104 | case Qt::ForegroundRole: 105 | // For Index URL it means that there is URL list in m_url 106 | if ( m_urls.size() > 1 ) 107 | return QBrush( QColor( Qt::red ) ); 108 | else if ( isSeeAlso() ) 109 | return QBrush( QColor( Qt::lightGray ) ); 110 | break; 111 | 112 | case Qt::ToolTipRole: 113 | case Qt::WhatsThisRole: 114 | return m_name; 115 | } 116 | 117 | return QVariant(); 118 | } 119 | -------------------------------------------------------------------------------- /src/treeitem_index.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef TREEITEM_INDEX_H 20 | #define TREEITEM_INDEX_H 21 | 22 | #include 23 | 24 | class TreeItem_Index : public QTreeWidgetItem 25 | { 26 | public: 27 | TreeItem_Index( QTreeWidgetItem* parent, QTreeWidgetItem* after, const QString& name, const QList& urls, const QString& seealso ); 28 | TreeItem_Index( QTreeWidget* parent, QTreeWidgetItem* after, const QString& name, const QList& urls, const QString& seealso ); 29 | 30 | QUrl getUrl() const; 31 | bool containstUrl( const QUrl& url ) const; 32 | bool isSeeAlso() const; 33 | QString seeAlso() const; 34 | 35 | // Overridden methods 36 | int columnCount () const; 37 | QVariant data ( int column, int role ) const; 38 | 39 | private: 40 | QString m_name; 41 | QList m_urls; 42 | QString m_seealso; 43 | }; 44 | 45 | #endif // TREEITEM_INDEX_H 46 | -------------------------------------------------------------------------------- /src/treeitem_toc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "ebook.h" 20 | #include "mainwindow.h" 21 | #include "treeitem_toc.h" 22 | 23 | TreeItem_TOC::TreeItem_TOC(QTreeWidgetItem *parent, QTreeWidgetItem *after, const QString &name, const QUrl &url, int image) 24 | : QTreeWidgetItem( parent, after ) 25 | { 26 | m_name = name; 27 | m_url = url; 28 | m_image = image; 29 | } 30 | 31 | TreeItem_TOC::TreeItem_TOC(QTreeWidget *parent, QTreeWidgetItem *after, const QString &name, const QUrl &url, int image) 32 | : QTreeWidgetItem( parent, after ) 33 | { 34 | m_name = name; 35 | m_url = url; 36 | m_image = image; 37 | } 38 | 39 | QUrl TreeItem_TOC::getUrl() const 40 | { 41 | return m_url; 42 | } 43 | 44 | bool TreeItem_TOC::containstUrl(const QUrl &url, bool ignorefragment ) const 45 | { 46 | if ( ignorefragment ) 47 | { 48 | // This appears to be a bug in Qt: the url.path() returns a proper path starting with /, 49 | // but m_url.path() returns a relative URL starting with no / - so we make sure both are. 50 | QString urlpath = url.path(); 51 | QString ourpath = m_url.path(); 52 | 53 | // Memory allocation-wise this must really suck :( however this code is rarely used, 54 | // and only for buggy epub/chms. 55 | if ( !urlpath.startsWith( '/') ) 56 | urlpath.prepend( '/' ); 57 | 58 | if ( !ourpath.startsWith( '/') ) 59 | ourpath.prepend( '/' ); 60 | 61 | return urlpath == ourpath; 62 | } 63 | else 64 | { 65 | return url == m_url; 66 | } 67 | } 68 | 69 | int TreeItem_TOC::columnCount() const 70 | { 71 | return 1; 72 | } 73 | 74 | QVariant TreeItem_TOC::data(int column, int role) const 75 | { 76 | int imagenum; 77 | 78 | if ( column != 0 ) 79 | return QVariant(); 80 | 81 | switch( role ) 82 | { 83 | // Item name 84 | case Qt::DisplayRole: 85 | return m_name; 86 | 87 | // Item image 88 | case Qt::DecorationRole: 89 | if ( m_image != EBookTocEntry::IMAGE_NONE ) 90 | { 91 | // If the item has children, we change the book image to "open book", or next image automatically 92 | if ( childCount() ) 93 | { 94 | if ( isExpanded() ) 95 | imagenum = (m_image == EBookTocEntry::IMAGE_AUTO) ? 1 : m_image; 96 | else 97 | imagenum = (m_image == EBookTocEntry::IMAGE_AUTO) ? 0 : m_image + 1; 98 | } 99 | else 100 | imagenum = (m_image == EBookTocEntry::IMAGE_AUTO) ? 10 : m_image; 101 | 102 | const QPixmap *pix = ::mainWindow->getEBookIconPixmap( (EBookTocEntry::Icon) imagenum ); 103 | 104 | if ( !pix || pix->isNull() ) 105 | abort(); 106 | 107 | return *pix; 108 | } 109 | break; 110 | 111 | case Qt::ToolTipRole: 112 | case Qt::WhatsThisRole: 113 | return m_name; 114 | } 115 | 116 | return QVariant(); 117 | } 118 | -------------------------------------------------------------------------------- /src/treeitem_toc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef TREEITEM_TOC_H 20 | #define TREEITEM_TOC_H 21 | 22 | #include 23 | 24 | class TreeItem_TOC : public QTreeWidgetItem 25 | { 26 | public: 27 | TreeItem_TOC( QTreeWidgetItem* parent, QTreeWidgetItem* after, const QString& name, const QUrl& url, int image ); 28 | TreeItem_TOC( QTreeWidget* parent, QTreeWidgetItem* after, const QString& name, const QUrl& url, int image ); 29 | 30 | QUrl getUrl() const; 31 | bool containstUrl(const QUrl& url , bool ignorefragment ) const; 32 | 33 | // Overridden methods 34 | int columnCount () const; 35 | QVariant data ( int column, int role ) const; 36 | 37 | private: 38 | QString m_name; 39 | QUrl m_url; 40 | int m_image; 41 | }; 42 | 43 | #endif // TREEITEM_TOC_H 44 | -------------------------------------------------------------------------------- /src/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef INCLUDE_VERSION_H 20 | #define INCLUDE_VERSION_H 21 | 22 | #define APP_VERSION_MAJOR 8 23 | #define APP_VERSION_MINOR 0 24 | 25 | #endif /* INCLUDE_VERSION_H */ 26 | -------------------------------------------------------------------------------- /src/viewwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef VIEWWINDOW_H 2 | #define VIEWWINDOW_H 3 | 4 | // We support both engines 5 | #if defined (USE_WEBENGINE) 6 | #include "viewwindow_webengine.h" 7 | #else 8 | #include "viewwindow_webkit.h" 9 | #endif 10 | 11 | #endif // VIEWWINDOW_H 12 | -------------------------------------------------------------------------------- /src/viewwindow_webengine.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2016 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef VIEWWINDOW_WEBENGINE_H 20 | #define VIEWWINDOW_WEBENGINE_H 21 | 22 | #include 23 | 24 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) 25 | #include 26 | #endif 27 | 28 | #include "kde-qt.h" 29 | #include "dataprovider_qwebengine.h" 30 | 31 | class ViewWindow : public QWebEngineView 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | ViewWindow( QWidget * parent ); 37 | virtual ~ViewWindow(); 38 | 39 | //! Open a page from current chm archive 40 | bool openUrl (const QUrl& url ); 41 | 42 | QUrl getOpenedPage() const { return url(); } 43 | QUrl getNewTabLink() const { return m_newTabLinkKeeper; } 44 | 45 | static void initialize(); 46 | 47 | signals: 48 | void dataLoaded( ViewWindow * window ); 49 | 50 | public: 51 | // Apply the configuration settings (JS enabled etc) to the web renderer 52 | static void applySettings(); 53 | 54 | //! Invalidate current view, doing all the cleanups etc. 55 | void invalidate(); 56 | 57 | //! Popups the print dialog, and prints the current page on the printer. 58 | bool printCurrentPage(); 59 | 60 | //! Return current ZoomFactor. 61 | qreal getZoomFactor() const; 62 | 63 | //! Sets ZoomFactor. The value returned by getZoomFactor(), given to this function, should give the same result. 64 | void setZoomFactor( qreal zoom ); 65 | 66 | /*! 67 | * Return current scrollbar position in view window. Saved on program exit. 68 | * There is no restriction on returned value, except that giving this value to 69 | * setScrollbarPosition() should move the scrollbar in the same position. 70 | */ 71 | int getScrollbarPosition(); 72 | 73 | //! Sets the scrollbar position. 74 | void setScrollbarPosition(int pos, bool force = false); 75 | 76 | //! Select the content of the whole page 77 | void clipSelectAll(); 78 | 79 | //! Copies the selected content to the clipboard 80 | void clipCopy(); 81 | 82 | //! Updates the history toolbar icon status 83 | void updateHistoryIcons(); 84 | 85 | //! Returns the window title 86 | QString title() const; 87 | 88 | //! Navigation stuff 89 | void navigateBack(); 90 | void navigateHome(); 91 | void navigateForward(); 92 | 93 | //! Keeps the tab URL between link following 94 | void setTabKeeper ( const QUrl& link ); 95 | 96 | public slots: 97 | void zoomIncrease(); 98 | void zoomDecrease(); 99 | 100 | protected: 101 | bool openPage ( const QUrl& url ); 102 | void handleStartPageAsImage( QUrl& link ); 103 | 104 | QMenu * getContextMenu( const QUrl& link, QWidget * parent ); 105 | QMenu * createStandardContextMenu( QWidget * parent ); 106 | 107 | // Overriden to change the source 108 | void setSource ( const QUrl & name ); 109 | //QString anchorAt( const QPoint & pos ); 110 | 111 | // Overloaded to provide custom context menu 112 | void contextMenuEvent( QContextMenuEvent *e ); 113 | //void mouseReleaseEvent ( QMouseEvent * event ); 114 | 115 | virtual QWebEngineView* createWindow(QWebEnginePage::WebWindowType type) override; 116 | 117 | private slots: 118 | // Used to restore the scrollbar position and the navigation button status 119 | void onLoadFinished ( bool ok ); 120 | 121 | private: 122 | QMenu * m_contextMenu; 123 | QMenu * m_contextMenuLink; 124 | 125 | // This member keeps a "open new tab" link between getContextMenu() 126 | // call and appropriate slot call 127 | QUrl m_newTabLinkKeeper; 128 | 129 | // Keeps the scrollbar position to move after the page is loaded. 130 | // It is set to -1 if no scrollbar position has been set and the page is not loaded yet 131 | // It is set to 0 if no scrollbar position has been set and the page is loaded already 132 | int m_storedScrollbarPosition; 133 | }; 134 | 135 | #endif // VIEWWINDOW_WEBENGINE_H 136 | -------------------------------------------------------------------------------- /src/viewwindow_webkit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef VIEWWINDOW_WEBKIT_H 20 | #define VIEWWINDOW_WEBKIT_H 21 | 22 | #include 23 | 24 | #include "kde-qt.h" 25 | 26 | class ViewWindow : public QWebView 27 | { 28 | Q_OBJECT 29 | 30 | public: 31 | ViewWindow( QWidget * parent ); 32 | virtual ~ViewWindow(); 33 | 34 | //! Open a page from current chm archive 35 | bool openUrl (const QUrl& url ); 36 | 37 | QUrl getOpenedPage() const { return url(); } 38 | QUrl getNewTabLink() const { return m_newTabLinkKeeper; } 39 | 40 | static void initialize(); 41 | 42 | signals: 43 | void dataLoaded( ViewWindow * window ); 44 | 45 | public: 46 | // Apply the configuration settings (JS enabled etc) to the web renderer 47 | static void applySettings(); 48 | 49 | //! Invalidate current view, doing all the cleanups etc. 50 | void invalidate(); 51 | 52 | //! Popups the print dialog, and prints the current page on the printer. 53 | bool printCurrentPage(); 54 | 55 | //! Return current ZoomFactor. 56 | qreal getZoomFactor() const; 57 | 58 | //! Sets ZoomFactor. The value returned by getZoomFactor(), given to this function, should give the same result. 59 | void setZoomFactor( qreal zoom ); 60 | 61 | /*! 62 | * Return current scrollbar position in view window. Saved on program exit. 63 | * There is no restriction on returned value, except that giving this value to 64 | * setScrollbarPosition() should move the scrollbar in the same position. 65 | */ 66 | int getScrollbarPosition(); 67 | 68 | //! Sets the scrollbar position. 69 | void setScrollbarPosition(int pos, bool force = false); 70 | 71 | //! Select the content of the whole page 72 | void clipSelectAll(); 73 | 74 | //! Copies the selected content to the clipboard 75 | void clipCopy(); 76 | 77 | //! Updates the history toolbar icon status 78 | void updateHistoryIcons(); 79 | 80 | //! Returns the window title 81 | QString title() const; 82 | 83 | //! Navigation stuff 84 | void navigateBack(); 85 | void navigateHome(); 86 | void navigateForward(); 87 | 88 | //! Keeps the tab URL between link following 89 | void setTabKeeper ( const QUrl& link ); 90 | 91 | public slots: 92 | void zoomIncrease(); 93 | void zoomDecrease(); 94 | 95 | protected: 96 | bool openPage ( const QUrl& url ); 97 | void handleStartPageAsImage( QUrl& link ); 98 | 99 | QMenu * getContextMenu( const QUrl& link, QWidget * parent ); 100 | QMenu * createStandardContextMenu( QWidget * parent ); 101 | 102 | // Overriden to change the source 103 | void setSource ( const QUrl & name ); 104 | QString anchorAt( const QPoint & pos ); 105 | 106 | // Overloaded to provide custom context menu 107 | void contextMenuEvent( QContextMenuEvent *e ); 108 | void mouseReleaseEvent ( QMouseEvent * event ); 109 | 110 | private slots: 111 | // Used to restore the scrollbar position and the navigation button status 112 | void onLoadFinished ( bool ok ); 113 | 114 | private: 115 | QMenu * m_contextMenu; 116 | QMenu * m_contextMenuLink; 117 | 118 | // This member keeps a "open new tab" link between getContextMenu() 119 | // call and appropriate slot call 120 | QUrl m_newTabLinkKeeper; 121 | 122 | // Keeps the scrollbar position to move after the page is loaded 123 | int m_storedScrollbarPosition; 124 | }; 125 | 126 | #endif 127 | -------------------------------------------------------------------------------- /src/viewwindowmgr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kchmviewer - a CHM and EPUB file viewer with broad language support 3 | * Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef VIEWWINDOWMGR_H 20 | #define VIEWWINDOWMGR_H 21 | 22 | #include "kde-qt.h" 23 | #include "settings.h" 24 | #include "ui_window_browser.h" 25 | 26 | 27 | class ViewWindowTabWidget; 28 | 29 | class ViewWindowMgr : public QWidget, public Ui::TabbedBrowser 30 | { 31 | Q_OBJECT 32 | public: 33 | ViewWindowMgr( QWidget *parent ); 34 | ~ViewWindowMgr( ); 35 | 36 | // Returns a handle to a currently viewed window. 37 | // Guaranteeed to return a valid handle, or aborts. 38 | ViewWindow * current(); 39 | 40 | // Adds a new tab, creating a new browser window 41 | ViewWindow * addNewTab( bool set_active ); 42 | 43 | // Sets the tab name and updates Windows menu 44 | void setTabName( ViewWindow* window ); 45 | 46 | void invalidate(); 47 | 48 | // Creates a Window menu 49 | void createMenu( MainWindow * parent, QMenu * menuWindow, QAction * actionCloseWindow ); 50 | 51 | // Saves and restores current settings between sessions 52 | void restoreSettings( const Settings::viewindow_saved_settings_t& settings ); 53 | void saveSettings( Settings::viewindow_saved_settings_t& settings ); 54 | 55 | void setCurrentPage( int index ); 56 | int currentPageIndex() const; 57 | 58 | // Reloads all windows 59 | void reloadAllWindows(); 60 | 61 | // Set up the configuration settings 62 | void applyBrowserSettings(); 63 | 64 | public slots: 65 | void onCloseCurrentWindow(); 66 | void onCloseWindow( int num ); 67 | void onActivateFind(); 68 | void onFindNext(); 69 | void onFindPrevious(); 70 | void onWindowContentChanged(ViewWindow *window ); 71 | void copyUrlToClipboard(); 72 | 73 | protected slots: 74 | void openNewTab(); 75 | void onTabChanged( int newtabIndex ); 76 | void updateCloseButtons(); 77 | void activateWindow(); 78 | void closeSearch(); 79 | 80 | void editTextEdited( const QString & text ); 81 | 82 | private: 83 | void find( bool backward = false ); 84 | 85 | typedef struct 86 | { 87 | QWidget * widget; 88 | ViewWindow * window; 89 | QAction * action; 90 | } TabData; 91 | 92 | void closeAllWindows(); 93 | void closeWindow( QWidget * widget ); 94 | TabData * findTab( QWidget * widget ); 95 | 96 | // Storage of all available windows 97 | QList< TabData > m_Windows; 98 | typedef QList< TabData >::iterator WindowsIterator; 99 | 100 | QMenu * m_menuWindow; 101 | QAction * m_actionCloseWindow; 102 | 103 | // Window menu actions. Contains one action per window. They are not 104 | // linked permanently - if a middle window is deleted, all the following 105 | // actions will be relinked and replaced. 106 | QList< QAction* > m_actions; 107 | 108 | // Last word searched 109 | QString m_lastSearchedWord; 110 | 111 | ViewWindowTabWidget * m_tabWidget; 112 | }; 113 | 114 | #endif /* INCLUDE_KCHMVIEWWINDOWMGR_H */ 115 | -------------------------------------------------------------------------------- /templates/cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2004-2005 by Georgy Yunaev, gyunaev@ulduzsoft.com * 3 | * Please do not use email address above for bug reports; see * 4 | * the README file * 5 | * * 6 | * This program is free software; you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, write to the * 18 | * Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | -------------------------------------------------------------------------------- /templates/h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2004-2005 by Georgy Yunaev, gyunaev@ulduzsoft.com * 3 | * Please do not use email address above for bug reports; see * 4 | * the README file * 5 | * * 6 | * This program is free software; you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, write to the * 18 | * Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | -------------------------------------------------------------------------------- /tests/autotest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | CHMDIR="/mnt/ebooks /mnt/disk_d/Docs" 4 | #KCHMVIEWER="../src/kchmviewer" 5 | KCHMVIEWER="../bin/kchmviewer" 6 | COMMONLOG="autotest.log" 7 | FATALLOG="fatal.log" 8 | CMDOPTIONS="--nocrashhandler" 9 | 10 | #find $CHMDIR -iname "*.chm" -print -exec 11 | 12 | find $CHMDIR -iname "*.chm" -print | while read file; do 13 | 14 | echo "Testing file $file" 15 | echo "File $file" >> $COMMONLOG 16 | $KCHMVIEWER $CMDOPTIONS --shortautotestmode "$file" >>$COMMONLOG 2>&1 17 | 18 | if test $? != 0; then 19 | echo "$file FAILED, exit code $?!" >> FATALLOG 20 | fi 21 | 22 | done 23 | --------------------------------------------------------------------------------