From 3aef1afb880077b776d9807b1186a6744d851760 Mon Sep 17 00:00:00 2001 From: Darrell Anderson Date: Wed, 19 Feb 2014 18:58:08 -0600 Subject: Add help handbook, add DocPath, rename files. --- src/tde/Makefile.am | 8 ++ src/tde/kchmdcopiface.cpp | 86 +++++++++++++++++ src/tde/kchmdcopiface.h | 59 ++++++++++++ src/tde/kchmdcopiface_skel.cpp | 98 ++++++++++++++++++++ src/tde/kchmviewwindow_tdehtmlpart.cpp | 163 +++++++++++++++++++++++++++++++++ src/tde/kchmviewwindow_tdehtmlpart.h | 118 ++++++++++++++++++++++++ 6 files changed, 532 insertions(+) create mode 100644 src/tde/Makefile.am create mode 100644 src/tde/kchmdcopiface.cpp create mode 100644 src/tde/kchmdcopiface.h create mode 100644 src/tde/kchmdcopiface_skel.cpp create mode 100644 src/tde/kchmviewwindow_tdehtmlpart.cpp create mode 100644 src/tde/kchmviewwindow_tdehtmlpart.h (limited to 'src/tde') diff --git a/src/tde/Makefile.am b/src/tde/Makefile.am new file mode 100644 index 0000000..8524867 --- /dev/null +++ b/src/tde/Makefile.am @@ -0,0 +1,8 @@ +lib_LIBRARIES=libkdeextra.a +libkdeextra_a_SOURCES = kchmdcopiface.cpp kchmdcopiface.skel kchmviewwindow_tdehtmlpart.cpp +noinst_HEADERS = kchmdcopiface.h kchmviewwindow_tdehtmlpart.h + +INCLUDES = $(QT_INCLUDES) $(CHM_INCLUDES) $(KDE_INCLUDES) $(LIBCHMFILE_INCLUDES) + +METASOURCES = AUTO +KDE_OPTIONS = qtonly diff --git a/src/tde/kchmdcopiface.cpp b/src/tde/kchmdcopiface.cpp new file mode 100644 index 0000000..d6a90da --- /dev/null +++ b/src/tde/kchmdcopiface.cpp @@ -0,0 +1,86 @@ +/*************************************************************************** + * Copyright (C) 2004-2005 by Georgy Yunaev, gyunaev@ulduzsoft.com * + * Please do not use email address above for bug reports; see * + * the README file * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include "kchmdcopiface.h" +#include "kchmdcopiface.moc" + +#include "kchmmainwindow.h" +#include "kchmsearchwindow.h" + + +KCHMDCOPIface::KCHMDCOPIface(TQObject *parent, const char *name) + : TQObject(parent, name), DCOPObject( "KCHMDCOPIface" ) +{ +} + + +KCHMDCOPIface::~KCHMDCOPIface() +{ +} + + +void KCHMDCOPIface::loadHelpFile( const TQString & filename, const TQString & page2open ) +{ + TQStringList args; + + args.push_back( filename ); + args.push_back( page2open ); + + tqApp->postEvent( ::mainWindow, new KCHMUserEvent( "loadAndOpen", args ) ); +} + + +void KCHMDCOPIface::openPage( const TQString & page2open ) +{ + TQStringList args; + + args.push_back( page2open ); + tqApp->postEvent( ::mainWindow, new KCHMUserEvent( "openPage", args ) ); +} + + +void KCHMDCOPIface::guiFindInIndex( const TQString & word ) +{ + TQStringList args; + + args.push_back( word ); + tqApp->postEvent( ::mainWindow, new KCHMUserEvent( "findInIndex", args ) ); +} + + +void KCHMDCOPIface::guiSearchQuery( const TQString & query ) +{ + TQStringList args; + + args.push_back( query ); + tqApp->postEvent( ::mainWindow, new KCHMUserEvent( "searchQuery", args ) ); +} + +TQStringList KCHMDCOPIface::searchQuery( const TQString & query ) +{ + TQStringList results; + + if ( ::mainWindow->searchWindow()->searchQuery( query, &results ) ) + return results; + else + return TQStringList(); +} + diff --git a/src/tde/kchmdcopiface.h b/src/tde/kchmdcopiface.h new file mode 100644 index 0000000..6922a82 --- /dev/null +++ b/src/tde/kchmdcopiface.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * Copyright (C) 2004-2005 by Georgy Yunaev, gyunaev@ulduzsoft.com * + * Please do not use email address above for bug reports; see * + * the README file * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifndef KCHMDCOPIFACE_H +#define KCHMDCOPIFACE_H + +#include +#include +#include +#include + +class KCHMDCOPIface : public TQObject, public DCOPObject +{ + Q_OBJECT +// + K_DCOP + + public: + KCHMDCOPIface( TQObject *parent = 0, const char *name = 0 ); + ~KCHMDCOPIface(); + + k_dcop: + //! Loads a CHM file \a filename , and opens the URL \a url. Use URL "/" to open default homepage + void loadHelpFile( const TQString& filename, const TQString& url ); + + //! Opens a specific \a url inside the loaded CHM file + void openPage( const TQString& url ); + + //! Tries to find word in index, opening the index window and scrolling it there + void guiFindInIndex( const TQString& word ); + + //! Executes a search in GUI. \a query contains the complete search query. + void guiSearchQuery( const TQString& query ); + + //! Executes a search; GUI is not involved and user sees nothing. + //! \a query contains the complete search query. + //! Returns a list of URLs, or empty array if nothing os + TQStringList searchQuery( const TQString& query ); +}; + +#endif diff --git a/src/tde/kchmdcopiface_skel.cpp b/src/tde/kchmdcopiface_skel.cpp new file mode 100644 index 0000000..be1e994 --- /dev/null +++ b/src/tde/kchmdcopiface_skel.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** DCOP Skeleton generated by dcopidl2cpp from kchmdcopiface.kidl +** +** WARNING! All changes made in this file will be lost! +** +*****************************************************************************/ + +#include "./kchmdcopiface.h" + +#include + + +static const char* const KCHMDCOPIface_ftable[6][3] = { + { "void", "loadHelpFile(TQString,TQString)", "loadHelpFile(TQString filename,TQString url)" }, + { "void", "openPage(TQString)", "openPage(TQString url)" }, + { "void", "guiFindInIndex(TQString)", "guiFindInIndex(TQString word)" }, + { "void", "guiSearchQuery(TQString)", "guiSearchQuery(TQString query)" }, + { TQSTRINGLIST_OBJECT_NAME_STRING, "searchQuery(TQString)", "searchQuery(TQString query)" }, + { 0, 0, 0 } +}; +static const int KCHMDCOPIface_ftable_hiddens[5] = { + 0, + 0, + 0, + 0, + 0, +}; + +bool KCHMDCOPIface::process(const TQCString &fun, const TQByteArray &data, TQCString& replyType, TQByteArray &replyData) +{ + if ( fun == KCHMDCOPIface_ftable[0][1] ) { // void loadHelpFile(TQString,TQString) + TQString arg0; + TQString arg1; + TQDataStream arg( data, IO_ReadOnly ); + if (arg.atEnd()) return false; + arg >> arg0; + if (arg.atEnd()) return false; + arg >> arg1; + replyType = KCHMDCOPIface_ftable[0][0]; + loadHelpFile(arg0, arg1 ); + } else if ( fun == KCHMDCOPIface_ftable[1][1] ) { // void openPage(TQString) + TQString arg0; + TQDataStream arg( data, IO_ReadOnly ); + if (arg.atEnd()) return false; + arg >> arg0; + replyType = KCHMDCOPIface_ftable[1][0]; + openPage(arg0 ); + } else if ( fun == KCHMDCOPIface_ftable[2][1] ) { // void guiFindInIndex(TQString) + TQString arg0; + TQDataStream arg( data, IO_ReadOnly ); + if (arg.atEnd()) return false; + arg >> arg0; + replyType = KCHMDCOPIface_ftable[2][0]; + guiFindInIndex(arg0 ); + } else if ( fun == KCHMDCOPIface_ftable[3][1] ) { // void guiSearchQuery(TQString) + TQString arg0; + TQDataStream arg( data, IO_ReadOnly ); + if (arg.atEnd()) return false; + arg >> arg0; + replyType = KCHMDCOPIface_ftable[3][0]; + guiSearchQuery(arg0 ); + } else if ( fun == KCHMDCOPIface_ftable[4][1] ) { // TQStringList searchQuery(TQString) + TQString arg0; + TQDataStream arg( data, IO_ReadOnly ); + if (arg.atEnd()) return false; + arg >> arg0; + replyType = KCHMDCOPIface_ftable[4][0]; + TQDataStream _replyStream( replyData, IO_WriteOnly ); + _replyStream << searchQuery(arg0 ); + } else { + return DCOPObject::process( fun, data, replyType, replyData ); + } + return true; +} + +QCStringList KCHMDCOPIface::interfaces() +{ + QCStringList ifaces = DCOPObject::interfaces(); + ifaces += "KCHMDCOPIface"; + return ifaces; +} + +QCStringList KCHMDCOPIface::functions() +{ + QCStringList funcs = DCOPObject::functions(); + for ( int i = 0; KCHMDCOPIface_ftable[i][2]; i++ ) { + if (KCHMDCOPIface_ftable_hiddens[i]) + continue; + TQCString func = KCHMDCOPIface_ftable[i][0]; + func += ' '; + func += KCHMDCOPIface_ftable[i][2]; + funcs << func; + } + return funcs; +} + + diff --git a/src/tde/kchmviewwindow_tdehtmlpart.cpp b/src/tde/kchmviewwindow_tdehtmlpart.cpp new file mode 100644 index 0000000..3a57e35 --- /dev/null +++ b/src/tde/kchmviewwindow_tdehtmlpart.cpp @@ -0,0 +1,163 @@ +/*************************************************************************** + * Copyright (C) 2004-2007 by Georgy Yunaev, gyunaev@ulduzsoft.com * + * Please do not use email address above for bug reports; see * + * the README file * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include + +#include +#include + +#include "tde-tqt.h" +#include "kchmmainwindow.h" +#include "kchmconfig.h" +#include "kchmviewwindow_tdehtmlpart.h" + +#include "kchmviewwindow_tdehtmlpart.moc" + + +TQWidget * KCHMViewWindow_TDEHTMLPart::getTQWidget() +{ + return view(); +} + +KCHMViewWindow_TDEHTMLPart::KCHMViewWindow_TDEHTMLPart( TQTabWidget * parent ) + : TDEHTMLPart ( parent ), KCHMViewWindow ( parent ) +{ + m_zoomfactor = 0; + m_currentEncoding = 0; + m_searchForward = true; + + invalidate(); + + connect( browserExtension(), TQT_SIGNAL( openURLRequest( const KURL &, const KParts::URLArgs & ) ), + this, TQT_SLOT ( onOpenURLRequest( const KURL &, const KParts::URLArgs & )) ); + + connect( this, TQT_SIGNAL ( popupMenu ( const TQString &, const TQPoint &) ), + this, TQT_SLOT ( onPopupMenu ( const TQString &, const TQPoint &) ) ); +} + + +KCHMViewWindow_TDEHTMLPart::~KCHMViewWindow_TDEHTMLPart() +{ +} + +bool KCHMViewWindow_TDEHTMLPart::openPage (const TQString& url) +{ + // Set or change the encoding + if ( m_currentEncoding != ::mainWindow->chmFile()->currentEncoding() ) + { + m_currentEncoding = ::mainWindow->chmFile()->currentEncoding(); + setEncoding ( m_currentEncoding->qtcodec, TRUE ); + } + + TQString fullurl = "ms-its:" + ::mainWindow->getOpenedFileName() + "::" + url; + openURL ( KURL(fullurl) ); + + return true; +} + +void KCHMViewWindow_TDEHTMLPart::setZoomFactor( int zoom ) +{ + m_zoomfactor = zoom; + + // Default ZoomFactor is 100, any increase or decrease should modify this value. + TDEHTMLPart::setZoomFactor ( 100 + (m_zoomfactor * 10) ); +} + +void KCHMViewWindow_TDEHTMLPart::invalidate( ) +{ + m_zoomfactor = 0; + m_searchForward = true; + m_searchText = TQString(); + + setJScriptEnabled ( appConfig.m_kdeEnableJS ); + setJavaEnabled ( appConfig.m_kdeEnableJava ); + setMetaRefreshEnabled ( appConfig.m_kdeEnableRefresh ); + setPluginsEnabled ( appConfig.m_kdeEnablePlugins ); + + KCHMViewWindow::invalidate( ); +} + +int KCHMViewWindow_TDEHTMLPart::getScrollbarPosition( ) +{ + return view()->contentsY (); +} + +void KCHMViewWindow_TDEHTMLPart::setScrollbarPosition( int pos ) +{ + view()->scrollBy (0, pos); +} + +void KCHMViewWindow_TDEHTMLPart::addZoomFactor( int value ) +{ + setZoomFactor( m_zoomfactor + value); +} + +bool KCHMViewWindow_TDEHTMLPart::printCurrentPage() +{ + view()->print(); + return true; +} + +void KCHMViewWindow_TDEHTMLPart::searchWord( const TQString & word, bool forward, bool ) +{ + if ( word != m_searchText || forward != m_searchForward ) + { + m_searchText = word; + m_searchForward = forward; + + findText ( word, forward ? 0 : KFindDialog::FindBackwards, ::mainWindow, 0 ); + } + + findTextNext (); +} + +void KCHMViewWindow_TDEHTMLPart::onOpenURLRequest( const KURL & url, const KParts::URLArgs & ) +{ + bool sourcechange = true; + emit signalLinkClicked ( url.prettyURL(), sourcechange ); +} + +void KCHMViewWindow_TDEHTMLPart::slotLinkClicked( const TQString & newlink ) +{ + bool notused; + emit signalLinkClicked (newlink, notused); +} + + +void KCHMViewWindow_TDEHTMLPart::clipSelectAll() +{ + selectAll (); +} + +void KCHMViewWindow_TDEHTMLPart::clipCopy() +{ + TQString text = selectedText(); + + if ( !text.isEmpty() ) + TQApplication::clipboard()->setText( text ); +} + +void KCHMViewWindow_TDEHTMLPart::onPopupMenu ( const TQString &url, const TQPoint & point ) +{ + KTQPopupMenu * menu = getContextMenu( url, view() ); + menu->exec( point ); +} + diff --git a/src/tde/kchmviewwindow_tdehtmlpart.h b/src/tde/kchmviewwindow_tdehtmlpart.h new file mode 100644 index 0000000..0dcbe47 --- /dev/null +++ b/src/tde/kchmviewwindow_tdehtmlpart.h @@ -0,0 +1,118 @@ +/*************************************************************************** + * Copyright (C) 2004-2007 by Georgy Yunaev, gyunaev@ulduzsoft.com * + * Please do not use email address above for bug reports; see * + * the README file * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifndef KCHMVIEWWINDOW_TDEHTMLPART_H +#define KCHMVIEWWINDOW_TDEHTMLPART_H + +#include "tde-tqt.h" + +#include "kchmviewwindow.h" +#include "kchmsourcefactory.h" +#include "libchmtextencoding.h" + +#ifdef Q_MOC_RUN +#define USE_KDE +#endif // Q_MOC_RUN + +/** +@author Georgy Yunaev +*/ +/* + * For TQt-only version, we cannot compile KCHMViewWindow_TDEHTMLPart. However, + * we cannot just exclude it, because it would not generate a MOC file for a KDE + * version. Therefore we declare it, and compile the .moc file, but do not provide + * the class methods. + */ +#if defined (USE_KDE) +class KCHMViewWindow_TDEHTMLPart : public TDEHTMLPart, public KCHMViewWindow +{ +Q_OBJECT + +public: + KCHMViewWindow_TDEHTMLPart( TQTabWidget * parent ); + ~KCHMViewWindow_TDEHTMLPart(); + + //! Open a page from current chm archive + virtual bool openPage (const TQString& url); + + //! Invalidate current view, doing all the cleanups etc. + virtual void invalidate(); + + //! Return current ZoomFactor. + virtual int getZoomFactor() const { return m_zoomfactor; } + + //! Sets ZoomFactor. The value returned by getZoomFactor(), given to this function, should give the same result. + virtual void setZoomFactor (int zoom); + + //! Relatively changes ZoomFactor. Most common values are -1 and 1. + virtual void addZoomFactor (int value); + + //! Popups the print dialog, and prints the current page on the printer. + virtual bool printCurrentPage(); + + //! Initiates the find-in-page search, if succeed, cursor moved to the first entry + virtual void searchWord( const TQString & word, bool forward = true, bool casesensitive = false ); + + //! Select the content of the whole page + virtual void clipSelectAll(); + + //! Copies the selected content to the clipboard + virtual void clipCopy(); + + /*! + * Return current scrollbar position in view window. Saved on program exit. + * There is no restriction on returned value, except that giving this value to + * setScrollbarPosition() should move the scrollbar in the same position. + */ + virtual int getScrollbarPosition(); + + //! Sets the scrollbar position. + virtual void setScrollbarPosition(int pos); + + virtual TQObject * getTQObject() { return this; } + virtual TQWidget * getTQWidget(); + +signals: + /*! + * Emitted when the user clicked on the link, before the page changed. + * If signalLinkClicked() sets follow_link to false, the current page should NOT change. + * Otherwise it should be changed to the new link value. + */ + void signalLinkClicked ( const TQString & newlink, bool& follow_link ); + +private slots: + virtual void slotLinkClicked ( const TQString & newlink); + virtual void onOpenURLRequest( const KURL &, const KParts::URLArgs & ); + virtual void onPopupMenu ( const TQString & url, const TQPoint & point ); + +private: + void setSource ( const TQString & name ); + + int m_zoomfactor; + bool m_searchForward; + TQString m_searchText; + + const LCHMTextEncoding * m_currentEncoding; +}; + +#endif /* USE_KDE */ + +#endif /* KCHMVIEWWINDOW_TDEHTMLPART_H */ -- cgit v1.2.3