fixed several bugs

This commit is contained in:
Rinaldus 2016-02-08 18:30:13 +03:00
parent 97f9e5ed5e
commit 4df494adae
3 changed files with 23 additions and 15 deletions

View File

@ -70,7 +70,7 @@ class Window(QDialog):
self.ui.btnTestConnection.clicked.connect(self.btnTestConnection_clicked) self.ui.btnTestConnection.clicked.connect(self.btnTestConnection_clicked)
self.ui.comboAccounts.currentTextChanged.connect(self.comboAccounts_changed) self.ui.comboAccounts.currentTextChanged.connect(self.comboAccounts_changed)
self.ui.btnAddAccount.clicked.connect(self.btnAddAccount_clicked) self.ui.btnAddAccount.clicked.connect(self.btnAddAccount_clicked)
self.ui.btnModifyAccount.clicked.connect(self.btnModifyAccount_clicked) self.ui.btnRenameAccount.clicked.connect(self.btnRenameAccount_clicked)
self.ui.btnRemoveAccount.clicked.connect(self.btnRemoveAccount_clicked) self.ui.btnRemoveAccount.clicked.connect(self.btnRemoveAccount_clicked)
# Main timer # Main timer
@ -114,10 +114,10 @@ class Window(QDialog):
self.ui.checkFreq.setValue(int(settings.value("CheckInterval"))) self.ui.checkFreq.setValue(int(settings.value("CheckInterval")))
self.ui.boolifNotify.setChecked(bool(settings.value("Notify"))) self.ui.boolifNotify.setChecked(bool(settings.value("Notify")))
def SettingsSave(self): def SettingsSave(self,account):
settings.setValue("CheckInterval",self.ui.checkFreq.value()) settings.setValue("CheckInterval",self.ui.checkFreq.value())
settings.setValue("Notify", self.ui.boolifNotify.isChecked()) settings.setValue("Notify", self.ui.boolifNotify.isChecked())
settings.beginGroup(self.ui.comboAccounts.currentText()) settings.beginGroup(account)
settings.setValue("MailServer",self.ui.txtboxMailServer.text()) settings.setValue("MailServer",self.ui.txtboxMailServer.text())
settings.setValue("Port",self.ui.txtboxPort.text()) settings.setValue("Port",self.ui.txtboxPort.text())
settings.setValue("Login",self.ui.txtboxLogin.text()) settings.setValue("Login",self.ui.txtboxLogin.text())
@ -131,7 +131,7 @@ class Window(QDialog):
settings.endGroup() settings.endGroup()
def btnOK_clicked(self): def btnOK_clicked(self):
self.SettingsSave() self.SettingsSave(self.ui.comboAccounts.currentText())
if (settings.value("MailServer") == "" or settings.value("Port") == "" or settings.value("Login") == "" or settings.value("Password") == ""): if (settings.value("MailServer") == "" or settings.value("Port") == "" or settings.value("Login") == "" or settings.value("Password") == ""):
QMessageBox.critical(self, "Warning","You should fill all fields in IMAP settings!") QMessageBox.critical(self, "Warning","You should fill all fields in IMAP settings!")
@ -164,11 +164,12 @@ class Window(QDialog):
self.ui.comboAccounts.addItem(GroupName[0]) self.ui.comboAccounts.addItem(GroupName[0])
self.ui.comboAccounts.setCurrentText(GroupName[0]) self.ui.comboAccounts.setCurrentText(GroupName[0])
def btnModifyAccount_clicked(self): def btnRenameAccount_clicked(self):
Index = self.ui.comboAccounts.currentIndex() Index = self.ui.comboAccounts.currentIndex()
OldGroupName = self.ui.comboAccounts.currentText() OldGroupName = self.ui.comboAccounts.currentText()
GroupName = QInputDialog.getText(self,"Enter account name","Enter account name",QLineEdit.Normal,self.ui.comboAccounts.currentText()) GroupName = QInputDialog.getText(self,"Enter account name","Enter account name",QLineEdit.Normal,self.ui.comboAccounts.currentText())
if (GroupName[0]): if (GroupName[0]):
self.SettingsSave(GroupName[0])
self.ui.comboAccounts.setItemText(Index, GroupName[0]) self.ui.comboAccounts.setItemText(Index, GroupName[0])
self.ui.comboAccounts.setCurrentText(GroupName[0]) self.ui.comboAccounts.setCurrentText(GroupName[0])
self.SettingsRemove(OldGroupName) self.SettingsRemove(OldGroupName)
@ -232,10 +233,10 @@ class Mail():
return "ERROR" return "ERROR"
def mail_check(): def mail_check():
mail_count = 0
if (GlobalSettingsExist() and AccountExist()): if (GlobalSettingsExist() and AccountExist()):
m = Mail() m = Mail()
groups = settings.childGroups() groups = settings.childGroups()
mail_count = 0
for i in range (len(groups)): for i in range (len(groups)):
settings.beginGroup(groups[i]) settings.beginGroup(groups[i])
group = groups[i] group = groups[i]
@ -246,7 +247,10 @@ def mail_check():
ssl = settings.value("SSL") ssl = settings.value("SSL")
settings.endGroup() settings.endGroup()
if m.login(mailserver,port,user,password,ssl): if m.login(mailserver,port,user,password,ssl):
mail_count += m.checkMail() # mail_count + "ERROR" = ????? if (mail_count == "ERROR" or m.checkMail() == "ERROR"):
mail_count = "ERROR"
else:
mail_count += m.checkMail()
else: else:
window.trayIcon.setToolTip("Unable to establish connection to mailbox. Check your mail settings and make sure that you have not network problems.") window.trayIcon.setToolTip("Unable to establish connection to mailbox. Check your mail settings and make sure that you have not network problems.")
notify("Unable to establish connection to mailbox. Check your mail settings and make sure that you have not network problems.") notify("Unable to establish connection to mailbox. Check your mail settings and make sure that you have not network problems.")
@ -292,3 +296,7 @@ if __name__ == '__main__':
mail_check() mail_check()
window.start() window.start()
sys.exit(app.exec_()) sys.exit(app.exec_())
# TODO:
# Separate mail count for each account
# New save account button
# Account removal warning dialog

View File

@ -340,7 +340,7 @@
</iconset> </iconset>
</property> </property>
</widget> </widget>
<widget class="QPushButton" name="btnModifyAccount"> <widget class="QPushButton" name="btnRenameAccount">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>220</x> <x>220</x>
@ -350,7 +350,7 @@
</rect> </rect>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Modify account</string> <string>Rename account</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>

View File

@ -123,13 +123,13 @@ class Ui_Settings(object):
icon1.addPixmap(QtGui.QPixmap(":/icons/add_account.png"), QtGui.QIcon.Normal, QtGui.QIcon.On) icon1.addPixmap(QtGui.QPixmap(":/icons/add_account.png"), QtGui.QIcon.Normal, QtGui.QIcon.On)
self.btnAddAccount.setIcon(icon1) self.btnAddAccount.setIcon(icon1)
self.btnAddAccount.setObjectName("btnAddAccount") self.btnAddAccount.setObjectName("btnAddAccount")
self.btnModifyAccount = QtWidgets.QPushButton(Settings) self.btnRenameAccount = QtWidgets.QPushButton(Settings)
self.btnModifyAccount.setGeometry(QtCore.QRect(220, 80, 31, 23)) self.btnRenameAccount.setGeometry(QtCore.QRect(220, 80, 31, 23))
self.btnModifyAccount.setText("") self.btnRenameAccount.setText("")
icon2 = QtGui.QIcon() icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(":/icons/modify_account.png"), QtGui.QIcon.Normal, QtGui.QIcon.On) icon2.addPixmap(QtGui.QPixmap(":/icons/modify_account.png"), QtGui.QIcon.Normal, QtGui.QIcon.On)
self.btnModifyAccount.setIcon(icon2) self.btnRenameAccount.setIcon(icon2)
self.btnModifyAccount.setObjectName("btnModifyAccount") self.btnRenameAccount.setObjectName("btnRenameAccount")
self.btnRemoveAccount = QtWidgets.QPushButton(Settings) self.btnRemoveAccount = QtWidgets.QPushButton(Settings)
self.btnRemoveAccount.setGeometry(QtCore.QRect(260, 80, 31, 23)) self.btnRemoveAccount.setGeometry(QtCore.QRect(260, 80, 31, 23))
self.btnRemoveAccount.setText("") self.btnRemoveAccount.setText("")
@ -160,7 +160,7 @@ class Ui_Settings(object):
self.label.setText(_translate("Settings", "Check for unread mail every")) self.label.setText(_translate("Settings", "Check for unread mail every"))
self.label_2.setText(_translate("Settings", "minutes")) self.label_2.setText(_translate("Settings", "minutes"))
self.btnAddAccount.setToolTip(_translate("Settings", "Add account")) self.btnAddAccount.setToolTip(_translate("Settings", "Add account"))
self.btnModifyAccount.setToolTip(_translate("Settings", "Modify account")) self.btnRenameAccount.setToolTip(_translate("Settings", "Rename account"))
self.btnRemoveAccount.setToolTip(_translate("Settings", "Remove account")) self.btnRemoveAccount.setToolTip(_translate("Settings", "Remove account"))
import resources_rc import resources_rc