MacroManager.cpp.patch

Abdelghani Omari, 08/17/2017 03:21 PM

Download (2.14 KB)

View differences:

MacroManager.cpp (working copy)
47 47
	
48 48
	newGlobalLabel.Enable();
49 49
	importGlobalsLabel.Enable();
50
	exportGlobalsLabel.Enable();
50
	exportGlobalsLabel.Enable(globalTree.GetChildCount(0));
51 51
}
52 52

  
53 53
void MacroManagerWindow::InitToolButton(
......
223 223
		fileName << ".usc";
224 224
	
225 225
	String fullPath = AppendFileName(GetLocalDir(), fileName);
226
	RealizeDirectory(GetLocalDir());
226 227
	if(FileExists(fullPath)) {
227 228
		PromptOK(String() << t_("file") << " \"" << fileName << "\" " << t_("already exists!"));
228 229
		return;
229 230
	}
230 231
	
231
	SaveFile(fullPath, "macro \"" + GetFileTitle(fileName) + "\" {}");
232
	ReloadGlobalMacros(); // TODO: This is a little bit overkill we add one element to the tree and we reload all tree...
233
	globalTree.FindSetCursor(fileName);
232
	if(!SaveFile(fullPath, "macro \"" + GetFileTitle(fileName) + "\" {}")) {
233
		PromptOK(String() << t_("Error occured while saving file") << " \"" << fileName << "\"");
234
		return;
235
	}
236

  
237
	int fileNode = globalTree.Add(0, Image(), fullPath, fileName);
238
	auto list = UscFileParser(fullPath).Parse();
239
	for(const auto& element : list)
240
		globalTree.Add(fileNode, element.GetImage(), RawToValue(element), element.name);
241
	globalTree.OpenDeep(fileNode);
242

  
243
	//ReloadGlobalMacros(); // TODO: This is a little bit overkill we add one element to the tree and we reload all tree...
244
				//  OK, replaced by adding the file at the end of the Tree.
245
				
246
	globalTree.FindSetCursor(fullPath);
234 247
	
235 248
	OnGlobalMacrosChanged();
236 249
}
......
238 251
void MacroManagerWindow::OnDeleteMacroFile()
239 252
{
240 253
	auto fileName = static_cast<String>(globalTree.GetValue());
241
	if(!PromptOKCancel(t_("Are you sure you want to remove followin macro file \"" + fileName + "\"?")))
254
	if(!PromptOKCancel(t_("Are you sure you want to remove following macro file \"" + fileName + "\"?")))
242 255
		return;
243 256
	
244 257
	FileDelete(AppendFileName(GetLocalDir(), fileName));
......
250 263

  
251 264
void MacroManagerWindow::OnGlobalMacrosChanged()
252 265
{
266
	exportGlobalsLabel.Enable(globalTree.GetChildCount(0));
253 267
	globalMacrosChanged = true;
254 268
}
255 269