MCPcopy Create free account
hub / github.com/SpartanJ/eepp / editBuild

Method editBuild

src/tools/ecode/projectbuild.cpp:293–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291}
292
293void ProjectBuildManager::editBuild( std::string buildName, UIWidget* buildTab ) {
294 if ( buildName.empty() )
295 return;
296
297 auto build = mBuilds.find( buildName );
298 if ( build == mBuilds.end() )
299 return;
300
301 std::string hashName = String::toString( String::hash( buildName ) );
302 UIWidget* widget = nullptr;
303 if ( ( widget = buildTab->getUISceneNode()->getRoot()->querySelector( "#build_settings_" +
304 hashName ) ) ) {
305 widget->asType<UITab>()->getTabWidget()->setTabSelected( widget->asType<UITab>() );
306 return;
307 }
308 auto ret = mApp->getSplitter()->createWidget(
309 UIBuildSettings::New( build->second, mConfig, false,
310 [this]( const std::string& oldName, const std::string& newName ) {
311 auto buildIt = mBuilds.find( oldName );
312 if ( buildIt != mBuilds.end() ) {
313 auto build = mBuilds.extract( buildIt );
314 build.key() = newName;
315 mBuilds.insert( std::move( build ) );
316 }
317 } ),
318 mApp->i18n( "build_settings", "Build Settings" ) );
319 auto bs = ret.second->asType<UIBuildSettings>();
320 bs->setTab( ret.first );
321 mCbs[bs].insert( bs->on( Event::OnConfirm, [this, bs]( const Event* event ) {
322 event->getNode()->removeEventListener( event->getCallbackId() );
323 mCbs[bs].erase( event->getCallbackId() );
324 saveAsync();
325 } ) );
326 mCbs[bs].insert( bs->on( Event::OnClose, [this, bs]( auto ) { mCbs.erase( bs ); } ) );
327 bs->on( Event::OnClear, [this]( const Event* event ) {
328 if ( mBuilds.erase( event->asTextEvent()->getText() ) > 0 ) {
329 if ( mConfig.buildName == event->asTextEvent()->getText() )
330 mConfig.buildName = mBuilds.empty() ? "" : mBuilds.begin()->first;
331 updateSidePanelTab();
332 }
333 } );
334 bs->on( Event::OnCopy, [this, buildName, buildTab]( const Event* event ) {
335 std::string clonedName( event->asTextEvent()->getText() );
336 if ( mBuilds.find( clonedName ) != mBuilds.end() ) {
337 UIMessageBox::New(
338 UIMessageBox::OK,
339 mApp->i18n( "cloned_name_must_be_different",
340 "Cloned name must be different from any existing build name." ) )
341 ->show();
342 } else {
343 cloneBuild( buildName, clonedName );
344 updateSidePanelTab();
345 editBuild( clonedName, buildTab );
346 }
347 } );
348 ret.first->setIcon( mApp->findIcon( "hammer" ) );
349}
350

Callers

nothing calls this directly

Calls 15

hashFunction · 0.85
querySelectorMethod · 0.80
setTabMethod · 0.80
getNodeMethod · 0.80
getCallbackIdMethod · 0.80
asTextEventMethod · 0.80
toStringFunction · 0.50
NewFunction · 0.50
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
getRootMethod · 0.45

Tested by

no test coverage detected