summaryrefslogtreecommitdiffstats
path: root/ksirc/KSTicker/ksttest.cpp
blob: 6c4bd80ebcd54da7390cb31d3ecd68688c326420 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <kapplication.h>
#include <tdeconfig.h>
#include <tqapplication.h>
#include <tqsocketnotifier.h>
#include <tqregexp.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <klocale.h>

#include <unistd.h>

#include "ksticker.h"
#include "ksttest.h"
#include "../ksopts.h"

TDEConfig *kConfig;

StdInTicker::StdInTicker()
  : KSTicker()
{
  kConfig->setGroup("defaults");
  TQFont 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){
      TQCString str(buf, bytes);
      str.replace(TQRegExp("\n"), " // ");
      mergeString(str);
  }
}

void StdInTicker::end()
{
    delete this;
}

void StdInTicker::closeEvent ( TQCloseEvent *e )
{
  KSTicker::closeEvent(e);
  delete this;
}


int main(int argc, char **argv){
    TDEAboutData aboutData( "ksirc", I18N_NOOP("KSirc"),
                          "2.0.0", "", TDEAboutData::License_Artistic,
                          I18N_NOOP("(c) 1997-2002, Andrew Stanley-Jones"));
    aboutData.addAuthor("Andrew Stanley-Jones",I18N_NOOP("Original Author"), "asj-ksirc@cban.com");
    TDECmdLineArgs::init( argc, argv, &aboutData );

    TDEApplication a(argc, argv);

    kConfig = a.config();

    // Options
    KSOptions opts;
    opts.load();

    StdInTicker *kst = new StdInTicker();
    TQSocketNotifier *sn = new TQSocketNotifier(0, TQSocketNotifier::Read);
    TQObject::connect(sn, TQT_SIGNAL(activated(int)),
                     kst, TQT_SLOT(readsocket(int)));
    TQObject::connect(kst, TQT_SIGNAL(doubleClick()), kst, TQT_SLOT(end()));
    TQObject::connect(kst, TQT_SIGNAL(closing()), kst, TQT_SLOT(end()));
    a.setMainWidget(kst);
    kst->show();
    return a.exec();
}

#include "ksttest.moc"