class AppletSettings(QWidget): def __init__(self, obj=None, parent=None): QWidget.__init__(self, parent) self.prnt = parent self.Settings = obj.Settings colorNames = QColor().colorNames() timeOut = self.Settings.value("TimeOut", 300).toInt()[0] autoClose = self.Settings.value("AutoClose", 3).toInt()[0] popup = self.Settings.value("PopUp", 1).toInt()[0] iconText = self.Settings.value("IconText", 1).toInt()[0] popupColor = self.Settings.value("PopUpColor", "red").toString() iconTextColor = self.Settings.value("IconTextColor", "blue").toString() self.layout = QGridLayout() self.timeOutLabel = QLabel("Timeout checking (sec.):") self.layout.addWidget(self.timeOutLabel, 0, 0) self.timeOutBox = KIntSpinBox(10, 7200, 1, timeOut, self) self.timeOutBox.setMaximumWidth(75) self.layout.addWidget(self.timeOutBox, 0, 5) self.autoCloseLabel = QLabel("Advice auto close (sec.):") self.layout.addWidget(self.autoCloseLabel, 1, 0) self.autoCloseBox = KIntSpinBox(1, 7200, 1, autoClose, self) self.autoCloseBox.setMaximumWidth(75) self.layout.addWidget(self.autoCloseBox, 1, 5) self.popupLabel = QLabel("Show pop-up advice:") self.layout.addWidget(self.popupLabel, 2, 0) self.popupBox = QCheckBox() if popup == 0: self.popupBox.setCheckState(Qt.Unchecked) else: self.popupBox.setCheckState(Qt.Checked) self.popupBox.setMaximumWidth(75) self.layout.addWidget(self.popupBox, 2, 5) self.popupColorLabel = QLabel("Pop-up color:") self.layout.addWidget(self.popupColorLabel, 3, 0) self.popupColorBox = QComboBox() self.popupColorBox.setMaximumWidth(150) self.popupColorBox.addItems(colorNames) self.popupColorBox.setCurrentIndex(self.popupColorBox.findText(popupColor)) self.layout.addWidget(self.popupColorBox, 3, 5) self.iconTextLabel = QLabel("Show advice in Icon:") self.layout.addWidget(self.iconTextLabel, 4, 0) self.iconTextBox = QCheckBox() if iconText == 0: self.iconTextBox.setCheckState(Qt.Unchecked) else: self.iconTextBox.setCheckState(Qt.Checked) self.iconTextBox.setMaximumWidth(75) self.layout.addWidget(self.iconTextBox, 4, 5) self.iconTextColorLabel = QLabel("IconText color:") self.layout.addWidget(self.iconTextColorLabel, 5, 0) self.iconTextColorBox = QComboBox() self.iconTextColorBox.setMaximumWidth(150) self.iconTextColorBox.addItems(colorNames) self.iconTextColorBox.setCurrentIndex(self.iconTextColorBox.findText(iconTextColor)) self.layout.addWidget(self.iconTextColorBox, 5, 5) self.setLayout(self.layout) def refreshSettings(self, parent=None): self.Settings.setValue("TimeOut", str(self.timeOutBox.value())) self.Settings.setValue("AutoClose", str(self.autoCloseBox.value())) self.Settings.setValue("PopUp", self.popupBox.checkState() / 2) self.Settings.setValue("IconText", self.iconTextBox.checkState() / 2) self.Settings.setValue("PopUpColor", self.popupColorBox.currentText()) self.Settings.setValue("IconTextColor", self.iconTextColorBox.currentText()) self.Settings.sync() def eventClose(self, event): self.prnt.done(0)
class AppletSettings(QWidget): def __init__(self, obj = None, parent= None): QWidget.__init__(self, parent) self.Parent = obj self.prnt = parent self.tr = Translator('AppletSettings') self.Settings = self.Parent.Settings self.checkAccess = self.Parent.checkAccess timeOut = self.initValue('TimeOut', '600') AutoRun = self.initValue('AutoRun', '0') countProbe = self.initValue('CountProbe', '3') showError = self.initValue('ShowError', '1') waitThread = self.initValue('WaitThread', '120') stayDebLog = self.initValue('stayDebLog', '5') showVersion = self.initValue('ShowVersion', '1') timeOutGroup = self.initValue('TimeOutGroup', '3') maxShowedMail = self.initValue('MaxShowedMail', '1024') mailsInGroup = self.initValue('MailsInGroup', '5') self.layout = QGridLayout() self.timeOutLabel = QLabel(self.tr._translate("Timeout checking (sec.):")) self.layout.addWidget(self.timeOutLabel,0,0) self.timeOutBox = KIntSpinBox(10, 7200, 1, int(timeOut), self) self.timeOutBox.setMaximumWidth(75) self.layout.addWidget(self.timeOutBox, 0, 5) self.autoRunLabel = QLabel(self.tr._translate("Autorun mail checking :")) self.layout.addWidget(self.autoRunLabel,1,0) self.AutoRunBox = QCheckBox() if int(AutoRun) > 0 : self.AutoRunBox.setCheckState(Qt.Checked) self.layout.addWidget(self.AutoRunBox,1,5) self.countProbe = QLabel(self.tr._translate("Count of connect probe\nto mail server:")) self.layout.addWidget(self.countProbe,2,0) self.countProbeBox = KIntSpinBox(1, 10, 1, int(countProbe), self) self.layout.addWidget(self.countProbeBox, 2, 5) self.showError = QLabel(self.tr._translate("Show error messages :")) self.layout.addWidget(self.showError,3,0) self.showErrorBox = QCheckBox() if int(showError) > 0 : self.showErrorBox.setCheckState(Qt.Checked) self.layout.addWidget(self.showErrorBox,3,5) self.waitThreadLabel = QLabel(self.tr._translate("Autoexit of connect (sec.):")) self.layout.addWidget(self.waitThreadLabel,4,0) self.waitThreadBox = KIntSpinBox(3, 7200, 1, int(waitThread), self) self.layout.addWidget(self.waitThreadBox, 4, 5) self.stayDebLogLabel = QLabel(self.tr._translate("Stay Debug output Log :")) self.layout.addWidget(self.stayDebLogLabel,5,0) self.stayDebLogBox = KIntSpinBox(1, 50, 1, int(stayDebLog), self) self.stayDebLogBox.setMaximumWidth(75) self.layout.addWidget(self.stayDebLogBox, 5, 5) self.showVersion = QLabel(self.tr._translate("Show Version :")) self.layout.addWidget(self.showVersion,6,0) self.showVersionBox = QCheckBox() if int(showVersion) > 0 : self.showVersionBox.setCheckState(Qt.Checked) self.layout.addWidget(self.showVersionBox,6,5) self.timeOutGroupLabel = QLabel(self.tr._translate("Group Akonadi events timeout (sec.):")) self.timeOutGroupLabel.setEnabled(AkonadiModuleExist) self.layout.addWidget(self.timeOutGroupLabel, 7, 0) self.timeOutGroupBox = KIntSpinBox(1, 200, 1, int(timeOutGroup), self) self.timeOutGroupBox.setMaximumWidth(75) self.timeOutGroupBox.setEnabled(AkonadiModuleExist) self.layout.addWidget(self.timeOutGroupBox, 7, 5) self.maxMailLabel = QLabel(self.tr._translate("Max Count of Showed Mail :")) self.layout.addWidget(self.maxMailLabel, 8, 0) self.maxMailBox = KIntSpinBox(1, 1024, 1, int(maxShowedMail), self) self.maxMailBox.setMaximumWidth(75) self.maxMailBox.valueChanged[int].connect(self.showMailGroupping) self.layout.addWidget(self.maxMailBox, 8, 5) self.mailInGroupLabel = QLabel('\t' + self.tr._translate("Count of Mail in Group for account:")) self.mailInGroupLabel.setEnabled(False) self.layout.addWidget(self.mailInGroupLabel, 9, 0) self.mailInGroupBox = KIntSpinBox(1, 10, 1, int(mailsInGroup), self) self.mailInGroupBox.setMaximumWidth(75) self.mailInGroupBox.setEnabled(False) self.layout.addWidget(self.mailInGroupBox, 9, 5) self.setLayout(self.layout) self.maxMailBox.valueChanged.emit(int(maxShowedMail)) def initValue(self, key_, default = '0'): if self.Settings.contains(key_) : #print dateStamp() , key_, self.Settings.value(key_).toString() return self.Settings.value(key_).toString() else : self.Settings.setValue(key_, QVariant(default)) #print dateStamp() , key_, self.Settings.value(key_).toString() return default def stateChanged(self, state): self.mailInGroupLabel.setEnabled(state) self.mailInGroupBox.setEnabled(state) def showMailGroupping(self, i): if i > self.mailInGroupBox.value() : self.stateChanged(True) else : self.stateChanged(False) def refreshSettings(self): if not self.checkAccess() : return None self.Settings.setValue('TimeOut', str(self.timeOutBox.value())) self.Settings.setValue('CountProbe', str(self.countProbeBox.value())) self.Settings.setValue('WaitThread', str(self.waitThreadBox.value())) self.Settings.setValue('stayDebLog', str(self.stayDebLogBox.value())) self.Settings.setValue('TimeOutGroup', str(self.timeOutGroupBox.value())) self.Settings.setValue('MaxShowedMail', str(self.maxMailBox.value())) self.Settings.setValue('MailsInGroup', str(self.mailInGroupBox.value())) if self.AutoRunBox.isChecked() : self.Settings.setValue('AutoRun', '1') else: self.Settings.setValue('AutoRun', '0') if self.showErrorBox.isChecked() : self.Settings.setValue('ShowError', '1') else: self.Settings.setValue('ShowError', '0') if self.showVersionBox.isChecked() : self.Settings.setValue('ShowVersion', '1') else: self.Settings.setValue('ShowVersion', '0') self.Settings.sync() def eventClose(self, event): self.prnt.done(0)