Fixed some embarassing bugs wrt to %s strings outside logging, & made theme selections persist between list rebuilds
This commit is contained in:
parent
95060f9bdd
commit
d3ee9d07e0
1 changed files with 42 additions and 43 deletions
|
@ -139,7 +139,7 @@ class ThemeManager(QtCore.QObject):
|
||||||
PchumLog.debug("(force_install is enabled)")
|
PchumLog.debug("(force_install is enabled)")
|
||||||
if not theme_name in self.database_entries:
|
if not theme_name in self.database_entries:
|
||||||
PchumLog.error("Theme %s does not exist in the database!", theme_name)
|
PchumLog.error("Theme %s does not exist in the database!", theme_name)
|
||||||
self.errored.emit("Theme %s does not exist in the database!", theme_name)
|
self.errored.emit("Theme %s does not exist in the database!" % theme_name)
|
||||||
return
|
return
|
||||||
|
|
||||||
all_themes = self.config.availableThemes()
|
all_themes = self.config.availableThemes()
|
||||||
|
@ -192,9 +192,8 @@ class ThemeManager(QtCore.QObject):
|
||||||
theme["inherits"],
|
theme["inherits"],
|
||||||
)
|
)
|
||||||
self.errored.emit(
|
self.errored.emit(
|
||||||
"Theme %s requires theme %s, which is not installed and not in the database. Cancelling install",
|
"Theme %s requires theme %s, which is not installed and not in the database. Cancelling install"
|
||||||
theme_name,
|
% (theme_name, theme["inherits"])
|
||||||
theme["inherits"],
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -214,8 +213,8 @@ class ThemeManager(QtCore.QObject):
|
||||||
theme_name,
|
theme_name,
|
||||||
)
|
)
|
||||||
self.errored.emit(
|
self.errored.emit(
|
||||||
"Theme %s is already installed, and no update is available. Cancelling install",
|
"Theme %s is already installed, and no update is available. Cancelling install"
|
||||||
theme_name,
|
% theme_name
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -252,7 +251,7 @@ class ThemeManager(QtCore.QObject):
|
||||||
"An error occured contacting the repository: %s", reply.error()
|
"An error occured contacting the repository: %s", reply.error()
|
||||||
)
|
)
|
||||||
self.errored.emit(
|
self.errored.emit(
|
||||||
"An error occured contacting the repository: %s", reply.error()
|
"An error occured contacting the repository: %s" % reply.error()
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
|
@ -297,13 +296,13 @@ class ThemeManager(QtCore.QObject):
|
||||||
|
|
||||||
except json.decoder.JSONDecodeError as e:
|
except json.decoder.JSONDecodeError as e:
|
||||||
PchumLog.error("Could not decode theme database JSON: %s", e)
|
PchumLog.error("Could not decode theme database JSON: %s", e)
|
||||||
self.errored.emit("Could not decode theme database JSON: %s", e)
|
self.errored.emit("Could not decode theme database JSON: %s" % e)
|
||||||
return
|
return
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
self.database = {}
|
self.database = {}
|
||||||
self.database_entries = {}
|
self.database_entries = {}
|
||||||
PchumLog.error("Vital key missing from theme database: %s", e)
|
PchumLog.error("Vital key missing from theme database: %s", e)
|
||||||
self.errored.emit("Vital key missing from theme database: %s", e)
|
self.errored.emit("Vital key missing from theme database: %s" % e)
|
||||||
return
|
return
|
||||||
|
|
||||||
def _handle_downloaded_zip(self, zip_buffer, theme_name):
|
def _handle_downloaded_zip(self, zip_buffer, theme_name):
|
||||||
|
@ -485,38 +484,32 @@ class ThemeManagerWidget(QtWidgets.QWidget):
|
||||||
self.btn_uninstall.setVisible(themeManager.is_installed(theme_name))
|
self.btn_uninstall.setVisible(themeManager.is_installed(theme_name))
|
||||||
|
|
||||||
self.lbl_theme_name.setText(theme_name)
|
self.lbl_theme_name.setText(theme_name)
|
||||||
self.lbl_author_name.setText("By %s", theme["author"])
|
self.lbl_author_name.setText("By %s" % theme["author"])
|
||||||
self.lbl_description.setText(theme["description"])
|
self.lbl_description.setText(theme["description"])
|
||||||
version_text = "Version %s", theme["version"]
|
version_text = "Version %s" % theme["version"]
|
||||||
if has_update:
|
if has_update:
|
||||||
version_text += (
|
version_text += (
|
||||||
" (installed: %s)",
|
" (installed: %s)" % themeManager.manifest[theme_name]["version"]
|
||||||
themeManager.manifest[theme_name]["version"],
|
|
||||||
)
|
)
|
||||||
self.lbl_version.setText(version_text)
|
self.lbl_version.setText(version_text)
|
||||||
self.lbl_requires.setText(
|
requires_text = ""
|
||||||
(
|
if theme["inherits"]:
|
||||||
"Requires %s",
|
requires_text += "Requires %s" % theme["inherits"]
|
||||||
theme["inherits"]
|
if theme["inherits"] in self.config.availableThemes():
|
||||||
+ (
|
requires_text += " (installed)"
|
||||||
" (installed)"
|
self.lbl_requires.setText((requires_text) if theme["inherits"] else "")
|
||||||
if theme["inherits"] in self.config.availableThemes()
|
last_update_text = "Released on: "
|
||||||
else ""
|
last_update_text += datetime.fromtimestamp(theme["updated"]).strftime(
|
||||||
),
|
"%d/%m/%Y, %H:%M"
|
||||||
)
|
|
||||||
if theme["inherits"]
|
|
||||||
else ""
|
|
||||||
)
|
|
||||||
self.lbl_last_update.setText(
|
|
||||||
"Released on: "
|
|
||||||
+ datetime.fromtimestamp(theme["updated"]).strftime("%d/%m/%Y, %H:%M")
|
|
||||||
)
|
)
|
||||||
|
self.lbl_last_update.setText(last_update_text)
|
||||||
|
|
||||||
@QtCore.pyqtSlot(dict)
|
@QtCore.pyqtSlot(dict)
|
||||||
def _on_database_refreshed(self, _):
|
def _on_database_refreshed(self, _):
|
||||||
self.rebuild()
|
self.rebuild()
|
||||||
|
|
||||||
def rebuild(self):
|
def rebuild(self):
|
||||||
|
prev_selected_index = self.list_results.currentRow()
|
||||||
database = themeManager.database
|
database = themeManager.database
|
||||||
self.list_results.clear()
|
self.list_results.clear()
|
||||||
self.lbl_error.setText("")
|
self.lbl_error.setText("")
|
||||||
|
@ -538,23 +531,29 @@ class ThemeManagerWidget(QtWidgets.QWidget):
|
||||||
else:
|
else:
|
||||||
status = "~ (installed)"
|
status = "~ (installed)"
|
||||||
icon = self.icons[1]
|
icon = self.icons[1]
|
||||||
text = "%s by %s %s", (dbitem["name"], dbitem["author"], status)
|
text = "%s by %s %s" % (dbitem["name"], dbitem["author"], status)
|
||||||
item = QtWidgets.QListWidgetItem(icon, text)
|
item = QtWidgets.QListWidgetItem(icon, text)
|
||||||
self.list_results.addItem(item)
|
self.list_results.addItem(item)
|
||||||
|
|
||||||
self.btn_install.setDisabled(True)
|
if prev_selected_index > -1:
|
||||||
for lbl in [
|
# Re-select last item, if it was selected
|
||||||
self.lbl_author_name,
|
self.list_results.setCurrentRow(prev_selected_index)
|
||||||
self.lbl_description,
|
self._on_theme_selected(self.list_results.currentItem())
|
||||||
self.lbl_version,
|
else:
|
||||||
self.lbl_requires,
|
# Return sidebar info panel to defaults if nothing was selected
|
||||||
self.lbl_last_update,
|
self.btn_install.setDisabled(True)
|
||||||
]:
|
for lbl in [
|
||||||
lbl.setText("")
|
self.lbl_author_name,
|
||||||
self.lbl_theme_name.setText("Click a theme to get started")
|
self.lbl_description,
|
||||||
self.btn_uninstall.setVisible(False)
|
self.lbl_version,
|
||||||
self.btn_install.setVisible(True)
|
self.lbl_requires,
|
||||||
self.btn_install.setDisabled(True)
|
self.lbl_last_update,
|
||||||
|
]:
|
||||||
|
lbl.setText("")
|
||||||
|
self.lbl_theme_name.setText("Click a theme to get started")
|
||||||
|
self.btn_uninstall.setVisible(False)
|
||||||
|
self.btn_install.setVisible(True)
|
||||||
|
self.btn_install.setDisabled(True)
|
||||||
|
|
||||||
self.rebuilt.emit()
|
self.rebuilt.emit()
|
||||||
PchumLog.debug("Rebuilt emitted")
|
PchumLog.debug("Rebuilt emitted")
|
||||||
|
|
Loading…
Reference in a new issue