20#include "kchartHeaderFooterConfigPage.h"
21#include "kchartHeaderFooterConfigPage.moc"
23#include <tdeapplication.h>
28#include <tqlineedit.h>
29#include <tqbuttongroup.h>
30#include <tqwhatsthis.h>
31#include <tdefontdialog.h>
33#include "kchart_params.h"
38KChartHeaderFooterConfigPage::KChartHeaderFooterConfigPage( KChartParams* params,
40 TQWidget( parent ),_params( params )
42 TQGridLayout* layout =
new TQGridLayout(
this, 4, 3 );
43 layout->setSpacing( KDialog::spacingHint() );
44 layout->setMargin( KDialog::marginHint() );
46 TQLabel *lab=
new TQLabel(i18n(
"Title:"),
this);
47 TQWhatsThis::add(lab, i18n(
"Write here the title of your chart if you want one. The title will be centered on top above your chart."));
48 layout->addWidget(lab,0,0);
50 titleEdit=
new TQLineEdit(
this);
51 TQWhatsThis::add(titleEdit, i18n(
"Write here the title of your chart if you want one. The title will be centered on top above your chart."));
52 layout->addWidget(titleEdit,0,1);
54 titleColorButton=
new KColorButton(
this);
55 TQWhatsThis::add(titleColorButton, i18n(
"Click on this button to choose the color for the title font."));
56 layout->addWidget(titleColorButton,0,2);
58 titleFontButton=
new TQPushButton(i18n(
"Font..."),
this);
59 TQWhatsThis::add(titleFontButton, i18n(
"Click on this button to choose the font family, style and size for the title."));
60 layout->addWidget(titleFontButton,0,3);
61 connect( titleFontButton, TQ_SIGNAL(clicked()),
this, TQ_SLOT(changeTitleFont()));
63 lab=
new TQLabel(i18n(
"Subtitle:"),
this);
64 TQWhatsThis::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."));
65 layout->addWidget(lab,1,0);
67 subtitleEdit=
new TQLineEdit(
this);
68 TQWhatsThis::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."));
69 layout->addWidget(subtitleEdit,1,1);
71 subtitleColorButton=
new KColorButton(
this);
72 TQWhatsThis::add(subtitleColorButton, i18n(
"Click on this button to choose the color for the subtitle font."));
73 layout->addWidget(subtitleColorButton,1,2);
75 subtitleFontButton=
new TQPushButton(i18n(
"Font..."),
this);
76 TQWhatsThis::add(subtitleFontButton, i18n(
"Click on this button to choose the font family, style and size for the subtitle."));
77 layout->addWidget(subtitleFontButton,1,3);
78 connect( subtitleFontButton, TQ_SIGNAL(clicked()),
this, TQ_SLOT(changeSubtitleFont()));
80 lab=
new TQLabel(i18n(
"Footer:"),
this);
81 TQWhatsThis::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."));
82 layout->addWidget(lab,2,0);
84 footerEdit=
new TQLineEdit(
this);
85 TQWhatsThis::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."));
86 layout->addWidget(footerEdit,2,1);
88 footerColorButton=
new KColorButton(
this);
89 TQWhatsThis::add(footerColorButton, i18n(
"Click on this button to choose the color for the footer font."));
90 layout->addWidget(footerColorButton,2,2);
92 footerFontButton=
new TQPushButton(i18n(
"Font..."),
this);
93 TQWhatsThis::add(footerFontButton, i18n(
"Click on this button to choose the font family, style and size for the footer."));
94 connect( footerFontButton, TQ_SIGNAL(clicked()),
this, TQ_SLOT(changeFooterFont()));
95 layout->addWidget(footerFontButton,2,3);
97 layout->addItem(
new TQSpacerItem( 5, 5, TQSizePolicy::Minimum, TQSizePolicy::Expanding ), 3, 0 );
102void KChartHeaderFooterConfigPage::init()
104 titleColorButton->setColor(_params->headerFooterColor( KDChartParams::HdFtPosHeader ) );
105 subtitleColorButton->setColor(_params->headerFooterColor( KDChartParams::HdFtPosHeader2 ));
106 footerColorButton->setColor(_params->headerFooterColor( KDChartParams::HdFtPosFooter ) );
107 titleEdit->setText(_params->header1Text());
108 subtitleEdit->setText(_params->header2Text());
109 footerEdit->setText(_params->footerText());
112 titleFont = _params->header1Font();
113 titleFontIsRelative = _params->headerFooterFontUseRelSize(KDChartParams::HdFtPosHeader)
116 if( TQButton::On == titleFontIsRelative )
117 titleFont.setPointSize( _params->headerFooterFontRelSize(KDChartParams::HdFtPosHeader) );
119 subtitleFont = _params->header2Font();
120 subtitleFontIsRelative = _params->headerFooterFontUseRelSize(KDChartParams::HdFtPosHeader2)
123 if( TQButton::On == subtitleFontIsRelative )
124 subtitleFont.setPointSize( _params->headerFooterFontRelSize(KDChartParams::HdFtPosHeader2) );
126 footerFont = _params->footerFont();
127 footerFontIsRelative = _params->headerFooterFontUseRelSize(KDChartParams::HdFtPosFooter)
130 if( TQButton::On == footerFontIsRelative )
131 footerFont.setPointSize( _params->headerFooterFontRelSize(KDChartParams::HdFtPosFooter) );
135void KChartHeaderFooterConfigPage::apply()
137 _params->setHeaderFooterColor( KDChartParams::HdFtPosHeader,titleColorButton->color() );
138 _params->setHeaderFooterColor( KDChartParams::HdFtPosHeader2,subtitleColorButton->color() );
139 _params->setHeaderFooterColor( KDChartParams::HdFtPosFooter, footerColorButton->color() );
142 _params->setHeader1Text(titleEdit->text());
143 _params->setHeader2Text(subtitleEdit->text());
144 _params->setFooterText(footerEdit->text());
147 _params->setHeaderFooterFont( KDChartParams::HdFtPosHeader, titleFont,
149 titleFont.pointSize() );
150 _params->setHeaderFooterFont( KDChartParams::HdFtPosHeader2, subtitleFont,
151 subtitleFontIsRelative,
152 subtitleFont.pointSize() );
153 _params->setHeaderFooterFont( KDChartParams::HdFtPosFooter, footerFont,
154 footerFontIsRelative,
155 footerFont.pointSize() );
158void KChartHeaderFooterConfigPage::changeTitleFont()
160 TQButton::ToggleState state = titleFontIsRelative;
161 if ( TDEFontDialog::getFont( titleFont,
false,
this,
true,&state ) != TQDialog::Rejected
162 && TQButton::NoChange != state )
163 titleFontIsRelative = state;
166void KChartHeaderFooterConfigPage::changeSubtitleFont()
168 TQButton::ToggleState state = subtitleFontIsRelative;
169 if ( TDEFontDialog::getFont( subtitleFont,
false,
this,
true,&state ) != TQDialog::Rejected
170 && TQButton::NoChange != state )
171 subtitleFontIsRelative = state;
174void KChartHeaderFooterConfigPage::changeFooterFont()
176 TQButton::ToggleState state = footerFontIsRelative;
177 if ( TDEFontDialog::getFont( footerFont,
false,
this,
true,&state ) != TQDialog::Rejected
178 && TQButton::NoChange != state )
179 footerFontIsRelative = state;