From 84da08d7b7fcda12c85caeb5a10b4903770a6f69 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: 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/kdeaddons@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- noatun-plugins/ffrs/Makefile.am | 17 +++ noatun-plugins/ffrs/ffrs.cpp | 305 ++++++++++++++++++++++++++++++++++++++++ noatun-plugins/ffrs/ffrs.h | 80 +++++++++++ noatun-plugins/ffrs/ffrs.plugin | 108 ++++++++++++++ 4 files changed, 510 insertions(+) create mode 100644 noatun-plugins/ffrs/Makefile.am create mode 100644 noatun-plugins/ffrs/ffrs.cpp create mode 100644 noatun-plugins/ffrs/ffrs.h create mode 100644 noatun-plugins/ffrs/ffrs.plugin (limited to 'noatun-plugins/ffrs') diff --git a/noatun-plugins/ffrs/Makefile.am b/noatun-plugins/ffrs/Makefile.am new file mode 100644 index 0000000..96eae2d --- /dev/null +++ b/noatun-plugins/ffrs/Makefile.am @@ -0,0 +1,17 @@ +INCLUDES= -I$(kde_includes)/arts $(all_includes) +kde_module_LTLIBRARIES = noatun_ffrs.la + +noatun_ffrs_la_SOURCES = ffrs.cpp + +noatun_ffrs_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined +noatun_ffrs_la_LIBADD = $(LIB_KFILE) -lnoatun -lm + +noatun_ffrs_la_METASOURCES = AUTO + +noinst_HEADERS = ffrs.h + +noatun_DATA = ffrs.plugin +noatundir = $(kde_datadir)/noatun + +messages: rc.cpp + $(XGETTEXT) *.cpp *.h -o $(podir)/ffrs.pot diff --git a/noatun-plugins/ffrs/ffrs.cpp b/noatun-plugins/ffrs/ffrs.cpp new file mode 100644 index 0000000..5c4282a --- /dev/null +++ b/noatun-plugins/ffrs/ffrs.cpp @@ -0,0 +1,305 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "ffrs.h" + +extern "C" Plugin *create_plugin() +{ + KGlobal::locale()->insertCatalogue("ffrs"); + return new FFRS(); +} + + +View::View(int width, int height, int block, int unblock, QColor front, QColor back, int channel) + : QWidget(0,0, Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_StaysOnTop | Qt::WType_TopLevel), mChannel(channel) +{ + fg = front; + bg = back; + resize(width, height); + setPaletteBackgroundColor(back); + KWin::setState(handle(), NET::SkipTaskbar); + + KConfig *c = napp->config(); + c->setGroup("FFRS"); + + QSize size = napp->desktop()->size(); + QRect desktop(0,0, size.width(), size.height()); + + QPoint at; + if (channel==0) + { + at = QPoint(size.width()-width*4, size.height()-height-32); + QToolTip::add(this, i18n("Left")); + } + else // if (channel==1) + { + at = QPoint(size.width()-width*2, size.height()-height-32); + QToolTip::add(this, i18n("Right")); + } + + move(c->readPointEntry("at"+QString::number(mChannel), &at)); + + // make sure we're on the desktop + if ( + !desktop.contains(rect().topLeft()) + || !desktop.contains(rect().bottomRight()) + ) + { + move(at); + } + + + QBitmap mask(width, height); + QPainter p(&mask); + +// Qt::color0 = transparent +// Qt::color1 = opaque + p.fillRect(0, 0, width, height, Qt::color0); + for (int i=0; i < height; ) + { + p.fillRect(0, height-i-block, width, block, Qt::color1); + i += block + unblock; + } + setMask(mask); + units = block+unblock; + show(); + + moving=false; +} + +View::~View() +{ + KConfig *c = napp->config(); + c->setGroup("FFRS"); + c->writeEntry("at"+QString::number(mChannel), pos()); +} + +void View::mouseMoveEvent(QMouseEvent *) +{ + if (moving) + { + move ( QCursor::pos()-mMousePoint ); + } +} + +void View::mousePressEvent(QMouseEvent *) +{ + moving = true; + mMousePoint = mapFromGlobal(QCursor::pos()); +} + +void View::mouseReleaseEvent(QMouseEvent *) +{ + moving = false; +} + +void View::draw(float level) +{ + int w = width(); + int h = height(); + + // now convert level to pixels + + static const float LEVEL_MIN = 1.0/(1<<20); + if (level < LEVEL_MIN) level = LEVEL_MIN; + level = (2.0/log(2.0))*log(level+1.0); + + float fpix = level * (float)h; + fpix = fabs(fpix); + if (fpix - (int)fpix > .5) fpix += .5; + + int pix = (int)(fpix / units) * units; + + // and draw it (it updates too quickly for it to + // need a paintEvent) + QPainter p(this); + p.fillRect(0, 0, w, h-pix, bg); + p.fillRect(0, h-pix, w, h - (h-pix), fg); +} + + + +FFRS::FFRS() : QObject(), Plugin() +{ + dpyleft = dpyright = 0; + changed(); + prefs = new FFRSPrefs(this); + connect(prefs, SIGNAL(changed()), SLOT(changed())); + + setSamples(256); + + start(); +} + +FFRS::~FFRS() +{ + delete dpyleft; + delete dpyright; +} + +void FFRS::scopeEvent(float *left, float *right, int len) +{ + float avl=0; + float avr=0; + + for (int i=0; i < len; i++) + { + avl += fabs(left[i]); + avr += fabs(right[i]); + } + avl /= len; + avr /= len; + + dpyleft->draw(avl); + if (dpyright) + dpyright->draw(avr); +} + +void FFRS::changed() +{ + delete dpyleft; + delete dpyright; + + dpyleft = new View(prefs->width(), prefs->height(), prefs->fgblock(), prefs->bgblock(), prefs->fgcolor(), prefs->bgcolor(), 0); + dpyright = new View(prefs->width(), prefs->height(), prefs->fgblock(), prefs->bgblock(), prefs->fgcolor(), prefs->bgcolor(), 1); + + setInterval(prefs->rate()); +} + + +#include +#include +#include +#include +#include + +FFRSPrefs::FFRSPrefs( QObject *parent ) + : CModule(i18n("Foreign Region"), i18n("French Foreign Region"),"",parent) +{ + QVBoxLayout *layout = new QVBoxLayout(this); + + QHBox *box = new QHBox(this); + layout->addWidget(box); + new QLabel(i18n("Width:"), box); + mWidth = new KIntNumInput(width(), box); + mWidth->setMinValue(0); + + box = new QHBox(this); + layout->addWidget(box); + new QLabel(i18n("Height:"), box); + mHeight = new KIntNumInput(height(), box); + mHeight->setMinValue(0); + + box = new QHBox(this); + layout->addWidget(box); + new QLabel(i18n("Visible block size:"), box); + mFgblock = new KIntNumInput(fgblock(), box); + mFgblock->setMinValue(0); + + box = new QHBox(this); + layout->addWidget(box); + new QLabel(i18n("Transparent block size:"), box); + mBgblock = new KIntNumInput(bgblock(), box); + mBgblock->setMinValue(0); + + box = new QHBox(this); + layout->addWidget(box); + new QLabel(i18n("Update interval:"), box); + mRate = new KIntNumInput(rate(), box); + mRate->setMinValue(0); + + box = new QHBox(this); + layout->addWidget(box); + new QLabel(i18n("Foreground color:"), box); + mFgcolor = new KColorButton(fgcolor(), box); + + box = new QHBox(this); + layout->addWidget(box); + new QLabel(i18n("Background color:"), box); + mBgcolor = new KColorButton(bgcolor(), box); + + layout->addStretch(); +} + +void FFRSPrefs::save() +{ + KConfig *c = napp->config(); + + c->setGroup("FFRS"); + c->writeEntry("width", mWidth->value()); + c->writeEntry("height", mHeight->value()); + c->writeEntry("fgblock", mFgblock->value()); + c->writeEntry("bgblock", mBgblock->value()); + c->writeEntry("rate", mRate->value()); + + c->writeEntry("bgcolor", mBgcolor->color()); + c->writeEntry("fgcolor", mFgcolor->color()); + + emit changed(); +} + +int FFRSPrefs::width() +{ + KConfig *c = napp->config(); + c->setGroup("FFRS"); + return c->readNumEntry("width", 22); +} + +int FFRSPrefs::height() +{ + KConfig *c = napp->config(); + c->setGroup("FFRS"); + return c->readNumEntry("height", 162); +} + +int FFRSPrefs::fgblock() +{ + KConfig *c = napp->config(); + c->setGroup("FFRS"); + return c->readNumEntry("fgblock", 27-12); +} + +int FFRSPrefs::bgblock() +{ + KConfig *c = napp->config(); + c->setGroup("FFRS"); + return c->readNumEntry("bgblock", 12); +} + +int FFRSPrefs::rate() +{ + KConfig *c = napp->config(); + c->setGroup("FFRS"); + return c->readNumEntry("rate", 110); +} + + +QColor FFRSPrefs::bgcolor() +{ + KConfig *c = napp->config(); + c->setGroup("FFRS"); + QColor dumbass(0, 64, 0); + return c->readColorEntry("bgcolor", &dumbass); +} + +QColor FFRSPrefs::fgcolor() +{ + KConfig *c = napp->config(); + c->setGroup("FFRS"); + QColor dumbass(0, 255, 0); + return c->readColorEntry("fgcolor", &dumbass); +} + +#include "ffrs.moc" + diff --git a/noatun-plugins/ffrs/ffrs.h b/noatun-plugins/ffrs/ffrs.h new file mode 100644 index 0000000..b97c576 --- /dev/null +++ b/noatun-plugins/ffrs/ffrs.h @@ -0,0 +1,80 @@ +#ifndef FFRS_H +#define FFRS_H + +#include +#include + + +class View : public QWidget +{ +Q_OBJECT +public: + View(int width, int height, int block, int unblock, QColor front, QColor back, int channel); + ~View(); + + void draw(float intensity); + + virtual void mouseMoveEvent(QMouseEvent *e); + virtual void mousePressEvent(QMouseEvent *e); + virtual void mouseReleaseEvent(QMouseEvent *e); + +private: + int units; + QColor fg, bg; + bool moving; + QPoint mMousePoint; + int mChannel; +}; + +class FFRSPrefs; + +class FFRS : public QObject, public Plugin, public StereoScope +{ +Q_OBJECT + +public: + FFRS(); + ~FFRS(); + + virtual void scopeEvent(float *left, float *right, int len); + +public slots: + void changed(); + +private: + View *dpyleft, *dpyright; + FFRSPrefs *prefs; +}; + + +class KIntNumInput; +class KColorButton; + +class FFRSPrefs : public CModule +{ +Q_OBJECT + +public: + FFRSPrefs( QObject *parent ); + virtual void save(); + + int width(); + int height(); + int fgblock(); + int bgblock(); + int rate(); + + QColor bgcolor(); + QColor fgcolor(); + +signals: + void changed(); + +private: + KIntNumInput *mWidth, *mHeight, *mFgblock, *mBgblock, *mRate; + KColorButton *mBgcolor, *mFgcolor; +}; + + +#endif + diff --git a/noatun-plugins/ffrs/ffrs.plugin b/noatun-plugins/ffrs/ffrs.plugin new file mode 100644 index 0000000..2213169 --- /dev/null +++ b/noatun-plugins/ffrs/ffrs.plugin @@ -0,0 +1,108 @@ +Filename=noatun_ffrs.la +Author=Charles Samuels +Site=http://noatun.kde.org +Email=charles@kde.org +Type=visualization +License=BSD with Advertising Clause +Name=French Foreign Region +Name[af]=Franse Buiteland Streek +Name[az]=Fransız Xarici Bölgə +Name[bg]=Френски регион +Name[bs]=Francuski strani region +Name[ca]=Comarca estrangera francesa +Name[cs]=Cizí francouzský region +Name[cy]=Ardal Estron Ffrengig +Name[da]=Fransk udlandsområde +Name[de]=Ausländische Regionen (franz.) +Name[eo]=Franca eksterlanda regio +Name[es]=Región externa francesa +Name[et]=Prantsuse välisalad +Name[eu]=Frantziaren atzerriko lurraldea +Name[fa]=منطقۀ بیگانۀ فرانسوی +Name[fr]=Région étrangère française +Name[fy]=Bûtenlânske gebieten (Frânsktalich) +Name[ga]=Réigiún Coigríochach na Fraince +Name[gl]=Rexión Estranxeira da Franza +Name[hi]=फ्रांसीसी विदेशी क्षेत्र +Name[hr]=Francuska Legija stranaca +Name[is]=Franska útlendingasveitin +Name[it]=Legione Straniera Francese +Name[ka]=ფრანგული საზღვარგარეთ რეგიონი +Name[kk]=Францияның шетел өлкесі +Name[km]=តំបន់​​ខាង​ក្រៅ​​ ភាសាបារាំង +Name[lt]=Prancūzų užsieniečių regionas +Name[mk]=Француски странски регион +Name[ms]=Rantau Asing Perancis +Name[nb]=Franske fremmedlegion +Name[nds]=Franzöösch frömd Regioon +Name[ne]=फ्रेन्च विदेशी क्षेत्र +Name[nl]=Buitenlandse gebieden (Franstalig) +Name[nn]=Den franske framandregionen +Name[pa]=ਫਰੈਂਚ ਵਿਦੇਸ਼ੀ ਖੇਤਰ +Name[pl]=Natężenie dźwięku +Name[pt]=Região Estrangeira da França +Name[pt_BR]=Legião Estrangeira Francesa +Name[ro]=Regiunea străină franceză +Name[ru]=Зрительный образ Плавающие кривые +Name[sk]=Francúzske zahraničné regióny +Name[sl]=Francosko tuje področje +Name[sr]=Француски страни регион +Name[sr@Latn]=Francuski strani region +Name[sv]=Franska främlingslegionen +Name[ta]=பிரான்சு வெளியிடம் +Name[tg]=Намуди тамошобини мавҷҳои каҷ +Name[tr]=Fransız Yabancı Bölge +Name[uk]=Французький іноземний регіон +Name[vi]=Miền ngoài Pháp +Name[xh]=Ummandla welizwe langaphandle lwesiFrentshi +Name[zh_CN]=法国外籍兵团 +Name[zh_TW]=法國國外區域 +Comment=Floating scopes +Comment[bg]=Хвърчащи сфери +Comment[bs]=Plutajući scopes +Comment[ca]=Camps flotants +Comment[cs]=Plovoucí sloupce +Comment[da]=Svævende skoper +Comment[de]=Gleitendes Oszilloskop +Comment[el]=Επιπλέοντα καλειδοσκόπια +Comment[eo]=Flosantaj borderoj +Comment[es]=Alcance variable +Comment[et]=Hõljuv ostsilloskoop +Comment[eu]=Eremu flotatzaileak +Comment[fa]=دامنه‌های شناور +Comment[fi]=Kelluvat oskiloskoopit +Comment[fr]=Scopes flottants +Comment[fy]=Driuwende Ossillioskopen +Comment[gl]=Osciloscópios flutuantes +Comment[he]=תחומים צפים +Comment[hi]=फ्लोटिंग स्कोप्स +Comment[hr]=Plivajući oscilograf +Comment[hu]=Lebegő monoszkópok +Comment[is]=Fljótandi mælar +Comment[it]=Floating Scopes +Comment[ka]=მოტივტივე მრუდები +Comment[kk]=Қалқымалы көрінісі +Comment[km]=វិសាល​ភាព​​​អណ្ដែត +Comment[lt]=Plaukiojančios kreivės +Comment[mk]=Лебдечки осцилоскопи +Comment[ms]=Skop Apung +Comment[nb]=Flytende skop +Comment[nds]=Sweven Frequenzkieker +Comment[ne]=उत्प्लावन क्षेत्र +Comment[nl]=Drijvende Oscillioscopen +Comment[nn]=Flytande skop +Comment[pl]=Przesuwany wskaźnik natężenia dźwięku +Comment[pt]=Osciloscópios flutuantes +Comment[pt_BR]=Escopos Flutuantes +Comment[ru]=Плавающие кривые +Comment[sk]=Plávajúce rámce +Comment[sl]=Plavajoči analizatorji +Comment[sr]=Плутајући опсези +Comment[sr@Latn]=Plutajući opsezi +Comment[sv]=Flytande oscilloskop +Comment[ta]=மிதவு வரையெல்லைகள் +Comment[tg]=Мавҷҳои каҷ +Comment[tr]=Yüzen alanlar +Comment[uk]=Плаваючі криві +Comment[vi]=Xem nổi +Comment[zh_CN]=浮动观测器 -- cgit v1.2.1