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

Method configureTerminalWorkingDir

src/tools/ecode/terminalmanager.cpp:266–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264}
265
266void TerminalManager::configureTerminalWorkingDir() {
267 static const auto layout( R"xml(
268 <window layout_width="450dp" layout_height="154dp" window-flags="default|shadow"
269 window-title='@string(terminal_working_dir_configuration, "Terminal Default Working Directory Configuration")'>
270 <vbox lw="mp" lh="wrap_content" padding="4dp">
271 <TextView text='@string(configure_terminal_default_working_dir, "Configure Terminal default working directory:")' font-size="14dp" margin-bottom="8dp" />
272 <DropDownList id="working_dir_combo" layout_width="match_parent" layout_height="wrap_content" selectedIndex="0" popup-to-root="true" />
273 <hbox id="other_dir_container" lw="mp" lh="wrap_content" margin-top="8dp" visible="false">
274 <TextInput id="other_dir_input" lw="0" lw8="1" lh="wrap_content" hint="@string(other_working_directory, Other Working Directory)" />
275 <PushButton id="other_dir_browse" lw="wrap_content" lh="wrap_content" text="..." margin-left="4dp" />
276 </hbox>
277 <hbox layout_gravity="right" margin-top="8dp">
278 <PushButton id="ok" text="@string(msg_box_ok, Ok)" icon="ok" />
279 <PushButton id="cancel" text="@string(msg_box_cancel, Cancel)" margin-left="8dp" icon="cancel" />
280 </hbox>
281 </vbox>
282 </window>
283 )xml" );
284 UIWindow* window = mApp->getUISceneNode()->loadLayoutFromString( layout )->asType<UIWindow>();
285 UIDropDownList* workingDirCombo = window->find<UIDropDownList>( "working_dir_combo" );
286 UIWidget* otherDirContainer = window->find<UIWidget>( "other_dir_container" );
287 UITextInput* otherDirInput = window->find<UITextInput>( "other_dir_input" );
288 UIPushButton* otherDirBrowse = window->find<UIPushButton>( "other_dir_browse" );
289 UIPushButton* ok = window->find<UIPushButton>( "ok" );
290 UIPushButton* cancel = window->find<UIPushButton>( "cancel" );
291
292 const std::vector<EE::String> options = {
293 mApp->i18n( "project_root_directory", "Project Root Directory" ),
294 mApp->i18n( "current_file_directory", "Current File Directory" ),
295 mApp->i18n( "user_home_directory", "User Home" ),
296 mApp->i18n( "other_directory", "Other" ) };
297
298 workingDirCombo->getListBox()->addListBoxItems( options );
299 workingDirCombo->getListBox()->setSelected(
300 static_cast<Uint32>( mApp->getConfig().term.workingDir ) );
301 otherDirInput->setText( mApp->getConfig().term.workingDirOther );
302
303 const auto updateOtherVisible = [otherDirContainer]( TerminalWorkingDir::Mode mode ) {
304 otherDirContainer->setVisible( mode == TerminalWorkingDir::Other );
305 };
306
307 updateOtherVisible( mApp->getConfig().term.workingDir );
308
309 workingDirCombo->on( Event::OnValueChange, [updateOtherVisible, workingDirCombo]( auto ) {
310 updateOtherVisible( static_cast<TerminalWorkingDir::Mode>(
311 workingDirCombo->getListBox()->getItemSelectedIndex() ) );
312 } );
313
314 otherDirBrowse->onClick( [this, otherDirInput]( auto ) {
315 UIFileDialog* dialog = mApp->openFileDialog( false );
316 dialog->setTitle( mApp->i18n( "select_working_directory", "Select Working Directory" ) );
317 dialog->addFilePattern( "*", true );
318 dialog->setAllowFolderSelect( true );
319 dialog->on( Event::OpenFile, [otherDirInput, dialog]( const Event* ) {
320 otherDirInput->setText( dialog->getFullPath() );
321 } );
322 } );
323

Callers 1

Calls 15

loadLayoutFromStringMethod · 0.80
addListBoxItemsMethod · 0.80
getConfigMethod · 0.80
openFileDialogMethod · 0.80
addFilePatternMethod · 0.80
setAllowFolderSelectMethod · 0.80
getFullPathMethod · 0.80
toUtf8Method · 0.80
closeWindowMethod · 0.80
asKeyEventMethod · 0.80
centerMethod · 0.80
getUISceneNodeMethod · 0.45

Tested by

no test coverage detected