@@ -14,7 +14,8 @@ import {
1414 IsWindows ,
1515 OSExeSuffix ,
1616 searchForExeInQtInfo ,
17- telemetry
17+ telemetry ,
18+ QtWorkspaceFeatures
1819} from 'qt-lib' ;
1920import { coreAPI , projectManager } from '@/extension' ;
2021import { EXTENSION_ID } from '@/constants' ;
@@ -40,6 +41,14 @@ export async function openInLinguistCommand() {
4041 logger . error ( 'No project found for the active document' ) ;
4142 return ;
4243 }
44+ const workspaceFeatures = coreAPI ?. getValue < QtWorkspaceFeatures > (
45+ project . folder ,
46+ CoreKey . WORKSPACE_FEATURES
47+ ) ;
48+ const venvBinPath = coreAPI ?. getValue < string > (
49+ project . folder ,
50+ CoreKey . VENV_BIN_PATH
51+ ) ;
4352 const selectedKitPath = coreAPI ?. getValue < string > (
4453 project . folder ,
4554 CoreKey . SELECTED_KIT_PATH
@@ -49,16 +58,40 @@ export async function openInLinguistCommand() {
4958 CoreKey . SELECTED_QT_PATHS
5059 ) ;
5160 let linguistPath : string | undefined ;
52- if ( selectedKitPath ) {
53- linguistPath = await locateLinguist ( selectedKitPath ) ;
54- } else if ( selectedQtPaths ) {
55- linguistPath = await locateLinguistFromQtPaths ( selectedQtPaths ) ;
61+
62+ if ( workspaceFeatures ?. projectTypes . pyside ) {
63+ if ( venvBinPath ) {
64+ linguistPath = await locateLinguistFromVenvBinPaths ( venvBinPath ) ;
65+ }
66+ }
67+
68+ if ( workspaceFeatures ?. projectTypes . cmake ) {
69+ if ( selectedKitPath ) {
70+ linguistPath = await locateLinguist ( selectedKitPath ) ;
71+ } else if ( selectedQtPaths ) {
72+ linguistPath = await locateLinguistFromQtPaths ( selectedQtPaths ) ;
73+ }
5674 }
75+
5776 if ( ! linguistPath ) {
5877 logger . error ( 'Linguist executable not found' ) ;
59- void vscode . window . showErrorMessage (
60- 'Cannot find Qt Linguist executable. Check that the Qt version in the kit includes Qt Linguist.'
61- ) ;
78+
79+ const isCMake = ! ! workspaceFeatures ?. projectTypes . cmake ;
80+ const isPySide = ! ! workspaceFeatures ?. projectTypes . pyside ;
81+ const message = [ 'Cannot find Qt Linguist executable.' ] ;
82+
83+ if ( isCMake && ! isPySide ) {
84+ message . push (
85+ 'Check that the Qt version in the kit includes Qt Linguist.'
86+ ) ;
87+ } else if ( ! isCMake && isPySide ) {
88+ message . push (
89+ 'Check that PySide6 is properly installed ' +
90+ 'in a valid virtual environment.'
91+ ) ;
92+ }
93+
94+ void vscode . window . showErrorMessage ( message . join ( ' ' ) ) ;
6295 return ;
6396 }
6497 if ( ! ( await exists ( linguistPath ) ) ) {
@@ -118,6 +151,11 @@ async function locateLinguist(selectedKitPath: string) {
118151 return '' ;
119152}
120153
154+ async function locateLinguistFromVenvBinPaths ( venvBinPath : string ) {
155+ const candidate = path . join ( venvBinPath , 'pyside6-linguist' + OSExeSuffix ) ;
156+ return ( await exists ( candidate ) ) ? candidate : undefined ;
157+ }
158+
121159function openInLinguist ( linguistPath : string , file : string ) {
122160 const child = child_process . spawn ( linguistPath , [ file ] , {
123161 stdio : 'inherit' ,
0 commit comments