summaryrefslogtreecommitdiff
path: root/core/apps
authorkergoth <kergoth>2003-08-09 17:42:14 (UTC)
committer kergoth <kergoth>2003-08-09 17:42:14 (UTC)
commit1ab4ca95e4d2cf24d32b38c9031cb6076351e730 (patch) (unidiff)
tree644d196b01c7f280981bd17da23c7592a18e5643 /core/apps
parentec14206f63dd93e9fb84c76cbc76fc1968637590 (diff)
downloadopie-1ab4ca95e4d2cf24d32b38c9031cb6076351e730.zip
opie-1ab4ca95e4d2cf24d32b38c9031cb6076351e730.tar.gz
opie-1ab4ca95e4d2cf24d32b38c9031cb6076351e730.tar.bz2
Merge from BRANCH_1_0
Diffstat (limited to 'core/apps') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/.cvsignore1
-rw-r--r--core/apps/embeddedkonsole/MyPty.cpp3
-rw-r--r--core/apps/helpbrowser/helpbrowser.cpp48
-rw-r--r--core/apps/helpbrowser/helpbrowser.h4
-rw-r--r--core/apps/helpbrowser/helpbrowser.pro4
-rw-r--r--core/apps/helpbrowser/magictextbrowser.cpp99
-rw-r--r--core/apps/helpbrowser/magictextbrowser.h42
-rw-r--r--core/apps/helpbrowser/main.cpp9
-rw-r--r--core/apps/textedit/textedit.cpp8
9 files changed, 189 insertions, 29 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 @@
1binconfig.in
2config.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
@@ -163,7 +163,8 @@ int MyPty::run(const char* cmd, QStrList &, const char*, int)
163 ttmode.c_cc[VINTR] = 3; 163 ttmode.c_cc[VINTR] = 3;
164 ttmode.c_cc[VERASE] = 8; 164 ttmode.c_cc[VERASE] = 8;
165 tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); 165 tcsetattr( STDIN_FILENO, TCSANOW, &ttmode );
166 setenv("TERM","vt100",1); 166 if(strlen(getenv("TERM"))<=0)
167 setenv("TERM","vt100",1);
167 setenv("COLORTERM","0",1); 168 setenv("COLORTERM","0",1);
168 169
169 if (getuid() == 0) { 170 if (getuid() == 0) {
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,7 +1,7 @@
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
@@ -18,10 +18,14 @@
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>
@@ -30,6 +34,7 @@
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>
@@ -48,8 +53,9 @@
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 ),
@@ -58,11 +64,14 @@ HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f )
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() ) );
@@ -80,12 +89,12 @@ void HelpBrowser::init( const QString& _home )
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
@@ -93,14 +102,13 @@ void HelpBrowser::init( const QString& _home )
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 );
@@ -112,11 +120,18 @@ void HelpBrowser::init( const QString& _home )
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&)) );
@@ -124,11 +139,18 @@ void HelpBrowser::init( const QString& _home )
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
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,7 +1,7 @@
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
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
@@ -1,8 +1,8 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on release 2 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
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8 DEPENDPATH+= $(OPIEDIR)/include 8 DEPENDPATH+= $(OPIEDIR)/include
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
17MagicTextBrowser::MagicTextBrowser(QWidget* parent) :
18 QTextBrowser(parent){
19}
20
21void 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
31bool 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}
51bool 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}
71QString 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
80QString 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
26class MagicTextBrowser : public QTextBrowser {
27public:
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 );
36private:
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,7 +1,7 @@
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
@@ -20,15 +20,14 @@
20 20
21#include "helpbrowser.h" 21#include "helpbrowser.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qtopia/qpeapplication.h>
24 24
25int main( int argc, char ** argv ) 25int main( int argc, char ** argv )
26{ 26{
27 QPEApplication a( argc, argv ); 27 QPEApplication a( argc, argv );
28 28
29 HelpBrowser mw; 29 HelpBrowser mw;
30 mw.setCaption( HelpBrowser::tr("HelpBrowser") ); 30 a.showMainWidget( &mw );
31 a.showMainDocumentWidget( &mw );
32 31
33 return a.exec(); 32 return a.exec();
34} 33}
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
@@ -569,7 +569,6 @@ void TextEdit::fileNew() {
569void TextEdit::fileOpen() { 569void TextEdit::fileOpen() {
570 Config cfg("TextEdit"); 570 Config cfg("TextEdit");
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;
574 map.insert(tr("All"), QStringList() ); 573 map.insert(tr("All"), QStringList() );
575 QStringList text; 574 QStringList text;
@@ -578,11 +577,10 @@ void TextEdit::fileOpen() {
578 text << "*"; 577 text << "*";
579 map.insert(tr("All"), text ); 578 map.insert(tr("All"), text );
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);
583 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) 582 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() )
584 { 583 {
585 cfg.writeEntry("LastOpenDirectory", QFileInfo(str).dirPath(false));
586 openFile( str ); 584 openFile( str );
587 } 585 }
588 else 586 else
@@ -976,7 +974,7 @@ void TextEdit::updateCaption( const QString &name ) {
976 } 974 }
977// if(s.left(1) == "/") 975// if(s.left(1) == "/")
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 }
981} 979}
982 980
@@ -1022,7 +1020,7 @@ void TextEdit::editDelete() {
1022 switch ( QMessageBox::warning(this,tr("Text Editor"), 1020 switch ( QMessageBox::warning(this,tr("Text Editor"),
1023 tr("Do you really want<BR>to <B>delete</B> " 1021 tr("Do you really want<BR>to <B>delete</B> "
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) ) {
1027 case 0: 1025 case 0:
1028 if(doc) { 1026 if(doc) {