wip: database checker

This commit is contained in:
2025-09-12 00:02:28 +08:00
parent 5db2207ee0
commit 1453686de6
24 changed files with 1060 additions and 430 deletions

48
ui/utils/url.py Normal file
View File

@ -0,0 +1,48 @@
from pathlib import Path
from PySide6.QtCore import QFileInfo, QObject, QUrl, Slot
from PySide6.QtQml import QmlElement, QmlSingleton
from .common import UTILS_QML_IMPORT_NAME
QML_IMPORT_NAME = UTILS_QML_IMPORT_NAME
QML_IMPORT_MAJOR_VERSION = 1
QML_IMPORT_MINOR_VERSION = 0
@QmlElement
@QmlSingleton
class UrlUtils(QObject):
@Slot(str, result=bool)
@staticmethod
def isDir(url: str):
return QFileInfo(QUrl(url).toLocalFile()).isDir()
@Slot(str, result=bool)
@staticmethod
def isFile(url: str):
return QFileInfo(QUrl(url).toLocalFile()).isFile()
@Slot(str, result=str)
@staticmethod
def stem(url: str):
return Path(QUrl(url).toLocalFile()).stem
@Slot(str, result=str)
@staticmethod
def name(url: str):
return Path(QUrl(url).toLocalFile()).name
@Slot(str, result=QUrl)
@staticmethod
def parent(url: str):
return QUrl.fromLocalFile(Path(QUrl(url).toLocalFile()).parent)
@QmlElement
@QmlSingleton
class UrlFormatUtils(QObject):
@Slot(str, result=str)
@staticmethod
def toLocalFile(url: str):
return QUrl(url).toLocalFile()