Fix a couple bugs/niggles
This commit is contained in:
parent
10145545cb
commit
f477495977
@ -1,12 +1,21 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
Version 0.3
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Released: 2017-08-11
|
||||||
|
|
||||||
|
- Shorten the time the tray icon message shows to 5 seconds
|
||||||
|
- Force the window to raise above other applications when clicking on the tray icon
|
||||||
|
- Toggle between showing and hiding the window when clicking on the tray icon
|
||||||
|
|
||||||
Version 0.2
|
Version 0.2
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
Released: 2017-06-13
|
Released: 2017-06-13
|
||||||
|
|
||||||
- Added the ability tpo minimize to a system tray icon
|
- Added the ability to minimize to a system tray icon
|
||||||
- Moved the module into a file instead of a directory
|
- Moved the module into a file instead of a directory
|
||||||
- Updated setup.py for the module move
|
- Updated setup.py for the module move
|
||||||
|
|
||||||
|
2
setup.py
2
setup.py
@ -13,7 +13,7 @@ with open(os.path.join(HERE, 'README.rst'), encoding='utf8') as f:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='WebAppify',
|
name='WebAppify',
|
||||||
version='0.2',
|
version='0.3',
|
||||||
description='Create desktop apps of your favourite websites',
|
description='Create desktop apps of your favourite websites',
|
||||||
long_description=LONG_DESCRIPTION,
|
long_description=LONG_DESCRIPTION,
|
||||||
url='https://launchpad.net/webappify',
|
url='https://launchpad.net/webappify',
|
||||||
|
46
webappify.py
46
webappify.py
@ -26,6 +26,8 @@ import platform
|
|||||||
|
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
|
IS_PY2 = sys.version_info[0] == 2
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from PyQt5 import QtWebEngineWidgets
|
from PyQt5 import QtWebEngineWidgets
|
||||||
HAS_WEBENGINE = True
|
HAS_WEBENGINE = True
|
||||||
@ -79,10 +81,10 @@ class WebWindow(QtWidgets.QWidget):
|
|||||||
super(WebWindow, self).__init__(None)
|
super(WebWindow, self).__init__(None)
|
||||||
self.hasShownWarning = False
|
self.hasShownWarning = False
|
||||||
self.app = app
|
self.app = app
|
||||||
self.icon = icon
|
self.icon = QtGui.QIcon(icon)
|
||||||
self.canMinimizeToTray = canMinimizeToTray
|
self.canMinimizeToTray = canMinimizeToTray
|
||||||
self.setWindowTitle(title)
|
self.setWindowTitle(title)
|
||||||
self.setWindowIcon(QtGui.QIcon(self.icon))
|
self.setWindowIcon(self.icon)
|
||||||
self.setContentsMargins(0, 0, 0, 0)
|
self.setContentsMargins(0, 0, 0, 0)
|
||||||
self.layout = QtWidgets.QVBoxLayout(self)
|
self.layout = QtWidgets.QVBoxLayout(self)
|
||||||
self.layout.setContentsMargins(0, 0, 0, 0)
|
self.layout.setContentsMargins(0, 0, 0, 0)
|
||||||
@ -102,7 +104,7 @@ class WebWindow(QtWidgets.QWidget):
|
|||||||
if not self.hasShownWarning:
|
if not self.hasShownWarning:
|
||||||
self.trayIcon.showMessage(self.windowTitle(), 'This program will continue running in the system tray. '
|
self.trayIcon.showMessage(self.windowTitle(), 'This program will continue running in the system tray. '
|
||||||
'To close the program, choose <b>Quit</b> in the context menu of the system '
|
'To close the program, choose <b>Quit</b> in the context menu of the system '
|
||||||
'tray icon.')
|
'tray icon.', QtWidgets.QSystemTrayIcon.Information, 5000)
|
||||||
self.hasShownWarning = True
|
self.hasShownWarning = True
|
||||||
|
|
||||||
def _updateTrayMenu(self):
|
def _updateTrayMenu(self):
|
||||||
@ -115,17 +117,44 @@ class WebWindow(QtWidgets.QWidget):
|
|||||||
self.minimizeAction.setEnabled(self.isVisible() and not self.isMinimized())
|
self.minimizeAction.setEnabled(self.isVisible() and not self.isMinimized())
|
||||||
self.maximizeAction.setEnabled(self.isVisible() and not self.isMaximized())
|
self.maximizeAction.setEnabled(self.isVisible() and not self.isMaximized())
|
||||||
|
|
||||||
|
def _raiseWindow(self):
|
||||||
|
"""
|
||||||
|
Raise the Window, depending on the version of Python
|
||||||
|
"""
|
||||||
|
# Get the "raise" method depending on Python 2 or 3
|
||||||
|
if IS_PY2:
|
||||||
|
raiser = getattr(self, 'raise_')
|
||||||
|
else:
|
||||||
|
raiser = getattr(self, 'raise')
|
||||||
|
raiser()
|
||||||
|
|
||||||
|
def _restoreWindow(self):
|
||||||
|
"""
|
||||||
|
Restore the window and activate it
|
||||||
|
"""
|
||||||
|
self.showNormal()
|
||||||
|
self.activateWindow()
|
||||||
|
self._raiseWindow()
|
||||||
|
|
||||||
|
def _maximizeWindow(self):
|
||||||
|
"""
|
||||||
|
Restore the window and activate it
|
||||||
|
"""
|
||||||
|
self.showMaximized()
|
||||||
|
self.activateWindow()
|
||||||
|
self._raiseWindow()
|
||||||
|
|
||||||
def _getTrayMenu(self):
|
def _getTrayMenu(self):
|
||||||
"""
|
"""
|
||||||
Create and return the menu for the tray icon
|
Create and return the menu for the tray icon
|
||||||
"""
|
"""
|
||||||
# Create the actions for the menu
|
# Create the actions for the menu
|
||||||
self.restoreAction = QtWidgets.QAction('&Restore', self)
|
self.restoreAction = QtWidgets.QAction('&Restore', self)
|
||||||
self.restoreAction.triggered.connect(self.showNormal)
|
self.restoreAction.triggered.connect(self._restoreWindow)
|
||||||
self.minimizeAction = QtWidgets.QAction('Mi&nimize', self)
|
self.minimizeAction = QtWidgets.QAction('Mi&nimize', self)
|
||||||
self.minimizeAction.triggered.connect(self.close)
|
self.minimizeAction.triggered.connect(self.close)
|
||||||
self.maximizeAction = QtWidgets.QAction('Ma&ximize', self)
|
self.maximizeAction = QtWidgets.QAction('Ma&ximize', self)
|
||||||
self.maximizeAction.triggered.connect(self.showMaximized)
|
self.maximizeAction.triggered.connect(self._maximizeWindow)
|
||||||
self.quitAction = QtWidgets.QAction('&Quit', self)
|
self.quitAction = QtWidgets.QAction('&Quit', self)
|
||||||
self.quitAction.triggered.connect(self.app.quit)
|
self.quitAction.triggered.connect(self.app.quit)
|
||||||
# Create the menu and add the actions
|
# Create the menu and add the actions
|
||||||
@ -141,7 +170,7 @@ class WebWindow(QtWidgets.QWidget):
|
|||||||
"""
|
"""
|
||||||
Set up the tray icon
|
Set up the tray icon
|
||||||
"""
|
"""
|
||||||
self.trayIcon = QtWidgets.QSystemTrayIcon(QtGui.QIcon(self.icon), self)
|
self.trayIcon = QtWidgets.QSystemTrayIcon(self.icon, self)
|
||||||
self.trayIcon.setContextMenu(self._getTrayMenu())
|
self.trayIcon.setContextMenu(self._getTrayMenu())
|
||||||
self.trayIcon.activated.connect(self.onTrayIconActivated)
|
self.trayIcon.activated.connect(self.onTrayIconActivated)
|
||||||
self.trayIcon.show()
|
self.trayIcon.show()
|
||||||
@ -201,6 +230,9 @@ class WebWindow(QtWidgets.QWidget):
|
|||||||
React to the tray icon being activated
|
React to the tray icon being activated
|
||||||
"""
|
"""
|
||||||
if reason == QtWidgets.QSystemTrayIcon.Trigger:
|
if reason == QtWidgets.QSystemTrayIcon.Trigger:
|
||||||
|
if self.isVisible():
|
||||||
|
self.close()
|
||||||
|
else:
|
||||||
self.showNormal()
|
self.showNormal()
|
||||||
|
|
||||||
|
|
||||||
@ -234,7 +266,7 @@ class WebApp(QtWidgets.QApplication):
|
|||||||
self.window.setupTrayIcon()
|
self.window.setupTrayIcon()
|
||||||
self.window.showMaximized()
|
self.window.showMaximized()
|
||||||
# Get the "exec" method depending on Python 2 or 3
|
# Get the "exec" method depending on Python 2 or 3
|
||||||
if sys.version_info[0] == 2:
|
if IS_PY2:
|
||||||
runner = getattr(self, 'exec_')
|
runner = getattr(self, 'exec_')
|
||||||
else:
|
else:
|
||||||
runner = getattr(self, 'exec')
|
runner = getattr(self, 'exec')
|
||||||
|
Loading…
Reference in New Issue
Block a user