Ejemplo n.º 1
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)

        self.init_ui()
        self.init_signals()

        self.input_manager = InputManager().get_instance()
Ejemplo n.º 2
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)

        self.input_manager = InputManager().get_instance()
        self.radio_categories = []

        self.init_ui()
        self.init_signals()

        self.current_page = None
Ejemplo n.º 3
0
def open_directory_dialog(
    hint="Select directory to open",
    dir="",
    options=QFileDialog.ShowDirsOnly,
    process=lambda k: InputManager.get_instance().add_folder(k)):
    directory = QFileDialog.getExistingDirectory(None, hint, dir, options)
    if directory:
        process(directory)
Ejemplo n.º 4
0
def open_file_dialog(
    hint="Select file to open",
    dir="",
    filter=";;".join([ALL_FILTER, IMAGE_FILTER, VIDEO_FILTER, AUDIO_FILTER]),
    process=lambda k: InputManager.get_instance().add_media(k, get_format(k))):
    filename, _ = QFileDialog.getOpenFileName(None, hint, dir, filter)
    if filename:
        process(filename)
Ejemplo n.º 5
0
    def __init__(self):
        self.input_manager = InputManager.get_instance()
        self.ui_manager = UIManager.get_instance()

        self.commands = {
            "open_file":
            Command(1, "Открыть файл", self.open_file),
            "open_files":
            Command("Infinity", "Открыть файлы", self.open_files),
            "open_directory":
            Command(1, "Открыть директорию", self.open_directory),
            "exit":
            Command(0, "Выйти из медиаплеера", self.exit),
            "bit_slower":
            Command(0, "Сделать скорость немного медленнее", self.bit_slower),
            "slower":
            Command(0, "Сделать скорость медленнее", self.slower),
            "normal_speed":
            Command(0, "Установить нормальную скорость", self.normal_speed),
            "bit_faster":
            Command(0, "Сделать скорость немного быстрее", self.bit_faster),
            "faster":
            Command(0, "Сделать скорость быстрее", self.faster),
            "forward_time":
            Command(0, "Совершить скачок вперед", self.forward_time),
            "backward_time":
            Command(0, "Совершить скачок назад", self.backward_time),
            "at_time":
            Command(3, "Перейти к заданному времени", self.at_time),
            "play":
            Command(0, "Начать воспроизведение", self.play),
            "pause":
            Command(0, "Поставить воспроизведение на паузу", self.pause),
            "stop":
            Command(0, "Остановить воспроизведение", self.stop),
            "backward_media":
            Command(0, "Перейти к предыдущему в плейлисте медиафайлу",
                    self.backward_media),
            "forward_media":
            Command(0, "Перейти к следующему в плейлисте медиафайлу",
                    self.forward_media),
            "increase_volume":
            Command(0, "Сделать громкость больше", self.increase_volume),
            "decrease_volume":
            Command(0, "Сделать громкость меньше", self.decrease_volume),
            "mute":
            Command(0, "Выключить звук", self.mute),
            "show_fullscreen":
            Command(0, "Перейти в полноэкранный режим", self.show_fullscreen)
        }
        self.daemons = []
Ejemplo n.º 6
0
class TimeTravelDialog(QDialog):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)

        self.init_ui()
        self.init_signals()

        self.input_manager = InputManager().get_instance()

    def init_ui(self):
        uic.loadUi("../time_travel_dialog.ui", self)

    def init_signals(self):
        self.reset_btn.clicked.connect(lambda: self.time_edit.clear())

        self.go_btn.clicked.connect(self.go_btn_slot)
        self.cancel_btn.clicked.connect(lambda: self.done(-1))

    def go_btn_slot(self):
        new_position = QTime(0, 0).secsTo(self.time_edit.time()) * 1000
        self.input_manager.set_position(new_position)

        self.done(0)
Ejemplo n.º 7
0
class PlaylistDialog(QDialog):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)

        self.input_manager = InputManager().get_instance()
        self.radio_categories = []

        self.init_ui()
        self.init_signals()

        self.current_page = None

    def init_ui(self):
        uic.loadUi("../playlist_dialog.ui", self)

        self.playlist_item = PlaylistTreeItem("Плейлист", self.chooser)
        self.mediateque_item = PlaylistTreeItem("Медиатека", self.chooser)

        self.computer_item = PlaylistTreeItem("Компьютер", self.chooser)

        self.video_item = PlaylistTreeItem("Видео", self.computer_item)
        self.music_item = PlaylistTreeItem("Музыка", self.computer_item)
        self.pictures_item = PlaylistTreeItem("Изображения",
                                              self.computer_item)

        self.devices_item = PlaylistTreeItem("Устройства", self.chooser)
        self.disks_item = PlaylistTreeItem("Диски", self.devices_item)

        self.internet_item = PlaylistTreeItem("Интернет", self.chooser)
        self.podcasts_item = PlaylistTreeItem("Подкасты", self.internet_item)

        self.radio_item = PlaylistTreeItem("Радио", self.internet_item)
        for category in self.input_manager.get_radio_categories():
            self.radio_categories.append(
                PlaylistTreeItem(category["name"], self.radio_item))

    def draw_page(self, item):
        self.current_page = item

        if item == self.radio_item:
            self.draw_radio_page()
        if item in self.radio_categories:
            self.draw_radio_page(category=item.text(0))

    def open_media(self, item):
        if self.current_page == self.radio_item or self.current_page in self.radio_categories:
            self.input_manager.add_media(item.url(), FILE_FORMAT.URL)
        self.input_manager.play()

    def draw_radio_page(self, category=None):
        if not category:
            stations = self.input_manager.get_radio_stations(limit=50)
        else:
            stations = self.input_manager.get_radio_stations(limit=50,
                                                             category=category)
        self.media_table.setRowCount(len(stations))
        for i, station in enumerate(stations):
            item = QRadioTableWidgetItem(f"{station['name']}",
                                         url=station["stream_url"])
            self.media_table.setItem(i, 0, item)

    def search(self):
        search_result = self.media_table.findItems(self.search_edit.text(),
                                                   Qt.MatchContains)
        to_show = [e.row() for e in search_result if e is not None]
        for row in range(0, self.media_table.rowCount()):
            if row in to_show:
                self.media_table.showRow(row)
            else:
                self.media_table.hideRow(row)

    def init_signals(self):
        self.chooser.itemActivated.connect(self.draw_page)
        self.media_table.itemDoubleClicked.connect(self.open_media)
        self.search_edit.editingFinished.connect(self.search)