mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
load and store last projects is more secure
This commit is contained in:
parent
07abf855dd
commit
72ec36239b
2 changed files with 38 additions and 17 deletions
|
|
@ -34,7 +34,12 @@ class Window(QtWidgets.QDialog):
|
||||||
self._db = AvalonMongoDB()
|
self._db = AvalonMongoDB()
|
||||||
self._db.install()
|
self._db.install()
|
||||||
|
|
||||||
self._settings = QtCore.QSettings("pypeclub", "StandalonePublisher")
|
try:
|
||||||
|
settings = QtCore.QSettings("pypeclub", "StandalonePublisher")
|
||||||
|
except Exception:
|
||||||
|
settings = None
|
||||||
|
|
||||||
|
self._settings = settings
|
||||||
|
|
||||||
self.pyblish_paths = pyblish_paths
|
self.pyblish_paths = pyblish_paths
|
||||||
|
|
||||||
|
|
@ -46,9 +51,7 @@ class Window(QtWidgets.QDialog):
|
||||||
self.valid_parent = False
|
self.valid_parent = False
|
||||||
|
|
||||||
# assets widget
|
# assets widget
|
||||||
widget_assets = AssetWidget(
|
widget_assets = AssetWidget(self._db, settings, self)
|
||||||
self._settings, dbcon=self._db, parent=self
|
|
||||||
)
|
|
||||||
|
|
||||||
# family widget
|
# family widget
|
||||||
widget_family = FamilyWidget(dbcon=self._db, parent=self)
|
widget_family = FamilyWidget(dbcon=self._db, parent=self)
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ class AssetWidget(QtWidgets.QWidget):
|
||||||
current_changed = QtCore.Signal() # on view current index change
|
current_changed = QtCore.Signal() # on view current index change
|
||||||
task_changed = QtCore.Signal()
|
task_changed = QtCore.Signal()
|
||||||
|
|
||||||
def __init__(self, settings, dbcon, parent=None):
|
def __init__(self, dbcon, settings, parent=None):
|
||||||
super(AssetWidget, self).__init__(parent=parent)
|
super(AssetWidget, self).__init__(parent=parent)
|
||||||
self.setContentsMargins(0, 0, 0, 0)
|
self.setContentsMargins(0, 0, 0, 0)
|
||||||
|
|
||||||
|
|
@ -238,6 +238,34 @@ class AssetWidget(QtWidgets.QWidget):
|
||||||
output.extend(self.get_parents(parent))
|
output.extend(self.get_parents(parent))
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
def _get_last_projects(self):
|
||||||
|
if not self._settings:
|
||||||
|
return []
|
||||||
|
|
||||||
|
project_names = []
|
||||||
|
for project_name in self._settings.value("projects", "").split("|"):
|
||||||
|
if project_name:
|
||||||
|
project_names.append(project_name)
|
||||||
|
return project_names
|
||||||
|
|
||||||
|
def _add_last_project(self, project_name):
|
||||||
|
if not self._settings:
|
||||||
|
return
|
||||||
|
|
||||||
|
last_projects = []
|
||||||
|
for _project_name in self._settings.value("projects", "").split("|"):
|
||||||
|
if _project_name:
|
||||||
|
last_projects.append(_project_name)
|
||||||
|
|
||||||
|
if project_name in last_projects:
|
||||||
|
last_projects.remove(project_name)
|
||||||
|
|
||||||
|
last_projects.insert(0, project_name)
|
||||||
|
while len(last_projects) > 5:
|
||||||
|
last_projects.pop(-1)
|
||||||
|
|
||||||
|
self._settings.setValue("projects", "|".join(last_projects))
|
||||||
|
|
||||||
def _set_projects(self):
|
def _set_projects(self):
|
||||||
project_names = list()
|
project_names = list()
|
||||||
for project in self.dbcon.projects():
|
for project in self.dbcon.projects():
|
||||||
|
|
@ -253,9 +281,8 @@ class AssetWidget(QtWidgets.QWidget):
|
||||||
sorted_project_names = list(sorted(project_names))
|
sorted_project_names = list(sorted(project_names))
|
||||||
self.combo_projects.addItems(list(sorted(sorted_project_names)))
|
self.combo_projects.addItems(list(sorted(sorted_project_names)))
|
||||||
|
|
||||||
last_projects = self._settings.value("projects", "")
|
|
||||||
last_project = sorted_project_names[0]
|
last_project = sorted_project_names[0]
|
||||||
for project_name in last_projects.split("|"):
|
for project_name in self._get_last_projects():
|
||||||
if project_name in sorted_project_names:
|
if project_name in sorted_project_names:
|
||||||
last_project = project_name
|
last_project = project_name
|
||||||
break
|
break
|
||||||
|
|
@ -272,16 +299,7 @@ class AssetWidget(QtWidgets.QWidget):
|
||||||
project_name = self.combo_projects.currentText()
|
project_name = self.combo_projects.currentText()
|
||||||
if project_name in projects:
|
if project_name in projects:
|
||||||
self.dbcon.Session["AVALON_PROJECT"] = project_name
|
self.dbcon.Session["AVALON_PROJECT"] = project_name
|
||||||
last_projects = [
|
self._add_last_project(project_name)
|
||||||
value
|
|
||||||
for value in self._settings.value("projects", "").split("|")
|
|
||||||
]
|
|
||||||
if project_name in last_projects:
|
|
||||||
last_projects.remove(project_name)
|
|
||||||
last_projects.insert(0, project_name)
|
|
||||||
while len(last_projects) > 5:
|
|
||||||
last_projects.pop(-1)
|
|
||||||
self._settings.setValue("projects", "|".join(last_projects))
|
|
||||||
|
|
||||||
self.project_changed.emit(project_name)
|
self.project_changed.emit(project_name)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue