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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
#!/usr/bin/python
###########################################################################
# kcontrol_module - description #
# ------------------------------ #
# begin : Mon May 2 2005 #
# copyright : (C) 2005 by AUTHOR #
# email : your@email.com #
# #
###########################################################################
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
###########################################################################
import sys
from qt import *
from tdecore import *
from tdeui import *
import kdedesigner
from KcontrolModuleWidgetUI import *
description = "A Kcontrol module"
version = "0.1"
############################################################################
def AboutData():
global version,description
about_data = TDEAboutData("kcontrol_module", "kcontrol_module", version, \
description, TDEAboutData.License_GPL, "(C) 2005 AUTHOR", None, None,\
"your@email.com")
about_data.addAuthor("AUTHOR", None, "your@email.com")
return about_data
############################################################################
class KcontrolModuleWidget(KcontrolModuleWidgetUI):
def __init__(self,parent=None):
KcontrolModuleWidgetUI.__init__(self,parent,"Kcontrol module")
# Add other methods, slots and signals here.
############################################################################
# The base class that we use depends on whether this is running inside
# kcontrol or as a standalone application.
# Are we running as a separate standalone application or in KControl?
standalone = __name__=='__main__'
if standalone:
programbase = KDialogBase
else:
programbase = TDECModule
class KcontrolModuleApp(programbase):
########################################################################
def __init__(self,parent=None,name=None):
global standalone
if standalone:
KDialogBase.__init__(self,KJanusWidget.Plain,"Kcontrol module",KDialogBase.User1|KDialogBase.Close, KDialogBase.Close)
self.setButtonText(KDialogBase.User1,"About")
else:
TDECModule.__init__(self,parent,name)
# Create a configuration object.
self.config = TDEConfig("kcontrol_module")
self.setButtons(0)
self.aboutdata = AboutData()
# The appdir needs to be explicitly otherwise we won't be able to
# load our icons and images.
TDEGlobal.iconLoader().addAppDir("kcontrol_module")
if standalone:
toplayout = QVBoxLayout( self.plainPage(), 0, KDialog.spacingHint() )
mainwidget = KcontrolModuleWidget(self.plainPage())
else:
toplayout = QVBoxLayout( self, 0, KDialog.spacingHint() )
mainwidget = KcontrolModuleWidget(self)
toplayout.addWidget(mainwidget)
self.aboutus = TDEAboutApplication(self)
########################################################################
def __del__(self):
pass
########################################################################
# KDialogBase method
def exec_loop(self):
global programbase
# Load configuration here
self.__loadOptions()
programbase.exec_loop(self)
# Save configuration here
self.__saveOptions()
########################################################################
# KDialogBase method
def slotUser1(self):
self.aboutus.show()
########################################################################
def slotCloseButton(self):
self.close()
########################################################################
def __loadOptions(self):
global kapp
config = kapp.config()
config.setGroup("General")
size = config.readSizeEntry("Geometry")
if size.isEmpty()==False:
self.resize(size)
#######################################################################
def __saveOptions(self):
global kapp
config = kapp.config()
config.setGroup("General")
config.writeEntry("Geometry", self.size())
config.sync()
#######################################################################
# KControl virtual void methods
def load(self):
pass
def save(self):
pass
def defaults(self):
pass
def sysdefaults(self):
pass
def aboutData(self):
# Return the TDEAboutData object which we created during initialisation.
return self.aboutdata
def buttons(self):
# Only supply a Help button. Other choices are Default and Apply.
return TDECModule.Help
############################################################################
# This is the entry point used when running this module outside of kcontrol.
def main():
global kapp
about_data = AboutData()
TDECmdLineArgs.init(sys.argv,about_data)
kapp = TDEApplication()
myapp = KcontrolModuleApp()
myapp.exec_loop()
############################################################################
# Factory function for KControl
def create_kcontrol_module(parent,name):
global kapp
kapp = TDEApplication.kApplication()
return KcontrolModuleApp(parent, name)
############################################################################
if standalone:
main()
|