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 | ae2a03c2941bf92573f89b88ef73f8aa842bea0a (patch) | |
tree | 3566563f3fb6ac3cb3496669d8f233062d3091bc /eyesapplet | |
download | tdetoys-ae2a03c2941bf92573f89b88ef73f8aa842bea0a.tar.gz tdetoys-ae2a03c2941bf92573f89b88ef73f8aa842bea0a.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/kdetoys@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'eyesapplet')
-rw-r--r-- | eyesapplet/Makefile.am | 20 | ||||
-rw-r--r-- | eyesapplet/configure.in.in | 3 | ||||
-rw-r--r-- | eyesapplet/eyes.cpp | 202 | ||||
-rw-r--r-- | eyesapplet/eyes.h | 48 | ||||
-rw-r--r-- | eyesapplet/eyesapplet.desktop | 120 |
5 files changed, 393 insertions, 0 deletions
diff --git a/eyesapplet/Makefile.am b/eyesapplet/Makefile.am new file mode 100644 index 0000000..964c446 --- /dev/null +++ b/eyesapplet/Makefile.am @@ -0,0 +1,20 @@ +INCLUDES = $(all_includes) + +kde_module_LTLIBRARIES = eyes_panelapplet.la + +eyes_panelapplet_la_SOURCES = eyes.cpp + +METASOURCES = AUTO +noinst_HEADERS = eyes.h + +lnkdir = $(kde_datadir)/kicker/applets +lnk_DATA = eyesapplet.desktop + +EXTRA_DIST = $(lnk_DATA) + +eyes_panelapplet_la_LDFLAGS = $(KDE_PLUGIN) -module $(all_libraries) +eyes_panelapplet_la_LIBADD = $(LIB_KDEUI) + +messages: + $(XGETTEXT) *.cpp *.h -o $(podir)/keyesapplet.pot + diff --git a/eyesapplet/configure.in.in b/eyesapplet/configure.in.in new file mode 100644 index 0000000..f9df512 --- /dev/null +++ b/eyesapplet/configure.in.in @@ -0,0 +1,3 @@ +if test "x$kde_use_qt_mac" = "xyes"; then + DO_NOT_COMPILE="$DO_NOT_COMPILE eyesapplet" +fi diff --git a/eyesapplet/eyes.cpp b/eyesapplet/eyes.cpp new file mode 100644 index 0000000..99d8e55 --- /dev/null +++ b/eyesapplet/eyes.cpp @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2000 Matthias Elter <elter@kde.org> + * based on keyes (C) 1999 by Jerome Tollet <tollet@magic.fr> + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + */ + +#include <math.h> + +#include <qpainter.h> +#include <qcursor.h> +#include <qimage.h> + +#include <klocale.h> +#include <kglobal.h> +#include <kapplication.h> + +#include "eyes.h" +#include "eyes.moc" + +#define AAFACTOR 4 + +extern "C" +{ + KDE_EXPORT KPanelApplet* init(QWidget *parent, const QString& configFile) + { + KGlobal::locale()->insertCatalogue("keyesapplet"); + EyesApplet *applet = new EyesApplet(configFile, KPanelApplet::Normal, 0, parent, "keyesapplet"); + return applet; + } +} + +EyesApplet::EyesApplet(const QString& configFile, Type t, int actions, + QWidget *parent, const char *name) + : KPanelApplet( configFile, t, actions, parent, name ) +{ + setWFlags(WNoAutoErase); + setBackgroundOrigin(AncestorOrigin); + startTimer(50); + oldleft = QPoint(-1, -1); + oldright = QPoint(-1, -1); + oldMouse = QPoint(-1, -1); +} + +int EyesApplet::widthForHeight(int h) const +{ + return static_cast<int>(1.4 * h); // rectangular shape. +} +int EyesApplet::heightForWidth(int w) const +{ + return static_cast<int>(w / 1.4); // rectangular shape. +} + +void EyesApplet::resizeEvent( QResizeEvent*e ) +{ + QWidget::resizeEvent(e); +} + +void EyesApplet::timerEvent(QTimerEvent*) +{ + QPoint mouse = mapFromGlobal(QCursor::pos()); + if (mouse != oldMouse) + update(); +} + +void EyesApplet::paintEvent(QPaintEvent*) +{ + int spWidth = width() * AAFACTOR; + int spHeight = height() * AAFACTOR; + + if (spWidth != _cache.width() || spHeight != _cache.height()) + _cache.resize(spWidth, spHeight); + + QPainter paint(&_cache); + + if (paletteBackgroundPixmap()) + { + QPixmap bg(width(), height()); + QPainter p(&bg); + QPoint offset = backgroundOffset(); + p.drawTiledPixmap(0, 0, width(), height(), *paletteBackgroundPixmap(), offset.x(), offset.y()); + p.end(); + QImage bgImage = bg.convertToImage().scale(spWidth, spHeight); + paint.drawImage(0, 0, bgImage); + } + else + { + _cache.fill(paletteBackgroundColor()); + } + + // draw eyes, no pupils + paint.setPen(QPen(black, 2 * AAFACTOR)); + paint.setBrush(QBrush(white)); + + int w = spWidth; // - AAFACTOR * 2; + int h = spHeight; // - AAFACTOR * 2; + + // left eye + paint.drawEllipse(AAFACTOR, AAFACTOR, w/2 - AAFACTOR, h - AAFACTOR * 2); + + // right eye + paint.drawEllipse(w/2, AAFACTOR, w/2 - AAFACTOR, h - AAFACTOR * 2); + + // draw pupils + drawPupils(&paint); + paint.end(); + + QPainter paintFinal(this); + QImage spImage = _cache.convertToImage(); + QImage displayImage = spImage.smoothScale(size()); + paintFinal.drawImage(0, 0, displayImage); + paintFinal.end(); +} + +void EyesApplet::drawPupils(QPainter* p) +{ + QPoint pos, mouse, vect; + double cos_alpha,sin_alpha; + + int w = width() * AAFACTOR; + int h = height() * AAFACTOR; + + oldMouse = mapFromGlobal(QCursor::pos()); + mouse = oldMouse * AAFACTOR; + int tmp = QMIN(h, w)/6; + + // left pupil + vect.setX(mouse.x() - h / 4); + vect.setY(mouse.y() - h / 2); + + cos_alpha = vect.x() / sqrt(double(vect.x() * vect.x() + vect.y() * vect.y())); + sin_alpha = vect.y() / sqrt(double(vect.x() * vect.x() + vect.y() * vect.y())); + + if(vect.x() * vect.x() + vect.y() * vect.y() > (w/4 - tmp) * (w/4 - tmp)* + cos_alpha * cos_alpha+ (h/2-tmp) * (h/2-tmp) * sin_alpha * sin_alpha) { + pos.setX(int((w/4-tmp) * cos_alpha+w/4)); + pos.setY(int((h/2-tmp) * sin_alpha+h/2)); + } + else + pos = mouse; + + if(pos != oldleft) { + + int sizeEye=QMIN(h,w)/6; + +// // draw over old pos +// p->setPen(QPen(NoPen)); +// p->setBrush(QBrush(white)); +// p->drawEllipse(oldleft.x() - sizeEye/2, oldleft.y() - sizeEye/2, sizeEye, sizeEye); + + // draw left pupil + p->setPen(QPen(NoPen)); + p->setBrush(QBrush(black)); + p->drawEllipse(pos.x() - sizeEye/2, pos.y() - sizeEye/2, sizeEye, sizeEye); + + //oldleft = pos; + } + + // right pupil + vect.setX(mouse.x() - 3*w/4); + vect.setY(mouse.y() - h/2); + + cos_alpha = vect.x()/sqrt(double(vect.x()*vect.x()+vect.y()*vect.y())); + sin_alpha = vect.y()/sqrt(double(vect.x()*vect.x()+vect.y()*vect.y())); + + if(vect.x()*vect.x() + vect.y()*vect.y() > (w/4-tmp)*(w/4-tmp) + *cos_alpha*cos_alpha+(h/2-tmp)*(h/2-tmp)*sin_alpha*sin_alpha) + { + pos.setX(int((w/4-tmp)*cos_alpha+3*w/4)); + pos.setY(int((h/2-tmp)*sin_alpha+h/2)); + } + else + pos = mouse; + + if(pos != oldright) { + + int sizeEye=QMIN(h,w)/6; + +// // draw over old pos +// p->setPen(QPen(NoPen)); +// p->setBrush(QBrush(white)); +// p->drawEllipse(oldright.x() - sizeEye/2, oldright.y() - sizeEye/2, sizeEye, sizeEye); + + // draw left pupil + p->setPen(QPen(NoPen)); + p->setBrush(QBrush(black)); + p->drawEllipse(pos.x() - sizeEye/2, pos.y() - sizeEye/2, sizeEye, sizeEye); + + //oldright = pos; + } +} diff --git a/eyesapplet/eyes.h b/eyesapplet/eyes.h new file mode 100644 index 0000000..2bb8d72 --- /dev/null +++ b/eyesapplet/eyes.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2000 Matthias Elter <elter@kde.org> + * based on keyes (C) 1999 by Jerome Tollet <tollet@magic.fr> + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + */ + +#ifndef __eyes_h__ +#define __eyes_h__ + +#include <qpixmap.h> +#include <kpanelapplet.h> + +class EyesApplet : public KPanelApplet +{ + Q_OBJECT + +public: + EyesApplet(const QString& configFile, Type t = Normal, int actions = 0, + QWidget *parent = 0, const char *name = 0); + + int widthForHeight(int height) const; + int heightForWidth(int width) const; + +protected: + void timerEvent(QTimerEvent*); + void resizeEvent(QResizeEvent*); + void paintEvent(QPaintEvent*); + +private: + void drawPupils(QPainter* p); + + QPoint oldleft, oldright, oldMouse; + QPixmap _cache; +}; + +#endif // __eyes_h__ diff --git a/eyesapplet/eyesapplet.desktop b/eyesapplet/eyesapplet.desktop new file mode 100644 index 0000000..7ffeda1 --- /dev/null +++ b/eyesapplet/eyesapplet.desktop @@ -0,0 +1,120 @@ +[Desktop Entry] +Type=Plugin +Name=Eyes +Name[af]=Oë +Name[ar]=عيون +Name[az]=Gözlər +Name[be]=Вочы +Name[bg]=Очички +Name[bn]=চোখ +Name[br]=Daoulagad +Name[bs]=Oči +Name[ca]=Ulls +Name[cs]=Oči +Name[cy]=Llygaid +Name[da]=Øjne +Name[de]=Augen +Name[el]=Μάτια +Name[eo]=Okuloj +Name[es]=Ojos +Name[et]=Silmad +Name[eu]=Begiak +Name[fa]=چشمها +Name[fi]=Silmät +Name[fo]=Eygu +Name[fr]=Yeux +Name[gl]=Ollos +Name[he]=עיניים +Name[hi]=आँखें +Name[hr]=Oči +Name[hu]=Szemek +Name[is]=Augu +Name[it]=Occhi +Name[km]=ភ្នែក +Name[ko]=눈 +Name[lt]=Akys +Name[lv]=Acis +Name[mk]=Очи +Name[mt]=Għajnejn +Name[nb]=Øyne +Name[nds]=Ogen +Name[ne]=आँखा +Name[nl]=Ogen +Name[nn]=Auge +Name[pa]=ਅੱਖਾਂ +Name[pl]=Oczy +Name[pt]=Olhos +Name[pt_BR]=Olhos +Name[ro]=Ochi +Name[ru]=Глаза +Name[sk]=Oči +Name[sl]=Oči +Name[sr]=Очи +Name[sr@Latn]=Oči +Name[sv]=Ögon +Name[ta]= கண்கள் +Name[tg]=Чашмҳо +Name[th]=ดวงตา +Name[tr]=Gözler +Name[uk]=Очі +Name[uz]=Koʻzlar +Name[uz@cyrillic]=Кўзлар +Name[ven]=Mato +Name[wa]=Ouys +Name[xh]=Amehlo +Name[zh_CN]=眼睛 +Name[zh_TW]=眼睛 +Name[zu]=Amehlo + +Comment=Keeps an eye on your mouse pointer +Comment[ar]=عين تلاحق دوماً مؤشر الفأرة +Comment[be]=Сочаць за мышшу +Comment[bg]=Очички, които следят показалеца на мишката +Comment[bn]=মাউস পয়েন্টারের ওপর চোখ রাখে +Comment[ca]=Vigila el cursor del ratolí +Comment[cs]=Oči sledující ukazatel myši +Comment[cy]=Yn cadw llygad ar bwyntydd eich llygoden +Comment[da]=Holder øje med din musemarkør +Comment[de]=Beobachtet Ihren Mauszeiger +Comment[el]=Ακολουθεί το δρομέα του ποντικιού σας +Comment[eo]=Konservu okulon sur via musmontrilo +Comment[es]=Echa una ojeada al puntero del ratón +Comment[et]=Utiliit, mis hoiab su hiirekursoril silma peal +Comment[eu]=Begi bat zure saguaren erakuslean mantentzen du +Comment[fa]=به اشارهگر موشی چشم میدوزد +Comment[fi]=Silmäilee hiiriosoitintasi +Comment[fr]=Garde un œil sur le pointeur de votre souris +Comment[ga]=Coinnigh súil ar do phointeoir luiche +Comment[gl]=Non perde de vista o ponteiro do rato +Comment[he]=עוקב אחרי הסמן של העכבר שלך +Comment[hr]=Drži oko na pokazivaču miša +Comment[hu]=Az egérmozgás figyelése +Comment[is]=Fylgist með músarbendlinum +Comment[it]=Fissa un occhio sul puntatore del mouse +Comment[ja]=マウスポインタを追いかける目 +Comment[km]=ចាំយាមមើលព្រួញកណ្ដុររបស់អ្នក +Comment[lv]=Pieskata jūsu peli +Comment[mk]=Го следи движењето на вашиот покажувач +Comment[nb]=Holder et øye med musepekeren din +Comment[nds]=Beluert Dien Muuswieser +Comment[ne]=तपाईँको माउस पोइन्टरमा आँखा राख्दछ +Comment[nl]=Houdt een oogje op uw muisaanwijzer +Comment[nn]=Held auge med musepeikaren +Comment[pl]=Trzyma oko na Twój kursor myszy +Comment[pt]=Vigia o ponteiro do rato +Comment[pt_BR]=Vigia o ponteiro do seu mouse +Comment[ro]=Urmăreşte cursorul mouse-ului +Comment[ru]=Не сводит глаз с мыши +Comment[sk]=Drží pohľad na kurzor myši +Comment[sl]=Z očmi spremlja kazalec vaše miške +Comment[sr]=Прати погледом ваш показивач миша +Comment[sr@Latn]=Prati pogledom vaš pokazivač miša +Comment[sv]=Håller ett öga på muspekaren +Comment[tg]=Нишонаи мушро нигоҳ дошта истодааст +Comment[tr]=Gözlerin fare imlecinizi takip etmesini sağlar +Comment[uk]=Спостерігає за стрілкою мишки +Comment[zh_CN]=盯着您鼠标指针的眼睛 +Comment[zh_TW]=讓眼睛盯著滑鼠游標跑 + +Icon=xeyes +X-KDE-Library=eyes_panelapplet |