Skip to content

Commit c0660de

Browse files
committed
Fixed icons in tree / stats
1 parent 7305575 commit c0660de

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

src/control.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,10 @@ export class Control {
118118
);
119119

120120
// Load Stats View
121-
Logger.log(`Stats: ${configuration.getParam('views.stats.enabled') ? 'Enabled' : 'Disabled'}`);
122-
Logger.log(`Stats AutoRefresh: ${configuration.getParam('views.stats.autoRefresh') ? 'Enabled' : 'Disabled'}`);
121+
Logger.log('Loading Stats View...');
122+
context.subscriptions.push((this._statsView = new StatsView()));
123123

124-
if (config.getParam('views.stats.enabled')) {
125-
Logger.log('Loading Stats View...');
126-
context.subscriptions.push((this._statsView = new StatsView()));
127-
} else {
128-
let disposable: Disposable;
129-
// eslint-disable-next-line prefer-const
130-
disposable = configuration.onDidChange(e => {
131-
if (configuration.changed(e, 'views.stats.enabled')) {
132-
disposable.dispose();
133-
Logger.log('Loading Stats View...');
134-
context.subscriptions.push((this._statsView = new StatsView()));
135-
}
136-
});
137-
}
124+
Logger.log(`Stats AutoRefresh: ${configuration.getParam('views.stats.autoRefresh') ? 'Enabled' : 'Disabled'}`);
138125

139126
// Load Support Heart to Statusbar
140127
this._statusBarControl.updateStatusBar(

src/util/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ export const constants: IConstants = {
4646
},
4747
extensionOutputChannelName: gcode.packageJSON.shortName,
4848
extensionQualifiedId: extensionQualifiedId,
49-
gcodeIcon: path.join(__dirname, '..', '..', 'resources', 'icons', 'gcode.svg'),
50-
iconsPath: path.join(__dirname, '..', '..', 'resources', 'icons'),
49+
gcodeIcon: path.join(__dirname, '..', 'resources', 'icons', 'gcode.svg'),
50+
iconsPath: path.join(__dirname, '..', 'resources', 'icons'),
5151
iconExt: '.svg',
5252
langId: gcode.packageJSON.contributes.languages[0].id,
5353
urls: {

src/views/statsView.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
* -------------------------------------------------------------------------------------------- */
55
'use strict';
66

7-
import { commands, ConfigurationChangeEvent, TextDocumentChangeEvent, TreeItemCollapsibleState, window } from 'vscode';
7+
import {
8+
commands,
9+
ConfigurationChangeEvent,
10+
TextDocumentChangeEvent,
11+
ThemeIcon,
12+
TreeItemCollapsibleState,
13+
window,
14+
} from 'vscode';
815
import { Control } from '../control';
916
import { configuration } from '../util/config';
1017
import { constants, Contexts } from '../util/constants';
@@ -21,7 +28,6 @@ const StatsViewInfo = {
2128
ViewName: 'Stats',
2229
Config: {
2330
AutoRefresh: 'views.stats.autoRefresh',
24-
Enabled: 'views.stats.enabled',
2531
MaxAutoRefresh: 'views.maxAutoRefresh',
2632
},
2733
Context: Contexts.ViewsStatsEnabled,
@@ -104,7 +110,7 @@ export class StatsView extends GView<StatsNode> {
104110
} else {
105111
void Control.setContext(Contexts.ViewsStatsEnabled, false);
106112

107-
this._children = [];
113+
this._children = [this.placeholder()];
108114
this._onDidChangeTreeData.fire(undefined);
109115
}
110116
}
@@ -122,7 +128,7 @@ export class StatsView extends GView<StatsNode> {
122128
} else {
123129
void Control.setContext(Contexts.ViewsStatsEnabled, false);
124130

125-
this._children = [];
131+
this._children = [this.placeholder()];
126132
this._onDidChangeTreeData.fire(undefined);
127133
}
128134
}
@@ -258,4 +264,18 @@ export class StatsView extends GView<StatsNode> {
258264
return false;
259265
}
260266
}
267+
268+
private placeholder(): StatsNode {
269+
const ph = new StatsNode(
270+
StatsType.Info,
271+
'AutoRefresh is Disabled',
272+
undefined,
273+
ResourceType.Stats,
274+
TreeItemCollapsibleState.None,
275+
);
276+
277+
ph.iconPath = new ThemeIcon('extensions-info-message');
278+
279+
return ph;
280+
}
261281
}

0 commit comments

Comments
 (0)