示例#1
0
 def _load_service_icons():
     from Qt import QtGui
     ITrayService._failed_icon = QtGui.QIcon(
         resources.get_resource("icons", "circle_red.png"))
     ITrayService._icon_running = QtGui.QIcon(
         resources.get_resource("icons", "circle_green.png"))
     ITrayService._icon_idle = QtGui.QIcon(
         resources.get_resource("icons", "circle_orange.png"))
示例#2
0
    def __init__(self, tray_widget, main_window):
        self.tray_widget = tray_widget
        self.main_window = main_window
        self.log = Logger().get_logger(self.__class__.__name__)

        self.icon_run = QtGui.QIcon(get_resource('circle_green.png'))
        self.icon_stay = QtGui.QIcon(get_resource('circle_orange.png'))
        self.icon_failed = QtGui.QIcon(get_resource('circle_red.png'))

        self.services_thread = None
示例#3
0
    def __init__(self, parent):
        if os.getenv("PYPE_DEV"):
            icon_file_name = "icon_dev.png"
        else:
            icon_file_name = "icon.png"

        self.icon = QtGui.QIcon(get_resource(icon_file_name))

        QtWidgets.QSystemTrayIcon.__init__(self, self.icon, parent)

        # Store parent - QtWidgets.QMainWindow()
        self.parent = parent

        # Setup menu in Tray
        self.menu = QtWidgets.QMenu()
        self.menu.setStyleSheet(style.load_stylesheet())

        # Set modules
        self.tray_man = TrayManager(self, self.parent)
        self.tray_man.process_presets()

        # Catch activate event
        self.activated.connect(self.on_systray_activated)
        # Add menu to Context of SystemTrayIcon
        self.setContextMenu(self.menu)
示例#4
0
 def set_splash(self):
     if os.getenv("PYPE_DEV"):
         splash_file_name = "splash_dev.png"
     else:
         splash_file_name = "splash.png"
     splash_pix = QtGui.QPixmap(get_resource(splash_file_name))
     splash = QtWidgets.QSplashScreen(splash_pix)
     splash.setMask(splash_pix.mask())
     splash.setEnabled(False)
     splash.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint
                           | QtCore.Qt.FramelessWindowHint)
     return splash
示例#5
0
    def set_working_widget(self):
        image_file = get_resource('working.svg')
        img_pix = QtGui.QPixmap(image_file)
        if image_file.endswith('.svg'):
            widget = QtSvg.QSvgWidget(image_file)
        else:
            widget = QtWidgets.QLabel()
            widget.setPixmap(img_pix)

        # Set widget properties
        widget.setGeometry(img_pix.rect())
        widget.setMask(img_pix.mask())
        widget.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint
                              | QtCore.Qt.FramelessWindowHint)
        widget.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)

        self.center_widget(widget)
        self._working_widget = widget
        self.helper = DragAndDropHelper(self._working_widget)
示例#6
0
class LoginServerHandler(BaseHTTPRequestHandler):
    '''Login server handler.'''

    message_filepath = resources.get_resource("ftrack", "sign_in_message.html")

    def __init__(self, login_callback, *args, **kw):
        '''Initialise handler.'''
        self.login_callback = login_callback
        BaseHTTPRequestHandler.__init__(self, *args, **kw)

    def do_GET(self):
        '''Override to handle requests ourselves.'''
        parsed_path = parse.urlparse(self.path)
        query = parsed_path.query

        api_user = None
        api_key = None
        login_credentials = None
        if 'api_user' and 'api_key' in query:
            login_credentials = parse.parse_qs(query)
            api_user = login_credentials['api_user'][0]
            api_key = login_credentials['api_key'][0]

            with open(self.message_filepath, "r") as message_file:
                sign_in_message = message_file.read()

            # formatting html code for python
            replacements = (("{", "{{"), ("}", "}}"), ("{{}}", "{}"))
            for replacement in (replacements):
                sign_in_message = sign_in_message.replace(*replacement)
            message = sign_in_message.format(api_user)
        else:
            message = "<h1>Failed to sign in</h1>"

        self.send_response(200)
        self.end_headers()
        self.wfile.write(message.encode())

        if login_credentials:
            self.login_callback(api_user, api_key)