summaryrefslogtreecommitdiff
path: root/core/apps/helpbrowser/helpbrowser.cpp
Unidiff
Diffstat (limited to 'core/apps/helpbrowser/helpbrowser.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/apps/helpbrowser/helpbrowser.cpp48
1 files changed, 35 insertions, 13 deletions
diff --git a/core/apps/helpbrowser/helpbrowser.cpp b/core/apps/helpbrowser/helpbrowser.cpp
index 48da7c6..531dbff 100644
--- a/core/apps/helpbrowser/helpbrowser.cpp
+++ b/core/apps/helpbrowser/helpbrowser.cpp
@@ -1,10 +1,10 @@
1#/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
@@ -15,24 +15,29 @@
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#define QTOPIA_INTERNAL_LANGLIST
22
21#include "helpbrowser.h" 23#include "helpbrowser.h"
22 24
23#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
24#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/mimetype.h>
28#include <qpe/applnk.h>
25#include <qpe/global.h> 29#include <qpe/global.h>
26 30
27#include <qstatusbar.h> 31#include <qstatusbar.h>
28#include <qdragobject.h> 32#include <qdragobject.h>
29#include <qpixmap.h> 33#include <qpixmap.h>
30#include <qpopupmenu.h> 34#include <qpopupmenu.h>
31#include <qpe/qpemenubar.h> 35#include <qpe/qpemenubar.h>
32#include <qpe/qpetoolbar.h> 36#include <qpe/qpetoolbar.h>
37#include <qpe/qcopenvelope_qws.h>
33#include <qtoolbutton.h> 38#include <qtoolbutton.h>
34#include <qiconset.h> 39#include <qiconset.h>
35#include <qfile.h> 40#include <qfile.h>
36#include <qtextstream.h> 41#include <qtextstream.h>
37#include <qstylesheet.h> 42#include <qstylesheet.h>
38#include <qmessagebox.h> 43#include <qmessagebox.h>
@@ -45,27 +50,31 @@
45#include <qdatastream.h> 50#include <qdatastream.h>
46#include <qprinter.h> 51#include <qprinter.h>
47#include <qsimplerichtext.h> 52#include <qsimplerichtext.h>
48#include <qpaintdevicemetrics.h> 53#include <qpaintdevicemetrics.h>
49#include <qaction.h> 54#include <qaction.h>
50 55
51#include <ctype.h> 56#include <cctype>
52 57
58#include "magictextbrowser.h"
53 59
54HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) 60HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f )
55 : QMainWindow( parent, name, f ), 61 : QMainWindow( parent, name, f ),
56 selectedURL() 62 selectedURL()
57{ 63{
58 init( "index.html" ); 64 init( "index.html" );
59} 65}
60 66
67
68
61void HelpBrowser::init( const QString& _home ) 69void HelpBrowser::init( const QString& _home )
62{ 70{
63 setIcon( Resource::loadPixmap( "help_icon" ) ); 71 setIcon( Resource::loadPixmap( "HelpBrowser" ) );
72 setBackgroundMode( PaletteButton );
64 73
65 browser = new QTextBrowser( this ); 74 browser = new MagicTextBrowser( this );
66 browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 75 browser->setFrameStyle( QFrame::Panel | QFrame::Sunken );
67 connect( browser, SIGNAL( textChanged() ), 76 connect( browser, SIGNAL( textChanged() ),
68 this, SLOT( textChanged() ) ); 77 this, SLOT( textChanged() ) );
69 78
70 setCentralWidget( browser ); 79 setCentralWidget( browser );
71 setToolBarsMovable( FALSE ); 80 setToolBarsMovable( FALSE );
@@ -77,61 +86,74 @@ void HelpBrowser::init( const QString& _home )
77 toolbar->setHorizontalStretchable( TRUE ); 86 toolbar->setHorizontalStretchable( TRUE );
78 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 87 QPEMenuBar *menu = new QPEMenuBar( toolbar );
79 88
80 toolbar = new QPEToolBar( this ); 89 toolbar = new QPEToolBar( this );
81 // addToolBar( toolbar, "Toolbar"); 90 // addToolBar( toolbar, "Toolbar");
82 91
83 //QPopupMenu* go = new QPopupMenu( this ); 92 QPopupMenu* go = new QPopupMenu( this );
84 backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 ); 93 backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 );
85 connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) ); 94 connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) );
86 connect( browser, SIGNAL( backwardAvailable( bool ) ), 95 connect( browser, SIGNAL( backwardAvailable( bool ) ),
87 backAction, SLOT( setEnabled( bool ) ) ); 96 backAction, SLOT( setEnabled( bool ) ) );
88 //backAction->addTo( go ); 97 backAction->addTo( go );
89 backAction->addTo( toolbar ); 98 backAction->addTo( toolbar );
90 backAction->setEnabled( FALSE ); 99 backAction->setEnabled( FALSE );
91 100
92 forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 ); 101 forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 );
93 connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) ); 102 connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) );
94 connect( browser, SIGNAL( forwardAvailable( bool ) ), 103 connect( browser, SIGNAL( forwardAvailable( bool ) ),
95 forwardAction, SLOT( setEnabled( bool ) ) ); 104 forwardAction, SLOT( setEnabled( bool ) ) );
96 //forwardAction->addTo( go ); 105 forwardAction->addTo( go );
97 forwardAction->addTo( toolbar ); 106 forwardAction->addTo( toolbar );
98 forwardAction->setEnabled( FALSE ); 107 forwardAction->setEnabled( FALSE );
99 108
100 QAction *a = new QAction( tr( "Home" ), Resource::loadPixmap( 109 QAction *a = new QAction( tr( "Home" ), Resource::loadIconSet( "home" ), QString::null, 0, this, 0 );
101"home" ), QString::null, 0, this, 0 );
102 connect( a, SIGNAL( activated() ), browser, SLOT( home() ) ); 110 connect( a, SIGNAL( activated() ), browser, SLOT( home() ) );
103 //a->addTo( go ); 111 a->addTo( go );
104 a->addTo( toolbar ); 112 a->addTo( toolbar );
105 113
106 bookm = new QPopupMenu( this ); 114 bookm = new QPopupMenu( this );
107 bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); 115 bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) );
108 bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) ); 116 bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) );
109 bookm->insertSeparator(); 117 bookm->insertSeparator();
110 connect( bookm, SIGNAL( activated( int ) ), 118 connect( bookm, SIGNAL( activated( int ) ),
111 this, SLOT( bookmChosen( int ) ) ); 119 this, SLOT( bookmChosen( int ) ) );
112 120
113 readBookmarks(); 121 readBookmarks();
114 122
115 //menu->insertItem( tr("Go"), go ); 123 menu->insertItem( tr("Go"), go );
116 menu->insertItem( tr( "Bookmarks" ), bookm ); 124 menu->insertItem( tr( "Bookmarks" ), bookm );
117 125
118 resize( 240, 300 ); 126 resize( 240, 300 );
119 browser->setFocus(); 127 browser->setFocus();
128 browser->setFrameStyle( QFrame::NoFrame );
129
130#if !defined(QT_NO_COP)
131 QCopChannel *addressChannel = new QCopChannel("QPE/HelpBrowser" , this );
132 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)),
133 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) );
134#endif
120 135
121 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), 136 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
122 this, SLOT(appMessage(const QCString&, const QByteArray&)) ); 137 this, SLOT(appMessage(const QCString&, const QByteArray&)) );
123} 138}
124 139
125void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) 140void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data)
126{ 141{
142 qDebug("reached appMessage");
127 if ( msg == "showFile(QString)" ) { 143 if ( msg == "showFile(QString)" ) {
128 QDataStream ds(data,IO_ReadOnly); 144 QDataStream ds(data,IO_ReadOnly);
129 QString fn; 145 QString fn;
130 ds >> fn; 146 ds >> fn;
131 setDocument( fn ); 147 setDocument( fn );
148
149 QPEApplication::setKeepRunning();
150
151 showMaximized();
152 setActiveWindow();
153 raise();
132 } 154 }
133} 155}
134 156
135void HelpBrowser::setDocument( const QString &doc ) 157void HelpBrowser::setDocument( const QString &doc )
136{ 158{
137 if ( !doc.isEmpty() ) 159 if ( !doc.isEmpty() )