def showChangelogOnUpdate(): addonVersion = getCurrentAddonVersion() addonName = getCurrentAddonName() addonMeta = mw.addonManager.addonMeta(addonName) if addonMeta.get("human_version", None) != addonVersion: addonMeta["human_version"] = addonVersion mw.addonManager.writeAddonMeta(addonName, addonMeta) changelogPath = getResourcePath("CHANGELOG.html") if os.path.exists(changelogPath): with noBundledLibs(): showText(readResource("CHANGELOG.html"), type="html", title="Changelog")
def show_in_filemanager(filename): """mod of aqt.utils openFolder""" _, path, _, _ = process_path(filename) if isWin: subprocess.Popen(f'explorer /select, "file://{path}" ') elif isMac: with noBundledLibs(): script = """ tell application \"Finder\" activate select POSIX file \"{}\" end tell """.format(path) subprocess.Popen(osascript_to_args(script)) elif isLin: us = gc("File Manager in Linux and its args") us = check_if_executable_exists(us[0]) if not us: return if us: us.append("file://" + path) subprocess.Popen(us, env=env_adjust()) else: select_supported = ["dolphin", "nautilus" ] # caja 1.24 doesn't have "--select" for fm in select_supported: if which(fm) is not None: subprocess.Popen([fm, "--select", "file://" + path], env=env_adjust()) else: showInfo( "The file manager will show your media folder. The name of the file you " f"clicked is:\n\n{os.path.dirname(path)}") with noBundledLibs(): QDesktopServices.openUrl( QUrl("file://" + os.path.dirname(path)))
def myOpenFolder(path): """mod of aqt.utils openFolder""" if isWin: # subprocess.Popen(["explorer", ]) # original version, doesn't work in 2019-12 subprocess.Popen('explorer /select, {}'.format("file://" + path)) elif isLin and which("dolphin") is not None: # BUT in 2019-05 (in KDE) openFolder doesn't work for me in the prebuilt/compiled version # from Ankiweb. If I use runanki with my local PyQt it works subprocess.Popen(["dolphin", "--select", "file://" + path]) # subprocess.Popen(["dolphin","--select",path]) #also works else: with noBundledLibs(): script = """ tell application \"Finder\" activate select POSIX file \"{}\" end tell """.format(path) subprocess.Popen(osascript_to_args(script))
def showChangelogOnUpdate(): addonVersion = getCurrentAddonVersion() addonName = getCurrentAddonName() addonMeta = mw.addonManager.addonMeta(addonName) if addonMeta.get("human_version", None) != addonVersion: addonMeta["human_version"] = addonVersion mw.addonManager.writeAddonMeta(addonName, addonMeta) changelogPath = getResourcePath("CHANGELOG.html") if os.path.exists(changelogPath): with noBundledLibs(): diag, _ = showText( readResource("CHANGELOG.html"), type="html", title="Changelog", run=False, minWidth=800, minHeight=600, ) diag.setParent(None) diag.exec_()
def myOpenFolder(path): """mod of aqt.utils openFolder""" if isWin: # subprocess.Popen(["explorer", ]) # original version, doesn't work in 2019-12 subprocess.Popen('explorer /select, {}'.format("file://" + path)) elif isMac: with noBundledLibs(): script = """ tell application \"Finder\" activate select POSIX file \"{}\" end tell """.format(path) subprocess.Popen(osascript_to_args(script)) elif isLin: us = gc("File Manager in Linux and its args") env = os.environ.copy() toremove = ['LD_LIBRARY_PATH', 'QT_PLUGIN_PATH', 'QML2_IMPORT_PATH'] for e in toremove: env.pop(e, None) if us: us.append("file://" + path) subprocess.Popen(us, env=env) else: if which("dolphin") is not None: subprocess.Popen(["dolphin", "--select", "file://" + path], env=env) elif which("nautilus") is not None: # caja 1.20 doesn't have "--select" subprocess.Popen(["nautilus", "--select", "file://" + path], env=env) else: filename = os.path.dirname(path) showInfo( "The file manager will show your media folder. The name of the file you " "clicked is:\n\n{}".format(filename)) dirname = os.path.dirname(path) QDesktopServices.openUrl(QUrl("file://" + dirname))
def openFolder(path): if isWin: subprocess.Popen(["explorer", "file://" + path]) else: with noBundledLibs(): QDesktopServices.openUrl(QUrl("file://" + path))
def openLink(link): tooltip(_("Loading..."), period=1000) with noBundledLibs(): QDesktopServices.openUrl(QUrl(link))
def openLink(link): tooltip(tr(TR.QT_MISC_LOADING), period=1000) with noBundledLibs(): QDesktopServices.openUrl(QUrl(link))
def openLink(link: Union[str, QUrl]) -> None: tooltip(tr.qt_misc_loading(), period=1000) with noBundledLibs(): QDesktopServices.openUrl(QUrl(link))
def openFolder(path: str) -> None: if isWin: subprocess.run(["explorer", f"file://{path}"], check=False) else: with noBundledLibs(): QDesktopServices.openUrl(QUrl(f"file://{path}"))