mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Add show all groups button to groups dialog
This commit is contained in:
parent
55e9dc6a38
commit
ed18c9afe7
38
groups.cc
38
groups.cc
|
@ -26,6 +26,21 @@ Groups::Groups( QWidget * parent,
|
|||
ui.searchLine->applyTo( ui.dictionaries );
|
||||
addAction( ui.searchLine->getFocusAction() );
|
||||
|
||||
groupsListMenu = new QMenu( tr( "Group tabs" ), ui.groups );
|
||||
|
||||
groupsListButton = new QToolButton( ui.groups );
|
||||
groupsListButton->setAutoRaise( true );
|
||||
groupsListButton->setIcon( QIcon( ":/icons/windows-list.png" ) );
|
||||
groupsListButton->setMenu( groupsListMenu );
|
||||
groupsListButton->setToolTip( tr( "Open groups list" ) );
|
||||
groupsListButton->setPopupMode( QToolButton::InstantPopup );
|
||||
ui.groups->setCornerWidget( groupsListButton );
|
||||
groupsListButton->setFocusPolicy( Qt::ClickFocus );
|
||||
|
||||
connect(groupsListMenu, SIGNAL( aboutToShow() ), this, SLOT( fillGroupsMenu() ) );
|
||||
connect(groupsListMenu, SIGNAL( triggered( QAction * ) ),
|
||||
this, SLOT( switchToGroup( QAction * ) ) );
|
||||
|
||||
// Populate groups' widget
|
||||
|
||||
ui.groups->populate( groups, dicts, ui.dictionaries->getCurrentDictionaries() );
|
||||
|
@ -205,4 +220,27 @@ void Groups::showDictInfo( QPoint const & pos )
|
|||
}
|
||||
}
|
||||
|
||||
void Groups::fillGroupsMenu()
|
||||
{
|
||||
groupsListMenu->clear();
|
||||
for( int i = 0; i < ui.groups->count(); i++ )
|
||||
{
|
||||
QAction * act = groupsListMenu->addAction( ui.groups->tabText( i ) );
|
||||
act->setData( i );
|
||||
if (ui.groups->currentIndex() == i)
|
||||
{
|
||||
QFont f( act->font() );
|
||||
f.setBold( true );
|
||||
act->setFont( f );
|
||||
}
|
||||
}
|
||||
|
||||
if( groupsListMenu->actions().size() > 1 )
|
||||
groupsListMenu->setActiveAction( groupsListMenu->actions().at( ui.groups->currentIndex() ) );
|
||||
}
|
||||
|
||||
void Groups::switchToGroup( QAction * act )
|
||||
{
|
||||
int idx = act->data().toInt();
|
||||
ui.groups->setCurrentIndex(idx);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "dictionary.hh"
|
||||
#include "groups_widgets.hh"
|
||||
#include <QToolButton>
|
||||
#include <QMenu>
|
||||
|
||||
class Groups: public QWidget
|
||||
{
|
||||
|
@ -35,6 +36,9 @@ private:
|
|||
std::vector< sptr< Dictionary::Class > > const & dicts;
|
||||
Config::Groups groups;
|
||||
|
||||
QToolButton * groupsListButton;
|
||||
QMenu * groupsListMenu;
|
||||
|
||||
// Reacts to the event that the number of groups is possibly changed
|
||||
void countChanged();
|
||||
|
||||
|
@ -47,6 +51,8 @@ private slots:
|
|||
void removeFromGroup();
|
||||
void addAutoGroups();
|
||||
void showDictInfo( const QPoint & pos );
|
||||
void fillGroupsMenu();
|
||||
void switchToGroup( QAction * act );
|
||||
|
||||
signals:
|
||||
void showDictionaryInfo( QString const & id );
|
||||
|
|
Loading…
Reference in a new issue