From 1ab4ca95e4d2cf24d32b38c9031cb6076351e730 Mon Sep 17 00:00:00 2001 From: kergoth Date: Sat, 09 Aug 2003 17:42:14 +0000 Subject: Merge from BRANCH_1_0 --- (limited to 'core/apps') 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 @@ -binconfig.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) ttmode.c_cc[VINTR] = 3; ttmode.c_cc[VERASE] = 8; tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); - setenv("TERM","vt100",1); + if(strlen(getenv("TERM"))<=0) + setenv("TERM","vt100",1); setenv("COLORTERM","0",1); 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 @@ -#/********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. +/********************************************************************** +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software @@ -18,10 +18,14 @@ ** **********************************************************************/ +#define QTOPIA_INTERNAL_LANGLIST + #include "helpbrowser.h" #include #include +#include +#include #include #include @@ -30,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -48,8 +53,9 @@ #include #include -#include +#include +#include "magictextbrowser.h" HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) : QMainWindow( parent, name, f ), @@ -58,11 +64,14 @@ HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) init( "index.html" ); } + + void HelpBrowser::init( const QString& _home ) { - setIcon( Resource::loadPixmap( "help_icon" ) ); + setIcon( Resource::loadPixmap( "HelpBrowser" ) ); + setBackgroundMode( PaletteButton ); - browser = new QTextBrowser( this ); + browser = new MagicTextBrowser( this ); browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); connect( browser, SIGNAL( textChanged() ), this, SLOT( textChanged() ) ); @@ -80,12 +89,12 @@ void HelpBrowser::init( const QString& _home ) toolbar = new QPEToolBar( this ); // addToolBar( toolbar, "Toolbar"); - //QPopupMenu* go = new QPopupMenu( this ); + QPopupMenu* go = new QPopupMenu( this ); backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 ); connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) ); connect( browser, SIGNAL( backwardAvailable( bool ) ), backAction, SLOT( setEnabled( bool ) ) ); - //backAction->addTo( go ); + backAction->addTo( go ); backAction->addTo( toolbar ); backAction->setEnabled( FALSE ); @@ -93,14 +102,13 @@ void HelpBrowser::init( const QString& _home ) connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) ); connect( browser, SIGNAL( forwardAvailable( bool ) ), forwardAction, SLOT( setEnabled( bool ) ) ); - //forwardAction->addTo( go ); + forwardAction->addTo( go ); forwardAction->addTo( toolbar ); forwardAction->setEnabled( FALSE ); - QAction *a = new QAction( tr( "Home" ), Resource::loadPixmap( -"home" ), QString::null, 0, this, 0 ); + QAction *a = new QAction( tr( "Home" ), Resource::loadIconSet( "home" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), browser, SLOT( home() ) ); - //a->addTo( go ); + a->addTo( go ); a->addTo( toolbar ); bookm = new QPopupMenu( this ); @@ -112,11 +120,18 @@ void HelpBrowser::init( const QString& _home ) readBookmarks(); - //menu->insertItem( tr("Go"), go ); + menu->insertItem( tr("Go"), go ); menu->insertItem( tr( "Bookmarks" ), bookm ); resize( 240, 300 ); browser->setFocus(); + browser->setFrameStyle( QFrame::NoFrame ); + +#if !defined(QT_NO_COP) + QCopChannel *addressChannel = new QCopChannel("QPE/HelpBrowser" , this ); + connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), + this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); +#endif connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); @@ -124,11 +139,18 @@ void HelpBrowser::init( const QString& _home ) void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) { + qDebug("reached appMessage"); if ( msg == "showFile(QString)" ) { QDataStream ds(data,IO_ReadOnly); QString fn; ds >> fn; setDocument( fn ); + + QPEApplication::setKeepRunning(); + + showMaximized(); + setActiveWindow(); + raise(); } } 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 @@ /********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** 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 @@ TEMPLATE = app CONFIG = qt warn_on release DESTDIR = $(OPIEDIR)/bin -HEADERS = helpbrowser.h -SOURCES = helpbrowser.cpp \ +HEADERS = helpbrowser.h magictextbrowser.h +SOURCES = helpbrowser.cpp magictextbrowser.cpp \ main.cpp INCLUDEPATH += $(OPIEDIR)/include 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 @@ +#include +#include +#include +#include + +/* need to get Global::helpPath() */ +#define QTOPIA_INTERNAL_LANGLIST + +#include +#include +#include + +#include "magictextbrowser.h" + + + +MagicTextBrowser::MagicTextBrowser(QWidget* parent) : + QTextBrowser(parent){ +} + +void MagicTextBrowser::setSource( const QString& source ) { + QTextBrowser::setSource(source); + if ( magicQpe(source,"applications") || magicQpe(source,"games") || magicQpe(source,"settings") || magicQpe(source, "1Pim") ) // No tr + return; + if ( magicOpe(source, "applets") || magicOpe(source, "input") ) + return; + // Just those are magic (for now). Could do CGI here, + // or in Qtopia's mime source factory. +} + +bool MagicTextBrowser::magicQpe(const QString& source, const QString& name) { + if ( name+".html" == source || "help/"+name+".html" == source) { + QString fn = mimeSourceFactory()->makeAbsolute( source, context() ); + const QMimeSource* m = mimeSourceFactory()->data( fn, context() ); + if ( m ) { + QString txt; + if ( QTextDrag::decode(m,txt) ) { + QRegExp re(".*"); + int start,len; + if ( (start=re.match(txt,0,&len))>=0 ) { + QString generated = generateQpe(name); + txt.replace(start,len,generated); + setText(txt); + return true; + } + } + } + } + return false; +} +bool MagicTextBrowser::magicOpe( const QString& source, const QString& name ) { + if ( name+".html" != source && "help/"+name+".html" != source) return false; + + QString fn = mimeSourceFactory()->makeAbsolute( source, context() ); + const QMimeSource* m = mimeSourceFactory()->data(fn, context() ); + if (!m) return false; + + QString txt; + if ( !QTextDrag::decode(m, txt ) ) return false; + + QRegExp re(".*"); + int start,len; + if ( (start=re.match(txt,0,&len))>=0 ) { + QString generated = generateOpe(name); + txt.replace(start,len,generated); + setText(txt); + return true; + } + return false; +} +QString MagicTextBrowser::generateOpe(const QString& name)const { + if ( name == QString::fromLatin1("applets") ) { + return QString::fromLatin1("

No Applets found

"); + }else if ( name == QString::fromLatin1("input") ) { + return QString::fromLatin1("

No input methods available

"); + }else + return QString::null; +} + +QString MagicTextBrowser::generateQpe(const QString& name) const { + QString dir = MimeType::appsFolderName()+"/"+name[0].upper()+name.mid(1); + AppLnkSet lnkset(dir); + AppLnk* lnk; + QString r; + for (QListIterator it(lnkset.children()); (lnk=it.current()); ++it) { + QString name = lnk->name(); + QString icon = lnk->icon(); + QString helpFile = lnk->exec()+".html"; + QStringList helpPath = Global::helpPath(); + bool helpExists = FALSE; + for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) + helpExists = QFile::exists( *it + "/" + helpFile ); + + if ( helpExists ) { + r += "

"+name+"

\n"; + } + } + return r; +} 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 @@ +/********************************************************************** +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. +** Copyright (C) 2003 zecke +** +** This file is part of the Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ +#ifndef HELP_BROWSER_MAGIC_TEXT_BROWSER_H +#define HELP_BROWSER_MAGIC_TEXT_BROWSER_H + +#include + +class MagicTextBrowser : public QTextBrowser { +public: + MagicTextBrowser(QWidget* parent); + + void setSource( const QString& source ); + + /** honor QPE Attributes */ + bool magicQpe(const QString& source, const QString& name); + /** honor OPIE Attributes */ + bool magicOpe(const QString& source, const QString& name ); +private: + + QString generateQpe(const QString& name) const; + QString generateOpe(const QString& name) const; +}; + +#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 @@ /********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software @@ -20,15 +20,14 @@ #include "helpbrowser.h" -#include +#include int main( int argc, char ** argv ) { QPEApplication a( argc, argv ); HelpBrowser mw; - mw.setCaption( HelpBrowser::tr("HelpBrowser") ); - a.showMainDocumentWidget( &mw ); + a.showMainWidget( &mw ); return a.exec(); } 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() { void TextEdit::fileOpen() { Config cfg("TextEdit"); cfg. setGroup ( "View" ); - QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir()); QMap map; map.insert(tr("All"), QStringList() ); QStringList text; @@ -578,11 +577,10 @@ void TextEdit::fileOpen() { text << "*"; map.insert(tr("All"), text ); QString str = OFileDialog::getOpenFileName( 2, - dir , + QString::null , QString::null, map); if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) { - cfg.writeEntry("LastOpenDirectory", QFileInfo(str).dirPath(false)); openFile( str ); } else @@ -976,7 +974,7 @@ void TextEdit::updateCaption( const QString &name ) { } // if(s.left(1) == "/") // s = s.right(s.length()-1); - setCaption( s + " - " + tr("Text Editor") ); + setCaption( tr("%1 - Text Editor").arg( s ) ); } } @@ -1022,7 +1020,7 @@ void TextEdit::editDelete() { switch ( QMessageBox::warning(this,tr("Text Editor"), tr("Do you really want
to delete " "the current file\nfrom the disk?
This is " - "irreversable!!"), + "irreversable!"), tr("Yes"),tr("No"),0,0,1) ) { case 0: if(doc) { -- cgit v0.9.0.2