using auto, where it makes sense
This commit is contained in:
parent
72a7e7f8e7
commit
9989ae85d3
|
@ -43,7 +43,7 @@ ButtonBar::ButtonBar( QQuickItem* parentItem )
|
||||||
|
|
||||||
void ButtonBar::addIndicator( const char* name )
|
void ButtonBar::addIndicator( const char* name )
|
||||||
{
|
{
|
||||||
auto* label = new IndicatorLabel( this );
|
auto label = new IndicatorLabel( this );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The label should adjust vertically and be stretched horizontally
|
The label should adjust vertically and be stretched horizontally
|
||||||
|
|
|
@ -10,10 +10,10 @@ class SkinFactory : public QskSkinFactory
|
||||||
public:
|
public:
|
||||||
enum GraphicRoles
|
enum GraphicRoles
|
||||||
{
|
{
|
||||||
// to be visisble on a button
|
// to be visible on a button
|
||||||
Button,
|
Button,
|
||||||
|
|
||||||
// to be visisble on header/footer
|
// to be visible on header/footer
|
||||||
Indicator,
|
Indicator,
|
||||||
|
|
||||||
// in contrast to the background pixmap
|
// in contrast to the background pixmap
|
||||||
|
|
|
@ -210,7 +210,7 @@ class StackedControl final : public QskControl
|
||||||
|
|
||||||
for ( int a = 0; a < children().count(); a++ )
|
for ( int a = 0; a < children().count(); a++ )
|
||||||
{
|
{
|
||||||
QskControl* control = static_cast< QskControl* >( children().at( a ) );
|
auto control = static_cast< QskControl* >( children().at( a ) );
|
||||||
|
|
||||||
if ( control->objectName() == "verticalBar" )
|
if ( control->objectName() == "verticalBar" )
|
||||||
{
|
{
|
||||||
|
@ -250,7 +250,7 @@ class SectionTitleBar final : public QskLinearBox
|
||||||
{
|
{
|
||||||
setSpacing( 10 );
|
setSpacing( 10 );
|
||||||
|
|
||||||
auto* label = new QskTextLabel( title );
|
auto label = new QskTextLabel( title );
|
||||||
label->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
|
label->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
|
||||||
|
|
||||||
addItem( new QskSeparator() );
|
addItem( new QskSeparator() );
|
||||||
|
@ -275,7 +275,7 @@ class SliderBox final : public QskLinearBox
|
||||||
label->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
|
label->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
|
||||||
m_numberLabel->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
|
m_numberLabel->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
|
||||||
|
|
||||||
auto* plusButton = new ControlButton( '+' );
|
auto plusButton = new ControlButton( '+' );
|
||||||
auto minusButton = new ControlButton( '-' );
|
auto minusButton = new ControlButton( '-' );
|
||||||
|
|
||||||
m_slider = new QskSlider( Qt::Vertical );
|
m_slider = new QskSlider( Qt::Vertical );
|
||||||
|
|
|
@ -79,11 +79,11 @@ void Theme::setSkin( const QString& skinName )
|
||||||
if ( skinName == qskSetup->skinName() )
|
if ( skinName == qskSetup->skinName() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QskSkin* oldSkin = qskSetup->skin();
|
auto oldSkin = qskSetup->skin();
|
||||||
if ( oldSkin->parent() == qskSetup )
|
if ( oldSkin->parent() == qskSetup )
|
||||||
oldSkin->setParent( nullptr ); // otherwise setSkin deletes it
|
oldSkin->setParent( nullptr ); // otherwise setSkin deletes it
|
||||||
|
|
||||||
QskSkin* newSkin = qskSetup->setSkin( skinName );
|
auto newSkin = qskSetup->setSkin( skinName );
|
||||||
|
|
||||||
SkinTransition transition( m_accent );
|
SkinTransition transition( m_accent );
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,9 @@ ButtonBox::ButtonBox( QQuickItem* parent )
|
||||||
void ButtonBox::addButton(
|
void ButtonBox::addButton(
|
||||||
const QString& text, std::function< void() > func, bool autoRepeat )
|
const QString& text, std::function< void() > func, bool autoRepeat )
|
||||||
{
|
{
|
||||||
QskPushButton* button = new QskPushButton( text );
|
auto button = new QskPushButton( text );
|
||||||
button->setAutoRepeat( autoRepeat );
|
button->setAutoRepeat( autoRepeat );
|
||||||
|
|
||||||
QObject::connect( button, &QskPushButton::clicked, func );
|
QObject::connect( button, &QskPushButton::clicked, func );
|
||||||
|
|
||||||
addItem( button );
|
addItem( button );
|
||||||
|
|
|
@ -128,10 +128,11 @@ DynamicConstraintsPage::DynamicConstraintsPage( QQuickItem* parent )
|
||||||
setMargins( 10 );
|
setMargins( 10 );
|
||||||
setBackgroundColor( QskRgbValue::LightSteelBlue );
|
setBackgroundColor( QskRgbValue::LightSteelBlue );
|
||||||
|
|
||||||
Box* box = new Box();
|
auto box = new Box();
|
||||||
|
|
||||||
QskPushButton* button = new QskPushButton( "Flip" );
|
auto button = new QskPushButton( "Flip" );
|
||||||
button->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
|
button->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
|
||||||
|
|
||||||
QObject::connect( button, &QskPushButton::clicked, box, &Box::flip );
|
QObject::connect( button, &QskPushButton::clicked, box, &Box::flip );
|
||||||
|
|
||||||
addItem( button, Qt::AlignTop | Qt::AlignLeft );
|
addItem( button, Qt::AlignTop | Qt::AlignLeft );
|
||||||
|
|
|
@ -75,8 +75,9 @@ namespace
|
||||||
private:
|
private:
|
||||||
void addRectangle( const char* colorName )
|
void addRectangle( const char* colorName )
|
||||||
{
|
{
|
||||||
TestRectangle* rect = new TestRectangle( colorName );
|
auto rect = new TestRectangle( colorName );
|
||||||
rect->setText( QString::number( itemCount() + 1 ) );
|
rect->setText( QString::number( itemCount() + 1 ) );
|
||||||
|
|
||||||
addItem( rect, Qt::AlignCenter );
|
addItem( rect, Qt::AlignCenter );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -88,9 +89,9 @@ FlowLayoutPage::FlowLayoutPage( QQuickItem* parent )
|
||||||
setMargins( 10 );
|
setMargins( 10 );
|
||||||
setBackgroundColor( QskRgbValue::LightSteelBlue );
|
setBackgroundColor( QskRgbValue::LightSteelBlue );
|
||||||
|
|
||||||
Box* box = new Box();
|
auto box = new Box();
|
||||||
|
|
||||||
ButtonBox* buttonBox = new ButtonBox();
|
auto buttonBox = new ButtonBox();
|
||||||
buttonBox->addButton( "Flip", [ box ]() { box->transpose(); } );
|
buttonBox->addButton( "Flip", [ box ]() { box->transpose(); } );
|
||||||
buttonBox->addButton( "Mirror", [ box ]() { box->mirror(); } );
|
buttonBox->addButton( "Mirror", [ box ]() { box->mirror(); } );
|
||||||
buttonBox->addButton( "Rotate", [ box ]() { box->rotate(); } );
|
buttonBox->addButton( "Rotate", [ box ]() { box->rotate(); } );
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace
|
||||||
private:
|
private:
|
||||||
void addRectangle( const char* colorName )
|
void addRectangle( const char* colorName )
|
||||||
{
|
{
|
||||||
TestRectangle* rect = new TestRectangle( colorName );
|
auto rect = new TestRectangle( colorName );
|
||||||
rect->setText( QString::number( itemCount() + 1 ) );
|
rect->setText( QString::number( itemCount() + 1 ) );
|
||||||
|
|
||||||
addItem( rect, Qt::AlignCenter );
|
addItem( rect, Qt::AlignCenter );
|
||||||
|
@ -86,9 +86,9 @@ LinearLayoutPage::LinearLayoutPage( QQuickItem* parent )
|
||||||
setMargins( 10 );
|
setMargins( 10 );
|
||||||
setBackgroundColor( QskRgbValue::LightSteelBlue );
|
setBackgroundColor( QskRgbValue::LightSteelBlue );
|
||||||
|
|
||||||
Box* box = new Box();
|
auto box = new Box();
|
||||||
|
|
||||||
ButtonBox* buttonBox = new ButtonBox();
|
auto buttonBox = new ButtonBox();
|
||||||
buttonBox->addButton( "Flip", [ box ]() { box->transpose(); } );
|
buttonBox->addButton( "Flip", [ box ]() { box->transpose(); } );
|
||||||
buttonBox->addButton( "Mirror", [ box ]() { box->mirror(); } );
|
buttonBox->addButton( "Mirror", [ box ]() { box->mirror(); } );
|
||||||
buttonBox->addButton( "Rotate", [ box ]() { box->rotate(); } );
|
buttonBox->addButton( "Rotate", [ box ]() { box->rotate(); } );
|
||||||
|
|
|
@ -35,8 +35,7 @@ namespace
|
||||||
|
|
||||||
for ( int i = 0; i < itemCount(); i += 2 )
|
for ( int i = 0; i < itemCount(); i += 2 )
|
||||||
{
|
{
|
||||||
QskControl* control = qobject_cast< QskControl* >( itemAtIndex( i ) );
|
if ( auto control = qobject_cast< QskControl* >( itemAtIndex( i ) ) )
|
||||||
if ( control )
|
|
||||||
control->setFixedSize( 200, 200 );
|
control->setFixedSize( 200, 200 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ int main( int argc, char* argv[] )
|
||||||
SkinnyFont::init( &app );
|
SkinnyFont::init( &app );
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||||
|
|
||||||
QskTabView* tabView = new QskTabView();
|
auto tabView = new QskTabView();
|
||||||
tabView->setMargins( 10 );
|
tabView->setMargins( 10 );
|
||||||
tabView->setOrientation( Qt::Horizontal );
|
tabView->setOrientation( Qt::Horizontal );
|
||||||
tabView->addTab( "Grid Layout", new DummyLabel( "Grid Layout - TODO ..." ) );
|
tabView->addTab( "Grid Layout", new DummyLabel( "Grid Layout - TODO ..." ) );
|
||||||
|
@ -59,7 +59,7 @@ int main( int argc, char* argv[] )
|
||||||
tabView->addTab( "Linear Layout", new LinearLayoutPage() );
|
tabView->addTab( "Linear Layout", new LinearLayoutPage() );
|
||||||
int dynamicIndex = tabView->addTab( "Dynamic\nConstraints", new DynamicConstraintsPage() );
|
int dynamicIndex = tabView->addTab( "Dynamic\nConstraints", new DynamicConstraintsPage() );
|
||||||
|
|
||||||
QskTabButton* button = tabView->buttonAt( dynamicIndex );
|
auto button = tabView->buttonAt( dynamicIndex );
|
||||||
QskTextOptions textOptions = button->textOptions();
|
QskTextOptions textOptions = button->textOptions();
|
||||||
textOptions.setWrapMode( QskTextOptions::WordWrap );
|
textOptions.setWrapMode( QskTextOptions::WordWrap );
|
||||||
button->setTextOptions( textOptions );
|
button->setTextOptions( textOptions );
|
||||||
|
|
|
@ -131,7 +131,7 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
qskDialog->setPolicy( QskDialog::EmbeddedBox );
|
qskDialog->setPolicy( QskDialog::EmbeddedBox );
|
||||||
|
|
||||||
ButtonBox* box = new ButtonBox();
|
auto box = new ButtonBox();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
To avoid losing the focus, when a message box is executed
|
To avoid losing the focus, when a message box is executed
|
||||||
|
|
|
@ -70,8 +70,7 @@ class HandleNode : public QSGGeometryNode
|
||||||
|
|
||||||
if ( rect != m_rect || peakPos != m_peakPos )
|
if ( rect != m_rect || peakPos != m_peakPos )
|
||||||
{
|
{
|
||||||
QSGGeometry::Point2D* p =
|
auto p = reinterpret_cast< QSGGeometry::Point2D* >( m_geometry.vertexData() );
|
||||||
reinterpret_cast< QSGGeometry::Point2D* >( m_geometry.vertexData() );
|
|
||||||
|
|
||||||
const qreal y0 = rect.y() + qskPeak;
|
const qreal y0 = rect.y() + qskPeak;
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ class SliderBox : public QskLinearBox
|
||||||
|
|
||||||
for ( int i = 0; i < itemCount(); i++ )
|
for ( int i = 0; i < itemCount(); i++ )
|
||||||
{
|
{
|
||||||
if ( QskSlider* slider = qobject_cast< QskSlider* >( itemAtIndex( i ) ) )
|
if ( auto slider = qobject_cast< QskSlider* >( itemAtIndex( i ) ) )
|
||||||
{
|
{
|
||||||
slider->setObjectName( "Slider " + QString::number( i + 1 ) );
|
slider->setObjectName( "Slider " + QString::number( i + 1 ) );
|
||||||
slider->setValue( slider->minimum() +
|
slider->setValue( slider->minimum() +
|
||||||
|
@ -156,7 +156,7 @@ class SliderBox : public QskLinearBox
|
||||||
|
|
||||||
for ( int i = 0; i < itemCount(); i++ )
|
for ( int i = 0; i < itemCount(); i++ )
|
||||||
{
|
{
|
||||||
if ( QskSlider* slider = qobject_cast< QskSlider* >( itemAtIndex( i ) ) )
|
if ( auto slider = qobject_cast< QskSlider* >( itemAtIndex( i ) ) )
|
||||||
{
|
{
|
||||||
const Qt::Orientation orientation = inverted( slider->orientation() );
|
const Qt::Orientation orientation = inverted( slider->orientation() );
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ class SliderBox : public QskLinearBox
|
||||||
slider->setVisible( orientation == Qt::Horizontal );
|
slider->setVisible( orientation == Qt::Horizontal );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( QskSeparator* separator = qobject_cast< QskSeparator* >( itemAtIndex( i ) ) )
|
else if ( auto separator = qobject_cast< QskSeparator* >( itemAtIndex( i ) ) )
|
||||||
{
|
{
|
||||||
separator->setOrientation( inverted( separator->orientation() ) );
|
separator->setOrientation( inverted( separator->orientation() ) );
|
||||||
}
|
}
|
||||||
|
@ -195,24 +195,24 @@ int main( int argc, char* argv[] )
|
||||||
SkinnyFont::init( &app );
|
SkinnyFont::init( &app );
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||||
|
|
||||||
QskPushButton* buttonFlip = new QskPushButton( "Flip" );
|
auto buttonFlip = new QskPushButton( "Flip" );
|
||||||
buttonFlip->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
|
buttonFlip->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
|
||||||
buttonFlip->setFocus( true );
|
buttonFlip->setFocus( true );
|
||||||
|
|
||||||
SliderBox* sliderBox = new SliderBox();
|
auto sliderBox = new SliderBox();
|
||||||
sliderBox->setBackgroundColor( QskRgbValue::PeachPuff );
|
sliderBox->setBackgroundColor( QskRgbValue::PeachPuff );
|
||||||
|
|
||||||
QObject::connect( buttonFlip, &QskPushButton::clicked,
|
QObject::connect( buttonFlip, &QskPushButton::clicked,
|
||||||
sliderBox, &SliderBox::flip );
|
sliderBox, &SliderBox::flip );
|
||||||
|
|
||||||
QskLinearBox* mainBox = new QskLinearBox( Qt::Vertical );
|
auto mainBox = new QskLinearBox( Qt::Vertical );
|
||||||
mainBox->setMargins( 10 );
|
mainBox->setMargins( 10 );
|
||||||
mainBox->setSpacing( 10 );
|
mainBox->setSpacing( 10 );
|
||||||
mainBox->addItem( buttonFlip, Qt::AlignLeft );
|
mainBox->addItem( buttonFlip, Qt::AlignLeft );
|
||||||
mainBox->addItem( sliderBox );
|
mainBox->addItem( sliderBox );
|
||||||
mainBox->setStretchFactor( sliderBox, 10 );
|
mainBox->setStretchFactor( sliderBox, 10 );
|
||||||
|
|
||||||
QskFocusIndicator* focusIndicator = new QskFocusIndicator();
|
auto focusIndicator = new QskFocusIndicator();
|
||||||
focusIndicator->setObjectName( "FocusIndicator" );
|
focusIndicator->setObjectName( "FocusIndicator" );
|
||||||
|
|
||||||
QskWindow window;
|
QskWindow window;
|
||||||
|
|
Loading…
Reference in New Issue