opt: group widget remove all tabs (#892)

* opt: remove all group widget tabs

* 🎨 apply clang-format changes

* opt: does not elide text on tab name

* 🎨 apply clang-format changes

---------

Co-authored-by: xiaoyifang <xiaoyifang@users.noreply.github.com>
This commit is contained in:
xiaoyifang 2023-06-22 17:17:57 +08:00 committed by GitHub
parent 04a58d6418
commit ef594117c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 9 deletions

View file

@ -126,7 +126,7 @@
<enum>QTabWidget::North</enum> <enum>QTabWidget::North</enum>
</property> </property>
<property name="elideMode"> <property name="elideMode">
<enum>Qt::ElideRight</enum> <enum>Qt::ElideNone</enum>
</property> </property>
<widget class="QWidget" name="tab_4"> <widget class="QWidget" name="tab_4">
<attribute name="title"> <attribute name="title">

View file

@ -551,6 +551,9 @@ DictGroupsWidget::DictGroupsWidget( QWidget * parent ):
setMovable( true ); setMovable( true );
setContextMenuPolicy( Qt::CustomContextMenu ); setContextMenuPolicy( Qt::CustomContextMenu );
connect( this, &QWidget::customContextMenuRequested, this, &DictGroupsWidget::contextMenu ); connect( this, &QWidget::customContextMenuRequested, this, &DictGroupsWidget::contextMenu );
setElideMode( Qt::ElideNone );
setUsesScrollButtons( true );
} }
namespace { namespace {
@ -575,8 +578,7 @@ void DictGroupsWidget::populate( Config::Groups const & groups,
vector< sptr< Dictionary::Class > > const & allDicts_, vector< sptr< Dictionary::Class > > const & allDicts_,
vector< sptr< Dictionary::Class > > const & activeDicts_ ) vector< sptr< Dictionary::Class > > const & activeDicts_ )
{ {
while( count() ) removeAllGroups();
removeCurrentGroup();
allDicts = &allDicts_; allDicts = &allDicts_;
activeDicts = &activeDicts_; activeDicts = &activeDicts_;
@ -597,8 +599,6 @@ void DictGroupsWidget::populate( Config::Groups const & groups,
nextId = groups.nextId; nextId = groups.nextId;
setCurrentIndex( 0 ); setCurrentIndex( 0 );
setUsesScrollButtons( count() > 3 );
} }
/// Creates groups from what is currently set up /// Creates groups from what is currently set up
@ -666,8 +666,6 @@ void DictGroupsWidget::addNewGroup( QString const & name )
QString toolTipStr = "\"" + tabText( idx ) + "\"\n" + tr( "Dictionaries: " ) QString toolTipStr = "\"" + tabText( idx ) + "\"\n" + tr( "Dictionaries: " )
+ QString::number( getCurrentModel()->getCurrentDictionaries().size() ); + QString::number( getCurrentModel()->getCurrentDictionaries().size() );
setTabToolTip( idx, toolTipStr ); setTabToolTip( idx, toolTipStr );
setUsesScrollButtons( count() > 3 );
} }
int DictGroupsWidget::addUniqueGroup( const QString & name ) int DictGroupsWidget::addUniqueGroup( const QString & name )
@ -950,8 +948,6 @@ void DictGroupsWidget::removeCurrentGroup()
removeTab( current ); removeTab( current );
delete w; delete w;
} }
setUsesScrollButtons( count() > 3 );
} }
void DictGroupsWidget::removeAllGroups() void DictGroupsWidget::removeAllGroups()