Added 'Open folder containing this file'

This commit is contained in:
Uriziel 2016-12-31 02:54:28 +01:00
parent ddae114694
commit e60e1054e1
3 changed files with 18 additions and 0 deletions

View File

@ -409,6 +409,7 @@ en = {
"addurlstoplaylist-menu-label" : u"Add URL(s) to bottom of playlist",
"editplaylist-menu-label": u"Edit playlist",
"open-containing-folder": u"Open folder containing this file",
"addusersfiletoplaylist-menu-label" : u"Add {} file to playlist", # item owner indicator
"addusersstreamstoplaylist-menu-label" : u"Add {} stream to playlist", # item owner indicator
"openusersstream-menu-label" : u"Open {} stream", # [username]'s

View File

@ -577,6 +577,10 @@ class MainWindow(QtGui.QMainWindow):
if self._syncplayClient.isUntrustedTrustableURI(filename):
domain = utils.getDomainFromURL(filename)
menu.addAction(QtGui.QPixmap(resourcespath + u"shield_add.png"),getMessage("addtrusteddomain-menu-label").format(domain), lambda: self.addTrustedDomain(domain))
if not isURL(filename):
path = self._syncplayClient.fileSwitch.findFilepath(filename)
menu.addAction(QtGui.QPixmap(resourcespath + u"film_folder_edit.png"), getMessage('open-containing-folder'), lambda: utils.open_system_file_browser(path))
else:
return
menu.exec_(self.listTreeView.viewport().mapToGlobal(position))

View File

@ -12,6 +12,8 @@ import string
import urllib
import ast
import unicodedata
import platform
import subprocess
folderSearchEnabled = True
@ -311,6 +313,17 @@ def getDomainFromURL(URL):
except:
return None
def open_system_file_browser(path):
if isURL(path):
return
path = os.path.dirname(path)
if platform.system() == "Windows":
os.startfile(path)
elif platform.system() == "Darwin":
subprocess.Popen(["open", path])
else:
subprocess.Popen(["xdg-open", path])
def getListOfPublicServers():
try:
import urllib, syncplay, sys, messages, json