diff --git a/.env b/.env index e08dbd228..206ddd1e4 100644 --- a/.env +++ b/.env @@ -1,4 +1,5 @@ K1_PATH="C:\Program Files (x86)\Steam\steamapps\common\swkotor" K2_PATH="C:\Program Files (x86)\Steam\steamapps\common\Knights of the Old Republic II" PYTHONPATH="${env:PYTHONPATH};Libraries\PyKotor\src;Libraries\PyKotorGL\src;Libraries\PyKotorFont\src;Libraries\Utility\src" -NWNNSSCOMP_PATH="C:/Program Files (x86)/KotOR Scripting Tool/nwnnsscomp.exe" \ No newline at end of file +NWNNSSCOMP_PATH="C:/Program Files (x86)/KotOR Scripting Tool/nwnnsscomp.exe" +MYPYPATH="Libraries\PyKotor\src;Libraries\PyKotorGL\src;Libraries\PyKotorFont\src;Libraries\Utility\src;Tools\HoloPatcher\src;Tools\HolocronToolset\src;Tools\BatchPatcher\src;Tools\GUIDuplicator\src;Tools\MDLDecompile\src" \ No newline at end of file diff --git a/.github/workflows/publish_pykotor.yml b/.github/workflows/publish_pykotor.yml index ef82a3eff..f4f0d4180 100644 --- a/.github/workflows/publish_pykotor.yml +++ b/.github/workflows/publish_pykotor.yml @@ -188,7 +188,7 @@ jobs: if (-not (Test-Path -Path "upx-dir")) { New-Item -ItemType Directory -Path "upx-dir" } - Get-ChildItem -Path "temp_folder_upx/$fileNameWithoutExtension" -Recurse | Move-Item -Destination "upx-dir" + Get-ChildItem -LiteralPath "temp_folder_upx/$fileNameWithoutExtension" -Recurse | Move-Item -Destination "upx-dir" Remove-Item "temp_folder_upx" -Recurse -Force -ErrorAction SilentlyContinue } else { tar -xvf $archiveName --strip-components=1 -C "upx-dir" @@ -318,13 +318,13 @@ jobs: Write-Host "Virtual environment path: $venvPath" # Dynamically find the Python version directory inside the venv - $pythonLibPath = Get-ChildItem -Path "$venvPath/lib" | Where-Object { $_.PSIsContainer } | Select-Object -First 1 + $pythonLibPath = Get-ChildItem -LiteralPath "$venvPath/lib" | Where-Object { $_.PSIsContainer } | Select-Object -First 1 $sitePackagesPath = Join-Path -Path $pythonLibPath.FullName -ChildPath "site-packages" Write-Host "Site-packages path: $sitePackagesPath" # Use patchelf to adjust RPATH for all shared libraries in the virtual environment - Get-ChildItem -Path $sitePackagesPath -Filter *.so -Recurse | ForEach-Object { + Get-ChildItem -LiteralPath $sitePackagesPath -Filter *.so -Recurse | ForEach-Object { $libPath = $_.FullName Write-Host "Patching $libPath" sudo patchelf --set-rpath '$ORIGIN' $libPath @@ -337,7 +337,7 @@ jobs: Get-PSDrive -PSProvider FileSystem | ForEach-Object { $drive = $_.Root Write-Host "Searching in $drive" - Get-ChildItem -Path $drive -Filter 'api-ms-win-crt-*.dll' -Recurse -ErrorAction SilentlyContinue -Force | ForEach-Object { + Get-ChildItem -LiteralPath $drive -Filter 'api-ms-win-crt-*.dll' -Recurse -ErrorAction SilentlyContinue -Force | ForEach-Object { Write-Host $_.FullName } } @@ -467,13 +467,13 @@ jobs: Write-Host "Virtual environment path: $venvPath" # Dynamically find the Python version directory inside the venv - $pythonLibPath = Get-ChildItem -Path "$venvPath/lib" | Where-Object { $_.PSIsContainer } | Select-Object -First 1 + $pythonLibPath = Get-ChildItem -LiteralPath "$venvPath/lib" | Where-Object { $_.PSIsContainer } | Select-Object -First 1 $sitePackagesPath = Join-Path -Path $pythonLibPath.FullName -ChildPath "site-packages" Write-Host "Site-packages path: $sitePackagesPath" # Use patchelf to adjust RPATH for all shared libraries in the virtual environment - Get-ChildItem -Path $sitePackagesPath -Filter *.so -Recurse | ForEach-Object { + Get-ChildItem -LiteralPath $sitePackagesPath -Filter *.so -Recurse | ForEach-Object { $libPath = $_.FullName Write-Host "Patching $libPath" sudo patchelf --set-rpath '$ORIGIN' $libPath @@ -604,13 +604,13 @@ jobs: Write-Host "Virtual environment path: $venvPath" # Dynamically find the Python version directory inside the venv - $pythonLibPath = Get-ChildItem -Path "$venvPath/lib" | Where-Object { $_.PSIsContainer } | Select-Object -First 1 + $pythonLibPath = Get-ChildItem -LiteralPath "$venvPath/lib" | Where-Object { $_.PSIsContainer } | Select-Object -First 1 $sitePackagesPath = Join-Path -Path $pythonLibPath.FullName -ChildPath "site-packages" Write-Host "Site-packages path: $sitePackagesPath" # Use patchelf to adjust RPATH for all shared libraries in the virtual environment - Get-ChildItem -Path $sitePackagesPath -Filter *.so -Recurse | ForEach-Object { + Get-ChildItem -LiteralPath $sitePackagesPath -Filter *.so -Recurse | ForEach-Object { $libPath = $_.FullName Write-Host "Patching $libPath" sudo patchelf --set-rpath '$ORIGIN' $libPath @@ -882,7 +882,7 @@ jobs: } # Iterate through each tool in the folder - Get-ChildItem -Path $matrixPackagePath | ForEach-Object { + Get-ChildItem -LiteralPath $matrixPackagePath | ForEach-Object { $toolExePath = $_.FullName $toolFileName = $_.Name $fileBaseName = [IO.Path]::GetFileNameWithoutExtension($_.Name) diff --git a/.github/workflows/release_holopatcher.yml b/.github/workflows/release_holopatcher.yml index 0ba2f42c7..00b21b31b 100644 --- a/.github/workflows/release_holopatcher.yml +++ b/.github/workflows/release_holopatcher.yml @@ -191,7 +191,7 @@ jobs: if (-not (Test-Path -Path "upx-dir")) { New-Item -ItemType Directory -Path "upx-dir" } - Get-ChildItem -Path "temp_folder_upx/$fileNameWithoutExtension" -Recurse | Move-Item -Destination "upx-dir" + Get-ChildItem -LiteralPath "temp_folder_upx/$fileNameWithoutExtension" -Recurse | Move-Item -Destination "upx-dir" Remove-Item "temp_folder_upx" -Recurse -Force -ErrorAction SilentlyContinue } else { tar -xvf $archiveName --strip-components=1 -C "upx-dir" @@ -322,13 +322,13 @@ jobs: Write-Host "Virtual environment path: $venvPath" # Dynamically find the Python version directory inside the venv - $pythonLibPath = Get-ChildItem -Path "$venvPath/lib" | Where-Object { $_.PSIsContainer } | Select-Object -First 1 + $pythonLibPath = Get-ChildItem -LiteralPath "$venvPath/lib" | Where-Object { $_.PSIsContainer } | Select-Object -First 1 $sitePackagesPath = Join-Path -Path $pythonLibPath.FullName -ChildPath "site-packages" Write-Host "Site-packages path: $sitePackagesPath" # Use patchelf to adjust RPATH for all shared libraries in the virtual environment - Get-ChildItem -Path $sitePackagesPath -Filter *.so -Recurse | ForEach-Object { + Get-ChildItem -LiteralPath $sitePackagesPath -Filter *.so -Recurse | ForEach-Object { $libPath = $_.FullName Write-Host "Patching $libPath" sudo patchelf --set-rpath '$ORIGIN' $libPath @@ -451,7 +451,7 @@ jobs: $originalDir = Get-Location $sourceFolder = Join-Path -Path $originalDir -ChildPath "published_workflow_builds" Set-Location $sourceFolder - Get-ChildItem -Path "." -Directory | ForEach-Object { + Get-ChildItem -LiteralPath "." -Directory | ForEach-Object { $folderName = $_.Name $archiveName = "$folderName.zip" zip -r -9 $archiveName $folderName @@ -530,7 +530,7 @@ jobs: $archivePath = "published_workflow_builds/*.zip" $releaseId = $env:RELEASE_ID $token = "${{ secrets.GITHUB_TOKEN }}"" - Get-ChildItem -Path $archivePath | ForEach-Object { + Get-ChildItem -LiteralPath $archivePath | ForEach-Object { $filePath = $_.FullName $fileName = $_.Name $uploadUrl = "https://uploads.github.com/repos/$env:GITHUB_REPOSITORY/releases/$releaseId/assets?name=$fileName&label=$fileName" diff --git a/.github/workflows/release_toolset.yml b/.github/workflows/release_toolset.yml index 0e47fb791..3cfe9ffac 100644 --- a/.github/workflows/release_toolset.yml +++ b/.github/workflows/release_toolset.yml @@ -201,7 +201,7 @@ jobs: if (-not (Test-Path -Path "upx-dir")) { New-Item -ItemType Directory -Path "upx-dir" } - Get-ChildItem -Path "temp_folder_upx/$fileNameWithoutExtension" -Recurse | Move-Item -Destination "upx-dir" + Get-ChildItem -LiteralPath "temp_folder_upx/$fileNameWithoutExtension" -Recurse | Move-Item -Destination "upx-dir" Remove-Item "temp_folder_upx" -Recurse -Force -ErrorAction SilentlyContinue } else { tar -xvf $archiveName --strip-components=1 -C "upx-dir" @@ -341,13 +341,13 @@ jobs: Write-Host "Virtual environment path: $venvPath" # Dynamically find the Python version directory inside the venv - $pythonLibPath = Get-ChildItem -Path "$venvPath/lib" | Where-Object { $_.PSIsContainer } | Select-Object -First 1 + $pythonLibPath = Get-ChildItem -LiteralPath "$venvPath/lib" | Where-Object { $_.PSIsContainer } | Select-Object -First 1 $sitePackagesPath = Join-Path -Path $pythonLibPath.FullName -ChildPath "site-packages" Write-Host "Site-packages path: $sitePackagesPath" # Use patchelf to adjust RPATH for all shared libraries in the virtual environment - Get-ChildItem -Path $sitePackagesPath -Filter *.so -Recurse | ForEach-Object { + Get-ChildItem -LiteralPath $sitePackagesPath -Filter *.so -Recurse | ForEach-Object { $libPath = $_.FullName Write-Host "Patching $libPath" sudo patchelf --set-rpath '$ORIGIN' $libPath @@ -473,7 +473,7 @@ jobs: $originalDir = Get-Location $sourceFolder = Join-Path -Path $originalDir -ChildPath "published_workflow_builds" Set-Location $sourceFolder - Get-ChildItem -Path "." -Directory | ForEach-Object { + Get-ChildItem -LiteralPath "." -Directory | ForEach-Object { $folderName = $_.Name $archiveName = "$folderName.zip" zip -r -9 $archiveName $folderName @@ -552,7 +552,7 @@ jobs: $archivePath = "published_workflow_builds/*.zip" $releaseId = $env:RELEASE_ID $token = "${{ secrets.GITHUB_TOKEN }}"" - Get-ChildItem -Path $archivePath | ForEach-Object { + Get-ChildItem -LiteralPath $archivePath | ForEach-Object { $filePath = $_.FullName $fileName = $_.Name $uploadUrl = "https://uploads.github.com/repos/$env:GITHUB_REPOSITORY/releases/$releaseId/assets?name=$fileName&label=$fileName" diff --git a/.github/workflows/release_translator.yml b/.github/workflows/release_translator.yml index 4013a692c..0639d8b48 100644 --- a/.github/workflows/release_translator.yml +++ b/.github/workflows/release_translator.yml @@ -191,7 +191,7 @@ jobs: if (-not (Test-Path -Path "upx-dir")) { New-Item -ItemType Directory -Path "upx-dir" } - Get-ChildItem -Path "temp_folder_upx/$fileNameWithoutExtension" -Recurse | Move-Item -Destination "upx-dir" + Get-ChildItem -LiteralPath "temp_folder_upx/$fileNameWithoutExtension" -Recurse | Move-Item -Destination "upx-dir" Remove-Item "temp_folder_upx" -Recurse -Force -ErrorAction SilentlyContinue } else { tar -xvf $archiveName --strip-components=1 -C "upx-dir" @@ -321,13 +321,13 @@ jobs: Write-Host "Virtual environment path: $venvPath" # Dynamically find the Python version directory inside the venv - $pythonLibPath = Get-ChildItem -Path "$venvPath/lib" | Where-Object { $_.PSIsContainer } | Select-Object -First 1 + $pythonLibPath = Get-ChildItem -LiteralPath "$venvPath/lib" | Where-Object { $_.PSIsContainer } | Select-Object -First 1 $sitePackagesPath = Join-Path -Path $pythonLibPath.FullName -ChildPath "site-packages" Write-Host "Site-packages path: $sitePackagesPath" # Use patchelf to adjust RPATH for all shared libraries in the virtual environment - Get-ChildItem -Path $sitePackagesPath -Filter *.so -Recurse | ForEach-Object { + Get-ChildItem -LiteralPath $sitePackagesPath -Filter *.so -Recurse | ForEach-Object { $libPath = $_.FullName Write-Host "Patching $libPath" sudo patchelf --set-rpath '$ORIGIN' $libPath @@ -449,7 +449,7 @@ jobs: $originalDir = Get-Location $sourceFolder = Join-Path -Path $originalDir -ChildPath "published_workflow_builds" Set-Location $sourceFolder - Get-ChildItem -Path "." -Directory | ForEach-Object { + Get-ChildItem -LiteralPath "." -Directory | ForEach-Object { $folderName = $_.Name $archiveName = "$folderName.zip" zip -r -9 $archiveName $folderName @@ -528,7 +528,7 @@ jobs: $archivePath = "published_workflow_builds/*.zip" $releaseId = $env:RELEASE_ID $token = "${{ secrets.GITHUB_TOKEN }}"" - Get-ChildItem -Path $archivePath | ForEach-Object { + Get-ChildItem -LiteralPath $archivePath | ForEach-Object { $filePath = $_.FullName $fileName = $_.Name $uploadUrl = "https://uploads.github.com/repos/$env:GITHUB_REPOSITORY/releases/$releaseId/assets?name=$fileName&label=$fileName" diff --git a/.vscode/launch.json b/.vscode/launch.json index fbef85446..f3062ba58 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -56,8 +56,8 @@ "name": "Run HoloPatcher", "type": "debugpy", "request": "launch", - "program": "${workspaceFolder}${pathSeparator}Tools${pathSeparator}HoloPatcher${pathSeparator}src${pathSeparator}__main__.py", "cwd": "${workspaceFolder}/Tools/HoloPatcher/src/", + "module": "holopatcher", "console": "integratedTerminal", "env": {"PYTHONPATH": "${workspaceFolder}/Libraries/PyKotor/src;${workspaceFolder}/Libraries/Utility/src;${env:PYTHONPATH}"}, "justMyCode": true, @@ -66,7 +66,7 @@ "name": "Run BatchPatcher", "type": "debugpy", "request": "launch", - "program": "${workspaceFolder}${pathSeparator}Tools${pathSeparator}BatchPatcher${pathSeparator}src${pathSeparator}__main__.py", + "module": "batchpatcher", "cwd": "${workspaceFolder}/Tools/BatchPatcher/src/", "console": "integratedTerminal", "env": {"PYTHONPATH": "${workspaceFolder}/Libraries/PyKotor/src;${workspaceFolder}/Libraries/Utility/src;${env:PYTHONPATH}"}, diff --git a/.vscode/settings.json b/.vscode/settings.json index 63e0a79ba..02132f0d5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -55,20 +55,25 @@ "reportCallIssue": "warning", // doesn't handle NamedTuple correctly. "reportAssignmentType": "warning", "reportArgumentType": "warning", + "reportPrivateImportUsage": "warning", }, - "mypy-type-checker.args": [ - "--check-untyped-defs" // Ignores issues with defs that can optionally be None. - ], "python.analysis.autoFormatStrings": true, - "mypy.targets": [ - "Libraries", - "Tools" - ], "mypy.extraArguments": [ - "--exclude='./.venv'", - "--exclude='tests/results'" + "--exclude=./.venv", + "--exclude=tests/results", + "--check-untyped-defs", + "-v", + "--explicit-package-bases" ], "github-actions.workflows.pinned.workflows": [ ".github/workflows/publish_and_test_pykotor.yml" ], + "mypy-type-checker.args": [ + "--check-untyped-defs", + "--explicit-package-bases" + ], + "mypy.runUsingActiveInterpreter": true, + "mypy-type-checker.preferDaemon": true, + "mypy-type-checker.reportingScope": "workspace", + "mypy-type-checker.importStrategy": "fromEnvironment", } diff --git a/Libraries/PyKotor/src/pykotor/resource/formats/tpc/io_tga.py b/Libraries/PyKotor/src/pykotor/resource/formats/tpc/io_tga.py index cbbf5f24c..7b01214a5 100644 --- a/Libraries/PyKotor/src/pykotor/resource/formats/tpc/io_tga.py +++ b/Libraries/PyKotor/src/pykotor/resource/formats/tpc/io_tga.py @@ -190,10 +190,15 @@ def load( def _load_with_pillow( self, - ) -> TPC | None: + ): + if self._tpc is None: + raise ValueError("Call load() instead of this directly.") # Use Pillow to handle the TGA file print("Loading with pillow") - with Image.open(self._reader._stream) as img: # type: ignore[reportArgumentType] their static type is incorrect, it supports any stream/byte/filepath-like object. + + # Their static type is incorrect, it supports any stream/byte/filepath-like object. + with Image.open(self._reader._stream) as img: # type: ignore[reportArgumentType] + # Determine the appropriate texture format based on the image mode if img.mode == "L": texture_format = TPCTextureFormat.Greyscale diff --git a/Libraries/Utility/src/__init__.py b/Libraries/Utility/src/utility/__init__.py similarity index 100% rename from Libraries/Utility/src/__init__.py rename to Libraries/Utility/src/utility/__init__.py diff --git a/README.md b/README.md index d77810bed..b28845e95 100644 --- a/README.md +++ b/README.md @@ -31,10 +31,10 @@ If powershell is not an option for you, you can install Python manually from htt Once 'install_python_venv.ps1' finishes, you can run any of the provided tools, such as HoloPatcher, KotorDiff, or the Toolset, like this: ```commandline pip install -r Tools/HoloPatcher/requirements.txt --prefer-binary -python ./Tools/HoloPatcher/src/__main__.py +python Tools/HoloPatcher/src/holopatcher/__main__.py pip install -r Tools/HolocronToolset/requirements.txt --prefer-binary python Tools/HolocronToolset/src/toolset/__main__.py -python Tools/KotorDiff/__main__.py +python Tools/KotorDiff/src/kotordiff/__main__.py ``` see [HoloPatcher's readme](https://github.com/NickHugi/PyKotor/tree/master/Tools/HoloPatcher#readme) for more information diff --git a/Tools/BatchPatcher/src/__init__.py b/Tools/BatchPatcher/src/batchpatcher/__init__.py similarity index 100% rename from Tools/BatchPatcher/src/__init__.py rename to Tools/BatchPatcher/src/batchpatcher/__init__.py diff --git a/Tools/BatchPatcher/src/__main__.py b/Tools/BatchPatcher/src/batchpatcher/__main__.py similarity index 99% rename from Tools/BatchPatcher/src/__main__.py rename to Tools/BatchPatcher/src/batchpatcher/__main__.py index 595c5ac6c..656ab617f 100644 --- a/Tools/BatchPatcher/src/__main__.py +++ b/Tools/BatchPatcher/src/batchpatcher/__main__.py @@ -44,6 +44,7 @@ def add_sys_path(path: pathlib.Path): add_sys_path(utility_path.parent) +from batchpatcher.translate.language_translator import TranslationOption, Translator from pykotor.common.language import Language, LocalizedString from pykotor.common.stream import BinaryReader, BinaryWriter from pykotor.extract.capsule import Capsule @@ -65,7 +66,6 @@ def add_sys_path(path: pathlib.Path): from pykotor.tools.misc import is_any_erf_type_file, is_capsule_file from pykotor.tools.path import CaseAwarePath, find_kotor_paths_from_default from pykotor.tslpatcher.logger import LogType, PatchLog, PatchLogger -from translate.language_translator import TranslationOption, Translator from utility.system.path import Path, PurePath if TYPE_CHECKING: diff --git a/Tools/BatchPatcher/src/translate/__init__.py b/Tools/BatchPatcher/src/batchpatcher/translate/__init__.py similarity index 100% rename from Tools/BatchPatcher/src/translate/__init__.py rename to Tools/BatchPatcher/src/batchpatcher/translate/__init__.py diff --git a/Tools/BatchPatcher/src/translate/deepl_scraper.py b/Tools/BatchPatcher/src/batchpatcher/translate/deepl_scraper.py similarity index 100% rename from Tools/BatchPatcher/src/translate/deepl_scraper.py rename to Tools/BatchPatcher/src/batchpatcher/translate/deepl_scraper.py diff --git a/Tools/BatchPatcher/src/translate/language_translator.py b/Tools/BatchPatcher/src/batchpatcher/translate/language_translator.py similarity index 100% rename from Tools/BatchPatcher/src/translate/language_translator.py rename to Tools/BatchPatcher/src/batchpatcher/translate/language_translator.py diff --git a/Tools/GuiDuplicator/src/__init__.py b/Tools/GuiDuplicator/src/gui_duplicator/__init__.py similarity index 100% rename from Tools/GuiDuplicator/src/__init__.py rename to Tools/GuiDuplicator/src/gui_duplicator/__init__.py diff --git a/Tools/GuiDuplicator/src/__main__.py b/Tools/GuiDuplicator/src/gui_duplicator/__main__.py similarity index 100% rename from Tools/GuiDuplicator/src/__main__.py rename to Tools/GuiDuplicator/src/gui_duplicator/__main__.py diff --git a/Tools/HoloPatcher/src/__init__.py b/Tools/HoloPatcher/src/holopatcher/__init__.py similarity index 100% rename from Tools/HoloPatcher/src/__init__.py rename to Tools/HoloPatcher/src/holopatcher/__init__.py diff --git a/Tools/HoloPatcher/src/__main__.py b/Tools/HoloPatcher/src/holopatcher/__main__.py similarity index 98% rename from Tools/HoloPatcher/src/__main__.py rename to Tools/HoloPatcher/src/holopatcher/__main__.py index b5d8b7da2..4a9d3f07e 100644 --- a/Tools/HoloPatcher/src/__main__.py +++ b/Tools/HoloPatcher/src/holopatcher/__main__.py @@ -56,7 +56,7 @@ def update_sys_path(path): update_sys_path(utility_path.parent) -from config import CURRENT_VERSION, getRemoteHolopatcherUpdateInfo, remoteVersionNewer +from holopatcher.config import CURRENT_VERSION, getRemoteHolopatcherUpdateInfo, remoteVersionNewer from pykotor.common.misc import Game from pykotor.common.stream import BinaryReader from pykotor.extract.file import ResourceIdentifier @@ -70,7 +70,7 @@ def update_sys_path(path): from utility.error_handling import format_exception_with_variables, universal_simplify_exception from utility.misc import ProcessorArchitecture from utility.string_util import striprtf -from utility.system.os_helper import win_get_system32_dir +from utility.system.os_helper import kill_self_pid, win_get_system32_dir from utility.system.path import Path from utility.tkinter.tooltip import ToolTip from utility.tkinter.updater import TkProgressDialog @@ -295,7 +295,11 @@ def initialize_ui_controls(self): self.gamepaths = ttk.Combobox(top_frame, style="TCombobox") self.gamepaths.set("Select your KOTOR directory path") self.gamepaths.grid(row=1, column=0, padx=5, pady=2, sticky="ew") - self.gamepaths["values"] = [str(path) for game in find_kotor_paths_from_default().values() for path in game] + self.gamepaths["values"] = [ + str(path) + for game in find_kotor_paths_from_default().values() + for path in game + ] self.gamepaths.bind("<>", self.on_gamepaths_chosen) # Browse for a KOTOR path self.gamepaths_browse_button = ttk.Button(top_frame, text="Browse", command=self.open_kotor) @@ -1264,6 +1268,7 @@ def task(): def set_state( self, + *, state: bool, ): """Sets the active thread task state. Disables UI controls until this function is called again with run=False. @@ -1325,7 +1330,15 @@ def _execute_mod_install( 8. If CLI, exit regardless of success or error. """ confirm_msg: str = installer.config().confirm_message.strip() - if confirm_msg and not self.one_shot and confirm_msg != "N/A" and not messagebox.askokcancel("This mod requires confirmation", confirm_msg): + if ( + confirm_msg + and not self.one_shot + and confirm_msg != "N/A" + and not messagebox.askokcancel( + "This mod requires confirmation", + confirm_msg, + ) + ): return if progress_update_func is not None: self.progress_bar["maximum"] = len( @@ -1556,9 +1569,9 @@ def onAppCrash( def my_cleanup_function(app: App): """Prevents the patcher from running in the background after sys.exit is called.""" - #print("Fully shutting down Holo Patcher...") - #kill_self_pid() - #app.root.destroy() + print("Fully shutting down HoloPatcher...") + kill_self_pid() + app.root.destroy() def main(): diff --git a/Tools/HoloPatcher/src/config.py b/Tools/HoloPatcher/src/holopatcher/config.py similarity index 98% rename from Tools/HoloPatcher/src/config.py rename to Tools/HoloPatcher/src/holopatcher/config.py index 6a4d6413d..fe66bb7de 100644 --- a/Tools/HoloPatcher/src/config.py +++ b/Tools/HoloPatcher/src/holopatcher/config.py @@ -14,7 +14,7 @@ # <---JSON_START--->#{ "currentVersion": "1.6.0b3", "holopatcherLatestVersion": "1.5.2", - "holopatcherLatestBetaVersion": "1.6.0a1", + "holopatcherLatestBetaVersion": "1.6.0b3", "updateInfoLink": "https://api.github.com/repos/NickHugi/PyKotor/contents/Tools/HoloPatcher/src/config.py", "updateBetaInfoLink": "https://api.github.com/repos/NickHugi/PyKotor/contents/Tools/HoloPatcher/src/config.py?ref=bleeding-edge", "holopatcherDownloadLink": "https://deadlystream.com/files/file/1982-holocron-holopatcher", diff --git a/Tools/HoloPatcher/resources/icons/patcher_icon_v2.icns b/Tools/HoloPatcher/src/resources/icons/patcher_icon_v2.icns similarity index 100% rename from Tools/HoloPatcher/resources/icons/patcher_icon_v2.icns rename to Tools/HoloPatcher/src/resources/icons/patcher_icon_v2.icns diff --git a/Tools/HoloPatcher/resources/icons/patcher_icon_v2.ico b/Tools/HoloPatcher/src/resources/icons/patcher_icon_v2.ico similarity index 100% rename from Tools/HoloPatcher/resources/icons/patcher_icon_v2.ico rename to Tools/HoloPatcher/src/resources/icons/patcher_icon_v2.ico diff --git a/Tools/HoloPatcher/resources/icons/patcher_icon_v2.png b/Tools/HoloPatcher/src/resources/icons/patcher_icon_v2.png similarity index 100% rename from Tools/HoloPatcher/resources/icons/patcher_icon_v2.png rename to Tools/HoloPatcher/src/resources/icons/patcher_icon_v2.png diff --git a/Tools/HolocronToolset/src/toolset/__main__.py b/Tools/HolocronToolset/src/toolset/__main__.py index a03c6522d..3d36fef11 100644 --- a/Tools/HolocronToolset/src/toolset/__main__.py +++ b/Tools/HolocronToolset/src/toolset/__main__.py @@ -150,13 +150,13 @@ def is_running_from_temp(): # app.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True) # app.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True) - app.thread().setPriority(QThread.HighestPriority) + app.thread().setPriority(QThread.Priority.HighestPriority) sys.excepthook = onAppCrash if is_running_from_temp(): # Show error message using PyQt5's QMessageBox msgBox = QMessageBox() - msgBox.setIcon(QMessageBox.Critical) + msgBox.setIcon(QMessageBox.Icon.Critical) msgBox.setWindowTitle("Error") msgBox.setText("This application cannot be run from within a zip or temporary directory. Please extract it to a permanent location before running.") msgBox.exec_() diff --git a/Tools/HolocronToolset/src/toolset/data/me_controls.py b/Tools/HolocronToolset/src/toolset/data/me_controls.py index 9b7b74a92..73d744d1d 100644 --- a/Tools/HolocronToolset/src/toolset/data/me_controls.py +++ b/Tools/HolocronToolset/src/toolset/data/me_controls.py @@ -25,7 +25,7 @@ def getMouseCode(string: str): MOUSE_MAP = { - "LEFT": QtCore.Qt.LeftButton, + "LEFT": QtCore.Qt.MouseButton.LeftButton, "MIDDLE": QtCore.Qt.MiddleButton, "RIGHT": QtCore.Qt.RightButton, } diff --git a/Tools/HolocronToolset/src/toolset/data/settings.py b/Tools/HolocronToolset/src/toolset/data/settings.py index 425189286..593efbfc2 100644 --- a/Tools/HolocronToolset/src/toolset/data/settings.py +++ b/Tools/HolocronToolset/src/toolset/data/settings.py @@ -10,7 +10,7 @@ # Full mapping of Qt.MouseButton values to integers mouseButtonMap: dict[Qt.MouseButton, int] = { Qt.NoButton: 0, - Qt.LeftButton: 1, + Qt.MouseButton.LeftButton: 1, Qt.RightButton: 2, Qt.MiddleButton: 4, Qt.BackButton: 8, diff --git a/Tools/HolocronToolset/src/toolset/gui/dialogs/asyncloader.py b/Tools/HolocronToolset/src/toolset/gui/dialogs/asyncloader.py index 9e536526f..bee7d4090 100644 --- a/Tools/HolocronToolset/src/toolset/gui/dialogs/asyncloader.py +++ b/Tools/HolocronToolset/src/toolset/gui/dialogs/asyncloader.py @@ -133,7 +133,7 @@ def __init__( self.setWindowTitle(title) self.setFixedSize(260, 40) - self.setWindowFlag(QtCore.Qt.WindowContextHelpButtonHint, False) + self.setWindowFlag(Qt.WindowType.WindowContextHelpButtonHint, False) self.value: T = None # type: ignore[assignment] self.error: Exception | None = None @@ -177,7 +177,7 @@ def _onFailed(self, error: Exception): if self.errorTitle: error_msg = str(universal_simplify_exception(error)).replace("\n", "
") - QMessageBox(QMessageBox.Critical, self.errorTitle, error_msg).exec_() + QMessageBox(QMessageBox.Icon.Critical, self.errorTitle, error_msg).exec_() class AsyncWorker(QThread): @@ -249,7 +249,7 @@ def __init__( self.setWindowTitle(title) self.setFixedSize(260, 40) - self.setWindowFlag(QtCore.Qt.WindowContextHelpButtonHint, False) + self.setWindowFlag(Qt.WindowType.WindowContextHelpButtonHint, False) self.value: list[Any] = [] self.errors: list[Exception] = [] @@ -307,10 +307,10 @@ def _onAllCompleted(self): if self.failCount: errorTitle = f"{self.errorTitle} ({self.failCount} errors)" QMessageBox( - QMessageBox.Critical, + QMessageBox.Icon.Critical, errorTitle, "\n".join(str(universal_simplify_exception(error)).replace(",", ":", 1) + "
" for error in self.errors), - flags=Qt.Window | Qt.Dialog | Qt.WindowStaysOnTopHint, + flags=Qt.WindowType.Window | Qt.WindowType.Dialog | Qt.WindowType.WindowStaysOnTopHint, ).exec_() diff --git a/Tools/HolocronToolset/src/toolset/gui/dialogs/clone_module.py b/Tools/HolocronToolset/src/toolset/gui/dialogs/clone_module.py index 40950d10f..f524e51e9 100644 --- a/Tools/HolocronToolset/src/toolset/gui/dialogs/clone_module.py +++ b/Tools/HolocronToolset/src/toolset/gui/dialogs/clone_module.py @@ -128,20 +128,20 @@ def task(): if copyTextures: QMessageBox( - QMessageBox.Information, + QMessageBox.Icon.Information, "This may take a while", "You have selected to create copies of the " "texture. This process may add a few extra minutes to the waiting time.", - flags=Qt.Window | Qt.Dialog | Qt.WindowStaysOnTopHint, + flags=Qt.WindowType.Window | Qt.WindowType.Dialog | Qt.WindowType.WindowStaysOnTopHint, ).exec_() if not AsyncLoader(self, "Creating module", task, "Failed to create module").exec_(): return QMessageBox( - QMessageBox.Information, + QMessageBox.Icon.Information, "Clone Successful", f"You can now warp to the cloned module '{identifier}'.", - flags=Qt.Window | Qt.Dialog | Qt.WindowStaysOnTopHint, + flags=Qt.WindowType.Window | Qt.WindowType.Dialog | Qt.WindowType.WindowStaysOnTopHint, ).exec_() def loadModules(self): diff --git a/Tools/HolocronToolset/src/toolset/gui/dialogs/insert_instance.py b/Tools/HolocronToolset/src/toolset/gui/dialogs/insert_instance.py index 34587d074..a656221d9 100644 --- a/Tools/HolocronToolset/src/toolset/gui/dialogs/insert_instance.py +++ b/Tools/HolocronToolset/src/toolset/gui/dialogs/insert_instance.py @@ -109,7 +109,7 @@ def _setupResourceList(self): if resource.restype() == self._restype: item = QListWidgetItem(resource.resname()) item.setToolTip(str(resource.filepath())) - item.setData(QtCore.Qt.UserRole, resource) + item.setData(QtCore.Qt.ItemDataRole.UserRole, resource) self.ui.resourceList.addItem(item) for capsule in self._module.capsules(): @@ -118,7 +118,7 @@ def _setupResourceList(self): item = QListWidgetItem(resource.resname()) item.setToolTip(str(resource.filepath())) item.setForeground(QColor(30, 30, 30)) - item.setData(QtCore.Qt.UserRole, resource) + item.setData(QtCore.Qt.ItemDataRole.UserRole, resource) self.ui.resourceList.addItem(item) if self.ui.resourceList.count() > 0: @@ -137,7 +137,7 @@ def accept(self): super().accept() new = True - resource: FileResource = self.ui.resourceList.selectedItems()[0].data(QtCore.Qt.UserRole) + resource: FileResource = self.ui.resourceList.selectedItems()[0].data(QtCore.Qt.ItemDataRole.UserRole) if self.ui.reuseResourceRadio.isChecked(): new = False @@ -192,16 +192,16 @@ def onResourceRadioToggled(self): self.ui.resrefEdit.setEnabled(not self.ui.reuseResourceRadio.isChecked()) if self.ui.reuseResourceRadio.isChecked(): - self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(True) + self.ui.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(True) if self.ui.copyResourceRadio.isChecked(): - self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(self.isValidResref(self.ui.resrefEdit.text())) + self.ui.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(self.isValidResref(self.ui.resrefEdit.text())) if self.ui.createResourceRadio.isChecked(): - self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(self.isValidResref(self.ui.resrefEdit.text())) + self.ui.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(self.isValidResref(self.ui.resrefEdit.text())) def onResRefEdited(self, text: str): - self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(self.isValidResref(text)) + self.ui.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(self.isValidResref(text)) def onResourceFilterChanged(self): text = self.ui.resourceFilter.text() diff --git a/Tools/HolocronToolset/src/toolset/gui/dialogs/inventory.py b/Tools/HolocronToolset/src/toolset/gui/dialogs/inventory.py index ff2b4362b..6be4cb6ab 100644 --- a/Tools/HolocronToolset/src/toolset/gui/dialogs/inventory.py +++ b/Tools/HolocronToolset/src/toolset/gui/dialogs/inventory.py @@ -35,17 +35,17 @@ import os from qtpy.QtCore import QModelIndex, QPoint - from qtpy.QtGui import QDragEnterEvent, QDragMoveEvent, QDropEvent, QWidget - from qtpy.QtWidgets import QLabel + from qtpy.QtGui import QDragEnterEvent, QDragMoveEvent, QDropEvent + from qtpy.QtWidgets import QLabel, QWidget from pykotor.extract.file import ResourceIdentifier, ResourceResult from pykotor.resource.formats.tlk import TLK from pykotor.resource.formats.twoda.twoda_data import TwoDA from pykotor.resource.generics.uti import UTI -_RESNAME_ROLE = QtCore.Qt.UserRole + 1 -_FILEPATH_ROLE = QtCore.Qt.UserRole + 2 -_SLOTS_ROLE = QtCore.Qt.UserRole + 3 +_RESNAME_ROLE = QtCore.Qt.ItemDataRole.UserRole + 1 +_FILEPATH_ROLE = QtCore.Qt.ItemDataRole.UserRole + 2 +_SLOTS_ROLE = QtCore.Qt.ItemDataRole.UserRole + 3 class SlotMapping(NamedTuple): @@ -110,11 +110,11 @@ def __init__( self.ui.contentsTable.is_store = is_store self.ui.coreTree.setSortingEnabled(True) - self.ui.coreTree.sortByColumn(0, QtCore.Qt.DescendingOrder) + self.ui.coreTree.sortByColumn(0, QtCore.Qt.SortOrder.DescendingOrder) self.ui.modulesTree.setSortingEnabled(True) - self.ui.modulesTree.sortByColumn(0, QtCore.Qt.DescendingOrder) + self.ui.modulesTree.sortByColumn(0, QtCore.Qt.SortOrder.DescendingOrder) self.ui.overrideTree.setSortingEnabled(True) - self.ui.overrideTree.sortByColumn(0, QtCore.Qt.DescendingOrder) + self.ui.overrideTree.sortByColumn(0, QtCore.Qt.SortOrder.DescendingOrder) self.ui.coreSearchEdit.textEdited.connect(self.doSearch) self.ui.modulesSearchEdit.textEdited.connect(self.doSearch) self.ui.modulesSearchEdit.textEdited.connect(self.doSearch) @@ -249,7 +249,7 @@ def buildItems(self): else: self.reject() - def getItemImage(self, uti: UTI | None) -> QPixmap: + def getItemImage(self, uti: UTI) -> QPixmap: return self._installation.getItemIconFromUTI(uti) def getItem( @@ -392,6 +392,7 @@ def openItemContextMenu( menu.addAction(noItemAction) menu.addSeparator() + # TODO: #setItemAction = QAction("Set Item ResRef") #setItemAction.triggered.connect(lambda: self.promptSetItemResRefDialog(widget)) #menu.addAction(setItemAction) @@ -454,7 +455,7 @@ class DropFrame(ItemContainer, QFrame): def __init__(self, parent: QWidget | None): QFrame.__init__(self) ItemContainer.__init__(self) - self.setFrameShape(QFrame.Box) + self.setFrameShape(QFrame.Shape.Box) self.setAcceptDrops(True) self.slot: EquipmentSlot = EquipmentSlot.HIDE @@ -530,7 +531,7 @@ def dropEvent(self, event: QDropEvent): - Emits a signal with the new item details. """ if isinstance(event.source(), QTreeView): - event.setDropAction(QtCore.Qt.CopyAction) + event.setDropAction(QtCore.Qt.DropAction.CopyAction) tree: QTreeView | None = event.source() # type: ignore[] proxyModel: QSortFilterProxyModel = tree.model() @@ -584,7 +585,7 @@ def addItem( filepath, name, uti = self.window().getItem(resname, "") iconItem: QTableWidgetItem = self._set_uti(uti) nameItem = QTableWidgetItem(name) - nameItem.setFlags(nameItem.flags() ^ QtCore.Qt.ItemIsEditable) + nameItem.setFlags(nameItem.flags() ^ QtCore.Qt.ItemFlag.ItemIsEditable) resnameItem = InventoryTableResnameItem(resname, filepath, name, droppable, infinite) self._set_row(rowID, iconItem, resnameItem, nameItem) @@ -604,7 +605,7 @@ def dropEvent(self, event: QDropEvent | None): - Populate row with icon, resname and name from dropped item. """ if isinstance(event.source(), QTreeView): - event.setDropAction(QtCore.Qt.CopyAction) + event.setDropAction(QtCore.Qt.DropAction.CopyAction) tree: QTreeView = event.source() proxyModel: QSortFilterProxyModel = tree.model() @@ -617,7 +618,7 @@ def dropEvent(self, event: QDropEvent | None): filepath, name, uti = self.window().getItem(item.data(_RESNAME_ROLE), item.data(_FILEPATH_ROLE)) iconItem: QTableWidgetItem = self._set_uti(uti) nameItem = QTableWidgetItem(item.text()) - nameItem.setFlags(nameItem.flags() ^ QtCore.Qt.ItemIsEditable) + nameItem.setFlags(nameItem.flags() ^ QtCore.Qt.ItemFlag.ItemIsEditable) resnameItem = InventoryTableResnameItem(item.data(_RESNAME_ROLE), item.data(_FILEPATH_ROLE), item.text(), False, False) self._set_row(rowID, iconItem, resnameItem, nameItem) @@ -636,7 +637,7 @@ def _set_uti(self, uti: UTI) -> QTableWidgetItem: pixmap = self.window().getItemImage(uti) result = QTableWidgetItem(QIcon(pixmap), "") result.setSizeHint(QSize(48, 48)) - result.setFlags(result.flags() ^ QtCore.Qt.ItemIsEditable) + result.setFlags(result.flags() ^ QtCore.Qt.ItemFlag.ItemIsEditable) return result def resnameChanged(self, tableItem: QTableWidgetItem): @@ -661,7 +662,7 @@ def resnameChanged(self, tableItem: QTableWidgetItem): tableItem.setItem(tableItem.text(), filepath, name, tableItem.droppable, tableItem.infinite) self.item(tableItem.row(), 0).setIcon(icon) nameItem = QTableWidgetItem(name) - nameItem.setFlags(nameItem.flags() ^ QtCore.Qt.ItemIsEditable) + nameItem.setFlags(nameItem.flags() ^ QtCore.Qt.ItemFlag.ItemIsEditable) self.setItem(tableItem.row(), 2, nameItem) def openContextMenu(self, point: QPoint): @@ -723,7 +724,7 @@ def removeItem(self): self.tableWidget().removeRow(self.row()) -class ItemBuilderDialog(QDialog): +class ItemBuilderDialog(QDialog): # FIXME(th3w1zard1): There is UI code used in this builder!!! Should only manage UI code in main thread. """Popup dialog responsible for extracting a list of resources from the game files.""" def __init__( @@ -797,9 +798,13 @@ def getCategory(self, uti: UTI | None) -> str: - Return category based on first matching slot - Return default categories if no slots match. """ - baseitems: TwoDA = self._installation.htGetCache2DA(HTInstallation.TwoDA_BASEITEMS) - slots: int = -1 if uti is None else baseitems.get_row(uti.base_item).get_integer("equipableslots", 0) - droid: bool = False if uti is None else baseitems.get_row(uti.base_item).get_integer("droidorhuman", 0) == 2 + if uti is None: + slots: int = -1 + droid: bool = False + else: + baseitems: TwoDA = self._installation.htGetCache2DA(HTInstallation.TwoDA_BASEITEMS) + slots = baseitems.get_row(uti.base_item).get_integer("equipableslots", 0) + droid = baseitems.get_row(uti.base_item).get_integer("droidorhuman", 0) == 2 if slots & (EquipmentSlot.CLAW1.value | EquipmentSlot.CLAW2.value | EquipmentSlot.CLAW3.value): return "Creature Claw" diff --git a/Tools/HolocronToolset/src/toolset/gui/dialogs/load_from_module.py b/Tools/HolocronToolset/src/toolset/gui/dialogs/load_from_module.py index 6ce726981..89d8aa248 100644 --- a/Tools/HolocronToolset/src/toolset/gui/dialogs/load_from_module.py +++ b/Tools/HolocronToolset/src/toolset/gui/dialogs/load_from_module.py @@ -52,13 +52,13 @@ def __init__(self, capsule: Capsule, supported: list[ResourceType]): continue filename = resource.filename() item = QListWidgetItem(filename) - item.setData(Qt.UserRole, resource) + item.setData(Qt.ItemDataRole.UserRole, resource) self.ui.resourceList.addItem(item) def resname(self) -> str | None: currentItem: QListWidgetItem | None = self.ui.resourceList.currentItem() if currentItem: - resource: FileResource = currentItem.data(Qt.UserRole) + resource: FileResource = currentItem.data(Qt.ItemDataRole.UserRole) if resource: return resource.resname() return None @@ -66,7 +66,7 @@ def resname(self) -> str | None: def restype(self) -> ResourceType | None: currentItem: QListWidgetItem | None = self.ui.resourceList.currentItem() if currentItem: - resource: FileResource = currentItem.data(Qt.UserRole) + resource: FileResource = currentItem.data(Qt.ItemDataRole.UserRole) if resource: return resource.restype() return None @@ -74,7 +74,7 @@ def restype(self) -> ResourceType | None: def data(self) -> bytes | None: currentItem: QListWidgetItem | None = self.ui.resourceList.currentItem() if currentItem: - resource: FileResource = currentItem.data(Qt.UserRole) + resource: FileResource = currentItem.data(Qt.ItemDataRole.UserRole) if resource: return resource.data() return None diff --git a/Tools/HolocronToolset/src/toolset/gui/dialogs/search.py b/Tools/HolocronToolset/src/toolset/gui/dialogs/search.py index 7fc5ce1e4..a1232faee 100644 --- a/Tools/HolocronToolset/src/toolset/gui/dialogs/search.py +++ b/Tools/HolocronToolset/src/toolset/gui/dialogs/search.py @@ -228,11 +228,11 @@ def __init__( filepath = result.filepath() parent_name = filepath.name if filename != filepath.name else f"{filepath.parent.name}" item = QListWidgetItem(f"{parent_name}/{filename}") - item.setData(QtCore.Qt.UserRole, result) + item.setData(QtCore.Qt.ItemDataRole.UserRole, result) item.setToolTip(str(result.filepath())) self.ui.resultList.addItem(item) - self.ui.resultList.sortItems(QtCore.Qt.AscendingOrder) + self.ui.resultList.sortItems(QtCore.Qt.SortOrder.AscendingOrder) def accept(self): """Accepts the current selection from the result list. @@ -249,7 +249,7 @@ def accept(self): """ item = self.ui.resultList.currentItem() if item: - self.selection = item.data(QtCore.Qt.UserRole) + self.selection = item.data(QtCore.Qt.ItemDataRole.UserRole) self.selectionSignal.emit(self.selection) super().accept() @@ -272,7 +272,7 @@ def open(self): print("Nothing to open, item is None") return - resource: FileResource = item.data(QtCore.Qt.UserRole) + resource: FileResource = item.data(QtCore.Qt.ItemDataRole.UserRole) openResourceEditor( filepath=resource.filepath(), resref=resource.resname(), diff --git a/Tools/HolocronToolset/src/toolset/gui/dialogs/select_module.py b/Tools/HolocronToolset/src/toolset/gui/dialogs/select_module.py index 5e49593fb..215479035 100644 --- a/Tools/HolocronToolset/src/toolset/gui/dialogs/select_module.py +++ b/Tools/HolocronToolset/src/toolset/gui/dialogs/select_module.py @@ -82,7 +82,7 @@ def _buildModuleList(self): listedModules.add(root) item = QListWidgetItem(f"{moduleNames[module]} [{root}]") - item.setData(QtCore.Qt.UserRole, root) + item.setData(QtCore.Qt.ItemDataRole.UserRole, root) self.ui.moduleList.addItem(item) def browse(self): @@ -106,7 +106,7 @@ def confirm(self): - Gets the currently selected module from the module list widget - Calls accept to close the dialog and apply changes. """ - self.module = self.ui.moduleList.currentItem().data(QtCore.Qt.UserRole) + self.module = self.ui.moduleList.currentItem().data(QtCore.Qt.ItemDataRole.UserRole) self.accept() def onRowChanged(self): diff --git a/Tools/HolocronToolset/src/toolset/gui/dialogs/select_update.py b/Tools/HolocronToolset/src/toolset/gui/dialogs/select_update.py index c5067e88f..c1c8e425c 100644 --- a/Tools/HolocronToolset/src/toolset/gui/dialogs/select_update.py +++ b/Tools/HolocronToolset/src/toolset/gui/dialogs/select_update.py @@ -171,7 +171,7 @@ def populate_fork_combo_box(self): self.forkComboBox.addItem(fork) def on_pre_release_changed(self, state: bool): - self.include_prerelease = state == Qt.Checked + self.include_prerelease = state == Qt.CheckState.Checked self.filter_releases_based_on_prerelease() def filter_releases_based_on_prerelease(self): @@ -215,7 +215,7 @@ def on_update_latest_clicked(self): def on_install_selected(self): release = self.releaseComboBox.currentData() if not release: - QMessageBox(QMessageBox.Information, "Select a release", "No release selected, select one first.").exec_() + QMessageBox(QMessageBox.Icon.Information, "Select a release", "No release selected, select one first.").exec_() return self.start_update(release) @@ -229,12 +229,12 @@ def start_update(self, release: GithubRelease): links = [download_url] else: result = QMessageBox( # TODO(th3w1zard1): compile from src - QMessageBox.Question, + QMessageBox.Icon.Question, "No asset found for this release.", "There are no binaries available for download. Would you like to compile this release from source instead?", QMessageBox.Yes | QMessageBox.No, None, - flags=Qt.Window | Qt.Dialog | Qt.WindowStaysOnTopHint, + flags=Qt.WindowType.Window | Qt.WindowType.Dialog | Qt.WindowType.WindowStaysOnTopHint, ).exec_() return diff --git a/Tools/HolocronToolset/src/toolset/gui/editor.py b/Tools/HolocronToolset/src/toolset/gui/editor.py index 049dcd84d..f6d990a17 100644 --- a/Tools/HolocronToolset/src/toolset/gui/editor.py +++ b/Tools/HolocronToolset/src/toolset/gui/editor.py @@ -6,7 +6,7 @@ from qtpy import QtCore from qtpy.QtCore import Qt from qtpy.QtGui import QIcon, QPixmap -from qtpy.QtWidgets import QFileDialog, QLineEdit, QMainWindow, QMessageBox, QPlainTextEdit, QShortcut +from qtpy.QtWidgets import QFileDialog, QLineEdit, QMainWindow, QMenu, QMessageBox, QPlainTextEdit, QShortcut from pykotor.common.module import Module from pykotor.common.stream import BinaryReader @@ -90,10 +90,12 @@ def __init__( additional_formats = {"XML", "JSON", "CSV", "ASCII", "YAML"} for add_format in additional_formats: readSupported.extend( - ResourceType.__members__[f"{restype.name}_{add_format}"] for restype in readSupported if f"{restype.name}_{add_format}" in ResourceType.__members__ + ResourceType.__members__[f"{restype.name}_{add_format}"] + for restype in readSupported if f"{restype.name}_{add_format}" in ResourceType.__members__ ) writeSupported.extend( - ResourceType.__members__[f"{restype.name}_{add_format}"] for restype in writeSupported if f"{restype.name}_{add_format}" in ResourceType.__members__ + ResourceType.__members__[f"{restype.name}_{add_format}"] + for restype in writeSupported if f"{restype.name}_{add_format}" in ResourceType.__members__ ) self._readSupported: list[ResourceType] = readSupported self._writeSupported: list[ResourceType] = writeSupported @@ -130,7 +132,10 @@ def _setupMenus(self): - Sets Revert action to disabled - Connects keyboard shortcuts for New, Open, Save, Save As, Revert and Exit. """ - for action in self.menuBar().actions()[0].menu().actions(): + menubar = self.menuBar().actions()[0].menu() + if not isinstance(menubar, QMenu): + raise TypeError(f"self.menuBar().actions()[0].menu() returned a {type(menubar).__name__} object, expected QMenu.") + for action in menubar.actions(): if action.text() == "New": # sourcery skip: extract-method action.triggered.connect(self.new) if action.text() == "Open": @@ -202,11 +207,11 @@ def saveAs(self): get_root_logger().exception("ValueError raised, assuming invalid filename/extension '%s'", filepath_str) error_msg = str(universal_simplify_exception(e)).replace("\n", "
") QMessageBox( - QMessageBox.Critical, + QMessageBox.Icon.Critical, "Invalid filename/extension", f"Check the filename and try again. Could not save!

{error_msg}", parent=None, - flags=Qt.Window | Qt.Dialog | Qt.WindowStaysOnTopHint, + flags=Qt.WindowType.Window | Qt.WindowType.Dialog | Qt.WindowType.WindowStaysOnTopHint, ).exec_() return @@ -268,7 +273,7 @@ def save(self): file.writelines(lines) file.write("\n----------------------\n") error_msg = str(universal_simplify_exception(e)).replace("\n", "
") - QMessageBox(QMessageBox.Critical, "Failed to write to file", error_msg).exec_() + QMessageBox(QMessageBox.Icon.Critical, "Failed to write to file", error_msg).exec_() def _saveEndsWithBif(self, data: bytes, data_ext: bytes): """Saves data if dialog returns specific options. diff --git a/Tools/HolocronToolset/src/toolset/gui/editors/bwm.py b/Tools/HolocronToolset/src/toolset/gui/editors/bwm.py index 2b152ae2f..c2f6adf92 100644 --- a/Tools/HolocronToolset/src/toolset/gui/editors/bwm.py +++ b/Tools/HolocronToolset/src/toolset/gui/editors/bwm.py @@ -25,8 +25,8 @@ from pykotor.resource.formats.bwm import BWM, BWMFace from toolset.data.installation import HTInstallation -_TRANS_FACE_ROLE = QtCore.Qt.UserRole + 1 # type: ignore[attr-defined] -_TRANS_EDGE_ROLE = QtCore.Qt.UserRole + 2 # type: ignore[attr-defined] +_TRANS_FACE_ROLE = QtCore.Qt.ItemDataRole.UserRole + 1 # type: ignore[attr-defined] +_TRANS_EDGE_ROLE = QtCore.Qt.ItemDataRole.UserRole + 2 # type: ignore[attr-defined] class BWMEditor(Editor): @@ -122,7 +122,7 @@ def rebuildMaterials(self): icon = QIcon(QPixmap(image)) text = material.name.replace("_", " ").title() item = QListWidgetItem(icon, text) - item.setData(QtCore.Qt.UserRole, material) # type: ignore[attr-defined] + item.setData(QtCore.Qt.ItemDataRole.UserRole, material) # type: ignore[attr-defined] self.ui.materialList.addItem(item) def load(self, filepath: os.PathLike | str, resref: str, restype: ResourceType, data: bytes): @@ -187,11 +187,11 @@ def onMouseMoved(self, screen: Vector2, delta: Vector2, buttons: set[int], keys: worldData: Vector2 = self.ui.renderArea.toWorldDelta(delta.x, delta.y) face: BWMFace | None = self._bwm.faceAt(world.x, world.y) - if QtCore.Qt.LeftButton in buttons and QtCore.Qt.Key_Control in keys: # type: ignore[attr-defined] + if QtCore.Qt.MouseButton.LeftButton in buttons and QtCore.Qt.Key_Control in keys: # type: ignore[attr-defined] self.ui.renderArea.camera.nudgePosition(-worldData.x, -worldData.y) elif QtCore.Qt.MiddleButton in buttons and QtCore.Qt.Key_Control in keys: # type: ignore[attr-defined] self.ui.renderArea.camera.nudgeRotation(delta.x / 50) - elif QtCore.Qt.LeftButton in buttons and face is not None: # face will be None if user is clicking on nothing/background. + elif QtCore.Qt.MouseButton.LeftButton in buttons and face is not None: # face will be None if user is clicking on nothing/background. self.changeFaceMaterial(face) coordsText = f"x: {world.x:.2f}, {world.y:.2f}" @@ -224,7 +224,7 @@ def changeFaceMaterial(self, face: BWMFace): - Check if the current face material is different than the selected material - Assign the selected material to the provided face. """ - newMaterial = self.ui.materialList.currentItem().data(QtCore.Qt.UserRole) # type: ignore[attr-defined] + newMaterial = self.ui.materialList.currentItem().data(QtCore.Qt.ItemDataRole.UserRole) # type: ignore[attr-defined] if face and face.material != newMaterial: face.material = newMaterial diff --git a/Tools/HolocronToolset/src/toolset/gui/editors/dlg.py b/Tools/HolocronToolset/src/toolset/gui/editors/dlg.py index 50c48609c..0fb1f5ffa 100644 --- a/Tools/HolocronToolset/src/toolset/gui/editors/dlg.py +++ b/Tools/HolocronToolset/src/toolset/gui/editors/dlg.py @@ -52,8 +52,8 @@ DLGStunt, ) -_LINK_ROLE = QtCore.Qt.UserRole + 1 -_COPY_ROLE = QtCore.Qt.UserRole + 2 +_LINK_ROLE = QtCore.Qt.ItemDataRole.UserRole + 1 +_COPY_ROLE = QtCore.Qt.ItemDataRole.UserRole + 2 class GFFFieldSpinBox(QSpinBox): @@ -1266,14 +1266,14 @@ def onAddStuntClicked(self): def onRemoveStuntClicked(self): if self.ui.stuntList.selectedItems(): item: QListWidgetItem = self.ui.stuntList.selectedItems()[0] - stunt: DLGStunt = item.data(QtCore.Qt.UserRole) + stunt: DLGStunt = item.data(QtCore.Qt.ItemDataRole.UserRole) self._dlg.stunts.remove(stunt) self.refreshStuntList() def onEditStuntClicked(self): if self.ui.stuntList.selectedItems(): item: QListWidgetItem = self.ui.stuntList.selectedItems()[0] - stunt: DLGStunt = item.data(QtCore.Qt.UserRole) + stunt: DLGStunt = item.data(QtCore.Qt.ItemDataRole.UserRole) dialog = CutsceneModelDialog(self, stunt) if dialog.exec_(): stunt.stunt_model = dialog.stunt().stunt_model @@ -1285,7 +1285,7 @@ def refreshStuntList(self): for stunt in self._dlg.stunts: text = f"{stunt.stunt_model} ({stunt.participant})" item = QListWidgetItem(text) - item.setData(QtCore.Qt.UserRole, stunt) + item.setData(QtCore.Qt.ItemDataRole.UserRole, stunt) self.ui.stuntList.addItem(item) def onAddAnimClicked(self): @@ -1306,14 +1306,14 @@ def onRemoveAnimClicked(self): node: DLGNode = item.data(_LINK_ROLE).node animItem: QListWidgetItem = self.ui.animsList.selectedItems()[0] - anim: DLGAnimation = animItem.data(QtCore.Qt.UserRole) + anim: DLGAnimation = animItem.data(QtCore.Qt.ItemDataRole.UserRole) node.animations.remove(anim) self.refreshAnimList() def onEditAnimClicked(self): if self.ui.animsList.selectedItems(): animItem: QListWidgetItem = self.ui.animsList.selectedItems()[0] - anim: DLGAnimation = animItem.data(QtCore.Qt.UserRole) + anim: DLGAnimation = animItem.data(QtCore.Qt.ItemDataRole.UserRole) dialog = EditAnimationDialog(self, self._installation, anim) if dialog.exec_(): anim.animation_id = dialog.animation().animation_id @@ -1350,5 +1350,5 @@ def refreshAnimList(self): name = animations_2da.get_cell(anim.animation_id, "name") text: str = f"{name} ({anim.participant})" item = QListWidgetItem(text) - item.setData(QtCore.Qt.UserRole, anim) + item.setData(QtCore.Qt.ItemDataRole.UserRole, anim) self.ui.animsList.addItem(item) diff --git a/Tools/HolocronToolset/src/toolset/gui/editors/erf.py b/Tools/HolocronToolset/src/toolset/gui/editors/erf.py index 29532e738..8f10fdae5 100644 --- a/Tools/HolocronToolset/src/toolset/gui/editors/erf.py +++ b/Tools/HolocronToolset/src/toolset/gui/editors/erf.py @@ -165,11 +165,11 @@ def load(self, filepath: os.PathLike | str, resref: str, restype: ResourceType, else: QMessageBox( - QMessageBox.Critical, + QMessageBox.Icon.Critical, "Unable to load file", "The file specified is not a MOD/ERF type file.", parent=self, - flags=Qt.Window | Qt.Dialog | Qt.WindowStaysOnTopHint, + flags=Qt.WindowType.Window | Qt.WindowType.Dialog | Qt.WindowType.WindowStaysOnTopHint, ).show() def build(self) -> tuple[bytes, bytes]: @@ -312,10 +312,10 @@ def addResources(self, filepaths: list[str]): get_root_logger().exception("Failed to add resource at %s", c_filepath.absolute()) error_msg = str(universal_simplify_exception(e)).replace("\n", "
") QMessageBox( - QMessageBox.Critical, + QMessageBox.Icon.Critical, "Failed to add resource", f"Could not add resource at {c_filepath.absolute()}:

{error_msg}", - flags=Qt.Window | Qt.Dialog | Qt.WindowStaysOnTopHint, + flags=Qt.WindowType.Window | Qt.WindowType.Dialog | Qt.WindowType.WindowStaysOnTopHint, ).exec_() def selectFilesToAdd(self): @@ -334,7 +334,7 @@ def openSelected(self): - Opens the resource in an editor window. """ if self._filepath is None: - QMessageBox(QMessageBox.Critical, "Cannot edit resource", "Save the ERF and try again.", QMessageBox.Ok, self).exec_() + QMessageBox(QMessageBox.Icon.Critical, "Cannot edit resource", "Save the ERF and try again.", QMessageBox.StandardButton.Ok, self).exec_() return for index in self.ui.tableView.selectionModel().selectedRows(0): @@ -343,12 +343,12 @@ def openSelected(self): if resource.restype.name in ERFType.__members__: QMessageBox( - QMessageBox.Warning, + QMessageBox.Icon.Warning, "Nested ERF/RIM files is mostly unsupported.", "You are attempting to open a nested ERF/RIM. Any action besides extracting from them will not work. You've been warned.", - QMessageBox.Ok, + QMessageBox.StandardButton.Ok, self, - flags=Qt.Window | Qt.Dialog | Qt.WindowStaysOnTopHint, + flags=Qt.WindowType.Window | Qt.WindowType.Dialog | Qt.WindowType.WindowStaysOnTopHint, ).exec_() new_filepath = self._filepath if resource.restype.name in ERFType.__members__ or resource.restype == ResourceType.RIM: @@ -432,14 +432,14 @@ def dragEnterEvent(self, event: QDragEnterEvent): def dragMoveEvent(self, event: QDragMoveEvent): if event.mimeData().hasUrls: - event.setDropAction(QtCore.Qt.CopyAction) + event.setDropAction(QtCore.Qt.DropAction.CopyAction) event.accept() else: event.ignore() def dropEvent(self, event: QDropEvent): if event.mimeData().hasUrls: - event.setDropAction(QtCore.Qt.CopyAction) + event.setDropAction(QtCore.Qt.DropAction.CopyAction) event.accept() links: list[str] = [str(url.toLocalFile()) for url in event.mimeData().urls()] self.resourceDropped.emit(links) @@ -469,7 +469,7 @@ def startDrag(self, actions: QtCore.Qt.DropActions | QtCore.Qt.DropAction): urls: list[QtCore.QUrl] = [] for index in (index for index in self.selectedIndexes() if not index.column()): - resource: ERFResource = self.model().itemData(index)[QtCore.Qt.UserRole + 1] + resource: ERFResource = self.model().itemData(index)[QtCore.Qt.ItemDataRole.UserRole + 1] file_stem, file_ext = str(resource.resref), resource.restype.extension filepath = Path(tempDir, f"{file_stem}.{file_ext}") with filepath.open("wb") as file: @@ -480,4 +480,4 @@ def startDrag(self, actions: QtCore.Qt.DropActions | QtCore.Qt.DropAction): mimeData.setUrls(urls) drag = QtGui.QDrag(self) drag.setMimeData(mimeData) - drag.exec_(QtCore.Qt.CopyAction, QtCore.Qt.CopyAction) + drag.exec_(QtCore.Qt.DropAction.CopyAction, QtCore.Qt.DropAction.CopyAction) diff --git a/Tools/HolocronToolset/src/toolset/gui/editors/gff.py b/Tools/HolocronToolset/src/toolset/gui/editors/gff.py index 0636a8379..f2ef018a1 100644 --- a/Tools/HolocronToolset/src/toolset/gui/editors/gff.py +++ b/Tools/HolocronToolset/src/toolset/gui/editors/gff.py @@ -25,12 +25,12 @@ from toolset.data.installation import HTInstallation -_VALUE_NODE_ROLE = QtCore.Qt.UserRole + 1 -_TYPE_NODE_ROLE = QtCore.Qt.UserRole + 2 -_LABEL_NODE_ROLE = QtCore.Qt.UserRole + 3 +_VALUE_NODE_ROLE = QtCore.Qt.ItemDataRole.UserRole + 1 +_TYPE_NODE_ROLE = QtCore.Qt.ItemDataRole.UserRole + 2 +_LABEL_NODE_ROLE = QtCore.Qt.ItemDataRole.UserRole + 3 -_ID_SUBSTRING_ROLE = QtCore.Qt.UserRole + 1 -_TEXT_SUBSTRING_ROLE = QtCore.Qt.UserRole + 2 +_ID_SUBSTRING_ROLE = QtCore.Qt.ItemDataRole.UserRole + 1 +_TEXT_SUBSTRING_ROLE = QtCore.Qt.ItemDataRole.UserRole + 2 class GFFEditor(Editor): @@ -58,9 +58,9 @@ def __init__(self, parent: QWidget | None, installation: HTInstallation | None = self._setupMenus() self._setupSignals() - self.ui.treeView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.ui.treeView.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) - self.ui.treeView.sortByColumn(0, QtCore.Qt.AscendingOrder) + self.ui.treeView.sortByColumn(0, QtCore.Qt.SortOrder.AscendingOrder) self.ui.treeView.setSortingEnabled(True) # Make the right panel take as little space possible diff --git a/Tools/HolocronToolset/src/toolset/gui/editors/git.py b/Tools/HolocronToolset/src/toolset/gui/editors/git.py index bbfa8d1f3..e8d04dc9d 100644 --- a/Tools/HolocronToolset/src/toolset/gui/editors/git.py +++ b/Tools/HolocronToolset/src/toolset/gui/editors/git.py @@ -653,7 +653,7 @@ def setSelection(self, instances: list[GITInstance]): self._ui.listWidget.blockSignals(True) for i in range(self._ui.listWidget.count()): item = self._ui.listWidget.item(i) - instance = item.data(QtCore.Qt.UserRole) + instance = item.data(QtCore.Qt.ItemDataRole.UserRole) if instance in instances: self._ui.listWidget.setCurrentItem(item) self._ui.listWidget.blockSignals(False) @@ -775,7 +775,7 @@ def setListItemLabel(self, item: QListWidgetItem, instance: GITInstance): Sets the item data and tooltip, determines the label text based on instance type and editor settings, sets the item text and font if label not found. """ - item.setData(QtCore.Qt.UserRole, instance) + item.setData(QtCore.Qt.ItemDataRole.UserRole, instance) item.setToolTip(self.getInstanceTooltip(instance)) name: str | None = None @@ -848,7 +848,7 @@ def onItemSelectionChanged(self, item: QListWidgetItem): if item is None: self.setSelection([]) else: - self.setSelection([item.data(QtCore.Qt.UserRole)]) + self.setSelection([item.data(QtCore.Qt.ItemDataRole.UserRole)]) def updateStatusBar(self, world: Vector2): if self._ui.renderArea.instancesUnderMouse() and self._ui.renderArea.instancesUnderMouse()[-1] is not None: @@ -862,7 +862,7 @@ def openListContextMenu(self, item: QListWidgetItem, point: QPoint): if item is None: return - instance = item.data(QtCore.Qt.UserRole) + instance = item.data(QtCore.Qt.ItemDataRole.UserRole) menu = QMenu(self._ui.listWidget) self.addInstanceActionsToMenu(instance, menu) diff --git a/Tools/HolocronToolset/src/toolset/gui/editors/mdl.py b/Tools/HolocronToolset/src/toolset/gui/editors/mdl.py index 2a1a6a8b6..fd2d9cba2 100644 --- a/Tools/HolocronToolset/src/toolset/gui/editors/mdl.py +++ b/Tools/HolocronToolset/src/toolset/gui/editors/mdl.py @@ -118,7 +118,7 @@ def load(self, filepath: os.PathLike | str, resref: str, restype: ResourceType, mdl_data = self._installation.resource(resref, ResourceType.MDL, [SearchLocation.CHITIN]).data if mdl_data is None or mdx_data is None: - QMessageBox(QMessageBox.Critical, f"Could not find the '{c_filepath.stem}' MDL/MDX", "").exec_() + QMessageBox(QMessageBox.Icon.Critical, f"Could not find the '{c_filepath.stem}' MDL/MDX", "").exec_() return self.ui.modelRenderer.setModel(mdl_data, mdx_data) diff --git a/Tools/HolocronToolset/src/toolset/gui/editors/nss.py b/Tools/HolocronToolset/src/toolset/gui/editors/nss.py index f071e4993..e1dffbc72 100644 --- a/Tools/HolocronToolset/src/toolset/gui/editors/nss.py +++ b/Tools/HolocronToolset/src/toolset/gui/editors/nss.py @@ -149,12 +149,12 @@ def setInstallation(self, installation: HTInstallation): for function in functions: item = QListWidgetItem(function.name) - item.setData(QtCore.Qt.UserRole, function) + item.setData(QtCore.Qt.ItemDataRole.UserRole, function) self.ui.functionList.addItem(item) for constant in constants: item = QListWidgetItem(constant.name) - item.setData(QtCore.Qt.UserRole, constant) + item.setData(QtCore.Qt.ItemDataRole.UserRole, constant) self.ui.constantList.addItem(item) class SavedContext(NamedTuple): @@ -239,10 +239,10 @@ def load( self.ui.codeEdit.setPlainText(source) self._is_decompiled = True except ValueError as e: - QMessageBox(QMessageBox.Critical, "Decompilation Failed", str(universal_simplify_exception(e))).exec_() + QMessageBox(QMessageBox.Icon.Critical, "Decompilation Failed", str(universal_simplify_exception(e))).exec_() self.new() except NoConfigurationSetError as e: - QMessageBox(QMessageBox.Critical, "Filepath is not set", str(universal_simplify_exception(e))).exec_() + QMessageBox(QMessageBox.Icon.Critical, "Filepath is not set", str(universal_simplify_exception(e))).exec_() self.new() def build(self) -> tuple[bytes | None, bytes]: @@ -299,9 +299,9 @@ def compileCurrentScript(self): # Save using the overridden filepath and resource type. self.save() except ValueError as e: - QMessageBox(QMessageBox.Critical, "Failed to compile", str(universal_simplify_exception(e))).exec_() + QMessageBox(QMessageBox.Icon.Critical, "Failed to compile", str(universal_simplify_exception(e))).exec_() except OSError as e: - QMessageBox(QMessageBox.Critical, "Failed to save file", str(universal_simplify_exception(e))).exec_() + QMessageBox(QMessageBox.Icon.Critical, "Failed to save file", str(universal_simplify_exception(e))).exec_() def _compiledResourceSaved( self, @@ -316,7 +316,7 @@ def _compiledResourceSaved( # Format as /full/path/to/file.mod/resname.ncs savePath = savePath / f"{resname}.ncs" QMessageBox( - QMessageBox.Information, + QMessageBox.Icon.Information, "Success", f"Compiled script successfully saved to:\n {savePath}.", ).exec_() @@ -342,12 +342,12 @@ def changeDescription(self): if self.ui.tabWidget.currentIndex() == 0 and self.ui.functionList.selectedItems(): # Functions tab item = self.ui.functionList.selectedItems()[0] - function = item.data(QtCore.Qt.UserRole) + function = item.data(QtCore.Qt.ItemDataRole.UserRole) text = function.description + "\n" + str(function) self.ui.descriptionEdit.setPlainText(text) elif self.ui.tabWidget.currentIndex() == 1 and self.ui.constantList.selectedItems(): # Constants tab item = self.ui.constantList.selectedItems()[0] - constant = item.data(QtCore.Qt.UserRole) + constant = item.data(QtCore.Qt.ItemDataRole.UserRole) self.ui.descriptionEdit.setPlainText(str(constant)) def insertSelectedConstant(self): @@ -355,7 +355,7 @@ def insertSelectedConstant(self): then shifted to the end of the newly inserted constant. """ # noqa: D205 if self.ui.constantList.selectedItems(): - constant = self.ui.constantList.selectedItems()[0].data(QtCore.Qt.UserRole) + constant = self.ui.constantList.selectedItems()[0].data(QtCore.Qt.ItemDataRole.UserRole) insert = constant.name self.insertTextAtCursor(insert) @@ -364,7 +364,7 @@ def insertSelectedFunction(self): then shifted to the start of the first parameter of the inserted function. """ # noqa: D205 if self.ui.functionList.selectedItems(): - function: ScriptFunction = self.ui.functionList.selectedItems()[0].data(QtCore.Qt.UserRole) + function: ScriptFunction = self.ui.functionList.selectedItems()[0].data(QtCore.Qt.ItemDataRole.UserRole) insert = f"{function.name}()" self.insertTextAtCursor(insert, insert.index("(") + 1) diff --git a/Tools/HolocronToolset/src/toolset/gui/editors/tlk.py b/Tools/HolocronToolset/src/toolset/gui/editors/tlk.py index bdb9fa691..f2ba9f7cb 100644 --- a/Tools/HolocronToolset/src/toolset/gui/editors/tlk.py +++ b/Tools/HolocronToolset/src/toolset/gui/editors/tlk.py @@ -107,7 +107,7 @@ def _setupSignals(self): self.ui.talkTable.clicked.connect(self.selectionChanged) self.ui.textEdit.textChanged.connect(self.updateEntry) self.ui.soundEdit.textChanged.connect(self.updateEntry) - self.ui.talkTable.setContextMenuPolicy(Qt.CustomContextMenu) + self.ui.talkTable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.ui.talkTable.customContextMenuRequested.connect(self.showContextMenu) self.populateLanguageMenu() @@ -257,7 +257,7 @@ def handleSearchCompleted( ): if not results_list: QMessageBox( - QMessageBox.Information, + QMessageBox.Icon.Information, "No resources found", f"There are no GFFs that reference this tlk entry (stringref {stringref})", parent=self, @@ -413,8 +413,8 @@ def __init__( self.setWindowTitle("Loading...") self.setFixedSize(200, 40) - self.setWindowFlag(QtCore.Qt.WindowCloseButtonHint, False) - self.setWindowFlag(QtCore.Qt.WindowContextHelpButtonHint, False) + self.setWindowFlag(Qt.WindowType.WindowCloseButtonHint, False) + self.setWindowFlag(Qt.WindowType.WindowContextHelpButtonHint, False) self.model = QStandardItemModel() self.model.setColumnCount(2) diff --git a/Tools/HolocronToolset/src/toolset/gui/editors/twoda.py b/Tools/HolocronToolset/src/toolset/gui/editors/twoda.py index 7d289a94c..64af6de87 100644 --- a/Tools/HolocronToolset/src/toolset/gui/editors/twoda.py +++ b/Tools/HolocronToolset/src/toolset/gui/editors/twoda.py @@ -140,7 +140,7 @@ def load( self._load_main(data) except ValueError as e: error_msg = str(universal_simplify_exception(e)).replace("\n", "
") - QMessageBox(QMessageBox.Critical, "Failed to load file.", f"Failed to open or load file data.
{error_msg}").exec_() + QMessageBox(QMessageBox.Icon.Critical, "Failed to load file.", f"Failed to open or load file data.
{error_msg}").exec_() self.proxyModel.setSourceModel(self.model) self.new() diff --git a/Tools/HolocronToolset/src/toolset/gui/editors/utc.py b/Tools/HolocronToolset/src/toolset/gui/editors/utc.py index af3571db7..a8018e8ba 100644 --- a/Tools/HolocronToolset/src/toolset/gui/editors/utc.py +++ b/Tools/HolocronToolset/src/toolset/gui/editors/utc.py @@ -199,12 +199,12 @@ def _setupInstallation(self, installation: HTInstallation): text: str = installation.talktable().string(stringref) if stringref else feat.get_string("label") text = text or f"[Unused Feat ID: {feat.label()}]" item = QListWidgetItem(text) - item.setData(QtCore.Qt.UserRole, int(feat.label())) + item.setData(QtCore.Qt.ItemDataRole.UserRole, int(feat.label())) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) item.setCheckState(QtCore.Qt.Unchecked) self.ui.featList.addItem(item) self.ui.featList.setSortingEnabled(True) - self.ui.featList.sortItems(QtCore.Qt.AscendingOrder) + self.ui.featList.sortItems(QtCore.Qt.SortOrder.AscendingOrder) self.ui.powerList.clear() for power in powers: @@ -213,12 +213,12 @@ def _setupInstallation(self, installation: HTInstallation): text = text.replace("_", " ").replace("XXX", "").replace("\n", "").title() text = text or f"[Unused Power ID: {power.label()}]" item = QListWidgetItem(text) - item.setData(QtCore.Qt.UserRole, int(power.label())) + item.setData(QtCore.Qt.ItemDataRole.UserRole, int(power.label())) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) item.setCheckState(QtCore.Qt.Unchecked) self.ui.powerList.addItem(item) self.ui.powerList.setSortingEnabled(True) - self.ui.powerList.sortItems(QtCore.Qt.AscendingOrder) + self.ui.powerList.sortItems(QtCore.Qt.SortOrder.AscendingOrder) self.ui.noBlockCheckbox.setVisible(installation.tsl) self.ui.hologramCheckbox.setVisible(installation.tsl) @@ -336,7 +336,7 @@ def _loadUTC( item = self.getFeatItem(feat) if item is None: item = QListWidgetItem(f"[Modded Feat ID: {feat}]") - item.setData(QtCore.Qt.UserRole, feat) + item.setData(QtCore.Qt.ItemDataRole.UserRole, feat) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) self.ui.featList.addItem(item) item.setCheckState(QtCore.Qt.Checked) @@ -351,7 +351,7 @@ def _loadUTC( item = self.getPowerItem(power) if item is None: item = QListWidgetItem(f"[Modded Power ID: {power}]") - item.setData(QtCore.Qt.UserRole, power) + item.setData(QtCore.Qt.ItemDataRole.UserRole, power) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) self.ui.powerList.addItem(item) item.setCheckState(QtCore.Qt.Checked) @@ -467,13 +467,13 @@ def build(self) -> tuple[bytes, bytes]: for i in range(self.ui.featList.count()): item = self.ui.featList.item(i) if item.checkState() == QtCore.Qt.Checked: - utc.feats.append(item.data(QtCore.Qt.UserRole)) + utc.feats.append(item.data(QtCore.Qt.ItemDataRole.UserRole)) powers: list[int] = utc.classes[-1].powers for i in range(self.ui.powerList.count()): item = self.ui.powerList.item(i) if item.checkState() == QtCore.Qt.Checked: - powers.append(item.data(QtCore.Qt.UserRole)) + powers.append(item.data(QtCore.Qt.ItemDataRole.UserRole)) use_tsl: Literal[Game.K2, Game.K1] = Game.K2 if self.settings.alwaysSaveK2Fields or self._installation.tsl else Game.K1 data = bytearray() @@ -585,14 +585,14 @@ def editConversation(self): data: bytes | None = None if not resname: - QMessageBox(QMessageBox.Critical, "Failed to open DLG Editor", "Conversation field cannot be blank.").exec_() + QMessageBox(QMessageBox.Icon.Critical, "Failed to open DLG Editor", "Conversation field cannot be blank.").exec_() return search: ResourceResult | None = self._installation.resource(resname, ResourceType.DLG) if search is None: if ( - QMessageBox(QMessageBox.Information, "DLG file not found", "Do you wish to create a file in the override?", QMessageBox.Yes | QMessageBox.No).exec_() + QMessageBox(QMessageBox.Icon.Information, "DLG file not found", "Do you wish to create a file in the override?", QMessageBox.Yes | QMessageBox.No).exec_() == QMessageBox.Yes ): data = bytearray() @@ -645,7 +645,7 @@ def getFeatItem(self, featId: int) -> QListWidgetItem | None: if item is None: print(f"self.ui.featList.item(i={i}) returned None. Relevance: {self!r}.getFeatItem(featId={featId!r})") continue - if item.data(QtCore.Qt.UserRole) == featId: + if item.data(QtCore.Qt.ItemDataRole.UserRole) == featId: return item return None @@ -655,7 +655,7 @@ def getPowerItem(self, powerId: int) -> QListWidgetItem | None: if item is None: print(f"self.ui.powerList.item(i={i}) returned None. Relevance: {self!r}.getPowerItem(powerId={powerId!r})") continue - if item.data(QtCore.Qt.UserRole) == powerId: + if item.data(QtCore.Qt.ItemDataRole.UserRole) == powerId: return item return None diff --git a/Tools/HolocronToolset/src/toolset/gui/editors/utd.py b/Tools/HolocronToolset/src/toolset/gui/editors/utd.py index a6d374552..13e18408c 100644 --- a/Tools/HolocronToolset/src/toolset/gui/editors/utd.py +++ b/Tools/HolocronToolset/src/toolset/gui/editors/utd.py @@ -317,13 +317,13 @@ def editConversation(self): data, filepath = None, None if not resname or not resname.strip(): - QMessageBox(QMessageBox.Critical, "Failed to open DLG Editor", "Conversation field cannot be blank.").exec_() + QMessageBox(QMessageBox.Icon.Critical, "Failed to open DLG Editor", "Conversation field cannot be blank.").exec_() return search = self._installation.resource(resname, ResourceType.DLG) if search is None: - msgbox = QMessageBox(QMessageBox.Information, "DLG file not found", "Do you wish to create a file in the override?", QMessageBox.Yes | QMessageBox.No).exec_() + msgbox = QMessageBox(QMessageBox.Icon.Information, "DLG file not found", "Do you wish to create a file in the override?", QMessageBox.Yes | QMessageBox.No).exec_() if QMessageBox.Yes == msgbox: data = bytearray() diff --git a/Tools/HolocronToolset/src/toolset/gui/editors/uti.py b/Tools/HolocronToolset/src/toolset/gui/editors/uti.py index 5eae430c9..ecfebdb8c 100644 --- a/Tools/HolocronToolset/src/toolset/gui/editors/uti.py +++ b/Tools/HolocronToolset/src/toolset/gui/editors/uti.py @@ -136,8 +136,8 @@ def _setupInstallation( subtypeResname = itemProperties.get_cell(i, "subtyperesref") if not subtypeResname: - item.setData(0, QtCore.Qt.UserRole, i) - item.setData(0, QtCore.Qt.UserRole + 1, i) + item.setData(0, QtCore.Qt.ItemDataRole.UserRole, i) + item.setData(0, QtCore.Qt.ItemDataRole.UserRole + 1, i) continue subtype = installation.htGetCache2DA(subtypeResname) @@ -147,8 +147,8 @@ def _setupInstallation( name = UTIEditor.subpropertyName(installation, i, j) #assert name is not None child = QTreeWidgetItem([name]) - child.setData(0, QtCore.Qt.UserRole, i) - child.setData(0, QtCore.Qt.UserRole + 1, j) + child.setData(0, QtCore.Qt.ItemDataRole.UserRole, i) + child.setData(0, QtCore.Qt.ItemDataRole.UserRole + 1, j) item.addChild(child) def load( @@ -197,7 +197,7 @@ def _loadUTI(self, uti: UTI): for utiProperty in uti.properties: text = self.propertySummary(utiProperty) item = QListWidgetItem(text) - item.setData(QtCore.Qt.UserRole, utiProperty) + item.setData(QtCore.Qt.ItemDataRole.UserRole, utiProperty) self.ui.assignedPropertiesList.addItem(item) # Comments @@ -240,7 +240,7 @@ def build(self) -> tuple[bytes, bytes]: uti.texture_variation = self.ui.textureVarSpin.value() uti.properties = [ - self.ui.assignedPropertiesList.item(i).data(QtCore.Qt.UserRole) + self.ui.assignedPropertiesList.item(i).data(QtCore.Qt.ItemDataRole.UserRole) for i in range(self.ui.assignedPropertiesList.count()) ] # Comments @@ -283,21 +283,21 @@ def generateResref(self): def editSelectedProperty(self): if not self.ui.assignedPropertiesList.selectedItems(): return - utiProperty: UTIProperty = self.ui.assignedPropertiesList.selectedItems()[0].data(QtCore.Qt.UserRole) + utiProperty: UTIProperty = self.ui.assignedPropertiesList.selectedItems()[0].data(QtCore.Qt.ItemDataRole.UserRole) dialog = PropertyEditor(self._installation, utiProperty) if not dialog.exec_(): return - self.ui.assignedPropertiesList.selectedItems()[0].setData(QtCore.Qt.UserRole, dialog.utiProperty()) + self.ui.assignedPropertiesList.selectedItems()[0].setData(QtCore.Qt.ItemDataRole.UserRole, dialog.utiProperty()) self.ui.assignedPropertiesList.selectedItems()[0].setText(self.propertySummary(dialog.utiProperty())) def addSelectedProperty(self): if not self.ui.availablePropertyList.selectedItems(): return item = self.ui.availablePropertyList.selectedItems()[0] - propertyId = item.data(0, QtCore.Qt.UserRole) + propertyId = item.data(0, QtCore.Qt.ItemDataRole.UserRole) if propertyId is None: return - subtypeId = item.data(0, QtCore.Qt.UserRole + 1) + subtypeId = item.data(0, QtCore.Qt.ItemDataRole.UserRole + 1) self._add_property_main(propertyId, subtypeId) def _add_property_main( @@ -332,7 +332,7 @@ def _add_property_main( text: str = self.propertySummary(utiProperty) item = QListWidgetItem(text) - item.setData(QtCore.Qt.UserRole, utiProperty) + item.setData(QtCore.Qt.ItemDataRole.UserRole, utiProperty) self.ui.assignedPropertiesList.addItem(item) def removeSelectedProperty(self): @@ -514,7 +514,7 @@ def __init__( if not costName: print(f"No cost at index {i}") item = QListWidgetItem(costName) - item.setData(QtCore.Qt.UserRole, i) + item.setData(QtCore.Qt.ItemDataRole.UserRole, i) self.ui.costList.addItem(item) if utiProperty.param1 != 0xFF: @@ -525,7 +525,7 @@ def __init__( if not paramName: print(f"No param at index {i}") item = QListWidgetItem(paramName) - item.setData(QtCore.Qt.UserRole, i) + item.setData(QtCore.Qt.ItemDataRole.UserRole, i) self.ui.parameterList.addItem(item) upgrades = installation.htGetCache2DA(HTInstallation.TwoDA_UPGRADES) @@ -556,14 +556,14 @@ def selectCost(self): if not self.ui.costList.currentItem(): return - self._utiProperty.cost_value = self.ui.costList.currentItem().data(QtCore.Qt.UserRole) + self._utiProperty.cost_value = self.ui.costList.currentItem().data(QtCore.Qt.ItemDataRole.UserRole) self.reloadTextboxes() def selectParam(self): if not self.ui.parameterList.currentItem(): return - self._utiProperty.param1_value = self.ui.parameterList.currentItem().data(QtCore.Qt.UserRole) + self._utiProperty.param1_value = self.ui.parameterList.currentItem().data(QtCore.Qt.ItemDataRole.UserRole) self.reloadTextboxes() def utiProperty(self) -> UTIProperty: diff --git a/Tools/HolocronToolset/src/toolset/gui/editors/utp.py b/Tools/HolocronToolset/src/toolset/gui/editors/utp.py index c5e6a314c..a4d65e130 100644 --- a/Tools/HolocronToolset/src/toolset/gui/editors/utp.py +++ b/Tools/HolocronToolset/src/toolset/gui/editors/utp.py @@ -340,13 +340,13 @@ def editConversation(self): data, filepath = None, None if resname == "": - QMessageBox(QMessageBox.Critical, "Failed to open DLG Editor", "Conversation field cannot be blank.").exec_() + QMessageBox(QMessageBox.Icon.Critical, "Failed to open DLG Editor", "Conversation field cannot be blank.").exec_() return search: ResourceResult | None = self._installation.resource(resname, ResourceType.DLG) if search is None: - msgbox: int = QMessageBox(QMessageBox.Information, "DLG file not found", "Do you wish to create a file in the override?", QMessageBox.Yes | QMessageBox.No).exec_() + msgbox: int = QMessageBox(QMessageBox.Icon.Information, "DLG file not found", "Do you wish to create a file in the override?", QMessageBox.Yes | QMessageBox.No).exec_() if QMessageBox.Yes == msgbox: data = bytearray() diff --git a/Tools/HolocronToolset/src/toolset/gui/editors/uts.py b/Tools/HolocronToolset/src/toolset/gui/editors/uts.py index 90270934a..a803b2736 100644 --- a/Tools/HolocronToolset/src/toolset/gui/editors/uts.py +++ b/Tools/HolocronToolset/src/toolset/gui/editors/uts.py @@ -174,7 +174,7 @@ def _loadUTS(self, uts: UTS): self.ui.soundList.clear() for sound in uts.sounds: item = QListWidgetItem(str(sound)) - item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable) + item.setFlags(item.flags() | QtCore.Qt.ItemFlag.ItemIsEditable) self.ui.soundList.addItem(item) # Positioning @@ -316,17 +316,19 @@ def playSound(self): data: bytes | None = self._installation.sound(resname) if data: + # PyQt5 and PySide2 code path + from qtpy.QtMultimedia import QMediaContent self.buffer = QBuffer(self) self.buffer.setData(data) self.buffer.open(QIODevice.ReadOnly) self.player.setMedia(QMediaContent(), self.buffer) QtCore.QTimer.singleShot(0, self.player.play) else: - QMessageBox(QMessageBox.Critical, "Could not find audio file", f"Could not find audio resource '{resname}'.") + QMessageBox(QMessageBox.Icon.Critical, "Could not find audio file", f"Could not find audio resource '{resname}'.") def addSound(self): item = QListWidgetItem("new sound") - item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable) + item.setFlags(item.flags() | QtCore.Qt.ItemFlag.ItemIsEditable) self.ui.soundList.addItem(item) def removeSound(self): @@ -343,7 +345,7 @@ def moveSoundUp(self): self.ui.soundList.insertItem(row - 1, resname) self.ui.soundList.setCurrentRow(row - 1) item: QListWidgetItem | None = self.ui.soundList.item(row - 1) - item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable) + item.setFlags(item.flags() | QtCore.Qt.ItemFlag.ItemIsEditable) def moveSoundDown(self): if self.ui.soundList.currentRow() == -1: @@ -354,7 +356,7 @@ def moveSoundDown(self): self.ui.soundList.insertItem(row + 1, resname) self.ui.soundList.setCurrentRow(row + 1) item: QListWidgetItem | None = self.ui.soundList.item(row + 1) - item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable) + item.setFlags(item.flags() | QtCore.Qt.ItemFlag.ItemIsEditable) def closeEvent(self, e: QCloseEvent): self.player.stop() diff --git a/Tools/HolocronToolset/src/toolset/gui/widgets/edit/combobox_2da.py b/Tools/HolocronToolset/src/toolset/gui/widgets/edit/combobox_2da.py index 5bd9c1cb7..75b361313 100644 --- a/Tools/HolocronToolset/src/toolset/gui/widgets/edit/combobox_2da.py +++ b/Tools/HolocronToolset/src/toolset/gui/widgets/edit/combobox_2da.py @@ -16,7 +16,7 @@ class ComboBox2DA(QComboBox): def __init__(self, parent: QWidget): super().__init__(parent) - self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.customContextMenuRequested.connect(self.onContextMenu) self._sortAlphabetically: bool = False diff --git a/Tools/HolocronToolset/src/toolset/gui/widgets/main_widgets.py b/Tools/HolocronToolset/src/toolset/gui/widgets/main_widgets.py index 810e8be5c..25e040502 100644 --- a/Tools/HolocronToolset/src/toolset/gui/widgets/main_widgets.py +++ b/Tools/HolocronToolset/src/toolset/gui/widgets/main_widgets.py @@ -74,7 +74,7 @@ def __init__(self, parent: QWidget): self.modulesModel = ResourceModel() self.modulesModel.proxyModel().setFilterCaseSensitivity(QtCore.Qt.CaseInsensitive) self.ui.resourceTree.setModel(self.modulesModel.proxyModel()) - self.ui.resourceTree.sortByColumn(0, QtCore.Qt.AscendingOrder) + self.ui.resourceTree.sortByColumn(0, QtCore.Qt.SortOrder.AscendingOrder) self.sectionModel = QStandardItemModel() self.ui.sectionCombo.setModel(self.sectionModel) @@ -197,10 +197,10 @@ def onFilterStringUpdated(self): self.modulesModel.proxyModel().setFilterFixedString(self.ui.searchEdit.text()) def onSectionChanged(self): - self.sectionChanged.emit(self.ui.sectionCombo.currentData(QtCore.Qt.UserRole)) + self.sectionChanged.emit(self.ui.sectionCombo.currentData(QtCore.Qt.ItemDataRole.UserRole)) def onReloadClicked(self): - self.requestReload.emit(self.ui.sectionCombo.currentData(QtCore.Qt.UserRole)) + self.requestReload.emit(self.ui.sectionCombo.currentData(QtCore.Qt.ItemDataRole.UserRole)) def onRefreshClicked(self): self.requestRefresh.emit() @@ -405,8 +405,8 @@ def setResources( for resource in resources: item = QStandardItem(blankIcon, resource.resname()) item.setToolTip(resource.resname()) - item.setData(False, QtCore.Qt.UserRole) - item.setData(resource, QtCore.Qt.UserRole + 1) + item.setData(False, QtCore.Qt.ItemDataRole.UserRole) + item.setData(resource, QtCore.Qt.ItemDataRole.UserRole + 1) self.texturesModel.appendRow(item) if self._installation is not None: @@ -425,7 +425,7 @@ def selectedResources(self) -> list[FileResource]: for proxyIndex in self.ui.resourceList.selectedIndexes(): sourceIndex = self.texturesProxyModel.mapToSource(proxyIndex) item = self.texturesModel.item(sourceIndex.row()) - resources.append(item.data(QtCore.Qt.UserRole + 1)) + resources.append(item.data(QtCore.Qt.ItemDataRole.UserRole + 1)) return resources def visibleItems(self) -> list[QStandardItem]: @@ -483,10 +483,10 @@ def onFilterStringUpdated(self): self.texturesProxyModel.setFilterFixedString(self.ui.searchEdit.text()) def onSectionChanged(self): - self.sectionChanged.emit(self.ui.sectionCombo.currentData(QtCore.Qt.UserRole)) + self.sectionChanged.emit(self.ui.sectionCombo.currentData(QtCore.Qt.ItemDataRole.UserRole)) def onReloadClicked(self): - self.requestReload.emit(self.ui.sectionCombo.currentData(QtCore.Qt.UserRole)) + self.requestReload.emit(self.ui.sectionCombo.currentData(QtCore.Qt.ItemDataRole.UserRole)) def onRefreshClicked(self): self.requestRefresh.emit() @@ -513,7 +513,7 @@ def onTextureListScrolled(self): task = TextureListTask(item.row(), tpc, item_text) self._taskQueue.put(task) - item.setData(True, QtCore.Qt.UserRole) + item.setData(True, QtCore.Qt.ItemDataRole.UserRole) def onIconUpdate( self, diff --git a/Tools/HolocronToolset/src/toolset/gui/windows/help.py b/Tools/HolocronToolset/src/toolset/gui/windows/help.py index 55bbe9f7d..ddd1700f4 100644 --- a/Tools/HolocronToolset/src/toolset/gui/windows/help.py +++ b/Tools/HolocronToolset/src/toolset/gui/windows/help.py @@ -107,7 +107,7 @@ def _setupContentsRecJSON(self, parent: QTreeWidgetItem | None, data: dict[str, structure = data.get("structure", {}) for title in structure: item = QTreeWidgetItem([title]) - item.setData(0, QtCore.Qt.UserRole, structure[title]["filename"]) + item.setData(0, QtCore.Qt.ItemDataRole.UserRole, structure[title]["filename"]) addItem(item) self._setupContentsRecJSON(item, structure[title]) @@ -120,7 +120,7 @@ def _setupContentsRecXML(self, parent: QTreeWidgetItem | None, element: ElemTree for child in element: item = QTreeWidgetItem([child.get("name", "")]) - item.setData(0, QtCore.Qt.UserRole, child.get("file")) + item.setData(0, QtCore.Qt.ItemDataRole.UserRole, child.get("file")) addItem(item) self._setupContentsRecXML(item, child) @@ -143,22 +143,22 @@ def checkForUpdates(self): except Exception as e: # noqa: BLE001 error_msg = str(universal_simplify_exception(e)).replace("\n", "
") errMsgBox = QMessageBox( - QMessageBox.Information, + QMessageBox.Icon.Information, "An unexpected error occurred while parsing the help booklet.", error_msg, - QMessageBox.Ok, + QMessageBox.StandardButton.Ok, parent=None, - flags=Qt.Window | Qt.Dialog | Qt.WindowStaysOnTopHint, + flags=Qt.WindowType.Window | Qt.WindowType.Dialog | Qt.WindowType.WindowStaysOnTopHint, ) errMsgBox.setWindowIcon(self.windowIcon()) errMsgBox.exec_() else: newHelpMsgBox = QMessageBox( - QMessageBox.Information, + QMessageBox.Icon.Information, title, text, parent=None, - flags=Qt.Window | Qt.Dialog | Qt.WindowStaysOnTopHint, + flags=Qt.WindowType.Window | Qt.WindowType.Dialog | Qt.WindowType.WindowStaysOnTopHint, ) newHelpMsgBox.setWindowIcon(self.windowIcon()) newHelpMsgBox.addButton(QMessageBox.Yes) @@ -195,7 +195,7 @@ def displayFile(self, filepath: os.PathLike | str): self.ui.textDisplay.setHtml(html) except OSError as e: QMessageBox( - QMessageBox.Critical, + QMessageBox.Icon.Critical, "Failed to open help file", f"Could not access '{filepath}'.\n{universal_simplify_exception(e)}", ).exec_() @@ -204,7 +204,7 @@ def onContentsClicked(self): if not self.ui.contentsTree.selectedItems(): return item: QTreeWidgetItem = self.ui.contentsTree.selectedItems()[0] - filename = item.data(0, QtCore.Qt.UserRole) + filename = item.data(0, QtCore.Qt.ItemDataRole.UserRole) if filename: help_path = Path("./help").resolve() file_path = Path(help_path, filename) diff --git a/Tools/HolocronToolset/src/toolset/gui/windows/indoor_builder.py b/Tools/HolocronToolset/src/toolset/gui/windows/indoor_builder.py index f14c6bed6..8efe2ae5c 100644 --- a/Tools/HolocronToolset/src/toolset/gui/windows/indoor_builder.py +++ b/Tools/HolocronToolset/src/toolset/gui/windows/indoor_builder.py @@ -165,7 +165,7 @@ def _setupKits(self): if len(self._kits) == 0: noKitPrompt = QMessageBox( - QMessageBox.Warning, + QMessageBox.Icon.Warning, "No Kits Available", "No kits were detected, would you like to open the Kit downloader?", ) @@ -242,7 +242,7 @@ def open(self): self._filepath = filepath self._refreshWindowTitle() except OSError as e: - QMessageBox(QMessageBox.Critical, "Failed to load file", str(universal_simplify_exception(e))).exec_() + QMessageBox(QMessageBox.Icon.Critical, "Failed to load file", str(universal_simplify_exception(e))).exec_() def openKitDownloader(self): KitDownloader(self).exec_() @@ -258,7 +258,7 @@ def task(): msg += f"Map files can be found in:\n{path}" loader = AsyncLoader(self, "Building Map...", task, "Failed to build map.") if loader.exec_(): - QMessageBox(QMessageBox.Information, "Map built", msg).exec_() + QMessageBox(QMessageBox.Icon.Information, "Map built", msg).exec_() def deleteSelected(self): for room in self.ui.mapRenderer.selectedRooms(): @@ -267,7 +267,7 @@ def deleteSelected(self): def selectedComponent(self) -> KitComponent | None: currentItem: QListWidgetItem | None = self.ui.componentList.currentItem() - return None if currentItem is None else currentItem.data(QtCore.Qt.UserRole) + return None if currentItem is None else currentItem.data(QtCore.Qt.ItemDataRole.UserRole) def setWarpPoint( self, @@ -300,13 +300,13 @@ def onKitSelected(self): self.ui.componentList.clear() for component in kit.components: item = QListWidgetItem(component.name) - item.setData(QtCore.Qt.UserRole, component) + item.setData(QtCore.Qt.ItemDataRole.UserRole, component) self.ui.componentList.addItem(item) def onComponentSelected(self, item: QListWidgetItem): if item is None: return - component: KitComponent = item.data(QtCore.Qt.UserRole) + component: KitComponent = item.data(QtCore.Qt.ItemDataRole.UserRole) self.ui.componentImage.setPixmap(QPixmap.fromImage(component.image)) self.ui.mapRenderer.setCursorComponent(component) @@ -339,13 +339,13 @@ def onMouseMoved( self._refreshStatusBar() worldDelta: Vector2 = self.ui.mapRenderer.toWorldDelta(delta.x, delta.y) - if QtCore.Qt.LeftButton in buttons and QtCore.Qt.Key_Control in keys: + if QtCore.Qt.MouseButton.LeftButton in buttons and QtCore.Qt.Key_Control in keys: # LMB + CTRL self.ui.mapRenderer.panCamera(-worldDelta.x, -worldDelta.y) elif QtCore.Qt.MiddleButton in buttons and QtCore.Qt.Key_Control in keys: # MMB + CTRL self.ui.mapRenderer.rotateCamera(delta.x / 50) - elif QtCore.Qt.LeftButton in buttons: + elif QtCore.Qt.MouseButton.LeftButton in buttons: # LMB rooms: list[IndoorMapRoom] = self.ui.mapRenderer.selectedRooms() if not rooms: @@ -389,7 +389,7 @@ def onMousePressed( - Clears selection if no room found - Toggles cursor flip if middle mouse button and no control pressed. """ - if QtCore.Qt.LeftButton in buttons and QtCore.Qt.Key_Control not in keys: + if QtCore.Qt.MouseButton.LeftButton in buttons and QtCore.Qt.Key_Control not in keys: if self.ui.mapRenderer._cursorComponent is not None: component: KitComponent | None = self.selectedComponent() if component is not None: @@ -458,7 +458,7 @@ def onMouseDoubleClicked( keys: set[int], ): room: IndoorMapRoom | None = self.ui.mapRenderer.roomUnderMouse() - if QtCore.Qt.LeftButton in buttons and room: + if QtCore.Qt.MouseButton.LeftButton in buttons and room: self.ui.mapRenderer.clearSelectedRooms() self.addConnectedToSelection(room) @@ -1096,12 +1096,12 @@ def _setupDownloads(self): except Exception as e: # noqa: BLE001 error_msg = str(universal_simplify_exception(e)).replace("\n", "
") errMsgBox = QMessageBox( - QMessageBox.Information, + QMessageBox.Icon.Information, "An unexpected error occurred while setting up the kit downloader.", error_msg, - QMessageBox.Ok, + QMessageBox.StandardButton.Ok, parent=None, - flags=Qt.Window | Qt.Dialog | Qt.WindowStaysOnTopHint, + flags=Qt.WindowType.Window | Qt.WindowType.Dialog | Qt.WindowType.WindowStaysOnTopHint, ) errMsgBox.setWindowIcon(self.windowIcon()) errMsgBox.exec_() diff --git a/Tools/HolocronToolset/src/toolset/gui/windows/main.py b/Tools/HolocronToolset/src/toolset/gui/windows/main.py index 8f440294e..47f298310 100644 --- a/Tools/HolocronToolset/src/toolset/gui/windows/main.py +++ b/Tools/HolocronToolset/src/toolset/gui/windows/main.py @@ -108,11 +108,17 @@ def __init__(self, parent: QMainWindow): self.setLayout(QHBoxLayout(self)) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().setSpacing(0) - self.setWindowFlags(Qt.Window | Qt.WindowCloseButtonHint | Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint) + self.setWindowFlags( + Qt.WindowType.Window + | Qt.WindowType.WindowCloseButtonHint + | Qt.WindowType.WindowMinimizeButtonHint + | Qt.WindowType.WindowMaximizeButtonHint + ) # Create a label for the window title - self.titleLabel = QLabel("Holocron Toolset", self) - self.titleLabel.setAlignment(Qt.AlignCenter) + title = f"Holocron Toolset ({qtpy.API_NAME})" + self.titleLabel = QLabel(title, self) + self.titleLabel.setAlignment(Qt.AlignmentFlag.AlignCenter) # Create system buttons self.minimizeButton = QPushButton("-", self) @@ -156,12 +162,12 @@ def __init__(self, parent: QMainWindow): # Overriding mouse event handlers to enable dragging of the window def mousePressEvent(self, event): - if event.button() == Qt.LeftButton: + if event.button() == Qt.MouseButton.LeftButton: self._mousePressPos = event.globalPos() # global position at mouse press self._mouseDragPos = event.globalPos() # global position for ongoing drag def mouseMoveEvent(self, event): - if event.buttons() == Qt.LeftButton: + if event.buttons() == Qt.MouseButton.LeftButton: # Calculate how much the mouse has been moved globalPos = event.globalPos() if globalPos is None or self._mouseDragPos is None: @@ -204,7 +210,7 @@ def updateStyle(self, backgroundColor): def run_progress_dialog(progress_queue: Queue, title: str = "Operation Progress") -> NoReturn: app = QApplication(sys.argv) dialog = ProgressDialog(progress_queue, title) - icon = app.style().standardIcon(QStyle.SP_MessageBoxInformation) + icon = app.style().standardIcon(QStyle.StandardPixmap.SP_MessageBoxInformation) dialog.setWindowIcon(QIcon(icon)) dialog.show() sys.exit(app.exec_()) @@ -214,26 +220,6 @@ class ToolWindow(QMainWindow): moduleFilesUpdated = QtCore.Signal(object, object) overrideFilesUpdate = QtCore.Signal(object, object) - GFF_TYPES: ClassVar[list[ResourceType]] = [ - ResourceType.GFF, - ResourceType.UTC, - ResourceType.UTP, - ResourceType.UTD, - ResourceType.UTI, - ResourceType.UTM, - ResourceType.UTE, - ResourceType.UTT, - ResourceType.UTW, - ResourceType.UTS, - ResourceType.DLG, - ResourceType.GUI, - ResourceType.ARE, - ResourceType.IFO, - ResourceType.GIT, - ResourceType.JRL, - ResourceType.ITP, - ] - def __init__(self): """Initializes the main window. @@ -270,7 +256,6 @@ def __init__(self): from toolset.uic.pyqt6.windows.main import Ui_MainWindow # noqa: PLC0415 # pylint: disable=C0415 else: raise ImportError(f"Unsupported Qt bindings: {qtpy.API_NAME}") - self.ui = Ui_MainWindow() self.ui.setupUi(self) self._setupSignals() @@ -310,19 +295,24 @@ def __init__(self): with suppress(Exception): self.settings.extractPath = str(Path(str(TemporaryDirectory().name))) + title = f"Holocron Toolset ({qtpy.API_NAME})" + self.setWindowTitle(title) + self.toggle_stylesheet(self.settings.selectedTheme) # Overriding mouse event handlers to enable dragging of the window def mousePressEvent(self, event): - if event.button() == Qt.LeftButton: + if event.button() == Qt.MouseButton.LeftButton: self._mousePressPos = event.globalPos() self._mouseMovePos = event.globalPos() def mouseMoveEvent(self, event): - if event.buttons() == Qt.LeftButton: + if event.buttons() == Qt.MouseButton.LeftButton: # Calculate how much the mouse has been moved currPos = self.mapToGlobal(self.pos()) globalPos = event.globalPos() + if self._mouseMovePos is None: + return diff = globalPos - self._mouseMovePos newPos = self.mapFromGlobal(currPos + diff) @@ -333,7 +323,7 @@ def mouseMoveEvent(self, event): self._mouseMovePos = globalPos def mouseReleaseEvent(self, event): - if event.button() == Qt.LeftButton: + if event.button() == Qt.MouseButton.LeftButton: self._mousePressPos = None self._mouseMovePos = None @@ -369,7 +359,13 @@ def _setupSignals(self): self.ui.modulesWidget.requestOpenResource.connect(self.onOpenResources) def openModuleDesigner() -> ModuleDesigner: - designerUi = ModuleDesigner(self, self.active, self.active.module_path() / self.ui.modulesWidget.currentSection()) + designerUi = ( + ModuleDesigner( + self, + self.active, + self.active.module_path() / self.ui.modulesWidget.currentSection(), + ) + ) addWindow(designerUi) return designerUi @@ -385,11 +381,16 @@ def openModuleDesigner() -> ModuleDesigner: self.ui.texturesWidget.requestOpenResource.connect(self.onOpenResources) self.ui.extractButton.clicked.connect( - lambda: self.onExtractResources(self.getActiveResourceWidget().selectedResources(), resourceWidget=self.getActiveResourceWidget()) + lambda: self.onExtractResources( + self.getActiveResourceWidget().selectedResources(), + resourceWidget=self.getActiveResourceWidget(), + ), ) self.ui.openButton.clicked.connect( lambda *args: self.onOpenResources( - self.getActiveResourceWidget().selectedResources(), self.settings.gff_specializedEditors, resourceWidget=self.getActiveResourceWidget() + self.getActiveResourceWidget().selectedResources(), + self.settings.gff_specializedEditors, + resourceWidget=self.getActiveResourceWidget(), ) ) @@ -433,7 +434,7 @@ def toggle_stylesheet(self, theme: QAction | str): if app is None or not isinstance(app, QApplication): raise RuntimeError("No Qt Application found or not a QApplication instance.") # TODO: don't use custom title bar yet, is ugly - #self.setWindowFlags(Qt.FramelessWindowHint | Qt.Window) + #self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowType.Window) #self.titleBar.show() self.titleBar.hide() @@ -441,7 +442,7 @@ def toggle_stylesheet(self, theme: QAction | str): self.settings.selectedTheme = themeName if themeName == "Breeze (Dark)": file = QFile(":/dark/stylesheet.qss") - file.open(QFile.ReadOnly | QFile.Text) + file.open(QFile.OpenModeFlag.ReadOnly | QFile.OpenModeFlag.Text) stream = QTextStream(file) app.setStyleSheet(stream.readAll()) file.close() @@ -452,31 +453,36 @@ def toggle_stylesheet(self, theme: QAction | str): app.setPalette(self.original_palette) # Reset to default palette app.setStyle(self.original_style) # Reset window flags to default, which includes the title bar - self.setWindowFlags(Qt.Window | Qt.WindowCloseButtonHint | Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint) + self.setWindowFlags( + Qt.WindowType.Window + | Qt.WindowType.WindowCloseButtonHint + | Qt.WindowType.WindowMinimizeButtonHint + | Qt.WindowType.WindowMaximizeButtonHint + ) elif themeName == "Fusion (Dark)": app.setStyleSheet("") # Reset to default style app.setStyle("Fusion") # # # Now use a palette to switch to dark colors: dark_palette = QPalette() - dark_palette.setColor(QPalette.Window, QColor(53, 53, 53)) - dark_palette.setColor(QPalette.WindowText, Qt.white) - dark_palette.setColor(QPalette.Base, QColor(35, 35, 35)) - dark_palette.setColor(QPalette.AlternateBase, QColor(53, 53, 53)) - dark_palette.setColor(QPalette.ToolTipBase, QColor(25, 25, 25)) - dark_palette.setColor(QPalette.ToolTipText, Qt.white) - dark_palette.setColor(QPalette.Text, Qt.white) - dark_palette.setColor(QPalette.Button, QColor(53, 53, 53)) - dark_palette.setColor(QPalette.ButtonText, Qt.white) - dark_palette.setColor(QPalette.BrightText, Qt.red) - dark_palette.setColor(QPalette.Link, QColor(42, 130, 218)) - dark_palette.setColor(QPalette.Highlight, QColor(42, 130, 218)) - dark_palette.setColor(QPalette.HighlightedText, QColor(35, 35, 35)) - dark_palette.setColor(QPalette.Active, QPalette.Button, QColor(53, 53, 53)) - dark_palette.setColor(QPalette.Disabled, QPalette.ButtonText, Qt.darkGray) - dark_palette.setColor(QPalette.Disabled, QPalette.WindowText, Qt.darkGray) - dark_palette.setColor(QPalette.Disabled, QPalette.Text, Qt.darkGray) - dark_palette.setColor(QPalette.Disabled, QPalette.Light, QColor(53, 53, 53)) + dark_palette.setColor(QPalette.ColorRole.Window, QColor(53, 53, 53)) + dark_palette.setColor(QPalette.ColorRole.WindowText, Qt.GlobalColor.white) + dark_palette.setColor(QPalette.ColorRole.Base, QColor(35, 35, 35)) + dark_palette.setColor(QPalette.ColorRole.AlternateBase, QColor(53, 53, 53)) + dark_palette.setColor(QPalette.ColorRole.ToolTipBase, QColor(25, 25, 25)) + dark_palette.setColor(QPalette.ColorRole.ToolTipText, Qt.GlobalColor.white) + dark_palette.setColor(QPalette.ColorRole.Text, Qt.GlobalColor.white) + dark_palette.setColor(QPalette.ColorRole.Button, QColor(53, 53, 53)) + dark_palette.setColor(QPalette.ColorRole.ButtonText, Qt.GlobalColor.white) + dark_palette.setColor(QPalette.ColorRole.BrightText, Qt.GlobalColor.red) + dark_palette.setColor(QPalette.ColorRole.Link, QColor(42, 130, 218)) + dark_palette.setColor(QPalette.ColorRole.Highlight, QColor(42, 130, 218)) + dark_palette.setColor(QPalette.ColorRole.HighlightedText, QColor(35, 35, 35)) + dark_palette.setColor(QPalette.ColorGroup.Active, QPalette.ColorRole.Button, QColor(53, 53, 53)) + dark_palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.ButtonText, Qt.GlobalColor.darkGray) + dark_palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.WindowText, Qt.GlobalColor.darkGray) + dark_palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.Text, Qt.GlobalColor.darkGray) + dark_palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.Light, QColor(53, 53, 53)) QApplication.setPalette(dark_palette) print("themeName:", themeName) self.show() # Re-apply the window with new flags @@ -588,7 +594,7 @@ def onExtractResources( loader = AsyncBatchLoader(self, "Extracting Resources", [], "Failed to Extract Resources") loader.addTask(lambda: self._extractResource(resources[0], filepath, loader)) loader.exec_() - #QMessageBox(QMessageBox.Information, "Finished extracting", f"Extracted {len(resources)} resources to '{filepath}'").exec_() + #QMessageBox(QMessageBox.Icon.Information, "Finished extracting", f"Extracted {len(resources)} resources to '{filepath}'").exec_() elif len(resources) >= 1: # Player saves resources with original name to a specific directory @@ -601,10 +607,10 @@ def onExtractResources( filename = f"{resource.resname()}.{resource.restype().extension}" filepath = str(Path(folderpath, filename)) # Use QMetaObject.invokeMethod to ensure that _extractResource is called in the main thread - QMetaObject.invokeMethod(self, "_extractResource", Qt.QueuedConnection, - Qt.Q_ARG(FileResource, resource), - Qt.Q_ARG(str, filepath), - Qt.Q_ARG(AsyncBatchLoader, loader)) + QMetaObject.invokeMethod(self, "_extractResource", Qt.ConnectionType.QueuedConnection, + QtCore.Q_ARG(FileResource, resource), + QtCore.Q_ARG(str, filepath), + QtCore.Q_ARG(AsyncBatchLoader, loader)) loader.exec_() elif isinstance(resourceWidget, ResourceList) and is_capsule_file(resourceWidget.currentSection()): @@ -641,10 +647,10 @@ def _saveCapsuleFromToolUI(self, module_name: str): if is_mod_file(r_save_filepath): if capsule_type == "mod": write_erf(read_erf(c_filepath), r_save_filepath) - QMessageBox(QMessageBox.Information, "Module Saved", f"Module saved to '{r_save_filepath}'").exec_() + QMessageBox(QMessageBox.Icon.Information, "Module Saved", f"Module saved to '{r_save_filepath}'").exec_() else: module.rim_to_mod(r_save_filepath, self.active.module_path(), module_name, self.active.game()) - QMessageBox(QMessageBox.Information, "Module Built", f"Module built from relevant RIMs/ERFs and saved to '{r_save_filepath}'").exec_() + QMessageBox(QMessageBox.Icon.Information, "Module Built", f"Module built from relevant RIMs/ERFs and saved to '{r_save_filepath}'").exec_() return erf_or_rim: ERF | RIM = read_erf(c_filepath) if is_any_erf_type_file(c_filepath) else read_rim(c_filepath) @@ -652,18 +658,18 @@ def _saveCapsuleFromToolUI(self, module_name: str): if isinstance(erf_or_rim, ERF): erf_or_rim = erf_or_rim.to_rim() write_rim(erf_or_rim, r_save_filepath) - QMessageBox(QMessageBox.Information, "RIM Saved", f"Resource Image File saved to '{r_save_filepath}'").exec_() + QMessageBox(QMessageBox.Icon.Information, "RIM Saved", f"Resource Image File saved to '{r_save_filepath}'").exec_() elif is_any_erf_type_file(r_save_filepath): if isinstance(erf_or_rim, RIM): erf_or_rim = erf_or_rim.to_erf() erf_or_rim.erf_type = ERFType.from_extension(r_save_filepath) write_erf(erf_or_rim, r_save_filepath) - QMessageBox(QMessageBox.Information, "ERF Saved", f"Encapsulated Resource File saved to '{r_save_filepath}'").exec_() + QMessageBox(QMessageBox.Icon.Information, "ERF Saved", f"Encapsulated Resource File saved to '{r_save_filepath}'").exec_() except Exception as e: # noqa: BLE001 # pylint: disable=broad-exception-caught get_root_logger().exception("Error extracting capsule %s", module_name) - QMessageBox(QMessageBox.Critical, "Error saving capsule", str(universal_simplify_exception(e))).exec_() + QMessageBox(QMessageBox.Icon.Critical, "Error saving capsule", str(universal_simplify_exception(e))).exec_() def onOpenResources( self, @@ -811,7 +817,7 @@ def updateMenus(self): def openModuleDesigner(self): if self.active is None: - QMessageBox(QMessageBox.Information, "No installation loaded.", "Load an installation before opening the Module Designer.").exec_() + QMessageBox(QMessageBox.Icon.Information, "No installation loaded.", "Load an installation before opening the Module Designer.").exec_() return designer = ModuleDesigner(None, self.active) addWindow(designer) @@ -828,7 +834,7 @@ def openActiveTalktable(self): If there is no active information, show a message box instead. """ if self.active is None: - QMessageBox(QMessageBox.Information, "No installation loaded.", "Load an installation before opening the TalkTable Editor.").exec_() + QMessageBox(QMessageBox.Icon.Information, "No installation loaded.", "Load an installation before opening the TalkTable Editor.").exec_() return filepath = self.active.path() / "dialog.tlk" data = BinaryReader.load_file(filepath) @@ -836,7 +842,7 @@ def openActiveTalktable(self): def openActiveJournal(self): if self.active is None: - QMessageBox(QMessageBox.Information, "No installation loaded.", "Load an installation before opening the Journal Editor.").exec_() + QMessageBox(QMessageBox.Icon.Information, "No installation loaded.", "Load an installation before opening the Journal Editor.").exec_() return self.active.load_override(".") res = self.active.resource( @@ -845,7 +851,7 @@ def openActiveJournal(self): [SearchLocation.OVERRIDE, SearchLocation.CHITIN], ) if res is None: - QMessageBox(QMessageBox.Critical, "global.jrl not found", "Could not open the journal editor: 'global.jrl' not found.").exec_() + QMessageBox(QMessageBox.Icon.Critical, "global.jrl not found", "Could not open the journal editor: 'global.jrl' not found.").exec_() return openResourceEditor( res.filepath, @@ -925,10 +931,10 @@ def checkForUpdates(self, *, silent: bool = False): if not silent: etype, msg = universal_simplify_exception(e) QMessageBox( - QMessageBox.Information, + QMessageBox.Icon.Information, f"Unable to fetch latest version ({etype})", f"Check if you are connected to the internet.\nError: {msg}", - QMessageBox.Ok, + QMessageBox.StandardButton.Ok, self, ).exec_() @@ -966,35 +972,35 @@ def _check_toolset_update(self, *, silent: bool): if silent: return upToDateMsgBox = QMessageBox( - QMessageBox.Information, + QMessageBox.Icon.Information, "Version is up to date", f"You are running the latest {curVersionBetaReleaseStr}version ({CURRENT_VERSION}).", - QMessageBox.Ok | QMessageBox.Close, + QMessageBox.StandardButton.Ok | QMessageBox.Close, parent=None, - flags=Qt.Window | Qt.Dialog | Qt.WindowStaysOnTopHint, + flags=Qt.WindowType.Window | Qt.WindowType.Dialog | Qt.WindowType.WindowStaysOnTopHint, ) - upToDateMsgBox.button(QMessageBox.Ok).setText("Reinstall?") + upToDateMsgBox.button(QMessageBox.StandardButton.Ok).setText("Reinstall?") upToDateMsgBox.setWindowIcon(self.windowIcon()) result = upToDateMsgBox.exec_() - if result == QMessageBox.Ok: + if result == QMessageBox.StandardButton.Ok: toolset_updater = UpdateDialog(self) toolset_updater.exec_() return betaString = "release " if releaseVersionChecked else "beta " newVersionMsgBox = QMessageBox( - QMessageBox.Information, + QMessageBox.Icon.Information, f"New toolset {betaString}version available.", f"Your toolset version ({CURRENT_VERSION}) is outdated.
A new toolset {betaString}version ({greatestAvailableVersion}) available for download.
{toolsetLatestNotes}", - QMessageBox.Ok | QMessageBox.Abort, + QMessageBox.StandardButton.Ok | QMessageBox.Abort, parent=None, - flags=Qt.Window | Qt.Dialog | Qt.WindowStaysOnTopHint, + flags=Qt.WindowType.Window | Qt.WindowType.Dialog | Qt.WindowType.WindowStaysOnTopHint, ) - newVersionMsgBox.button(QMessageBox.Ok).setText("Install Now") + newVersionMsgBox.button(QMessageBox.StandardButton.Ok).setText("Install Now") newVersionMsgBox.button(QMessageBox.Abort).setText("Ignore") newVersionMsgBox.setWindowIcon(self.windowIcon()) response = newVersionMsgBox.exec_() - if response == QMessageBox.Ok: + if response == QMessageBox.StandardButton.Ok: #self.autoupdate_toolset(greatestAvailableVersion, remoteInfo, isRelease=releaseVersionChecked) toolset_updater = UpdateDialog(self) toolset_updater.exec_() @@ -1115,7 +1121,7 @@ def sortAlgo(moduleFileName: str) -> str: continue item = QStandardItem(f"{areaNames[moduleName]} [{moduleName}]") - item.setData(moduleName, QtCore.Qt.UserRole) + item.setData(moduleName, QtCore.Qt.ItemDataRole.UserRole) # Some users may choose to have items representing RIM files to have grey text. if self.settings.greyRIMText and lower_module_name.endswith(".rim"): @@ -1152,7 +1158,7 @@ def _getOverrideList(self, *, reload=True): sections = [] for directory in self.active.override_list(): section = QStandardItem(directory if directory.strip() else "[Root]") - section.setData(directory, QtCore.Qt.UserRole) + section.setData(directory, QtCore.Qt.ItemDataRole.UserRole) sections.append(section) return sections @@ -1190,7 +1196,7 @@ def _getTexturePackList( sections = [] for texturepack in self.active.texturepacks_list(): section = QStandardItem(texturepack) - section.setData(texturepack, QtCore.Qt.UserRole) + section.setData(texturepack, QtCore.Qt.ItemDataRole.UserRole) sections.append(section) return sections @@ -1290,7 +1296,7 @@ def changeActiveInstallation(self, index: int): # If the user has not set a path for the particular game yet, ask them too. if not path or not Path(path).safe_isdir(): if path and path.strip(): - QMessageBox(QMessageBox.Warning, f"Installation '{path}' not found", "Select another path now.").exec_() + QMessageBox(QMessageBox.Icon.Warning, f"Installation '{path}' not found", "Select another path now.").exec_() path = QFileDialog.getExistingDirectory(self, f"Select the game directory for {name}") # If the user still has not set a path, then return them to the [None] option. @@ -1468,7 +1474,7 @@ def openFromFile(self): openResourceEditor(filepath, *ResourceIdentifier.from_path(r_filepath).validate(), data, self.active, self) except ValueError as e: etype, msg = universal_simplify_exception(e) - QMessageBox(QMessageBox.Critical, f"Failed to open file ({etype})", msg).exec_() + QMessageBox(QMessageBox.Icon.Critical, f"Failed to open file ({etype})", msg).exec_() # endregion diff --git a/Tools/HolocronToolset/src/toolset/gui/windows/module_designer.py b/Tools/HolocronToolset/src/toolset/gui/windows/module_designer.py index ea6dfeb1c..447657e8f 100644 --- a/Tools/HolocronToolset/src/toolset/gui/windows/module_designer.py +++ b/Tools/HolocronToolset/src/toolset/gui/windows/module_designer.py @@ -497,11 +497,11 @@ def rebuildResourceTree(self): for resource in self._module.resources.values(): item = QTreeWidgetItem([f"{resource.resname()}.{resource.restype().extension}"]) - item.setData(0, QtCore.Qt.UserRole, resource) + item.setData(0, QtCore.Qt.ItemDataRole.UserRole, resource) category = categories.get(resource.restype(), categories[ResourceType.INVALID]) category.addChild(item) - self.ui.resourceTree.sortByColumn(0, QtCore.Qt.AscendingOrder) + self.ui.resourceTree.sortByColumn(0, QtCore.Qt.SortOrder.AscendingOrder) self.ui.resourceTree.setSortingEnabled(True) def openModuleResource(self, resource: ModuleResource): @@ -509,7 +509,7 @@ def openModuleResource(self, resource: ModuleResource): if editor is None: QMessageBox( - QMessageBox.Critical, + QMessageBox.Icon.Critical, "Failed to open editor", f"Failed to open editor for file: {resource.resname()}.{resource.restype().extension}", ).exec_() @@ -555,9 +555,9 @@ def selectResourceItem(self, instance: GITInstance, *, clearExisting: bool = Tru continue for j in range(parent.childCount()): item = parent.child(j) - res: ModuleResource = item.data(0, QtCore.Qt.UserRole) + res: ModuleResource = item.data(0, QtCore.Qt.ItemDataRole.UserRole) if not isinstance(res, ModuleResource): - self.log.debug("item.data(0, QtCore.Qt.UserRole) returned non ModuleResource in ModuleDesigner.selectResourceItem(): %s", safe_repr(res)) + self.log.debug("item.data(0, QtCore.Qt.ItemDataRole.UserRole) returned non ModuleResource in ModuleDesigner.selectResourceItem(): %s", safe_repr(res)) continue if res.identifier() != instance.identifier(): continue @@ -631,7 +631,7 @@ def rebuildInstanceList(self): if isinstance(instance, GITCamera): item.setText(f"Camera #{instance.camera_id}") item.setToolTip(f"Struct Index: {struct_index}\nCamera ID: {instance.camera_id}\nFOV: {instance.fov}") - item.setData(QtCore.Qt.UserRole + 1, "cam" + str(instance.camera_id).rjust(10, "0")) + item.setData(QtCore.Qt.ItemDataRole.UserRole + 1, "cam" + str(instance.camera_id).rjust(10, "0")) else: filename: str = instance.identifier().resname name: str = filename @@ -656,13 +656,13 @@ def rebuildInstanceList(self): item.setText(name) item.setToolTip(f"Struct Index: {struct_index}\nResRef: {filename}\nName: {name}\nTag: {tag}") - item.setData(QtCore.Qt.UserRole + 1, instance.identifier().restype.extension + name) + item.setData(QtCore.Qt.ItemDataRole.UserRole + 1, instance.identifier().restype.extension + name) item.setFont(font) - item.setData(QtCore.Qt.UserRole, instance) + item.setData(QtCore.Qt.ItemDataRole.UserRole, instance) items.append(item) - for item in sorted(items, key=lambda i: i.data(QtCore.Qt.UserRole + 1)): + for item in sorted(items, key=lambda i: i.data(QtCore.Qt.ItemDataRole.UserRole + 1)): self.ui.instanceList.addItem(item) def selectInstanceItemOnList(self, instance: GITInstance): @@ -682,7 +682,7 @@ def selectInstanceItemOnList(self, instance: GITInstance): self.ui.instanceList.clearSelection() for i in range(self.ui.instanceList.count()): item: QListWidgetItem | None = self.ui.instanceList.item(i) - data: GITInstance = item.data(QtCore.Qt.UserRole) + data: GITInstance = item.data(QtCore.Qt.ItemDataRole.UserRole) if data is instance: # TODO(th3w1zard1): Don't trust data(role) lookups to match original python ids, should be checking __eq__ here. item.setSelected(True) self.ui.instanceList.scrollToItem(item) @@ -962,7 +962,7 @@ def handleUndoRedoFromLongActionFinished(self): def onInstanceListDoubleClicked(self): if self.ui.instanceList.selectedItems(): item: QListWidgetItem = self.ui.instanceList.selectedItems()[0] - instance: GITInstance = item.data(QtCore.Qt.UserRole) + instance: GITInstance = item.data(QtCore.Qt.ItemDataRole.UserRole) self.setSelection([instance]) self.ui.mainRenderer.snapCameraToPoint(instance.position) self.ui.flatRenderer.snapCameraToPoint(instance.position) @@ -998,7 +998,7 @@ def onInstanceVisibilityDoubleClick(self, checkbox: QCheckBox): def onResourceTreeContextMenu(self, point: QPoint): menu = QMenu(self) - data = self.ui.resourceTree.currentItem().data(0, QtCore.Qt.UserRole) + data = self.ui.resourceTree.currentItem().data(0, QtCore.Qt.ItemDataRole.UserRole) if isinstance(data, ModuleResource): self._build_active_override_menu(data, menu) menu.exec_(self.ui.resourceTree.mapToGlobal(point)) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyqt5/dialogs/inventory.py b/Tools/HolocronToolset/src/toolset/uic/pyqt5/dialogs/inventory.py index 073949c5a..081767d5c 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyqt5/dialogs/inventory.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyqt5/dialogs/inventory.py @@ -32,7 +32,7 @@ def setupUi(self, Dialog): self.coreTree.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.coreTree.setDragEnabled(True) self.coreTree.setDragDropMode(QtWidgets.QAbstractItemView.DragOnly) - self.coreTree.setDefaultDropAction(QtCore.Qt.CopyAction) + self.coreTree.setDefaultDropAction(QtCore.Qt.DropAction.CopyAction) self.coreTree.setAlternatingRowColors(True) self.coreTree.setObjectName("coreTree") self.coreTree.header().setVisible(False) @@ -49,7 +49,7 @@ def setupUi(self, Dialog): self.modulesTree.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.modulesTree.setDragEnabled(True) self.modulesTree.setDragDropMode(QtWidgets.QAbstractItemView.DragOnly) - self.modulesTree.setDefaultDropAction(QtCore.Qt.CopyAction) + self.modulesTree.setDefaultDropAction(QtCore.Qt.DropAction.CopyAction) self.modulesTree.setAlternatingRowColors(True) self.modulesTree.setHeaderHidden(True) self.modulesTree.setObjectName("modulesTree") @@ -66,7 +66,7 @@ def setupUi(self, Dialog): self.overrideTree.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.overrideTree.setDragEnabled(True) self.overrideTree.setDragDropMode(QtWidgets.QAbstractItemView.DragOnly) - self.overrideTree.setDefaultDropAction(QtCore.Qt.CopyAction) + self.overrideTree.setDefaultDropAction(QtCore.Qt.DropAction.CopyAction) self.overrideTree.setAlternatingRowColors(True) self.overrideTree.setHeaderHidden(True) self.overrideTree.setObjectName("overrideTree") @@ -91,7 +91,7 @@ def setupUi(self, Dialog): self.headFrame = DropFrame(self.standardEquipmentTab) self.headFrame.setMinimumSize(QtCore.QSize(64, 64)) self.headFrame.setMaximumSize(QtCore.QSize(64, 64)) - self.headFrame.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.headFrame.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.headFrame.setAcceptDrops(True) self.headFrame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.headFrame.setFrameShadow(QtWidgets.QFrame.Raised) @@ -116,7 +116,7 @@ def setupUi(self, Dialog): self.gridLayout.addWidget(self.headFrame, 0, 1, 1, 1) self.beltFrame = DropFrame(self.standardEquipmentTab) self.beltFrame.setMaximumSize(QtCore.QSize(64, 64)) - self.beltFrame.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.beltFrame.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.beltFrame.setAcceptDrops(True) self.beltFrame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.beltFrame.setFrameShadow(QtWidgets.QFrame.Raised) @@ -141,7 +141,7 @@ def setupUi(self, Dialog): self.gridLayout.addWidget(self.beltFrame, 2, 1, 1, 1) self.armrFrame = DropFrame(self.standardEquipmentTab) self.armrFrame.setMaximumSize(QtCore.QSize(64, 64)) - self.armrFrame.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.armrFrame.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.armrFrame.setAcceptDrops(True) self.armrFrame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.armrFrame.setFrameShadow(QtWidgets.QFrame.Raised) @@ -166,7 +166,7 @@ def setupUi(self, Dialog): self.gridLayout.addWidget(self.armrFrame, 1, 3, 1, 1) self.handrFrame = DropFrame(self.standardEquipmentTab) self.handrFrame.setMaximumSize(QtCore.QSize(64, 64)) - self.handrFrame.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.handrFrame.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.handrFrame.setAcceptDrops(True) self.handrFrame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.handrFrame.setFrameShadow(QtWidgets.QFrame.Raised) @@ -191,7 +191,7 @@ def setupUi(self, Dialog): self.gridLayout.addWidget(self.handrFrame, 2, 3, 1, 1) self.handlFrame = DropFrame(self.standardEquipmentTab) self.handlFrame.setMaximumSize(QtCore.QSize(64, 64)) - self.handlFrame.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.handlFrame.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.handlFrame.setAcceptDrops(True) self.handlFrame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.handlFrame.setFrameShadow(QtWidgets.QFrame.Raised) @@ -221,7 +221,7 @@ def setupUi(self, Dialog): sizePolicy.setHeightForWidth(self.implantFrame.sizePolicy().hasHeightForWidth()) self.implantFrame.setSizePolicy(sizePolicy) self.implantFrame.setMaximumSize(QtCore.QSize(64, 64)) - self.implantFrame.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.implantFrame.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.implantFrame.setAcceptDrops(True) self.implantFrame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.implantFrame.setFrameShadow(QtWidgets.QFrame.Raised) @@ -247,7 +247,7 @@ def setupUi(self, Dialog): self.gridLayout.addWidget(self.implantFrame, 0, 0, 1, 1) self.gauntletFrame = DropFrame(self.standardEquipmentTab) self.gauntletFrame.setMaximumSize(QtCore.QSize(64, 64)) - self.gauntletFrame.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.gauntletFrame.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.gauntletFrame.setAcceptDrops(True) self.gauntletFrame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.gauntletFrame.setFrameShadow(QtWidgets.QFrame.Raised) @@ -272,7 +272,7 @@ def setupUi(self, Dialog): self.gridLayout.addWidget(self.gauntletFrame, 0, 3, 1, 1) self.armorFrame = DropFrame(self.standardEquipmentTab) self.armorFrame.setMaximumSize(QtCore.QSize(64, 64)) - self.armorFrame.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.armorFrame.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.armorFrame.setAcceptDrops(True) self.armorFrame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.armorFrame.setFrameShadow(QtWidgets.QFrame.Raised) @@ -297,7 +297,7 @@ def setupUi(self, Dialog): self.gridLayout.addWidget(self.armorFrame, 1, 1, 1, 1) self.armlFrame = DropFrame(self.standardEquipmentTab) self.armlFrame.setMaximumSize(QtCore.QSize(64, 64)) - self.armlFrame.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.armlFrame.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.armlFrame.setAcceptDrops(True) self.armlFrame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.armlFrame.setFrameShadow(QtWidgets.QFrame.Raised) @@ -334,7 +334,7 @@ def setupUi(self, Dialog): sizePolicy.setHeightForWidth(self.claw1Frame.sizePolicy().hasHeightForWidth()) self.claw1Frame.setSizePolicy(sizePolicy) self.claw1Frame.setMaximumSize(QtCore.QSize(64, 64)) - self.claw1Frame.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.claw1Frame.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.claw1Frame.setAcceptDrops(True) self.claw1Frame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.claw1Frame.setFrameShadow(QtWidgets.QFrame.Raised) @@ -360,7 +360,7 @@ def setupUi(self, Dialog): self.claw2Frame = DropFrame(self.naturalEquipmentTab) self.claw2Frame.setMinimumSize(QtCore.QSize(64, 64)) self.claw2Frame.setMaximumSize(QtCore.QSize(64, 64)) - self.claw2Frame.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.claw2Frame.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.claw2Frame.setAcceptDrops(True) self.claw2Frame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.claw2Frame.setFrameShadow(QtWidgets.QFrame.Raised) @@ -385,7 +385,7 @@ def setupUi(self, Dialog): self.gridLayout_2.addWidget(self.claw2Frame, 0, 1, 1, 1) self.claw3Frame = DropFrame(self.naturalEquipmentTab) self.claw3Frame.setMaximumSize(QtCore.QSize(64, 64)) - self.claw3Frame.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.claw3Frame.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.claw3Frame.setAcceptDrops(True) self.claw3Frame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.claw3Frame.setFrameShadow(QtWidgets.QFrame.Raised) @@ -416,7 +416,7 @@ def setupUi(self, Dialog): self.gridLayout_2.addWidget(self.frame, 1, 0, 1, 1) self.hideFrame = DropFrame(self.naturalEquipmentTab) self.hideFrame.setMaximumSize(QtCore.QSize(64, 64)) - self.hideFrame.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.hideFrame.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.hideFrame.setAcceptDrops(True) self.hideFrame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.hideFrame.setFrameShadow(QtWidgets.QFrame.Raised) @@ -462,7 +462,7 @@ def setupUi(self, Dialog): self.gridLayout_3.setSpacing(0) self.gridLayout_3.setObjectName("gridLayout_3") self.contentsTable = InventoryTable(self.tab_6) - self.contentsTable.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.contentsTable.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.contentsTable.setFrameShape(QtWidgets.QFrame.NoFrame) self.contentsTable.setDragDropMode(QtWidgets.QAbstractItemView.DropOnly) self.contentsTable.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/dlg.py b/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/dlg.py index 1df43c88f..6800a38bb 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/dlg.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/dlg.py @@ -23,7 +23,7 @@ def setupUi(self, MainWindow): self.splitter.setOrientation(QtCore.Qt.Vertical) self.splitter.setObjectName("splitter") self.dialogTree = QtWidgets.QTreeView(self.splitter) - self.dialogTree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.dialogTree.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.dialogTree.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.dialogTree.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.dialogTree.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/erf.py b/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/erf.py index 2538dad68..a9bbb3ba4 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/erf.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/erf.py @@ -24,7 +24,7 @@ def setupUi(self, MainWindow): self.tableView.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.tableView.setDragEnabled(True) self.tableView.setDragDropMode(QtWidgets.QAbstractItemView.DragDrop) - self.tableView.setDefaultDropAction(QtCore.Qt.CopyAction) + self.tableView.setDefaultDropAction(QtCore.Qt.DropAction.CopyAction) self.tableView.setAlternatingRowColors(True) self.tableView.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) self.tableView.setGridStyle(QtCore.Qt.NoPen) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/git.py b/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/git.py index bdab5fe88..b6e77c10b 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/git.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/git.py @@ -34,7 +34,7 @@ def setupUi(self, MainWindow): self.verticalLayout.addWidget(self.filterEdit) self.listWidget = QtWidgets.QListWidget(self.layoutWidget) self.listWidget.setMaximumSize(QtCore.QSize(16777215, 16777215)) - self.listWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.listWidget.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.listWidget.setObjectName("listWidget") self.verticalLayout.addWidget(self.listWidget) self.layoutWidget1 = QtWidgets.QWidget(self.splitter) @@ -361,7 +361,7 @@ def setupUi(self, MainWindow): self.renderArea.setSizePolicy(sizePolicy) self.renderArea.setMouseTracking(True) self.renderArea.setFocusPolicy(QtCore.Qt.StrongFocus) - self.renderArea.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.renderArea.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.renderArea.setStyleSheet("background: black;") self.renderArea.setObjectName("renderArea") self.verticalLayout_2.addWidget(self.renderArea) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/jrl.py b/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/jrl.py index f5d4d6ee6..c2f4dc76d 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/jrl.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/jrl.py @@ -23,7 +23,7 @@ def setupUi(self, MainWindow): self.splitter.setOrientation(QtCore.Qt.Vertical) self.splitter.setObjectName("splitter") self.journalTree = QtWidgets.QTreeView(self.splitter) - self.journalTree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.journalTree.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.journalTree.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.journalTree.setHeaderHidden(True) self.journalTree.setObjectName("journalTree") diff --git a/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/pth.py b/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/pth.py index 1eeeb5282..d3e0f1edc 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/pth.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/pth.py @@ -27,7 +27,7 @@ def setupUi(self, MainWindow): self.renderArea.setSizePolicy(sizePolicy) self.renderArea.setMouseTracking(True) self.renderArea.setFocusPolicy(QtCore.Qt.StrongFocus) - self.renderArea.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.renderArea.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.renderArea.setStyleSheet("background: black;") self.renderArea.setObjectName("renderArea") self.gridLayout.addWidget(self.renderArea, 0, 0, 1, 1) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/tpc.py b/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/tpc.py index b74f8ef20..8ef3eb30a 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/tpc.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/tpc.py @@ -20,7 +20,7 @@ def setupUi(self, MainWindow): self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName("verticalLayout") self.textureImage = QtWidgets.QLabel(self.centralwidget) - self.textureImage.setFrameShape(QtWidgets.QFrame.Box) + self.textureImage.setFrameShape(QtWidgets.QFrame.Shape.Box) self.textureImage.setFrameShadow(QtWidgets.QFrame.Sunken) self.textureImage.setText("") self.textureImage.setAlignment(QtCore.Qt.AlignCenter) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/utc.py b/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/utc.py index 3bcbe6542..c17b7c51f 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/utc.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyqt5/editors/utc.py @@ -162,7 +162,7 @@ def setupUi(self, MainWindow): self.portraitPicture.setMinimumSize(QtCore.QSize(64, 64)) self.portraitPicture.setMaximumSize(QtCore.QSize(64, 64)) self.portraitPicture.setStyleSheet("background-color: black;") - self.portraitPicture.setFrameShape(QtWidgets.QFrame.Box) + self.portraitPicture.setFrameShape(QtWidgets.QFrame.Shape.Box) self.portraitPicture.setText("") self.portraitPicture.setScaledContents(True) self.portraitPicture.setObjectName("portraitPicture") diff --git a/Tools/HolocronToolset/src/toolset/uic/pyqt5/widgets/resource_list.py b/Tools/HolocronToolset/src/toolset/uic/pyqt5/widgets/resource_list.py index cfea208b9..1d306248b 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyqt5/widgets/resource_list.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyqt5/widgets/resource_list.py @@ -49,7 +49,7 @@ def setupUi(self, Form): self.horizontalLayout_4.addWidget(self.reloadButton) self.verticalLayout.addLayout(self.horizontalLayout_4) self.resourceTree = QtWidgets.QTreeView(Form) - self.resourceTree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.resourceTree.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.resourceTree.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.resourceTree.setAlternatingRowColors(True) self.resourceTree.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyqt5/windows/indoor_builder.py b/Tools/HolocronToolset/src/toolset/uic/pyqt5/windows/indoor_builder.py index cd75bb7b4..3826f96a7 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyqt5/windows/indoor_builder.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyqt5/windows/indoor_builder.py @@ -44,7 +44,7 @@ def setupUi(self, MainWindow): self.mapRenderer = IndoorMapRenderer(self.centralwidget) self.mapRenderer.setMouseTracking(True) self.mapRenderer.setFocusPolicy(QtCore.Qt.StrongFocus) - self.mapRenderer.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.mapRenderer.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.mapRenderer.setObjectName("mapRenderer") self.horizontalLayout.addWidget(self.mapRenderer) self.horizontalLayout.setStretch(0, 1) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyqt5/windows/module_designer.py b/Tools/HolocronToolset/src/toolset/uic/pyqt5/windows/module_designer.py index 266d77ceb..57f8a26c9 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyqt5/windows/module_designer.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyqt5/windows/module_designer.py @@ -441,7 +441,7 @@ def setupUi(self, MainWindow): self.horizontalLayout.setObjectName("horizontalLayout") self.resourceTree = QtWidgets.QTreeWidget(self.centralwidget) self.resourceTree.setMaximumSize(QtCore.QSize(200, 16777215)) - self.resourceTree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.resourceTree.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.resourceTree.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.resourceTree.setHeaderHidden(True) self.resourceTree.setObjectName("resourceTree") @@ -462,7 +462,7 @@ def setupUi(self, MainWindow): self.horizontalLayout.addLayout(self.verticalLayout_2) self.instanceList = QtWidgets.QListWidget(self.centralwidget) self.instanceList.setMaximumSize(QtCore.QSize(200, 16777215)) - self.instanceList.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.instanceList.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.instanceList.setObjectName("instanceList") self.horizontalLayout.addWidget(self.instanceList) self.verticalLayout.addLayout(self.horizontalLayout) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside2/dialogs/inventory.py b/Tools/HolocronToolset/src/toolset/uic/pyside2/dialogs/inventory.py index 51685611c..f71963562 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside2/dialogs/inventory.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside2/dialogs/inventory.py @@ -41,7 +41,7 @@ def setupUi(self, Dialog): self.coreTree.setEditTriggers(QAbstractItemView.NoEditTriggers) self.coreTree.setDragEnabled(True) self.coreTree.setDragDropMode(QAbstractItemView.DragOnly) - self.coreTree.setDefaultDropAction(Qt.CopyAction) + self.coreTree.setDefaultDropAction(Qt.DropAction.CopyAction) self.coreTree.setAlternatingRowColors(True) self.coreTree.header().setVisible(False) @@ -62,7 +62,7 @@ def setupUi(self, Dialog): self.modulesTree.setEditTriggers(QAbstractItemView.NoEditTriggers) self.modulesTree.setDragEnabled(True) self.modulesTree.setDragDropMode(QAbstractItemView.DragOnly) - self.modulesTree.setDefaultDropAction(Qt.CopyAction) + self.modulesTree.setDefaultDropAction(Qt.DropAction.CopyAction) self.modulesTree.setAlternatingRowColors(True) self.modulesTree.setHeaderHidden(True) @@ -83,7 +83,7 @@ def setupUi(self, Dialog): self.overrideTree.setEditTriggers(QAbstractItemView.NoEditTriggers) self.overrideTree.setDragEnabled(True) self.overrideTree.setDragDropMode(QAbstractItemView.DragOnly) - self.overrideTree.setDefaultDropAction(Qt.CopyAction) + self.overrideTree.setDefaultDropAction(Qt.DropAction.CopyAction) self.overrideTree.setAlternatingRowColors(True) self.overrideTree.setHeaderHidden(True) @@ -112,7 +112,7 @@ def setupUi(self, Dialog): self.headFrame.setObjectName(u"headFrame") self.headFrame.setMinimumSize(QSize(64, 64)) self.headFrame.setMaximumSize(QSize(64, 64)) - self.headFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.headFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.headFrame.setAcceptDrops(True) self.headFrame.setFrameShape(QFrame.StyledPanel) self.headFrame.setFrameShadow(QFrame.Raised) @@ -137,7 +137,7 @@ def setupUi(self, Dialog): self.beltFrame = DropFrame(self.standardEquipmentTab) self.beltFrame.setObjectName(u"beltFrame") self.beltFrame.setMaximumSize(QSize(64, 64)) - self.beltFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.beltFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.beltFrame.setAcceptDrops(True) self.beltFrame.setFrameShape(QFrame.StyledPanel) self.beltFrame.setFrameShadow(QFrame.Raised) @@ -162,7 +162,7 @@ def setupUi(self, Dialog): self.armrFrame = DropFrame(self.standardEquipmentTab) self.armrFrame.setObjectName(u"armrFrame") self.armrFrame.setMaximumSize(QSize(64, 64)) - self.armrFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.armrFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.armrFrame.setAcceptDrops(True) self.armrFrame.setFrameShape(QFrame.StyledPanel) self.armrFrame.setFrameShadow(QFrame.Raised) @@ -187,7 +187,7 @@ def setupUi(self, Dialog): self.handrFrame = DropFrame(self.standardEquipmentTab) self.handrFrame.setObjectName(u"handrFrame") self.handrFrame.setMaximumSize(QSize(64, 64)) - self.handrFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.handrFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.handrFrame.setAcceptDrops(True) self.handrFrame.setFrameShape(QFrame.StyledPanel) self.handrFrame.setFrameShadow(QFrame.Raised) @@ -212,7 +212,7 @@ def setupUi(self, Dialog): self.handlFrame = DropFrame(self.standardEquipmentTab) self.handlFrame.setObjectName(u"handlFrame") self.handlFrame.setMaximumSize(QSize(64, 64)) - self.handlFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.handlFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.handlFrame.setAcceptDrops(True) self.handlFrame.setFrameShape(QFrame.StyledPanel) self.handlFrame.setFrameShadow(QFrame.Raised) @@ -242,7 +242,7 @@ def setupUi(self, Dialog): sizePolicy.setHeightForWidth(self.implantFrame.sizePolicy().hasHeightForWidth()) self.implantFrame.setSizePolicy(sizePolicy) self.implantFrame.setMaximumSize(QSize(64, 64)) - self.implantFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.implantFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.implantFrame.setAcceptDrops(True) self.implantFrame.setFrameShape(QFrame.StyledPanel) self.implantFrame.setFrameShadow(QFrame.Raised) @@ -269,7 +269,7 @@ def setupUi(self, Dialog): self.gauntletFrame = DropFrame(self.standardEquipmentTab) self.gauntletFrame.setObjectName(u"gauntletFrame") self.gauntletFrame.setMaximumSize(QSize(64, 64)) - self.gauntletFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.gauntletFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.gauntletFrame.setAcceptDrops(True) self.gauntletFrame.setFrameShape(QFrame.StyledPanel) self.gauntletFrame.setFrameShadow(QFrame.Raised) @@ -294,7 +294,7 @@ def setupUi(self, Dialog): self.armorFrame = DropFrame(self.standardEquipmentTab) self.armorFrame.setObjectName(u"armorFrame") self.armorFrame.setMaximumSize(QSize(64, 64)) - self.armorFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.armorFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.armorFrame.setAcceptDrops(True) self.armorFrame.setFrameShape(QFrame.StyledPanel) self.armorFrame.setFrameShadow(QFrame.Raised) @@ -319,7 +319,7 @@ def setupUi(self, Dialog): self.armlFrame = DropFrame(self.standardEquipmentTab) self.armlFrame.setObjectName(u"armlFrame") self.armlFrame.setMaximumSize(QSize(64, 64)) - self.armlFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.armlFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.armlFrame.setAcceptDrops(True) self.armlFrame.setFrameShape(QFrame.StyledPanel) self.armlFrame.setFrameShadow(QFrame.Raised) @@ -355,7 +355,7 @@ def setupUi(self, Dialog): sizePolicy.setHeightForWidth(self.claw1Frame.sizePolicy().hasHeightForWidth()) self.claw1Frame.setSizePolicy(sizePolicy) self.claw1Frame.setMaximumSize(QSize(64, 64)) - self.claw1Frame.setContextMenuPolicy(Qt.CustomContextMenu) + self.claw1Frame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.claw1Frame.setAcceptDrops(True) self.claw1Frame.setFrameShape(QFrame.StyledPanel) self.claw1Frame.setFrameShadow(QFrame.Raised) @@ -381,7 +381,7 @@ def setupUi(self, Dialog): self.claw2Frame.setObjectName(u"claw2Frame") self.claw2Frame.setMinimumSize(QSize(64, 64)) self.claw2Frame.setMaximumSize(QSize(64, 64)) - self.claw2Frame.setContextMenuPolicy(Qt.CustomContextMenu) + self.claw2Frame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.claw2Frame.setAcceptDrops(True) self.claw2Frame.setFrameShape(QFrame.StyledPanel) self.claw2Frame.setFrameShadow(QFrame.Raised) @@ -406,7 +406,7 @@ def setupUi(self, Dialog): self.claw3Frame = DropFrame(self.naturalEquipmentTab) self.claw3Frame.setObjectName(u"claw3Frame") self.claw3Frame.setMaximumSize(QSize(64, 64)) - self.claw3Frame.setContextMenuPolicy(Qt.CustomContextMenu) + self.claw3Frame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.claw3Frame.setAcceptDrops(True) self.claw3Frame.setFrameShape(QFrame.StyledPanel) self.claw3Frame.setFrameShadow(QFrame.Raised) @@ -439,7 +439,7 @@ def setupUi(self, Dialog): self.hideFrame = DropFrame(self.naturalEquipmentTab) self.hideFrame.setObjectName(u"hideFrame") self.hideFrame.setMaximumSize(QSize(64, 64)) - self.hideFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.hideFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.hideFrame.setAcceptDrops(True) self.hideFrame.setFrameShape(QFrame.StyledPanel) self.hideFrame.setFrameShadow(QFrame.Raised) @@ -497,7 +497,7 @@ def setupUi(self, Dialog): __qtablewidgetitem2 = QTableWidgetItem() self.contentsTable.setHorizontalHeaderItem(2, __qtablewidgetitem2) self.contentsTable.setObjectName(u"contentsTable") - self.contentsTable.setContextMenuPolicy(Qt.CustomContextMenu) + self.contentsTable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.contentsTable.setFrameShape(QFrame.NoFrame) self.contentsTable.setDragDropMode(QAbstractItemView.DropOnly) self.contentsTable.setSelectionMode(QAbstractItemView.SingleSelection) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/dlg.py b/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/dlg.py index ebb2da682..394eedcde 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/dlg.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/dlg.py @@ -44,7 +44,7 @@ def setupUi(self, MainWindow): self.splitter.setOrientation(Qt.Vertical) self.dialogTree = QTreeView(self.splitter) self.dialogTree.setObjectName(u"dialogTree") - self.dialogTree.setContextMenuPolicy(Qt.CustomContextMenu) + self.dialogTree.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.dialogTree.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.dialogTree.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.dialogTree.setEditTriggers(QAbstractItemView.NoEditTriggers) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/erf.py b/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/erf.py index cefbc20d4..69655a6cf 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/erf.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/erf.py @@ -42,7 +42,7 @@ def setupUi(self, MainWindow): self.tableView.setEditTriggers(QAbstractItemView.NoEditTriggers) self.tableView.setDragEnabled(True) self.tableView.setDragDropMode(QAbstractItemView.DragDrop) - self.tableView.setDefaultDropAction(Qt.CopyAction) + self.tableView.setDefaultDropAction(Qt.DropAction.CopyAction) self.tableView.setAlternatingRowColors(True) self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows) self.tableView.setGridStyle(Qt.NoPen) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/git.py b/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/git.py index 38e401df2..d8666b820 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/git.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/git.py @@ -117,7 +117,7 @@ def setupUi(self, MainWindow): self.listWidget = QListWidget(self.layoutWidget) self.listWidget.setObjectName(u"listWidget") self.listWidget.setMaximumSize(QSize(16777215, 16777215)) - self.listWidget.setContextMenuPolicy(Qt.CustomContextMenu) + self.listWidget.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.verticalLayout.addWidget(self.listWidget) @@ -463,7 +463,7 @@ def setupUi(self, MainWindow): self.renderArea.setSizePolicy(sizePolicy) self.renderArea.setMouseTracking(True) self.renderArea.setFocusPolicy(Qt.StrongFocus) - self.renderArea.setContextMenuPolicy(Qt.CustomContextMenu) + self.renderArea.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.renderArea.setStyleSheet(u"background: black;") self.verticalLayout_2.addWidget(self.renderArea) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/jrl.py b/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/jrl.py index 6347cd559..5d3b3baa2 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/jrl.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/jrl.py @@ -43,7 +43,7 @@ def setupUi(self, MainWindow): self.splitter.setOrientation(Qt.Vertical) self.journalTree = QTreeView(self.splitter) self.journalTree.setObjectName(u"journalTree") - self.journalTree.setContextMenuPolicy(Qt.CustomContextMenu) + self.journalTree.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.journalTree.setEditTriggers(QAbstractItemView.NoEditTriggers) self.journalTree.setHeaderHidden(True) self.splitter.addWidget(self.journalTree) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/pth.py b/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/pth.py index 94695b63c..5f28e033a 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/pth.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/pth.py @@ -45,7 +45,7 @@ def setupUi(self, MainWindow): self.renderArea.setSizePolicy(sizePolicy) self.renderArea.setMouseTracking(True) self.renderArea.setFocusPolicy(Qt.StrongFocus) - self.renderArea.setContextMenuPolicy(Qt.CustomContextMenu) + self.renderArea.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.renderArea.setStyleSheet(u"background: black;") self.gridLayout.addWidget(self.renderArea, 0, 0, 1, 1) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/tpc.py b/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/tpc.py index b2aee14ae..08d3c400e 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/tpc.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/tpc.py @@ -36,7 +36,7 @@ def setupUi(self, MainWindow): self.verticalLayout.setObjectName(u"verticalLayout") self.textureImage = QLabel(self.centralwidget) self.textureImage.setObjectName(u"textureImage") - self.textureImage.setFrameShape(QFrame.Box) + self.textureImage.setFrameShape(QFrame.Shape.Box) self.textureImage.setFrameShadow(QFrame.Sunken) self.textureImage.setAlignment(Qt.AlignCenter) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/utc.py b/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/utc.py index 4f5dc889b..35d80b5e7 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/utc.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside2/editors/utc.py @@ -269,7 +269,7 @@ def setupUi(self, MainWindow): self.portraitPicture.setMinimumSize(QSize(64, 64)) self.portraitPicture.setMaximumSize(QSize(64, 64)) self.portraitPicture.setStyleSheet(u"background-color: black;") - self.portraitPicture.setFrameShape(QFrame.Box) + self.portraitPicture.setFrameShape(QFrame.Shape.Box) self.portraitPicture.setScaledContents(True) self.horizontalLayout_7.addWidget(self.portraitPicture) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside2/widgets/resource_list.py b/Tools/HolocronToolset/src/toolset/uic/pyside2/widgets/resource_list.py index 607f556b5..0dbddc77a 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside2/widgets/resource_list.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside2/widgets/resource_list.py @@ -67,7 +67,7 @@ def setupUi(self, Form): self.resourceTree = QTreeView(Form) self.resourceTree.setObjectName(u"resourceTree") - self.resourceTree.setContextMenuPolicy(Qt.CustomContextMenu) + self.resourceTree.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.resourceTree.setEditTriggers(QAbstractItemView.NoEditTriggers) self.resourceTree.setAlternatingRowColors(True) self.resourceTree.setSelectionMode(QAbstractItemView.ExtendedSelection) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside2/windows/indoor_builder.py b/Tools/HolocronToolset/src/toolset/uic/pyside2/windows/indoor_builder.py index 414dc99e1..7e0b94c44 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside2/windows/indoor_builder.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside2/windows/indoor_builder.py @@ -78,7 +78,7 @@ def setupUi(self, MainWindow): self.mapRenderer.setObjectName(u"mapRenderer") self.mapRenderer.setMouseTracking(True) self.mapRenderer.setFocusPolicy(Qt.StrongFocus) - self.mapRenderer.setContextMenuPolicy(Qt.CustomContextMenu) + self.mapRenderer.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.horizontalLayout.addWidget(self.mapRenderer) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside2/windows/module_designer.py b/Tools/HolocronToolset/src/toolset/uic/pyside2/windows/module_designer.py index a558b2f90..036eb1c53 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside2/windows/module_designer.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside2/windows/module_designer.py @@ -484,7 +484,7 @@ def setupUi(self, MainWindow): self.resourceTree.setHeaderItem(__qtreewidgetitem) self.resourceTree.setObjectName(u"resourceTree") self.resourceTree.setMaximumSize(QSize(200, 16777215)) - self.resourceTree.setContextMenuPolicy(Qt.CustomContextMenu) + self.resourceTree.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.resourceTree.setEditTriggers(QAbstractItemView.NoEditTriggers) self.resourceTree.setHeaderHidden(True) @@ -512,7 +512,7 @@ def setupUi(self, MainWindow): self.instanceList = QListWidget(self.centralwidget) self.instanceList.setObjectName(u"instanceList") self.instanceList.setMaximumSize(QSize(200, 16777215)) - self.instanceList.setContextMenuPolicy(Qt.CustomContextMenu) + self.instanceList.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.horizontalLayout.addWidget(self.instanceList) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside6/dialogs/inventory.py b/Tools/HolocronToolset/src/toolset/uic/pyside6/dialogs/inventory.py index 0012175b4..4de003720 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside6/dialogs/inventory.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside6/dialogs/inventory.py @@ -48,7 +48,7 @@ def setupUi(self, Dialog): self.coreTree.setEditTriggers(QAbstractItemView.NoEditTriggers) self.coreTree.setDragEnabled(True) self.coreTree.setDragDropMode(QAbstractItemView.DragOnly) - self.coreTree.setDefaultDropAction(Qt.CopyAction) + self.coreTree.setDefaultDropAction(Qt.DropAction.CopyAction) self.coreTree.setAlternatingRowColors(True) self.coreTree.header().setVisible(False) @@ -69,7 +69,7 @@ def setupUi(self, Dialog): self.modulesTree.setEditTriggers(QAbstractItemView.NoEditTriggers) self.modulesTree.setDragEnabled(True) self.modulesTree.setDragDropMode(QAbstractItemView.DragOnly) - self.modulesTree.setDefaultDropAction(Qt.CopyAction) + self.modulesTree.setDefaultDropAction(Qt.DropAction.CopyAction) self.modulesTree.setAlternatingRowColors(True) self.modulesTree.setHeaderHidden(True) @@ -90,7 +90,7 @@ def setupUi(self, Dialog): self.overrideTree.setEditTriggers(QAbstractItemView.NoEditTriggers) self.overrideTree.setDragEnabled(True) self.overrideTree.setDragDropMode(QAbstractItemView.DragOnly) - self.overrideTree.setDefaultDropAction(Qt.CopyAction) + self.overrideTree.setDefaultDropAction(Qt.DropAction.CopyAction) self.overrideTree.setAlternatingRowColors(True) self.overrideTree.setHeaderHidden(True) @@ -119,7 +119,7 @@ def setupUi(self, Dialog): self.headFrame.setObjectName(u"headFrame") self.headFrame.setMinimumSize(QSize(64, 64)) self.headFrame.setMaximumSize(QSize(64, 64)) - self.headFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.headFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.headFrame.setAcceptDrops(True) self.headFrame.setFrameShape(QFrame.StyledPanel) self.headFrame.setFrameShadow(QFrame.Raised) @@ -144,7 +144,7 @@ def setupUi(self, Dialog): self.beltFrame = DropFrame(self.standardEquipmentTab) self.beltFrame.setObjectName(u"beltFrame") self.beltFrame.setMaximumSize(QSize(64, 64)) - self.beltFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.beltFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.beltFrame.setAcceptDrops(True) self.beltFrame.setFrameShape(QFrame.StyledPanel) self.beltFrame.setFrameShadow(QFrame.Raised) @@ -169,7 +169,7 @@ def setupUi(self, Dialog): self.armrFrame = DropFrame(self.standardEquipmentTab) self.armrFrame.setObjectName(u"armrFrame") self.armrFrame.setMaximumSize(QSize(64, 64)) - self.armrFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.armrFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.armrFrame.setAcceptDrops(True) self.armrFrame.setFrameShape(QFrame.StyledPanel) self.armrFrame.setFrameShadow(QFrame.Raised) @@ -194,7 +194,7 @@ def setupUi(self, Dialog): self.handrFrame = DropFrame(self.standardEquipmentTab) self.handrFrame.setObjectName(u"handrFrame") self.handrFrame.setMaximumSize(QSize(64, 64)) - self.handrFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.handrFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.handrFrame.setAcceptDrops(True) self.handrFrame.setFrameShape(QFrame.StyledPanel) self.handrFrame.setFrameShadow(QFrame.Raised) @@ -219,7 +219,7 @@ def setupUi(self, Dialog): self.handlFrame = DropFrame(self.standardEquipmentTab) self.handlFrame.setObjectName(u"handlFrame") self.handlFrame.setMaximumSize(QSize(64, 64)) - self.handlFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.handlFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.handlFrame.setAcceptDrops(True) self.handlFrame.setFrameShape(QFrame.StyledPanel) self.handlFrame.setFrameShadow(QFrame.Raised) @@ -249,7 +249,7 @@ def setupUi(self, Dialog): sizePolicy.setHeightForWidth(self.implantFrame.sizePolicy().hasHeightForWidth()) self.implantFrame.setSizePolicy(sizePolicy) self.implantFrame.setMaximumSize(QSize(64, 64)) - self.implantFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.implantFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.implantFrame.setAcceptDrops(True) self.implantFrame.setFrameShape(QFrame.StyledPanel) self.implantFrame.setFrameShadow(QFrame.Raised) @@ -276,7 +276,7 @@ def setupUi(self, Dialog): self.gauntletFrame = DropFrame(self.standardEquipmentTab) self.gauntletFrame.setObjectName(u"gauntletFrame") self.gauntletFrame.setMaximumSize(QSize(64, 64)) - self.gauntletFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.gauntletFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.gauntletFrame.setAcceptDrops(True) self.gauntletFrame.setFrameShape(QFrame.StyledPanel) self.gauntletFrame.setFrameShadow(QFrame.Raised) @@ -301,7 +301,7 @@ def setupUi(self, Dialog): self.armorFrame = DropFrame(self.standardEquipmentTab) self.armorFrame.setObjectName(u"armorFrame") self.armorFrame.setMaximumSize(QSize(64, 64)) - self.armorFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.armorFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.armorFrame.setAcceptDrops(True) self.armorFrame.setFrameShape(QFrame.StyledPanel) self.armorFrame.setFrameShadow(QFrame.Raised) @@ -326,7 +326,7 @@ def setupUi(self, Dialog): self.armlFrame = DropFrame(self.standardEquipmentTab) self.armlFrame.setObjectName(u"armlFrame") self.armlFrame.setMaximumSize(QSize(64, 64)) - self.armlFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.armlFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.armlFrame.setAcceptDrops(True) self.armlFrame.setFrameShape(QFrame.StyledPanel) self.armlFrame.setFrameShadow(QFrame.Raised) @@ -362,7 +362,7 @@ def setupUi(self, Dialog): sizePolicy.setHeightForWidth(self.claw1Frame.sizePolicy().hasHeightForWidth()) self.claw1Frame.setSizePolicy(sizePolicy) self.claw1Frame.setMaximumSize(QSize(64, 64)) - self.claw1Frame.setContextMenuPolicy(Qt.CustomContextMenu) + self.claw1Frame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.claw1Frame.setAcceptDrops(True) self.claw1Frame.setFrameShape(QFrame.StyledPanel) self.claw1Frame.setFrameShadow(QFrame.Raised) @@ -388,7 +388,7 @@ def setupUi(self, Dialog): self.claw2Frame.setObjectName(u"claw2Frame") self.claw2Frame.setMinimumSize(QSize(64, 64)) self.claw2Frame.setMaximumSize(QSize(64, 64)) - self.claw2Frame.setContextMenuPolicy(Qt.CustomContextMenu) + self.claw2Frame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.claw2Frame.setAcceptDrops(True) self.claw2Frame.setFrameShape(QFrame.StyledPanel) self.claw2Frame.setFrameShadow(QFrame.Raised) @@ -413,7 +413,7 @@ def setupUi(self, Dialog): self.claw3Frame = DropFrame(self.naturalEquipmentTab) self.claw3Frame.setObjectName(u"claw3Frame") self.claw3Frame.setMaximumSize(QSize(64, 64)) - self.claw3Frame.setContextMenuPolicy(Qt.CustomContextMenu) + self.claw3Frame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.claw3Frame.setAcceptDrops(True) self.claw3Frame.setFrameShape(QFrame.StyledPanel) self.claw3Frame.setFrameShadow(QFrame.Raised) @@ -446,7 +446,7 @@ def setupUi(self, Dialog): self.hideFrame = DropFrame(self.naturalEquipmentTab) self.hideFrame.setObjectName(u"hideFrame") self.hideFrame.setMaximumSize(QSize(64, 64)) - self.hideFrame.setContextMenuPolicy(Qt.CustomContextMenu) + self.hideFrame.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.hideFrame.setAcceptDrops(True) self.hideFrame.setFrameShape(QFrame.StyledPanel) self.hideFrame.setFrameShadow(QFrame.Raised) @@ -504,7 +504,7 @@ def setupUi(self, Dialog): __qtablewidgetitem2 = QTableWidgetItem() self.contentsTable.setHorizontalHeaderItem(2, __qtablewidgetitem2) self.contentsTable.setObjectName(u"contentsTable") - self.contentsTable.setContextMenuPolicy(Qt.CustomContextMenu) + self.contentsTable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.contentsTable.setFrameShape(QFrame.NoFrame) self.contentsTable.setDragDropMode(QAbstractItemView.DropOnly) self.contentsTable.setSelectionMode(QAbstractItemView.SingleSelection) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/dlg.py b/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/dlg.py index af2460ff5..ef5ca5ac9 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/dlg.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/dlg.py @@ -55,7 +55,7 @@ def setupUi(self, MainWindow): self.splitter.setOrientation(Qt.Vertical) self.dialogTree = QTreeView(self.splitter) self.dialogTree.setObjectName(u"dialogTree") - self.dialogTree.setContextMenuPolicy(Qt.CustomContextMenu) + self.dialogTree.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.dialogTree.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.dialogTree.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.dialogTree.setEditTriggers(QAbstractItemView.NoEditTriggers) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/erf.py b/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/erf.py index d2e052751..99d21912d 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/erf.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/erf.py @@ -49,7 +49,7 @@ def setupUi(self, MainWindow): self.tableView.setEditTriggers(QAbstractItemView.NoEditTriggers) self.tableView.setDragEnabled(True) self.tableView.setDragDropMode(QAbstractItemView.DragDrop) - self.tableView.setDefaultDropAction(Qt.CopyAction) + self.tableView.setDefaultDropAction(Qt.DropAction.CopyAction) self.tableView.setAlternatingRowColors(True) self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows) self.tableView.setGridStyle(Qt.NoPen) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/git.py b/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/git.py index 2f84e2091..bdb0e178e 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/git.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/git.py @@ -126,7 +126,7 @@ def setupUi(self, MainWindow): self.listWidget = QListWidget(self.layoutWidget) self.listWidget.setObjectName(u"listWidget") self.listWidget.setMaximumSize(QSize(16777215, 16777215)) - self.listWidget.setContextMenuPolicy(Qt.CustomContextMenu) + self.listWidget.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.verticalLayout.addWidget(self.listWidget) @@ -472,7 +472,7 @@ def setupUi(self, MainWindow): self.renderArea.setSizePolicy(sizePolicy) self.renderArea.setMouseTracking(True) self.renderArea.setFocusPolicy(Qt.StrongFocus) - self.renderArea.setContextMenuPolicy(Qt.CustomContextMenu) + self.renderArea.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.renderArea.setStyleSheet(u"background: black;") self.verticalLayout_2.addWidget(self.renderArea) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/jrl.py b/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/jrl.py index 9ca92ea6c..de8f20c3d 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/jrl.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/jrl.py @@ -53,7 +53,7 @@ def setupUi(self, MainWindow): self.splitter.setOrientation(Qt.Vertical) self.journalTree = QTreeView(self.splitter) self.journalTree.setObjectName(u"journalTree") - self.journalTree.setContextMenuPolicy(Qt.CustomContextMenu) + self.journalTree.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.journalTree.setEditTriggers(QAbstractItemView.NoEditTriggers) self.journalTree.setHeaderHidden(True) self.splitter.addWidget(self.journalTree) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/pth.py b/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/pth.py index 4f49ad795..84b1c18f5 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/pth.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/pth.py @@ -51,7 +51,7 @@ def setupUi(self, MainWindow): self.renderArea.setSizePolicy(sizePolicy) self.renderArea.setMouseTracking(True) self.renderArea.setFocusPolicy(Qt.StrongFocus) - self.renderArea.setContextMenuPolicy(Qt.CustomContextMenu) + self.renderArea.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.renderArea.setStyleSheet(u"background: black;") self.gridLayout.addWidget(self.renderArea, 0, 0, 1, 1) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/tpc.py b/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/tpc.py index 41f096090..6d756d397 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/tpc.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/tpc.py @@ -43,7 +43,7 @@ def setupUi(self, MainWindow): self.verticalLayout.setObjectName(u"verticalLayout") self.textureImage = QLabel(self.centralwidget) self.textureImage.setObjectName(u"textureImage") - self.textureImage.setFrameShape(QFrame.Box) + self.textureImage.setFrameShape(QFrame.Shape.Box) self.textureImage.setFrameShadow(QFrame.Sunken) self.textureImage.setAlignment(Qt.AlignCenter) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/utc.py b/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/utc.py index e2ad94b9b..0528fd971 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/utc.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside6/editors/utc.py @@ -279,7 +279,7 @@ def setupUi(self, MainWindow): self.portraitPicture.setMinimumSize(QSize(64, 64)) self.portraitPicture.setMaximumSize(QSize(64, 64)) self.portraitPicture.setStyleSheet(u"background-color: black;") - self.portraitPicture.setFrameShape(QFrame.Box) + self.portraitPicture.setFrameShape(QFrame.Shape.Box) self.portraitPicture.setScaledContents(True) self.horizontalLayout_7.addWidget(self.portraitPicture) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside6/widgets/resource_list.py b/Tools/HolocronToolset/src/toolset/uic/pyside6/widgets/resource_list.py index 1af2c1775..c548b80d7 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside6/widgets/resource_list.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside6/widgets/resource_list.py @@ -73,7 +73,7 @@ def setupUi(self, Form): self.resourceTree = QTreeView(Form) self.resourceTree.setObjectName(u"resourceTree") - self.resourceTree.setContextMenuPolicy(Qt.CustomContextMenu) + self.resourceTree.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.resourceTree.setEditTriggers(QAbstractItemView.NoEditTriggers) self.resourceTree.setAlternatingRowColors(True) self.resourceTree.setSelectionMode(QAbstractItemView.ExtendedSelection) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside6/windows/indoor_builder.py b/Tools/HolocronToolset/src/toolset/uic/pyside6/windows/indoor_builder.py index 2102192b5..caecf2498 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside6/windows/indoor_builder.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside6/windows/indoor_builder.py @@ -86,7 +86,7 @@ def setupUi(self, MainWindow): self.mapRenderer.setObjectName(u"mapRenderer") self.mapRenderer.setMouseTracking(True) self.mapRenderer.setFocusPolicy(Qt.StrongFocus) - self.mapRenderer.setContextMenuPolicy(Qt.CustomContextMenu) + self.mapRenderer.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.horizontalLayout.addWidget(self.mapRenderer) diff --git a/Tools/HolocronToolset/src/toolset/uic/pyside6/windows/module_designer.py b/Tools/HolocronToolset/src/toolset/uic/pyside6/windows/module_designer.py index ad3f47ab7..efefeab80 100644 --- a/Tools/HolocronToolset/src/toolset/uic/pyside6/windows/module_designer.py +++ b/Tools/HolocronToolset/src/toolset/uic/pyside6/windows/module_designer.py @@ -493,7 +493,7 @@ def setupUi(self, MainWindow): self.resourceTree.setHeaderItem(__qtreewidgetitem) self.resourceTree.setObjectName(u"resourceTree") self.resourceTree.setMaximumSize(QSize(200, 16777215)) - self.resourceTree.setContextMenuPolicy(Qt.CustomContextMenu) + self.resourceTree.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.resourceTree.setEditTriggers(QAbstractItemView.NoEditTriggers) self.resourceTree.setHeaderHidden(True) @@ -521,7 +521,7 @@ def setupUi(self, MainWindow): self.instanceList = QListWidget(self.centralwidget) self.instanceList.setObjectName(u"instanceList") self.instanceList.setMaximumSize(QSize(200, 16777215)) - self.instanceList.setContextMenuPolicy(Qt.CustomContextMenu) + self.instanceList.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.horizontalLayout.addWidget(self.instanceList) diff --git a/Tools/HolocronToolset/src/toolset/utils/script.py b/Tools/HolocronToolset/src/toolset/utils/script.py index 9525e35bb..5726d8234 100644 --- a/Tools/HolocronToolset/src/toolset/utils/script.py +++ b/Tools/HolocronToolset/src/toolset/utils/script.py @@ -108,7 +108,7 @@ def decompileScript(compiled_bytes: bytes, installation_path: Path, *, tsl: bool ) log.warning(msg.replace("
", "\n"), exc_info=True) QMessageBox( - QMessageBox.Warning, + QMessageBox.Icon.Warning, "Permission denied when attempting to update nwnnsscomp in registry", msg, ).exec_() @@ -309,11 +309,11 @@ def handle_permission_error( ) log.warning(msg.replace("
", "\n")) longMsgBoxErr = QMessageBox( - QMessageBox.Warning, + QMessageBox.Icon.Warning, "Permission denied when attempting to update nwnnsscomp in registry", msg, ) - longMsgBoxErr.setIcon(QMessageBox.Warning) + longMsgBoxErr.setIcon(QMessageBox.Icon.Warning) longMsgBoxErr.exec_() @@ -322,7 +322,7 @@ def _prompt_user_for_compiler_option() -> int: msgBox = QMessageBox() # Set the message box properties - msgBox.setIcon(QMessageBox.Question) + msgBox.setIcon(QMessageBox.Icon.Question) msgBox.setWindowTitle("Choose a NCS compiler") msgBox.setText("Would you like to use 'nwnnsscomp.exe' or Holocron Toolset's built-in compiler?") msgBox.setInformativeText("Choose one of the options below:") diff --git a/Tools/HolocronToolset/src/toolset/utils/window.py b/Tools/HolocronToolset/src/toolset/utils/window.py index fa99947e2..07fbdfcd6 100644 --- a/Tools/HolocronToolset/src/toolset/utils/window.py +++ b/Tools/HolocronToolset/src/toolset/utils/window.py @@ -248,24 +248,24 @@ def openResourceEditor( except Exception as e: QMessageBox( - QMessageBox.Critical, + QMessageBox.Icon.Critical, "An unexpected error has occurred", str(universal_simplify_exception(e)), - QMessageBox.Ok, + QMessageBox.StandardButton.Ok, parentWindowWidget, - flags=Qt.Window | Qt.Dialog | Qt.WindowStaysOnTopHint, + flags=Qt.WindowType.Window | Qt.WindowType.Dialog | Qt.WindowType.WindowStaysOnTopHint, ).show() raise else: return filepath, editor else: QMessageBox( - QMessageBox.Critical, + QMessageBox.Icon.Critical, "Failed to open file", f"The selected file format '{restype}' is not yet supported.", - QMessageBox.Ok, + QMessageBox.StandardButton.Ok, parentWindowWidget, - flags=Qt.Window | Qt.Dialog | Qt.WindowStaysOnTopHint, + flags=Qt.WindowType.Window | Qt.WindowType.Dialog | Qt.WindowType.WindowStaysOnTopHint, ).show() return None, None diff --git a/Tools/KotorDiff/src/__init__.py b/Tools/KotorDiff/src/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/Tools/HolocronToolset/src/__init__.py b/Tools/KotorDiff/src/kotordiff/__init__.py similarity index 100% rename from Tools/HolocronToolset/src/__init__.py rename to Tools/KotorDiff/src/kotordiff/__init__.py diff --git a/Tools/KotorDiff/src/__main__.py b/Tools/KotorDiff/src/kotordiff/__main__.py similarity index 100% rename from Tools/KotorDiff/src/__main__.py rename to Tools/KotorDiff/src/kotordiff/__main__.py diff --git a/Tools/MDLDecompile/src/__main__.py b/Tools/MDLDecompile/src/__main__.py deleted file mode 100644 index 411e660ea..000000000 --- a/Tools/MDLDecompile/src/__main__.py +++ /dev/null @@ -1,114 +0,0 @@ -from __future__ import annotations - -import argparse # noqa: INP001 -import pathlib -import sys -import traceback - -if getattr(sys, "frozen", False) is False: - - def update_sys_path(path): - working_dir = str(path) - if working_dir in sys.path: - sys.path.remove(working_dir) - sys.path.append(working_dir) - - pykotor_path = pathlib.Path(__file__).parents[3] / "Libraries" / "PyKotor" / "src" / "pykotor" - if pykotor_path.exists(): - update_sys_path(pykotor_path.parent) - utility_path = pathlib.Path(__file__).parents[3] / "Libraries" / "Utility" / "src" / "utility" - if utility_path.exists(): - update_sys_path(utility_path.parent) - -from pykotor.resource.formats.mdl import read_mdl, write_mdl -from pykotor.resource.type import ResourceType -from utility.system.path import Path - -parser = argparse.ArgumentParser(description="Extracts MDL/MDX in ASCII format, whatever that means") -parser.add_argument("--input", type=str, help="Path to the MDL/MDX file/folder of MDL files") -parser.add_argument("--output", type=str, help="Output directory") -parser.add_argument("--compile", action="store_true", help="Should compile or decompile") -parser_args, unknown = parser.parse_known_args() -parser.print_help() -while True: - parser_args.input = Path( - parser_args.input or (unknown[0] if len(unknown) > 0 else None) or input("Path to the MDL/MDX file/folder of MDL files: "), - ).resolve() - if parser_args.input.safe_exists(): - break - print("Invalid path:", parser_args.input) - parser.print_help() - parser_args.input = None -while True: - parser_args.output = Path( - parser_args.output or (unknown[1] if len(unknown) > 1 else None) or input("Output directory: "), - ).resolve() - if parser_args.output.parent.safe_exists(): - parser_args.output.mkdir(exist_ok=True, parents=True) - break - print("Invalid path:", parser_args.output) - parser.print_help() - parser_args.output = None -while True: - parser_args.compile = str( - parser_args.compile or (unknown[2] if len(unknown) > 2 else None) or input("Would you like to compile or decompile? (enter 'c', 'compile' 'd', or 'decompile'): "), - ) - if parser_args.compile.lower().strip() in {"compile", "c"}: - parser_args.compile = True - break - elif parser_args.compile.lower().strip() in {"decompile", "d"}: - parser_args.compile = False - break - else: - print("Invalid input: enter 'compile' or 'decompile'") - parser_args.compile = None - - -def process_file(mdl_file: Path, output_path: Path, *, should_compile: bool): - model = read_mdl(mdl_file) - if should_compile: - write_mdl( - model, # type: ignore[None] - output_path / f"{mdl_file.stem}.mdl", - ResourceType.MDL, - ) - print("Compiled some ascii model thing to: ", output_path / f"{mdl_file.stem}.mdl") - else: - write_mdl( - model, # type: ignore[None] - output_path / f"{mdl_file.stem}.ascii_output", - ResourceType.MDL_ASCII, - ) - print("Extracted some ascii model thing to: ", output_path / f"{mdl_file.stem}.ascii_output") - - -def main(): - try: - input_path: Path = parser_args.input - - if input_path.safe_isfile(): - process_file(input_path, parser_args.output, should_compile=parser_args.compile) - - elif input_path.safe_isdir(): - for gui_file in input_path.safe_rglob("*.gui"): - try: - relative_path: Path = gui_file.relative_to(input_path) - new_output_dir: Path = parser_args.output / relative_path.parent / gui_file.stem - new_output_dir.mkdir(parents=True, exist_ok=True) - process_file(gui_file, new_output_dir, should_compile=parser_args.compile) - except KeyboardInterrupt: # noqa: PERF203 - raise - except Exception: # pylint: disable=W0718 # noqa: BLE001 - traceback.print_exc() - - else: - print(f"Invalid input: {input_path}. It's neither a file nor a directory.") - return - print("Completed extractions") - except KeyboardInterrupt: - print("Goodbye") - except Exception: # pylint: disable=W0718 # noqa: BLE001 - traceback.print_exc() - - -main() diff --git a/compile/compile_batchpatcher.ps1 b/compile/compile_batchpatcher.ps1 index 5754feaf5..ccb28fca1 100644 --- a/compile/compile_batchpatcher.ps1 +++ b/compile/compile_batchpatcher.ps1 @@ -151,7 +151,7 @@ foreach ($arg in $pyInstallerArgs) { } # Append the final script path -$argumentsArray += "__main__.py" +$argumentsArray += "batchpatcher/__main__.py" # Use the call operator with the arguments array Write-Host "Executing command: $pythonExePath $argumentsArray" diff --git a/compile/compile_gui_duplicator.ps1 b/compile/compile_gui_duplicator.ps1 index 5599e6a44..57673b86e 100644 --- a/compile/compile_gui_duplicator.ps1 +++ b/compile/compile_gui_duplicator.ps1 @@ -172,7 +172,7 @@ foreach ($arg in $pyInstallerArgs) { } # Append the final script path -$argumentsArray += "__main__.py" +$argumentsArray += "gui_duplicator/__main__.py" # Use the call operator with the arguments array Write-Host "Executing command: $pythonExePath $argumentsArray" diff --git a/compile/compile_holopatcher.ps1 b/compile/compile_holopatcher.ps1 index 225371d91..5242ba61d 100644 --- a/compile/compile_holopatcher.ps1 +++ b/compile/compile_holopatcher.ps1 @@ -35,7 +35,7 @@ $largeModules = @() foreach ($moduleName in $modulesArray) { $modulePath = Join-Path -Path $venvPath -ChildPath $moduleName if (Test-Path $modulePath) { - $dirSize = (Get-ChildItem -Path $modulePath -Recurse | Measure-Object -Property Length -Sum).Sum + $dirSize = (Get-ChildItem -LiteralPath $modulePath -Recurse | Measure-Object -Property Length -Sum).Sum if ($dirSize -ge $sizeThreshold) { #Write-Output "Found large module $modulePath with size $dirSize (exceeding threshold $sizeThreshold)" $largeModules += $moduleName @@ -198,7 +198,7 @@ $pyInstallerArgs = @{ 'distpath' = ($rootPath + $pathSep + "dist") 'name' = 'HoloPatcher' 'upx-dir' = $upx_dir - 'icon' = "..$pathSep" + "resources$pathSep" + "icons$pathSep" + "patcher_icon_v2.$iconExtension" + 'icon' = "resources$pathSep" + "icons$pathSep" + "patcher_icon_v2.$iconExtension" } $pyInstallerArgs = $pyInstallerArgs.GetEnumerator() | ForEach-Object { @@ -243,22 +243,17 @@ if ((Get-OS) -eq "Mac") { } } -# Prepare the Python command as a single string -$pythonCommand = @" +if ((Get-OS) -eq "Mac") { + $pythonCommand = @" import tkinter root = tkinter.Tk() print(root.tk.exprstring('$tcl_library')) print(root.tk.exprstring('$tk_library')) "@ -if ((Get-OS) -eq "Mac") { - - # Execute the Python command and capture the output $output = & $pythonExePath -c $pythonCommand # The output will contain both paths, one per line. Split them. $lines = $output -split "`n" - - # Assuming the first line is the Tcl library path and the second line is the Tk library path $tcl_library = $lines[0] $tk_library = $lines[1] @@ -290,7 +285,7 @@ foreach ($arg in $pyInstallerArgs) { } # Append the final script path -$argumentsArray += "__main__.py" +$argumentsArray += "holopatcher/__main__.py" # Use the call operator with the arguments array Write-Host "Executing command: $pythonExePath $argumentsArray" diff --git a/compile/compile_kotordiff.ps1 b/compile/compile_kotordiff.ps1 index 72d287862..22550764f 100644 --- a/compile/compile_kotordiff.ps1 +++ b/compile/compile_kotordiff.ps1 @@ -172,7 +172,7 @@ foreach ($arg in $pyInstallerArgs) { } # Append the final script path -$argumentsArray += "__main__.py" +$argumentsArray += "kotordiff/__main__.py" # Use the call operator with the arguments array Write-Host "Executing command: $pythonExePath $argumentsArray" diff --git a/install_python_venv.ps1 b/install_python_venv.ps1 index c37340964..77f2dcf55 100644 --- a/install_python_venv.ps1 +++ b/install_python_venv.ps1 @@ -1,7 +1,7 @@ [CmdletBinding(PositionalBinding=$false)] param( [switch]$noprompt, - [string]$venv_name = ".venv_fedora", + [string]$venv_name = ".venv", [string]$force_python_version ) $global:force_python_version = $force_python_version @@ -419,7 +419,7 @@ function Install-Python-Linux { } } Find-Python -installIfNotFound $false - if ( $global:pythonInstallPath -eq "" ) { + if ( -not $global:pythonInstallPath ) { throw "Python not found/installed" } } catch { @@ -588,6 +588,7 @@ function Install-PythonUnixSource { "3.10" { "3.10.13" } "3.11" { "3.11.8" } "3.12" { "3.12.2" } + "3.13" { "3.13.0a5" } default { throw "Unsupported Python version: $pythonVersion" } } @@ -614,6 +615,7 @@ function Install-PythonUnixSource { # Using `make install` may break system packages, so we use `make altinstall` here. Invoke-BashCommand -Command "sudo make altinstall" Set-Location -LiteralPath $current_working_dir + $global:pythonInstallPath = "/usr/local/bin/python$pythonVersion" } function RefreshEnvVar { @@ -815,6 +817,17 @@ function Find-Python { Param ( [bool]$installIfNotFound ) + if ($global:pythonInstallPath) { + $testVersion = Get-Python-Version -pythonPath $global:pythonInstallPath + if ($testVersion -ne [Version]"0.0.0") { + $global:pythonVersion = Get-Python-Version $global:pythonInstallPath + if ($global:pythonVersion -ge $minVersion -and $global:pythonVersion -lt $maxVersion) { + Write-Host "Found python command with version $global:pythonVersion at path $global:pythonInstallPath" + return + } + } + } + # Check for Python 3 command and version if ($global:force_python_version) { $fallbackVersion = $global:force_python_version diff --git a/pyproject.toml b/pyproject.toml index c2151662b..1caa5ea79 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -182,6 +182,7 @@ ignore = [ "EM102", # Exception must not use an f-string literal, assign to variable first "SIM108", # Use ternary operator instead of 'if' 'else' block "SIM114", # Combine `if` branches using logical `or` operator + "S101", # Use of `assert` detected. # The following are currently violated by the codebase. # "D205", # 1 blank line required between summary line and description