Version 2.0

This commit is contained in:
Rinaldus 2016-03-23 13:18:15 +03:00
parent 6c08c40531
commit 91ced51326
6 changed files with 193 additions and 13 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
__pycache__

12
LICENSE.txt Normal file
View File

@ -0,0 +1,12 @@
Copyright (c) 2015-2016, 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:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -20,6 +20,12 @@ $ chmod +x mail-notifier.py
``` ```
## Changelog ## Changelog
### Version 2.0 (release date: 23.03.16)
* **Important! Users of Mail Notifier 1.x have to delete old configuration file located in ~/.config/mail-notifier/settings.conf before first launch of new version**
* New "About" window
* Added license (BSD 3-Clause)
### Version 2.0-beta1 (release date: 10.02.16) ### Version 2.0-beta1 (release date: 10.02.16)
* **Important! The configuration structure was changed. Users of Mail Notifier 1.x have to delete old configuration file located in ~/.config/mail-notifier/settings.conf before first launch of new version** * **Important! The configuration structure was changed. Users of Mail Notifier 1.x have to delete old configuration file located in ~/.config/mail-notifier/settings.conf before first launch of new version**
* Multi account support. Now the program is able to check new mails in several mailboxes. You will get the total quantity of new mails from all mailboxes in system tray * Multi account support. Now the program is able to check new mails in several mailboxes. You will get the total quantity of new mails from all mailboxes in system tray
@ -39,6 +45,3 @@ $ chmod +x mail-notifier.py
### Version 0.10 (pre release date: 28.10.15) ### Version 0.10 (pre release date: 28.10.15)
* Initial version * Initial version
* All parameters are stored right in script * All parameters are stored right in script
## Todo
* "About program" window

View File

@ -11,14 +11,15 @@ imaplib._MAXLINE = 400000
import subprocess import subprocess
import resources_rc import resources_rc
from ui_settings import Ui_Settings from ui_settings import Ui_Settings
from ui_about import Ui_about
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5 import QtCore, QtGui, QtWidgets
import os import os
import socket import socket
import time import time
#variables #variables
timers = []
programTitle = "Mail Notifier" programTitle = "Mail Notifier"
programVersion = "2.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
@ -80,16 +81,15 @@ class Window(QDialog):
# Menu actions # Menu actions
def createActions(self): def createActions(self):
self.quitAction = QAction(QIcon(':icons/menu_quit.png'),"&Quit", self, self.aboutShow = QAction(QIcon(':icons/mailbox_empty.png'),"&About", self, triggered=self.aboutShow)
triggered=QApplication.instance().quit) self.checkNow = QAction(QIcon(':icons/check_now.png'),"&Check now", self, triggered=mail_check)
self.checkNow = QAction(QIcon(':icons/check_now.png'),"&Check now", self, self.restoreAction = QAction(QIcon(":icons/settings.png"),"&Settings", self, triggered=self.showNormal)
triggered=mail_check) self.quitAction = QAction(QIcon(':icons/menu_quit.png'),"&Quit", self, triggered=QApplication.instance().quit)
self.restoreAction = QAction(QIcon(":icons/settings.png"),"&Settings", self,
triggered=self.showNormal)
# UI functions # UI functions
def createTrayIcon(self): def createTrayIcon(self):
self.trayIconMenu = QMenu(self) self.trayIconMenu = QMenu(self)
self.trayIconMenu.addAction(self.aboutShow)
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)
@ -197,6 +197,12 @@ class Window(QDialog):
self.ui.boolifSSL.setChecked(bool(settings.value("SSL"))) self.ui.boolifSSL.setChecked(bool(settings.value("SSL")))
settings.endGroup() settings.endGroup()
def aboutShow(self):
if (about.isMinimized):
about.hide()
about.show()
about.activateWindow()
def start(self): def start(self):
if (GlobalSettingsExist() and AccountExist()): if (GlobalSettingsExist() and AccountExist()):
CheckInterval = 1000*60*int(settings.value("CheckInterval")) CheckInterval = 1000*60*int(settings.value("CheckInterval"))
@ -208,8 +214,23 @@ class Window(QDialog):
def stop (self): def stop (self):
self.timer.stop() self.timer.stop()
class About(QDialog):
def __init__(self):
super(About, self).__init__()
self.ui = Ui_about()
self.ui.setupUi(self)
self.setWindowFlags(QtCore.Qt.Tool)
self.setFixedSize(483,334)
self.ui.lblNameVersion.setText(programTitle + " " + programVersion)
f = open('LICENSE.txt', 'r')
self.ui.txtLicense.setPlainText(f.read())
def closeEvent(self, event): def closeEvent(self, event):
print ("Closing the app") event.ignore()
self.hide()
# Common functions # Common functions
@ -288,6 +309,8 @@ def notify(message):
subprocess.Popen(['notify-send', programTitle, message]) subprocess.Popen(['notify-send', programTitle, message])
return return
if __name__ == '__main__': if __name__ == '__main__':
import sys import sys
app = QApplication(sys.argv) app = QApplication(sys.argv)
@ -302,6 +325,7 @@ if __name__ == '__main__':
sys.exit(1) sys.exit(1)
QApplication.setQuitOnLastWindowClosed(False) QApplication.setQuitOnLastWindowClosed(False)
window = Window() window = Window()
about = About()
if (GlobalSettingsExist() and AccountExist()): if (GlobalSettingsExist() and AccountExist()):
window.hide() window.hide()
else: else:

89
ui/about.ui Normal file
View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>about</class>
<widget class="QDialog" name="about">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>483</width>
<height>334</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Mail Notifier</string>
</property>
<property name="windowIcon">
<iconset resource="../resources.qrc">
<normaloff>:/icons/mailbox_empty.png</normaloff>:/icons/mailbox_empty.png</iconset>
</property>
<widget class="QPlainTextEdit" name="txtLicense">
<property name="geometry">
<rect>
<x>50</x>
<y>120</y>
<width>381</width>
<height>201</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="lblLogo">
<property name="geometry">
<rect>
<x>50</x>
<y>0</y>
<width>131</width>
<height>111</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../resources.qrc">:/icons/mailbox_empty.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="lblNameVersion">
<property name="geometry">
<rect>
<x>200</x>
<y>40</y>
<width>203</width>
<height>31</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>203</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>20</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Mail Notifier</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</widget>
<resources>
<include location="../resources.qrc"/>
</resources>
<connections/>
</ui>

51
ui_about.py Normal file
View File

@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'ui/about.ui'
#
# Created by: PyQt5 UI code generator 5.5.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_about(object):
def setupUi(self, about):
about.setObjectName("about")
about.resize(483, 334)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(about.sizePolicy().hasHeightForWidth())
about.setSizePolicy(sizePolicy)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icons/mailbox_empty.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
about.setWindowIcon(icon)
self.txtLicense = QtWidgets.QPlainTextEdit(about)
self.txtLicense.setGeometry(QtCore.QRect(50, 120, 381, 201))
self.txtLicense.setObjectName("txtLicense")
self.lblLogo = QtWidgets.QLabel(about)
self.lblLogo.setGeometry(QtCore.QRect(50, 0, 131, 111))
self.lblLogo.setText("")
self.lblLogo.setPixmap(QtGui.QPixmap(":/icons/mailbox_empty.png"))
self.lblLogo.setScaledContents(True)
self.lblLogo.setObjectName("lblLogo")
self.lblNameVersion = QtWidgets.QLabel(about)
self.lblNameVersion.setGeometry(QtCore.QRect(200, 40, 203, 31))
self.lblNameVersion.setMinimumSize(QtCore.QSize(203, 0))
font = QtGui.QFont()
font.setPointSize(20)
font.setBold(True)
font.setWeight(75)
self.lblNameVersion.setFont(font)
self.lblNameVersion.setScaledContents(True)
self.lblNameVersion.setObjectName("lblNameVersion")
self.retranslateUi(about)
QtCore.QMetaObject.connectSlotsByName(about)
def retranslateUi(self, about):
_translate = QtCore.QCoreApplication.translate
about.setWindowTitle(_translate("about", "Mail Notifier"))
self.lblNameVersion.setText(_translate("about", "Mail Notifier 2.0"))
import resources_rc