summaryrefslogtreecommitdiffstats
path: root/ksirc/KSTicker/ksttest.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitbcb704366cb5e333a626c18c308c7e0448a8e69f (patch)
treef0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /ksirc/KSTicker/ksttest.cpp
downloadtdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.tar.gz
tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ksirc/KSTicker/ksttest.cpp')
-rw-r--r--ksirc/KSTicker/ksttest.cpp93
1 files changed, 93 insertions, 0 deletions
diff --git a/ksirc/KSTicker/ksttest.cpp b/ksirc/KSTicker/ksttest.cpp
new file mode 100644
index 00000000..81373bd8
--- /dev/null
+++ b/ksirc/KSTicker/ksttest.cpp
@@ -0,0 +1,93 @@
+#include <kapplication.h>
+#include <kconfig.h>
+#include <qapplication.h>
+#include <qsocketnotifier.h>
+#include <qregexp.h>
+#include <kaboutdata.h>
+#include <kcmdlineargs.h>
+#include <klocale.h>
+
+#include <unistd.h>
+
+#include "ksticker.h"
+#include "ksttest.h"
+#include "../ksopts.h"
+
+KConfig *kConfig;
+
+StdInTicker::StdInTicker()
+ : KSTicker()
+{
+ kConfig->setGroup("defaults");
+ QFont font;
+ font = kConfig->readFontEntry("font");
+ font.setFixedPitch(TRUE);
+ setFont(font);
+ setSpeed(kConfig->readNumEntry("tick", 30),
+ kConfig->readNumEntry("step", 3));
+}
+
+StdInTicker::~StdInTicker()
+{
+ int tick, step;
+ speed(&tick, &step);
+ kConfig->setGroup("defaults");
+ kConfig->writeEntry("font", KSTicker::font());
+ kConfig->writeEntry("tick", tick);
+ kConfig->writeEntry("step", step);
+ kConfig->writeEntry("text", colorGroup().text() );
+ kConfig->writeEntry("background", colorGroup().background() );
+ kConfig->sync();
+}
+
+void StdInTicker::readsocket(int socket)
+{
+ char buf[1024];
+ int bytes = read(socket, buf, 1024);
+ if(bytes){
+ QCString str(buf, bytes);
+ str.replace(QRegExp("\n"), " // ");
+ mergeString(str);
+ }
+}
+
+void StdInTicker::end()
+{
+ delete this;
+}
+
+void StdInTicker::closeEvent ( QCloseEvent *e )
+{
+ KSTicker::closeEvent(e);
+ delete this;
+}
+
+
+int main(int argc, char **argv){
+ KAboutData aboutData( "ksirc", I18N_NOOP("KSirc"),
+ "2.0.0", "", KAboutData::License_Artistic,
+ I18N_NOOP("(c) 1997-2002, Andrew Stanley-Jones"));
+ aboutData.addAuthor("Andrew Stanley-Jones",I18N_NOOP("Original Author"), "asj-ksirc@cban.com");
+ KCmdLineArgs::init( argc, argv, &aboutData );
+
+ KApplication a(argc, argv);
+
+ kConfig = a.config();
+
+ // Options
+ KSOptions opts;
+ opts.load();
+
+ StdInTicker *kst = new StdInTicker();
+ QSocketNotifier *sn = new QSocketNotifier(0, QSocketNotifier::Read);
+ QObject::connect(sn, SIGNAL(activated(int)),
+ kst, SLOT(readsocket(int)));
+ QObject::connect(kst, SIGNAL(doubleClick()), kst, SLOT(end()));
+ QObject::connect(kst, SIGNAL(closing()), kst, SLOT(end()));
+ a.setMainWidget(kst);
+ kst->show();
+ return a.exec();
+}
+
+#include "ksttest.moc"
+