mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Add Alt+PgDown/PgUp shortcuts to select next/previous group
This commit is contained in:
parent
8cc13b98b9
commit
58484cf70c
|
@ -6,7 +6,9 @@
|
|||
#include <QShortcutEvent>
|
||||
|
||||
GroupComboBox::GroupComboBox( QWidget * parent ): QComboBox( parent ),
|
||||
popupAction( this )
|
||||
popupAction( this ),
|
||||
selectNextAction( this ),
|
||||
selectPreviousAction( this )
|
||||
{
|
||||
setSizeAdjustPolicy( AdjustToContents );
|
||||
setToolTip( tr( "Choose a Group (Alt+G)" ) );
|
||||
|
@ -16,6 +18,16 @@ GroupComboBox::GroupComboBox( QWidget * parent ): QComboBox( parent ),
|
|||
this, SLOT( popupGroups() ) );
|
||||
|
||||
addAction( &popupAction );
|
||||
|
||||
selectNextAction.setShortcut( QKeySequence( "Alt+PgDown" ) );
|
||||
connect( &selectNextAction, SIGNAL( triggered() ),
|
||||
this, SLOT( selectNextGroup() ) );
|
||||
addAction( &selectNextAction );
|
||||
|
||||
selectPreviousAction.setShortcut( QKeySequence( "Alt+PgUp" ) );
|
||||
connect( &selectPreviousAction, SIGNAL( triggered() ),
|
||||
this, SLOT( selectPreviousGroup() ) );
|
||||
addAction( &selectPreviousAction );
|
||||
}
|
||||
|
||||
void GroupComboBox::fill( Instances::Groups const & groups )
|
||||
|
@ -97,3 +109,23 @@ void GroupComboBox::popupGroups()
|
|||
{
|
||||
showPopup();
|
||||
}
|
||||
|
||||
void GroupComboBox::selectNextGroup()
|
||||
{
|
||||
if( count() <= 1 )
|
||||
return;
|
||||
int n = currentIndex() + 1;
|
||||
if( n >= count() )
|
||||
n = 0;
|
||||
setCurrentIndex( n );
|
||||
}
|
||||
|
||||
void GroupComboBox::selectPreviousGroup()
|
||||
{
|
||||
if( count() <= 1 )
|
||||
return;
|
||||
int n = currentIndex() - 1;
|
||||
if( n < 0 )
|
||||
n = count() - 1;
|
||||
setCurrentIndex( n );
|
||||
}
|
||||
|
|
|
@ -36,10 +36,13 @@ protected:
|
|||
private slots:
|
||||
|
||||
void popupGroups();
|
||||
void selectNextGroup();
|
||||
void selectPreviousGroup();
|
||||
|
||||
private:
|
||||
|
||||
QAction popupAction;
|
||||
QAction selectNextAction, selectPreviousAction;
|
||||
QMap< int, int > shortcuts;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue