def __init__(self, config=None): super().__init__() self._widgetConfig = config or self.getWidgetConfigClass( ).getDefaultObject() self._app = App.instance() self._updateRate = 20 self._refreshRate = 60 self._sampleMillis = 33 self._logger = logging.getLogger("spectrumWidget") self._logger.setLevel(logging.INFO) self._player = App.instance().getPlayer() self._thresholds = [] self._values = [] self._smooths = [] self._random = random.Random() self._helper = FftHelper() self._loadConfig() self._updateTimer = QtCore.QTimer(self) self._updateTimer.timeout.connect(self._onTick) self._updateTimer.start(1000 // self._updateRate) self._repaintTimer = QtCore.QTimer(self) self._repaintTimer.timeout.connect(self._doSmooth) self._repaintTimer.timeout.connect(self.repaint) self._repaintTimer.start(1000 // self._refreshRate) self.setFont(QtGui.QFont("", 10)) self.widgetConfigChanged.connect(self._onWidgetConfigChanged) self.setContextMenuPolicy( QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.customContextMenuRequested.connect( self._onCustomContextMenuRequested) self.setPalette( Just.of(self.palette()).apply( lambda x: x.setColor(QtGui.QPalette.ColorRole.Window, QtGui.QColor("white"))).value())
def __init__(self): super().__init__(QtWidgets.QApplication.activeWindow()) self._logger = logging.getLogger("configDialog") self._app = App.instance() self._config = App.instance().getConfig() self._applicationFontLabel = QtWidgets.QLabel( tt.Config_ApplicationFont) self._applicationFontButton = QtWidgets.QPushButton() self._applicationFontButton.setText( FontUtils.digestFont(self._config.applicationFont)) self._applicationFontPreviewLabel = QtWidgets.QLabel( tt.Config_QuickBrownFox) self._applicationFontPreviewLabel.setFont(self._config.applicationFont) applicationFontLayout = QtWidgets.QVBoxLayout() applicationFontLayout.addWidget(self._applicationFontButton) applicationFontLayout.addWidget(self._applicationFontPreviewLabel) self._buttonBox = WidgetUtils.createButtonBox(ok=True, cancel=True, apply=True) mainLayout = QtWidgets.QGridLayout() mainLayout.setColumnStretch(0, 1) mainLayout.setColumnStretch(1, 2) mainLayout.addWidget(self._applicationFontLabel) mainLayout.addLayout(applicationFontLayout, mainLayout.rowCount() - 1, mainLayout.columnCount() - 1) mainLayout.addWidget(WidgetUtils.createExpandingSpacer(), mainLayout.rowCount(), 0, 1, 2) mainLayout.addWidget(self._buttonBox, mainLayout.rowCount(), 0, 1, 2) self._applicationFontButton.clicked.connect( self._onApplicationFontButtonClicked) self._buttonBox.clicked.connect(self._onButtonBoxClicked) self.setLayout(mainLayout) self.resize(854, 480)
def __init__(self, parent: MainWindow): super().__init__() self._logger = logging.getLogger("menuToolbar") self._app = App.instance() self._config = self._app.getConfig() self._mainWindow = parent self._player = App.instance().getPlayer() self._playlistService = App.instance().getPlaylistService() self._configService = App.instance().getConfigService() self._pluginService = App.instance().getPluginService() self._setupView() self._refreshView() self._setupEvents()
def __init__(self, parent): super().__init__(parent) self._logger = logging.getLogger("controllerToolbar") self._player = App.instance().getPlayer() self._setupView() self._refreshView() self._setupEvents()
def getPluginConfig(cls) -> JsonSupport: from IceSpringMusicPlayer.app import App plugins = App.instance().getConfig().plugins for plugin in plugins: if plugin.clazz == cls: return plugin.config raise RuntimeError("Impossible")
def getDefaultConfig(cls) -> Config: from IceSpringMusicPlayer.app import App plugins = [] for clazz in App.instance().getPluginService().getPluginClasses(): plugins.append( Plugin(clazz=clazz, disabled=False, config=clazz.getPluginConfigClass().getDefaultObject())) return Config(language="en_US", geometry=b"", state=b"", toolbars=[ Toolbar(clazz=MenuToolbar, movable=False), Toolbar(clazz=ControllerToolbar, movable=False), Toolbar(clazz=VolumeToolbar, movable=False), Toolbar(clazz=PlaylistToolbar, movable=False), Toolbar(clazz=ProgressToolbar, movable=False), ], iconSize=48, applicationFont=QtWidgets.QApplication.font(), lyricFont=QtWidgets.QApplication.font(), volume=50, playbackMode=PlaybackMode.LOOP, frontPlaylistIndex=-1, layout=cls.getDefaultLayout(), plugins=plugins, playlists=Vector())
def __init__(self): super().__init__() self._logger = logging.getLogger("pluginManagerWidget") self._app = App.instance() self._pluginService = self._app.getPluginService() self._plugins = self._app.getConfig().plugins self._table = IceTableView() self._model = PluginManagerModel(self._plugins, self._table) self._table.setModel(self._model) self._table.setColumnWidth(0, 200) self._nameLabel = HumanLabel() self._versionLabel = HumanLabel() self._idLabel = HumanLabel() self._statusLabel = HumanLabel() self._systemLabel = HumanLabel() formLayout = QtWidgets.QFormLayout() formLayout.setMargin(10) formLayout.addRow("ID:", self._idLabel) formLayout.addWidget( Just.of(QtWidgets.QWidget()).apply( lambda x: x.setFixedHeight(5)).value()) formLayout.addRow("Name:", self._nameLabel) formLayout.addWidget( Just.of(QtWidgets.QWidget()).apply( lambda x: x.setFixedHeight(5)).value()) formLayout.addRow("Version:", self._versionLabel) formLayout.addWidget( Just.of(QtWidgets.QWidget()).apply( lambda x: x.setFixedHeight(5)).value()) formLayout.addRow("Status:", self._statusLabel) formLayout.addWidget( Just.of(QtWidgets.QWidget()).apply( lambda x: x.setFixedHeight(5)).value()) formLayout.addRow("System:", self._systemLabel) widget = QtWidgets.QWidget() widget.setLayout(formLayout) self.addWidget(self._table) self.addWidget(widget) self.setHandleWidth(2) self.setSizes((2**16 * 2, 2**16)) for i in range(self.count()): self.handle(i).setPalette( Just.of(QtGui.QPalette()).apply( lambda x: x.setColor(QtGui.QPalette.ColorRole.Window, QtGui.QColor("#EEEEEE"))).value()) self._table.setSelectionMode( QtWidgets.QAbstractItemView.SelectionMode.SingleSelection) self._table.setContextMenuPolicy( QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self._table.selectionModel().currentRowChanged.connect( self._onCurrentRowChanged) self._app.languageChanged.connect(self._onLanguageChanged) self._pluginService.pluginEnabled.connect(self._onPluginStateChanged) self._pluginService.pluginDisabled.connect(self._onPluginStateChanged) self._pluginService.pluginsInserted.connect(self._onPluginsInserted) self._pluginService.pluginsRemoved.connect(self._onPluginsRemoved) self._table.customContextMenuRequested.connect( self._onCustomContextMenuRequested) self._table.selectRow(0)
def __init__(self, pluginService: PluginService, parent: QtCore.QObject = None): super().__init__(parent) self._logger = logging.getLogger("configService") self._app = App.instance() self._pluginService = pluginService self._config = self._loadConfig()
def __init__(self, parent): super().__init__(parent) self._logger = logging.getLogger("volumeToolbar") self._app = App.instance() self._player = self._app.getPlayer() self._setupView() self._refreshView() self._setupEvents()
def __init__(self, vertical=False, children=0): orientation = QtCore.Qt.Orientation.Vertical if vertical else QtCore.Qt.Orientation.Horizontal super().__init__(orientation) self._app = App.instance() self.setHandleWidth(2) for _ in range(children): self.addWidget(BlankWidget()) self.setSizes([2 ** 16 for _ in range(children)])
def __init__(self, parent): super().__init__(parent) self._logger = logging.getLogger("progressToolbar") self._logger.setLevel(logging.INFO) self._app = App.instance() self._player = self._app.getPlayer() self._setupView() self._refreshView() self._setupEvents()
def __init__(self): super().__init__() self._app = App.instance() self.setLayout(QtWidgets.QGridLayout(self)) self._label = QtWidgets.QLabel() self._label.setAlignment(gg(QtCore.Qt.AlignmentFlag.AlignCenter)) self.layout().addWidget(self._label) self._refreshView() self._app.languageChanged.connect(self._refreshView)
def __init__(self, parent: QtWidgets.QMainWindow) -> None: super().__init__(parent) self._parent = parent self._app = App.instance() self._replaceable = None self.setContextMenuPolicy( QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.customContextMenuRequested.connect( self._onCustomContextMenuRequested) self.setGeometry(parent.centralWidget().geometry())
def __init__(self, parent): super().__init__(parent) self._app = App.instance() self._player = self._app.getPlayer() self._logger = logging.getLogger("playlistToolbar") self._setupView() self._refreshView() self._app.languageChanged.connect(self._refreshView) self._player.frontPlaylistIndexChanged.connect(self._refreshView) self._player.playlistInserted.connect(self._refreshView) self._player.playlistsRemoved.connect(self._refreshView)
def __init__(self) -> None: super().__init__() self._logger = logging.getLogger("playlistManagerWidget") self._player = App.instance().getPlayer() self.setModel(PlaylistManagerModel(self)) self.setColumnWidth(0, 320) self.doubleClicked.connect(self._onDoubleClicked) self.setContextMenuPolicy( QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.customContextMenuRequested.connect( self._onCustomContextMenuRequested) self._player.playlistInserted.connect(self._onPlaylistInserted)
def __init__(self, config, parent) -> None: super().__init__() self._widgetConfig = config self._parent = gg(parent) self._logger = logging.getLogger("playlistTable") self._app = App.instance() self._player = App.instance().getPlayer() self._playlistService = self._app.getPlaylistService() self.setModel(PlaylistModel(self)) self.setColumnWidth(0, int(35 * self._app.getZoom())) self.setColumnWidth(1, int(150 * self._app.getZoom())) self.doubleClicked.connect(self._onDoubleClicked) self.setIconSize(QtCore.QSize(32, 32) * self._app.getZoom()) self.horizontalHeader().setSortIndicator( -1, QtCore.Qt.SortOrder.AscendingOrder) self.setWordWrap(False) self.setSortingEnabled(True) self.setContextMenuPolicy( QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.customContextMenuRequested.connect( self._onCustomContextMenuRequested) self.selectionModel().selectionChanged.connect( self._onSelectionChanged) self._app.requestLocateCurrentMusic.connect( self._onRequestLocateCurrentMusic) self._player.stateChanged.connect(self._onPlayerStateChanged) self._player.frontPlaylistIndexAboutToBeChanged.connect( self._onFrontPlaylistIndexAboutToBeChanged) self._player.frontPlaylistIndexChanged.connect( self._onFrontPlaylistIndexChanged) self._player.selectedMusicIndexesChanged.connect( self._onSelectedMusicIndexesChanged) self._player.currentMusicIndexChanged.connect( self._onCurrentMusicIndexChanged) self._player.musicsInserted.connect(self._onMusicsInserted) self._player.musicsRemoved.connect(self._onMusicsRemoved) self._player.musicsSorted.connect(self._onMusicsSorted) self._selectAndFollowMusics(self._player.getSelectedMusicIndexes()) self._loadConfig() self._parent.widgetConfigChanged.connect(self._onWidgetConfigChanged)
def __init__(self): super().__init__() self._toolbarClasses = [MenuToolbar, ControllerToolbar, VolumeToolbar, PlaylistToolbar, ProgressToolbar] self._logger = logging.getLogger("mainWindow") self._positionLogger = logging.getLogger("position") self._positionLogger.setLevel(logging.INFO) self._app = App.instance() self._playlistService = self._app.getPlaylistService() self._pluginService = self._app.getPluginService() self._configService = self._app.getConfigService() self._config = App.instance().getConfig() self._player = App.instance().getPlayer() self._layoutEditing = False self._maskWidget = None self._initPalette() self._loadConfig() self._initStatusBar() self.layoutChanged.connect(self._onLayoutChanged) self.layoutEditingChanged.connect(self._onLayoutEditingChanged) self._playlistService.musicParsed.connect(self._onMusicParsed) self._player.positionChanged.connect(self._onPlayerPositionChanged) self._player.currentMusicIndexChanged.connect(self._onMusicIndexChanged) self._app.aboutToPersistConfig.connect(self._onAboutToPersistConfig)
def __init__(self, config=None) -> None: super().__init__() self._widgetConfig = config or self.getWidgetConfigClass( ).getDefaultObject() self._logger = logging.getLogger("playlistWidget") self._player = App.instance().getPlayer() self._tabBar = QtWidgets.QTabBar() self._tabBar.setSizePolicy(QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Maximum) self._playlistTable = PlaylistTable(self._widgetConfig, self) mainLayout = QtWidgets.QVBoxLayout() mainLayout.addWidget(self._tabBar) mainLayout.addWidget(self._playlistTable) mainLayout.setMargin(0) self.setLayout(mainLayout) self._tabBar.currentChanged.connect(self._onTabBarCurrentChanged) self.widgetConfigChanged.connect(self._onWidgetConfigChanged) self._player.frontPlaylistIndexChanged.connect( self._onFrontPlaylistIndexChanged) self._refreshTabBar()
def __init__(self, parent: QtCore.QObject): super().__init__(parent) self._logger = logging.getLogger("player") self._config = App.instance().getConfig() self._playbackMode = self._config.playbackMode self._playlists = self._config.playlists self._frontPlaylistIndex = self._config.frontPlaylistIndex self._currentPlaylistIndex = self._config.frontPlaylistIndex self._currentMusicIndex = -1 self._histories = dict() self._historyPosition = -1 self._playedCount = 0 self._isStoppedByTime = False self._sampleWidth = 0 self._samples = array.array('i') self._proxy = PatchedMediaPlayer() self._proxy.setVolume(50) self._proxy.stateChanged.connect(self._onProxyStateChanged) self._proxy.durationChanged.connect(self._onProxyDurationChanged) self._proxy.positionChanged.connect(self._onProxyPositionChanged)
def __init__(self, config=None): super().__init__() self._logger = logging.getLogger("demoWidget") self._app = App.instance() self._pluginConfig = DemoPlugin.getPluginConfig() self._widgetConfig = config or self.getWidgetConfigClass().getDefaultObject() self._pluginCounterLabel = QtWidgets.QLabel() self._widgetCounterLabel = QtWidgets.QLabel() layout = QtWidgets.QVBoxLayout() layout.setSpacing(15) layout.addStretch() layout.addWidget(self._pluginCounterLabel, 0, gg(QtCore.Qt.AlignCenter)) layout.addWidget(self._widgetCounterLabel, 0, gg(QtCore.Qt.AlignCenter)) layout.addStretch() self.setLayout(layout) DemoPlugin.pluginConfigChanged.connect(self._onPluginConfigChanged) self.widgetConfigChanged.connect(self._onWidgetConfigChanged) self._app.languageChanged.connect(self.onLanguageChanged) self.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.customContextMenuRequested.connect(self._onCustomContextMenuRequested) self._refreshWidget()
def __init__(self, config=None): super().__init__() self._widgetConfig = config or LyricsWidgetConfig.getDefaultObject() self._logger = logging.getLogger("lyricsWidget") self._logger.setLevel(logging.INFO) self._app = App.instance() self._player = self._app.getPlayer() self._lyrics: typing.Dict[int, str] = dict() self._prevLyricIndex = -1 self._timer = QtCore.QTimer() self._loadConfig() self._setupView() self._resetLayout() self._setupLyrics() self.horizontalScrollBar().rangeChanged.connect( lambda *args, bar=self.horizontalScrollBar(): bar.setValue((bar.maximum() + bar.minimum()) // 2)) self.customContextMenuRequested.connect(self._onCustomContextMenuRequested) self.widgetConfigChanged.connect(self._onWidgetConfigChanged) self._player.stateChanged.connect(self.onPlayerStateChanged) self._player.currentMusicIndexChanged.connect(self._onCurrentMusicIndexChanged) self._player.positionChanged.connect(self._onTick) self._timer.timeout.connect(self._onTick)
def __init__(self) -> None: super().__init__() self._app = App.instance() self._logger = logging.getLogger("demoPluginConfigWidget") self._pluginConfig = DemoPlugin.getPluginConfig() decreaseButton = QtWidgets.QPushButton("Decrease") increaseButton = QtWidgets.QPushButton("Increase") self._pluginCounterLabel = QtWidgets.QLabel() layout = QtWidgets.QVBoxLayout() layout.setSpacing(15) layout.addStretch() layout.addWidget(decreaseButton, 0, gg(QtCore.Qt.AlignCenter)) layout.addWidget(self._pluginCounterLabel, 0, gg(QtCore.Qt.AlignCenter)) layout.addWidget(increaseButton, 0, gg(QtCore.Qt.AlignCenter)) layout.addStretch() self.setLayout(layout) increaseButton.clicked.connect(self._onIncreaseButtonClicked) decreaseButton.clicked.connect(self._onDecreaseButtonClicked) DemoPlugin.pluginConfigChanged.connect(self._onPluginConfigChanged) self._app.languageChanged.connect(self._onLanguageChanged) self._refreshWidget()
def __init__(self, parent: QtCore.QObject = None): super().__init__(parent) self._logger = logging.getLogger("playlistService") self._player = App.instance().getPlayer()
def __init__(self, parent: QtCore.QObject) -> None: super().__init__(parent) self._logger = logging.getLogger("playlistModel") self._app = App.instance() self._player = App.instance().getPlayer() self._app.languageChanged.connect(self._onLanguageChanged)
def __init__(self, parent: QtCore.QObject) -> None: super().__init__(parent) self._player = App.instance().getPlayer()
def __init__(self, config=None) -> None: super().__init__() self._widgetConfig = config or self.getWidgetConfigClass( ).getDefaultObject() self._logger = logging.getLogger("controlsWidget") self._config = App.instance().getConfig() self._app = App.instance() self._player = App.instance().getPlayer() layout = QtWidgets.QHBoxLayout(self) layout.setSpacing(5) playButton = QtWidgets.QToolButton(self) playButton.setIcon(qtawesome.icon("mdi.play")) playButton.clicked.connect(self._onPlayButtonClicked) stopButton = QtWidgets.QToolButton(self) stopButton.setIcon(qtawesome.icon("mdi.stop")) stopButton.clicked.connect(self._onStopButtonClicked) previousButton = QtWidgets.QToolButton(self) previousButton.setIcon(qtawesome.icon("mdi.step-backward")) previousButton.clicked.connect(self._onPlayPreviousButtonClicked) nextButton = QtWidgets.QToolButton(self) nextButton.setIcon(qtawesome.icon("mdi.step-forward")) nextButton.clicked.connect(self._onPlayNextButtonClicked) playbackButton = QtWidgets.QToolButton(self) playbackButton.setIcon(qtawesome.icon("mdi.repeat")) playbackButton.clicked.connect(self._onPlaybackButtonClicked) for button in playButton, stopButton, previousButton, nextButton, playbackButton: button.setAutoRaise(True) progressSlider = FluentSlider(QtCore.Qt.Orientation.Horizontal, self) progressSlider.valueChanged.connect(self._onProgressSliderValueChanged) progressLabel = QtWidgets.QLabel("00:00/00:00", self) volumeDial = QtWidgets.QDial(self) volumeDial.valueChanged.connect(self._onVolumeDialValueChanged) layout.addWidget(playButton) layout.addWidget(stopButton) layout.addWidget(previousButton) layout.addWidget(nextButton) layout.addWidget(progressSlider) layout.addWidget(progressLabel) layout.addWidget(playbackButton) layout.addWidget(volumeDial) self._playButton = playButton self._playbackButton = playbackButton self._progressSlider = progressSlider self._progressLabel = progressLabel self._volumeDial = volumeDial self._refreshIcons() self._refreshView() self._player.currentMusicIndexChanged.connect( self._onCurrentMusicIndexChanged) self._player.stateChanged.connect(self._onPlayerStateChanged) self._player.durationChanged.connect(self._onPlayerDurationChanged) self._player.positionChanged.connect(self._onPlayerPositionChanged) self._player.playbackModeChanged.connect(self._onPlaybackModeChanged) self._player.volumeChanged.connect(self._onPlayerVolumeChanged) self.widgetConfigChanged.connect(self._onWidgetConfigChanged) self.setContextMenuPolicy( QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.customContextMenuRequested.connect( self._onCustomContextMenuRequested) self.setPalette( Just.of(self.palette()).apply( lambda x: x.setColor(QtGui.QPalette.ColorRole.Window, QtGui.QColor("white"))).value())
def __init__(self, parent: QtCore.QObject = None): super().__init__(parent) self._logger = logging.getLogger("pluginService") self._app = App.instance()