-rw-r--r-- | core/apps/.cvsignore | 1 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/MyPty.cpp | 1 | ||||
-rw-r--r-- | core/apps/helpbrowser/helpbrowser.cpp | 48 | ||||
-rw-r--r-- | core/apps/helpbrowser/helpbrowser.h | 4 | ||||
-rw-r--r-- | core/apps/helpbrowser/helpbrowser.pro | 4 | ||||
-rw-r--r-- | core/apps/helpbrowser/magictextbrowser.cpp | 99 | ||||
-rw-r--r-- | core/apps/helpbrowser/magictextbrowser.h | 42 | ||||
-rw-r--r-- | core/apps/helpbrowser/main.cpp | 9 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 8 |
9 files changed, 188 insertions, 28 deletions
diff --git a/core/apps/.cvsignore b/core/apps/.cvsignore index faa68ae..6d678c6 100644 --- a/core/apps/.cvsignore +++ b/core/apps/.cvsignore | |||
@@ -1,2 +1 @@ | |||
1 | binconfig.in | ||
2 | config.in | config.in | |
diff --git a/core/apps/embeddedkonsole/MyPty.cpp b/core/apps/embeddedkonsole/MyPty.cpp index 9adc248..7e820ad 100644 --- a/core/apps/embeddedkonsole/MyPty.cpp +++ b/core/apps/embeddedkonsole/MyPty.cpp | |||
@@ -165,2 +165,3 @@ int MyPty::run(const char* cmd, QStrList &, const char*, int) | |||
165 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); | 165 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); |
166 | if(strlen(getenv("TERM"))<=0) | ||
166 | setenv("TERM","vt100",1); | 167 | setenv("TERM","vt100",1); |
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,5 +1,5 @@ | |||
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 | ** |
@@ -20,2 +20,4 @@ | |||
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_LANGLIST | ||
22 | |||
21 | #include "helpbrowser.h" | 23 | #include "helpbrowser.h" |
@@ -24,2 +26,4 @@ | |||
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> |
@@ -32,2 +36,3 @@ | |||
32 | #include <qpe/qpetoolbar.h> | 36 | #include <qpe/qpetoolbar.h> |
37 | #include <qpe/qcopenvelope_qws.h> | ||
33 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
@@ -50,4 +55,5 @@ | |||
50 | 55 | ||
51 | #include <ctype.h> | 56 | #include <cctype> |
52 | 57 | ||
58 | #include "magictextbrowser.h" | ||
53 | 59 | ||
@@ -60,7 +66,10 @@ HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) | |||
60 | 66 | ||
67 | |||
68 | |||
61 | void HelpBrowser::init( const QString& _home ) | 69 | void 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 ); |
@@ -82,3 +91,3 @@ void HelpBrowser::init( const QString& _home ) | |||
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 ); |
@@ -87,3 +96,3 @@ void HelpBrowser::init( const QString& _home ) | |||
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 ); |
@@ -95,3 +104,3 @@ void HelpBrowser::init( const QString& _home ) | |||
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 ); |
@@ -99,6 +108,5 @@ void HelpBrowser::init( const QString& _home ) | |||
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 ); |
@@ -114,3 +122,3 @@ void HelpBrowser::init( const QString& _home ) | |||
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 ); |
@@ -119,2 +127,9 @@ void HelpBrowser::init( const QString& _home ) | |||
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 | ||
@@ -126,2 +141,3 @@ void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) | |||
126 | { | 141 | { |
142 | qDebug("reached appMessage"); | ||
127 | if ( msg == "showFile(QString)" ) { | 143 | if ( msg == "showFile(QString)" ) { |
@@ -131,2 +147,8 @@ void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) | |||
131 | setDocument( fn ); | 147 | setDocument( fn ); |
148 | |||
149 | QPEApplication::setKeepRunning(); | ||
150 | |||
151 | showMaximized(); | ||
152 | setActiveWindow(); | ||
153 | raise(); | ||
132 | } | 154 | } |
diff --git a/core/apps/helpbrowser/helpbrowser.h b/core/apps/helpbrowser/helpbrowser.h index 2f7153a..5f7e6b6 100644 --- a/core/apps/helpbrowser/helpbrowser.h +++ b/core/apps/helpbrowser/helpbrowser.h | |||
@@ -1,5 +1,5 @@ | |||
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 | ** |
diff --git a/core/apps/helpbrowser/helpbrowser.pro b/core/apps/helpbrowser/helpbrowser.pro index 6bb43bd..3525b7e 100644 --- a/core/apps/helpbrowser/helpbrowser.pro +++ b/core/apps/helpbrowser/helpbrowser.pro | |||
@@ -3,4 +3,4 @@ CONFIG = qt warn_on release | |||
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS = helpbrowser.h | 4 | HEADERS = helpbrowser.h magictextbrowser.h |
5 | SOURCES = helpbrowser.cpp \ | 5 | SOURCES = helpbrowser.cpp magictextbrowser.cpp \ |
6 | main.cpp | 6 | main.cpp |
diff --git a/core/apps/helpbrowser/magictextbrowser.cpp b/core/apps/helpbrowser/magictextbrowser.cpp new file mode 100644 index 0000000..8ce0325 --- a/dev/null +++ b/core/apps/helpbrowser/magictextbrowser.cpp | |||
@@ -0,0 +1,99 @@ | |||
1 | #include <qfile.h> | ||
2 | #include <qstring.h> | ||
3 | #include <qdragobject.h> | ||
4 | #include <qregexp.h> | ||
5 | |||
6 | /* need to get Global::helpPath() */ | ||
7 | #define QTOPIA_INTERNAL_LANGLIST | ||
8 | |||
9 | #include <qtopia/global.h> | ||
10 | #include <qtopia/mimetype.h> | ||
11 | #include <qtopia/applnk.h> | ||
12 | |||
13 | #include "magictextbrowser.h" | ||
14 | |||
15 | |||
16 | |||
17 | MagicTextBrowser::MagicTextBrowser(QWidget* parent) : | ||
18 | QTextBrowser(parent){ | ||
19 | } | ||
20 | |||
21 | void MagicTextBrowser::setSource( const QString& source ) { | ||
22 | QTextBrowser::setSource(source); | ||
23 | if ( magicQpe(source,"applications") || magicQpe(source,"games") || magicQpe(source,"settings") || magicQpe(source, "1Pim") ) // No tr | ||
24 | return; | ||
25 | if ( magicOpe(source, "applets") || magicOpe(source, "input") ) | ||
26 | return; | ||
27 | // Just those are magic (for now). Could do CGI here, | ||
28 | // or in Qtopia's mime source factory. | ||
29 | } | ||
30 | |||
31 | bool MagicTextBrowser::magicQpe(const QString& source, const QString& name) { | ||
32 | if ( name+".html" == source || "help/"+name+".html" == source) { | ||
33 | QString fn = mimeSourceFactory()->makeAbsolute( source, context() ); | ||
34 | const QMimeSource* m = mimeSourceFactory()->data( fn, context() ); | ||
35 | if ( m ) { | ||
36 | QString txt; | ||
37 | if ( QTextDrag::decode(m,txt) ) { | ||
38 | QRegExp re("<qtopia-"+name+">.*</qtopia-"+name+">"); | ||
39 | int start,len; | ||
40 | if ( (start=re.match(txt,0,&len))>=0 ) { | ||
41 | QString generated = generateQpe(name); | ||
42 | txt.replace(start,len,generated); | ||
43 | setText(txt); | ||
44 | return true; | ||
45 | } | ||
46 | } | ||
47 | } | ||
48 | } | ||
49 | return false; | ||
50 | } | ||
51 | bool MagicTextBrowser::magicOpe( const QString& source, const QString& name ) { | ||
52 | if ( name+".html" != source && "help/"+name+".html" != source) return false; | ||
53 | |||
54 | QString fn = mimeSourceFactory()->makeAbsolute( source, context() ); | ||
55 | const QMimeSource* m = mimeSourceFactory()->data(fn, context() ); | ||
56 | if (!m) return false; | ||
57 | |||
58 | QString txt; | ||
59 | if ( !QTextDrag::decode(m, txt ) ) return false; | ||
60 | |||
61 | QRegExp re("<opie-"+name+">.*</opie-"+name+">"); | ||
62 | int start,len; | ||
63 | if ( (start=re.match(txt,0,&len))>=0 ) { | ||
64 | QString generated = generateOpe(name); | ||
65 | txt.replace(start,len,generated); | ||
66 | setText(txt); | ||
67 | return true; | ||
68 | } | ||
69 | return false; | ||
70 | } | ||
71 | QString MagicTextBrowser::generateOpe(const QString& name)const { | ||
72 | if ( name == QString::fromLatin1("applets") ) { | ||
73 | return QString::fromLatin1("<h3>No Applets found</h3>"); | ||
74 | }else if ( name == QString::fromLatin1("input") ) { | ||
75 | return QString::fromLatin1("<h3>No input methods available</h3>"); | ||
76 | }else | ||
77 | return QString::null; | ||
78 | } | ||
79 | |||
80 | QString MagicTextBrowser::generateQpe(const QString& name) const { | ||
81 | QString dir = MimeType::appsFolderName()+"/"+name[0].upper()+name.mid(1); | ||
82 | AppLnkSet lnkset(dir); | ||
83 | AppLnk* lnk; | ||
84 | QString r; | ||
85 | for (QListIterator<AppLnk> it(lnkset.children()); (lnk=it.current()); ++it) { | ||
86 | QString name = lnk->name(); | ||
87 | QString icon = lnk->icon(); | ||
88 | QString helpFile = lnk->exec()+".html"; | ||
89 | QStringList helpPath = Global::helpPath(); | ||
90 | bool helpExists = FALSE; | ||
91 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) | ||
92 | helpExists = QFile::exists( *it + "/" + helpFile ); | ||
93 | |||
94 | if ( helpExists ) { | ||
95 | r += "<h3><a href="+helpFile+"><img src="+icon+">"+name+"</a></h3>\n"; | ||
96 | } | ||
97 | } | ||
98 | return r; | ||
99 | } | ||
diff --git a/core/apps/helpbrowser/magictextbrowser.h b/core/apps/helpbrowser/magictextbrowser.h new file mode 100644 index 0000000..ff91e68 --- a/dev/null +++ b/core/apps/helpbrowser/magictextbrowser.h | |||
@@ -0,0 +1,42 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
3 | ** Copyright (C) 2003 zecke | ||
4 | ** | ||
5 | ** This file is part of the Qtopia Environment. | ||
6 | ** | ||
7 | ** This file may be distributed and/or modified under the terms of the | ||
8 | ** GNU General Public License version 2 as published by the Free Software | ||
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
10 | ** packaging of this file. | ||
11 | ** | ||
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
14 | ** | ||
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
16 | ** | ||
17 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
18 | ** not clear to you. | ||
19 | ** | ||
20 | **********************************************************************/ | ||
21 | #ifndef HELP_BROWSER_MAGIC_TEXT_BROWSER_H | ||
22 | #define HELP_BROWSER_MAGIC_TEXT_BROWSER_H | ||
23 | |||
24 | #include <qtextbrowser.h> | ||
25 | |||
26 | class MagicTextBrowser : public QTextBrowser { | ||
27 | public: | ||
28 | MagicTextBrowser(QWidget* parent); | ||
29 | |||
30 | void setSource( const QString& source ); | ||
31 | |||
32 | /** honor QPE Attributes */ | ||
33 | bool magicQpe(const QString& source, const QString& name); | ||
34 | /** honor OPIE Attributes */ | ||
35 | bool magicOpe(const QString& source, const QString& name ); | ||
36 | private: | ||
37 | |||
38 | QString generateQpe(const QString& name) const; | ||
39 | QString generateOpe(const QString& name) const; | ||
40 | }; | ||
41 | |||
42 | #endif | ||
diff --git a/core/apps/helpbrowser/main.cpp b/core/apps/helpbrowser/main.cpp index 1cb10b7..b1bea56 100644 --- a/core/apps/helpbrowser/main.cpp +++ b/core/apps/helpbrowser/main.cpp | |||
@@ -1,5 +1,5 @@ | |||
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 | ** |
@@ -22,3 +22,3 @@ | |||
22 | 22 | ||
23 | #include <qpe/qpeapplication.h> | 23 | #include <qtopia/qpeapplication.h> |
24 | 24 | ||
@@ -29,4 +29,3 @@ int main( int argc, char ** argv ) | |||
29 | HelpBrowser mw; | 29 | HelpBrowser mw; |
30 | mw.setCaption( HelpBrowser::tr("HelpBrowser") ); | 30 | a.showMainWidget( &mw ); |
31 | a.showMainDocumentWidget( &mw ); | ||
32 | 31 | ||
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 6f96574..1c95a97 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -571,3 +571,2 @@ void TextEdit::fileOpen() { | |||
571 | cfg. setGroup ( "View" ); | 571 | cfg. setGroup ( "View" ); |
572 | QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir()); | ||
573 | QMap<QString, QStringList> map; | 572 | QMap<QString, QStringList> map; |
@@ -580,3 +579,3 @@ void TextEdit::fileOpen() { | |||
580 | QString str = OFileDialog::getOpenFileName( 2, | 579 | QString str = OFileDialog::getOpenFileName( 2, |
581 | dir , | 580 | QString::null , |
582 | QString::null, map); | 581 | QString::null, map); |
@@ -584,3 +583,2 @@ void TextEdit::fileOpen() { | |||
584 | { | 583 | { |
585 | cfg.writeEntry("LastOpenDirectory", QFileInfo(str).dirPath(false)); | ||
586 | openFile( str ); | 584 | openFile( str ); |
@@ -978,3 +976,3 @@ void TextEdit::updateCaption( const QString &name ) { | |||
978 | // s = s.right(s.length()-1); | 976 | // s = s.right(s.length()-1); |
979 | setCaption( s + " - " + tr("Text Editor") ); | 977 | setCaption( tr("%1 - Text Editor").arg( s ) ); |
980 | } | 978 | } |
@@ -1024,3 +1022,3 @@ void TextEdit::editDelete() { | |||
1024 | "the current file\nfrom the disk?<BR>This is " | 1022 | "the current file\nfrom the disk?<BR>This is " |
1025 | "<B>irreversable!!</B>"), | 1023 | "<B>irreversable!</B>"), |
1026 | tr("Yes"),tr("No"),0,0,1) ) { | 1024 | tr("Yes"),tr("No"),0,0,1) ) { |