mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-02-01 15:49:09 +00:00
split open_file func from ts_qt.py
This commit is contained in:
1
tagstudio/src/qt/helpers/__init__.py
Normal file
1
tagstudio/src/qt/helpers/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .open_file import open_file
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,6 @@ import os
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
import shutil
|
||||
import subprocess
|
||||
from types import FunctionType
|
||||
from datetime import datetime as dt
|
||||
@@ -46,6 +45,7 @@ from src.core.ts_core import (PLAINTEXT_TYPES, TagStudioCore, TAG_COLORS, DATE_F
|
||||
from src.core.utils.web import strip_web_protocol
|
||||
from src.qt.flowlayout import FlowLayout, FlowWidget
|
||||
from src.qt.main_window import Ui_MainWindow
|
||||
from src.qt.helpers import open_file
|
||||
import src.qt.resources_rc
|
||||
|
||||
# SIGQUIT is not defined on Windows
|
||||
@@ -65,26 +65,6 @@ logging.basicConfig(format="%(message)s", level=logging.INFO)
|
||||
QSettings.setPath(QSettings.IniFormat, QSettings.UserScope, os.getcwd())
|
||||
|
||||
|
||||
def open_file(path: str):
|
||||
try:
|
||||
if sys.platform == "win32":
|
||||
# Windows needs special attention to handle spaces in the file
|
||||
# first parameter is for title, NOT filepath
|
||||
subprocess.Popen(["start", "", os.path.normpath(path)], shell=True, close_fds=True, creationflags=subprocess.DETACHED_PROCESS)
|
||||
else:
|
||||
if sys.platform == "darwin":
|
||||
command_name = "open"
|
||||
else:
|
||||
command_name = "xdg-open"
|
||||
command = shutil.which(command_name)
|
||||
if command is not None:
|
||||
subprocess.Popen([command, path], close_fds=True)
|
||||
else:
|
||||
logging.info(f"Could not find {command_name} on system PATH")
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
class NavigationState():
|
||||
"""Represents a state of the Library grid view."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user