author | kergoth <kergoth> | 2002-11-04 00:32:59 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-11-04 00:32:59 (UTC) |
commit | dc44b0babe9ffa7b29cc6269596703bab8edf6ab (patch) (side-by-side diff) | |
tree | d1a3e10c58737597832b3d34e4fe3173f307c324 /noncore/todayplugins/fortune/fortunepluginwidget.cpp | |
parent | 829eeff0374389891aa88b12fcafffb55f480797 (diff) | |
download | opie-dc44b0babe9ffa7b29cc6269596703bab8edf6ab.zip opie-dc44b0babe9ffa7b29cc6269596703bab8edf6ab.tar.gz opie-dc44b0babe9ffa7b29cc6269596703bab8edf6ab.tar.bz2 |
fortune plugin, though it doesnt like me
Diffstat (limited to 'noncore/todayplugins/fortune/fortunepluginwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/todayplugins/fortune/fortunepluginwidget.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/noncore/todayplugins/fortune/fortunepluginwidget.cpp b/noncore/todayplugins/fortune/fortunepluginwidget.cpp new file mode 100644 index 0000000..583bf0b --- a/dev/null +++ b/noncore/todayplugins/fortune/fortunepluginwidget.cpp @@ -0,0 +1,83 @@ +/* + * 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 ); +} |