Skip to content

Commit

Permalink
Make doNotAskForDefaultQtFolder a config variable
Browse files Browse the repository at this point in the history
Storing that value in global `settings.json` is better than storing in
`StateManager` because when a config variable is used, users can copy
their configuration easily. That is not possible when it is stored in
`StateManager`.

Change-Id: I70cb712f0ec5296e427dc9aa8987b5e7d4612a5b
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
  • Loading branch information
OrkunTokdemir committed Mar 20, 2024
1 parent 82e57b8 commit 80a5b8e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@
"default": "",
"description": "Specify the Qt folder",
"scope": "machine"
},
"vscode-qt-tools.doNotAskForDefaultQtFolder": {
"type": "boolean",
"default": false,
"description": "Do not ask for default Qt folder",
"scope": "machine"
}
}
}
Expand Down
22 changes: 20 additions & 2 deletions src/commands/register-qt-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,26 @@ export function getQtFolder(): string {
);
}

export async function setDoNotAskForDefaultQtFolder(value: boolean) {
await vscode.workspace
.getConfiguration('vscode-qt-tools')
.update(
'doNotAskForDefaultQtFolder',
value,
vscode.ConfigurationTarget.Global
);
}

export function getDoNotAskForDefaultQtFolder(): boolean {
return (
vscode.workspace
.getConfiguration('vscode-qt-tools')
.get<boolean>('doNotAskForDefaultQtFolder') ?? false
);
}

export function checkDefaultQtFolderPath() {
if (!stateManager.getAskForDefaultQtFolder()) {
if (getDoNotAskForDefaultQtFolder()) {
return;
}

Expand Down Expand Up @@ -122,7 +140,7 @@ export function checkDefaultQtFolderPath() {
if (response === setDefaultPathButtonMessage) {
void setQtFolder(defaultPath);
} else if (response === doNotShowAgainButtonMessage) {
void stateManager.setAskForDefaultQtFolder(false);
void setDoNotAskForDefaultQtFolder(true);
}
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/commands/reset-qt-ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

import * as vscode from 'vscode';
import { stateManager } from '../state';
import { setQtFolder } from './register-qt-path';
import { setDoNotAskForDefaultQtFolder, setQtFolder } from './register-qt-path';

export async function resetQtExt() {
await stateManager.reset();
await setQtFolder('');
await setDoNotAskForDefaultQtFolder(false);
}

export function registerResetQtExtCommand() {
Expand Down
7 changes: 0 additions & 7 deletions src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,8 @@ export class StateManager {
public setQtInstallations(value: string[]): Thenable<void> {
return this._update('qtInstallations', value);
}
public setAskForDefaultQtFolder(value: boolean): Thenable<void> {
return this._update('askForDefaultQtFolder', value);
}
public getAskForDefaultQtFolder(): boolean {
return this._get<boolean>('askForDefaultQtFolder', true);
}
public async reset() {
await this.setQtInstallations([]);
await this.setAskForDefaultQtFolder(true);
}
}

Expand Down

0 comments on commit 80a5b8e

Please sign in to comment.