Esempio n. 1
0
class Module(object):
    def __init__(self):
        """
		This implements the Path edition functionality
		"""
        super(Module, self).__init__()

        self._right_docker = ControlDockWidget(
            'Videos list', side=ControlDockWidget.SIDE_LEFT, order=0, margin=5)
        self._right_details = ControlDockWidget(
            'Details', side=ControlDockWidget.SIDE_RIGHT, order=1, margin=5)

        self._right_docker.value = self._project
        #self._right_docker.hide()
        #self._right_details.hide()

        self.mainmenu[2]['Windows'].append({
            'Videos': self.__show_objects_list_event,
            'icon': conf.ANNOTATOR_ICON_MOVIES
        })

    def __show_objects_list_event(self):
        self._right_docker.show()
        self._right_details.show()

    def process_frame_event(self, frame):
        """
		Function called before render each frame
		"""
        if self._player.video_index is not None:
            self._project.draw(frame, self._player.video_index - 1)
        return super().process_frame_event(frame)

    def add_graph(self, name, data):
        self._time.add_graph(name, data)

    ######################################################################################
    #### IO FUNCTIONS ####################################################################
    ######################################################################################

    ######################################################################################
    #### PROPERTIES ######################################################################
    ######################################################################################

    @property
    def objects(self):
        return self._project.objects

    @property
    def details(self):
        return self._right_details.value

    @details.setter
    def details(self, value):
        self._right_details.value = value
Esempio n. 2
0
class CinemaManager(BaseWidget):

    def __init__(self, *args, **kwargs):
        super().__init__('Cinema manager')

        self._pesel = ""
        self._client = Client('http://localhost:8080/projekt?wsdl')
        self._selected_date = date.today()

        # Screening window
        self._search_screenings_button = ControlButton("Search")
        self._screening_day = ControlNumber("Day:", default=self._selected_date.day, minimum=1,
                                            maximum=monthrange(self._selected_date.year, self._selected_date.month)[1],
                                            changed_event=self._change_day)
        self._screening_month = ControlNumber("Month:", default=self._selected_date.month, minimum=1,
                                              maximum=12, changed_event=self._change_month)
        self._screening_year = ControlNumber("Year:", default=self._selected_date.year,
                                             minimum=self._selected_date.year,
                                             maximum=self._selected_date.year + 1,
                                             changed_event=self._change_day)
        self._screening_list = ControlList('Screenings', readonly=True, select_entire_row=True,
                                           cell_double_clicked_event=self._screening_changed_event)
        self._screening_list.horizontal_headers = ['Time', 'Movie', 'Description']
        self._all_showings = self._client.service.getShowingsByDate(self._selected_date.year, self._selected_date.month,
                                                                    self._selected_date.day)
        self._search_screenings_button.value = self._searchScreeningsButton

        for showing in self._all_showings:
            self._screening_list += [showing.date.strftime("%H:%M"), str(showing.movie.title),
                                     str(showing.movie.description)]

        # Client window
        self._all_reservations = []

        self._reservation_list = ControlList('Reservations', readonly=True, select_entire_row=True,
                                             cell_double_clicked_event=self._reservation_changed_event)
        self._reservation_list.horizontal_headers = ['Date', 'Time', 'Movie', 'Seats', 'Paid']
        self._screening_panel = ControlDockWidget()
        self._screening_panel.hide()
        self._reservation_panel = ControlDockWidget()
        self._reservation_panel.hide()
        self._loginWindow = LoginWindow(self._client)
        self.hide()
        self._loginWindow.parent = self
        self._loginWindow.show()
        print(self._client.service)
        # Define the organization of the Form Controls
        self.formset = [{
            'a:Screening': [('_screening_day', '_screening_month', '_screening_year', '_search_screenings_button'), '=',
                            '_screening_list'],
            'b:Client': ['_reservation_list']
        },
        ]

    def _screening_changed_event(self, row, column):
        self._all_showings = self._client.service.getShowingsByDate(self._selected_date.year, self._selected_date.month,
                                                                    self._selected_date.day)
        print(self._all_showings)
        win = ScreeningWindow(self._all_showings[row], self._client, self._pesel)
        win.parent = self
        self._screening_panel.show()
        self._reservation_panel.hide()
        self._screening_panel.label = "Screening info"
        self._screening_panel.value = win

    def _reservation_changed_event(self, row, column):
        self._all_reservations = self._client.service.getUserReservationsByPesel(self._pesel)
        win = ClientReservationWindow(self._all_reservations[row], self._client)
        win.parent = self
        self._screening_panel.hide()
        self._reservation_panel.show()
        self._reservation_panel.label = "Reservation details"
        self._reservation_panel.value = win

    def setUserPesel(self,pesel):
        self._pesel = pesel
        self.updateInfo()

    def updateInfo(self):
        self._screening_list.clear()
        self._all_showings = self._client.service.getShowingsByDate(self._selected_date.year, self._selected_date.month,
                                                                    self._selected_date.day)
        for show in self._all_showings:
            self._screening_list += [show.date.strftime("%H:%M"), str(show.movie.title),
                                     str(show.movie.description)]
        self._reservation_list.clear()
        self._all_reservations = self._client.service.getUserReservationsByPesel(self._pesel)
        for reservation in self._all_reservations:
            self._reservation_list += [reservation['showing']['date'].strftime("%d-%m-%Y"),
                                       reservation['showing']['date'].strftime("%H:%M"),
                                       str(reservation['showing']['movie']['title']), str(reservation['places']),
                                       "Yes" if reservation['isPaid'] is True else "No"]

    def _searchScreeningsButton(self):
        self._screening_list.clear()
        self._all_showings = self._client.service.getShowingsByDate(self._selected_date.year, self._selected_date.month,
                                                                    self._selected_date.day)
        for show in self._all_showings:
            self._screening_list += [show.date.strftime("%H:%M"), str(show.movie.title),
                                     str(show.movie.description)]

    def _change_day(self):
        self._selected_date = self._selected_date.replace(day=int(self._screening_day.value))

    def _change_month(self):
        self._selected_date = self._selected_date.replace(month=int(self._screening_month.value), day=1)
        self._screening_day.max = monthrange(self._selected_date.year, self._selected_date.month)[1]
        self._screening_day.value = 1
Esempio n. 3
0
class NSScreenshotMakerGUI(BaseWidget):
    def __init__(self, *args, **kwargs):
        global games_json
        super().__init__("NSScreenshotMaker")
        self._tmpinputfolder = tempfile.mkdtemp()
        self._settingsbutton = ControlButton("⚙️")
        self._settingsbutton.value = self.openSettings
        self._runbutton = ControlButton("Go!")
        self._runbutton.value = self.go
        self._combo = ControlCombo(
            helptext="The game the Switch will think the screenshot is from")
        self.gameslist = games_json
        for k in self.gameslist:
            self._combo.add_item(k, self.gameslist[k])
        self._combo.add_item("Custom", "Custom")
        self._combolabel = ControlLabel(
            "Game ID",
            helptext="The game the Switch will think the screenshot is from")
        self._imagelist = ControlFilesTree()
        self._imagelist._form.setDragEnabled(True)
        self._imagelist._form.setAcceptDrops(True)
        self._imagelist._form.setDropIndicatorShown(True)
        self._imagelist._form.dropEvent = self.dropEvent
        model = QFileSystemModel(parent=None)
        model.setReadOnly(False)
        self._imagelist._form.setModel(model)
        model.setRootPath(QtCore.QDir.currentPath())
        self._imagelist._form.setRootIndex(
            model.setRootPath(self._tmpinputfolder))
        self._imagelist._form.setIconSize(QtCore.QSize(32, 32))
        self.formset = [("_combolabel", "_combo", "_settingsbutton"),
                        "_imagelist", "_runbutton"]
        self._firstrunpanel = ControlDockWidget()
        self._firstrunpanel.hide()
        self._firstrunwin = FirstRun()
        if not os.path.isfile(
                appdirs.AppDirs("NSScreenshotMaker", "").user_data_dir +
                "/settings.json"):
            self._firstrunwin.parent = self
            self._firstrunpanel.value = self._firstrunwin
            self._firstrunpanel.show()
            self._firstrunwin.show()
        self._settingspanel = ControlDockWidget()
        self._settingspanel.hide()
        self._settingswin = SettingsWindow()

    def dropEvent(self, event):
        if event.mimeData().hasUrls:
            event.setDropAction(QtCore.Qt.CopyAction)
            event.accept()
            # to get a list of files:
            drop_list = []
            for url in event.mimeData().urls():
                drop_list.append(str(url.toLocalFile()))
            # handle the list here
            for f in drop_list:
                try:
                    if not f.endswith(".cbr") and not f.endswith(
                            ".cbz") and not f.endswith(
                                ".zip") and not f.endswith(".rar"):
                        Image.open(f)
                    shutil.copy(f, self._tmpinputfolder)
                except:
                    pass
        else:
            event.ignore()

    def closeEvent(self, event):
        shutil.rmtree(self._tmpinputfolder)

    def openSettings(self):
        self._firstrunwin.close()
        self._firstrunpanel.hide()
        self._settingswin.close()
        self._settingswin.parent = self
        self._settingspanel.value = self._settingswin
        self._settingspanel.show()
        self._settingswin.show()

    def go(self):
        global settings_json
        if len(os.listdir(self._tmpinputfolder)) == 0:
            return
        prevFileName = ""
        totalElements = 0
        state = 0
        if settings_json["type"] == "manga":
            state = 1
        if settings_json["type"] == "comics":
            state = 2
        for fileName in os.listdir(self._tmpinputfolder):
            print("Processing file " + fileName)
            totalElements += 1
            if fileName.endswith(".zip") or fileName.endswith(".cbz"):
                zf = zipfile.ZipFile(self._tmpinputfolder + "/" + fileName)
                for f in zf.infolist():
                    with open(self._tmpinputfolder + "/" + f.filename,
                              "wb") as fp:
                        fp.write(zf.read(f))
            elif fileName.endswith(".rar") or fileName.endswith(".cbr"):
                rf = rarfile.RarFile(self._tmpinputfolder + "/" + fileName)
                for f in rf.infolist():
                    with open(self._tmpinputfolder + "/" + f.filename,
                              "wb") as fp:
                        fp.write(rf.read(f))
            else:
                try:
                    if state == 0:
                        if list(self._combo._items.values())[
                                self._combo.current_index] != "Custom":
                            processFile(
                                self._tmpinputfolder + "/" + fileName,
                                bytes.fromhex(settings_json["hmackey"]),
                                list(self._combo._items.values())[
                                    self._combo.current_index],
                                settings_json["outputfolder"])
                        else:
                            processFile(
                                self._tmpinputfolder + "/" + fileName,
                                bytes.fromhex(settings_json["hmackey"]),
                                settings_json["customgameid"],
                                settings_json["outputfolder"])
                    elif prevFileName != "":
                        if list(self._combo._items.values())[
                                self._combo.current_index] != "Custom":
                            processFile(
                                self._tmpinputfolder + "/" + fileName,
                                bytes.fromhex(settings_json["hmackey"]),
                                list(self._combo._items.values())[
                                    self._combo.current_index],
                                settings_json["outputfolder"], state,
                                self._tmpinputfolder + "/" + prevFileName)
                        else:
                            processFile(
                                self._tmpinputfolder + "/" + fileName,
                                bytes.fromhex(settings_json["hmackey"]),
                                settings_json["customgameid"],
                                settings_json["outputfolder"], state,
                                self._tmpinputfolder + "/" + prevFileName)
                        prevFileName = ""
                        continue
                    prevFileName = fileName
                except:
                    pass
        if state != 0 and totalElements % 2 != 0:
            if list(self._combo._items.values())[
                    self._combo.current_index] != "Custom":
                processFile(
                    self._tmpinputfolder + "/" + fileName,
                    bytes.fromhex(settings_json["hmackey"]),
                    list(self._combo._items.values())
                    [self._combo.current_index], settings_json["outputfolder"])
            else:
                processFile(self._tmpinputfolder + "/" + fileName,
                            bytes.fromhex(settings_json["hmackey"]),
                            settings_json["customgameid"],
                            settings_json["outputfolder"])