Пример #1
0
def main():
    global win
    signal.signal(signal.SIGINT, exit)
    args = parse_arguments()
    appKey = "scudcloud.pid"
    socket = QLocalSocket()
    socket.connectToServer(appKey)
    if socket.isOpen():
        socket.close()
        socket.deleteLater()
        return 0
    socket.deleteLater()
    app = QtWidgets.QApplication(sys.argv)
    app.setApplicationName(Resources.APP_NAME + ' Slack')
    app.setWindowIcon(QtGui.QIcon(Resources.get_path('scudcloud.png')))
    try:
        settings_path, cache_path = load_settings(args.confdir, args.cachedir)
    except:
        print("Data directories " + args.confdir + " and " + args.cachedir +
              " could not be created! Exiting...")
        raise SystemExit()
    minimized = True if args.minimized is True else None
    urgent_hint = True if args.urgent_hint is True else None

    # Let's move the CSS to cachedir to enable additional actions
    copyfile(Resources.get_path('resources.css'),
             os.path.join(cache_path, 'resources.css'))

    # If there is an qt4 config and not a qt5, let's copy the old one
    qt4_config = os.path.join(settings_path, 'scudcloud.cfg')
    qt5_config = os.path.join(settings_path, 'scudcloud_qt5.cfg')
    if os.path.exists(qt4_config) and not os.path.exists(qt5_config):
        copyfile(qt4_config, qt5_config)

    win = sca.ScudCloud(debug=args.debug,
                        minimized=minimized,
                        urgent_hint=urgent_hint,
                        settings_path=settings_path,
                        cache_path=cache_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_())
Пример #2
0
def main():
    global win
    signal.signal(signal.SIGINT, exit)
    args = parse_arguments()
    appKey = "scudcloud.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+' Slack_SSB')
    app.setWindowIcon(QtGui.QIcon(Resources.get_path('scudcloud.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
    urgent_hint = True if args.urgent_hint is True else None

    win = sca.ScudCloud(debug=args.debug, minimized=minimized, urgent_hint=urgent_hint, 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_())
Пример #3
0
def main():
    global win
    signal.signal(signal.SIGINT, exit)
    args = parse_arguments()
    appKey = "scudcloud.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('scudcloud.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.ScudCloud(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_())
Пример #4
0
 def reset(self):
     self.setFixedWidth(0)
     self.setVisible(False)
     self.setUrl(QUrl.fromLocalFile(Resources.get_path("leftpane.html")))
     self.page().currentFrame().addToJavaScriptWindowObject(
         "leftPane", self)
     self.page().currentFrame().evaluateJavaScript(self.js)
Пример #5
0
 def __init__(self, debug = False, minimized = None, urgent_hint = None, settings_path = '', cache_path = ''):
     super(ScudCloud, self).__init__(None)
     self.debug = debug
     self.minimized = minimized
     self.urgent_hint = urgent_hint
     self.setWindowTitle(self.title)
     self.settings_path = settings_path
     self.cache_path = cache_path
     self.notifier = Notifier(Resources.APP_NAME, Resources.get_path('scudcloud.png'))
     self.settings = QSettings(self.settings_path + '/scudcloud_qt5.cfg', QSettings.IniFormat)
     self.notifier.enabled = self.settings.value('Notifications', defaultValue=True, type=bool)
     self.identifier = self.settings.value("Domain")
     if Unity is not None:
         self.launcher = Unity.LauncherEntry.get_for_desktop_id("scudcloud.desktop")
     else:
         self.launcher = DummyLauncher(self)
     self.webSettings()
     self.snippetsSettings()
     self.leftPane = LeftPane(self)
     self.stackedWidget = QtWidgets.QStackedWidget()
     centralWidget = QtWidgets.QWidget(self)
     layout = QtWidgets.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 = self.identifier.split(",")
         else:
             self.domains = self.identifier
         self.startURL = self.normalize(self.domains[0])
     else:
         self.domains = []
     self.addWrapper(self.startURL)
     self.addMenu()
     self.tray = Systray(self)
     self.systray(self.minimized)
     self.installEventFilter(self)
     self.statusBar().showMessage('Loading Slack...')
     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()
Пример #6
0
 def __init__(self, window):
     self.configure_proxy()
     QWebView.__init__(self)
     self.window = window
     with open(Resources.get_path('scudcloud.js'), 'r') as f:
         self.default_js = f.read()
     if self.window.disable_snippets:
         with open(Resources.get_path('disable_snippets.js'), 'r') as f:
             self.disable_snippets_js = f.read()
     self.setPage(Browser())
     self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
     self.urlChanged.connect(self._urlChanged)
     self.loadStarted.connect(self._loadStarted)
     self.loadFinished.connect(self._loadFinished)
     self.linkClicked.connect(self._linkClicked)
     self.page().featurePermissionRequested.connect(self.permissionRequested)
     self.addActions()
Пример #7
0
 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()
Пример #8
0
 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()
Пример #9
0
 def __init__(self, debug = False, parent = None, minimized = None, urgent_hint = None, settings_path = ""):
     super(ScudCloud, self).__init__(parent)
     self.debug = debug
     self.minimized = minimized
     self.urgent_hint = urgent_hint
     self.setWindowTitle(self.title)
     self.settings_path = settings_path
     self.notifier = Notifier(Resources.APP_NAME, Resources.get_path('scudcloud.png'))
     self.settings = QSettings(self.settings_path + '/scudcloud.cfg', QSettings.IniFormat)
     self.identifier = self.settings.value("Domain")
     if Unity is not None:
         self.launcher = Unity.LauncherEntry.get_for_desktop_id("scudcloud.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 = self.identifier.split(",")
         else:
             self.domains = self.identifier
         self.startURL = self.normalize(self.domains[0])
     else:
         self.domains = []
     self.addWrapper(self.startURL)
     self.addMenu()
     self.tray = Systray(self)
     self.systray(self.minimized)
     self.installEventFilter(self)
     self.statusBar().showMessage('Loading Slack...')
     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()
Пример #10
0
 def snippetsSettings(self):
     self.disable_snippets = self.settings.value("Snippets")
     if self.disable_snippets is not None:
         self.disable_snippets = self.disable_snippets == "False"
     else:
         self.disable_snippets = False
     if self.disable_snippets:
         disable_snippets_css = ''
         with open(Resources.get_path('disable_snippets.css'), 'r') as f:
             disable_snippets_css = f.read()
         with open(os.path.join(self.cache_path, 'resources.css'), 'a') as f:
             f.write(disable_snippets_css)
Пример #11
0
 def __init__(self, window):
     self.configure_proxy()
     QWebView.__init__(self)
     self.window = window
     with open(Resources.get_path("scudcloud.js"), "r") as f:
         self.js = f.read()
     self.setZoomFactor(self.window.zoom)
     self.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
     self.urlChanged.connect(self._urlChanged)
     self.loadStarted.connect(self._loadStarted)
     self.loadFinished.connect(self._loadFinished)
     self.linkClicked.connect(self._linkClicked)
     self.page().featurePermissionRequested.connect(self.permissionRequested)
     self.addActions()
Пример #12
0
 def __init__(self, window):
     self.configure_proxy()
     QWebView.__init__(self)
     self.window = window
     with open(Resources.get_path("scudcloud.js"), "r") as f:
         self.js = f.read()
     self.setZoomFactor(self.window.zoom)
     self.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
     self.urlChanged.connect(self._urlChanged)
     self.loadStarted.connect(self._loadStarted)
     self.loadFinished.connect(self._loadFinished)
     self.linkClicked.connect(self._linkClicked)
     self.page().featurePermissionRequested.connect(self.permissionRequested)
     self.addActions()
Пример #13
0
 def _loadStarted(self):
     # Some custom CSS to clean/fix UX
     self.settings().setUserStyleSheetUrl(
         QUrl.fromLocalFile(Resources.get_path("resources.css")))
Пример #14
0
 def _loadStarted(self):
     # Some custom CSS to clean/fix UX
     self.settings().setUserStyleSheetUrl(QUrl.fromLocalFile(Resources.get_path("resources.css")))
Пример #15
0
 def reset(self):
     self.setFixedWidth(0)
     self.setVisible(False)
     self.setUrl(QUrl.fromLocalFile(Resources.get_path("leftpane.html")))
     self.page().currentFrame().addToJavaScriptWindowObject("leftPane", self)
     self.page().currentFrame().evaluateJavaScript(self.js)