Save side panel tabs order.

This commit is contained in:
Martín Lucas Golini
2025-01-01 16:18:26 -03:00
parent e0eb9d9096
commit cf84fc7cff
16 changed files with 131 additions and 41 deletions

View File

@@ -96,10 +96,18 @@ GitPlugin::~GitPlugin() {
if ( getUISceneNode() )
getUISceneNode()->removeActionsByTag( GIT_STATUS_UPDATE_TAG );
{ Lock l( mGitBranchMutex ); }
{ Lock l( mGitStatusMutex ); }
{ Lock l( mRepoMutex ); }
{ Lock l( mReposMutex ); }
{
Lock l( mGitBranchMutex );
}
{
Lock l( mGitStatusMutex );
}
{
Lock l( mRepoMutex );
}
{
Lock l( mReposMutex );
}
// TODO: Add a signal for these waits
while ( mRunningUpdateStatus )
@@ -293,6 +301,9 @@ void GitPlugin::updateUINow( bool force ) {
if ( !mGit || !getUISceneNode() )
return;
if ( !mProjectPath.empty() )
getUISceneNode()->runOnMainThread( [this] { buildSidePanelTab(); } );
updateStatus( force );
updateBranches();
}
@@ -339,9 +350,6 @@ void GitPlugin::updateStatusBarSync() {
mStatusButton->setIcon( iconDrawable( "source-control", 10 ) );
mStatusButton->reloadStyle( true, true );
mStatusButton->getTextBox()->setUsingCustomStyling( true );
auto childCount = mStatusBar->getChildCount();
if ( childCount > 2 )
mStatusButton->toPosition( mStatusBar->getChildCount() - 2 );
mStatusButton->on( Event::MouseClick, [this]( const Event* event ) {
if ( nullptr == mTab )
@@ -398,6 +406,12 @@ void GitPlugin::updateStatusBarSync() {
void GitPlugin::updateStatus( bool force ) {
if ( !mGit || !mGitFound || mRunningUpdateStatus )
return;
if ( !mGit || mGit->getGitFolder().empty() ) {
getUISceneNode()->runOnMainThread( [this] { updateStatusBarSync(); } );
return;
}
mRunningUpdateStatus++;
mThreadPool->run(
[this, force] {
@@ -1311,6 +1325,11 @@ void GitPlugin::updateBranches( bool force ) {
if ( !mGit || !mGitFound || ( mRunningUpdateBranches && !force ) )
return;
if ( !mGit || mGit->getGitFolder().empty() ) {
getUISceneNode()->runOnMainThread( [this] { updateBranchesUI( nullptr ); } );
return;
}
mRunningUpdateBranches++;
mThreadPool->run(
[this] {
@@ -1401,7 +1420,7 @@ void GitPlugin::buildSidePanelTab() {
UIIcon* icon = findIcon( "source-control" );
mTab = mSidePanel->add( i18n( "source_control", "Source Control" ), mTabContents,
icon ? icon->getSize( PixelDensity::dpToPx( 12 ) ) : nullptr );
mTab->setId( "source_control" );
mTab->setId( "source_control_tab" );
mTab->setTextAsFallback( true );
return;
}
@@ -1471,7 +1490,7 @@ void GitPlugin::buildSidePanelTab() {
mTabContents = getUISceneNode()->loadLayoutFromString( String::format( STYLE, color, color ) );
mTab = mSidePanel->add( i18n( "source_control", "Source Control" ), mTabContents,
icon ? icon->getSize( PixelDensity::dpToPx( 12 ) ) : nullptr );
mTab->setId( "source_control" );
mTab->setId( "source_control_tab" );
mTab->setTextAsFallback( true );
mTabContents->bind( "git_panel_switcher", mPanelSwicher );

View File

@@ -37,7 +37,7 @@ static constexpr const char* GIT_STASH_TOOLTIP_CLASS = "git-stash-tooltip";
class GitPlugin : public PluginBase {
public:
static PluginDefinition Definition() {
return { "git", "Git", "Git integration", GitPlugin::New, { 0, 1, 1 }, GitPlugin::NewSync };
return { "git", "Git", "Git integration", GitPlugin::New, { 0, 1, 2 }, GitPlugin::NewSync };
}
static Plugin* New( PluginManager* pluginManager );