forked from M-Labs/artiq
gui/explorer: fix 'parent folder' on Windows
This commit is contained in:
parent
155c2ec2ef
commit
6973a9471b
|
@ -1,5 +1,6 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtWidgets
|
from PyQt5 import QtCore, QtWidgets
|
||||||
|
@ -77,23 +78,24 @@ class _OpenFileDialog(QtWidgets.QDialog):
|
||||||
if selected:
|
if selected:
|
||||||
selected = selected[0].text()
|
selected = selected[0].text()
|
||||||
if selected == "..":
|
if selected == "..":
|
||||||
if (not self.explorer.current_directory
|
if not self.explorer.current_directory:
|
||||||
or self.explorer.current_directory[-1] not in "\\/"):
|
|
||||||
return
|
return
|
||||||
idx = None
|
if re.fullmatch("[a-zA-Z]:\\\\",
|
||||||
for sep in "\\/":
|
self.explorer.current_directory):
|
||||||
try:
|
|
||||||
idx = self.explorer.current_directory[:-1].rindex(sep)
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
if idx is None:
|
|
||||||
return
|
|
||||||
self.explorer.current_directory = \
|
|
||||||
self.explorer.current_directory[:idx+1]
|
|
||||||
if self.explorer.current_directory == "/":
|
|
||||||
self.explorer.current_directory = ""
|
self.explorer.current_directory = ""
|
||||||
|
else:
|
||||||
|
idx = None
|
||||||
|
for sep in "\\/":
|
||||||
|
try:
|
||||||
|
idx = self.explorer.current_directory[:-1].rindex(sep)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
self.explorer.current_directory = \
|
||||||
|
self.explorer.current_directory[:idx+1]
|
||||||
|
if self.explorer.current_directory == "/":
|
||||||
|
self.explorer.current_directory = ""
|
||||||
asyncio.ensure_future(self.refresh_view())
|
asyncio.ensure_future(self.refresh_view())
|
||||||
elif selected[-1] in "\\/":
|
elif selected[-1] in "\\/":
|
||||||
self.explorer.current_directory += selected
|
self.explorer.current_directory += selected
|
||||||
|
|
Loading…
Reference in New Issue