mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +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>
|
#include <QShortcutEvent>
|
||||||
|
|
||||||
GroupComboBox::GroupComboBox( QWidget * parent ): QComboBox( parent ),
|
GroupComboBox::GroupComboBox( QWidget * parent ): QComboBox( parent ),
|
||||||
popupAction( this )
|
popupAction( this ),
|
||||||
|
selectNextAction( this ),
|
||||||
|
selectPreviousAction( this )
|
||||||
{
|
{
|
||||||
setSizeAdjustPolicy( AdjustToContents );
|
setSizeAdjustPolicy( AdjustToContents );
|
||||||
setToolTip( tr( "Choose a Group (Alt+G)" ) );
|
setToolTip( tr( "Choose a Group (Alt+G)" ) );
|
||||||
|
@ -16,6 +18,16 @@ GroupComboBox::GroupComboBox( QWidget * parent ): QComboBox( parent ),
|
||||||
this, SLOT( popupGroups() ) );
|
this, SLOT( popupGroups() ) );
|
||||||
|
|
||||||
addAction( &popupAction );
|
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 )
|
void GroupComboBox::fill( Instances::Groups const & groups )
|
||||||
|
@ -97,3 +109,23 @@ void GroupComboBox::popupGroups()
|
||||||
{
|
{
|
||||||
showPopup();
|
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:
|
private slots:
|
||||||
|
|
||||||
void popupGroups();
|
void popupGroups();
|
||||||
|
void selectNextGroup();
|
||||||
|
void selectPreviousGroup();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QAction popupAction;
|
QAction popupAction;
|
||||||
|
QAction selectNextAction, selectPreviousAction;
|
||||||
QMap< int, int > shortcuts;
|
QMap< int, int > shortcuts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue