1 # Copyright (c) 2005 Fredrik Kuivinen <freku045@student.liu.se>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License version 2 as
5 # published by the Free Software Foundation.
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License
13 # along with this program; if not, write to the Free Software
14 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 qconnect
= qt
.QObject
.connect
21 class Settings(qt
.QDialog
):
23 qt
.QDialog
.__init
__(self
)
25 self
.setCaption('Preferences')
26 self
.layout
= qt
.QVBox(self
)
31 self
.quitL
= qt
.QHBox(l
)
32 self
.quitBox
= qt
.QCheckBox(self
.quitL
)
33 self
.quitLabel
= qt
.QLabel('Exit on no changed files', self
.quitL
)
34 self
.quitLabel
.setBuddy(self
.quitBox
)
36 self
.signoffL
= qt
.QHBox(l
)
37 self
.signoffLabel
= qt
.QLabel('Commit signoff', self
.signoffL
)
38 self
.signoffBox
= qt
.QTextEdit(self
.signoffL
)
39 self
.signoffLabel
.setBuddy(self
.signoffBox
)
41 self
.buttonL
= qt
.QHBox(l
)
42 self
.ok
= qt
.QPushButton("&Ok", self
.buttonL
)
43 self
.cancel
= qt
.QPushButton("&Cancel", self
.buttonL
)
44 qconnect(self
.ok
, qt
.SIGNAL("clicked()"), self
.accept
)
45 qconnect(self
.cancel
, qt
.SIGNAL("clicked()"), self
.reject
)
47 self
.resize(l
.sizeHint())
48 l
.resize(l
.sizeHint())
49 self
.qset
= qt
.QSettings()
52 def loadSettings(self
):
53 self
.qset
.setPath(shortName
, shortName
)
54 self
.quitOnNoChanges
= str(self
.qset
.readEntry('/foo/quitOnNoChanges', 'False')[0]) == 'True'
55 self
.splitter
= eval(str(self
.qset
.readEntry('/geometry/splitter', '[400, 200]')[0]))
56 self
.width
= self
.qset
.readNumEntry('/geometry/width', 500)[0]
57 self
.height
= self
.qset
.readNumEntry('/geometry/height', 600)[0]
58 self
.signoff
= str(self
.qset
.readEntry('/foo/signoff', '')[0])
60 self
.quitBox
.setChecked(self
.quitOnNoChanges
)
61 self
.signoffBox
.setText(self
.signoff
)
63 def writeSettings(self
):
64 self
.qset
.setPath(shortName
, shortName
)
65 self
.qset
.writeEntry('/foo/quitOnNoChanges', str(self
.quitOnNoChanges
))
66 self
.qset
.writeEntry('/geometry/splitter', repr(self
.splitter
))
67 self
.qset
.writeEntry('/geometry/width', self
.width
)
68 self
.qset
.writeEntry('/geometry/height', self
.height
)
69 self
.qset
.writeEntry('/foo/signoff', str(self
.signoff
))
71 # Flush the written entries to disk
73 self
.qset
= qt
.QSettings()
75 def paintEvent(self
, e
):
76 qt
.QDialog
.paintEvent(self
, e
)
78 def showSettings(self
):
79 if self
.exec_loop() == qt
.QDialog
.Accepted
:
80 self
.quitOnNoChanges
= self
.quitBox
.isChecked()
81 self
.signoff
= self
.signoffBox
.text()
83 self
.quitBox
.setChecked(self
.quitOnNoChanges
)