mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-10 06:41:54 +02:00
[ui] ScriptEditorManager: Added properties to get if we have history of scripts
hasPreviousScript and hasNextScript are getters for history if that is available
This commit is contained in:
parent
a90d5c4d38
commit
9fa772442d
1 changed files with 20 additions and 0 deletions
|
@ -44,6 +44,18 @@ class ScriptEditorManager(QObject):
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
settings.beginGroup(self._GROUP)
|
settings.beginGroup(self._GROUP)
|
||||||
return settings.value(self._KEY)
|
return settings.value(self._KEY)
|
||||||
|
|
||||||
|
def _hasPreviousScript(self):
|
||||||
|
""" Returns whether there is a previous script available.
|
||||||
|
"""
|
||||||
|
# If the current index is greater than the first
|
||||||
|
return self._index > 0
|
||||||
|
|
||||||
|
def _hasNextScript(self):
|
||||||
|
""" Returns whethere there is a new script available to load.
|
||||||
|
"""
|
||||||
|
# If the current index is lower than the available indexes
|
||||||
|
return self._index < (len(self._history) - 1)
|
||||||
|
|
||||||
# Public
|
# Public
|
||||||
@Slot(str, result=str)
|
@Slot(str, result=str)
|
||||||
|
@ -74,6 +86,7 @@ class ScriptEditorManager(QObject):
|
||||||
# Add the script to the history and move up the index to the top of history stack
|
# Add the script to the history and move up the index to the top of history stack
|
||||||
self._history.append(script)
|
self._history.append(script)
|
||||||
self._index = len(self._history)
|
self._index = len(self._history)
|
||||||
|
self.scriptIndexChanged.emit()
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -89,6 +102,7 @@ class ScriptEditorManager(QObject):
|
||||||
If there is no next entry, return an empty string. """
|
If there is no next entry, return an empty string. """
|
||||||
if self._index + 1 < len(self._history) and len(self._history) > 0:
|
if self._index + 1 < len(self._history) and len(self._history) > 0:
|
||||||
self._index = self._index + 1
|
self._index = self._index + 1
|
||||||
|
self.scriptIndexChanged.emit()
|
||||||
return self._history[self._index]
|
return self._history[self._index]
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
@ -98,6 +112,7 @@ class ScriptEditorManager(QObject):
|
||||||
If there is no previous entry, return an empty string. """
|
If there is no previous entry, return an empty string. """
|
||||||
if self._index - 1 >= 0 and self._index - 1 < len(self._history):
|
if self._index - 1 >= 0 and self._index - 1 < len(self._history):
|
||||||
self._index = self._index - 1
|
self._index = self._index - 1
|
||||||
|
self.scriptIndexChanged.emit()
|
||||||
return self._history[self._index]
|
return self._history[self._index]
|
||||||
elif self._index == 0 and len(self._history):
|
elif self._index == 0 and len(self._history):
|
||||||
return self._history[self._index]
|
return self._history[self._index]
|
||||||
|
@ -120,6 +135,11 @@ class ScriptEditorManager(QObject):
|
||||||
settings.beginGroup(self._GROUP)
|
settings.beginGroup(self._GROUP)
|
||||||
settings.setValue(self._KEY, script)
|
settings.setValue(self._KEY, script)
|
||||||
settings.sync()
|
settings.sync()
|
||||||
|
|
||||||
|
scriptIndexChanged = Signal()
|
||||||
|
|
||||||
|
hasPreviousScript = Property(bool, _hasPreviousScript, notify=scriptIndexChanged)
|
||||||
|
hasNextScript = Property(bool, _hasNextScript, notify=scriptIndexChanged)
|
||||||
|
|
||||||
|
|
||||||
class CharFormat(QtGui.QTextCharFormat):
|
class CharFormat(QtGui.QTextCharFormat):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue