kchart

kchartHeaderFooterConfigPage.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001,2002,2003,2004 Laurent Montel <montel@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "kchartHeaderFooterConfigPage.h"
00021 #include "kchartHeaderFooterConfigPage.moc"
00022 
00023 #include <kapplication.h>
00024 #include <kdialog.h>
00025 #include <klocale.h>
00026 #include <qlayout.h>
00027 #include <qlabel.h>
00028 #include <qlineedit.h>
00029 #include <qbuttongroup.h>
00030 #include <qwhatsthis.h>
00031 #include <kfontdialog.h>
00032 
00033 #include "kchart_params.h"
00034 
00035 namespace KChart
00036 {
00037 
00038 KChartHeaderFooterConfigPage::KChartHeaderFooterConfigPage( KChartParams* params,
00039                                                       QWidget* parent ) :
00040     QWidget( parent ),_params( params )
00041 {
00042     QGridLayout* layout = new QGridLayout( this, 4, 3 );
00043     layout->setSpacing( KDialog::spacingHint() );
00044     layout->setMargin( KDialog::marginHint() );
00045 
00046     QLabel *lab=new QLabel(i18n("Title:"), this);
00047     QWhatsThis::add(lab, i18n("Write here the title of your chart if you want one. The title will be centered on top above your chart."));
00048     layout->addWidget(lab,0,0);
00049 
00050     titleEdit=new QLineEdit(this);
00051     QWhatsThis::add(titleEdit, i18n("Write here the title of your chart if you want one. The title will be centered on top above your chart."));
00052     layout->addWidget(titleEdit,0,1);
00053 
00054     titleColorButton=new KColorButton(this);
00055     QWhatsThis::add(titleColorButton, i18n("Click on this button to choose the color for the title font."));
00056     layout->addWidget(titleColorButton,0,2);
00057 
00058     titleFontButton=new QPushButton(i18n("Font..."),this);
00059     QWhatsThis::add(titleFontButton, i18n("Click on this button to choose the font family, style and size for the title."));
00060     layout->addWidget(titleFontButton,0,3);
00061     connect( titleFontButton, SIGNAL(clicked()), this, SLOT(changeTitleFont()));
00062 
00063     lab=new QLabel(i18n("Subtitle:"),this);
00064     QWhatsThis::add(lab, i18n("Write here the subtitle of your chart if you want one. The subtitle will be centered on top just below the title."));
00065     layout->addWidget(lab,1,0);
00066 
00067     subtitleEdit=new QLineEdit(this);
00068     QWhatsThis::add(subtitleEdit, i18n("Write here the subtitle of your chart if you want one. The subtitle will be centered on top just below the title."));
00069     layout->addWidget(subtitleEdit,1,1);
00070 
00071     subtitleColorButton=new KColorButton(this);
00072     QWhatsThis::add(subtitleColorButton, i18n("Click on this button to choose the color for the subtitle font."));
00073     layout->addWidget(subtitleColorButton,1,2);
00074 
00075     subtitleFontButton=new QPushButton(i18n("Font..."),this);
00076     QWhatsThis::add(subtitleFontButton, i18n("Click on this button to choose the font family, style and size for the subtitle."));
00077     layout->addWidget(subtitleFontButton,1,3);
00078     connect( subtitleFontButton, SIGNAL(clicked()), this, SLOT(changeSubtitleFont()));
00079 
00080     lab=new QLabel(i18n("Footer:"),this);
00081     QWhatsThis::add(lab, i18n("Write here the footer of your chart if you want one. The footer will be centered at the bottom just below your chart."));
00082     layout->addWidget(lab,2,0);
00083 
00084     footerEdit=new QLineEdit(this);
00085     QWhatsThis::add(footerEdit, i18n("Write here the subtitle of your chart if you want one. The subtitle will be centered on top just below the title."));
00086     layout->addWidget(footerEdit,2,1);
00087 
00088     footerColorButton=new KColorButton(this);
00089     QWhatsThis::add(footerColorButton, i18n("Click on this button to choose the color for the footer font."));
00090     layout->addWidget(footerColorButton,2,2);
00091 
00092     footerFontButton=new QPushButton(i18n("Font..."),this);
00093     QWhatsThis::add(footerFontButton, i18n("Click on this button to choose the font family, style and size for the footer."));
00094     connect( footerFontButton, SIGNAL(clicked()), this, SLOT(changeFooterFont()));
00095     layout->addWidget(footerFontButton,2,3);
00096 
00097     layout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ), 3, 0 );
00098 
00099     layout->activate();
00100 }
00101 
00102 void KChartHeaderFooterConfigPage::init()
00103 {
00104     titleColorButton->setColor(_params->headerFooterColor( KDChartParams::HdFtPosHeader ) );
00105     subtitleColorButton->setColor(_params->headerFooterColor( KDChartParams::HdFtPosHeader2 ));
00106     footerColorButton->setColor(_params->headerFooterColor( KDChartParams::HdFtPosFooter ) );
00107     titleEdit->setText(_params->header1Text());
00108     subtitleEdit->setText(_params->header2Text());
00109     footerEdit->setText(_params->footerText());
00110 
00111 
00112     titleFont = _params->header1Font();
00113     titleFontIsRelative = _params->headerFooterFontUseRelSize(KDChartParams::HdFtPosHeader)
00114                           ? QButton::On
00115                           : QButton::Off;
00116     if( QButton::On == titleFontIsRelative )
00117         titleFont.setPointSize( _params->headerFooterFontRelSize(KDChartParams::HdFtPosHeader) );
00118 
00119     subtitleFont = _params->header2Font();
00120     subtitleFontIsRelative = _params->headerFooterFontUseRelSize(KDChartParams::HdFtPosHeader2)
00121                           ? QButton::On
00122                           : QButton::Off;
00123     if( QButton::On == subtitleFontIsRelative )
00124         subtitleFont.setPointSize( _params->headerFooterFontRelSize(KDChartParams::HdFtPosHeader2) );
00125 
00126     footerFont = _params->footerFont();
00127     footerFontIsRelative = _params->headerFooterFontUseRelSize(KDChartParams::HdFtPosFooter)
00128                           ? QButton::On
00129                           : QButton::Off;
00130     if( QButton::On == footerFontIsRelative )
00131         footerFont.setPointSize( _params->headerFooterFontRelSize(KDChartParams::HdFtPosFooter) );
00132 }
00133 
00134 
00135 void KChartHeaderFooterConfigPage::apply()
00136 {
00137     _params->setHeaderFooterColor( KDChartParams::HdFtPosHeader,titleColorButton->color() );
00138     _params->setHeaderFooterColor( KDChartParams::HdFtPosHeader2,subtitleColorButton->color() );
00139     _params->setHeaderFooterColor( KDChartParams::HdFtPosFooter, footerColorButton->color() );
00140 
00141 
00142     _params->setHeader1Text(titleEdit->text());
00143     _params->setHeader2Text(subtitleEdit->text());
00144     _params->setFooterText(footerEdit->text());
00145 
00146 
00147     _params->setHeaderFooterFont( KDChartParams::HdFtPosHeader, titleFont,
00148                                   titleFontIsRelative,
00149                                   titleFont.pointSize() );
00150     _params->setHeaderFooterFont( KDChartParams::HdFtPosHeader2, subtitleFont,
00151                                   subtitleFontIsRelative,
00152                                   subtitleFont.pointSize() );
00153     _params->setHeaderFooterFont( KDChartParams::HdFtPosFooter, footerFont,
00154                                   footerFontIsRelative,
00155                                   footerFont.pointSize() );
00156 }
00157 
00158 void KChartHeaderFooterConfigPage::changeTitleFont()
00159 {
00160     QButton::ToggleState state = titleFontIsRelative;
00161     if (    KFontDialog::getFont( titleFont,false,this, true,&state ) != QDialog::Rejected
00162             && QButton::NoChange != state )
00163         titleFontIsRelative = state;
00164 }
00165 
00166 void KChartHeaderFooterConfigPage::changeSubtitleFont()
00167 {
00168     QButton::ToggleState state = subtitleFontIsRelative;
00169     if (    KFontDialog::getFont( subtitleFont,false,this, true,&state ) != QDialog::Rejected
00170             && QButton::NoChange != state )
00171         subtitleFontIsRelative = state;
00172 }
00173 
00174 void KChartHeaderFooterConfigPage::changeFooterFont()
00175 {
00176     QButton::ToggleState state = footerFontIsRelative;
00177     if (    KFontDialog::getFont( footerFont,false,this, true,&state ) != QDialog::Rejected
00178             && QButton::NoChange != state )
00179         footerFontIsRelative = state;
00180 }
00181 
00182 }  //KChart namespace
KDE Home | KDE Accessibility Home | Description of Access Keys