Add Squiek theme
This commit is contained in:
parent
49cd540ce0
commit
e4a07909ac
|
@ -496,7 +496,7 @@ void Editor::setupRadioBox()
|
||||||
|
|
||||||
setColor( Q::Symbol | Q::Disabled, m_pal.onSurface38 );
|
setColor( Q::Symbol | Q::Disabled, m_pal.onSurface38 );
|
||||||
|
|
||||||
setMargin( Q::Text, QskMargins( 10_dp, 0, 0, 0 ));
|
setMargin( Q::Text, QskMargins( 10_dp, 0, 10_dp, 0 ));
|
||||||
|
|
||||||
setAlignment( Q::Text, Qt::AlignBottom );
|
setAlignment( Q::Text, Qt::AlignBottom );
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <QskPopup.h>
|
#include <QskPopup.h>
|
||||||
#include <QskProgressBar.h>
|
#include <QskProgressBar.h>
|
||||||
#include <QskPushButton.h>
|
#include <QskPushButton.h>
|
||||||
|
#include <QskRadioBox.h>
|
||||||
#include <QskScrollView.h>
|
#include <QskScrollView.h>
|
||||||
#include <QskSeparator.h>
|
#include <QskSeparator.h>
|
||||||
#include <QskSegmentedBar.h>
|
#include <QskSegmentedBar.h>
|
||||||
|
@ -144,6 +145,7 @@ namespace
|
||||||
void setupPopup();
|
void setupPopup();
|
||||||
void setupProgressBar();
|
void setupProgressBar();
|
||||||
void setupPushButton();
|
void setupPushButton();
|
||||||
|
void setupRadioBox();
|
||||||
void setupScrollView();
|
void setupScrollView();
|
||||||
void setupSegmentedBar();
|
void setupSegmentedBar();
|
||||||
void setupSeparator();
|
void setupSeparator();
|
||||||
|
@ -259,6 +261,7 @@ void Editor::setup()
|
||||||
setupPopup();
|
setupPopup();
|
||||||
setupProgressBar();
|
setupProgressBar();
|
||||||
setupPushButton();
|
setupPushButton();
|
||||||
|
setupRadioBox();
|
||||||
setupScrollView();
|
setupScrollView();
|
||||||
setupSegmentedBar();
|
setupSegmentedBar();
|
||||||
setupSeparator();
|
setupSeparator();
|
||||||
|
@ -607,6 +610,38 @@ void Editor::setupPushButton()
|
||||||
setAlignment( Q::Graphic, Qt::AlignCenter );
|
setAlignment( Q::Graphic, Qt::AlignCenter );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Editor::setupRadioBox()
|
||||||
|
{
|
||||||
|
using Q = QskRadioBox;
|
||||||
|
|
||||||
|
setSpacing(Q::Panel, qskDpiScaled( 10 ) );
|
||||||
|
|
||||||
|
setStrutSize( Q::Button, { qskDpiScaled( 20 ), qskDpiScaled( 20 ) });
|
||||||
|
setStrutSize( Q::Symbol, { qskDpiScaled( 9 ), qskDpiScaled( 9 ) });
|
||||||
|
|
||||||
|
setBoxShape(Q::Button, qskDpiScaled( 20 ) );
|
||||||
|
setBoxShape(Q::Ripple, qskDpiScaled( 40 ) );
|
||||||
|
setBoxBorderMetrics( Q::Button, qskDpiScaled( 1 ) );
|
||||||
|
|
||||||
|
setBoxBorderColors( Q::Button, m_pal.darker125 );
|
||||||
|
setBoxBorderColors( Q::Button | Q::Disabled, m_pal.theme );
|
||||||
|
|
||||||
|
setColor( Q::Text, m_pal.themeForeground );
|
||||||
|
setColor( Q::Symbol, m_pal.themeForeground );
|
||||||
|
setColor( Q::Panel, m_pal.lighter125 );
|
||||||
|
setColor( Q::Panel | Q::Disabled, m_pal.lighter125 );
|
||||||
|
|
||||||
|
setColor( Q::Button | Q::Disabled, m_pal.lighter110 );
|
||||||
|
|
||||||
|
setColor( Q::Text | Q::Disabled, m_pal.darker200 );
|
||||||
|
|
||||||
|
setColor( Q::Symbol | Q::Disabled, m_pal.darker200 );
|
||||||
|
|
||||||
|
setMargin( Q::Text, QskMargins( qskDpiScaled( 10 ), 0, qskDpiScaled( 10 ), 0 ));
|
||||||
|
|
||||||
|
setAlignment( Q::Text, Qt::AlignBottom );
|
||||||
|
}
|
||||||
|
|
||||||
void Editor::setupDialogButtonBox()
|
void Editor::setupDialogButtonBox()
|
||||||
{
|
{
|
||||||
using Q = QskDialogButtonBox;
|
using Q = QskDialogButtonBox;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#include "QskRadioBox.h"
|
#include "QskRadioBox.h"
|
||||||
#include "QskEvent.h"
|
#include "QskEvent.h"
|
||||||
#include "QskAnimationHint.h"
|
#include "QskAnimationHint.h"
|
||||||
|
#include "QskSkinlet.h"
|
||||||
|
|
||||||
|
#include <qglobal.h>
|
||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
|
|
||||||
QSK_SUBCONTROL( QskRadioBox, Panel )
|
QSK_SUBCONTROL( QskRadioBox, Panel )
|
||||||
|
@ -18,6 +20,7 @@ class QskRadioBox::PrivateData {
|
||||||
public:
|
public:
|
||||||
QStringList items;
|
QStringList items;
|
||||||
int selectedIndex = -1;
|
int selectedIndex = -1;
|
||||||
|
int focusedIndex = -1;
|
||||||
int pressedIndex = -1;
|
int pressedIndex = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,7 +40,7 @@ QskRadioBox::QskRadioBox( QQuickItem* parent ) :
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setPositionHint( Ripple, -1 );
|
setFocusedIndex( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskRadioBox::QskRadioBox( const QStringList& list, QQuickItem* parent ) :
|
QskRadioBox::QskRadioBox( const QStringList& list, QQuickItem* parent ) :
|
||||||
|
@ -57,6 +60,37 @@ QskRadioBox::QskRadioBox( const QStringList& items,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRectF QskRadioBox::focusIndicatorRect() const {
|
||||||
|
if( m_data->focusedIndex > -1) {
|
||||||
|
|
||||||
|
auto textRect = effectiveSkinlet()->sampleRect( this,
|
||||||
|
contentsRect(), QskRadioBox::Text, m_data->focusedIndex );
|
||||||
|
|
||||||
|
auto buttonRect = effectiveSkinlet()->sampleRect( this,
|
||||||
|
contentsRect(), QskRadioBox::Button, m_data->focusedIndex );
|
||||||
|
|
||||||
|
auto result = QRectF(
|
||||||
|
qMin( textRect.x(), buttonRect.x() ),
|
||||||
|
qMin( textRect.y(), buttonRect.y() ),
|
||||||
|
buttonRect.width() + textRect.width(),
|
||||||
|
qMax( buttonRect.height(), textRect.height() ));
|
||||||
|
|
||||||
|
if( layoutMirroring() ) {
|
||||||
|
result.setWidth(
|
||||||
|
result.width() + marginHint( Text ).right()
|
||||||
|
+ marginHint( Button ).left() );
|
||||||
|
} else {
|
||||||
|
result.setWidth(
|
||||||
|
result.width() + marginHint( Text ).left()
|
||||||
|
+ marginHint( Button ).right() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QRectF();
|
||||||
|
}
|
||||||
|
|
||||||
int QskRadioBox::selectedIndex() const {
|
int QskRadioBox::selectedIndex() const {
|
||||||
return m_data->selectedIndex;
|
return m_data->selectedIndex;
|
||||||
}
|
}
|
||||||
|
@ -92,6 +126,10 @@ void QskRadioBox::setItems( const QStringList& items ){
|
||||||
m_data->items = items;
|
m_data->items = items;
|
||||||
itemsChanged( items );
|
itemsChanged( items );
|
||||||
setSelectedIndex( m_data->selectedIndex );
|
setSelectedIndex( m_data->selectedIndex );
|
||||||
|
|
||||||
|
if( m_data->focusedIndex > items.size() ) {
|
||||||
|
setFocusedIndex( 0 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskRadioBox::keyPressEvent( QKeyEvent* event )
|
void QskRadioBox::keyPressEvent( QKeyEvent* event )
|
||||||
|
@ -101,36 +139,36 @@ void QskRadioBox::keyPressEvent( QKeyEvent* event )
|
||||||
case Qt::Key_Up:
|
case Qt::Key_Up:
|
||||||
case Qt::Key_Left:
|
case Qt::Key_Left:
|
||||||
m_data->selectedIndex = qMax(m_data->selectedIndex - 1, 0);
|
m_data->selectedIndex = qMax(m_data->selectedIndex - 1, 0);
|
||||||
setPositionHint( Ripple, m_data->selectedIndex );
|
setFocusedIndex( m_data->selectedIndex );
|
||||||
event->setAccepted( true );
|
event->setAccepted( true );
|
||||||
update();
|
update();
|
||||||
return;
|
return;
|
||||||
case Qt::Key_Down:
|
case Qt::Key_Down:
|
||||||
case Qt::Key_Right:
|
case Qt::Key_Right:
|
||||||
m_data->selectedIndex = qMin(m_data->selectedIndex + 1, items().size() - 1);
|
m_data->selectedIndex = qMin(m_data->selectedIndex + 1, items().size() - 1);
|
||||||
setPositionHint( Ripple, m_data->selectedIndex );
|
setFocusedIndex( m_data->selectedIndex );
|
||||||
event->setAccepted( true );
|
event->setAccepted( true );
|
||||||
update();
|
update();
|
||||||
return;
|
return;
|
||||||
case Qt::Key_Select:
|
case Qt::Key_Select:
|
||||||
case Qt::Key_Return:
|
case Qt::Key_Return:
|
||||||
case Qt::Key_Space:
|
case Qt::Key_Space:
|
||||||
m_data->selectedIndex = positionHint( Ripple );
|
m_data->selectedIndex = m_data->focusedIndex;
|
||||||
event->setAccepted( true );
|
event->setAccepted( true );
|
||||||
update();
|
update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentTabIndex = positionHint( Ripple );
|
auto currentTabIndex = m_data->focusedIndex;
|
||||||
auto nextTabIndex = currentTabIndex + qskFocusChainIncrement( event );
|
auto nextTabIndex = currentTabIndex + qskFocusChainIncrement( event );
|
||||||
if( nextTabIndex >= items().size()
|
if( nextTabIndex >= items().size()
|
||||||
|| nextTabIndex < 0 ) {
|
|| nextTabIndex < 0 ) {
|
||||||
Inherited::keyPressEvent( event );
|
Inherited::keyPressEvent( event );
|
||||||
setPositionHint(Ripple, -1);
|
setFocusedIndex( -1);
|
||||||
update();
|
update();
|
||||||
} else {
|
} else {
|
||||||
event->setAccepted( true );
|
event->setAccepted( true );
|
||||||
setPositionHint( Ripple, (float) nextTabIndex );
|
setFocusedIndex( (float) nextTabIndex );
|
||||||
|
|
||||||
const auto aspect = Ripple | QskAspect::Metric | QskAspect::Position;
|
const auto aspect = Ripple | QskAspect::Metric | QskAspect::Position;
|
||||||
auto hint = animationHint(aspect | skinStates());
|
auto hint = animationHint(aspect | skinStates());
|
||||||
|
@ -157,7 +195,7 @@ void QskRadioBox::mousePressEvent( QMouseEvent* e )
|
||||||
m_data->pressedIndex = indexAtPosition;
|
m_data->pressedIndex = indexAtPosition;
|
||||||
m_data->selectedIndex = -1;
|
m_data->selectedIndex = -1;
|
||||||
|
|
||||||
setPositionHint( Ripple, indexAtPosition );
|
setFocusedIndex( indexAtPosition );
|
||||||
|
|
||||||
e->setAccepted( true );
|
e->setAccepted( true );
|
||||||
update();
|
update();
|
||||||
|
@ -176,9 +214,9 @@ void QskRadioBox::mouseReleaseEvent( QMouseEvent* e )
|
||||||
|
|
||||||
void QskRadioBox::focusInEvent( QFocusEvent* e ) {
|
void QskRadioBox::focusInEvent( QFocusEvent* e ) {
|
||||||
if( e->reason() == Qt::TabFocusReason ) {
|
if( e->reason() == Qt::TabFocusReason ) {
|
||||||
setPositionHint( Ripple, 0 );
|
setFocusedIndex(0 );
|
||||||
} else if( e->reason() == Qt::BacktabFocusReason ) {
|
} else if( e->reason() == Qt::BacktabFocusReason ) {
|
||||||
setPositionHint( Ripple, items().size() - 1 );
|
setFocusedIndex(items().size() - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
@ -186,7 +224,7 @@ void QskRadioBox::focusInEvent( QFocusEvent* e ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskRadioBox::focusOutEvent( QFocusEvent* e ) {
|
void QskRadioBox::focusOutEvent( QFocusEvent* e ) {
|
||||||
setPositionHint(Ripple, -1);
|
setFocusedIndex( -1 );
|
||||||
update();
|
update();
|
||||||
|
|
||||||
Inherited::focusOutEvent( e );
|
Inherited::focusOutEvent( e );
|
||||||
|
@ -202,4 +240,11 @@ int QskRadioBox::indexAt( const QPointF& target ) const {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QskRadioBox::setFocusedIndex( int index ) {
|
||||||
|
qDebug() << "setting index " << index;
|
||||||
|
m_data->focusedIndex = index;
|
||||||
|
setPositionHint( Ripple, index );
|
||||||
|
focusIndicatorRectChanged();
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_QskRadioBox.cpp"
|
#include "moc_QskRadioBox.cpp"
|
||||||
|
|
|
@ -29,6 +29,8 @@ class QSK_EXPORT QskRadioBox : public QskControl
|
||||||
QskRadioBox( const QStringList&, QQuickItem* parent = nullptr );
|
QskRadioBox( const QStringList&, QQuickItem* parent = nullptr );
|
||||||
QskRadioBox( const QStringList&, int, QQuickItem* parent = nullptr );
|
QskRadioBox( const QStringList&, int, QQuickItem* parent = nullptr );
|
||||||
|
|
||||||
|
QRectF focusIndicatorRect() const override;
|
||||||
|
|
||||||
const QStringList& items() const;
|
const QStringList& items() const;
|
||||||
int selectedIndex() const;
|
int selectedIndex() const;
|
||||||
int pressedIndex() const;
|
int pressedIndex() const;
|
||||||
|
@ -54,6 +56,7 @@ class QSK_EXPORT QskRadioBox : public QskControl
|
||||||
int indexAt( const QPointF& ) const;
|
int indexAt( const QPointF& ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setFocusedIndex( int index );
|
||||||
class PrivateData;
|
class PrivateData;
|
||||||
std::unique_ptr< PrivateData > m_data;
|
std::unique_ptr< PrivateData > m_data;
|
||||||
};
|
};
|
||||||
|
|
|
@ -162,16 +162,23 @@ QRectF QskRadioBoxSkinlet::textRect( const QskRadioBox* radio,
|
||||||
auto spacing = radio->spacingHint(Q::Panel);
|
auto spacing = radio->spacingHint(Q::Panel);
|
||||||
auto lh = lineHeight( radio );
|
auto lh = lineHeight( radio );
|
||||||
const auto textMargins = radio->marginHint( Q::Text );
|
const auto textMargins = radio->marginHint( Q::Text );
|
||||||
|
const auto font = radio->effectiveFont( Q::Text );
|
||||||
|
|
||||||
result.moveTop( index * ( lh + spacing )
|
result.moveTop( index * ( lh + spacing )
|
||||||
+ lh - radio->effectiveFontHeight(Q::Text)
|
+ lh - radio->effectiveFontHeight(Q::Text)
|
||||||
+ textMargins.top());
|
+ textMargins.top());
|
||||||
|
|
||||||
if( !radio->layoutMirroring() ) {
|
result.setHeight( lh );
|
||||||
auto maxWidth = qMax( buttonRect( radio, Q::Symbol, rect, index ).width(),
|
result.setWidth( qskHorizontalAdvance( font, radio->items()[index] ) );
|
||||||
buttonRect( radio, Q::Button, rect, index ).width());
|
|
||||||
|
|
||||||
result.moveLeft( maxWidth + textMargins.left());
|
auto buttonWidth = buttonRect( radio, Q::Button, rect, index ).width();
|
||||||
|
auto buttonsMargins = radio->marginHint( Q::Button );
|
||||||
|
if( radio->layoutMirroring() ) {
|
||||||
|
result.moveLeft( rect.width() - textMargins.right()
|
||||||
|
- result.width() - buttonWidth - buttonsMargins.left());
|
||||||
|
} else {
|
||||||
|
result.moveLeft( buttonWidth + textMargins.left()
|
||||||
|
+ radio->marginHint( Q::Button ).right());
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in New Issue