Back to index

kdeartwork  4.3.2
Public Member Functions | Protected Member Functions | Protected Attributes
kVmSaver Class Reference

#include <kvm.h>

Collaboration diagram for kVmSaver:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 kVmSaver (WId id)
virtual ~kVmSaver ()
void setSpeed (int spd)
void setRefreshTimeout (const int refreshTimeout)

Protected Member Functions

void readSettings ()
int getRandom (const int max_value)
void modifyArea (const int op)
void paintEvent (QPaintEvent *event)

Protected Attributes

QTimer timer
int speed
m_statepool_state
int refreshStep
int refreshTimeout

Detailed Description

Definition at line 43 of file kvm.h.


Constructor & Destructor Documentation

kVmSaver::kVmSaver ( WId  id)

Definition at line 189 of file kvm.cpp.

                           : KScreenSaver( id )
{
       readSettings();

        QPalette palette;
        palette.setColor( backgroundRole(), Qt::black );
        setPalette( palette );
       setAutoFillBackground(true);

        setSpeed( speed );
        setRefreshTimeout( refreshTimeout );

        refreshStep = 0;

        pool_state = init_pool( this );
        vm_default_initstate( time(0), &(pool_state->pool->vm_random_data) );
       connect( &timer, SIGNAL( timeout() ), SLOT( update() ) );
        timer.start( 100 - speed );
        show();
}

Here is the call graph for this function:

kVmSaver::~kVmSaver ( ) [virtual]

Definition at line 210 of file kvm.cpp.

{
       timer.stop();
        vm_done_pool( pool_state->pool );
        delete[] pool_state->modified;
}

Here is the call graph for this function:


Member Function Documentation

int kVmSaver::getRandom ( const int  max_value) [protected]

Definition at line 235 of file kvm.cpp.

                                             {
 return (int)( vm_random(&(pool_state->pool->vm_random_data))*1.0*(max_value + 1.0)/
               (VM_RAND_MAX + 1.0) );
// return (int)( rand()*1.0*(max_value + 1.0)/
//               (RAND_MAX + 1.0) );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void kVmSaver::modifyArea ( const int  op) [protected]

Definition at line 241 of file kvm.cpp.

                                        {
 int position;

 vm_modify( pool_state->pool, position =
            getRandom(pool_state->pool->area_size - 1), op );
 pool_state->modified[position] = 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void kVmSaver::paintEvent ( QPaintEvent *  event) [protected]

Definition at line 249 of file kvm.cpp.

{
 setAttribute( Qt::WA_NoSystemBackground ); // Only after initial clear

 for( int i = 0; i < 1; ++i ) {
  if( getRandom(2) == 0 )
   modifyArea( VM_OP_PUSH + getRandom(11) - getRandom(11) );
  if( getRandom(8) == 0 )
   modifyArea( VM_OP_STOP );
  if( getRandom(8) == 0 )
   modifyArea( VM_OP_COPY );
  if( getRandom(8) == 0 )
   modifyArea( VM_OP_EXEC );
//  if( getRandom(5) == 0 )
//   modifyArea( VM_OP_WAIT );
 }
 if( getRandom(0) == 0 )
  vm_exec( pool_state->pool, getRandom(pool_state->pool->area_size - 1), 0,
           vm_get_reverse( pool_state->pool ) );
 vm_iterate( pool_state->pool, pool_state->modified );
// if( refreshStep++ >= refreshTimeout*refreshTimeout*refreshTimeout ) {
 if( refreshStep++ >= refreshTimeout ) {
  draw_pool( pool_state );
  refreshStep = 0;
 }
}

Here is the call graph for this function:

void kVmSaver::readSettings ( ) [protected]

Definition at line 228 of file kvm.cpp.

{
       KConfigGroup config(KGlobal::config(), "Settings");

       speed = config.readEntry( "Speed", 50 );
       refreshTimeout = config.readEntry( "DisplayRefreshTimeout", 0 );
}

Here is the caller graph for this function:

void kVmSaver::setRefreshTimeout ( const int  refreshTimeout)

Definition at line 223 of file kvm.cpp.

Here is the caller graph for this function:

void kVmSaver::setSpeed ( int  spd)

Definition at line 217 of file kvm.cpp.

{
       speed = spd;
//     timer.start( (100 - speed)*(100 - speed)*(100 - speed)/10000 );
       timer.start( (100 - speed) );
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 63 of file kvm.h.

int kVmSaver::refreshStep [protected]

Definition at line 64 of file kvm.h.

int kVmSaver::refreshTimeout [protected]

Definition at line 65 of file kvm.h.

int kVmSaver::speed [protected]

Definition at line 62 of file kvm.h.

QTimer kVmSaver::timer [protected]

Definition at line 60 of file kvm.h.


The documentation for this class was generated from the following files: