diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | bcb704366cb5e333a626c18c308c7e0448a8e69f (patch) | |
tree | f0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /ksirc/KSTicker | |
download | tdenetwork-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')
-rw-r--r-- | ksirc/KSTicker/Makefile.am | 20 | ||||
-rw-r--r-- | ksirc/KSTicker/kspainter.cpp | 186 | ||||
-rw-r--r-- | ksirc/KSTicker/kspainter.h | 25 | ||||
-rw-r--r-- | ksirc/KSTicker/ksticker.cpp | 548 | ||||
-rw-r--r-- | ksirc/KSTicker/ksticker.h | 106 | ||||
-rw-r--r-- | ksirc/KSTicker/ksttest.cpp | 93 | ||||
-rw-r--r-- | ksirc/KSTicker/ksttest.h | 24 | ||||
-rw-r--r-- | ksirc/KSTicker/libksticker.c | 0 | ||||
-rw-r--r-- | ksirc/KSTicker/speeddialog.cpp | 61 | ||||
-rw-r--r-- | ksirc/KSTicker/speeddialog.dlg | 117 | ||||
-rw-r--r-- | ksirc/KSTicker/speeddialog.h | 42 | ||||
-rw-r--r-- | ksirc/KSTicker/speeddialogData.cpp | 107 | ||||
-rw-r--r-- | ksirc/KSTicker/speeddialogData.h | 51 |
13 files changed, 1380 insertions, 0 deletions
diff --git a/ksirc/KSTicker/Makefile.am b/ksirc/KSTicker/Makefile.am new file mode 100644 index 00000000..ab937def --- /dev/null +++ b/ksirc/KSTicker/Makefile.am @@ -0,0 +1,20 @@ +INCLUDES= $(all_includes) + +noinst_LTLIBRARIES = libksticker.la + +libksticker_la_SOURCES = ksticker.cpp speeddialog.cpp speeddialogData.cpp \ + kspainter.cpp + +noinst_HEADERS = ksticker.h speeddialog.h speeddialogData.h \ + kspainter.h + +METASOURCES = AUTO + + +check_PROGRAMS = ksttest + +ksttest_SOURCES = ksttest.cpp +ksttest_LDADD = libksticker.la ../ksopts.lo ../nickColourMaker.lo $(LIB_KDEUI) +ksttest_LDFLAGS = $(all_libraries) $(KDE_RPATH) + + diff --git a/ksirc/KSTicker/kspainter.cpp b/ksirc/KSTicker/kspainter.cpp new file mode 100644 index 00000000..fe5fbf65 --- /dev/null +++ b/ksirc/KSTicker/kspainter.cpp @@ -0,0 +1,186 @@ +#include "kspainter.h" +#include "../ksopts.h" +#include <stdlib.h> + +const int KSPainter::optcolours = 8; +const int KSPainter::startspecial = 16; +const int KSPainter::maxcolour = 16+optcolours; + +const QColor KSPainter::brown ( 165, 42, 42 ); +const QColor KSPainter::orange ( 255, 165, 0 ); +const QColor KSPainter::lightCyan( 224, 255, 255 ); +const QColor KSPainter::lightBlue( 173, 216, 230 ); +const QColor KSPainter::pink ( 255, 192, 203 ); + +QColor KSPainter::num2colour[KSPainter::maxcolour] = { Qt::white, + Qt::black, + Qt::darkBlue, + Qt::darkGreen, + Qt::red, + brown, + Qt::darkMagenta, + orange, + Qt::yellow, + Qt::green, + Qt::darkCyan, + Qt::cyan, + Qt::blue, + pink, + Qt::gray, + Qt::lightGray }; + +void KSPainter::initOptColours() +{ + num2colour[startspecial+0] = ksopts->textColor; + num2colour[startspecial+1] = ksopts->infoColor; + num2colour[startspecial+2] = ksopts->channelColor; + num2colour[startspecial+3] = ksopts->errorColor; + num2colour[startspecial+4] = ksopts->ownNickColor; + num2colour[startspecial+5] = ksopts->nickForeground; + num2colour[startspecial+6] = ksopts->nickBackground; + num2colour[startspecial+7] = ksopts->backgroundColor; +} + +int KSPainter::colour2num(const QColor &colour) +{ + for(int i = 0; i < maxcolour; i++) + if(num2colour[i] == colour) + return i; + + return -1; +} + +void KSPainter::colourDrawText(QPainter *p, int startx, int starty, + char *str, int length) +{ + int offset = 0; + int pcolour; + char buf[3]; + int loc = 0, i; + buf[2] = 0; + bool ReverseText = FALSE; + + // Default pen (colour) + + const QPen qpDefPen = p->pen(); + + for(loc = 0; (str[loc] != 0x00) && (loc != length) ; loc++){ + if(str[loc] == 0x03 || str[loc] == '~'){ + i = loc; + p->drawText(startx, starty, str + offset, i-offset); + startx += p->fontMetrics().width(str + offset, i-offset); + offset = i; + // lastp = i; + if((str[i+1] >= 0x30) && (str[i+1] <= 0x39)){ + i++; + buf[0] = str[i]; + i++; + if((str[i] >= 0x30) && (str[i] <= 0x39)){ + buf[1] = str[i]; + i++; + } + else{ + buf[1] = 0; + } + + pcolour = atoi(buf); + if(pcolour < maxcolour) + p->setPen(num2colour[pcolour]); + else + i = loc; + if(str[i] == ','){ + i++; + if((str[i] >= 0x30) && (str[i] <= 0x39)){ + buf[0] = str[i]; + i++; + if((str[i] >= 0x30) && (str[i] <= 0x39)){ + buf[1] = str[i]; + i++; + } + else{ + buf[1] = 0; + } + int bcolour = atoi(buf); + if(pcolour == bcolour){ + if(bcolour + 1 < maxcolour) + bcolour += 1; + else + bcolour -= 1; + } + if(bcolour < maxcolour ){ + p->setBackgroundColor(num2colour[bcolour]); + p->setBackgroundMode(Qt::OpaqueMode); + } + + } + } + } + else if(str[i] == 0x03){ + i++; + p->setPen(qpDefPen); + p->setBackgroundMode(Qt::TransparentMode); + } + else if((str[i] == '~') && ((str[i+1] >= 0x61) || (str[i+1] <= 0x7a))){ + QFont fnt = p->font(); + QColor temppen; + switch(str[i+1]){ + case 'c': + p->setPen(qpDefPen); + p->setBackgroundMode(Qt::TransparentMode); + break; + case 'C': + p->setPen(qpDefPen); + p->setBackgroundMode(Qt::TransparentMode); + fnt.setBold(FALSE); + fnt.setItalic(FALSE); + fnt.setUnderline(FALSE); + ReverseText = TRUE; // Force reverse removed, all fall through. + // FALL THROUGH. + case 'r': + if(ReverseText == TRUE) { + ReverseText = FALSE; + p->setBackgroundMode(Qt::TransparentMode); + } + else { + ReverseText = TRUE; + p->setBackgroundMode(Qt::OpaqueMode); + } + temppen = p->pen().color(); + p->setPen( p->backgroundColor() ); + p->setBackgroundColor( temppen ); + break; + case 'b': + if(fnt.bold() == TRUE) + fnt.setBold(FALSE); + else + fnt.setBold(TRUE); + break; + case 'i': + if(fnt.italic() == TRUE) + fnt.setItalic(FALSE); + else + fnt.setItalic(TRUE); + break; + case 'u': + if(fnt.underline() == TRUE) + fnt.setUnderline(FALSE); + else + fnt.setUnderline(TRUE); + break; + case '~': + loc++; // Skip ahead 2 characters + break; + default: + i-=1; + offset -= 1; + } + p->setFont(fnt); + i += 2; + } + offset += i - loc; + } + } + p->drawText(startx, starty, str + offset, loc-offset); + +} + diff --git a/ksirc/KSTicker/kspainter.h b/ksirc/KSTicker/kspainter.h new file mode 100644 index 00000000..21f9495d --- /dev/null +++ b/ksirc/KSTicker/kspainter.h @@ -0,0 +1,25 @@ +#ifndef KSPAINTER_H +#define KSPAINTER_H + +#include <qpainter.h> +#include <qobject.h> + +class KSPainter +{ +public: + static void initOptColours(); + static void colourDrawText(QPainter *p, int startx, int starty, char *str, int length = -1); + static const int startspecial; + static const int maxcolour; + static const int optcolours; + static QColor num2colour[16+8]; + static int colour2num(const QColor &colour); + + static const QColor brown; + static const QColor orange; + static const QColor lightCyan; + static const QColor lightBlue; + static const QColor pink; +}; + +#endif diff --git a/ksirc/KSTicker/ksticker.cpp b/ksirc/KSTicker/ksticker.cpp new file mode 100644 index 00000000..dc65118a --- /dev/null +++ b/ksirc/KSTicker/ksticker.cpp @@ -0,0 +1,548 @@ +#include <stdlib.h> +#include <qpainter.h> +#include <qframe.h> +#include <qpaintdevice.h> +#include <qcursor.h> +#include <qtooltip.h> +#include <qregexp.h> + +#include <kapplication.h> +#include <kfontdialog.h> +#include <klocale.h> + +#include "ksticker.h" +#include "speeddialog.h" + +#include "kspainter.h" +#include "../ksopts.h" +#include "../nickColourMaker.h" + +#include <kconfig.h> +#include <kwin.h> +#include <kdebug.h> + +KSTicker::KSTicker(QWidget * parent, const char * name, WFlags f) +: QFrame(parent, name, f) +{ + + pHeight = 1; + + pic = new QPixmap(); // create pic map here, resize it later though. + // pic->setBackgroundMode(TransparentMode); + + KConfig *conf = kapp->config(); + conf->setGroup("KSTicker"); + bScrollConstantly = conf->readNumEntry("ScollConst", FALSE); + + bAtEnd = FALSE; + setFont(conf->readFontEntry("Font", &ksopts->defaultFont)); + ourFont = font(); //QFont("Courier"); + setFont(ourFont); + setMinimumSize(100, 10); + setFixedHeight((fontMetrics().height()+fontMetrics().descent()*2)*pHeight); + descent = fontMetrics().descent(); + onechar = fontMetrics().width("X"); + + pic->resize(width() + onechar, height()); + pic->fill(backgroundColor()); + + tickStep = 2; + cOffset = 0; + + tickRate = 30; + + currentChar = 0; + chars = this->width() / onechar; + + popup = new QPopupMenu(); + popup->insertItem(i18n( "Font..." ), this, SLOT(fontSelector())); + popup->insertItem(i18n( "Scroll Rate..." ), this, SLOT(scrollRate())); + iScrollItem = popup->insertItem(i18n( "Scroll Constantly" ), this, SLOT(scrollConstantly())); + popup->setItemChecked(iScrollItem, bScrollConstantly); + popup->insertSeparator(); + popup->insertItem(i18n( "Return to Normal Mode" ), this, SIGNAL(doubleClick())); + + currentStr = ""; + + /* + * Tell KWM to use only minimum decurations + */ + // ### FIXME: port to kwin + //KWM::setDecoration(winId(), KWM::tinyDecoration); + // KWin::setType(winId(), NET::Override); + + /* + * Setup basic colours and background status info for ticker. + */ + + KSPainter::initOptColours(); + + bold = FALSE; + underline = FALSE; + italics = FALSE; + defbg = ksopts->backgroundColor; + deffg = ksopts->textColor; + setBackgroundColor(defbg); + bg = ksopts->backgroundColor; + fg = ksopts->textColor; + +} + +KSTicker::~KSTicker() +{ + killTimers(); + delete pic; +} + +void KSTicker::show() +{ + /* + * Tell KWM to use only minimum decurations + */ + // ### FIXME: port to kwin + //KWM::setDecoration(winId(), KWM::tinyDecoration); + QSize size = this->size(); + size.setHeight(QFontMetrics(font()).height()+10); + setFixedHeight(QFontMetrics(font()).height()+10); + resize(size); + + QFrame::show(); + if(currentStr.length() != 0) + startTicker(); + currentChar = 0; + repaint(TRUE); +} + +void KSTicker::hide() +{ + killTimers(); + QFrame::hide(); +} + +void KSTicker::iconify() +{ + QFrame::showMinimized(); + killTimers(); +} + +void KSTicker::setString(QString str) +{ + strlist.clear(); + strlist.append(str); + repaint(TRUE); + startTicker(); +} + +void KSTicker::mergeString(QString str, QColor c) +{ + int num = KSPainter::colour2num(c); + + if(num != -1){ + str.prepend(QString("~%1").arg(num)); + } + mergeString(str); + +} + +void KSTicker::mergeString(QString str) +{ + QRegExp rx("~n(\\S+)~n"); + if(rx.search(str) >= 0){ + int value = nickColourMaker::colourMaker()->findIdx(rx.cap(1)); + if(value >= 0){ + QString newText = QString("~%1\\1~c").arg(value); + str.replace(rx, newText); + } + } + + str.append("~C "); + strlist.append(str); + + if(strlist.count() > 5){ + int found = 0; + QStringList::Iterator it = strlist.begin(); + for(; it != strlist.end(); it++){ + if(((*it).find(ksopts->server["global"].nick, 0, FALSE) == -1) && + ((*it).find(ksopts->server["global"].altNick, 0, FALSE) == -1)){ + strlist.remove(it); + found = 1; + break; + } + else { + } + } + if(found == 0){ + strlist.pop_front(); + } + } + + if(bScrollConstantly == FALSE) + startTicker(); + + QStringList sep = QStringList::split(" ", stripCols(str)); + int len = 0; + QString brok; + QStringList::Iterator it = sep.begin(); + for(; it != sep.end(); ++it) { + brok += *it + " "; + len += (*it).length(); + if(len >= 50){ + brok += "\n"; + len = 0; + } + } + if(brok.endsWith("\n")) + brok.truncate(brok.length()-1); + + tipbuffer.append(brok); + while(tipbuffer.count() > 10) + tipbuffer.pop_front(); + QString tip = tipbuffer.join("\n"); + +// QToolTip::remove(this); + QToolTip::add(this, tip); + + +} + +void KSTicker::timerEvent(QTimerEvent *) +{ + if((uint)currentChar >= currentStr.length()){ + if(strlist.isEmpty()){ + if(bScrollConstantly == TRUE){ + currentStr = strbuffer.first(); + strbuffer.append(strbuffer.first()); + strbuffer.pop_front(); + currentChar = 0; + } + else{ + stopTicker(); + return; + } + } + else { + currentStr = strlist.first(); + strlist.pop_front(); + strbuffer.append(currentStr); + while(strbuffer.count() > 10) + strbuffer.pop_front(); + currentChar = 0; + } + } + + bAtEnd = FALSE; + static BGMode bgmode = TransparentMode; + + bitBlt(pic, -tickStep, 0, pic); + QPainter p(pic); + + cOffset += tickStep; + if(cOffset >= onechar){ + int step = 1; // Used to check if we did anything, and hence + // catch ~c~c type things. Set to 1 to start loop + while(((currentStr[currentChar] == '~') || (currentStr[currentChar] == 0x03)) + && (step > 0)){ + step = 1; // reset in case it's our second, or more loop. + QString text = currentStr.mid(currentChar); + QString buf = ""; + + if((text[step] >= '0') && + (text[step] <= '9')) { + buf += text[step]; + step++; + if((text[step] >= '0') && + (text[step] <= '9')) { + buf += text[step]; + step++; + } + int col = buf.toInt(); + if((col >= 0) || (col <= KSPainter::maxcolour)){ + fg = KSPainter::num2colour[col]; + } + bg = defbg; + buf = ""; + if(text[step] == ','){ + step++; + if((text[step] >= '0') && + (text[step] <= '9')) { + buf += text[step]; + step++; + if((text[step] >= '0') && + (text[step] <= '9')) { + buf += text[step]; + step++; + } + int col = buf.toInt(); + if((col >= 0) || (col <= KSPainter::maxcolour)){ + bg = KSPainter::num2colour[col]; + bgmode = OpaqueMode; + } + } + } + else{ + bgmode = TransparentMode; + } + } + else { + switch(text[step].latin1()){ + case 'c': + fg = deffg; + bg = defbg; + step++; + break; + case 'C': + fg = deffg; + bg = defbg; + bold = FALSE; + underline = FALSE; + italics = FALSE; + step++; + break; + case '#': + fg.setNamedColor(text.mid(step, 7)); + step += 7; + break; + case 'b': + bold == TRUE ? bold = FALSE : bold = TRUE; + step++; + break; + case 'u': + underline == TRUE ? underline = FALSE : underline = TRUE; + step++; + break; + case 'i': + italics == TRUE ? italics = FALSE : italics = TRUE; + step++; + break; + case 'n': + fg = ksopts->nickForeground; + bg = ksopts->nickBackground; + step++; + break; + case 'o': + fg = ksopts->msgContainNick; + step++; + break; + case '~': + currentChar++; // Move ahead 1, but... + step = 0; // Don't loop on next ~. + break; + default: + if(currentStr[currentChar] == 0x03){ + fg = deffg; + bg = defbg; + } + else + step = 0; + } + } + currentChar += step; + } + if((uint)currentChar >= currentStr.length()){ // Bail out if we're + // at the end of the string. + return; + } + + + QFont fnt = font(); + fnt.setBold(bold); + fnt.setUnderline(underline); + fnt.setItalic(italics); + p.setFont(fnt); + + p.setPen(fg); + p.setBackgroundColor(bg); + p.setBackgroundMode(OpaqueMode); + p.drawText(this->width() - cOffset + onechar, // remove -onechar. + this->height() / 4 + p.fontMetrics().height() / 2, + currentStr.mid(currentChar, 1), + 1); + currentChar++; // Move ahead to next character. + cOffset -= onechar; // Set offset back one. + } + p.end(); + bitBlt(this, 0, descent, pic); +} + +void KSTicker::paintEvent( QPaintEvent *) +{ + if(isVisible() == FALSE) + return; + bitBlt(this, 0, descent, pic); +} + +void KSTicker::resizeEvent( QResizeEvent *e) +{ + QFrame::resizeEvent(e); + onechar = fontMetrics().width("X"); + chars = this->width() / onechar; + killTimers(); + QPixmap *new_pic = new QPixmap(width() + onechar, height()); + new_pic->fill(backgroundColor()); + bitBlt(new_pic, + new_pic->width() - pic->width(), 0, + pic, 0, 0, + pic->width(), pic->height(), + CopyROP, TRUE); + delete pic; + pic = new_pic; + // if(ring.length() > (uint) chars) + startTicker(); +} + +void KSTicker::closeEvent( QCloseEvent *) +{ + emit closing(); + killTimers(); + // delete this; +} + +void KSTicker::startTicker() +{ + killTimers(); + startTimer(tickRate); +} + +void KSTicker::stopTicker() +{ + killTimers(); +} + +void KSTicker::mouseDoubleClickEvent( QMouseEvent * ) +{ + emit doubleClick(); +} + +void KSTicker::mousePressEvent( QMouseEvent *e) +{ + if(e->button() == RightButton){ + popup->popup(this->cursor().pos()); + } + else{ + QFrame::mousePressEvent(e); + } +} +void KSTicker::fontSelector() +{ + int result = KFontDialog::getFont( ourFont, true ); + if ( result == KFontDialog::Accepted ) { + updateFont(ourFont); + } +} + +void KSTicker::scrollRate() +{ + SpeedDialog *sd = new SpeedDialog(tickRate, tickStep); + sd->setLimit(5, 200, 1, onechar); + connect(sd, SIGNAL(stateChange(int, int)), + this, SLOT(setSpeed(int, int))); + sd->show(); +} + +void KSTicker::scrollConstantly() +{ + bScrollConstantly = !bScrollConstantly; + popup->setItemChecked(iScrollItem, bScrollConstantly); + if(bScrollConstantly == TRUE) + startTicker(); + KConfig *conf = kapp->config(); + conf->setGroup("KSTicker"); + conf->writeEntry("ScollConst", bScrollConstantly); + conf->sync(); +} + +void KSTicker::updateFont(const QFont &font){ + setFont(font); + setFixedHeight((fontMetrics().height()+fontMetrics().descent()*2)*pHeight); + resize(fontMetrics().width("X")*chars, + (fontMetrics().height()+fontMetrics().descent())*pHeight); + KConfig *conf = kapp->config(); + conf->setGroup("KSTicker"); + conf->writeEntry("Font", font); + conf->sync(); + +} + +void KSTicker::setSpeed(int _tickRate, int _tickStep){ + tickRate = _tickRate; + tickStep = _tickStep; + startTicker(); +} + +void KSTicker::speed(int *_tickRate, int *_tickStep){ + *_tickRate = tickRate; + *_tickStep = tickStep; +} + +void KSTicker::setBackgroundColor ( const QColor &c ) +{ + QFrame::setBackgroundColor(c); + pic->fill(c); + bitBlt(this, 0,0, pic); + defbg = backgroundColor(); + bg = backgroundColor(); +} + +void KSTicker::setPalette ( const QPalette & p ) +{ + QFrame::setPalette(p); + + pic->fill(backgroundColor()); + bitBlt(this, 0,0, pic); + defbg = backgroundColor(); + bg = backgroundColor(); + deffg = backgroundColor(); + fg = foregroundColor(); +} + +QString KSTicker::stripCols( QString str ) +{ + uint i = 0; + QString ret; + for(i = 0; i < str.length(); i++){ + if(((str[i] == '~') || (str[i] == 0x03))){ + if((str[i+1] >= '0') && + (str[i+1] <= '9')) { + i+=1; + if((str[i+1] >= '0') && + (str[i+1] <= '9')) { + i+=1; + } + if(str[i+1] == ','){ + i+=1; + if((str[i+1] >= '0') && + (str[i+1] <= '9')) { + i+=1; + if((str[i+1] >= '0') && + (str[i+1] <= '9')) { + i+=1; + } + } + } + } + else { + switch(str[i+1].latin1()){ + case 'c': + case 'C': + case 'b': + case 'u': + case 'i': + case 'n': + case 'o': + i+= 1; + break; + case '~': + i+= 0; + break; + default: + ret.append(str[i]); + } + } + } + else { + ret.append(str[i]); + } + } + return ret; +} +#include "ksticker.moc" diff --git a/ksirc/KSTicker/ksticker.h b/ksirc/KSTicker/ksticker.h new file mode 100644 index 00000000..d11d8a0f --- /dev/null +++ b/ksirc/KSTicker/ksticker.h @@ -0,0 +1,106 @@ +#ifndef KSTICKER_H +#define KSTICKER_H + +#include <qobject.h> +#include <qframe.h> +#include <qstring.h> +#include <qptrlist.h> +#include <qpopupmenu.h> + +class SInfo { +public: + int length; +}; + +class KSTicker : public QFrame +{ + Q_OBJECT + +public: + KSTicker(QWidget * parent=0, const char * name=0, WFlags f=0); + virtual ~KSTicker(); + + void setString(QString); + void mergeString(QString); + void mergeString(QString, QColor); + + virtual void show(); + virtual void hide(); + + void speed(int *, int *); + + virtual void setBackgroundColor ( const QColor & ); + virtual void setPalette ( const QPalette & p ); + +signals: + void doubleClick(); + void closing(); + +public slots: + virtual void setSpeed(int, int); + +protected slots: + virtual void fontSelector(); + virtual void scrollRate(); + virtual void updateFont(const QFont &font); + virtual void scrollConstantly(); + +protected: + virtual void timerEvent ( QTimerEvent * ); + virtual void paintEvent ( QPaintEvent * ); + virtual void resizeEvent( QResizeEvent * ); + virtual void closeEvent( QCloseEvent * ); + virtual void mouseDoubleClickEvent( QMouseEvent * ); + virtual void mousePressEvent ( QMouseEvent * ); + virtual void iconify(); + + +private: + + QString stripCols(QString); + + QStringList strlist; /* everything left to parse */ + QStringList strbuffer; /* fifo of the last 10 lines to scroll in scroll constantly mode */ + QStringList tipbuffer; /* 5 lines for the tooltip */ + QString currentStr; /* the string we are currently parsing */ + + QFont ourFont; + + int onechar; + int chars; + int descent; + + int tickStep; + int cOffset; + + int tickRate; + + int pHeight; + + int currentChar; + + void startTicker(); + void stopTicker(); + + bool bScrollConstantly; + int iScrollItem; + bool bAtEnd; + + QPixmap *pic; + + QPopupMenu *popup; + + /* + * Drawing settings and variables + */ + bool bold; + bool underline; + bool italics; + QColor defbg; + QColor deffg; + QColor bg; + QColor fg; +}; + +#endif // KSTICKER_H + 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" + diff --git a/ksirc/KSTicker/ksttest.h b/ksirc/KSTicker/ksttest.h new file mode 100644 index 00000000..9d166b66 --- /dev/null +++ b/ksirc/KSTicker/ksttest.h @@ -0,0 +1,24 @@ +#ifndef _KST_STD_IN_ +#define _KST_STD_IN_ + + +#include "ksticker.h" + +class StdInTicker : public KSTicker +{ + Q_OBJECT +public: + StdInTicker(); + ~StdInTicker(); + +protected: + void closeEvent ( QCloseEvent * ); + +public slots: + void readsocket(int socket); + void end(); + +}; + +#endif + diff --git a/ksirc/KSTicker/libksticker.c b/ksirc/KSTicker/libksticker.c new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ksirc/KSTicker/libksticker.c diff --git a/ksirc/KSTicker/speeddialog.cpp b/ksirc/KSTicker/speeddialog.cpp new file mode 100644 index 00000000..eb1ff462 --- /dev/null +++ b/ksirc/KSTicker/speeddialog.cpp @@ -0,0 +1,61 @@ +/********************************************************************** + + --- Qt Architect generated file --- + + File: speeddialog.cpp + Last generated: Sun Dec 21 08:52:31 1997 + + *********************************************************************/ + +#include <klocale.h> + +#include "speeddialog.h" + +SpeedDialog::SpeedDialog +( + int tick, + int step, + QWidget* parent, + const char* name +) + : speeddialogData( parent, name ) +{ + setCaption(i18n( "Speed Setup") ); + connect(sliderTick, SIGNAL(valueChanged(int)), + lcdTick, SLOT(display(int))); + connect(sliderStep, SIGNAL(valueChanged(int)), + lcdStep, SLOT(display(int))); + lcdTick->display(tick); + sliderTick->setValue(tick); + lcdStep->display(step); + sliderStep->setValue(step); +} + + +SpeedDialog::~SpeedDialog() +{ +} + + +void SpeedDialog::updateTick(int tick) +{ + emit stateChange(tick, sliderStep->value()); +} + +void SpeedDialog::updateStep(int step) +{ + emit stateChange(sliderTick->value(), step); +} + +void SpeedDialog::terminate() +{ + delete this; +} + +void SpeedDialog::setLimit(int tmin, int tmax, int smin, int smax) +{ + sliderTick->setRange(tmin, tmax); + sliderStep->setRange(smin, smax); +} + +#include "speeddialog.moc" diff --git a/ksirc/KSTicker/speeddialog.dlg b/ksirc/KSTicker/speeddialog.dlg new file mode 100644 index 00000000..00e26c67 --- /dev/null +++ b/ksirc/KSTicker/speeddialog.dlg @@ -0,0 +1,117 @@ +DlgEdit:v1.2:Dialog: +Dialog { + ClassHeader {speeddialog.h} + ClassSource {speeddialog.cpp} + ClassName {SpeedDialog} + DataHeader {speeddialogData.h} + DataSource {speeddialogData.cpp} + DataName {speeddialogData} + WindowBaseClass {QDialog} + IsModal {FALSE} + WindowFlags {0} +} +WidgetLayout { +InitialPos {-1 -1} +Size {270 120} +MinSize {0 0} +MaxSize {32767 32767} +Grid {10} + +Slider { + Orientation {Horizontal} + MinValue {10} + MaxValue {200} + Initial {30} + LineStep {10} + PageStep {50} + Tracking {TRUE} + Tickmarks {NoMarks} + TickInterval {0} + Rect {90 10 100 20} + Name {Slider_1} + Variable {sliderTick} + Signal {[Protected] valueChanged --> updateTick (int)} + LayoutStatus {NoLayout} + MinimumSize {10 10} + MaximumSize {32767 32767} +} +Slider { + Orientation {Horizontal} + MinValue {1} + MaxValue {10} + Initial {3} + LineStep {1} + PageStep {2} + Tracking {TRUE} + Tickmarks {NoMarks} + TickInterval {0} + Rect {90 45 100 20} + Name {Slider_2} + Variable {sliderStep} + Signal {[Protected] valueChanged --> updateStep (int)} + LayoutStatus {NoLayout} + MinimumSize {10 10} + MaximumSize {32767 32767} +} +LCDNumber { + Digits {3} + SmallDecimalPoint {FALSE} + Mode {Dec} + SegmentStyle {Outline} + Style {33} + Rect {200 5 60 30} + Name {LCDNumber_1} + Variable {lcdTick} + LayoutStatus {NoLayout} + MinimumSize {10 10} + MaximumSize {32767 32767} +} +LCDNumber { + Digits {3} + SmallDecimalPoint {FALSE} + Mode {Dec} + SegmentStyle {Outline} + Style {33} + Rect {200 40 60 30} + Name {LCDNumber_2} + Variable {lcdStep} + LayoutStatus {NoLayout} + MinimumSize {10 10} + MaximumSize {32767 32767} +} +Label { + Text {Tick Interval} + AutoResize {FALSE} + Margin {-1} + Rect {10 5 80 30} + Name {Label_1} + LayoutStatus {NoLayout} + MinimumSize {10 10} + MaximumSize {32767 32767} +} +Label { + Text {Step Size} + AutoResize {FALSE} + Margin {-1} + Rect {10 40 80 30} + Name {Label_2} + LayoutStatus {NoLayout} + MinimumSize {10 10} + MaximumSize {32767 32767} +} +PushButton { + ToggleButton {FALSE} + Default {FALSE} + AutoDefault {FALSE} + Text {&Close} + AutoRepeat {FALSE} + AutoResize {FALSE} + Rect {140 80 120 30} + Name {PushButton_2} + Signal {[Protected] pressed --> terminate ()} + LayoutStatus {NoLayout} + MinimumSize {10 10} + MaximumSize {32767 32767} +} +Layout {None} +} diff --git a/ksirc/KSTicker/speeddialog.h b/ksirc/KSTicker/speeddialog.h new file mode 100644 index 00000000..4efdb2a8 --- /dev/null +++ b/ksirc/KSTicker/speeddialog.h @@ -0,0 +1,42 @@ +/********************************************************************** + + --- Qt Architect generated file --- + + File: speeddialog.h + Last generated: Sun Dec 21 08:52:31 1997 + + *********************************************************************/ + +#ifndef SpeedDialog_included +#define SpeedDialog_included + +#include "speeddialogData.h" + +class SpeedDialog : public speeddialogData +{ + Q_OBJECT + +public: + + SpeedDialog + ( + int tick, + int step, + QWidget* parent = NULL, + const char* name = NULL + ); + + virtual ~SpeedDialog(); + void setLimit(int, int, int, int); + +signals: + void stateChange(int, int); + +protected slots: + virtual void updateTick(int); + virtual void updateStep(int); + virtual void terminate(); + + +}; +#endif // SpeedDialog_included diff --git a/ksirc/KSTicker/speeddialogData.cpp b/ksirc/KSTicker/speeddialogData.cpp new file mode 100644 index 00000000..0dbb1c0b --- /dev/null +++ b/ksirc/KSTicker/speeddialogData.cpp @@ -0,0 +1,107 @@ +/********************************************************************** + + --- Qt Architect generated file --- + + File: speeddialogData.cpp + Last generated: Sun Dec 21 09:13:46 1997 + + DO NOT EDIT!!! This file will be automatically + regenerated by qtarch. All changes will be lost. + + *********************************************************************/ + +#include "speeddialogData.h" + +#include <qlabel.h> +#include <klocale.h> +#include <kpushbutton.h> +#include <kstdguiitem.h> +#include <qlayout.h> +#include <kdialog.h> + +speeddialogData::speeddialogData ( QWidget* parent, const char* name ) + :QDialog( parent, name, 0 ) +{ + QGridLayout *grid = new QGridLayout( this, 3, 2 , KDialog::marginHint(), KDialog::spacingHint()); + sliderTick = new QSlider( this, "Slider_1" ); + grid->addWidget( sliderTick, 0, 1 ); + connect( sliderTick, SIGNAL(valueChanged(int)), SLOT(updateTick(int)) ); + sliderTick->setOrientation( QSlider::Horizontal ); + sliderTick->setRange( 10, 200 ); + sliderTick->setSteps( 10, 50 ); + sliderTick->setValue( 30 ); + sliderTick->setTracking( TRUE ); + sliderTick->setTickmarks( QSlider::NoMarks ); + sliderTick->setTickInterval( 0 ); + + sliderStep = new QSlider( this, "Slider_2" ); + grid->addWidget( sliderStep, 1, 1 ); + + connect( sliderStep, SIGNAL(valueChanged(int)), SLOT(updateStep(int)) ); + sliderStep->setOrientation( QSlider::Horizontal ); + sliderStep->setRange( 1, 10 ); + sliderStep->setSteps( 1, 2 ); + sliderStep->setValue( 3 ); + sliderStep->setTracking( TRUE ); + sliderStep->setTickmarks( QSlider::NoMarks ); + sliderStep->setTickInterval( 0 ); + + lcdTick = new QLCDNumber( this, "LCDNumber_1" ); + lcdTick->setFrameStyle( 33 ); + lcdTick->setSmallDecimalPoint( FALSE ); + lcdTick->setNumDigits( 3 ); + lcdTick->setMode( QLCDNumber::DEC ); + lcdTick->setSegmentStyle( QLCDNumber::Outline ); + grid->addWidget( lcdTick, 0, 2 ); + + lcdStep = new QLCDNumber( this, "LCDNumber_2" ); + lcdStep->setFrameStyle( 33 ); + lcdStep->setSmallDecimalPoint( FALSE ); + lcdStep->setNumDigits( 3 ); + lcdStep->setMode( QLCDNumber::DEC ); + lcdStep->setSegmentStyle( QLCDNumber::Outline ); + grid->addWidget( lcdStep, 1, 2 ); + + + QLabel* dlgedit_Label_1; + dlgedit_Label_1 = new QLabel( this, "Label_1" ); + dlgedit_Label_1->setText( i18n("Tick interval:") ); + dlgedit_Label_1->setAlignment( 289 ); + dlgedit_Label_1->setMargin( -1 ); + grid->addWidget( dlgedit_Label_1, 0, 0 ); + + + QLabel* dlgedit_Label_2; + dlgedit_Label_2 = new QLabel( this, "Label_2" ); + dlgedit_Label_2->setText( i18n("Step size:") ); + dlgedit_Label_2->setAlignment( 289 ); + dlgedit_Label_2->setMargin( -1 ); + grid->addWidget( dlgedit_Label_2, 1, 0 ); + + + QPushButton* dlgedit_PushButton_2; + dlgedit_PushButton_2 = new KPushButton( KStdGuiItem::close(), this, "PushButton_2" ); + connect( dlgedit_PushButton_2, SIGNAL(pressed()), SLOT(terminate()) ); +// dlgedit_PushButton_2->setAutoRepeat( FALSE ); +// dlgedit_PushButton_2->setAutoResize( FALSE ); + grid->addWidget( dlgedit_PushButton_2, 2, 2 ); + + //resize( 270,120 ); + setMinimumSize( 0, 0 ); + setMaximumSize( 32767, 32767 ); +} + + +speeddialogData::~speeddialogData() +{ +} +void speeddialogData::updateTick(int) +{ +} +void speeddialogData::updateStep(int) +{ +} +void speeddialogData::terminate() +{ +} +#include "speeddialogData.moc" diff --git a/ksirc/KSTicker/speeddialogData.h b/ksirc/KSTicker/speeddialogData.h new file mode 100644 index 00000000..6e9f06f9 --- /dev/null +++ b/ksirc/KSTicker/speeddialogData.h @@ -0,0 +1,51 @@ +/********************************************************************** + + --- Qt Architect generated file --- + + File: speeddialogData.h + Last generated: Sun Dec 21 09:13:46 1997 + + DO NOT EDIT!!! This file will be automatically + regenerated by qtarch. All changes will be lost. + + *********************************************************************/ + +#ifndef speeddialogData_included +#define speeddialogData_included + +#include <qdialog.h> +#include <qslider.h> +#include <qlcdnumber.h> + +class speeddialogData : public QDialog +{ + Q_OBJECT + +public: + + speeddialogData + ( + QWidget* parent = NULL, + const char* name = NULL + ); + + virtual ~speeddialogData(); + +public slots: + + +protected slots: + + virtual void terminate(); + virtual void updateTick(int); + virtual void updateStep(int); + +protected: + QSlider* sliderTick; + QSlider* sliderStep; + QLCDNumber* lcdTick; + QLCDNumber* lcdStep; + +}; + +#endif // speeddialogData_included |