def reset(self): self.setFixedWidth(0) self.setVisible(False) self.setUrl(QUrl.fromLocalFile(Resources.get_path("leftpane.html"))) self._teams=[] self.page().currentFrame().addToJavaScriptWindowObject("leftPane", self) self.page().currentFrame().evaluateJavaScript(self.js)
def main(): global win signal.signal(signal.SIGINT, exit) args = parse_arguments() appKey = "hipscud.pid" socket = QLocalSocket() socket.connectToServer(appKey) if socket.isOpen(): socket.close() socket.deleteLater() return 0 socket.deleteLater() app = QtGui.QApplication(sys.argv) app.setApplicationName(Resources.APP_NAME) app.setWindowIcon(QtGui.QIcon(Resources.get_path('hipscud.png'))) try: settings_path = load_settings(args.confdir) except: print("Configuration directory " + args.confdir +\ " could not be created! Exiting...") raise SystemExit() minimized = True if args.minimized is True else None win = sca.HipScud(debug=args.debug, minimized=minimized, settings_path=settings_path) app.commitDataRequest.connect(win.setForceClose, type=QtCore.Qt.DirectConnection) server = QLocalServer() server.newConnection.connect(restore) server.listen(appKey) win.restore() if win.minimized is None: win.show() sys.exit(app.exec_())
def __init__(self, window): QWebView.__init__(self) self.window = window with open(Resources.get_path("leftpane.js"), "r") as f: self.js = f.read() # We don't want plugins for this simple pane self.settings().setAttribute(QWebSettings.PluginsEnabled, False) self.reset()
def __init__(self, debug = False, parent = None, minimized = None, settings_path = ""): super(HipScud, self).__init__(parent) self.debug = debug self.minimized = minimized self.setWindowTitle(self.title) self.settings_path = settings_path self.notifier = Notifier(Resources.APP_NAME, Resources.get_path('hipscud.png')) self.settings = QSettings(self.settings_path + '/hipscud.cfg', QSettings.IniFormat) self.identifier = self.settings.value("Domain") if Unity is not None: self.launcher = Unity.LauncherEntry.get_for_desktop_id("hipscud.desktop") else: self.launcher = DummyLauncher(self) self.webSettings() self.leftPane = LeftPane(self) self.stackedWidget = QtGui.QStackedWidget() centralWidget = QtGui.QWidget(self) layout = QtGui.QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addWidget(self.leftPane) layout.addWidget(self.stackedWidget) centralWidget.setLayout(layout) self.setCentralWidget(centralWidget) self.startURL = Resources.SIGNIN_URL if self.identifier is not None: if isinstance(self.identifier, str): self.domains = json.loads(self.identifier) else: self.domains = self.identifier self.leftPane.loadFinished.connect(self.populate_initial_teams) else: self.domains = [] if self.domains: def generate_next_function(i): next_function = generate_next_function(i+1) if i < (len(self.domains) - 1) else None return lambda: self.addWrapper(self.domains[i]['team_url'], next_function) self.addWrapper(self.domains[0]['team_url'], generate_next_function(1) if len(self.domains) > 1 else None) else: self.addWrapper(self.startURL) self.addMenu() self.tray = Systray(self) self.systray(self.minimized) self.installEventFilter(self) self.statusBar().showMessage('Loading HipChat...') self.tickler = QTimer(self) self.tickler.setInterval(1800000) # Watch for ScreenLock events if DBusQtMainLoop is not None: DBusQtMainLoop(set_as_default=True) sessionBus = dbus.SessionBus() # Ubuntu 12.04 and other distros sessionBus.add_match_string("type='signal',interface='org.gnome.ScreenSaver'") # Ubuntu 14.04 and above sessionBus.add_match_string("type='signal',interface='com.ubuntu.Upstart0_6'") sessionBus.add_message_filter(self.screenListener) self.tickler.timeout.connect(self.sendTickle) # If dbus is not present, tickler timer will act like a blocker to not send tickle too often else: self.tickler.setSingleShot(True) self.tickler.start()