Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 6ba5592

Browse files
committed
merge develop
2 parents f65c030 + 572e2bd commit 6ba5592

File tree

5 files changed

+128
-74
lines changed

5 files changed

+128
-74
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ out
22
node_modules
33
.vscode-test/
44
*.vsix
5+
package-lock.json

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,26 @@
77
* `qmllint`
88
* `qmleasing`
99
* Color provider for QML and QSS
10-
* Button for `qmlscene` preview
1110
* `pyqtdeploy` (PyQt5 only)
1211
* CI/CD
1312

13+
## 0.2.0
14+
15+
### Added
16+
17+
* Menus in editor/title and editor/context
18+
1419
## 0.1.1
1520

1621
### Changed
1722

1823
* Format the README.md
1924
* Update the username of badgets
2025

26+
### Fixed
27+
28+
* Now, the path of input file could include spaces. (thanks to _Paolo (ZioLupo)_)
29+
2130
## 0.1.0
2231

2332
### Added

README.md

Lines changed: 18 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -23,63 +23,32 @@ A Visual Studio Code extension provides some common functionalities for PyQt5 an
2323

2424
## Features
2525

26-
* Qt Markup Language (`*.qml`) highlighting and snippets support
27-
* QML Module Definition Files (`*.qmldir`) highlighting and snippets support
28-
* Qt Style Sheets (`*.qss`) highlighting and snippets support
29-
* Qt Linguist Translation (`*.qt.ts`) highlighting support (XML)
30-
* Resource Collection Files (`*.qrc`) highlighting support (XML)
31-
* Qt Designer Form (`*.ui`) highlighting support (XML)
32-
* Qt Creator User Settings (`*.pro.user`) highlighting support (XML)
33-
* `qmake` highlighting support
34-
* New form (Qt Designer `*.ui` file) command
35-
* Edit form (Qt Designer `*.ui` file) command
36-
* Edit translation (Qt Linguist `*.qt.ts` file)
37-
* Release translation (Qt Linguist `*.qt.ts` file) to `*.qm` file
38-
* Preview QML
26+
* [x] Qt Markup Language (`*.qml`) highlighting and snippets support
27+
* [x] QML Module Definition Files (`*.qmldir`) highlighting and snippets support
28+
* [x] Qt Style Sheets (`*.qss`) highlighting and snippets support
29+
* [x] Qt Linguist Translation (`*.qt.ts`) highlighting support (XML)
30+
* [x] Resource Collection Files (`*.qrc`) highlighting support (XML)
31+
* [x] Qt Designer Form (`*.ui`) highlighting support (XML)
32+
* [x] Qt Creator User Settings (`*.pro.user`) highlighting support (XML)
33+
* [x] `qmake` highlighting support
34+
* [x] New form (Qt Designer `*.ui` file) command
35+
* [x] Edit form (Qt Designer `*.ui` file) command
36+
* [x] Compile form (Qt Designer `*.ui` file) into Python file (require `pyuic5` or `pyside2-uic`)
37+
* [x] Update translation (Qt Linguist `*.qt.ts` file) from Python file (require `pylupdate5` or `pyside2-lupdate`)
38+
* [x] Edit translation (Qt Linguist `*.qt.ts` file)
39+
* [x] Release translation (Qt Linguist `*.qt.ts` file) to `*.qm` file
40+
* [x] Preview QML
41+
* [x] Compile QRC (Qt Resource File) into Python file (require `pyrcc5` or `pyside2-rcc`)
3942

4043
## Requirements
4144

4245
This extension requires Qt Designer, Qt Linguist, Qt `lrelease` and Qt `qmlscene` for different features. You could install these tools by installing [Qt Creator](https://www.qt.io/download).
4346

4447
After the installation, you could find the tools within the installing folder of Qt Creator in your computer. For example, if you install Qt Creator 5.12.0 in `/opt/Qt` in Linux, you could find out the binary of these tools in `/opt/Qt/5.12.0/gcc_64/bin`. Or, for Windows, you could find the binary of the tools in `C:\Qt\5.12.0\mingw73_64\bin` if you did not change the default path. You have to set the paths of tools in **Qt for Python** section in user settings of Visual Studio Code before using the commands provided by this extension.
4548

46-
## Command and Explorer Context Menu
49+
## Caveat
4750

48-
> **Note**: All file generated by the following command would overwrite the existing files with the same name **without warning**.
49-
50-
### New Form (Qt Designer UI File)
51-
52-
* When: Any condition for command palette or the target in explorer context is a folder.
53-
* Behavior: Create new UI file in Qt Designer.
54-
55-
### Edit Form (Qt Designer UI File)
56-
57-
* When: The file name extension of the target file in explorer context or the current document in the editor is `*.ui`.
58-
* Behavior: Edit the UI file in Qt Designer.
59-
60-
### Edit Qt Linguist Translation File
61-
62-
* When: The file name extension of the target file in explorer context or the current document in the editor is `*.qt.ts` and the language is `xml`.
63-
* Behavior: Edit the `qt.ts` file in Qt Linguist.
64-
65-
### Release Qt Linguist Translation to QM File
66-
67-
* When: The file name extension of the target file in explorer context or the current document in the editor is `*.qt.ts` and the language is `xml`.
68-
* Behavior: Use `lrelease` to convert the `qt.ts` file into `*.qm` file.
69-
70-
### Preview QML
71-
72-
* When: The file name extension of the target file in explorer context or the current document in the editor is `*.qml`.
73-
* Behavior: Use `qmlscene` to preview the QML file.
74-
75-
## Extension Settings
76-
77-
This extension contributes the following settings:
78-
79-
* `qtForPython.path.designer`: The path of Qt Designer with CLI arguments to create and edit form (`*.ui`) files. For example, `/opt/Qt/5.12.0/gcc_64/bin/designer`.
80-
* `qtForPython.path.linguist`: The path of Qt Linguist with CLI arguments to edit translation (`*.qt.ts`) files. For example, `/opt/Qt/5.12.0/gcc_64/bin/linguist`.
81-
* `qtForPython.path.lrelease`: The path of Qt lrelease with CLI arguments to edit translation (`*.qt.ts`) files. For example, `/opt/Qt/5.12.0/gcc_64/bin/lrelease -qm ./out.qm`.
82-
* `qtForPython.path.qmlscene`: The path of Qt QML Scene (`qmlscene`) with CLI arguments to preview QML (`*.qml`) files. For example, `/opt/Qt/5.12.0/gcc_64/bin/qmlscene --verbose`.
51+
* All file generated by the following command would overwrite the existing files with the same name **without warning**.
8352

8453
## Release Notes
8554

package.json

Lines changed: 92 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"name": "vscode-qt-for-python",
3+
<<<<<<< HEAD
34
"version": "0.1.1",
5+
=======
6+
"version": "0.2.0",
7+
>>>>>>> develop
48
"publisher": "seanwu",
59
"engines": {
610
"vscode": "^1.30.0"
@@ -64,6 +68,36 @@
6468
}
6569
],
6670
"menus": {
71+
"commandPalette": [
72+
{
73+
"command": "qtForPython.editForm",
74+
"when": "resourceExtname == .ui && resourceLangId == xml"
75+
},
76+
{
77+
"command": "qtForPython.compileForm",
78+
"when": "resourceExtname == .ui && resourceLangId == xml"
79+
},
80+
{
81+
"command": "qtForPython.updateTranslation",
82+
"when": "resourceLangId == python"
83+
},
84+
{
85+
"command": "qtForPython.editTranslation",
86+
"when": "resourceExtname == .ts && resourceLangId == xml"
87+
},
88+
{
89+
"command": "qtForPython.releaseTranslation",
90+
"when": "resourceExtname == .ts && resourceLangId == xml"
91+
},
92+
{
93+
"command": "qtForPython.previewQml",
94+
"when": "resourceLangId == qml"
95+
},
96+
{
97+
"command": "qtForPython.compileResource",
98+
"when": "resourceExtname == .qrc && resourceLangId == xml"
99+
}
100+
],
67101
"explorer/context": [
68102
{
69103
"command": "qtForPython.newForm",
@@ -106,34 +140,78 @@
106140
"group": "qtForPython@8"
107141
}
108142
],
109-
"commandPalette": [
143+
"editor/title": [
110144
{
111145
"command": "qtForPython.editForm",
112-
"when": "resourceExtname == .ui && resourceLangId == xml"
146+
"when": "resourceExtname == .ui && resourceLangId == xml",
147+
"group": "qtForPython@2"
113148
},
114149
{
115150
"command": "qtForPython.compileForm",
116-
"when": "resourceExtname == .ui && resourceLangId == xml"
151+
"when": "resourceExtname == .ui && resourceLangId == xml",
152+
"group": "qtForPython@3"
117153
},
118154
{
119155
"command": "qtForPython.updateTranslation",
120-
"when": "resourceLangId == python"
156+
"when": "resourceLangId == python",
157+
"group": "qtForPython@4"
121158
},
122159
{
123160
"command": "qtForPython.editTranslation",
124-
"when": "resourceExtname == .ts && resourceLangId == xml"
161+
"when": "resourceExtname == .ts && resourceLangId == xml",
162+
"group": "qtForPython@5"
125163
},
126164
{
127165
"command": "qtForPython.releaseTranslation",
128-
"when": "resourceExtname == .ts && resourceLangId == xml"
166+
"when": "resourceExtname == .ts && resourceLangId == xml",
167+
"group": "qtForPython@6"
129168
},
130169
{
131170
"command": "qtForPython.previewQml",
132-
"when": "resourceLangId == qml"
171+
"when": "resourceLangId == qml",
172+
"group": "qtForPython@7"
133173
},
134174
{
135175
"command": "qtForPython.compileResource",
136-
"when": "resourceExtname == .qrc && resourceLangId == xml"
176+
"when": "resourceExtname == .qrc && resourceLangId == xml",
177+
"group": "qtForPython@8"
178+
}
179+
],
180+
"editor/context": [
181+
{
182+
"command": "qtForPython.editForm",
183+
"when": "resourceExtname == .ui && resourceLangId == xml",
184+
"group": "qtForPython@2"
185+
},
186+
{
187+
"command": "qtForPython.compileForm",
188+
"when": "resourceExtname == .ui && resourceLangId == xml",
189+
"group": "qtForPython@3"
190+
},
191+
{
192+
"command": "qtForPython.updateTranslation",
193+
"when": "resourceLangId == python",
194+
"group": "qtForPython@4"
195+
},
196+
{
197+
"command": "qtForPython.editTranslation",
198+
"when": "resourceExtname == .ts && resourceLangId == xml",
199+
"group": "qtForPython@5"
200+
},
201+
{
202+
"command": "qtForPython.releaseTranslation",
203+
"when": "resourceExtname == .ts && resourceLangId == xml",
204+
"group": "qtForPython@6"
205+
},
206+
{
207+
"command": "qtForPython.previewQml",
208+
"when": "resourceLangId == qml",
209+
"group": "qtForPython@7"
210+
},
211+
{
212+
"command": "qtForPython.compileResource",
213+
"when": "resourceExtname == .qrc && resourceLangId == xml",
214+
"group": "qtForPython@8"
137215
}
138216
]
139217
},
@@ -143,12 +221,12 @@
143221
"qtForPython.path.designer": {
144222
"type": "string",
145223
"default": "",
146-
"markdownDescription": "The path of Qt Designer with CLI arguments to create and edit form (`*.ui`) files. For example, `/opt/Qt/5.12.0/gcc_64/bin/designer` in Linux or `C:\\Qt\\5.12.0\\mingw73_64\\bin\\designer.exe` in Windows."
224+
"markdownDescription": "The path of Qt Designer with CLI arguments to create and edit form (`*.ui`) files. For example, `\"/opt/Qt/5.12.0/gcc_64/bin/designer\"` in Linux or `\"C:\\Qt\\5.12.0\\mingw73_64\\bin\\designer.exe\"` in Windows."
147225
},
148226
"qtForPython.path.pyuic": {
149227
"type": "string",
150228
"default": "",
151-
"markdownDescription": "The path of UI compiler of Qt for Python (PyQt5 or PySide2). For example, `pyuic5 -d -o ./out.py ` for PyQt5 or `pyside2-uic -d -o ./out.py ` for PySide2."
229+
"markdownDescription": "The path of UI compiler of Qt for Python (PyQt5 or PySide2). For example, `pyuic5 -d -o ./out.py` for PyQt5 or `pyside2-uic -d -o ./out.py` for PySide2."
152230
},
153231
"qtForPython.path.pylupdate": {
154232
"type": "string",
@@ -158,17 +236,17 @@
158236
"qtForPython.path.linguist": {
159237
"type": "string",
160238
"default": "",
161-
"markdownDescription": "The path of Qt Linguist with CLI arguments to edit translation (`*.qt.ts`) files. For example, `/opt/Qt/5.12.0/gcc_64/bin/linguist` in Linux or `C:\\Qt\\5.12.0\\mingw73_64\\bin\\linguist.exe` in Windows."
239+
"markdownDescription": "The path of Qt Linguist with CLI arguments to edit translation (`*.qt.ts`) files. For example, `\"/opt/Qt/5.12.0/gcc_64/bin/linguist\"` in Linux or `\"C:\\Qt\\5.12.0\\mingw73_64\\bin\\linguist.exe\"` in Windows."
162240
},
163241
"qtForPython.path.lrelease": {
164242
"type": "string",
165243
"default": "",
166-
"markdownDescription": "The path of Qt lrelease with CLI arguments to edit translation (`*.qt.ts`) files. For example, `/opt/Qt/5.12.0/gcc_64/bin/lrelease -qm ./out.qm` in Linux or `C:\\Qt\\5.12.0\\mingw73_64\\bin\\lrelease.exe -qm .\\out.qm` in Windows."
244+
"markdownDescription": "The path of Qt lrelease with CLI arguments to edit translation (`*.qt.ts`) files. For example, `\"/opt/Qt/5.12.0/gcc_64/bin/lrelease\" -qm ./out.qm` in Linux or `\"C:\\Qt\\5.12.0\\mingw73_64\\bin\\lrelease.exe\" -qm .\\out.qm` in Windows."
167245
},
168246
"qtForPython.path.qmlscene": {
169247
"type": "string",
170248
"default": "",
171-
"markdownDescription": "The path of Qt QML Scene (`qmlscene`) with CLI arguments to preview QML (`*.qml`) files. For example, `/opt/Qt/5.12.0/gcc_64/bin/qmlscene --verbose` in Linux or `C:\\Qt\\5.12.0\\mingw73_64\\bin\\qmlscene.exe --verbose` in Windows."
249+
"markdownDescription": "The path of Qt QML Scene (`qmlscene`) with CLI arguments to preview QML (`*.qml`) files. For example, `\"/opt/Qt/5.12.0/gcc_64/bin/qmlscene\" --verbose` in Linux or `\"C:\\Qt\\5.12.0\\mingw73_64\\bin\\qmlscene.exe\" --verbose` in Windows."
172250
},
173251
"qtForPython.path.pyrcc": {
174252
"type": "string",
@@ -329,4 +407,4 @@
329407
"url": "https://github.com/seanwu1105/vscode-qt-for-python/issues",
330408
"email": "seanwu1105@gmail.com"
331409
}
332-
}
410+
}

src/extension.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export function activate(context: vscode.ExtensionContext) {
1919
// (console.error).
2020
// This line of code will only be executed once when your extension is
2121
// activated.
22-
console.log('The extension "vscode-qt-for-python" is now active!')
2322

2423
outputChannel = vscode.window.createOutputChannel('Qt for Python')
2524

@@ -56,25 +55,23 @@ export function activate(context: vscode.ExtensionContext) {
5655
if (tsFileArg) {
5756
// Remove "-ts ts-files" from toolPath.
5857
toolPath = toolPath.replace(tsFileArgRegex, '')
59-
console.log(tsFileArg)
60-
console.log(toolPath)
6158
if (fileUri) { // from explorer/context menus
6259
// Move "-ts ts-files" behind the fileUri.
63-
exec(`${toolPath} ${fileUri.fsPath} ${tsFileArg}`)
60+
exec(`${toolPath} "${fileUri.fsPath}" ${tsFileArg}`)
6461
} else { // from command palette
6562
const activeTextEditor = vscode.window.activeTextEditor
6663
if (activeTextEditor) {
6764
const documentUri = activeTextEditor.document.uri
6865
// Move "-ts ts-files" behind the fileUri.
69-
exec(`${toolPath} ${documentUri.fsPath} ${tsFileArg}`)
66+
exec(`${toolPath} "${documentUri.fsPath}" ${tsFileArg}`)
7067
}
7168
}
7269
} else {
7370
const response = await vscode.window.showErrorMessage(
7471
'The output location of TS file is required. Add ' +
7572
'"-ts ts-filename" to the path of pylupdate.',
7673
'Setting'
77-
)
74+
)
7875
if (response === 'Setting') {
7976
vscode.commands.executeCommand('workbench.action.openSettings')
8077
}
@@ -108,12 +105,12 @@ function useTool(id: string, name: string, targetUri: vscode.Uri) {
108105
const toolPath = vscode.workspace.getConfiguration('qtForPython.path').get<string>(id)
109106
if (toolPath) {
110107
if (targetUri) { // from explorer/context menus
111-
exec(`${toolPath} ${targetUri.fsPath}`)
108+
exec(`${toolPath} "${targetUri.fsPath}"`)
112109
} else { // from command palette
113110
const activeTextEditor = vscode.window.activeTextEditor
114111
if (activeTextEditor) {
115112
const documentUri = activeTextEditor.document.uri
116-
exec(`${toolPath} ${documentUri.fsPath}`)
113+
exec(`${toolPath} "${documentUri.fsPath}"`)
117114
}
118115
}
119116
} else { showPathNotExist(name) }
@@ -130,10 +127,10 @@ async function showPathNotExist(name: string) {
130127
}
131128
}
132129

133-
async function exec(file: string, options = { cwd: rootPath }) {
130+
async function exec(command: string, options = { cwd: rootPath }) {
134131
let output
135132
try {
136-
output = await util.promisify(child_process.exec)(file, options)
133+
output = await util.promisify(child_process.exec)(command, options)
137134
} catch (err) {
138135
vscode.window.showErrorMessage(err.message)
139136
outputChannel.appendLine(`[ERROR] ${err.message}`)

0 commit comments

Comments
 (0)