Start adding systray

This commit is contained in:
Micah Lee 2021-06-29 16:52:10 -07:00
parent 47bf46cb3d
commit f4739e749a
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
6 changed files with 53 additions and 6 deletions

1
.gitignore vendored
View file

@ -134,3 +134,4 @@ deb_dist
.DS_Store .DS_Store
install/windows/Dangerzone.wxs install/windows/Dangerzone.wxs
test_docs/sample-safe.pdf test_docs/sample-safe.pdf
share/bin

View file

@ -58,6 +58,12 @@ If you don't have it already, install poetry (`pip3 install --user poetry`). The
poetry install poetry install
``` ```
Make sure Docker Desktop is installed (Dangerzone copies hyperkit and vpnkit binaries from it) and run this to collect the binaries:
```
./install/macos/collect-bins.sh
```
Run from source tree: Run from source tree:
``` ```

View file

@ -8,6 +8,7 @@ from PySide2 import QtCore, QtWidgets
from .common import GuiCommon from .common import GuiCommon
from .main_window import MainWindow from .main_window import MainWindow
from .systray import SysTray
from .docker_installer import ( from .docker_installer import (
is_docker_installed, is_docker_installed,
is_docker_ready, is_docker_ready,
@ -149,4 +150,7 @@ def gui_main(custom_container, filename):
# If the application is activated and all windows are closed, open a new one # If the application is activated and all windows are closed, open a new one
app_wrapper.application_activated.connect(application_activated) app_wrapper.application_activated.connect(application_activated)
# Create a system tray, which also handles the VM subprocess
systray = SysTray(global_common, gui_common, app)
sys.exit(app.exec_()) sys.exit(app.exec_())

29
dangerzone/gui/systray.py Normal file
View file

@ -0,0 +1,29 @@
from PySide2 import QtCore, QtGui, QtWidgets
class SysTray(QtWidgets.QSystemTrayIcon):
def __init__(self, global_common, gui_common, app):
super(SysTray, self).__init__()
self.global_common = global_common
self.gui_common = gui_common
self.app = app
self.setIcon(self.gui_common.get_window_icon())
menu = QtWidgets.QMenu()
self.status_action = menu.addAction("Dangerzone is starting ...")
self.status_action.setEnabled(False)
menu.addSeparator()
self.restart_action = menu.addAction("Restart")
self.restart_action.triggered.connect(self.restart_clicked)
self.quit_action = menu.addAction("Quit")
self.quit_action.triggered.connect(self.quit_clicked)
self.setContextMenu(menu)
self.show()
def restart_clicked(self):
self.status_action.setText("Restarting Dangerzone ...")
def quit_clicked(self):
self.app.quit()

4
install/macos/collect-bins.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
mkdir -p share/bin
cp /Applications/Docker.app/Contents/Resources/bin/com.docker.hyperkit share/bin/hyperkit
cp /Applications/Docker.app/Contents/Resources/bin/com.docker.vpnkit share/bin/vpnkit

View file

@ -5,5 +5,8 @@
<!-- Required for binaries built with PyInstaller --> <!-- Required for binaries built with PyInstaller -->
<key>com.apple.security.cs.allow-unsigned-executable-memory</key> <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/> <true/>
<key>com.apple.vm.networking</key>
<true/>
</dict> </dict>
</plist> </plist>