-
-
Notifications
You must be signed in to change notification settings - Fork 56
Only set wallpaper/theme when true #364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,22 +95,22 @@ def __init__(self): | |
| self._theme_dark = None | ||
|
|
||
| @property | ||
| def theme_light(self) -> str: | ||
| def theme_light(self) -> str | None: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should never be None, I'd rather return an empty string here |
||
| return self._theme_light | ||
|
|
||
| @theme_light.setter | ||
| def theme_light(self, value: str): | ||
| check_theme(value) | ||
| self._theme_light = value | ||
| if check_theme(value): | ||
| self._theme_light = value | ||
|
|
||
| @property | ||
| def theme_dark(self) -> str: | ||
| def theme_dark(self) -> str | None: | ||
| return self._theme_dark | ||
|
|
||
| @theme_dark.setter | ||
| def theme_dark(self, value: str): | ||
| check_theme(value) | ||
| self._theme_dark = value | ||
| if check_theme(value): | ||
| self._theme_dark = value | ||
|
|
||
| @property | ||
| def available(self) -> bool: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -239,17 +239,15 @@ def update_location(self): | |
| self.load_times() | ||
|
|
||
| def select_wallpaper(self, dark: bool): | ||
| message_light = self.tr('Open light wallpaper') | ||
| message_dark = self.tr('Open dark wallpaper') | ||
| file_name, _ = QFileDialog.getOpenFileName( | ||
| self, message_dark if dark else message_light, | ||
| self, self.tr(f'Open {"dark" if dark else "light"} wallpaper'), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. self.tr() gets translations for that message. Since different languages use different, grammar, we shouldn't do that |
||
| QStandardPaths.standardLocations(QStandardPaths.PicturesLocation)[0], | ||
| 'Images (*.png *.jpg *.jpeg *.JPG *.JPEG)') | ||
|
|
||
| group_wallpaper = self.ui.plugins_scroll_content.findChild(QtWidgets.QGroupBox, 'groupWallpaper') | ||
| inputs_wallpaper = group_wallpaper.findChildren(QtWidgets.QLineEdit) | ||
| i = 1 if dark else 0 | ||
| inputs_wallpaper[i].setText(file_name) | ||
| if file_name: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we should definitely handle empty strings better. I would say we should disable the plugin if no valid input was provided.
Other plugins with text input will have the same issue, so implementing it there makes sense. If
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just pushed an implementation for that to master. If any plugin has any theme with an empty string and is enabled, the user will see an error when saving. |
||
| group_wallpaper = self.ui.plugins_scroll_content.findChild(QtWidgets.QGroupBox, 'groupWallpaper') | ||
| inputs_wallpaper = group_wallpaper.findChildren(QtWidgets.QLineEdit) | ||
| inputs_wallpaper[1 if dark else 0].setText(file_name) | ||
|
|
||
| def select_color(self, dark: bool, initial_color: QColor): | ||
| selected_color = QColorDialog.getColor(initial_color) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't really like that syntax. I prefer to have one statement per line, that's less confusing to me.