def __init__(self, parent=None): super().__init__(parent) self.player = Player() self.resize(15, 15) self._current_mode = self.player.playback_mode self._set_mode()
class PlaymodeSwitchLabel(QLabel): def __init__(self, parent=None): super().__init__(parent) self.player = Player() self.resize(15, 15) self._current_mode = self.player.playback_mode self._set_mode() def _set_mode(self): if self._current_mode == 1: self.setPixmap( QPixmap(ICON_PATH + "single_repeat.png").scaled(self.size())) elif self._current_mode == 3: self.setPixmap( QPixmap(ICON_PATH + "repeat.png").scaled(self.size())) elif self._current_mode == 4: self.setPixmap( QPixmap(ICON_PATH + "random.png").scaled(self.size())) def _switch_mode(self): if self._current_mode == 4: self._current_mode = 1 elif self._current_mode == 1: self._current_mode = 3 elif self._current_mode == 3: self._current_mode = 4 self._set_mode() self.player.set_play_mode(self._current_mode) @pyqtSlot(int) def on_mode_changed(self, mode): LOG.info('current play mode is %d.' ' 1 for single in loop, 3 for loop, 4 for random' % mode) if mode != self._current_mode: self._current_mode = mode self._switch_mode() def mousePressEvent(self, event): self._switch_mode()
class PlaymodeSwitchLabel(QLabel): def __init__(self, parent=None): super().__init__(parent) self.player = Player() self.resize(15, 15) self._current_mode = self.player.playback_mode self._update_mode_icon() def _update_mode_icon(self): if self._current_mode == 1: self.setPixmap(QPixmap(ICON_PATH + "single_repeat.png").scaled(self.size())) elif self._current_mode == 3: self.setPixmap(QPixmap(ICON_PATH + "repeat.png").scaled(self.size())) elif self._current_mode == 4: self.setPixmap(QPixmap(ICON_PATH + "random.png").scaled(self.size())) def _switch_mode(self): if self._current_mode == 4: self._current_mode = 1 elif self._current_mode == 1: self._current_mode = 3 elif self._current_mode == 3: self._current_mode = 4 else: self._current_mode = 4 self._update_mode_icon() self.player.set_play_mode(self._current_mode) @pyqtSlot(int) def on_mode_changed(self, mode): LOG.info('current play mode is %d.' ' 1 for single in loop, 3 for loop, 4 for random' % mode) if mode != self._current_mode: self._current_mode = mode self._switch_mode() def mousePressEvent(self, event): self._switch_mode()
class PlaymodeSwitchLabel(QLabel): def __init__(self, parent=None): super().__init__(parent) self.player = Player() self.resize(15, 15) self._current_mode = self.player.playback_mode self._set_mode() def _set_mode(self): if self._current_mode == 1: self.setPixmap(QPixmap(ICON_PATH + "single_repeat.png").scaled(self.size())) elif self._current_mode == 3: self.setPixmap(QPixmap(ICON_PATH + "repeat.png").scaled(self.size())) elif self._current_mode == 4: self.setPixmap(QPixmap(ICON_PATH + "random.png").scaled(self.size())) def _switch_mode(self): if self._current_mode == 4: self._current_mode = 1 elif self._current_mode == 1: self._current_mode = 3 elif self._current_mode == 3: self._current_mode = 4 self._set_mode() self.player.set_play_mode(self._current_mode) @pyqtSlot(int) def on_mode_changed(self, mode): if mode != self._current_mode: self._current_mode = mode self._switch_mode() def mousePressEvent(self, event): self._switch_mode()
def __init__(self, parent=None): super().__init__(parent) ui = UiMainWidget() ViewOp.ui = ui ViewOp.controller = ControllerApi ui.setup_ui(self) engine = create_engine( 'sqlite:////%s' % DATABASE_SQLITE, connect_args={'check_same_thread': False}, echo=False) Base.metadata.create_all(engine) Session = sessionmaker() Session.configure(bind=engine) session = Session() LOG.info('db connected: %s' % DATABASE_SQLITE) ControllerApi.player = Player() ControllerApi.session = session ControllerApi.view = ViewOp ControllerApi.desktop_mini = DesktopMiniLayer() ControllerApi.lyric_widget = LyricWidget() ControllerApi.notify_widget = NotifyWidget() ControllerApi.network_manager = NetworkManager() ControllerApi.current_playlist_widget = MusicTableWidget() self._search_shortcut = QShortcut(QKeySequence('Ctrl+F'), self) self._minimize_shortcut = QShortcut(QKeySequence('Ctrl+M'), self) self._pre_focus = QShortcut(QKeySequence('Ctrl+['), self) self._next_focus = QShortcut(QKeySequence('Ctrl+]'), self) # self._switch_mode_shortcut = QShortcut(QKeySequence(Qt.Key_Escape), self) self.setAttribute(Qt.WA_MacShowFocusRect, False) self.setWindowIcon(QIcon(WINDOW_ICON)) self.setWindowTitle('FeelUOwn') self.resize(960, 600) self.mode_manager = ModesManger() self._init_signal_binding() app_event_loop = asyncio.get_event_loop() app_event_loop.call_later(1, self._init_plugins) app_event_loop.call_later(6, TipsManager.show_start_tip) asyncio.Task(VersionManager.check_release())