Compare commits
12 Commits
Author | SHA1 | Date |
---|---|---|
Rinaldus | 7822c3690b | |
Rinaldus | b04cb9a6ff | |
Rinaldus | 66020b44a5 | |
Rinaldus | 8fbcb94182 | |
Rinaldus | c025371c1b | |
Rinaldus | 6ccb04632b | |
Rinaldus | a49944eab6 | |
Rinaldus | d7378800d0 | |
Rinaldus | 6b73eb58bc | |
Rinaldus | f4b5be7933 | |
Rinaldus | 5af9d228b3 | |
Rinaldus | 147b7f47dc |
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2015-2016, Peter Svirshchevskiy
|
||||
Copyright (c) 2015-2017, Peter Svirshchevskiy
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -26,6 +26,11 @@ $ chmod +x mail-notifier.py
|
|||
|
||||
## Changelog
|
||||
|
||||
### Version 3.01 (release date: 10.10.17)
|
||||
* Added status bar in Details window
|
||||
* Details window now remembers its size
|
||||
* Some cosmetic improvements in menu
|
||||
|
||||
### Version 3.0 (release date: 26.07.16)
|
||||
* System tray icon displays count of unread mail directly on itself
|
||||
* Popup notification behaviour was changed: now popup notification appears only if the number of unread emails has
|
||||
|
|
|
@ -18,10 +18,11 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
|||
import os
|
||||
import socket
|
||||
import time
|
||||
from datetime import datetime, date, time
|
||||
|
||||
#variables
|
||||
programTitle = "Mail Notifier"
|
||||
programVersion = "3.0"
|
||||
programVersion = "3.01-dev"
|
||||
settings = QSettings(os.path.expanduser("~")+"/.config/mail-notifier/settings.conf", QSettings.NativeFormat)
|
||||
def GlobalSettingsExist():
|
||||
if ((settings.contains("CheckInterval") and settings.value("CheckInterval") != "") and
|
||||
|
@ -86,6 +87,12 @@ class Window(QDialog):
|
|||
self.ui.btnSaveAccount.clicked.connect(self.btnSaveAccount_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
|
||||
self.timer = QTimer(self)
|
||||
self.timer.timeout.connect(mail_check)
|
||||
|
@ -94,19 +101,23 @@ class Window(QDialog):
|
|||
|
||||
# Menu actions
|
||||
def createActions(self):
|
||||
self.detailsShow = QAction(QIcon(':icons/details.png'),"&Details", self, triggered=self.detailsShow)
|
||||
self.aboutShow = QAction(QIcon(':icons/mailbox_empty.png'),"&About", self, triggered=self.aboutShow)
|
||||
self.detailsShow = QAction(QIcon(':icons/details.png'),"&Details...", self, triggered=self.detailsShow)
|
||||
self.aboutShow = QAction(QIcon(':icons/mailbox_empty.png'),"&About " + programTitle + "...", self, triggered=self.aboutShow)
|
||||
self.checkNow = QAction(QIcon(':icons/check_now.png'),"&Check now", self, triggered=mail_check)
|
||||
self.restoreAction = QAction(QIcon(":icons/settings.png"),"&Settings", self, triggered=self.showNormal)
|
||||
self.restoreAction = QAction(QIcon(":icons/settings.png"),"&Settings...", self, triggered=self.showNormal)
|
||||
self.quitAction = QAction(QIcon(':icons/menu_quit.png'),"&Quit", self, triggered=QApplication.instance().quit)
|
||||
|
||||
# UI functions
|
||||
def createTrayIcon(self):
|
||||
self.trayIconMenu = QMenu(self)
|
||||
self.trayIconMenu.addAction(self.aboutShow)
|
||||
f = self.trayIconMenu.font()
|
||||
f.setBold(True)
|
||||
self.detailsShow.setFont(f)
|
||||
self.trayIconMenu.addAction(self.detailsShow)
|
||||
self.trayIconMenu.addSeparator()
|
||||
self.trayIconMenu.addAction(self.checkNow)
|
||||
self.trayIconMenu.addAction(self.restoreAction)
|
||||
self.trayIconMenu.addAction(self.aboutShow)
|
||||
self.trayIconMenu.addAction(self.quitAction)
|
||||
self.trayIcon = QSystemTrayIcon(self)
|
||||
self.trayIcon.setContextMenu(self.trayIconMenu)
|
||||
|
@ -115,6 +126,7 @@ class Window(QDialog):
|
|||
def SettingsRestore(self):
|
||||
if (GlobalSettingsExist() and AccountExist()):
|
||||
groups = settings.childGroups()
|
||||
self.ui.comboAccounts.clear() # Clear account items before fill them again
|
||||
for i in range (len(groups)):
|
||||
self.ui.comboAccounts.addItem(groups[i])
|
||||
self.ui.comboAccounts.setCurrentText(groups[i])
|
||||
|
@ -202,6 +214,10 @@ class Window(QDialog):
|
|||
GroupName = self.ui.comboAccounts.currentText()
|
||||
self.ui.comboAccounts.removeItem(Index)
|
||||
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):
|
||||
self.ui.lblTestOutput.setText("")
|
||||
|
@ -246,7 +262,7 @@ class About(QDialog):
|
|||
self.ui = Ui_about()
|
||||
self.ui.setupUi(self)
|
||||
self.setWindowFlags(QtCore.Qt.Tool)
|
||||
self.setFixedSize(483,334)
|
||||
self.setFixedSize(511,334)
|
||||
|
||||
self.ui.lblNameVersion.setText(programTitle + " " + programVersion)
|
||||
|
||||
|
@ -268,9 +284,15 @@ class Details(QDialog):
|
|||
self.ui.setupUi(self)
|
||||
self.setWindowFlags(QtCore.Qt.Window)
|
||||
self.ui.btnRefresh.clicked.connect(self.Refresh_clicked)
|
||||
if (settings.contains("Details_width") and settings.contains("Details_height")):
|
||||
width = int(settings.value("Details_width"))
|
||||
height = int(settings.value("Details_height"))
|
||||
self.resize(width,height)
|
||||
|
||||
def closeEvent(self, event):
|
||||
event.ignore()
|
||||
settings.setValue("Details_width",self.width())
|
||||
settings.setValue("Details_height",self.height())
|
||||
self.hide()
|
||||
|
||||
def Refresh_clicked(self):
|
||||
|
@ -324,6 +346,7 @@ class Mail():
|
|||
return "ERROR"
|
||||
|
||||
def mail_check():
|
||||
details.ui.statusBar.setText(datetime.strftime(datetime.now(), "%d.%m.%Y %H:%M:%S")+" - Starting mail check")
|
||||
mail_count = 0
|
||||
AllFroms=[]
|
||||
AllSubjs=[]
|
||||
|
@ -370,16 +393,20 @@ def mail_check():
|
|||
painter.end()
|
||||
# End drawing text on icon
|
||||
window.trayIcon.setIcon(QtGui.QIcon(pixmap))
|
||||
details.ui.statusBar.setText(datetime.strftime(datetime.now(), "%d.%m.%Y %H:%M:%S")+" - Mail check completed. You have no unread letters")
|
||||
elif mail_count == "ERROR":
|
||||
window.trayIcon.setIcon(QIcon(":icons/mailbox_error.png"))
|
||||
window.trayIcon.setToolTip ("Error checking mail.")
|
||||
details.ui.statusBar.setText(datetime.strftime(datetime.now(), "%d.%m.%Y %H:%M:%S")+" - Error checking mail")
|
||||
elif mail_count == "CONNECTION_ERROR":
|
||||
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.")
|
||||
window.trayIcon.setIcon(QIcon(":icons/mailbox_error.png"))
|
||||
details.ui.statusBar.setText(datetime.strftime(datetime.now(), "%d.%m.%Y %H:%M:%S")+" - Unable to establish connection to mailbox. Check your mail settings and make sure that you have not network problems")
|
||||
elif mail_count == "CONFIGURATION_ERROR":
|
||||
window.trayIcon.setIcon(QIcon(":icons/mailbox_error.png"))
|
||||
window.trayIcon.setToolTip("Cannot find configuration file. You should give access to your mailbox")
|
||||
details.ui.statusBar.setText(datetime.strftime(datetime.now(), "%d.%m.%Y %H:%M:%S")+" - Cannot find configuration file. You should give access to your mailbox")
|
||||
else:
|
||||
# When mailbox has unread letters
|
||||
window.trayIcon.setToolTip ("You have "+ str(mail_count)+" unread letters")
|
||||
|
@ -403,6 +430,7 @@ def mail_check():
|
|||
details.ui.tableWidget.setRowCount(len(AllFroms))
|
||||
details.ui.tableWidget.setColumnCount(3)
|
||||
#Enter data onto Table
|
||||
try:
|
||||
horHeaders = []
|
||||
for n, key in enumerate(sorted(data.keys())):
|
||||
#print(data.keys())
|
||||
|
@ -410,6 +438,9 @@ def mail_check():
|
|||
for m, item in enumerate(data[key]):
|
||||
newitem = QtWidgets.QTableWidgetItem(item)
|
||||
details.ui.tableWidget.setItem(m, n, newitem)
|
||||
except:
|
||||
print("Unable to load some data")
|
||||
pass
|
||||
|
||||
#Add Header
|
||||
details.ui.tableWidget.setHorizontalHeaderLabels(horHeaders)
|
||||
|
@ -417,12 +448,16 @@ def mail_check():
|
|||
#Adjust size of Table
|
||||
details.ui.tableWidget.resizeColumnsToContents()
|
||||
details.ui.tableWidget.resizeRowsToContents()
|
||||
details.ui.statusBar.setText(datetime.strftime(datetime.now(), "%d.%m.%Y %H:%M:%S")+" - Mail check completed. You have "+ str(mail_count) +" unread letters")
|
||||
# check was successfull, lastCheckCount is updating
|
||||
window.lastCheckCount = mail_count
|
||||
def notify(message):
|
||||
try:
|
||||
if settings.value("Notify"):
|
||||
subprocess.Popen(['notify-send', programTitle, message])
|
||||
return
|
||||
except:
|
||||
print(message)
|
||||
|
||||
|
||||
|
||||
|
|
3796
resources_rc.py
3796
resources_rc.py
File diff suppressed because it is too large
Load Diff
|
@ -6,7 +6,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>483</width>
|
||||
<width>511</width>
|
||||
<height>334</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -60,7 +60,7 @@
|
|||
<rect>
|
||||
<x>200</x>
|
||||
<y>40</y>
|
||||
<width>203</width>
|
||||
<width>291</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
|
|
@ -42,6 +42,37 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="statusBar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Form implementation generated from reading ui file 'ui/about.ui'
|
||||
#
|
||||
# Created by: PyQt5 UI code generator 5.5.1
|
||||
# Created by: PyQt5 UI code generator 5.8.2
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
|
@ -11,7 +11,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
|||
class Ui_about(object):
|
||||
def setupUi(self, about):
|
||||
about.setObjectName("about")
|
||||
about.resize(483, 334)
|
||||
about.resize(511, 334)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
|
@ -31,7 +31,7 @@ class Ui_about(object):
|
|||
self.lblLogo.setScaledContents(True)
|
||||
self.lblLogo.setObjectName("lblLogo")
|
||||
self.lblNameVersion = QtWidgets.QLabel(about)
|
||||
self.lblNameVersion.setGeometry(QtCore.QRect(200, 40, 203, 31))
|
||||
self.lblNameVersion.setGeometry(QtCore.QRect(200, 40, 291, 31))
|
||||
self.lblNameVersion.setMinimumSize(QtCore.QSize(203, 0))
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(20)
|
||||
|
|
|
@ -36,6 +36,19 @@ class Ui_Details(object):
|
|||
self.tableWidget.setRowCount(0)
|
||||
self.horizontalLayout.addWidget(self.tableWidget)
|
||||
self.verticalLayout_2.addLayout(self.horizontalLayout)
|
||||
self.statusBar = QtWidgets.QLabel(Details)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.statusBar.sizePolicy().hasHeightForWidth())
|
||||
self.statusBar.setSizePolicy(sizePolicy)
|
||||
self.statusBar.setMinimumSize(QtCore.QSize(0, 0))
|
||||
self.statusBar.setBaseSize(QtCore.QSize(0, 0))
|
||||
self.statusBar.setFrameShape(QtWidgets.QFrame.StyledPanel)
|
||||
self.statusBar.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
self.statusBar.setText("")
|
||||
self.statusBar.setObjectName("statusBar")
|
||||
self.verticalLayout_2.addWidget(self.statusBar)
|
||||
|
||||
self.retranslateUi(Details)
|
||||
QtCore.QMetaObject.connectSlotsByName(Details)
|
||||
|
|
Loading…
Reference in New Issue