00001 #include "kchartWizardLabelsLegendPage.h"
00002 #include "kchart_view.h"
00003 #include "kchart_part.h"
00004
00005 #include <qbuttongroup.h>
00006 #include <qlineedit.h>
00007 #include <qradiobutton.h>
00008 #include <qlabel.h>
00009 #include <klocale.h>
00010 #include <kfontdialog.h>
00011 #include <qlayout.h>
00012 #include <qpushbutton.h>
00013 #include <qcolor.h>
00014
00015 #include "kchart_params.h"
00016
00017 namespace KChart
00018 {
00019
00020 KChartWizardLabelsLegendPage::KChartWizardLabelsLegendPage( QWidget* parent, KChartPart* chart ) :
00021 QWidget( parent ),
00022 _chart( chart )
00023 {
00024 #if 0
00025 ytitle2=true;
00026 #endif
00027
00028 KDChartAxisParams leftparams;
00029 leftparams = _chart->params()->axisParams( KDChartAxisParams::AxisPosLeft );
00030 KDChartAxisParams bottomparams;
00031 bottomparams = _chart->params()->axisParams( KDChartAxisParams::AxisPosBottom );
00032 x_color=bottomparams.axisLineColor();
00033 y_color=leftparams.axisLineColor();
00034 xlabel=bottomparams.axisLabelsFont();
00035 ylabel=leftparams.axisLabelsFont();
00036
00037 QGridLayout *grid1 = new QGridLayout(this,2,2,KDialog::marginHint(), KDialog::spacingHint());
00038
00039 QGroupBox* tmpQGroupBox;
00040 tmpQGroupBox = new QGroupBox( this, "GroupBox_1" );
00041 tmpQGroupBox->setFrameStyle( 49 );
00042
00043 QGridLayout *grid2 = new QGridLayout(tmpQGroupBox,4,4,KDialog::marginHint(), KDialog::spacingHint());
00044
00045 QLabel* titleLA = new QLabel( i18n( "Title:" ),tmpQGroupBox );
00046 grid2->addWidget(titleLA,0,0);
00047
00048 _titleED = new QLineEdit( tmpQGroupBox );
00049 grid2->addWidget(_titleED,0,1);
00050 _titleED->setText( _chart->params()->header1Text() );
00051
00052 titlefont = new QPushButton( tmpQGroupBox );
00053 grid2->addWidget(titlefont,0,2);
00054 titlefont->setText(i18n("Font..."));
00055
00056 titlecolor=new KColorButton(tmpQGroupBox);
00057 grid2->addWidget(titlecolor,0,3);
00058 title_color=_chart->params()->headerFooterColor( KDChartParams::HdFtPosHeader );
00059 titlecolor->setColor( title_color );
00060
00061
00062 QLabel* xlabelLA = new QLabel( i18n( "X-title:" ), tmpQGroupBox );
00063
00064 grid2->addWidget(xlabelLA,1,0);
00065
00066 _xlabelED = new QLineEdit( tmpQGroupBox );
00067
00068 _xlabelED->setText(_chart->params()->axisTitle( KDChartAxisParams::AxisPosBottom));
00069 grid2->addWidget(_xlabelED,1,1);
00070
00071 xtitlefont = new QPushButton( tmpQGroupBox );
00072 xtitlefont->setText(i18n("Font..."));
00073
00074 grid2->addWidget(xtitlefont,1,2);
00075
00076 xtitlecolor=new KColorButton(tmpQGroupBox);
00077
00078
00079 xtitlecolor->setColor( x_color );
00080
00081 grid2->addWidget(xtitlecolor,1,3);
00082
00083
00084 QLabel* ylabelLA = new QLabel( i18n( "Y-title:" ), tmpQGroupBox );
00085
00086 grid2->addWidget(ylabelLA,2,0);
00087
00088 _ylabelED = new QLineEdit( tmpQGroupBox );
00089
00090 _ylabelED->setText(_chart->params()->axisTitle( KDChartAxisParams::AxisPosLeft));
00091 grid2->addWidget(_ylabelED,2,1);
00092
00093
00094 ytitlefont = new QPushButton( tmpQGroupBox);
00095 ytitlefont->setText(i18n("Font..."));
00096
00097 grid2->addWidget(ytitlefont,2,2);
00098
00099 ytitlecolor=new KColorButton(tmpQGroupBox);
00100
00101
00102
00103 ytitlecolor->setColor( y_color );
00104 grid2->addWidget(ytitlecolor,2,3);
00105
00106 #if 0
00107
00108 QLabel* ylabelLA2 = new QLabel( i18n( "Y-title 2:" ), tmpQGroupBox );
00109 ylabelLA2->setEnabled(false);
00110 grid2->addWidget(ylabelLA2,3,0);
00111
00112 _ylabel2ED = new QLineEdit( tmpQGroupBox );
00113 _ylabel2ED->setEnabled(false);
00114
00115
00116 grid2->addWidget(_ylabel2ED,3,1);
00117
00118 ytitle2font = new QPushButton( tmpQGroupBox);
00119 ytitle2font->setText(i18n("Font..."));
00120 ytitle2font->setEnabled(false);
00121 grid2->addWidget(ytitle2font,3,2);
00122
00123 ytitle2color=new KColorButton(tmpQGroupBox);
00124 ytitle2color->setEnabled(false);
00125
00126
00127 ytitle2color->setColor( y_color2 );
00128 grid2->addWidget(ytitle2color,3,3);
00129 #endif
00130
00131
00132
00133
00134
00135
00136 QLabel* lab = new QLabel( i18n( "Legend title:" ), tmpQGroupBox );
00137 grid2->addWidget(lab,3,0);
00138
00139 _legendTitleText = new QLineEdit( tmpQGroupBox );
00140 grid2->addWidget(_legendTitleText,3,1);
00141 _legendTitleText->setText( _chart->params()->legendTitleText() );
00142
00143
00144 legendTitleFont = new QPushButton( tmpQGroupBox );
00145 legendTitleFont->setText(i18n("Font..."));
00146 _legendTitleFont=_chart->params()->legendTitleFont();
00147 grid2->addWidget(legendTitleFont,3,2);
00148
00149 legendTitleColor=new KColorButton(tmpQGroupBox);
00150 _legendTitleColor=_chart->params()->legendTitleTextColor();
00151 legendTitleColor->setColor( _legendTitleColor );
00152 grid2->addWidget(legendTitleColor,3,3);
00153
00154
00155 lab = new QLabel( i18n( "Legend text:" ), tmpQGroupBox );
00156 grid2->addWidget(lab,4,0);
00157
00158 legendTextFont = new QPushButton( tmpQGroupBox );
00159 _legendTextFont=_chart->params()->legendFont();
00160 legendTextFont->setText(i18n("Font..."));
00161 grid2->addWidget(legendTextFont,4,2);
00162
00163 legendTextColor=new KColorButton(tmpQGroupBox);
00164 _legendTextColor=_chart->params()->legendTextColor();
00165 legendTextColor->setColor( _legendTextColor );
00166 grid2->addWidget(legendTextColor,4,3);
00167
00168 title=_chart->params()->header1Font();
00169 grid1->addWidget(tmpQGroupBox,0,0);
00170
00171 connect(xtitlefont,SIGNAL(clicked()),this,SLOT(changeXLabelFont()));
00172 connect(ytitlefont,SIGNAL(clicked()),this,SLOT(changeYLabelFont()));
00173 #if 0
00174 connect(ytitle2font,SIGNAL(clicked()),this,SLOT(changeY2LabelFont()));
00175 #endif
00176 connect(titlefont,SIGNAL(clicked()),this,SLOT(changeTitleFont()));
00177 connect(legendTitleFont,SIGNAL(clicked()),this,SLOT(changeLegendTitleFont()));
00178
00179 connect(legendTextFont,SIGNAL(clicked()),this,SLOT(changeLegendTextFont()));
00180
00181 connect(xtitlecolor,SIGNAL(changed( const QColor & )),
00182 this,SLOT(changeXLabelColor(const QColor &)));
00183 connect(ytitlecolor,SIGNAL(changed( const QColor & )),
00184 this,SLOT(changeYLabelColor(const QColor &)));
00185 connect(titlecolor,SIGNAL(changed( const QColor & )),
00186 this,SLOT(changeTitleColor(const QColor &)));
00187 #if 0
00188 connect(ytitle2color,SIGNAL(changed( const QColor & )),
00189 this,SLOT(changeYTitle2Color(const QColor &)));
00190 #endif
00191 connect(legendTitleColor,SIGNAL(changed( const QColor & )),
00192 this,SLOT(changeLegendTitleColor(const QColor &)));
00193
00194 connect(legendTextColor,SIGNAL(changed( const QColor & )),
00195 this,SLOT(changeLegendTextColor(const QColor &)));
00196
00197 }
00198
00199
00200 KChartWizardLabelsLegendPage::~KChartWizardLabelsLegendPage()
00201 {
00202
00203 }
00204
00205 void KChartWizardLabelsLegendPage::changeLegendTextFont()
00206 {
00207 if (KFontDialog::getFont( _legendTextFont,false,this ) == QDialog::Rejected )
00208 return;
00209 }
00210
00211 void KChartWizardLabelsLegendPage::changeLegendTitleFont()
00212 {
00213 if (KFontDialog::getFont( _legendTitleFont,false,this ) == QDialog::Rejected )
00214 return;
00215 }
00216
00217 void KChartWizardLabelsLegendPage::changeXLabelFont()
00218 {
00219 if (KFontDialog::getFont( xlabel,false,this ) == QDialog::Rejected )
00220 return;
00221 }
00222
00223 void KChartWizardLabelsLegendPage::changeYLabelFont()
00224 {
00225 if (KFontDialog::getFont( ylabel ,false,this ) == QDialog::Rejected )
00226 return;
00227 }
00228
00229 #if 0
00230 void KChartWizardLabelsLegendPage::changeY2LabelFont()
00231 {
00232 if (KFontDialog::getFont( ylabel2, false, this ) == QDialog::Rejected )
00233 return;
00234 }
00235 #endif
00236
00237 void KChartWizardLabelsLegendPage::changeTitleFont()
00238 {
00239 if (KFontDialog::getFont( title ,false,this ) == QDialog::Rejected )
00240 return;
00241
00242 }
00243
00244 void KChartWizardLabelsLegendPage::changeLegendTextColor(const QColor &_color)
00245 {
00246 _legendTextColor=_color;
00247 }
00248
00249 void KChartWizardLabelsLegendPage::changeXLabelColor(const QColor &_color)
00250 {
00251 x_color=_color;
00252 }
00253
00254 void KChartWizardLabelsLegendPage::changeYLabelColor(const QColor &_color)
00255 {
00256 y_color=_color;
00257 }
00258
00259 void KChartWizardLabelsLegendPage::changeTitleColor(const QColor &_color)
00260 {
00261 title_color=_color;
00262 }
00263
00264 #if 0
00265 void KChartWizardLabelsLegendPage::changeYTitle2Color(const QColor &_color)
00266 {
00267 y_color2=_color;
00268 }
00269 #endif
00270
00271 void KChartWizardLabelsLegendPage::changeLegendTitleColor(const QColor &_color)
00272 {
00273 _legendTitleColor=_color;
00274 }
00275
00276 void KChartWizardLabelsLegendPage::paintEvent( QPaintEvent * )
00277 {
00278 #if 0
00279 if( ytitle2 ) {
00280 _ylabel2ED->setEnabled(true);
00281 ytitle2color->setEnabled(true);
00282 }
00283 else {
00284 _ylabel2ED->setEnabled(false);
00285 ytitle2color->setEnabled(false);
00286 }
00287 #endif
00288 }
00289
00290 void KChartWizardLabelsLegendPage::apply( )
00291 {
00292 _chart->params()->setHeader1Text( _titleED->text() );
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304 _chart->params()->setHeaderFooterColor( KDChartParams::HdFtPosHeader,title_color);
00305 _chart->params()->setHeader1Font(title);
00306 _chart->params()->setAxisTitle( KDChartAxisParams::AxisPosBottom, _xlabelED->text() );
00307 _chart->params()->setAxisTitle( KDChartAxisParams::AxisPosLeft, _ylabelED->text() );
00308
00309 _chart->params()->setLegendTitleText(_legendTitleText->text());
00310 _chart->params()->setLegendTitleTextColor(_legendTitleColor);
00311 _chart->params()->setLegendTitleFont(_legendTitleFont,true);
00312 _chart->params()->setLegendTextColor(_legendTextColor);
00313 _chart->params()->setLegendFont( _legendTextFont,true);
00314
00315 KDChartAxisParams leftparams;
00316 leftparams = _chart->params()->axisParams( KDChartAxisParams::AxisPosLeft );
00317 KDChartAxisParams bottomparams;
00318 bottomparams = _chart->params()->axisParams( KDChartAxisParams::AxisPosBottom );
00319 if( x_color.isValid() )
00320 bottomparams.setAxisLineColor( x_color );
00321 if( y_color.isValid() )
00322 leftparams.setAxisLineColor( y_color );
00323 if(bottomparams.axisLabelsFont()!=xlabel)
00324 bottomparams.setAxisLabelsFont(xlabel,false);
00325 if(leftparams.axisLabelsFont()!=ylabel)
00326 leftparams.setAxisLabelsFont(ylabel,true);
00327
00328 _chart->params()->setAxisParams( KDChartAxisParams::AxisPosBottom, bottomparams );
00329 _chart->params()->setAxisParams( KDChartAxisParams::AxisPosLeft, leftparams );
00330 }
00331
00332 }
00333
00334 #include "kchartWizardLabelsLegendPage.moc"