combo box improved
This commit is contained in:
parent
52fc83ea35
commit
d8dd07d305
@ -236,14 +236,16 @@ void QskComboBox::openPopup()
|
|||||||
|
|
||||||
auto menu = new QskMenu();
|
auto menu = new QskMenu();
|
||||||
|
|
||||||
menu->setParent( this );
|
menu->setWrapping( false );
|
||||||
menu->setParentItem( window()->contentItem() );
|
menu->setOrigin( mapToScene( cr.topLeft() ) );
|
||||||
menu->setPopupFlag( QskPopup::DeleteOnClose, true );
|
|
||||||
|
|
||||||
menu->setOrigin( mapToScene( cr.bottomLeft() ) );
|
|
||||||
menu->setFixedWidth( cr.width() );
|
menu->setFixedWidth( cr.width() );
|
||||||
|
|
||||||
menu->setOptions( m_data->options );
|
menu->setOptions( m_data->options );
|
||||||
|
menu->setCurrentIndex( currentIndex() );
|
||||||
|
|
||||||
|
menu->setParent( this );
|
||||||
|
menu->setParentItem( window()->contentItem() );
|
||||||
|
menu->setPopupFlag( QskPopup::DeleteOnClose, true );
|
||||||
|
|
||||||
connect( menu, &QskMenu::currentIndexChanged,
|
connect( menu, &QskMenu::currentIndexChanged,
|
||||||
this, &QskComboBox::indexInPopupChanged );
|
this, &QskComboBox::indexInPopupChanged );
|
||||||
|
@ -53,6 +53,8 @@ class QskMenu::PrivateData
|
|||||||
|
|
||||||
int triggeredIndex = -1;
|
int triggeredIndex = -1;
|
||||||
int currentIndex = -1;
|
int currentIndex = -1;
|
||||||
|
|
||||||
|
bool wrapping = true;
|
||||||
bool isPressed = false;
|
bool isPressed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -105,6 +107,20 @@ QRectF QskMenu::clipRect() const
|
|||||||
return Inherited::clipRect();
|
return Inherited::clipRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QskMenu::isWrapping() const
|
||||||
|
{
|
||||||
|
return m_data->wrapping;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskMenu::setWrapping( bool on )
|
||||||
|
{
|
||||||
|
if ( m_data->wrapping != on )
|
||||||
|
{
|
||||||
|
m_data->wrapping = on;
|
||||||
|
Q_EMIT wrappingChanged( on );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
|
||||||
// has no effect as we do not offer submenus yet. TODO ...
|
// has no effect as we do not offer submenus yet. TODO ...
|
||||||
@ -422,6 +438,9 @@ void QskMenu::traverse( int steps )
|
|||||||
int action1 = qskActionIndex( actions, m_data->currentIndex );
|
int action1 = qskActionIndex( actions, m_data->currentIndex );
|
||||||
int action2 = action1 + steps;
|
int action2 = action1 + steps;
|
||||||
|
|
||||||
|
if ( !m_data->wrapping )
|
||||||
|
action2 = qBound( 0, action2, count - 1 );
|
||||||
|
|
||||||
// when cycling we want to slide in
|
// when cycling we want to slide in
|
||||||
int index1;
|
int index1;
|
||||||
|
|
||||||
|
@ -23,6 +23,9 @@ class QSK_EXPORT QskMenu : public QskPopup
|
|||||||
Q_PROPERTY( bool cascading READ isCascading WRITE setCascading
|
Q_PROPERTY( bool cascading READ isCascading WRITE setCascading
|
||||||
RESET resetCascading NOTIFY cascadingChanged )
|
RESET resetCascading NOTIFY cascadingChanged )
|
||||||
|
|
||||||
|
Q_PROPERTY( bool wrapping READ isWrapping
|
||||||
|
WRITE setWrapping NOTIFY wrappingChanged )
|
||||||
|
|
||||||
Q_PROPERTY( QVector< QskLabelData > options READ options
|
Q_PROPERTY( QVector< QskLabelData > options READ options
|
||||||
WRITE setOptions NOTIFY optionsChanged )
|
WRITE setOptions NOTIFY optionsChanged )
|
||||||
|
|
||||||
@ -47,6 +50,9 @@ class QSK_EXPORT QskMenu : public QskPopup
|
|||||||
void setCascading( bool );
|
void setCascading( bool );
|
||||||
void resetCascading();
|
void resetCascading();
|
||||||
|
|
||||||
|
bool isWrapping() const;
|
||||||
|
void setWrapping( bool );
|
||||||
|
|
||||||
void setOrigin( const QPointF& );
|
void setOrigin( const QPointF& );
|
||||||
QPointF origin() const;
|
QPointF origin() const;
|
||||||
|
|
||||||
@ -87,6 +93,7 @@ class QSK_EXPORT QskMenu : public QskPopup
|
|||||||
Q_INVOKABLE int exec();
|
Q_INVOKABLE int exec();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
void wrappingChanged( bool );
|
||||||
void cascadingChanged( bool );
|
void cascadingChanged( bool );
|
||||||
void originChanged( const QPointF& );
|
void originChanged( const QPointF& );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user