Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
73e66ba
Added new exit dialog.
JamesWrigley Aug 23, 2014
b4edbc8
Some code cleanups.
JamesWrigley Aug 24, 2014
0089ca5
Moar cleanups.
JamesWrigley Aug 31, 2014
1c044a2
Initial commit for a new file viewer dialog, not properly hooked up y…
JamesWrigley Sep 3, 2014
83e5d21
Added support for image previews (when possible).
JamesWrigley Sep 3, 2014
1207194
Merge remote-tracking branch 'origin/develop' into dialogs
JamesWrigley Sep 3, 2014
97d2151
Minor fix to remove the 'file://' prefix from the path bar.
JamesWrigley Sep 3, 2014
c789763
Hooked up the new file dialog to open when saving a new graph.
JamesWrigley Sep 4, 2014
8a7e562
Fixed buttleData.saveData(), previously it would save in the current …
JamesWrigley Sep 4, 2014
1b9ca13
The QUrl stuff was messing things up. Note: with this change, we'll h…
JamesWrigley Sep 5, 2014
30b3108
The file dialog now displays the filename of the selected file in the…
JamesWrigley Sep 5, 2014
bed9796
Switched finderLoadGraph to be a FileViewerDialog. The whole open/sav…
JamesWrigley Sep 5, 2014
6bca292
General improvements to the file dialog: It now opens at the users ho…
JamesWrigley Sep 6, 2014
a03e859
Moved visible property from ExitDialog.qml to the dialogs themselves …
JamesWrigley Sep 6, 2014
7789f09
Replaced the openGraph dialog with an ExitDialog, removed the abortBu…
JamesWrigley Sep 8, 2014
425aa8b
Added comment, and switched to using a FileViewerDialog for openGraph.
JamesWrigley Sep 9, 2014
605e16e
Reverted 1b9ca13.
JamesWrigley Sep 13, 2014
ece3a33
Rewrote the showDialog signals to send a string describing the action…
JamesWrigley Sep 13, 2014
6cc09b4
Some cleanups for the dialogs. Of particular note, the message in Exi…
JamesWrigley Sep 22, 2014
6639c29
Simplified the way we assign the current folder to the URL bar. Todo:…
JamesWrigley Oct 3, 2014
396aad9
And at long last, a fix for the bug that started it all, #72 :P
JamesWrigley Oct 4, 2014
b1aab84
Simplified the ridiculous interation between dialogs, fixed a TODO so…
JamesWrigley Oct 13, 2014
747ad26
Replaced the QtQuick dialogs with our own.
JamesWrigley Oct 13, 2014
00b83ac
Removed modality property.
JamesWrigley Oct 13, 2014
ec4d869
Merge branch 'develop' into dialogs
JamesWrigley Jan 22, 2015
8353dbe
Whitespace cleanup to satisfy flake.
JamesWrigley Jan 22, 2015
1c9b9b3
Fixed bug that would hide the graph widget on startup. Seems to have
JamesWrigley Jan 22, 2015
db0f620
Merge branch 'dialogs' of https://github.com/JamesWrigley/ButtleOFX i…
aoblet Jul 13, 2015
3b363f4
Features:
aoblet Jul 13, 2015
fc763e2
browser: fix bug recurse search
aoblet Jul 13, 2015
2801467
bModel doc
aoblet Jul 18, 2015
832ee97
new style parent constructor
aoblet Jul 18, 2015
77f9a6c
fix new style super constructor
aoblet Jul 18, 2015
f51624d
set three views mode
aoblet Jul 18, 2015
2216250
fix view visible quickGraph
aoblet Jul 18, 2015
340556b
clean views
aoblet Jul 18, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified blackMosquito.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
288 changes: 119 additions & 169 deletions buttleofx/MainWindow.qml

Large diffs are not rendered by default.

40 changes: 25 additions & 15 deletions buttleofx/data/buttleData.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,8 @@ def loadData(self, url='buttleofx/backup/data.bofx'):
"""
Loads all data from a Json file (the default Json file if no url is given)
"""

filepath = QtCore.QUrl(url).toLocalFile()

Qurl = QtCore.QUrl(url)
filepath = (Qurl.isLocalFile() and Qurl.toLocalFile()) or url
self.newData()

with open(filepath, 'r') as f:
Expand Down Expand Up @@ -647,14 +646,21 @@ def saveData(self, url):
"""
Saves all data in a json file
"""
# If called from Python, it could be a str or a QUrl
if isinstance(url, str):
# If called from Python, it could be a str or a QUrl.
filepath = QtCore.QUrl.fromLocalFile(url).toLocalFile()
filepath = url
else:
filepath = QtCore.QUrl(url).toLocalFile()
filepath = url.toLocalFile() if url.isLocalFile() else url.toString()

if filepath.endswith('buttleSave_now.bofx'):
filepath = os.path.dirname(filepath)

if not filepath.lower().endswith(".bofx"):
filepath = filepath + ".bofx"
# if destination path is a folder, we create a file name containing date and time of now
if os.path.isdir(filepath):
filepath = os.path.join(filepath, 'buttleSave%s' % datetime.today().strftime('%m_%d_%y_%I_%M'))

if not filepath.lower().endswith('.bofx'):
filepath += '.bofx'

with io.open(filepath, 'w', encoding='utf-8') as f:
dictJson = {
Expand All @@ -675,8 +681,8 @@ def saveData(self, url):
# Graph
dictJson["graph"] = self.getGraph().object_to_dict()

# Graph : currentSeletedNodes
for node in self.getGraph().getNodes():
# Graph : currentSelectedNodes
for node in self._graph.getNodes():
if node.getName() in self.getCurrentSelectedNodeNames():
dictJson["graph"]["currentSelectedNodes"].append(node.getName())

Expand Down Expand Up @@ -736,6 +742,9 @@ def zoom(self, width, height, nodeWidth, zoomCoeff, graphPreviousWidth, graphPre
def getButtlePath(self):
return self._buttlePath

def getHomeDir(self):
return os.path.expanduser("~")

def getCurrentConnectionWrapper(self):
"""
Returns the current currentConnectionWrapper.
Expand Down Expand Up @@ -1036,6 +1045,7 @@ def graphCanBeSaved(self):

# filePath
buttlePath = QtCore.pyqtProperty(str, getButtlePath, constant=True)
homeDir = QtCore.pyqtProperty(str, getHomeDir, constant=True)

# Current param, view, and selected node
currentParamNodeChanged = QtCore.pyqtSignal()
Expand Down Expand Up @@ -1092,12 +1102,12 @@ def graphCanBeSaved(self):
globalButtleData = ButtleData()


def _decode_dict(dict_):
def _decode_dict(_dict):
"""
This function will recursively pass in nested dicts, and will convert
all str elements into string (essential for some Tuttle functions).
"""
for key in dict_:
if isinstance(dict_[key], str):
dict_[key] = str(dict_[key])
return dict_
for key in _dict:
if isinstance(_dict[key], str):
_dict[key] = str(_dict[key])
return _dict
9 changes: 5 additions & 4 deletions buttleofx/gui/browser_v2/actions/browserAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

from buttleofx.gui.browser_v2.actions.actionManager import globalActionManager
from buttleofx.gui.browser_v2.actions.actionWrapper import ActionWrapper
from buttleofx.gui.browser_v2.browserModel import globalBrowserModel
from buttleofx.gui.browser_v2.browserItem import BrowserItem
from buttleofx.gui.browser_v2.actions.concreteActions.copy import Copy
from buttleofx.gui.browser_v2.actions.concreteActions.move import Move
from buttleofx.gui.browser_v2.actions.concreteActions.create import Create
from buttleofx.gui.browser_v2.actions.concreteActions.delete import Delete
from buttleofx.gui.browser_v2.browserModel import globalBrowserDialog, globalBrowser


class BrowserAction(QtCore.QObject):
Expand All @@ -21,11 +21,11 @@ class BrowserAction(QtCore.QObject):
"""
cacheChanged = QtCore.pyqtSignal()

def __init__(self):
def __init__(self, bModel):
logging.debug('BrowserAction begin constructor')
QtCore.QObject.__init__(self)
self._cacheActions = None # for copy, move actions
self._browserModel = globalBrowserModel
self._browserModel = bModel
logging.debug('BrowserAction end constructor')

def pushCache(self, listActions):
Expand Down Expand Up @@ -99,4 +99,5 @@ def handleNew(self, typeItem):
isCache = QtCore.pyqtProperty(bool, isEmptyCache, notify=cacheChanged)


globalBrowserAction = BrowserAction()
globalBrowserAction = BrowserAction(globalBrowser)
globalBrowserActionDialog = BrowserAction(globalBrowserDialog)
21 changes: 16 additions & 5 deletions buttleofx/gui/browser_v2/browserModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(self, path=op.expanduser("~/"), sync=False, showSeq=True, hideDotFi
"""
QtCore.QObject.__init__(self, parent)
self._currentPath = path
self._bufferBrowserItems = [] # used when recursive process: fix async signal connection when add object
self._browserItems = [] # used only in python side
self._browserItemsModel = QObjectListModel(self) # used for UI
self._filter = filterFiles
Expand Down Expand Up @@ -98,6 +99,7 @@ def updateItems(self, recursivePattern):
return

self.clearItemsSync.emit()
self._bufferBrowserItems.clear()
detectOption = sequenceParser.eDetectionDefaultWithDotFile
if self._hideDotFiles:
detectOption = sequenceParser.eDetectionDefault
Expand Down Expand Up @@ -146,6 +148,7 @@ def pushBrowserItems(self, allItems, toModel=True):
if not self._isSync:
itemToAdd.moveToThread(self.thread())
self.addItemSync.emit(itemToAdd, toModel)
self._bufferBrowserItems.append(itemToAdd)

@QtCore.pyqtSlot(object, bool)
def onAddItemSync(self, bItem, toModel=True):
Expand All @@ -168,30 +171,37 @@ def onClearItemsSync(self):
@QtCore.pyqtSlot(str, object)
def searchRecursively(self, pattern, modelRequester):
"""
Process a recursive search. Disable thumbnail build for sub BrowserModel
Process a recursive search. Disable thumbnail build for sub BrowserModel.
:param pattern: user input search pattern
:param modelRequester: main model which starts the recursive search
"""
logging.debug("Start recursive search: %s", self._currentPath)
if modelRequester.getParallelThread().isStopped():
return

listToBrowse = self._browserItems
listToBrowse = self._bufferBrowserItems
# Clear on the first level
if self == modelRequester:
listToBrowse = self._browserItems.copy() # copy: _browserItems deleted line after
modelRequester.clearItemsSync.emit()

for bItem in listToBrowse: # 1st pass, all files in current dir
logging.debug("processing %s" % bItem.getPath())
if pattern.lower() in bItem.getName().lower():
bItem.moveToThread(modelRequester.thread())
# Build thumbnails manually only on matching files
bItem.startBuildThumbnail()
modelRequester.addItemSync.emit(bItem, True)

for bItem in listToBrowse: # 2nd pass, recurse
if not modelRequester._isSync and modelRequester.getParallelThread().isStopped():
return
if bItem.isFolder():
# Do not compute thumbnails on all elements, but only manually on matching files.
recursiveModel = BrowserModel(bItem.getPath(), True, self._showSeq, self._hideDotFiles, self._filter, buildThumbnail=False)
# Browse items for this folder and fill model
recursiveModel.loadData()
# Launch a search on all sub directories
recursiveModel.searchRecursively(pattern.lower(), modelRequester)

def getFilter(self):
Expand Down Expand Up @@ -250,7 +260,7 @@ def onSortBrowserItems(self):
self._browserItems.sort(key=lambda it: (it.getType(), it.getWeight()), reverse=rev)

# sort by folder, file
self._browserItems.sort(key=lambda it: (it.getType()))
self._browserItems.sort(key=lambda it: (it.getType())) # TODO: check needed

def searchIndexItem(self, bItem):
"""
Expand Down Expand Up @@ -417,4 +427,5 @@ def selectItemTo(self, index):
loading = QtCore.pyqtProperty(bool, isLoading, notify=loadingChanged)


globalBrowserModel = BrowserModel()
globalBrowser = BrowserModel()
globalBrowserDialog = BrowserModel()
34 changes: 29 additions & 5 deletions buttleofx/gui/browser_v2/qml/Browser.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ Rectangle {
height: 600
color: "#353535"

property alias fileWindow: fileWindow
property alias navBar: navBar
property bool showTab: true
property variant bModel: _browser
property variant bAction: _browserAction
property int visitedFolderListIndex: 0

signal buttonCloseClicked(bool clicked)
signal buttonFullscreenClicked(bool clicked)

Expand All @@ -22,6 +28,13 @@ Rectangle {
++ visitedFolderListIndex
}

function popVisitedFolder(){
if (visitedFolderList.count > 0 && visitedFolderListIndex > 0) {
-- visitedFolderListIndex
bModel.currentPath = visitedFolderList.get(visitedFolderListIndex).url
}
}

// Recently visited folder stack
ListModel {
id: visitedFolderList
Expand All @@ -32,9 +45,10 @@ Rectangle {
spacing: 0

Tab {
Layout.fillWidth: true
id: tabBar
Layout.fillWidth: true
name: "Browser"
visible: root.showTab
onCloseClicked: root.buttonCloseClicked(true)
onFullscreenClicked: root.buttonFullscreenClicked(true)
}
Expand All @@ -44,20 +58,19 @@ Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: childrenRect.height

property var model: _browser
property var model: root.bModel
property alias visitedFolderList: visitedFolderList
property alias visitedFolderListIndex: root.visitedFolderListIndex

onPushVisitedFolder: {
root.pushVisitedFolder(path)
}
}

Rectangle {
id: separator

Layout.fillWidth: true
Layout.preferredHeight: 1

color: "#00b2a1"
}

Expand All @@ -67,7 +80,8 @@ Rectangle {
Layout.fillWidth: true
Layout.fillHeight: true

property var model: _browser
property var model: root.bModel
property var bAction: root.bAction
property alias visitedFolderList: visitedFolderList
property alias visitedFolderListIndex: root.visitedFolderListIndex

Expand All @@ -76,4 +90,14 @@ Rectangle {
}
}
}

Keys.onPressed: {
if ((event.modifiers & Qt.ControlModifier) && (event.key == Qt.Key_L)){
navBar.toggleUrlEdit()
}

if (event.key == Qt.Key_Backspace){
popVisitedFolder()
}
}
}
Loading