TDE base libraries and programs
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

136 lignes
3.2KB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // kblankscrn - Basic screen saver for KDE
  4. //
  5. // Copyright (c) Martin R. Jones 1996
  6. //
  7. // 1998/04/19 Layout management added by Mario Weilguni <mweilguni@kde.org>
  8. // 2001/03/04 Converted to use libtdescreensaver by Martin R. Jones
  9. #include <stdlib.h>
  10. #include <tqlabel.h>
  11. #include <tqlayout.h>
  12. #include <tdeapplication.h>
  13. #include <tdelocale.h>
  14. #include <tdeconfig.h>
  15. #include <kcolordialog.h>
  16. #include <kbuttonbox.h>
  17. #include <kcolorbutton.h>
  18. #include <tdeglobal.h>
  19. #include "blankscrn.h"
  20. #include "blankscrn.moc"
  21. // libtdescreensaver interface
  22. extern "C"
  23. {
  24. KDE_EXPORT const char *kss_applicationName = "kblankscrn.kss";
  25. KDE_EXPORT const char *kss_description = I18N_NOOP( "KBlankScreen" );
  26. KDE_EXPORT const char *kss_version = "2.2.0";
  27. KDE_EXPORT KScreenSaver* kss_create( WId id )
  28. {
  29. return new KBlankSaver( id );
  30. }
  31. KDE_EXPORT TQDialog* kss_setup()
  32. {
  33. return new KBlankSetup();
  34. }
  35. }
  36. //-----------------------------------------------------------------------------
  37. // dialog to setup screen saver parameters
  38. //
  39. KBlankSetup::KBlankSetup( TQWidget *parent, const char *name )
  40. : KDialogBase( parent, name, true, i18n( "Setup Blank Screen Saver" ),
  41. Ok|Cancel, Ok, true )
  42. {
  43. readSettings();
  44. TQFrame *main = makeMainWidget();
  45. TQGridLayout *grid = new TQGridLayout(main, 4, 2, 0, spacingHint() );
  46. TQLabel *label = new TQLabel( i18n("Color:"), main );
  47. grid->addWidget(label, 0, 0);
  48. KColorButton *colorPush = new KColorButton( color, main );
  49. colorPush->setMinimumWidth(80);
  50. connect( colorPush, TQT_SIGNAL( changed(const TQColor &) ),
  51. TQT_SLOT( slotColor(const TQColor &) ) );
  52. grid->addWidget(colorPush, 1, 0);
  53. preview = new TQWidget( main );
  54. preview->setFixedSize( 220, 165 );
  55. preview->setBackgroundColor( black );
  56. preview->show(); // otherwise saver does not get correct size
  57. saver = new KBlankSaver( preview->winId() );
  58. grid->addMultiCellWidget(preview, 0, 2, 1, 1);
  59. grid->setRowStretch( 2, 10 );
  60. grid->setRowStretch( 3, 20 );
  61. setMinimumSize( sizeHint() );
  62. }
  63. // read settings from config file
  64. void KBlankSetup::readSettings()
  65. {
  66. TDEConfig *config = TDEGlobal::config();
  67. config->setGroup( "Settings" );
  68. color = config->readColorEntry( "Color", &black );
  69. }
  70. void KBlankSetup::slotColor( const TQColor &col )
  71. {
  72. color = col;
  73. saver->setColor( color );
  74. }
  75. // Ok pressed - save settings and exit
  76. void KBlankSetup::slotOk()
  77. {
  78. TDEConfig *config = TDEGlobal::config();
  79. config->setGroup( "Settings" );
  80. config->writeEntry( "Color", color );
  81. config->sync();
  82. accept();
  83. }
  84. //-----------------------------------------------------------------------------
  85. KBlankSaver::KBlankSaver( WId id ) : KScreenSaver( id )
  86. {
  87. readSettings();
  88. blank();
  89. }
  90. KBlankSaver::~KBlankSaver()
  91. {
  92. }
  93. // set the color
  94. void KBlankSaver::setColor( const TQColor &col )
  95. {
  96. color = col;
  97. blank();
  98. }
  99. // read configuration settings from config file
  100. void KBlankSaver::readSettings()
  101. {
  102. TDEConfig *config = TDEGlobal::config();
  103. config->setGroup( "Settings" );
  104. color = config->readColorEntry( "Color", &black );
  105. }
  106. void KBlankSaver::blank()
  107. {
  108. setBackgroundColor( color );
  109. erase();
  110. }