summaryrefslogtreecommitdiffstats
path: root/languages/cpp/app_templates/kscreensaver/kscreensaver.cpp
blob: efdbf40b605cf7123541597081aa3a0a8b502e81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
%{CPP_TEMPLATE}

#include <stdlib.h>
#include <tqcheckbox.h>
#include <tqcolor.h>
#include <kapplication.h>
#include <klocale.h>
#include <kpushbutton.h>
#include <kconfig.h>
#include <kglobal.h>
#include "%{APPNAMELC}.h"
#include "%{APPNAMELC}ui.h"

//! libkscreensaver interface
extern "C"
{
    const char *kss_applicationName = "%{APPNAMELC}.kss";
    const char *kss_description = I18N_NOOP( "%{APPNAME}" );
    const char *kss_version = "2.2.0";

    %{APPNAME} *kss_create( WId id )
    {
        KGlobal::locale()->insertCatalogue("%{APPNAMELC}");
        return new %{APPNAME}( id );
    }

    TQDialog *kss_setup()
    {
        KGlobal::locale()->insertCatalogue("%{APPNAMELC}");
        return new %{APPNAME}Setup();
    }
}

//-----------------------------------------------------------------------------
//! dialog to setup screen saver parameters
%{APPNAME}Setup::%{APPNAME}Setup( TQWidget *parent, const char *name )
        : %{APPNAME}UI( parent, name, TRUE )
{
    /// @todo
    //Connect your signals and slots here to configure the screen saver.
    connect( OkayPushButton, TQT_SIGNAL( released() ),
             TQT_SLOT( slotOkPressed() ) );
    connect( CancelPushButton, TQT_SIGNAL( released() ),
             TQT_SLOT( slotCancelPressed() ) );
}


//! read settings from config file
void %{APPNAME}Setup::readSettings()
{
    KConfig *config = KGlobal::config();
    config->setGroup( "Settings" );
    /// @todo
    // Add your config options here...
    CheckBox1->setChecked(config->readBoolEntry( "somesetting", false ));
}


//! Ok pressed - save settings and exit
void %{APPNAME}Setup::slotOkPressed()
{
    KConfig *config = KGlobal::config();
    config->setGroup( "Settings" );
    /// @todo
    // Add your config options here.
    config->writeEntry( "somesetting", CheckBox1->isChecked() );
    config->sync();

    accept();
}

void %{APPNAME}Setup::slotCancelPressed()
{
    reject();
}
//-----------------------------------------------------------------------------


%{APPNAME}::%{APPNAME}( WId id ) : KScreenSaver( id )
{
    readSettings();
    blank();
}

%{APPNAME}::~%{APPNAME}()
{}


//! read configuration settings from config file
void %{APPNAME}::readSettings()
{
    KConfig *config = KGlobal::config();
    config->setGroup( "Settings" );
    /// @todo
    // Add your config options here...
    bool somesetting = config->readBoolEntry( "somesetting", false );
}


void %{APPNAME}::blank()
{
    /// @todo
    //Add your code to render the screen.
    setBackgroundColor( TQColor(black)  );
    //
    erase();
}