File action menu edits
This commit is contained in:
parent
8d877eb71b
commit
634de3f6b0
Binary file not shown.
@ -58,9 +58,9 @@ class GridSignals:
|
|||||||
self.copyCutArry = self.grid.returnSelectedFiles()
|
self.copyCutArry = self.grid.returnSelectedFiles()
|
||||||
|
|
||||||
def paste(self, widget):
|
def paste(self, widget):
|
||||||
print(len(self.copyCutArry))
|
|
||||||
self.currentPath = self.grid.returnCurrentPath()
|
self.currentPath = self.grid.returnCurrentPath()
|
||||||
status = self.filehandler.paste(self.copyCutArry, self.currentPath, self.pasteType)
|
status = self.filehandler.paste(self.copyCutArry, self.currentPath, self.pasteType)
|
||||||
|
|
||||||
if status == 0:
|
if status == 0:
|
||||||
self.grid.setIconViewDir(self.currentPath)
|
self.grid.setIconViewDir(self.currentPath)
|
||||||
if self.pasteType == 2: # cut == 2
|
if self.pasteType == 2: # cut == 2
|
||||||
|
@ -62,6 +62,7 @@ class FileHandler:
|
|||||||
else: # Create Folder
|
else: # Create Folder
|
||||||
os.mkdir(name)
|
os.mkdir(name)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@ -69,22 +70,26 @@ class FileHandler:
|
|||||||
def paste(self, files, toPath, pasteType):
|
def paste(self, files, toPath, pasteType):
|
||||||
try:
|
try:
|
||||||
for file in files:
|
for file in files:
|
||||||
parts = file.split("/")
|
parts = file.split("/")
|
||||||
toBePath = toPath + parts[len(parts) - 1]
|
toBePath = toPath + "/" + parts[len(parts) - 1] # Used to check for duplicates
|
||||||
finalForm = file + self.dedupPathIter(toBePath)
|
finalForm = file + self.dedupPathIter(toBePath)
|
||||||
|
isDuplicate = finalForm != file
|
||||||
|
|
||||||
|
if isDuplicate:
|
||||||
|
os.rename(file, finalForm)
|
||||||
|
|
||||||
|
if pasteType == 1: # copy paste = 1
|
||||||
|
shutil.copy2(finalForm, toPath)
|
||||||
|
if isDuplicate:
|
||||||
|
os.rename(finalForm, file) # Rename back after copy completes
|
||||||
|
if pasteType == 2: # cut paste = 2
|
||||||
|
shutil.move(finalForm, toPath)
|
||||||
|
|
||||||
print(toBePath)
|
|
||||||
print(finalForm)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
# if finalForm != file:
|
return 0
|
||||||
# os.rename(file, finalForm)
|
|
||||||
#
|
|
||||||
# if pasteType == 1: # copy paste == 1
|
|
||||||
# shutil.move(finalForm, toPath)
|
|
||||||
# if pasteType == 2: # cut paste == 2
|
|
||||||
# shutil.copy2(finalForm, toPath)
|
|
||||||
|
|
||||||
def delete(self, toDeleteFiles):
|
def delete(self, toDeleteFiles):
|
||||||
try:
|
try:
|
||||||
@ -124,7 +129,6 @@ class FileHandler:
|
|||||||
print("The folder/file does not exist")
|
print("The folder/file does not exist")
|
||||||
return 1
|
return 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("An error occured moving the file to trash:")
|
|
||||||
print(e)
|
print(e)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@ -140,7 +144,6 @@ class FileHandler:
|
|||||||
print("The folder/file does not exist")
|
print("The folder/file does not exist")
|
||||||
return 1
|
return 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("An error occured renaming the file:")
|
|
||||||
print(e)
|
print(e)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
@ -197,7 +197,13 @@ class Grid:
|
|||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
def returnSelectedFiles(self):
|
def returnSelectedFiles(self):
|
||||||
return self.selectedFiles
|
# NOTE: Just returning selectedFiles looks like it returns a "pointer"
|
||||||
|
# to the children. This mean we lose the list if any left click occures
|
||||||
|
# in this class.
|
||||||
|
files = []
|
||||||
|
for file in self.selectedFiles:
|
||||||
|
files.append(file)
|
||||||
|
return files
|
||||||
|
|
||||||
def returnCurrentPath(self):
|
def returnCurrentPath(self):
|
||||||
return self.currentPath
|
return self.currentPath
|
||||||
|
Loading…
Reference in New Issue
Block a user