filling table function was moved to main check_mail() function
Final preparations for version 3.0
This commit is contained in:
parent
ee2d66c8c8
commit
5d9fa72bd0
|
@ -21,7 +21,7 @@ import time
|
||||||
|
|
||||||
#variables
|
#variables
|
||||||
programTitle = "Mail Notifier"
|
programTitle = "Mail Notifier"
|
||||||
programVersion = "2.0"
|
programVersion = "3.0"
|
||||||
settings = QSettings(os.path.expanduser("~")+"/.config/mail-notifier/settings.conf", QSettings.NativeFormat)
|
settings = QSettings(os.path.expanduser("~")+"/.config/mail-notifier/settings.conf", QSettings.NativeFormat)
|
||||||
def GlobalSettingsExist():
|
def GlobalSettingsExist():
|
||||||
if ((settings.contains("CheckInterval") and settings.value("CheckInterval") != "") and
|
if ((settings.contains("CheckInterval") and settings.value("CheckInterval") != "") and
|
||||||
|
@ -103,8 +103,8 @@ class Window(QDialog):
|
||||||
# UI functions
|
# UI functions
|
||||||
def createTrayIcon(self):
|
def createTrayIcon(self):
|
||||||
self.trayIconMenu = QMenu(self)
|
self.trayIconMenu = QMenu(self)
|
||||||
self.trayIconMenu.addAction(self.detailsShow)
|
|
||||||
self.trayIconMenu.addAction(self.aboutShow)
|
self.trayIconMenu.addAction(self.aboutShow)
|
||||||
|
self.trayIconMenu.addAction(self.detailsShow)
|
||||||
self.trayIconMenu.addAction(self.checkNow)
|
self.trayIconMenu.addAction(self.checkNow)
|
||||||
self.trayIconMenu.addAction(self.restoreAction)
|
self.trayIconMenu.addAction(self.restoreAction)
|
||||||
self.trayIconMenu.addAction(self.quitAction)
|
self.trayIconMenu.addAction(self.quitAction)
|
||||||
|
@ -273,55 +273,7 @@ class Details(QDialog):
|
||||||
self.hide()
|
self.hide()
|
||||||
|
|
||||||
def Refresh_clicked(self):
|
def Refresh_clicked(self):
|
||||||
mail_count = 0
|
mail_check()
|
||||||
AllFroms=[]
|
|
||||||
AllSubjs=[]
|
|
||||||
AllDates=[]
|
|
||||||
if (GlobalSettingsExist() and AccountExist()):
|
|
||||||
m = Mail()
|
|
||||||
groups = settings.childGroups()
|
|
||||||
for i in range (len(groups)):
|
|
||||||
settings.beginGroup(groups[i])
|
|
||||||
group = groups[i]
|
|
||||||
user = settings.value("Login")
|
|
||||||
password = settings.value("Password")
|
|
||||||
mailserver = settings.value("MailServer")
|
|
||||||
port = settings.value("Port")
|
|
||||||
ssl = settings.value("SSL")
|
|
||||||
settings.endGroup()
|
|
||||||
if m.login(mailserver,port,user,password,ssl):
|
|
||||||
if (mail_count == "ERROR" or m.checkMail() == "ERROR"):
|
|
||||||
mail_count = "ERROR"
|
|
||||||
else:
|
|
||||||
mail_count += m.checkMail()
|
|
||||||
AllFroms.extend(m.parseMail("From"))
|
|
||||||
AllSubjs.extend(m.parseMail("Subject"))
|
|
||||||
AllDates.extend(m.parseMail("Date"))
|
|
||||||
else:
|
|
||||||
mail_count = "CONNECTION_ERROR"
|
|
||||||
else:
|
|
||||||
mail_count = "CONFIGURATION_ERROR"
|
|
||||||
|
|
||||||
data = {"From":AllFroms,
|
|
||||||
"Subject":AllSubjs,
|
|
||||||
"Date":AllDates,}
|
|
||||||
self.ui.tableWidget.setRowCount(len(AllFroms))
|
|
||||||
self.ui.tableWidget.setColumnCount(3)
|
|
||||||
#Enter data onto Table
|
|
||||||
horHeaders = []
|
|
||||||
for n, key in enumerate(sorted(data.keys())):
|
|
||||||
#print(data.keys())
|
|
||||||
horHeaders.append(key)
|
|
||||||
for m, item in enumerate(data[key]):
|
|
||||||
newitem = QtWidgets.QTableWidgetItem(item)
|
|
||||||
self.ui.tableWidget.setItem(m, n, newitem)
|
|
||||||
|
|
||||||
#Add Header
|
|
||||||
self.ui.tableWidget.setHorizontalHeaderLabels(horHeaders)
|
|
||||||
|
|
||||||
#Adjust size of Table
|
|
||||||
self.ui.tableWidget.resizeColumnsToContents()
|
|
||||||
self.ui.tableWidget.resizeRowsToContents()
|
|
||||||
|
|
||||||
# Common functions
|
# Common functions
|
||||||
|
|
||||||
|
@ -372,6 +324,9 @@ class Mail():
|
||||||
|
|
||||||
def mail_check():
|
def mail_check():
|
||||||
mail_count = 0
|
mail_count = 0
|
||||||
|
AllFroms=[]
|
||||||
|
AllSubjs=[]
|
||||||
|
AllDates=[]
|
||||||
if (GlobalSettingsExist() and AccountExist()):
|
if (GlobalSettingsExist() and AccountExist()):
|
||||||
m = Mail()
|
m = Mail()
|
||||||
groups = settings.childGroups()
|
groups = settings.childGroups()
|
||||||
|
@ -389,6 +344,9 @@ def mail_check():
|
||||||
mail_count = "ERROR"
|
mail_count = "ERROR"
|
||||||
else:
|
else:
|
||||||
mail_count += m.checkMail()
|
mail_count += m.checkMail()
|
||||||
|
AllFroms.extend(m.parseMail("From"))
|
||||||
|
AllSubjs.extend(m.parseMail("Subject"))
|
||||||
|
AllDates.extend(m.parseMail("Date"))
|
||||||
else:
|
else:
|
||||||
mail_count = "CONNECTION_ERROR"
|
mail_count = "CONNECTION_ERROR"
|
||||||
else:
|
else:
|
||||||
|
@ -433,6 +391,28 @@ def mail_check():
|
||||||
# Popup notification appears only if mail count changed since last check
|
# Popup notification appears only if mail count changed since last check
|
||||||
if (mail_count != window.lastCheckCount):
|
if (mail_count != window.lastCheckCount):
|
||||||
notify ("You have "+ str(mail_count) +" unread letters")
|
notify ("You have "+ str(mail_count) +" unread letters")
|
||||||
|
|
||||||
|
# Filling table
|
||||||
|
data = {"From":AllFroms,
|
||||||
|
"Subject":AllSubjs,
|
||||||
|
"Date":AllDates,}
|
||||||
|
details.ui.tableWidget.setRowCount(len(AllFroms))
|
||||||
|
details.ui.tableWidget.setColumnCount(3)
|
||||||
|
#Enter data onto Table
|
||||||
|
horHeaders = []
|
||||||
|
for n, key in enumerate(sorted(data.keys())):
|
||||||
|
#print(data.keys())
|
||||||
|
horHeaders.append(key)
|
||||||
|
for m, item in enumerate(data[key]):
|
||||||
|
newitem = QtWidgets.QTableWidgetItem(item)
|
||||||
|
details.ui.tableWidget.setItem(m, n, newitem)
|
||||||
|
|
||||||
|
#Add Header
|
||||||
|
details.ui.tableWidget.setHorizontalHeaderLabels(horHeaders)
|
||||||
|
|
||||||
|
#Adjust size of Table
|
||||||
|
details.ui.tableWidget.resizeColumnsToContents()
|
||||||
|
details.ui.tableWidget.resizeRowsToContents()
|
||||||
# check was successfull, lastCheckCount is updating
|
# check was successfull, lastCheckCount is updating
|
||||||
window.lastCheckCount = mail_count
|
window.lastCheckCount = mail_count
|
||||||
def notify(message):
|
def notify(message):
|
||||||
|
|
Loading…
Reference in New Issue