def __init__(self, parent=None, ux_mapper=None, frame=False, always_on_top=True): """ The bottom panel subwindow class for guiscrcpy :param parent: The caller of the function :param ux_mapper: The UX Mapper toolkit :param frame: Boolean (Frame window / Frameless Window) :param always_on_top: Boolean (always on top) """ # noinspection PyArgumentList QMainWindow.__init__(self) Ui_HorizontalPanel.__init__(self) self.name = "panel" self.uid = uuid.uuid4() self.setupUi(self) self.parent = parent self.oldPos = self.pos() __flags = QtCore.Qt.Window if not frame: __flags |= QtCore.Qt.FramelessWindowHint if always_on_top: __flags |= QtCore.Qt.WindowStaysOnTopHint self.setWindowFlags(__flags) if ux_mapper: self.ux = ux_mapper else: self.ux = UXMapper()
def __init__(self, ux_mapper=None, parent=None, frame=False, always_on_top=True): """ Side panel toolkit for guiscrcpy main window :param ux_mapper: :param parent: :param frame: :param: always_on_top: bool """ QMainWindow.__init__(self) Ui_ToolbarPanel.__init__(self) self.name = "toolkit" self.uid = uuid.uuid4() self.setupUi(self) self.parent = parent self.oldPos = None self.ux = None __flags = QtCore.Qt.Window if not frame: __flags |= QtCore.Qt.FramelessWindowHint if always_on_top: __flags |= QtCore.Qt.WindowStaysOnTopHint self.setWindowFlags(__flags) if ux_mapper: self.ux = ux_mapper else: self.ux = UXMapper()
def init(self): self.ux = UXMapper() self.backk.clicked.connect(self.ux.key_back) self.menuUII.clicked.connect(self.ux.key_menu) self.homee.clicked.connect(self.ux.key_home) self.powerUII.clicked.connect(self.ux.key_power) self.vupp.clicked.connect(self.ux.key_volume_up) self.vdownn.clicked.connect(self.ux.key_volume_down) self.show()
def __init__(self, ux_mapper=None, parent=None, frame=False): """ Side panel toolkit for guiscrcpy main window :param ux_mapper: :param parent: :param frame: """ QMainWindow.__init__(self) Ui_ToolbarPanel.__init__(self) self.name = "toolkit" self.uid = uuid.uuid4() self.setupUi(self) self.parent = parent self.oldPos = None self.ux = None if not frame: self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint) if ux_mapper: self.ux = ux_mapper else: self.ux = UXMapper()
def init(self): self.ux = UXMapper() self.clipD2PC.clicked.connect(self.ux.copy_devpc) self.clipPC2D.clicked.connect(self.ux.copy_pc2dev) self.back.clicked.connect(self.ux.key_back) self.screenfreeze.clicked.connect(self.quitn) self.appswi.clicked.connect(self.ux.key_switch) self.menuUI.clicked.connect(self.ux.key_menu) self.home.clicked.connect(self.ux.key_home) self.notif_pull.clicked.connect(self.ux.expand_notifications) self.notif_collapse.clicked.connect(self.ux.collapse_notifications) self.fullscreenUI.clicked.connect(self.ux.fullscreen) self.powerUI.clicked.connect(self.ux.key_power) self.vup.clicked.connect(self.ux.key_volume_up) self.vdown.clicked.connect(self.ux.key_volume_down) self.potraitUI.clicked.connect(self.ux.reorientP) self.landscapeUI.clicked.connect(self.ux.reorientL) self.show()
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
class Panel(QMainWindow, Ui_HorizontalPanel): # there was a Dialog in the bracket def __init__(self, parent=None, ux_mapper=None, frame=False, always_on_top=True): """ The bottom panel subwindow class for guiscrcpy :param parent: The caller of the function :param ux_mapper: The UX Mapper toolkit :param frame: Boolean (Frame window / Frameless Window) :param always_on_top: Boolean (always on top) """ # noinspection PyArgumentList QMainWindow.__init__(self) Ui_HorizontalPanel.__init__(self) self.name = "panel" self.uid = uuid.uuid4() self.setupUi(self) self.parent = parent self.oldPos = self.pos() __flags = QtCore.Qt.Window if not frame: __flags |= QtCore.Qt.FramelessWindowHint if always_on_top: __flags |= QtCore.Qt.WindowStaysOnTopHint self.setWindowFlags(__flags) if ux_mapper: self.ux = ux_mapper else: self.ux = UXMapper() def init(self): self.bp_close.clicked.connect(self.quit_window) self.backk.clicked.connect(self.ux.key_back) self.menuUII.clicked.connect(self.ux.key_menu) self.homee.clicked.connect(self.ux.key_home) self.powerUII.clicked.connect(self.ux.key_power) self.vupp.clicked.connect(self.ux.key_volume_up) self.vdownn.clicked.connect(self.ux.key_volume_down) self.colorize() self.show() def colorize(self): hexdigest = self.ux.get_sha()[:6] self.bp_device_id.setStyleSheet(f"background-color: #{hexdigest};") def mousePressEvent(self, event): self.oldPos = event.globalPos() def mouseMoveEvent(self, event): try: delta = QPoint(event.globalPos() - self.oldPos) self.move(self.x() + delta.x(), self.y() + delta.y()) self.oldPos = event.globalPos() except (TypeError, AttributeError): pass def quit_window(self): for instance in self.parent.child_windows: # noqa # We are checking for any more windows running before killing # the main window. self.child_windows has the list of all # objects spawned by the main window ui # This method checks if we are the last member of the windows # spawned and we ourselves are not a member of ourself by # checking the uuid generated on creation if not instance.isHidden() \ and instance.name != "swipe" and instance.uid != \ self.uid: self.hide() break else: for instance in self.parent.child_windows: # noqa if instance.name == 'swipe' and instance.ux.get_sha() == \ self.ux.get_sha(): instance.hide() self.hide()
def __init__(self, ux_wrapper=None, frame=False): QMainWindow.__init__(self) super(SwipeUX, self).__init__() self.oldPos = None self.name = "swipe" self.uid = uuid.uuid4() # ================= if ux_wrapper: self.ux = ux_wrapper else: self.ux = UXMapper() hexdigest = self.ux.get_sha()[:6] self.setObjectName("SwipeUX") if not frame: self.setWindowFlags(Qt.FramelessWindowHint) self.setAttribute(Qt.WA_NoSystemBackground, True) self.setAttribute(Qt.WA_TranslucentBackground, True) # self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint # QtCore.Qt.FramelessWindowHint) self.resize(70, 70) # ----------------------- icon = QtGui.QIcon() icon.addPixmap( QtGui.QPixmap(":/res/ui/guiscrcpy_logo.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off, ) self.setWindowIcon(icon) self.setStyleSheet( "QWidget {" "background-color: rgba(0,0,0,0);}\nQPushButton {\n" "border-radius: 15px;\n" "background-color: qradialgradient(" "spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.495098, fy:0.5, " "stop:0.887255 rgba(35, 35, 35, 255), " "stop:0.901961 rgba(0, 0, 0, 255));\n" "color: rgb(0, 0, 0);\n" "}\n\n" "QPushButton:pressed {\n" "border-radius: 15px;\n" "\n" "background-color: qlineargradient(" "spread:pad, x1:0, y1:0, x2:1, y2:1, " "stop:0 rgba(0, 255, 255, 255), " "stop:1 rgba(0, 255, 152, 255));\n" "color: rgb(0, 0, 0);\n" " }\n" "QMainWindow{background-color: rgba(0,0,0,30);}\n" "QPushButton:hover {\n" "border-radius: 15px;\n" "background-color: qlineargradient(" "spread:pad, x1:0, y1:0, x2:1, y2:1, " "stop:0 rgba(0, 199, 199, 255), " "stop:1 rgba(0, 190, 113, 255));\n" "color: rgb(0, 0, 0);\n" "}") self.centralwidget = QtWidgets.QWidget(self) self.centralwidget.setObjectName("centralwidget") self.lol = QtWidgets.QPushButton(self.centralwidget) self.lol.setGeometry(QtCore.QRect(24, 24, 25, 25)) self.lol.setText("") self.lol.setObjectName("lol") self.lol.setStyleSheet(f"background-color: #{hexdigest};" f"border-radius: 12px; ") self.swirt = QtWidgets.QPushButton(self.centralwidget) self.swirt.setGeometry(QtCore.QRect(40, 20, 30, 30)) self.swirt.setText("") icon1 = QtGui.QIcon() icon1.addPixmap( QtGui.QPixmap(":/icons/icons/chevron-sign-right.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off, ) self.swirt.setIcon(icon1) self.swirt.setObjectName("swirt") self.swilf = QtWidgets.QPushButton(self.centralwidget) self.swilf.setGeometry(QtCore.QRect(0, 20, 30, 30)) self.swilf.setText("") icon2 = QtGui.QIcon() icon2.addPixmap( QtGui.QPixmap(":/icons/icons/chevron-sign-left.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off, ) self.swilf.setIcon(icon2) self.swilf.setObjectName("swilf") self.swidn = QtWidgets.QPushButton(self.centralwidget) self.swidn.setGeometry(QtCore.QRect(20, 40, 30, 30)) self.swidn.setText("") icon3 = QtGui.QIcon() icon3.addPixmap( QtGui.QPixmap(":/icons/icons/chevron-sign-down.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off, ) self.swidn.setIcon(icon3) self.swidn.setObjectName("swidn") self.swiup = QtWidgets.QPushButton(self.centralwidget) self.swiup.setGeometry(QtCore.QRect(20, 0, 30, 30)) self.swiup.setText("") icon4 = QtGui.QIcon() icon4.addPixmap( QtGui.QPixmap(":/icons/icons/chevron-sign-up.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off, ) self.swiup.setIcon(icon4) self.swiup.setObjectName("swiup") self.setCentralWidget(self.centralwidget) self.oldpos = self.pos() self.swiup.pressed.connect(self.swipup) self.swidn.pressed.connect(self.swipdn) self.swilf.pressed.connect(self.swipleft) self.swirt.pressed.connect(self.swipright)
class SwipeUX(QMainWindow): def __init__(self, ux_wrapper=None, frame=False): QMainWindow.__init__(self) super(SwipeUX, self).__init__() self.oldPos = None self.name = "swipe" self.uid = uuid.uuid4() # ================= if ux_wrapper: self.ux = ux_wrapper else: self.ux = UXMapper() hexdigest = self.ux.get_sha()[:6] self.setObjectName("SwipeUX") if not frame: self.setWindowFlags(Qt.FramelessWindowHint) self.setAttribute(Qt.WA_NoSystemBackground, True) self.setAttribute(Qt.WA_TranslucentBackground, True) # self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint # QtCore.Qt.FramelessWindowHint) self.resize(70, 70) # ----------------------- icon = QtGui.QIcon() icon.addPixmap( QtGui.QPixmap(":/res/ui/guiscrcpy_logo.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off, ) self.setWindowIcon(icon) self.setStyleSheet( "QWidget {" "background-color: rgba(0,0,0,0);}\nQPushButton {\n" "border-radius: 15px;\n" "background-color: qradialgradient(" "spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.495098, fy:0.5, " "stop:0.887255 rgba(35, 35, 35, 255), " "stop:0.901961 rgba(0, 0, 0, 255));\n" "color: rgb(0, 0, 0);\n" "}\n\n" "QPushButton:pressed {\n" "border-radius: 15px;\n" "\n" "background-color: qlineargradient(" "spread:pad, x1:0, y1:0, x2:1, y2:1, " "stop:0 rgba(0, 255, 255, 255), " "stop:1 rgba(0, 255, 152, 255));\n" "color: rgb(0, 0, 0);\n" " }\n" "QMainWindow{background-color: rgba(0,0,0,30);}\n" "QPushButton:hover {\n" "border-radius: 15px;\n" "background-color: qlineargradient(" "spread:pad, x1:0, y1:0, x2:1, y2:1, " "stop:0 rgba(0, 199, 199, 255), " "stop:1 rgba(0, 190, 113, 255));\n" "color: rgb(0, 0, 0);\n" "}") self.centralwidget = QtWidgets.QWidget(self) self.centralwidget.setObjectName("centralwidget") self.lol = QtWidgets.QPushButton(self.centralwidget) self.lol.setGeometry(QtCore.QRect(24, 24, 25, 25)) self.lol.setText("") self.lol.setObjectName("lol") self.lol.setStyleSheet(f"background-color: #{hexdigest};" f"border-radius: 12px; ") self.swirt = QtWidgets.QPushButton(self.centralwidget) self.swirt.setGeometry(QtCore.QRect(40, 20, 30, 30)) self.swirt.setText("") icon1 = QtGui.QIcon() icon1.addPixmap( QtGui.QPixmap(":/icons/icons/chevron-sign-right.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off, ) self.swirt.setIcon(icon1) self.swirt.setObjectName("swirt") self.swilf = QtWidgets.QPushButton(self.centralwidget) self.swilf.setGeometry(QtCore.QRect(0, 20, 30, 30)) self.swilf.setText("") icon2 = QtGui.QIcon() icon2.addPixmap( QtGui.QPixmap(":/icons/icons/chevron-sign-left.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off, ) self.swilf.setIcon(icon2) self.swilf.setObjectName("swilf") self.swidn = QtWidgets.QPushButton(self.centralwidget) self.swidn.setGeometry(QtCore.QRect(20, 40, 30, 30)) self.swidn.setText("") icon3 = QtGui.QIcon() icon3.addPixmap( QtGui.QPixmap(":/icons/icons/chevron-sign-down.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off, ) self.swidn.setIcon(icon3) self.swidn.setObjectName("swidn") self.swiup = QtWidgets.QPushButton(self.centralwidget) self.swiup.setGeometry(QtCore.QRect(20, 0, 30, 30)) self.swiup.setText("") icon4 = QtGui.QIcon() icon4.addPixmap( QtGui.QPixmap(":/icons/icons/chevron-sign-up.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off, ) self.swiup.setIcon(icon4) self.swiup.setObjectName("swiup") self.setCentralWidget(self.centralwidget) self.oldpos = self.pos() self.swiup.pressed.connect(self.swipup) self.swidn.pressed.connect(self.swipdn) self.swilf.pressed.connect(self.swipleft) self.swirt.pressed.connect(self.swipright) def init(self): self.show() def paintEvent(self, event): qp = QtGui.QPainter() qp.begin(self) qp.setRenderHint(QtGui.QPainter.Antialiasing) qp.setPen(Qt.NoPen) qp.setBrush(QtGui.QColor(0, 0, 0, 127)) qp.drawEllipse(0, 0, 70, 70) qp.end() def mousePressEvent(self, event): self.oldPos = event.globalPos() def mouseMoveEvent(self, event): try: delta = QPoint(event.globalPos() - self.oldPos) self.move(self.x() + delta.x(), self.y() + delta.y()) self.oldPos = event.globalPos() except (TypeError, AttributeError): pass def swipdn(self): logging.debug("Passing SWIPE DOWN") dim_values = self.ux.android_dimensions pos_y = int(dim_values[1]) - 200 pos_x = int(dim_values[0]) new_pos_x = pos_x / 2 # find center self.ux.do_swipe(new_pos_x, 200, new_pos_x, pos_y) def swipup(self): logging.debug("Passing SWIPE UP") dim_values = self.ux.android_dimensions pos_y = int(dim_values[1]) - 100 pos_x = int(dim_values[0]) new_pos_x = int(pos_x / 2) # find center self.ux.do_swipe(new_pos_x, pos_y, new_pos_x, 200) def swipleft(self): logging.debug("Passing SWIPE LEFT") dim_values = self.ux.android_dimensions pos_y = int(dim_values[1]) pos_x = int(dim_values[0]) - 10 new_pos_y = int(pos_y / 2) # find center self.ux.do_swipe(10, new_pos_y, pos_x, new_pos_y) def swipright(self): logging.debug("Passing SWIPE RIGHT") dim_values = self.ux.android_dimensions pos_y = int(dim_values[1]) pos_x = int(dim_values[0]) - 10 new_pos_y = int(pos_y / 2) # find center self.ux.do_swipe(pos_x, new_pos_y, 10, new_pos_y)
class InterfaceToolkit(QMainWindow, Ui_ToolbarPanel): def __init__(self, ux_mapper=None, parent=None, frame=False): """ Side panel toolkit for guiscrcpy main window :param ux_mapper: :param parent: :param frame: """ QMainWindow.__init__(self) Ui_ToolbarPanel.__init__(self) self.name = "toolkit" self.uid = uuid.uuid4() self.setupUi(self) self.parent = parent self.oldPos = None self.ux = None if not frame: self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint) if ux_mapper: self.ux = ux_mapper else: self.ux = UXMapper() def init(self): self.clipD2PC.clicked.connect(self.ux.copy_devpc) self.clipPC2D.clicked.connect(self.ux.copy_pc2dev) self.back.clicked.connect(self.ux.key_back) self.screenfreeze.clicked.connect(self.quit_window) self.appswi.clicked.connect(self.ux.key_switch) self.menuUI.clicked.connect(self.ux.key_menu) self.home.clicked.connect(self.ux.key_home) self.notif_pull.clicked.connect(self.ux.expand_notifications) self.notif_collapse.clicked.connect(self.ux.collapse_notifications) self.fullscreenUI.clicked.connect(self.ux.fullscreen) self.powerUI.clicked.connect(self.ux.key_power) self.vup.clicked.connect(self.ux.key_volume_up) self.vdown.clicked.connect(self.ux.key_volume_down) self.potraitUI.clicked.connect(self.ux.reorient_portrait) self.landscapeUI.clicked.connect(self.ux.reorient_landscape) self.colorize() # give a unique color for each device self.show() def colorize(self): hexdigest = self.ux.get_sha()[:6] self.tk_device_id.setStyleSheet(f"background-color: #{hexdigest};") def mousePressEvent(self, event): self.oldPos = event.globalPos() def mouseMoveEvent(self, event): try: delta = QPoint(event.globalPos() - self.oldPos) self.move(self.x() + delta.x(), self.y() + delta.y()) self.oldPos = event.globalPos() except (TypeError, AttributeError): pass def quit_window(self): for instance in self.parent.child_windows: # We are checking for any more windows running before killing # the main window. self.child_windows has the list of all # objects spawned by the main window ui # This method checks if we are the last member of the windows # spawned and we ourselves are not a member of ourself by # checking the uuid generated on creation if not instance.isHidden() \ and instance.name != "swipe" and instance.uid != \ self.uid: self.hide() break else: sys.exit()
def start_act(self): # prepare launch of scrcpy, # reset colors # reset vars # 1: reset progress = self.progress(0) stylesheet = \ "background-color: qlineargradient(" \ "spread:pad, x1:0, y1:0, x2:1, y2:1, " \ "stop:0 rgba(0, 255, 255, 255), " \ "stop:1 rgba(0, 255, 152, 255)); " \ "border-radius: 10px;" self.private_message_box_adb.setStyleSheet(stylesheet) # ==================================================================== # 2: Update UI to start checking self.private_message_box_adb.setText("CHECKING DEVICE CONNECTION") initial_time = time.time() progress = self.progress(progress) # ==================================================================== # 3: Check devices values_devices_list = self.__refresh_devices_combo_box_cb() if len(values_devices_list) != 2: return 0 else: more_devices, device_id = values_devices_list progress = self.progress(progress) # ==================================================================== # 4: Parse dimension slider # check if the defaultDimension is checked or not for giving signal 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") # edit configuration files to update dimension key if config['dimension'] is None: self.options = " " pass elif config['dimension'] is not None: self.options = " -m " + str(config['dimension']) else: self.options = "" progress = self.progress(progress) # ==================================================================== # 5: Check if always_on and fullscreen switches are on if self.aotop.isChecked(): self.options += " --always-on-top" if self.fullscreen.isChecked(): self.options += " -f" config['fullscreen'] = True else: config['fullscreen'] = False progress = self.progress(progress) # ==================================================================== # 6: Check if show touches / recording are on if self.showTouches.isChecked(): self.options += " --show-touches" config['swtouches'] = True else: config['swtouches'] = False progress = self.progress(progress) # ==================================================================== # 7: Check if the record option is selected if self.recScui.isChecked(): self.options += " -r " + str(int(time.time())) + ".mp4 " progress = self.progress(progress) # ==================================================================== # 8: Check if the display is forced to be on if self.displayForceOn.isChecked(): self.options += " -S" config['dispRO'] = True else: config['dispRO'] = False progress = self.progress(progress) # ==================================================================== # 9: Parse bitrate # Bitrate is parsed, by editing the bitrate mask if self.bitrateText.text().split()[1][0] in ['K', 'M', 'T']: bitrate_multiplier = str(self.bitrateText.text().split()[1][0]) elif self.bitrateText.text().split()[1][0] == "B": bitrate_multiplier = "B" else: # do not proceed. Invalid file size multiplier multiplier_error = f"Invalid file size multiplier \ '{str(self.bitrateText.text().split()[1][0])}'. " \ f"Please use only K, M, T only" print(multiplier_error) self.private_message_box_adb.setText(multiplier_error) return False if self.bitrateText.text().split()[0].isdigit(): bitrate_integer = int(self.bitrateText.text().split()[0]) else: bitrate_integer = 8000 self.options += " -b {}{}".format(bitrate_integer, bitrate_multiplier) config['bitrate'] = bitrate_integer progress = self.progress(progress) # ==================================================================== # 10: Make user aware that there were no problems in connection # or in the data provided by the user logger.debug("CONNECTION ESTABLISHED") self.progressBar.setValue(50) logger.debug("Flags passed to scrcpy engine : " + self.options) self.progressBar.setValue(60) config['extra'] = self.flaglineedit.text() progress = self.progress(progress) # ==================================================================== # 11: Initialize User Experience Mapper ux = UXMapper(device_id=device_id) progress = self.progress(progress) # ==================================================================== # 12: Init side_panel if necessary if self.check_side_panel.isChecked(): side_instance = InterfaceToolkit( parent=self, ux_mapper=ux, frame=args.force_window_frame ) for instance in self.child_windows: if instance.ux.get_sha() == side_instance.ux.get_sha() and \ instance.name == side_instance.name: break else: side_instance.init() self.child_windows.append(side_instance) progress = self.progress(progress) # ==================================================================== # 13: Init bottom_panel if necessary if self.check_bottom_panel.isChecked(): panel_instance = Panel( parent=self, ux_mapper=ux, frame=args.force_window_frame ) for instance in self.child_windows: if instance.ux.get_sha() == panel_instance.ux.get_sha() and \ instance.name == panel_instance.name: break else: panel_instance.init() self.child_windows.append(panel_instance) progress = self.progress(progress) # ==================================================================== # 14: Init swipe panel if necessary if self.check_swipe_panel.isChecked(): swipe_instance = SwipeUX( ux_wrapper=ux, frame=args.force_window_frame ) # Load swipe UI for instance in self.child_windows: if instance.ux.get_sha() == swipe_instance.ux.get_sha() and \ instance.name == swipe_instance.name: break else: swipe_instance.init() self.child_windows.append(swipe_instance) progress = self.progress(progress) # ==================================================================== # 15: Generate uuid for device and set uuid color for PMBA hexdigest = ux.get_sha()[:6] stylesheet = f"background-color: #{hexdigest}; border-radius: 10px; " self.private_message_box_adb.setStyleSheet(stylesheet) progress = self.progress(progress) # ==================================================================== # 16: Parse scrcpy arguments if self.cmx is not None: config['cmx'] = ' '.join(map(str, self.cmx)) arguments_scrcpy = "{} {} {}".format( self.options, config['extra'], config['cmx'] ) progress = self.progress(progress) # ==================================================================== # 17: Handle more devices if more_devices: # guiscrcpy found more devices # scrcpy will fail if more than one device is found # its important to pass the device serial id, if more than one # device is found arguments_scrcpy = f"-s {device_id} {arguments_scrcpy}" # tell end users that the color of the device is this self.private_message_box_adb.setText( f"Device {device_id} is connected; (color id matches " f"toolkit color)" ) progress = self.progress(progress) # ==================================================================== # 18: Return if args.noscrcpy: # for debugging purposes, its important to not start scrcpy # every time return False progress = self.progress(progress) # ==================================================================== # 19: Start Scrcpy scrcpy.start(scrcpy.path, arguments_scrcpy) final_time = time.time() eta = final_time - initial_time print("scrcpy launched in {:.2f}s".format(eta)) progress = self.progress(progress) # ==================================================================== # 20: Update configuration cfgmgr.update_config(config) cfgmgr.write_file() progress = self.progress(progress) # ==================================================================== # 21: Finish (optional: notification aduitor if self.notifChecker.isChecked(): # call notification auditor if notification_auditor is checked only from guiscrcpy.lib.notify import NotifyAuditor try: NotifyAuditor() except (AttributeError, NameError, ValueError): self.notifChecker.setChecked(False) print("guiscrcpy notification auditor failed. ") print("Your OS / Desktop Environment might not support it atm") return self.progress(progress)
def init(self): self.ux = UXMapper() self.show()