The program didn't work when account didn't exist.

Also fixed crash when the program tried to load incorrect mail headers
This commit is contained in:
Rinaldus 2017-11-19 18:35:54 +03:00
parent b04cb9a6ff
commit 7822c3690b
Signed by: Rinaldus
GPG Key ID: CB02A5190B0EC070
1 changed files with 21 additions and 7 deletions

View File

@ -87,6 +87,12 @@ class Window(QDialog):
self.ui.btnSaveAccount.clicked.connect(self.btnSaveAccount_clicked) self.ui.btnSaveAccount.clicked.connect(self.btnSaveAccount_clicked)
self.ui.btnRemoveAccount.clicked.connect(self.btnRemoveAccount_clicked) self.ui.btnRemoveAccount.clicked.connect(self.btnRemoveAccount_clicked)
# Check if account doesn't exist, it creates default one
if (AccountExist() == False):
self.ui.comboAccounts.addItem("Default")
self.ui.comboAccounts.setCurrentText("Default")
# Main timer # Main timer
self.timer = QTimer(self) self.timer = QTimer(self)
self.timer.timeout.connect(mail_check) self.timer.timeout.connect(mail_check)
@ -208,6 +214,10 @@ class Window(QDialog):
GroupName = self.ui.comboAccounts.currentText() GroupName = self.ui.comboAccounts.currentText()
self.ui.comboAccounts.removeItem(Index) self.ui.comboAccounts.removeItem(Index)
self.SettingsRemove(GroupName) self.SettingsRemove(GroupName)
# Check if account doesn't exist, it creates default one
if (AccountExist() == False):
self.ui.comboAccounts.addItem("Default")
self.ui.comboAccounts.setCurrentText("Default")
def comboAccounts_changed(self): def comboAccounts_changed(self):
self.ui.lblTestOutput.setText("") self.ui.lblTestOutput.setText("")
@ -420,6 +430,7 @@ def mail_check():
details.ui.tableWidget.setRowCount(len(AllFroms)) details.ui.tableWidget.setRowCount(len(AllFroms))
details.ui.tableWidget.setColumnCount(3) details.ui.tableWidget.setColumnCount(3)
#Enter data onto Table #Enter data onto Table
try:
horHeaders = [] horHeaders = []
for n, key in enumerate(sorted(data.keys())): for n, key in enumerate(sorted(data.keys())):
#print(data.keys()) #print(data.keys())
@ -427,6 +438,9 @@ def mail_check():
for m, item in enumerate(data[key]): for m, item in enumerate(data[key]):
newitem = QtWidgets.QTableWidgetItem(item) newitem = QtWidgets.QTableWidgetItem(item)
details.ui.tableWidget.setItem(m, n, newitem) details.ui.tableWidget.setItem(m, n, newitem)
except:
print("Unable to load some data")
pass
#Add Header #Add Header
details.ui.tableWidget.setHorizontalHeaderLabels(horHeaders) details.ui.tableWidget.setHorizontalHeaderLabels(horHeaders)