diff --git a/Furious/Widget/AssetViewer.py b/Furious/Widget/AssetViewer.py index 7372695..55a4a73 100644 --- a/Furious/Widget/AssetViewer.py +++ b/Furious/Widget/AssetViewer.py @@ -19,19 +19,11 @@ from PySide6.QtWidgets import QFileDialog, QListWidget, QListWidgetItem, QMainWi import os import shutil import logging -import threading -import watchfiles import darkdetect logger = logging.getLogger(__name__) -def watchFileChanges(callback): - for changes in watchfiles.watch(AssetViewerWidget.AssetDir): - if callable(callback): - callback() - - class QuestionDeleteBox(MessageBox): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -127,6 +119,8 @@ class ImportAction(Action): # Show the MessageBox and wait for user to close it self.importErrorBox.exec() else: + self.parent().flushItem() + self.importSuccessBox.setWindowTitle(_('Import')) self.importSuccessBox.setText(_('Import asset file success.')) @@ -142,13 +136,6 @@ class ExitAction(Action): self.parent().hide() -class WatchFiles(QtCore.QObject): - filesChanged = QtCore.Signal() - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - class AssetViewerWidget( Translatable, SupportConnectedCallback, SupportThemeChangedCallback, QMainWindow ): @@ -179,17 +166,6 @@ class AssetViewerWidget( logger.info(f'asset dir is \'{AssetViewerWidget.AssetDir}\'') - # Check filesystem events - self.watchFiles = WatchFiles() - self.watchFiles.filesChanged.connect(lambda: self.flushItem()) - - self.watchFilesListenerThread = threading.Thread( - target=watchFileChanges, - args=(self.watchFiles.filesChanged.emit,), - daemon=True, - ) - self.watchFilesListenerThread.start() - contextMenuActions = [ Action( _('Delete'), callback=lambda: self.deleteSelectedItem(), parent=self @@ -246,6 +222,8 @@ class AssetViewerWidget( for index in indexes: os.remove(AssetViewerWidget.AssetDir / self.listWidget.item(index).text()) + self.flushItem() + def flushItemByTheme(self, theme): self.listWidget.clear() diff --git a/Furious/__main__.py b/Furious/__main__.py index 5708269..d0e4fa3 100644 --- a/Furious/__main__.py +++ b/Furious/__main__.py @@ -25,12 +25,6 @@ def main(): exitcode = process.exitcode - if exitcode == -6: - # On Linux platform, daemon thread(filesystem events listener thread) - # terminated and result in application exitcode -6. Make it as exit - # success thus error window won't show. - exitcode = 0 - if exitcode == 0: sys.exit(exitcode)