author | kergoth <kergoth> | 2003-01-26 04:34:14 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-01-26 04:34:14 (UTC) |
commit | c3347d556ea8caf355c17a169070a4c052f266de (patch) (side-by-side diff) | |
tree | 4a13ff90baeed8e03a9149e4524a52a5d02624d3 | |
parent | 2b0f00c32cb051f8cf074747e26387620f541ca0 (diff) | |
download | opie-c3347d556ea8caf355c17a169070a4c052f266de.zip opie-c3347d556ea8caf355c17a169070a4c052f266de.tar.gz opie-c3347d556ea8caf355c17a169070a4c052f266de.tar.bz2 |
Strip newlines from the fortune.
-rw-r--r-- | noncore/todayplugins/fortune/fortunepluginwidget.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/noncore/todayplugins/fortune/fortunepluginwidget.cpp b/noncore/todayplugins/fortune/fortunepluginwidget.cpp index 583bf0b..b210fa9 100644 --- a/noncore/todayplugins/fortune/fortunepluginwidget.cpp +++ b/noncore/todayplugins/fortune/fortunepluginwidget.cpp @@ -1,83 +1,84 @@ /* * fortunepluginwidget.cpp * * copyright : (c) 2002 by Maximilian Reiß * email : harlekin@handhelds.org * */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include "fortunepluginwidget.h" #include <qvaluelist.h> #include <qtl.h> #include <qstring.h> #include <qscrollview.h> #include <qobject.h> #include <qlayout.h> #include <qpe/config.h> #include <qpe/qcopenvelope_qws.h> #include <opie/oprocess.h> #include <opie/oticker.h> FortunePluginWidget::FortunePluginWidget( QWidget *parent, const char* name ) : QWidget( parent, name ) { fortune = NULL; getFortune(); } FortunePluginWidget::~FortunePluginWidget() { if( fortuneProcess ){ delete fortuneProcess; } } /** * Get the fortunes */ void FortunePluginWidget::getFortune() { QVBoxLayout* layoutFortune = new QVBoxLayout( this ); if ( fortune ) { delete fortune; } fortune = new OTicker( this ); // fortune->setReadOnly( TRUE ); // fortune->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); fortune->setText( QString("Obtaining fortune...") ); layoutFortune->addWidget( fortune ); fortuneProcess = new OProcess(); *fortuneProcess << "fortune"; connect(fortuneProcess, SIGNAL(receivedStdout(OProcess*, char*, int ) ), this, SLOT(slotStdOut(OProcess*, char*, int) ) ); if(!fortuneProcess->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { qWarning("could not start :("); fortune->setText( QString("Failed to obtain fortune.") ); delete fortuneProcess; fortuneProcess = 0; } } void FortunePluginWidget::slotStdOut( OProcess* proc, char* buf, int len ) { - QCString cstring( buf, len ); - fortune->setText( cstring ); + QCString s( buf, len ); + s.replace( QRegExp("\n"), "" ); + fortune->setText( s ); } |