1 --- ./eyesaver.cpp.orig 2008-10-02 19:27:47.000000000 +0200
2 +++ ./eyesaver.cpp 2009-01-07 09:24:43.000000000 +0100
6 +#include <QtGui/QWidget> // QWIDGETSIZE_MAX
7 +#include <QtDBus/QDBusInterface>
8 +#include <QtDBus/QDBusReply>
9 +#include <QGraphicsLinearLayout>
13 #include <QFontMetrics>
19 + m_screenSaverIface = new OrgFreedesktopScreenSaverInterface("org.freedesktop.ScreenSaver", "/ScreenSaver",
20 + QDBusConnection::sessionBus(), this);
26 quandopausa = cfg.readEntry("quandopausa", 2700);
27 disattivato = cfg.readEntry("disattivato", 0);
28 musichetta = cfg.readEntry("musichetta", 1);
29 + screenlock = cfg.readEntry("screenlock", 1);
32 void Plasmaeyesaver::saveConfig ()
34 duratapausa = m_durata_pausa->value()*60;
35 quandopausa = m_quando_pausa->value()*60;
36 musichetta = m_musichetta->isChecked();
37 + screenlock = m_screenlock->isChecked();
38 cfg.writeEntry("quandopausa", quandopausa);
39 cfg.writeEntry("duratapausa", duratapausa);
40 cfg.writeEntry("disattivato", disattivato);
41 cfg.writeEntry("musichetta",musichetta);
42 + cfg.writeEntry("screenlock",screenlock);
45 void Plasmaeyesaver::apridocum () {
47 m_quando_pausa->setValue(quandopausa/60);
48 m_musichetta = new QCheckBox("Play sound", page);
49 m_musichetta->setChecked(musichetta);
50 + m_screenlock = new QCheckBox("Lock the screen", page);
51 + m_screenlock->setChecked(screenlock);
52 m_riavvia = new QPushButton("Restart", page);
53 connect(m_riavvia, SIGNAL( clicked() ), SLOT(riavvia()));
54 connect(m_riavvia, SIGNAL( clicked() ), SLOT(saveConfig()));
56 layout->addWidget( durata_label, 1, 0 );
57 layout->addWidget( m_durata_pausa, 1, 1 );
58 layout->addWidget( m_musichetta, 2, 0 );
59 - layout->addWidget( m_riavvia, 3, 1 );
60 + layout->addWidget( m_screenlock, 3, 0 );
61 + layout->addWidget( m_riavvia, 4, 1 );
62 fette->addLayout( layout );
63 fette->addWidget( groupBox );
64 p_parent->addPage( page, i18nc( "name of the applet", "%1 Settings", name() ), icon() );
67 if (secondo>=quandopausa)
69 - if(musichetta) {Phonon::MediaObject *music = Phonon::createPlayer(Phonon::NotificationCategory, Phonon::MediaSource("/usr/kde/4.1/share/sounds/KDE-Sys-Log-In-Short.ogg"));music->play();}
70 + if(musichetta) {Phonon::MediaObject *music = Phonon::createPlayer(Phonon::NotificationCategory, Phonon::MediaSource("/usr/share/sounds/KDE-Sys-Warning.ogg"));music->play();}
73 m_timer->start( 1000 );
75 + if(screenlock) {lockScreen();}
77 else m_timer->start( 4000 );
81 if (secondo==duratapausa)
83 - if(musichetta) {Phonon::MediaObject *music = Phonon::createPlayer(Phonon::NotificationCategory, Phonon::MediaSource("/usr/kde/4.1/share/sounds/KDE-Im-Phone-Ring.ogg"));
84 + if(musichetta) {Phonon::MediaObject *music = Phonon::createPlayer(Phonon::NotificationCategory, Phonon::MediaSource("/usr/share/sounds/KDE-Sys-Warning.ogg"));
92 +void Plasmaeyesaver::lockScreen()
94 + m_screenSaverIface->Lock();
97 #include "eyesaver.moc"
98 --- ./eyesaver.h.orig 2008-10-02 19:28:04.000000000 +0200
99 +++ ./eyesaver.h 2009-01-07 08:59:44.000000000 +0100
101 #include <Plasma/Applet>
102 #include <Plasma/Svg>
104 +#include "screensaver_interface.h"
107 class KProgressDialog;
109 KIntNumInput *m_quando_pausa;
111 QCheckBox *m_musichetta;
112 + QCheckBox *m_screenlock;
116 QPushButton *m_riavvia;
118 //QProgressBar *barra;
119 //KProgressDialog progresso;
120 + /* Enable the screensaver */
122 + /* Dbus interface to the screensaver and idle time functions */
123 + OrgFreedesktopScreenSaverInterface * m_screenSaverIface;
126 // This is the command that links your applet to the .desktop file
127 --- ./CMakeLists.txt.orig 2008-09-15 20:29:51.000000000 +0200
128 +++ ./CMakeLists.txt 2009-01-06 13:17:03.000000000 +0100
130 # Project Needs a name ofcourse
131 project(plasma-eyesaver)
135 # Find the required Libaries
136 find_package(KDE4 REQUIRED)
137 include(KDE4Defaults)
140 # We add our source code here
141 set(tutorial1_SRCS eyesaver.cpp)
145 +if(EXISTS "${DBUS_INTERFACES_INSTALL_DIR}/org.freedesktop.ScreenSaver.xml")
147 +set(screensaver_xml "${DBUS_INTERFACES_INSTALL_DIR}/org.freedesktop.ScreenSaver.xml")
149 +else(EXISTS "${DBUS_INTERFACES_INSTALL_DIR}/org.freedesktop.ScreenSaver.xml")
151 +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
152 +include(PkgConfigGetVar)
153 +PKGCONFIG_GETVAR(dbus-1 prefix DBUS_PREFIX)
154 +set(screensaver_xml ${DBUS_PREFIX}/share/dbus-1/interfaces/org.freedesktop.ScreenSaver.xml)
156 +endif(EXISTS "${DBUS_INTERFACES_INSTALL_DIR}/org.freedesktop.ScreenSaver.xml")
158 +QT4_ADD_DBUS_INTERFACE(tutorial1_SRCS ${screensaver_xml} screensaver_interface )
161 # Now make sure all files get to the right place
162 kde4_add_plugin(plasma_applet_eyesaver ${tutorial1_SRCS})
163 target_link_libraries(plasma_applet_eyesaver
164 - ${PLASMA_LIBS} ${KDE4_KDEUI_LIBS} ${PHONON_LIBS} ${KDE4_KIO_LIBRARY})
165 + ${PLASMA_LIBS} ${KDE4_KDEUI_LIBS} ${PHONON_LIBS} ${KDE4_KIO_LIBRARY} kworkspace ${X11_Xscreensaver_LIB})
167 install(TARGETS plasma_applet_eyesaver
168 DESTINATION ${PLUGIN_INSTALL_DIR})