Ejemplo n.º 1
0
def bootstrap0():
    # enable highdpi scaling
    QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
    QApplication.setAttribute(
        QtCore.Qt.AA_UseHighDpiPixmaps, True)  # use highdpi icons
    app = QtWidgets.QApplication(sys.argv)

    app.setStyle('Breeze')
    app.setStyleSheet(darkstylesheet())

    window = QtWidgets.QMainWindow()  # Create windwo
    prog = InterfaceGuiscrcpy(window)

    splash_pix = QPixmap(":/res/ui/guiscrcpy-branding.png")
    splash = QtWidgets.QSplashScreen(splash_pix)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    adb.devices(adb.path)

    app.processEvents()

    window.show()
    splash.hide()
    app.exec_()
    sys.exit()
Ejemplo n.º 2
0
def bootstrap0():
    # enable highdpi scaling
    QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
    QApplication.setAttribute(
        QtCore.Qt.AA_UseHighDpiPixmaps, True)  # use highdpi icons
    app = QtWidgets.QApplication(sys.argv)

    app.setStyle('Breeze')
    app.setStyleSheet(darkstylesheet())

    splash_pix = QPixmap(":/res/ui/guiscrcpy-branding.png")
    splash = QtWidgets.QSplashScreen(splash_pix)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()
    cfedited = False

    from guiscrcpy.install.finder import openFileNameDialog
    if adb.path is None:
        adb.path = openFileNameDialog(None, 'adb')
        cfedited = True
        config['adb'] = adb.path

    if scrcpy.path is None:
        scrcpy.path = openFileNameDialog(None, 'scrcpy')
        cfedited = True
        config['scrcpy'] = scrcpy.path

    if (scrcpy.server_path is None) and (platform.System() == 'Windows'):
        scrcpy.server_path = openFileNameDialog(None, 'scrcpy-server')
        cfedited = True
        config['scrcpy-server'] = scrcpy.server_path

    if cfedited:
        cfgmgr.update_config(config)
        cfgmgr.write_file()

    adb.devices(adb.path)
    prog = InterfaceGuiscrcpy()
    prog.show()
    app.processEvents()
    splash.hide()
    app.exec_()
    sys.exit()
Ejemplo n.º 3
0
    def __refresh_devices_combo_box_cb(self):
        devices_list = adb.devices(adb.path)

        if len(devices_list) == 0:
            self.private_message_box_adb.setText("DEVICE IS NOT CONNECTED")
            self.progressBar.setValue(0)
            return 0,
        else:
            valid_devices = []
            invalid_devices = []
            for dev, stat in devices_list:
                if stat == "unauthorized":
                    invalid_devices.append(
                        f"{dev} IS UNAUTHORIZED. CLICK 'ok' when asked.")
                elif stat == "device":
                    valid_devices.append(dev)
                else:
                    invalid_devices.append(
                        f"{dev} is connected. Failed to establish connection")
            self.private_message_box_adb.setText(
                "Connected: {};".format(', '.join(valid_devices))
            )
        if len(valid_devices) > 1:
            if self.devices_combox.currentText(
            ) == '' or self.devices_combox.currentText().isspace():
                logger.info(
                    "Found more than one device. "
                    "Please select device in drop down box")
                self.private_message_box_adb.setText(
                    "Found more than one device. "
                    "Please select device in drop down box")
                self.devices_combox.clear()
                self.devices_combox.addItems(
                    [f"{x[0]} : {x[1]}" for x in devices_list])
                return 0,

            else:
                more_devices = True
                device_id = self.devices_combox.currentText().split(":")[
                    0].strip()
        else:
            more_devices = False
            device_id = None

        return more_devices, device_id
Ejemplo n.º 4
0
    def start_act(self):

        self.runningNot.setText("CHECKING DEVICE CONNECTION")
        timei = time.time()
        self.progressBar.setValue(5)

        devices_list = adb.devices(adb.path)

        if devices_list[0] == "\n":
            self.runningNot.setText("DEVICE IS NOT CONNECTED")
            self.progressBar.setValue(0)
            return 0
        try:
            exc = devices_list[1].find("device")
        except IndexError:
            self.runningNot.setText("DEVICE IS NOT CONNECTED")
            self.progressBar.setValue(0)
            return 0

        if exc > -1:
            self.runningNot.setText(
                "DEVICE " + str(devices_list[0]) + " IS CONNECTED")
            self.progressBar.setValue(10)

        elif devices_list[1][:-1] == "unauthorized":
            self.runningNot.setText(
                "DEVICE IS UNAUTHORIZED. PLEASE CLICK 'OK' ON DEVICE WHEN ASKED FOR"
            )
            self.progressBar.setValue(0)
            return 0

        else:
            self.runningNot.setText(
                "DEVICE CONNECTED BUT FAILED TO ESTABLISH CONNECTION"
            )
            self.progressBar.setValue(0)
            return 0
        # check if the defaultDimension is checked or not for giving signal

        ux = UXMapper()
        dimValues = adb.get_dimensions(adb.path)

        self.progressBar.setValue(15)

        if self.dimensionDefaultCheckbox.isChecked():
            self.dimensionSlider.setEnabled(False)
            self.dimensionText.setText("DEFAULT")
            config['dimension'] = None

        else:
            self.dimensionSlider.setEnabled(True)
            config['dimension'] = int(self.dimensionSlider.value())
            self.dimensionSlider.setValue(config['dimension'])
            self.dimensionText.setText(str(config['dimension']) + "px")

        # check if the defaultDimension is checked or not for giving signal
        self.progressBar.setValue(20)

        # process dimension
        if config['dimension'] is None:
            self.options = " "
            pass
        elif config['dimension'] is not None:
            self.options = " -m " + str(config['dimension'])
        else:
            self.options = ""

        self.progressBar.setValue(25)
        # CHECK BOX GROUP CONNECT
        if self.aotop.isChecked():
            self.options += " --always-on-top"
        if self.fullscreen.isChecked():
            self.options += " -f"
            config['fullscreen'] = True
        else:
            config['fullscreen'] = False

        self.progressBar.setValue(30)
        if self.showTouches.isChecked():
            self.options += " --show-touches"
            config['swtouches'] = True

        else:
            config['swtouches'] = False
        if self.recScui.isChecked():
            self.options += " -r " + str(int(time.time())) + ".mp4 "

        if self.displayForceOn.isChecked():
            self.options += " -S"
            config['dispRO'] = True

        else:
            config['dispRO'] = False

        self.options += " -b " + str(int(self.dial.value())) + "K"
        config['bitrate'] = int(self.dial.value())
        self.progressBar.setValue(40)
        logging.debug("CONNECTION ESTABLISHED")
        self.progressBar.setValue(50)
        logging.debug("Flags passed to scrcpy engine : " + self.options)
        self.progressBar.setValue(75)
        config['extra'] = self.flaglineedit.text()
        self.swipe_instance.init()  # show Swipe UI
        self.panel_instance.init()
        self.side_instance.init()

        # run scrcpy usng subprocess
        args = "{} {}".format(self.options, config['extra'])
        scrcpy.start(scrcpy.path, args)

        timef = time.time()
        eta = timef - timei
        print("SCRCPY is launched in", eta, "seconds")
        self.progressBar.setValue(100)

        # handle config files
        cfgmgr.update_config(config)
        cfgmgr.write_file()

        if self.notifChecker.isChecked():
            from guiscrcpy.lib.notify import NotifyAuditor
            NotifyAuditor()

        return True
Ejemplo n.º 5
0
def bootstrap0():
    """
    Launch the guiscrcpy window
    :return:
    """
    # enable High DPI scaling
    QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
    QApplication.setAttribute(
        QtCore.Qt.AA_UseHighDpiPixmaps, True)  # use HIGH DPI icons
    app = QtWidgets.QApplication(sys.argv)

    app.setStyle('Breeze')
    app.setStyleSheet(dark_stylesheet())

    splash_pix = QPixmap(":/res/ui/guiscrcpy-branding.png")
    splash = QtWidgets.QSplashScreen(splash_pix)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()
    cfg_edited = False

    if (adb.path is None) or (not os.path.exists(adb.path)):
        adb.path = open_exe_name_dialog(None, 'adb')
        cfg_edited = True
        config['adb'] = adb.path

    if (scrcpy.path is None) or (not os.path.exists(scrcpy.path)):
        scrcpy.path = open_exe_name_dialog(None, 'scrcpy')
        cfg_edited = True
        config['scrcpy'] = scrcpy.path

    # on windows, users are likely not to add the scrcpy-server to the
    # SCRCPY_SERVER_PATH
    scrcpy_server_path_env = os.getenv('SCRCPY_SERVER_PATH', None)
    if scrcpy_server_path_env:
        if os.path.exists(scrcpy_server_path_env):
            config['scrcpy-server'] = scrcpy.server_path
        else:
            scrcpy.server_path = open_exe_name_dialog(None, 'scrcpy-server')
            cfg_edited = True
            config['scrcpy-server'] = scrcpy.server_path
            os.environ['SCRCPY_SERVER_PATH'] = scrcpy.server_path
    elif (
        (scrcpy.server_path is None) or
        (not os.path.exists(scrcpy.server_path))
    ) and (
        platform.System().system() == 'Windows'
    ):
        scrcpy.server_path = open_exe_name_dialog(None, 'scrcpy-server')
        cfg_edited = True
        config['scrcpy-server'] = scrcpy.server_path
        os.environ['SCRCPY_SERVER_PATH'] = scrcpy.server_path
    elif platform.System().system() == "Windows":
        os.environ['SCRCPY_SERVER_PATH'] = scrcpy.server_path

    if cfg_edited:
        cfgmgr.update_config(config)
        cfgmgr.write_file()

    adb.devices(adb.path)
    guiscrcpy = InterfaceGuiscrcpy()
    guiscrcpy.show()
    app.processEvents()
    splash.hide()
    app.exec_()
    sys.exit()