void DiagramSettings::Private::changeBackgroundColor() { if ( m_chart && m_chart->coordinatePlane() && m_chart->coordinatePlane()->diagram() ) { BackgroundAttributes bat = m_chart->coordinatePlane()->backgroundAttributes(); bat.setVisible( true ); ui->visibleBtn->setChecked( true ); if ( ui->color->isChecked() ) { QBrush setBrush = bat.brush(); const QColor color = QColorDialog::getColor( setBrush.color(), qq, tr( "Choose new color" ) ); if ( !color.isValid() ) return; bat.setBrush( color ); QPalette palette = ui->diagramBackground->palette(); palette.setBrush( QPalette::Button, color ); ui->diagramBackground->setPalette( palette ); } else if ( ui->textureBtn->isChecked() ) { //QBrush setBrush = m_chart->coordinatePlane()->diagram()->brush( index ); QImage texture; const QString filename = QFileDialog::getOpenFileName( qq, tr( "Choose Texture" ), QString(), tr( "Images (*.png *.xpm *.jpg)" ) ); if ( filename.isEmpty() ) return; texture = QImage( filename ); bat.setBrush( texture ); QPalette palette = ui->diagramBackground->palette(); palette.setBrush( QPalette::Button, QBrush( texture ) ); ui->diagramBackground->setPalette( palette ); } else { QBrush setBrush = bat.brush(); QGradient grad; QLinearGradient lGrad; lGrad.setColorAt( 0, Qt::black ); lGrad.setColorAt( 1, setBrush.color() ); grad = lGrad; if ( setBrush.gradient() ) grad = *setBrush.gradient(); const QGradient &color = GradientDialog::getGradient( grad, qq, tr( "Choose new color" ) ); bat.setBrush( color ); QPalette palette = ui->diagramBackground->palette(); palette.setBrush( QPalette::Button, QBrush( color ) ); ui->diagramBackground->setPalette( palette ); } bat.setVisible( true ); m_chart->coordinatePlane()->setBackgroundAttributes( bat ); qq->update(); } }
void DiagramSettings::refreshSettings() { if ( d->m_chart && d->m_chart->coordinatePlane() && d->m_chart->coordinatePlane()->diagram() ) { BarDiagram *bars = qobject_cast< BarDiagram* >( d->m_chart->coordinatePlane()->diagram() ); LineDiagram *lines = qobject_cast< LineDiagram* >( d->m_chart->coordinatePlane()->diagram() ); PieDiagram *pie = qobject_cast< PieDiagram* >( d->m_chart->coordinatePlane()->diagram() ); if ( bars ) { const AbstractThreeDAttributes &td = bars->threeDBarAttributes(); d->setThreeDData( td ); } else if ( lines ) { const AbstractThreeDAttributes &td = lines->threeDLineAttributes(); d->setThreeDData( td ); } else if ( pie ) { const AbstractThreeDAttributes &td = pie->threeDPieAttributes(); d->setThreeDData( td ); } BackgroundAttributes bat = d->m_chart->coordinatePlane()->backgroundAttributes(); QBrush setBrush = bat.brush(); QPalette palette = d->ui->diagramBackground->palette(); if ( bat.isVisible() ) palette.setBrush( QPalette::Button, setBrush ); else palette.setBrush( QPalette::Button, this->palette().brush( QPalette::Button ) ); d->ui->diagramBackground->setPalette( palette ); } }
bool BackgroundAttributes::isEqualTo( const BackgroundAttributes& other, bool ignorePixmap ) const { /* qDebug() << "BackgroundAttributes::operator=="; qDebug() << "isVisible" << (isVisible() == other.isVisible()); qDebug() << "brush" << (brush() == other.brush()); qDebug() << "pixmapMode"<< (pixmapMode() == other.pixmapMode()); qDebug() << "pixmap" << (pixmap().serialNumber() == other.pixmap().serialNumber()); */ return ( isVisible() == other.isVisible() && brush() == other.brush() && pixmapMode() == other.pixmapMode() && (ignorePixmap || pixmap().cacheKey() == other.pixmap().cacheKey()) ); }