From ce15a793027321c6c5dd0af8330505177be37890 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Fri, 20 Jun 2014 21:15:46 -0400 Subject: [PATCH] window icon works now. fixes #49 --- onionshare_gui/onionshare_gui.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 6a542d84..2369d0dc 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -1,10 +1,12 @@ import onionshare, webapp -import os, sys, subprocess +import os, sys, subprocess, inspect from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * +window_icon = None + class Application(QApplication): def __init__(self): platform = onionshare.get_platform() @@ -23,18 +25,20 @@ class WebAppThread(QThread): class Window(QWebView): def __init__(self, basename, webapp_port): + global window_icon QWebView.__init__(self) self.setWindowTitle("{0} | OnionShare".format(basename)) self.resize(580, 400) self.setMinimumSize(580, 400) self.setMaximumSize(580, 400) - self.setWindowIcon(QIcon("onionshare-icon.png")) + self.setWindowIcon(window_icon) self.load(QUrl("http://127.0.0.1:{0}".format(webapp_port))) def alert(msg, icon=QMessageBox.NoIcon): + global window_icon dialog = QMessageBox() dialog.setWindowTitle("OnionShare") - self.setWindowIcon(QIcon("onionshare-icon.png")) + dialog.setWindowIcon(window_icon) dialog.setText(msg) dialog.setIcon(icon) dialog.exec_() @@ -74,6 +78,11 @@ def main(): subprocess.call(['/usr/bin/gksudo']+sys.argv) return + # create the onionshare icon + global window_icon + onionshare_gui_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) + window_icon = QIcon("{0}/onionshare-icon.png".format(onionshare_gui_dir)) + # try starting hidden service onionshare_port = onionshare.choose_port() try: