Improved UICheckBox. Fixed a bug and simplified UIPluginManager.

This commit is contained in:
Martín Lucas Golini
2024-01-28 02:15:58 -03:00
parent 2ae84f7c9d
commit 1399d23770
9 changed files with 89 additions and 47 deletions

View File

@@ -608,7 +608,7 @@ void GitPlugin::push() {
"Are you sure you want to push the local changes to the remote server?" ) );
msgBox->on( Event::OnConfirm, [this]( auto ) {
runAsync( [this]() { return mGit->push( repoSelected() ); }, true, true, true );
runAsync( [this]() { return mGit->push( repoSelected() ); }, true, true, true, true );
} );
msgBox->setCloseShortcut( { KEY_ESCAPE, KEYMOD_NONE } );
msgBox->setTitle( i18n( "git_confirm", "Confirm" ) );
@@ -1312,23 +1312,26 @@ void GitPlugin::openFileStatusMenu( const Git::DiffFile& file ) {
}
void GitPlugin::runAsync( std::function<Git::Result()> fn, bool _updateStatus, bool _updateBranches,
bool displaySuccessMsg ) {
bool displaySuccessMsg, bool updateBranchesOnError ) {
if ( !mGit )
return;
mLoader->setVisible( true );
mThreadPool->run( [this, fn, _updateStatus, _updateBranches, displaySuccessMsg] {
auto res = fn();
mLoader->runOnMainThread( [this] { mLoader->setVisible( false ); } );
if ( res.fail() || displaySuccessMsg ) {
showMessage( LSPMessageType::Warning, res.result );
return;
}
if ( _updateBranches )
updateBranches( true );
mThreadPool->run(
[this, fn, _updateStatus, _updateBranches, displaySuccessMsg, updateBranchesOnError] {
auto res = fn();
mLoader->runOnMainThread( [this] { mLoader->setVisible( false ); } );
if ( res.fail() || displaySuccessMsg ) {
showMessage( LSPMessageType::Warning, res.result );
if ( _updateBranches && updateBranchesOnError )
updateBranches();
return;
}
if ( _updateBranches )
updateBranches();
if ( _updateStatus )
updateStatus( true );
} );
if ( _updateStatus )
updateStatus( true );
} );
}
void GitPlugin::addMenuItem( UIMenu* menu, const std::string& txtKey, const std::string& txtVal,

View File

@@ -189,7 +189,7 @@ class GitPlugin : public PluginBase {
void openFileStatusMenu( const Git::DiffFile& file );
void runAsync( std::function<Git::Result()> fn, bool updateStatus, bool updateBranches,
bool displaySuccessMsg = false );
bool displaySuccessMsg = false, bool updateBranchesOnError = false );
void addMenuItem( UIMenu* menu, const std::string& txtKey, const std::string& txtVal,
const std::string& icon = "",