mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-30 17:24:08 +00:00
fix: remove some tabText() in groupWidget when rename group (#1897)
* fix: remove some tabText() in groupWidget rename group * Update src/ui/groups_widgets.cc Co-authored-by: shenleban tongying <shenlebantongying@gmail.com> --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: shenleban tongying <shenlebantongying@gmail.com>
This commit is contained in:
parent
8be7b65f29
commit
285a0d8882
|
@ -29,7 +29,8 @@ DictGroupWidget::DictGroupWidget( QWidget * parent,
|
||||||
vector< sptr< Dictionary::Class > > const & dicts,
|
vector< sptr< Dictionary::Class > > const & dicts,
|
||||||
Config::Group const & group ):
|
Config::Group const & group ):
|
||||||
QWidget( parent ),
|
QWidget( parent ),
|
||||||
groupId( group.id )
|
groupId( group.id ),
|
||||||
|
groupName( group.name )
|
||||||
{
|
{
|
||||||
ui.setupUi( this );
|
ui.setupUi( this );
|
||||||
ui.dictionaries->populate( Instances::Group( group, dicts, Config::Group() ).dictionaries, dicts );
|
ui.dictionaries->populate( Instances::Group( group, dicts, Config::Group() ).dictionaries, dicts );
|
||||||
|
@ -139,6 +140,7 @@ Config::Group DictGroupWidget::makeGroup() const
|
||||||
|
|
||||||
g.favoritesFolder = ui.favoritesFolder->text().replace( '\\', '/' );
|
g.favoritesFolder = ui.favoritesFolder->text().replace( '\\', '/' );
|
||||||
|
|
||||||
|
g.name = groupName;
|
||||||
return g.makeConfigGroup();
|
return g.makeConfigGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,8 +560,7 @@ void DictGroupsWidget::populate( Config::Groups const & groups,
|
||||||
connect( gr, &DictGroupWidget::showDictionaryInfo, this, &DictGroupsWidget::showDictionaryInfo );
|
connect( gr, &DictGroupWidget::showDictionaryInfo, this, &DictGroupsWidget::showDictionaryInfo );
|
||||||
connect( gr->getModel(), &DictListModel::contentChanged, this, &DictGroupsWidget::tabDataChanged );
|
connect( gr->getModel(), &DictListModel::contentChanged, this, &DictGroupsWidget::tabDataChanged );
|
||||||
|
|
||||||
QString toolTipStr =
|
QString toolTipStr = tr( "Dictionaries: " ) + QString::number( getDictionaryCountAt( x ) );
|
||||||
"\"" + tabText( x ) + "\"\n" + tr( "Dictionaries: " ) + QString::number( getDictionaryCountAt( x ) );
|
|
||||||
setTabToolTip( x, toolTipStr );
|
setTabToolTip( x, toolTipStr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,7 +578,6 @@ Config::Groups DictGroupsWidget::makeGroups() const
|
||||||
|
|
||||||
for ( int x = 0; x < count(); ++x ) {
|
for ( int x = 0; x < count(); ++x ) {
|
||||||
result.push_back( dynamic_cast< DictGroupWidget & >( *widget( x ) ).makeGroup() );
|
result.push_back( dynamic_cast< DictGroupWidget & >( *widget( x ) ).makeGroup() );
|
||||||
result.back().name = Utils::unescapeAmps( tabText( x ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -648,6 +648,7 @@ int DictGroupsWidget::addNewGroup( QString const & name )
|
||||||
Config::Group newGroup;
|
Config::Group newGroup;
|
||||||
|
|
||||||
newGroup.id = nextId++;
|
newGroup.id = nextId++;
|
||||||
|
newGroup.name = name;
|
||||||
|
|
||||||
const auto gr = new DictGroupWidget( this, *allDicts, newGroup );
|
const auto gr = new DictGroupWidget( this, *allDicts, newGroup );
|
||||||
const int idx = insertTab( currentIndex() + 1, gr, Utils::escapeAmps( name ) );
|
const int idx = insertTab( currentIndex() + 1, gr, Utils::escapeAmps( name ) );
|
||||||
|
@ -655,8 +656,7 @@ int DictGroupsWidget::addNewGroup( QString const & name )
|
||||||
|
|
||||||
connect( gr->getModel(), &DictListModel::contentChanged, this, &DictGroupsWidget::tabDataChanged );
|
connect( gr->getModel(), &DictListModel::contentChanged, this, &DictGroupsWidget::tabDataChanged );
|
||||||
|
|
||||||
const QString toolTipStr =
|
const QString toolTipStr = tr( "Dictionaries: " ) + QString::number( getDictionaryCountAt( idx ) );
|
||||||
"\"" + tabText( idx ) + "\"\n" + tr( "Dictionaries: " ) + QString::number( getDictionaryCountAt( idx ) );
|
|
||||||
setTabToolTip( idx, toolTipStr );
|
setTabToolTip( idx, toolTipStr );
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
@ -910,13 +910,13 @@ void DictGroupsWidget::groupsByMetadata()
|
||||||
addGroupBasedOnMap( groupToDicts );
|
addGroupBasedOnMap( groupToDicts );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString DictGroupsWidget::getCurrentGroupName() const
|
QString DictGroupsWidget::getCurrentGroupName() const
|
||||||
{
|
{
|
||||||
const int current = currentIndex();
|
const int current = currentIndex();
|
||||||
|
|
||||||
if ( current >= 0 ) {
|
if ( current >= 0 ) {
|
||||||
return Utils::unescapeAmps( tabText( current ) );
|
auto * w = qobject_cast< DictGroupWidget * >( widget( current ) );
|
||||||
|
return w->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
@ -927,6 +927,8 @@ void DictGroupsWidget::renameCurrentGroup( QString const & name )
|
||||||
const int current = currentIndex();
|
const int current = currentIndex();
|
||||||
|
|
||||||
if ( current >= 0 ) {
|
if ( current >= 0 ) {
|
||||||
|
auto * w = dynamic_cast< DictGroupWidget * >( widget( current ) );
|
||||||
|
w->setName( name );
|
||||||
setTabText( current, Utils::escapeAmps( name ) );
|
setTabText( current, Utils::escapeAmps( name ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -971,8 +973,7 @@ void DictGroupsWidget::combineGroups( int source, int target )
|
||||||
|
|
||||||
connect( model, &DictListModel::contentChanged, this, &DictGroupsWidget::tabDataChanged );
|
connect( model, &DictListModel::contentChanged, this, &DictGroupsWidget::tabDataChanged );
|
||||||
|
|
||||||
const QString toolTipStr = "\"" + tabText( target ) + "\"\n" + tr( "Dictionaries: " )
|
const QString toolTipStr = tr( "Dictionaries: " ) + QString::number( model->getCurrentDictionaries().size() );
|
||||||
+ QString::number( model->getCurrentDictionaries().size() );
|
|
||||||
setTabToolTip( target, toolTipStr );
|
setTabToolTip( target, toolTipStr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1124,8 +1125,8 @@ void DictGroupsWidget::contextMenu( QPoint const & pos )
|
||||||
|
|
||||||
void DictGroupsWidget::tabDataChanged()
|
void DictGroupsWidget::tabDataChanged()
|
||||||
{
|
{
|
||||||
const QString toolTipStr = "\"" + tabText( currentIndex() ) + "\"\n" + tr( "Dictionaries: " )
|
const QString toolTipStr =
|
||||||
+ QString::number( getCurrentModel()->getCurrentDictionaries().size() );
|
tr( "Dictionaries: " ) + QString::number( getCurrentModel()->getCurrentDictionaries().size() );
|
||||||
setTabToolTip( currentIndex(), toolTipStr );
|
setTabToolTip( currentIndex(), toolTipStr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,9 +121,6 @@ class DictGroupWidget: public QWidget
|
||||||
public:
|
public:
|
||||||
DictGroupWidget( QWidget * parent, std::vector< sptr< Dictionary::Class > > const &, Config::Group const & );
|
DictGroupWidget( QWidget * parent, std::vector< sptr< Dictionary::Class > > const &, Config::Group const & );
|
||||||
|
|
||||||
/// Makes the group's configuration out of the data currently held.
|
|
||||||
/// Since the group's name is not part of the widget by design right now
|
|
||||||
/// (it is known by the containing tab widget only), it is returned as empty.
|
|
||||||
Config::Group makeGroup() const;
|
Config::Group makeGroup() const;
|
||||||
|
|
||||||
DictListModel * getModel() const
|
DictListModel * getModel() const
|
||||||
|
@ -136,6 +133,16 @@ public:
|
||||||
return ui.dictionaries->selectionModel();
|
return ui.dictionaries->selectionModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString name()
|
||||||
|
{
|
||||||
|
return groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setName( const QString & name )
|
||||||
|
{
|
||||||
|
groupName = name;
|
||||||
|
}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void groupIconActivated( int );
|
void groupIconActivated( int );
|
||||||
|
@ -145,6 +152,7 @@ private slots:
|
||||||
private:
|
private:
|
||||||
Ui::DictGroupWidget ui;
|
Ui::DictGroupWidget ui;
|
||||||
unsigned groupId;
|
unsigned groupId;
|
||||||
|
QString groupName;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void showDictionaryInfo( QString const & id );
|
void showDictionaryInfo( QString const & id );
|
||||||
|
|
Loading…
Reference in a new issue