diff options
Diffstat (limited to 'kmilo/kmilod')
-rw-r--r-- | kmilo/kmilod/Makefile.am | 43 | ||||
-rw-r--r-- | kmilo/kmilod/defaultskin.cpp | 107 | ||||
-rw-r--r-- | kmilo/kmilod/defaultskin.h | 56 | ||||
-rw-r--r-- | kmilo/kmilod/defaultwidget.ui | 195 | ||||
-rw-r--r-- | kmilo/kmilod/displayskin.cpp | 34 | ||||
-rw-r--r-- | kmilo/kmilod/displayskin.h | 47 | ||||
-rw-r--r-- | kmilo/kmilod/kmilod.cpp | 227 | ||||
-rw-r--r-- | kmilo/kmilod/kmilod.desktop | 59 | ||||
-rw-r--r-- | kmilo/kmilod/kmilod.h | 72 | ||||
-rw-r--r-- | kmilo/kmilod/kmilointerface.cpp | 26 | ||||
-rw-r--r-- | kmilo/kmilod/kmilointerface.h | 57 | ||||
-rw-r--r-- | kmilo/kmilod/kmilopluginsvc.desktop | 9 | ||||
-rw-r--r-- | kmilo/kmilod/monitor.cpp | 44 | ||||
-rw-r--r-- | kmilo/kmilod/monitor.h | 98 |
14 files changed, 1074 insertions, 0 deletions
diff --git a/kmilo/kmilod/Makefile.am b/kmilo/kmilod/Makefile.am new file mode 100644 index 0000000..72662db --- /dev/null +++ b/kmilo/kmilod/Makefile.am @@ -0,0 +1,43 @@ +# This file is part of the KDE project +# Copyright (C) 2003 George Staikos <staikos@kde.org> + +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. + +# This library 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 +# Library General Public License for more details. + +# You should have received a copy of the GNU Library General Public License +# along with this library; see the file COPYING.LIB. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. + +INCLUDES=$(all_includes) + +kde_module_LTLIBRARIES = kded_kmilod.la +kded_kmilod_la_LDFLAGS = -module -avoid-version $(all_libraries) +kded_kmilod_la_LIBADD = $(LIB_KIO) libkmilo.la +kded_kmilod_la_SOURCES = kmilod.cpp kmilod.skel defaultskin.cpp \ + defaultwidget.ui kmilointerface.cpp + +lib_LTLIBRARIES = libkmilo.la +libkmilo_la_SOURCES = monitor.cpp displayskin.cpp +libkmilo_la_LDFLAGS = -version-info 1:0:0 -no-undefined $(all_libraries) +libkmilo_la_LIBADD = $(LIB_QT) + +METASOURCES = AUTO + +noinst_HEADERS = kmilod.h monitor.h displayskin.h defaultskin.h + +services_DATA = kmilod.desktop +servicesdir = $(kde_servicesdir)/kded + +servicetypes_DATA = kmilopluginsvc.desktop +servicetypesdir = $(kde_servicetypesdir)/kmilo + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kmilod.pot diff --git a/kmilo/kmilod/defaultskin.cpp b/kmilo/kmilod/defaultskin.cpp new file mode 100644 index 0000000..f0324de --- /dev/null +++ b/kmilo/kmilod/defaultskin.cpp @@ -0,0 +1,107 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 2; -*- +/* + This file is part of the KDE project + + Copyright (c) 2003 George Staikos <staikos@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + +*/ + +#include "defaultwidget.h" + +#include <qprogressbar.h> +#include <qwidget.h> +#include <qwidgetstack.h> +#include <qlabel.h> +#include <qapplication.h> + +#include <kwin.h> +#include <netwm.h> +#include <kglobalsettings.h> +#include <kdeversion.h> + +#include "defaultskin.h" + + +DefaultSkin::DefaultSkin() { + connect(&_timer, SIGNAL(timeout()), this, SLOT(timeout())); + + _widget = new DefaultWidget(0, "Screen Indicator", Qt::WX11BypassWM); + _widget->setFocusPolicy(QWidget::NoFocus); + + KWin::setOnAllDesktops(_widget->winId(), true); + KWin::setState( _widget->winId(), NET::StaysOnTop | NET::Sticky + | NET::SkipTaskbar | NET::SkipPager ); + KWin::setType(_widget->winId(), NET::Override); + + _widget->hide(); +} + + +DefaultSkin::~DefaultSkin() { + delete _widget; + _widget = 0; +} + + +void DefaultSkin::clear() { + _timer.stop(); + _widget->hide(); +} + + +void DefaultSkin::show() { +#if KDE_IS_VERSION(3,1,90) + QRect r = KGlobalSettings::splashScreenDesktopGeometry(); +#else + QRect r = QApplication::desktop()->geometry(); +#endif + // _label->resize(_label->minimumSizeHint()); + // _widget->resize(_label->minimumSizeHint()); + _widget->move(r.center() - + QPoint(_widget->width()/2, _widget->height()/2)); + _widget->show(); + _timer.start(750, true); +} + + +void DefaultSkin::displayText(const QString& text, const QPixmap& customPixmap) { + Q_UNUSED(customPixmap) + _timer.stop(); + _widget->_widgetStack->raiseWidget(0); + _widget->_textOnly->setText(text); + show(); +} + + +void DefaultSkin::displayProgress(const QString& text, int percent, const QPixmap& customPixmap) { + Q_UNUSED(customPixmap) + _timer.stop(); + _widget->_progressText->setText(text); + _widget->_progress->setProgress(percent); + _widget->_widgetStack->raiseWidget(1); + show(); +} + + +void DefaultSkin::timeout() { + clear(); +} + + +#include "defaultskin.moc" + diff --git a/kmilo/kmilod/defaultskin.h b/kmilo/kmilod/defaultskin.h new file mode 100644 index 0000000..0e01f23 --- /dev/null +++ b/kmilo/kmilod/defaultskin.h @@ -0,0 +1,56 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 2; -*- +/* + This file is part of the KDE project + + Copyright (c) 2003 George Staikos <staikos@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _DEFAULTSKIN_H_ +#define _DEFAULTSKIN_H_ + +#include <qstring.h> +#include <qobject.h> +#include <qtimer.h> +#include "displayskin.h" + +class DefaultWidget; + +class DefaultSkin : public QObject, public KMilo::DisplaySkin { + Q_OBJECT + public: + DefaultSkin(); + virtual ~DefaultSkin(); + + virtual void clear(); + + virtual void displayText(const QString& text, const QPixmap& customPixmap=QPixmap()); + virtual void displayProgress(const QString& text, + int percent, const QPixmap& customPixmap=QPixmap()); + + private slots: + void timeout(); + + private: + void show(); + + DefaultWidget *_widget; + QTimer _timer; +}; + + +#endif diff --git a/kmilo/kmilod/defaultwidget.ui b/kmilo/kmilod/defaultwidget.ui new file mode 100644 index 0000000..b4809fe --- /dev/null +++ b/kmilo/kmilod/defaultwidget.ui @@ -0,0 +1,195 @@ +<!DOCTYPE UI><UI version="3.1" stdsetdef="1"> +<class>DefaultWidget</class> +<comment>Default widget for the default display for kmilod +Released under the terms of the GNU GPL.</comment> +<author>George Staikos <staikos@kde.org</author> +<widget class="QWidget"> + <property name="name"> + <cstring>DefaultWidget</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>566</width> + <height>180</height> + </rect> + </property> + <property name="paletteBackgroundColor"> + <color> + <red>214</red> + <green>213</green> + <blue>212</blue> + </color> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QWidgetStack" row="0" column="0"> + <property name="name"> + <cstring>_widgetStack</cstring> + </property> + <property name="paletteBackgroundColor"> + <color> + <red>214</red> + <green>213</green> + <blue>212</blue> + </color> + </property> + <property name="frameShape"> + <enum>StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <widget class="QWidget"> + <property name="name"> + <cstring>page</cstring> + </property> + <attribute name="id"> + <number>0</number> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>_textOnly</cstring> + </property> + <property name="paletteForegroundColor"> + <color> + <red>26</red> + <green>69</green> + <blue>198</blue> + </color> + </property> + <property name="paletteBackgroundColor"> + <color> + <red>214</red> + <green>213</green> + <blue>212</blue> + </color> + </property> + <property name="font"> + <font> + <pointsize>28</pointsize> + <bold>1</bold> + </font> + </property> + <property name="text"> + <string></string> + </property> + <property name="alignment"> + <set>AlignCenter</set> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>page</cstring> + </property> + <attribute name="id"> + <number>1</number> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer row="1" column="2"> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>81</width> + <height>31</height> + </size> + </property> + </spacer> + <spacer row="1" column="0"> + <property name="name"> + <cstring>spacer1_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>81</width> + <height>31</height> + </size> + </property> + </spacer> + <widget class="QProgressBar" row="1" column="1"> + <property name="name"> + <cstring>_progress</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="paletteBackgroundColor"> + <color> + <red>214</red> + <green>213</green> + <blue>212</blue> + </color> + </property> + <property name="centerIndicator"> + <bool>false</bool> + </property> + </widget> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>_progressText</cstring> + </property> + <property name="paletteForegroundColor"> + <color> + <red>26</red> + <green>69</green> + <blue>198</blue> + </color> + </property> + <property name="paletteBackgroundColor"> + <color> + <red>214</red> + <green>213</green> + <blue>212</blue> + </color> + </property> + <property name="font"> + <font> + <pointsize>28</pointsize> + <bold>1</bold> + </font> + </property> + <property name="text"> + <string></string> + </property> + <property name="alignment"> + <set>AlignCenter</set> + </property> + </widget> + </grid> + </widget> + </widget> + </grid> +</widget> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/kmilo/kmilod/displayskin.cpp b/kmilo/kmilod/displayskin.cpp new file mode 100644 index 0000000..f0fd422 --- /dev/null +++ b/kmilo/kmilod/displayskin.cpp @@ -0,0 +1,34 @@ +/* + This file is part of the KDE project + + Copyright (c) 2003 George Staikos <staikos@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + +*/ + +#include "displayskin.h" + +namespace KMilo { + +DisplaySkin::DisplaySkin() { +} + +DisplaySkin::~DisplaySkin() { +} + +} + diff --git a/kmilo/kmilod/displayskin.h b/kmilo/kmilod/displayskin.h new file mode 100644 index 0000000..4e74e0c --- /dev/null +++ b/kmilo/kmilod/displayskin.h @@ -0,0 +1,47 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 2; -*- +/* + This file is part of the KDE project + + Copyright (c) 2003 George Staikos <staikos@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _DISPLAYSKIN_H_ +#define _DISPLAYSKIN_H_ + +#include <kdemacros.h> + +#include <qstring.h> +#include <qpixmap.h> + +namespace KMilo { + +class KDE_EXPORT DisplaySkin { + public: + DisplaySkin(); + virtual ~DisplaySkin(); + + virtual void clear() = 0; + + virtual void displayText(const QString& text,const QPixmap& customPixmap=QPixmap()) = 0; + virtual void displayProgress(const QString& text, + int percent, const QPixmap& customPixmap=QPixmap()) = 0; +}; + +} + +#endif diff --git a/kmilo/kmilod/kmilod.cpp b/kmilo/kmilod/kmilod.cpp new file mode 100644 index 0000000..98203b1 --- /dev/null +++ b/kmilo/kmilod/kmilod.cpp @@ -0,0 +1,227 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 2; -*- +/* + This file is part of the KDE project + + Copyright (c) 2003 George Staikos <staikos@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "kmilod.h" +#include "monitor.h" + +#include <qfile.h> + +#include <klocale.h> +#include <kdebug.h> +#include <kservicetype.h> +#include <kservice.h> +#include <kconfig.h> +#include <kparts/componentfactory.h> + +#include "kmilointerface.h" +#include "defaultskin.h" + +using namespace KMilo; + +extern "C" { + KDE_EXPORT KDEDModule *create_kmilod(const QCString &name) { + return new KMiloD(name); + } +} + + +KMiloD::KMiloD(const QCString &name) : KDEDModule(name), _interval(100) +{ + _monitors.setAutoDelete(true); + _miface = new KMiloInterface(this); + + // Create the display skin object + _display = new DefaultSkin; + + bool shouldPoll = false; + + // Load the modules + KService::List plugs = KServiceType::offers("KMilo Plugin"); + for (KService::List::ConstIterator it = plugs.begin(); + it != plugs.end(); ++it) { + KService::Ptr service = *it; + KMilo::Monitor *m = KParts::ComponentFactory::createInstanceFromService<KMilo::Monitor>(service, 0, service->desktopEntryName().latin1()); + if (m) { + m->setInterface(_miface); + if (m->init()) { + _monitors.append(m); + kdDebug() << "KMilo loaded module " + << service->property("Name").toString() + << endl; + shouldPoll = shouldPoll || m->shouldPoll(); + } else { + delete m; + } + } + } + + // Start the timer + QObject::connect(&_timer, SIGNAL(timeout()), this, SLOT(doTimer())); + if (shouldPoll) { + _timer.start(_interval); + } +} + + +KMiloD::~KMiloD() +{ + _timer.stop(); + + // Modules are automatically cleaned up when this is done. It has + // to be done before delete _display to avoid a race though. + _monitors.clear(); + + delete _display; + _display = 0L; + + delete _miface; + _miface = 0L; +} + + +void KMiloD::setEnabled(bool enabled) { + if (enabled) { + enable(); + } else { + disable(); + } +} + + +void KMiloD::enable() { + if (!_monitors.isEmpty()) { + _timer.start(_interval, false); + } +} + + +void KMiloD::disable() { + _timer.stop(); +} + + +bool KMiloD::enabled() const { + return _timer.isActive(); +} + + +int KMiloD::pollMilliSeconds() const { + return _interval; +} + + +bool KMiloD::setPollMilliSeconds(int ms) { + if (ms > 1000 || ms < 0) { + return false; + } + + if (!_monitors.isEmpty()) { + _timer.start(_interval, false); + } + + _interval = ms; + +return true; +} + + +void KMiloD::doTimer() { + // Iterate through all the modules we have and poll + for (KMilo::Monitor *m = _monitors.first(); m; m = _monitors.next()) { + if (!m->shouldPoll()) { + continue; + } + + KMilo::Monitor::DisplayType dt = m->poll(); + switch (dt) { + case KMilo::Monitor::Volume: + displayProgress(i18n("Volume"), m->progress()); + break; + case KMilo::Monitor::Brightness: + displayProgress(i18n("Brightness"), m->progress()); + break; + case KMilo::Monitor::Mute: + displayText(i18n("Muted")); + break; + case KMilo::Monitor::Tap: + displayText(m->message()); + break; + case KMilo::Monitor::Sleep: + displayText(m->message()); + break; + case KMilo::Monitor::None: + // Do nothing + break; + case KMilo::Monitor::Error: + { + // On error, remove the monitor and continue + KMilo::Monitor *n = _monitors.next(); + _monitors.remove(m); // deletes m + m = n; + } + break; + default: + kdWarning() << "Error in KMiloD. Please report." << endl; + break; + } + } +} + + +void KMiloD::displayText(const QString& text) { + _display->displayText(text, QPixmap()); +} + + +void KMiloD::displayText(const QString& text, const QPixmap& customPixmap) { + _display->displayText(text, customPixmap); +} + + +void KMiloD::displayProgress(const QString& text, int progress) { + _display->displayProgress(text, progress, QPixmap()); +} + +void KMiloD::displayProgress(const QString& text, int progress, const QPixmap& customPixmap ) { + _display->displayProgress(text, progress, customPixmap); +} + +void KMiloD::reconfigure() +{ + // load the kmilo configuration file: + KConfig config("kmilodrc"); + + KMilo::Monitor *monitor; + + for(monitor = _monitors.first(); monitor; monitor = _monitors.next()) + { + monitor->reconfigure(&config); + } +} + +#include "kmilod.moc" + diff --git a/kmilo/kmilod/kmilod.desktop b/kmilo/kmilod/kmilod.desktop new file mode 100644 index 0000000..d31dacb --- /dev/null +++ b/kmilo/kmilod/kmilod.desktop @@ -0,0 +1,59 @@ +[Desktop Entry] +Type=Service +ServiceTypes=KDEDModule +X-KDE-ModuleType=Library +X-KDE-Library=kmilod +X-KDE-FactoryName=kmilod +X-KDE-Kded-autoload=true +X-KDE-Kded-load-on-demand=false +Name=KMilo +Name[de]=KMilo Sondertasten +Name[hi]=के-मिलो +Name[ne]=केमिलो +Name[sv]=Kmilo +Name[ta]= கேமிலோ +Comment=KDE special key notifier +Comment[ar]=مبلغ كدى للمفاتيح الخاصة +Comment[bg]=Известяване при натискане на специалните клавиши на някои модели лаптопи +Comment[bs]=KDE obavještenje o posebnim tipkama +Comment[ca]=Notificador de tecles especials de KDE +Comment[cs]=Hlášení speciálních kláves +Comment[da]=KDE Speciel tast bekendtgørelse +Comment[de]=Unterstützung für Sonder- und Multimediatasten in KDE +Comment[el]=Ειδοποιητής ειδικών πλήκτρων του KDE +Comment[eo]=KDE-specialklavatentigilo +Comment[es]=Notificador de teclas especiales de KDE +Comment[et]=KDE eriklahvide märkija +Comment[eu]=KDE tekla berezien jakinarazlea +Comment[fa]=اخطار دهندۀ ویژۀ کلید KDE +Comment[fi]=KDE:n erikoisnäppäinhuomauttaja +Comment[fr]=Notificateur de touche spéciale pour KDE +Comment[hu]=KDE-s kezelőprogram a speciális billentyűkhöz +Comment[is]=KDE sérhnappatólið +Comment[it]=Gestione KDE dei tasti speciali +Comment[ja]=KDE の特殊キー通知 +Comment[kk]=KDE-ның арнаулы пернелерді қолдауы +Comment[km]=កម្មវិធីជូនដំណឹងគ្រាប់ចុច KDE ពិសេស +Comment[lt]=KDE specialiųjų raktų pranešiklis +Comment[mk]=Известувач за спец. копчиња во KDE +Comment[nb]=Beskjedgiver KDE spesialtaster +Comment[nds]=KDE-Sünnertastenmellen +Comment[ne]=KDE विशेष कुञ्जी सूचनाकर्ता +Comment[nl]=KDE-notificatie van speciale toetsen +Comment[nn]=KDE-verktøy for spesialtastar +Comment[pa]=KDE ਖਾਸ ਸਵਿੱਚ ਸੂਚਕ +Comment[pl]=Obsługa klawiszy specjalnych +Comment[pt]=Notificação de teclas especiais do KDE +Comment[pt_BR]=Notificador de tecla especial do KDE +Comment[ro]=Notificare taste speciale pentru KDE +Comment[ru]=Поддержка специальных клавиш +Comment[sk]=KDE upozornenie na špeciálne klávesy +Comment[sl]=Opomnik posebnih ključev v KDE +Comment[sr]=KDE-ов обаваштавач о посебним тастерима +Comment[sr@Latn]=KDE-ov obavaštavač o posebnim tasterima +Comment[sv]=Underrättelse om KDE specialtangent +Comment[ta]= கேடிஇ சிறப்பு விசை குறிப்பான் +Comment[tr]=KDE özel tuş bildirici +Comment[uk]=Сповіщувач про натискання спеціальних клавіш для KDE +Comment[zh_CN]=KDE 特殊按键通知程序 +Comment[zh_TW]=KDE 特殊鍵通知 diff --git a/kmilo/kmilod/kmilod.h b/kmilo/kmilod/kmilod.h new file mode 100644 index 0000000..d97027b --- /dev/null +++ b/kmilo/kmilod/kmilod.h @@ -0,0 +1,72 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 2; -*- +/* + This file is part of the KDE project + + Copyright (c) 2003 George Staikos <staikos@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + +*/ +#ifndef _KMILOD_H_ +#define _KMILOD_H_ + +#include <kdedmodule.h> +#include <qstring.h> +#include <qtimer.h> +#include <qptrlist.h> +#include "monitor.h" +#include "displayskin.h" + +namespace KMilo { + +class KMiloInterface; + +class KMiloD : public KDEDModule { + Q_OBJECT + K_DCOP + public: + KMiloD(const QCString &name); + virtual ~KMiloD(); + + k_dcop: + virtual void setEnabled(bool enabled); + virtual void enable(); + virtual void disable(); + virtual bool enabled() const; + virtual int pollMilliSeconds() const; + virtual bool setPollMilliSeconds(int ms); + + virtual void displayText(const QString& text); + virtual void displayText(const QString& text, const QPixmap& customPixmap); + virtual void displayProgress(const QString& text, int progress, const QPixmap& customPixmap); + virtual void displayProgress(const QString& text, int progress); + + virtual void reconfigure(); + + private slots: + virtual void doTimer(); + + private: + QTimer _timer; + int _interval; + QPtrList<Monitor> _monitors; + DisplaySkin *_display; + KMiloInterface *_miface; +}; + +} + +#endif diff --git a/kmilo/kmilod/kmilointerface.cpp b/kmilo/kmilod/kmilointerface.cpp new file mode 100644 index 0000000..21a6430 --- /dev/null +++ b/kmilo/kmilod/kmilointerface.cpp @@ -0,0 +1,26 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 2; -*- +/* + This file is part of the KDE project + + Copyright (c) 2003 George Staikos <staikos@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + +*/ + +#include "kmilointerface.h" +#include "kmilointerface.moc" + diff --git a/kmilo/kmilod/kmilointerface.h b/kmilo/kmilod/kmilointerface.h new file mode 100644 index 0000000..d1edbb9 --- /dev/null +++ b/kmilo/kmilod/kmilointerface.h @@ -0,0 +1,57 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 2; -*- +/* + This file is part of the KDE project + + Copyright (c) 2003 George Staikos <staikos@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + +*/ +#ifndef _KMILOI_H_ +#define _KMILOI_H_ + +#include <qobject.h> +#include <qstring.h> +#include "kmilod.h" + +namespace KMilo { + +// FIXME: make put the methods into .cpp file when the header is installed. +class KMiloInterface : public QObject { + Q_OBJECT + public: + KMiloInterface(KMiloD *p) : QObject() { _p = p; } + virtual ~KMiloInterface() {} + + public slots: + int pollMilliSeconds() const { return _p->pollMilliSeconds(); } + bool setPollMilliSeconds(int ms) { return _p->setPollMilliSeconds(ms); } + + void displayText(const QString& text) { _p->displayText(text); } + void displayText(const QString& text, const QPixmap& customPixmap) { _p->displayText(text, customPixmap); } + + void displayProgress(const QString& text, int progress, const QPixmap& customPixmap) { _p->displayProgress(text, progress, customPixmap); } + void displayProgress(const QString& text, int progress) { _p->displayProgress(text, progress); } + + void reconfigure() { _p->reconfigure(); } + + private: + KMiloD *_p; +}; + +} + +#endif diff --git a/kmilo/kmilod/kmilopluginsvc.desktop b/kmilo/kmilod/kmilopluginsvc.desktop new file mode 100644 index 0000000..bccb599 --- /dev/null +++ b/kmilo/kmilod/kmilopluginsvc.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=ServiceType +X-KDE-ServiceType=KMilo Plugin + +[PropertyDef::X-KMilo-Plugin-Author] +Type=QString +[PropertyDef::X-KMilo-Default-Enabled] +Type=bool + diff --git a/kmilo/kmilod/monitor.cpp b/kmilo/kmilod/monitor.cpp new file mode 100644 index 0000000..f427ce4 --- /dev/null +++ b/kmilo/kmilod/monitor.cpp @@ -0,0 +1,44 @@ +/* + This file is part of the KDE project + + Copyright (c) 2003 George Staikos <staikos@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + +*/ + +#include "monitor.h" + +KMilo::Monitor::Monitor(QObject *parent, const char *name, const QStringList&) +: QObject(parent, name) { + _poll = true; +} + +KMilo::Monitor::~Monitor() { +} + +void KMilo::Monitor::reconfigure(KConfig*) +{ +} + +KMilo::Monitor::DisplayType KMilo::Monitor::poll() { return None; } + +int KMilo::Monitor::progress() const { return 42; } + +QString KMilo::Monitor::message() const { return QString::null; } +QPixmap KMilo::Monitor::customPixmap() const { return QPixmap(); } +bool KMilo::Monitor::init() { return true; } + diff --git a/kmilo/kmilod/monitor.h b/kmilo/kmilod/monitor.h new file mode 100644 index 0000000..ee1581c --- /dev/null +++ b/kmilo/kmilod/monitor.h @@ -0,0 +1,98 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 2; -*- +/* + This file is part of the KDE project + + Copyright (c) 2003 George Staikos <staikos@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _MONITOR_H_ +#define _MONITOR_H_ + +#include <qstring.h> +#include <qstringlist.h> +#include <qpixmap.h> +#include <qobject.h> + +#include <kdemacros.h> + +class KConfig; + +namespace KMilo { +class KMiloInterface; + +class KDE_EXPORT Monitor : public QObject { + public: + Monitor(QObject *parent, const char *name, const QStringList&); + virtual ~Monitor(); + + /** + * Called by kmilod to initialise this plugin. The plugin + * must return true if its hardware is present and it should + * be loaded. If it returns false, it will be unloaded. + */ + virtual bool init(); + + enum DisplayType { None, //! + Error, //! Error + Volume, //! Volume level changed + Mute, //! Volume has been muted + Brightness, //! Brighteness of the screen has changed + Tap, //! Mousttracker tap mode has changed + Sleep //! laptop will sleep in progress() seconds + }; + + /** + * This is called by KMiloD when it polls. Must return + * the type of event that has occurred, or None. + */ + virtual DisplayType poll(); + + /** + * If poll() returns stating that a value has changed, this + * will be called by kmilod to determine the value (0..100) + * for the slider in the display, if necessary. + */ + virtual int progress() const; + + /** + * Message displayed for DisplayType's that are not int + * measurable ( DisplayType::Tap for example ) + */ + virtual QString message() const; + + /** + * Custom pixmap that can be displayed be the themes + * when displaying the DisplayType. + */ + virtual QPixmap customPixmap() const; + + bool shouldPoll() const { return _poll; } + + virtual void reconfigure(KConfig*); + + protected: + bool _poll; // set to false to disable polling. + friend class KMiloD; + void setInterface(KMiloInterface *i) { _interface = i; } + + KMiloInterface *_interface; +}; + +} + +#endif |