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

Method tryTabClose

src/tools/ecode/statusterminalcontroller.cpp:20–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20bool StatusTerminalController::tryTabClose( UITab* tab ) {
21 if ( !tab->getOwnedWidget()->isWidget() || tab->getOwnedWidget() == nullptr )
22 return true;
23
24 UIWidget* widget = tab->getOwnedWidget()->asType<UIWidget>();
25 if ( widget == nullptr || widget->getData() == 0 )
26 return true;
27
28 if ( mContext->getConfig().term.warnBeforeClosingTab && widget->isType( UI_TYPE_TERMINAL ) ) {
29 UITerminal* term = widget->asType<UITerminal>();
30 ProcessID pid = term->getTerm()->getTerminal()->getProcess()->pid();
31 if ( Sys::processHasChildren( pid ) ) {
32 UIMessageBox* msgBox =
33 UIMessageBox::New( UIMessageBox::OK_CANCEL,
34 mContext->i18n( "terminal_close_warn",
35 "Are you sure you want to close this "
36 "terminal?\nIt's still running a process." ) );
37 msgBox->on( Event::OnConfirm, [widget]( auto ) {
38 reinterpret_cast<UITab*>( widget->getData() )->removeTab();
39 } );
40 msgBox->on( Event::OnClose, [this]( const Event* ) { mContainer->setFocus(); } );
41 msgBox->setTitle( "ecode" );
42 msgBox->center();
43 msgBox->showWhenReady();
44 return false;
45 }
46 }
47 return true;
48}
49
50UIHLinearLayoutCommandExecuter* StatusTerminalController::createContainer() {
51 if ( mContainer )

Callers

nothing calls this directly

Calls 15

isWidgetMethod · 0.80
getOwnedWidgetMethod · 0.80
getConfigMethod · 0.80
centerMethod · 0.80
showWhenReadyMethod · 0.80
NewFunction · 0.50
getDataMethod · 0.45
isTypeMethod · 0.45
pidMethod · 0.45
getProcessMethod · 0.45
i18nMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected