setTabTextColor() no longer working

Report any problems with CopperSpice
Post Reply
seasoned_geek
Posts: 257
Joined: Thu Jun 11 2020 12:18 pm

setTabTextColor() no longer working

Post by seasoned_geek »

All,

Prior to merging from top into my RPM branch this code always worked.

Code: Select all

void MainWindow::updateDirtyIndicator( FileDetails dtls )
{
    qDebug() << "updatedirtyIndicator called\n";

    for ( int jjj=0; jjj < m_tabWidget->count(); ++jjj )
    {
        EdtEditWidget *ptr = static_cast<EdtEditWidget *>( m_tabWidget->widget( jjj ) );

        if ( ptr  &&  dtls.sameFile( ptr->editor()->fileDetails() ) )
        {
            QPalette palette;

            if ( dtls.isDirty() )
            {
                qDebug() << "setting tab text red\n";
                m_tabWidget->tabBar()->setTabTextColor( jjj, Qt::red );
            }
            else
            {
                m_tabWidget->tabBar()->setTabTextColor( jjj, palette.color( QPalette::Foreground ) );
            }
        }
    }
}
After the merge I can see the debug statements print out but the text in the tab does not change to red to indicate an editor buffer that needs saving.

Anybody else have CopperSpice from that point in time having the same issue?

It's like someone "optimized" and setting the text color for the tab no longer redraws the text. I don't see anything in the doc about this change.
https://www.copperspice.com/docs/cs_api/class_qtabbar.html#aa29d189c00bbf535b4a7087beef9caf9

Do I need to force this now? Get a copy of the text, set the color, then set the text?
ansel
Posts: 153
Joined: Fri Apr 10 2015 8:23 am

Re: setTabTextColor() no longer working

Post by ansel »

I tested your example code and the setTabTextColor() call did change the color of the tab text as expected. Since your code has dependencies on other parts of your program, I used our journal entry 19 and replaced the connect() at the end of the MainWindow constructor with the following:

Code: Select all

   connect(pb_1, &QPushButton::clicked, this, [tabWidget]
   {
      static bool colorState = true;

      for(int i = 0; i < tabWidget->count(); ++i) {
         if(colorState) {
            tabWidget->tabBar()->setTabTextColor(i, Qt::red );
         } else {
            tabWidget->tabBar()->setTabTextColor(i, Qt::blue );
         }

         colorState = !colorState;
      }     
   });
This code successfully changes the color of the tab text every time the pushbutton is clicked. Do you have a minimal sample which we can use to reproduce the behavior you are seeing?
Ansel Sermersheim
CopperSpice Cofounder
seasoned_geek
Posts: 257
Joined: Thu Jun 11 2020 12:18 pm

Re: setTabTextColor() no longer working

Post by seasoned_geek »

I hacked changes to Example2 in CsScintilla because that is the "smallest" it gets.

https://sourceforge.net/projects/csscintilla/

Seemed to be working. I really hope this isn't a deep seated bug/change in Scintilla again. I really regret merging the tip of both Scintilla and CopperSpice into my code after New Years. This has been beyond brutal.

Sorry to bother. I do now have more info for the other bug. Will append info there.
seasoned_geek
Posts: 257
Joined: Thu Jun 11 2020 12:18 pm

Re: setTabTextColor() no longer working

Post by seasoned_geek »

Just to follow up there was a Scintilla tweak.

For whatever reason https://www.scintilla.org/ScintillaDoc.html#SCN_SAVEPOINTREACHED

The SCN_SAVEPOINTLEFT seems to now cause a TRUE for SAVEPOINTREACHED immediately followed by a FALSE the the screen logic optimizes the change away. I have worked around for now.
Post Reply