From 4aed2c8219774f5d797760606b8489a92ddc5163 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/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kscreensaver/blankscrn.cpp | 135 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 kscreensaver/blankscrn.cpp (limited to 'kscreensaver/blankscrn.cpp') diff --git a/kscreensaver/blankscrn.cpp b/kscreensaver/blankscrn.cpp new file mode 100644 index 000000000..6b0b974c9 --- /dev/null +++ b/kscreensaver/blankscrn.cpp @@ -0,0 +1,135 @@ +//----------------------------------------------------------------------------- +// +// kblankscrn - Basic screen saver for KDE +// +// Copyright (c) Martin R. Jones 1996 +// +// 1998/04/19 Layout management added by Mario Weilguni +// 2001/03/04 Converted to use libkscreensaver by Martin R. Jones + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "blankscrn.h" +#include "blankscrn.moc" + +// libkscreensaver interface +extern "C" +{ + KDE_EXPORT const char *kss_applicationName = "kblankscrn.kss"; + KDE_EXPORT const char *kss_description = I18N_NOOP( "KBlankScreen" ); + KDE_EXPORT const char *kss_version = "2.2.0"; + + KDE_EXPORT KScreenSaver* kss_create( WId id ) + { + return new KBlankSaver( id ); + } + + KDE_EXPORT QDialog* kss_setup() + { + return new KBlankSetup(); + } +} + +//----------------------------------------------------------------------------- +// dialog to setup screen saver parameters +// +KBlankSetup::KBlankSetup( QWidget *parent, const char *name ) + : KDialogBase( parent, name, true, i18n( "Setup Blank Screen Saver" ), + Ok|Cancel, Ok, true ) +{ + readSettings(); + + QFrame *main = makeMainWidget(); + QGridLayout *grid = new QGridLayout(main, 4, 2, 0, spacingHint() ); + + QLabel *label = new QLabel( i18n("Color:"), main ); + grid->addWidget(label, 0, 0); + + KColorButton *colorPush = new KColorButton( color, main ); + colorPush->setMinimumWidth(80); + connect( colorPush, SIGNAL( changed(const QColor &) ), + SLOT( slotColor(const QColor &) ) ); + grid->addWidget(colorPush, 1, 0); + + preview = new QWidget( main ); + preview->setFixedSize( 220, 165 ); + preview->setBackgroundColor( black ); + preview->show(); // otherwise saver does not get correct size + saver = new KBlankSaver( preview->winId() ); + grid->addMultiCellWidget(preview, 0, 2, 1, 1); + + grid->setRowStretch( 2, 10 ); + grid->setRowStretch( 3, 20 ); + + setMinimumSize( sizeHint() ); +} + +// read settings from config file +void KBlankSetup::readSettings() +{ + KConfig *config = KGlobal::config(); + config->setGroup( "Settings" ); + + color = config->readColorEntry( "Color", &black ); +} + +void KBlankSetup::slotColor( const QColor &col ) +{ + color = col; + saver->setColor( color ); +} + +// Ok pressed - save settings and exit +void KBlankSetup::slotOk() +{ + KConfig *config = KGlobal::config(); + config->setGroup( "Settings" ); + config->writeEntry( "Color", color ); + config->sync(); + + accept(); +} + +//----------------------------------------------------------------------------- + + +KBlankSaver::KBlankSaver( WId id ) : KScreenSaver( id ) +{ + readSettings(); + blank(); +} + +KBlankSaver::~KBlankSaver() +{ +} + +// set the color +void KBlankSaver::setColor( const QColor &col ) +{ + color = col; + blank(); +} + +// read configuration settings from config file +void KBlankSaver::readSettings() +{ + KConfig *config = KGlobal::config(); + config->setGroup( "Settings" ); + + color = config->readColorEntry( "Color", &black ); +} + +void KBlankSaver::blank() +{ + setBackgroundColor( color ); + erase(); +} + -- cgit v1.2.1