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

Method createDocDirtyAlert

src/tools/ecode/ecode.cpp:2394–2457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2392}
2393
2394void App::createDocDirtyAlert( UICodeEditor* editor, bool showEnableAutoReload ) {
2395 UILinearLayout* docAlert = editor->findByClass<UILinearLayout>( "doc_alert" );
2396
2397 if ( docAlert )
2398 return;
2399
2400 const auto msg = R"xml(
2401 <hbox class="doc_alert" layout_width="wrap_content" layout_height="wrap_content" layout_gravity="top|right" gravity-owner="true">
2402 <TextView id="doc_alert_text" layout_width="wrap_content" layout_height="wrap_content" margin-right="24dp"
2403 text='@string(reload_current_file, "The file on the disk is more recent that the current buffer.&#xA;Do you want to reload it?")'
2404 />
2405 <PushButton id="file_autoreload" layout_width="wrap_content" layout_height="18dp" text='@string("enable_autoreload", "Enable Auto-Reload")' margin-right="4dp"
2406 tooltip='@string(tooltip_autoreload_file, "Will never again warn about on disk changes but always reload unless there are local changes.")' />
2407 <PushButton id="file_reload" layout_width="wrap_content" layout_height="18dp" text='@string("reload", "Reload")' margin-right="4dp"
2408 tooltip='@string(tooltip_reload_file, "Reload the file from disk. Unsaved changes will be lost.")' />
2409 <PushButton id="file_overwrite" layout_width="wrap_content" layout_height="18dp" text='@string("overwrite", "Overwrite")' margin-right="4dp"
2410 tooltip='@string(tooltip_write_local_changes, "Writes the local changes on disk, overwriting the disk changes")' />
2411 <PushButton id="file_ignore" layout_width="wrap_content" layout_height="18dp" text='@string("ignore", "Ignore")'
2412 tooltip='@string(tooltip_ignore_file_changes, "Ignores the changes on disk without any action.")' />
2413 </hbox>
2414 )xml";
2415 docAlert = mUISceneNode->loadLayoutFromString( msg, editor )->asType<UILinearLayout>();
2416
2417 editor->enableReportSizeChangeToChildren();
2418
2419 docAlert->find( "file_autoreload" )
2420 ->setVisible( showEnableAutoReload ? !editor->getDocument().isDirty() : false )
2421 ->onClick( [editor, docAlert, this]( const MouseEvent* ) {
2422 editor->getDocument().reload();
2423 editor->disableReportSizeChangeToChildren();
2424 docAlert->close();
2425 editor->setFocus();
2426 mConfig.editor.autoReloadOnDiskChange = true;
2427 mSettings->updateGlobalDocumentSettingsMenu();
2428 } );
2429
2430 docAlert->find( "file_reload" )->onClick( [editor, docAlert]( const MouseEvent* ) {
2431 editor->getDocument().reload();
2432 editor->disableReportSizeChangeToChildren();
2433 docAlert->close();
2434 editor->setFocus();
2435 } );
2436
2437 docAlert->find( "file_overwrite" )->onClick( [editor, docAlert]( const MouseEvent* ) {
2438 editor->getDocument().save();
2439 editor->disableReportSizeChangeToChildren();
2440 docAlert->close();
2441 editor->setFocus();
2442 } );
2443
2444 docAlert->find( "file_ignore" )->onClick( [docAlert, editor]( const MouseEvent* ) {
2445 editor->disableReportSizeChangeToChildren();
2446 docAlert->close();
2447 editor->setFocus();
2448 } );
2449
2450 docAlert->runOnMainThread(
2451 [docAlert, editor] {

Callers 1

loadDocumentsMethod · 0.80

Calls 15

SecondsFunction · 0.85
loadLayoutFromStringMethod · 0.80
getDocumentMethod · 0.80
runOnMainThreadMethod · 0.80
closeMethod · 0.65
onClickMethod · 0.45
setVisibleMethod · 0.45
findMethod · 0.45
isDirtyMethod · 0.45

Tested by

no test coverage detected