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,13 +430,17 @@ 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
horHeaders = [] try:
for n, key in enumerate(sorted(data.keys())): horHeaders = []
#print(data.keys()) for n, key in enumerate(sorted(data.keys())):
horHeaders.append(key) #print(data.keys())
for m, item in enumerate(data[key]): horHeaders.append(key)
newitem = QtWidgets.QTableWidgetItem(item) for m, item in enumerate(data[key]):
details.ui.tableWidget.setItem(m, n, newitem) newitem = QtWidgets.QTableWidgetItem(item)
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)