diff options
author | Mavridis Philippe <[email protected]> | 2023-10-04 22:56:39 +0300 |
---|---|---|
committer | Mavridis Philippe <[email protected]> | 2023-11-02 10:43:11 +0200 |
commit | c28a87c7d2e5c170a84bd8d1e7feece3ef9521ec (patch) | |
tree | c4f0029c8ac4faa9f78fa146866fca0d51bdac95 /tdeui/ktabbar.cpp | |
parent | 9755ecd967d605a7f2b6f1710389ed5a5de60ae6 (diff) | |
download | tdelibs-c28a87c7d2e5c170a84bd8d1e7feece3ef9521ec.tar.gz tdelibs-c28a87c7d2e5c170a84bd8d1e7feece3ef9521ec.zip |
KTabBar: add way to revert tab color to default
This commit adds a resetTabColor(...) method to TQTabBar and TQTabWidget which allows the color of the appropriate tab to be reset to the default as specified by the desktop color scheme.
It also changes how invalid color values are handled; before, an invalid value would be used as a valid color, resulting in 0,0,0 (black). Seeing that an invalid color is returned by KColorDialog when the default color checkbox is checked, it makes more sense to ignore invalid colors, using the appropriate color from the color scheme instead.
Signed-off-by: Mavridis Philippe <[email protected]>
Diffstat (limited to 'tdeui/ktabbar.cpp')
-rw-r--r-- | tdeui/ktabbar.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tdeui/ktabbar.cpp b/tdeui/ktabbar.cpp index 29479c0e9..2dd2cc9a3 100644 --- a/tdeui/ktabbar.cpp +++ b/tdeui/ktabbar.cpp @@ -298,9 +298,19 @@ void KTabBar::setTabColor( int id, const TQColor& color ) } } +void KTabBar::resetTabColor( int id ) +{ + TQTab *t = tab(id); + if (t) { + if (mTabColors.contains(id)) + mTabColors.remove(id); + repaint(t->rect(), false); + } +} + const TQColor &KTabBar::tabColor( int id ) const { - if ( mTabColors.contains( id ) ) + if ( mTabColors.contains(id) && mTabColors[id].isValid() ) return mTabColors[id]; return colorGroup().foreground(); @@ -359,7 +369,7 @@ void KTabBar::paintLabel( TQPainter *p, const TQRect& br, flags |= TQStyle::Style_HasFocus; TQColorGroup cg( colorGroup() ); - if ( mTabColors.contains( t->identifier() ) ) + if ( mTabColors.contains(t->identifier()) && mTabColors[t->identifier()].isValid() ) cg.setColor( TQColorGroup::Foreground, mTabColors[t->identifier()] ); style().drawControl( TQStyle::CE_TabBarLabel, p, this, r, |