| 55 | print "pynotify not installed, falling back to qt tray notification" |
| 56 | |
| 57 | class main(QObject): |
| 58 | def __init__(self): |
| 59 | """ |
| 60 | main setup |
| 61 | """ |
| 62 | QObject.__init__(self) |
| 63 | self.app = QApplication(sys.argv) |
| 64 | self.path = pypath |
| 65 | self.homedir = abspath("") |
| 66 | |
| 67 | self.configdir = "" |
| 68 | |
| 69 | self.init(True) |
| 70 | |
| 71 | def init(self, first=False): |
| 72 | """ |
| 73 | set main things up |
| 74 | """ |
| 75 | self.parser = XMLParser(join(self.configdir, "gui.xml"), join(self.path, "module", "config", "gui_default.xml")) |
| 76 | lang = self.parser.xml.elementsByTagName("language").item(0).toElement().text() |
| 77 | if not lang: |
| 78 | parser = XMLParser(join(self.path, "module", "config", "gui_default.xml")) |
| 79 | lang = parser.xml.elementsByTagName("language").item(0).toElement().text() |
| 80 | |
| 81 | gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None]) |
| 82 | translation = gettext.translation("pyLoadGui", join(pypath, "locale"), languages=[str(lang), "en"], fallback=True) |
| 83 | try: |
| 84 | translation.install(unicode=(True if sys.stdout.encoding.lower().startswith("utf") else False)) |
| 85 | except: |
| 86 | translation.install(unicode=False) |
| 87 | |
| 88 | |
| 89 | self.connector = Connector() |
| 90 | self.mainWindow = MainWindow(self.connector) |
| 91 | self.connWindow = ConnectionManager() |
| 92 | self.mainloop = self.Loop(self) |
| 93 | self.connectSignals() |
| 94 | |
| 95 | self.checkClipboard = False |
| 96 | default = self.refreshConnections() |
| 97 | self.connData = None |
| 98 | self.captchaProcessing = False |
| 99 | self.serverStatus = {"freespace":0} |
| 100 | |
| 101 | self.core = None # pyLoadCore if started |
| 102 | self.connectionLost = False |
| 103 | |
| 104 | if True: # when used if first, minimizing not working correctly.. |
| 105 | self.tray = TrayIcon() |
| 106 | self.tray.show() |
| 107 | self.notification = Notification(self.tray) |
| 108 | self.connect(self, SIGNAL("showMessage"), self.notification.showMessage) |
| 109 | self.connect(self.tray.exitAction, SIGNAL("triggered()"), self.slotQuit) |
| 110 | self.connect(self.tray.showAction, SIGNAL("toggled(bool)"), self.mainWindow.setVisible) |
| 111 | self.connect(self.mainWindow, SIGNAL("hidden"), self.tray.mainWindowHidden) |
| 112 | |
| 113 | if not first: |
| 114 | self.connWindow.show() |