ScolaSync  1.0
preferences.py
Aller à la documentation de ce fichier.
00001 #!/usr/bin/python
00002 # -*- coding: utf-8 -*-
00003 #       $Id: preferences.py 42 2011-01-15 22:38:04Z georgesk $  
00004 
00005 licence={}
00006 licence['en']="""
00007     file preferences.py
00008     this file is part of the project scolasync
00009     
00010     Copyright (C) 2010 Georges Khaznadar <georgesk@ofset.org>
00011 
00012     This program is free software: you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation, either version3 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00024 """
00025 
00026 from PyQt4.QtCore import *
00027 from PyQt4.QtGui import *
00028 
00029 class preferenceWindow(QDialog):
00030     ##
00031     # 
00032     #         Le constructeur
00033     #         
00034     def __init__(self, parent=None):
00035         QDialog.__init__(self, parent)
00036         from Ui_preferences import Ui_Dialog
00037         self.ui=Ui_Dialog()
00038         self.ui.setupUi(self)
00039         self.connect(self.ui.refreshEnabledBox, SIGNAL("stateChanged(int)"), self.enableDelay)
00040         self.connect(self.ui.refreshDelaySlider, SIGNAL("valueChanged(int)"), self.updateRefreshLabel)
00041 
00042     ##
00043     # 
00044     #         active ou désactive le glisseur pour modifier le délai de rafraichissement
00045     #         @param state l'état coché ou décoché de la boîte qui contrôle le rafraichissement
00046     #         
00047     def enableDelay(self, state):
00048         self.ui.refreshDelaySlider.setEnabled(bool(state))
00049 
00050     ##
00051     # 
00052     #         Met à jour l'affichage de la valeur du délai de rafraichissement
00053     #         @param val un nombre entier qui exprime le délai en secondes
00054     #         
00055     def updateRefreshLabel(self, val):
00056         labelTxt=QApplication.translate("Dialog", "%1 secondes", None, QApplication.UnicodeUTF8)
00057         val="%2d" %val
00058         labelTxt=labelTxt.arg(val)
00059         self.ui.refreshDelayLabel.setText(labelTxt)
00060 
00061     ##
00062     # 
00063     #         @return un dictionnaire de préférences
00064     #         
00065     def values(self):
00066         prefs={}
00067         prefs["checkable"]      = bool(self.ui.checkCheck.isChecked())
00068         prefs["mv"]             = bool(self.ui.mvCheck.isChecked())
00069         prefs["schoolFile"]     = "%s" %self.ui.lineEditSchoolFile.text().toUtf8()
00070         prefs["workdir"]        = "%s" %self.ui.dirEdit.text().toUtf8()
00071         prefs["manfile"]        = "%s" %self.ui.manFileEdit.text().toUtf8()
00072         prefs["refreshEnabled"] = bool(self.ui.refreshEnabledBox.isChecked())
00073         prefs["refreshDelay"]   = self.ui.refreshDelaySlider.value()
00074         return prefs
00075 
00076     ##
00077     # 
00078     #         Met en place les préférences dans le dialogue
00079     #         @param prefs un dictionnaire de préférences
00080     #         
00081     def setValues(self, prefs):
00082         if prefs["checkable"]:
00083             state=Qt.Checked
00084         else:
00085             state=Qt.Unchecked
00086         self.ui.checkCheck.setCheckState(state)
00087         if prefs["mv"]:
00088             state=Qt.Checked
00089         else:
00090             state=Qt.Unchecked
00091         self.ui.mvCheck.setCheckState(state)
00092         if prefs["refreshEnabled"]:
00093             state=Qt.Checked
00094         else:
00095             state=Qt.Unchecked
00096         self.ui.refreshEnabledBox.setCheckState(state)
00097         self.ui.refreshDelaySlider.setEnabled(prefs["refreshEnabled"])
00098         self.ui.lineEditSchoolFile.setText(prefs["schoolFile"])
00099         self.ui.dirEdit.setText(prefs["workdir"])
00100         self.ui.manFileEdit.setText(prefs["manfile"])
00101         self.ui.refreshDelaySlider.setValue(prefs["refreshDelay"])
00102 
 Tout Classes Espaces de nommage Fichiers Fonctions Variables