|
7 | 7 | QHBoxLayout, |
8 | 8 | QPlainTextEdit, |
9 | 9 | QPushButton, |
| 10 | + QLineEdit, |
| 11 | + QLabel, |
10 | 12 | ) |
11 | 13 |
|
12 | 14 | from feeluown.i18n import t |
@@ -67,10 +69,47 @@ def __init__(self, app, *args, **kwargs): |
67 | 69 | self._app = app |
68 | 70 | self.lyric_btn = LyricButton(app, height=16) |
69 | 71 | self.watch_btn = WatchButton(app, height=16) |
70 | | - self._layout = QHBoxLayout(self) |
71 | | - self._layout.addWidget(self.lyric_btn) |
72 | | - self._layout.addWidget(self.watch_btn) |
73 | | - self._layout.addStretch(0) |
| 72 | + |
| 73 | + btn_layout = QHBoxLayout() |
| 74 | + btn_layout.addWidget(self.lyric_btn) |
| 75 | + btn_layout.addWidget(self.watch_btn) |
| 76 | + btn_layout.addStretch(0) |
| 77 | + |
| 78 | + standby_label = QLabel(t("standby-providers-label")) |
| 79 | + self.standby_edit = QLineEdit(self) |
| 80 | + self.standby_edit.setPlaceholderText(t("standby-providers-placeholder")) |
| 81 | + self._refresh_standby_edit() |
| 82 | + self.standby_edit.editingFinished.connect(self._on_standby_editing_finished) |
| 83 | + |
| 84 | + standby_layout = QHBoxLayout() |
| 85 | + standby_layout.addWidget(standby_label) |
| 86 | + standby_layout.addWidget(self.standby_edit) |
| 87 | + |
| 88 | + self._layout = QVBoxLayout(self) |
| 89 | + self._layout.addLayout(btn_layout) |
| 90 | + self._layout.addLayout(standby_layout) |
| 91 | + self._layout.setSpacing(5) |
| 92 | + self._layout.setContentsMargins(0, 0, 0, 0) |
| 93 | + |
| 94 | + def _refresh_standby_edit(self): |
| 95 | + val = self._app.config.PROVIDERS_STANDBY |
| 96 | + if val is None: |
| 97 | + self.standby_edit.setText("*") |
| 98 | + else: |
| 99 | + self.standby_edit.setText(",".join(val)) |
| 100 | + |
| 101 | + def _on_standby_editing_finished(self): |
| 102 | + text = self.standby_edit.text().strip() |
| 103 | + if not text: |
| 104 | + self._app.config.PROVIDERS_STANDBY = [] |
| 105 | + self._app.library.set_providers_standby([]) |
| 106 | + elif text == "*": |
| 107 | + self._app.config.PROVIDERS_STANDBY = None |
| 108 | + self._app.library.set_providers_standby(None) |
| 109 | + else: |
| 110 | + providers = [p.strip() for p in text.split(",") if p.strip()] |
| 111 | + self._app.config.PROVIDERS_STANDBY = providers |
| 112 | + self._app.library.set_providers_standby(providers) |
74 | 113 |
|
75 | 114 |
|
76 | 115 | class NetworkSettings(QWidget): |
|
0 commit comments