From 91ced51326eef20c4c859deebdaa8ace2b869255 Mon Sep 17 00:00:00 2001 From: Rinaldus Date: Wed, 23 Mar 2016 13:18:15 +0300 Subject: [PATCH] Version 2.0 --- .gitignore | 1 + LICENSE.txt | 12 +++++++ README.md | 9 +++-- mail-notifier.py | 44 ++++++++++++++++++------ ui/about.ui | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ ui_about.py | 51 +++++++++++++++++++++++++++ 6 files changed, 193 insertions(+), 13 deletions(-) create mode 100644 .gitignore create mode 100644 LICENSE.txt create mode 100644 ui/about.ui create mode 100644 ui_about.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bee8a64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__ diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..d677a18 --- /dev/null +++ b/LICENSE.txt @@ -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. \ No newline at end of file diff --git a/README.md b/README.md index a7e274c..48fe039 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,12 @@ $ chmod +x mail-notifier.py ``` ## 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) * **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 @@ -39,6 +45,3 @@ $ chmod +x mail-notifier.py ### Version 0.10 (pre release date: 28.10.15) * Initial version * All parameters are stored right in script - -## Todo -* "About program" window diff --git a/mail-notifier.py b/mail-notifier.py index b3fc4ba..398269e 100755 --- a/mail-notifier.py +++ b/mail-notifier.py @@ -11,14 +11,15 @@ imaplib._MAXLINE = 400000 import subprocess import resources_rc from ui_settings import Ui_Settings +from ui_about import Ui_about from PyQt5 import QtCore, QtGui, QtWidgets import os import socket import time #variables -timers = [] programTitle = "Mail Notifier" +programVersion = "2.0" settings = QSettings(os.path.expanduser("~")+"/.config/mail-notifier/settings.conf", QSettings.NativeFormat) def GlobalSettingsExist(): if ((settings.contains("CheckInterval") and settings.value("CheckInterval") != "") and @@ -80,16 +81,15 @@ class Window(QDialog): # Menu actions def createActions(self): - self.quitAction = QAction(QIcon(':icons/menu_quit.png'),"&Quit", self, - triggered=QApplication.instance().quit) - 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.aboutShow = QAction(QIcon(':icons/mailbox_empty.png'),"&About", 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.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) self.trayIconMenu.addAction(self.checkNow) self.trayIconMenu.addAction(self.restoreAction) self.trayIconMenu.addAction(self.quitAction) @@ -196,6 +196,12 @@ class Window(QDialog): self.ui.txtboxPassword.setText(settings.value("Password")) self.ui.boolifSSL.setChecked(bool(settings.value("SSL"))) settings.endGroup() + + def aboutShow(self): + if (about.isMinimized): + about.hide() + about.show() + about.activateWindow() def start(self): if (GlobalSettingsExist() and AccountExist()): @@ -207,9 +213,24 @@ class Window(QDialog): def stop (self): self.timer.stop() - - def closeEvent(self, event): - print ("Closing the app") + +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): + event.ignore() + self.hide() # Common functions @@ -288,6 +309,8 @@ def notify(message): subprocess.Popen(['notify-send', programTitle, message]) return + + if __name__ == '__main__': import sys app = QApplication(sys.argv) @@ -302,6 +325,7 @@ if __name__ == '__main__': sys.exit(1) QApplication.setQuitOnLastWindowClosed(False) window = Window() + about = About() if (GlobalSettingsExist() and AccountExist()): window.hide() else: diff --git a/ui/about.ui b/ui/about.ui new file mode 100644 index 0000000..4b7d4d1 --- /dev/null +++ b/ui/about.ui @@ -0,0 +1,89 @@ + + + about + + + + 0 + 0 + 483 + 334 + + + + + 0 + 0 + + + + Mail Notifier + + + + :/icons/mailbox_empty.png:/icons/mailbox_empty.png + + + + + 50 + 120 + 381 + 201 + + + + + + + 50 + 0 + 131 + 111 + + + + + + + :/icons/mailbox_empty.png + + + true + + + + + + 200 + 40 + 203 + 31 + + + + + 203 + 0 + + + + + 20 + 75 + true + + + + Mail Notifier + + + true + + + + + + + + diff --git a/ui_about.py b/ui_about.py new file mode 100644 index 0000000..b820b04 --- /dev/null +++ b/ui_about.py @@ -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