Skip to content

Commit

Permalink
Add menu option to CueGUI to reset to the default layout. (#833)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbijl committed Dec 15, 2020
1 parent 2228f16 commit 96cefe2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cuegui/cuegui/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,16 @@ def startup(app_name, app_version, argv):

config_path = "/.%s/config" % app_name.lower()
settings = QtCore.QSettings(QtCore.QSettings.IniFormat, QtCore.QSettings.UserScope, config_path)
local = settings.fileName()
# If the user has chose to revert the layout. delete the file and copy the default back.
if settings.value('RevertLayout'):
os.remove(local)

QtGui.qApp.settings = settings

cuegui.Style.init()

# If the config file does not exist, copy over the default
local = settings.fileName()
# If the config file does not exist, copy over the default
if not os.path.exists(local):
default = os.path.join(cuegui.Constants.DEFAULT_INI_PATH, "%s.ini" % app_name.lower())
logger.warning('Not found: %s\nCopying: %s' % (local, default))
Expand Down
17 changes: 17 additions & 0 deletions cuegui/cuegui/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ def __windowMenuSetup(self, menu):
saveWindowSettings.triggered.connect(self.__saveSettings)
menu.addAction(saveWindowSettings)

# Menu Bar: Window -> Revert To Default Window Layout
revertWindowSettings = QtWidgets.QAction("Revert To Default Window Layout", self)
revertWindowSettings.triggered.connect(self.__revertLayout)
menu.addAction(revertWindowSettings)

menu.addSeparator()

# Load list of window titles
Expand Down Expand Up @@ -422,3 +427,15 @@ def __saveSettings(self):
self.size())
self.settings.setValue("%s/Position" % self.name,
self.pos())

def __revertLayout(self):
"""Revert back to default window layout"""
result = QtWidgets.QMessageBox.question(
self,
"Restart required ",
"You must restart for this action to take effect, close window?: ",
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)

if result == QtWidgets.QMessageBox.Yes:
self.settings.setValue("RevertLayout", True)
self.__windowCloseApplication()

0 comments on commit 96cefe2

Please sign in to comment.