-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathQuickActionsTreeviewProvider.ts
More file actions
179 lines (167 loc) · 5.18 KB
/
Copy pathQuickActionsTreeviewProvider.ts
File metadata and controls
179 lines (167 loc) · 5.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import {
Event,
EventEmitter,
ProviderResult,
ThemeColor,
ThemeIcon,
TreeDataProvider,
TreeItem,
TreeItemCollapsibleState,
} from 'vscode';
import { COMMAND } from '@demotime/common';
type QuickAction = {
label: string;
description: string;
icon: string;
color?: string;
command: string;
};
export class QuickActionsTreeviewProvider implements TreeDataProvider<QuickActionTreeItem> {
private isPresentationMode = false;
private isAutoProceedActive = false;
private isAutoProceedPaused = false;
private autoProceedCountdown = 0;
private _onDidChangeTreeData = new EventEmitter<QuickActionTreeItem | undefined>();
public readonly onDidChangeTreeData: Event<QuickActionTreeItem | undefined> =
this._onDidChangeTreeData.event;
public setPresentationMode(isPresentationMode: boolean): void {
this.isPresentationMode = isPresentationMode;
}
public setAutoProceedState(isActive: boolean, isPaused: boolean, countdown: number): void {
this.isAutoProceedActive = isActive;
this.isAutoProceedPaused = isPaused;
this.autoProceedCountdown = countdown;
}
getTreeItem(element: QuickActionTreeItem): TreeItem | Thenable<TreeItem> {
return element;
}
getChildren(): ProviderResult<QuickActionTreeItem[]> {
const presentationAction: QuickAction = this.isPresentationMode
? {
label: 'Stop Presentation Mode',
description: 'Leave presentation mode',
icon: 'debug-stop',
color: 'charts.red',
command: COMMAND.togglePresentationMode,
}
: {
label: 'Start Presentation Mode',
description: 'Enter presentation mode',
icon: 'play',
color: 'charts.green',
command: COMMAND.togglePresentationMode,
};
const autoProceedAction: QuickAction | null = this.isAutoProceedActive
? this.isAutoProceedPaused
? {
label: 'Resume Auto-Proceed',
description: 'Resume auto-advance countdown',
icon: 'play-circle',
color: 'charts.green',
command: COMMAND.resumeAutoProceed,
}
: {
label: `Pause Auto-Proceed`,
description: `Next scene in ${this.autoProceedCountdown}s — click to pause`,
icon: 'debug-pause',
color: 'charts.yellow',
command: COMMAND.pauseAutoProceed,
}
: null;
const actions: QuickAction[] = [
presentationAction,
...(autoProceedAction ? [autoProceedAction] : []),
{
label: 'Start Timer',
description: 'Start countdown timer for your session',
icon: 'watch',
color: 'charts.yellow',
command: COMMAND.startCountdown,
},
{
label: 'Open Presenter View',
description: 'Show presenter notes and controls',
icon: 'open-preview',
command: COMMAND.showPresenterView,
},
{
label: 'Reset Demo State',
description: 'Clear highlights and reset runner state',
icon: 'discard',
color: 'charts.orange',
command: COMMAND.reset,
},
{
label: 'Export Slides to PDF',
description: 'Export your presentation to a PDF file',
icon: 'file-pdf',
command: COMMAND.exportToPdf,
},
{
label: 'Find in Acts & Scenes',
description: 'Focus and search in the Acts & Scenes tree',
icon: 'search',
command: COMMAND.treeviewFind,
},
{
label: 'Create Act File',
description: 'Create a new act file in the .demo folder',
icon: 'new-file',
command: COMMAND.createDemoFile,
},
{
label: 'Open Overview',
description: 'Open the Demo Time overview panel',
icon: 'home',
command: COMMAND.showOverview,
},
{
label: 'Open Settings',
description: 'Open Demo Time settings panel',
icon: 'settings-gear',
command: COMMAND.showSettings,
},
{
label: 'Open PRO Features',
description: 'Discover or unlock PRO capabilities',
icon: 'lock',
color: 'charts.red',
command: COMMAND.showProFeatures,
},
{
label: 'Open Documentation',
description: 'Read docs, guides, and references',
icon: 'book',
command: COMMAND.documentation,
},
{
label: 'Support the Project',
description: 'Sponsor Demo Time development',
icon: 'heart',
color: 'charts.red',
command: COMMAND.openSupportTheProject,
},
];
return actions.map((action) => new QuickActionTreeItem(action));
}
update(): void {
this._onDidChangeTreeData.fire(undefined);
}
}
export class QuickActionTreeItem extends TreeItem {
constructor(action: QuickAction) {
super(action.label, TreeItemCollapsibleState.None);
this.label = action.label;
this.description = action.description;
this.tooltip = action.description;
this.iconPath = new ThemeIcon(
action.icon,
action.color ? new ThemeColor(action.color) : undefined,
);
this.command = {
command: action.command,
title: action.label,
};
this.contextValue = 'demo-time.quick-action';
}
}