Skip to content

Commit

Permalink
Add reload reading and reload data (decks, skins, and layouts)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowKyogre committed Aug 12, 2013
1 parent 8fb9d03 commit f79a1cd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
27 changes: 22 additions & 5 deletions qtarotlib/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class QTarot(QtGui.QMainWindow):

def __init__(self):
super().__init__()
self.last_layout=0
self.last_layout=None
self.initUI()

def updateCards(self):
Expand Down Expand Up @@ -134,17 +134,21 @@ def newReading(self,item=None,neg=None,skin=None,
qtrcfg.setup_skin(skin)

layouts=list(qtrcfg.layouts.keys())
if item not in list(qtrcfg.layouts.keys()):
if item not in layouts:
try:
idx = layouts.index(self.last_layout)
except ValueError as e:
idx = 0
item,ok = QtGui.QInputDialog.getItem(self, "Generate new reading",
"Layout to use:", layouts, self.last_layout, False)
"Layout to use:", layouts, idx, False)
if ok and item:
lay=qtrcfg.layouts[item]
self.last_layout=layouts.index(item)
self.last_layout=item
else:
return
else:
lay=qtrcfg.layouts[item]
self.last_layout=layouts.index(item)
self.last_layout=item
self.scene.clear()
self.scene.invalidate()

Expand Down Expand Up @@ -431,6 +435,16 @@ def initUI(self):
newChooseAction.setStatusTip('Generate a new reading using a deck and skin of choice')
newChooseAction.triggered.connect(lambda: self.newReading(ask_for_deck=True))

reloadDataAction = QtGui.QAction(QtGui.QIcon.fromTheme('document-new'), 'Reload data', self)
reloadDataAction.setShortcut('Ctrl+Shift+R')
reloadDataAction.setStatusTip('Generate a new reading using a deck and skin of choice')
reloadDataAction.triggered.connect(qtrcfg.refreshData)

reloadReadingAction = QtGui.QAction(QtGui.QIcon.fromTheme('document-new'), 'Reload reading', self)
reloadReadingAction.setShortcut('Ctrl+R')
reloadReadingAction.setStatusTip('Generate a new reading using the last layout')
reloadReadingAction.triggered.connect(lambda: self.newReading(item=self.last_layout))

saveAction = QtGui.QAction(QtGui.QIcon.fromTheme('document-save'), 'Save', self)
saveAction.setShortcut('Ctrl+S')
saveAction.setStatusTip('Save')
Expand Down Expand Up @@ -460,13 +474,16 @@ def initUI(self):
fileMenu.addAction(exitAction)
fileMenu.addAction(newLayAction)
fileMenu.addAction(newChooseAction)
fileMenu.addAction(reloadReadingAction)
fileMenu.addAction(reloadDataAction)
fileMenu.addAction(openAction)
fileMenu.addAction(saveAction)
fileMenu.addAction(settingsAction)

toolbar = self.addToolBar('Exit')
toolbar.addAction(exitAction)
toolbar.addAction(newLayAction)
toolbar.addAction(reloadReadingAction)
toolbar.addAction(openAction)
toolbar.addAction(saveAction)
toolbar.addAction(browsingAction)
Expand Down
3 changes: 3 additions & 0 deletions qtarotlib/guiconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ def reset_settings(self):
self.table=self.settings.value("table","skin:table.png")
self.settings.endGroup()

self.refreshData()

def refreshData(self):
self.load_deck_defs()
self.load_layouts()
self.load_skins()
Expand Down

0 comments on commit f79a1cd

Please sign in to comment.