27 #include <tqcheckbox.h>
29 #include <tqgroupbox.h>
30 #include <tqspinbox.h>
31 #include <tqtabwidget.h>
32 #include <tqwhatsthis.h>
35 #include <tdeglobal.h>
36 #include <tdeglobalsettings.h>
37 #include <tdelocale.h>
38 #include <kiconloader.h>
39 #include <tdeconfig.h>
40 #include <tdefontdialog.h>
41 #include <kpushbutton.h>
43 #include "colorlistbox.h"
45 #include "configurecardviewdialog.h"
50 ConfigureCardViewWidget::ConfigureCardViewWidget( TDEABC::AddressBook *ab, TQWidget *parent,
54 TQWidget *page = addPage( i18n(
"Look & Feel" ), TQString(),
55 DesktopIcon(
"preferences-desktop" ) );
59 ConfigureCardViewWidget::~ConfigureCardViewWidget()
67 mAdvancedPage->restoreSettings( config );
74 mAdvancedPage->saveSettings( config );
79 CardViewLookNFeelPage::CardViewLookNFeelPage( TQWidget *parent,
const char *name )
80 : TQVBox( parent, name )
85 CardViewLookNFeelPage::~CardViewLookNFeelPage()
89 void CardViewLookNFeelPage::restoreSettings( TDEConfig *config )
92 cbEnableCustomColors->setChecked( config->readBoolEntry(
"EnableCustomColors",
false ) );
94 c = TDEGlobalSettings::baseColor();
95 lbColors->insertItem(
new ColorListItem( i18n(
"Background Color"),
96 config->readColorEntry(
"BackgroundColor", &c ) ) );
97 c = colorGroup().foreground();
98 lbColors->insertItem(
new ColorListItem( i18n(
"Text Color"),
99 config->readColorEntry(
"TextColor", &c ) ) );
100 c = colorGroup().button();
101 lbColors->insertItem(
new ColorListItem( i18n(
"Header, Border & Separator Color"),
102 config->readColorEntry(
"HeaderColor", &c ) ) );
103 c = colorGroup().buttonText();
104 lbColors->insertItem(
new ColorListItem( i18n(
"Header Text Color"),
105 config->readColorEntry(
"HeaderTextColor", &c ) ) );
106 c = colorGroup().highlight();
107 lbColors->insertItem(
new ColorListItem( i18n(
"Highlight Color"),
108 config->readColorEntry(
"HighlightColor", &c ) ) );
109 c = colorGroup().highlightedText();
110 lbColors->insertItem(
new ColorListItem( i18n(
"Highlighted Text Color"),
111 config->readColorEntry(
"HighlightedTextColor", &c ) ) );
117 updateFontLabel( config->readFontEntry(
"TextFont", &fnt ), (TQLabel*)lTextFont );
119 updateFontLabel( config->readFontEntry(
"HeaderFont", &fnt ), (TQLabel*)lHeaderFont );
120 cbEnableCustomFonts->setChecked( config->readBoolEntry(
"EnableCustomFonts",
false ) );
124 sbMargin->setValue( config->readNumEntry(
"ItemMargin", 0 ) );
125 sbSpacing->setValue( config->readNumEntry(
"ItemSpacing", 10 ) );
126 sbSepWidth->setValue( config->readNumEntry(
"SeparatorWidth", 2 ) );
127 cbDrawSeps->setChecked( config->readBoolEntry(
"DrawSeparators",
true ) );
128 cbDrawBorders->setChecked( config->readBoolEntry(
"DrawBorder",
true ) );
131 cbShowFieldLabels->setChecked( config->readBoolEntry(
"DrawFieldLabels",
false ) );
132 cbShowEmptyFields->setChecked( config->readBoolEntry(
"ShowEmptyFields",
false ) );
135 void CardViewLookNFeelPage::saveSettings( TDEConfig *config )
138 config->writeEntry(
"EnableCustomColors", cbEnableCustomColors->isChecked() );
139 if ( cbEnableCustomColors->isChecked() )
141 config->writeEntry(
"BackgroundColor", lbColors->color( 0 ) );
142 config->writeEntry(
"TextColor", lbColors->color( 1 ) );
143 config->writeEntry(
"HeaderColor", lbColors->color( 2 ) );
144 config->writeEntry(
"HeaderTextColor", lbColors->color( 3 ) );
145 config->writeEntry(
"HighlightColor", lbColors->color( 4 ) );
146 config->writeEntry(
"HighlightedTextColor", lbColors->color( 5 ) );
149 config->writeEntry(
"EnableCustomFonts", cbEnableCustomFonts->isChecked() );
150 if ( cbEnableCustomFonts->isChecked() )
152 config->writeEntry(
"TextFont", lTextFont->font() );
153 config->writeEntry(
"HeaderFont", lHeaderFont->font() );
156 config->writeEntry(
"ItemMargin", sbMargin->value() );
157 config->writeEntry(
"ItemSpacing", sbSpacing->value() );
158 config->writeEntry(
"SeparatorWidth", sbSepWidth->value() );
159 config->writeEntry(
"DrawBorder", cbDrawBorders->isChecked());
160 config->writeEntry(
"DrawSeparators", cbDrawSeps->isChecked());
163 config->writeEntry(
"DrawFieldLabels", cbShowFieldLabels->isChecked());
164 config->writeEntry(
"ShowEmptyFields", cbShowEmptyFields->isChecked());
167 void CardViewLookNFeelPage::setTextFont()
169 TQFont f( lTextFont->font() );
170 if ( TDEFontDialog::getFont( f,
false,
this ) == TQDialog::Accepted )
171 updateFontLabel( f, lTextFont );
174 void CardViewLookNFeelPage::setHeaderFont()
176 TQFont f( lHeaderFont->font() );
177 if ( TDEFontDialog::getFont( f,
false,
this ) == TQDialog::Accepted )
178 updateFontLabel( f, lHeaderFont );
181 void CardViewLookNFeelPage::enableFonts()
183 vbFonts->setEnabled( cbEnableCustomFonts->isChecked() );
186 void CardViewLookNFeelPage::enableColors()
188 lbColors->setEnabled( cbEnableCustomColors->isChecked() );
191 void CardViewLookNFeelPage::initGUI()
193 int spacing = KDialog::spacingHint();
194 int margin = KDialog::marginHint();
196 TQTabWidget *tabs =
new TQTabWidget(
this );
199 TQVBox *loTab =
new TQVBox(
this,
"layouttab" );
201 loTab->setSpacing( spacing );
202 loTab->setMargin( margin );
204 TQGroupBox *gbGeneral =
new TQGroupBox( 1, TQt::Horizontal, i18n(
"General"), loTab );
206 cbDrawSeps =
new TQCheckBox( i18n(
"Draw &separators"), gbGeneral );
208 TQHBox *hbSW =
new TQHBox( gbGeneral );
209 TQLabel *lSW =
new TQLabel( i18n(
"Separator &width:"), hbSW );
210 sbSepWidth =
new TQSpinBox( 1, 50, 1, hbSW );
211 lSW->setBuddy( sbSepWidth);
213 TQHBox *hbPadding =
new TQHBox( gbGeneral );
214 TQLabel *lSpacing =
new TQLabel( i18n(
"&Padding:"), hbPadding );
215 sbSpacing =
new TQSpinBox( 0, 100, 1, hbPadding );
216 lSpacing->setBuddy( sbSpacing );
218 TQGroupBox *gbCards =
new TQGroupBox( 1, TQt::Horizontal, i18n(
"Cards"), loTab );
220 TQHBox *hbMargin =
new TQHBox( gbCards );
221 TQLabel *lMargin =
new TQLabel( i18n(
"&Margin:"), hbMargin );
222 sbMargin =
new TQSpinBox( 0, 100, 1, hbMargin );
223 lMargin->setBuddy( sbMargin );
225 cbDrawBorders =
new TQCheckBox( i18n(
"Draw &borders"), gbCards );
227 loTab->setStretchFactor(
new TQWidget( loTab ), 1 );
229 TQWhatsThis::add( sbMargin, i18n(
230 "The item margin is the distance (in pixels) between the item edge and the item data. Most noticeably, "
231 "incrementing the item margin will add space between the focus rectangle and the item data."
233 TQWhatsThis::add( lMargin, TQWhatsThis::textFor( sbMargin ) );
234 TQWhatsThis::add( sbSpacing, i18n(
235 "The item spacing decides the distance (in pixels) between the items and anything else: the view "
236 "borders, other items or column separators."
238 TQWhatsThis::add( lSpacing, TQWhatsThis::textFor( sbSpacing ) );
239 TQWhatsThis::add( sbSepWidth, i18n(
"Sets the width of column separators") );
240 TQWhatsThis::add( lSW, TQWhatsThis::textFor( sbSepWidth ) );
242 tabs->addTab( loTab, i18n(
"&Layout") );
245 TQVBox *colorTab =
new TQVBox(
this,
"colortab" );
246 colorTab->setSpacing( spacing );
247 colorTab->setMargin( spacing );
248 cbEnableCustomColors =
new TQCheckBox( i18n(
"&Enable custom colors"), colorTab );
249 connect( cbEnableCustomColors, TQ_SIGNAL(clicked()),
this, TQ_SLOT(enableColors()) );
250 lbColors =
new ColorListBox( colorTab );
251 tabs->addTab( colorTab, i18n(
"&Colors") );
253 TQWhatsThis::add( cbEnableCustomColors, i18n(
254 "If custom colors is enabled, you may choose the colors for the view below. "
255 "Otherwise colors from your current TDE color scheme are used."
257 TQWhatsThis::add( lbColors, i18n(
258 "Double click or press RETURN on a item to select a color for the related strings in the view."
262 TQVBox *fntTab =
new TQVBox(
this,
"fonttab" );
264 fntTab->setSpacing( spacing );
265 fntTab->setMargin( spacing );
267 cbEnableCustomFonts =
new TQCheckBox( i18n(
"&Enable custom fonts"), fntTab );
268 connect( cbEnableCustomFonts, TQ_SIGNAL(clicked()),
this, TQ_SLOT(enableFonts()) );
270 vbFonts =
new TQWidget( fntTab );
271 TQGridLayout *gFnts =
new TQGridLayout( vbFonts, 2, 3 );
272 gFnts->setSpacing( spacing );
273 gFnts->setAutoAdd(
true );
274 gFnts->setColStretch( 1, 1 );
275 TQLabel *lTFnt =
new TQLabel( i18n(
"&Text font:"), vbFonts );
276 lTextFont =
new TQLabel( vbFonts );
277 lTextFont->setFrameStyle( TQFrame::Panel|TQFrame::Sunken );
278 btnFont =
new KPushButton( i18n(
"Choose..."), vbFonts );
279 lTFnt->setBuddy( btnFont );
280 connect( btnFont, TQ_SIGNAL(clicked()),
this, TQ_SLOT(setTextFont()) );
282 TQLabel *lHFnt =
new TQLabel( i18n(
"&Header font:"), vbFonts );
283 lHeaderFont =
new TQLabel( vbFonts );
284 lHeaderFont->setFrameStyle( TQFrame::Panel|TQFrame::Sunken );
285 btnHeaderFont =
new KPushButton( i18n(
"Choose..."), vbFonts );
286 lHFnt->setBuddy( btnHeaderFont );
287 connect( btnHeaderFont, TQ_SIGNAL(clicked()),
this, TQ_SLOT(setHeaderFont()) );
289 fntTab->setStretchFactor(
new TQWidget( fntTab ), 1 );
291 TQWhatsThis::add( cbEnableCustomFonts, i18n(
292 "If custom fonts are enabled, you may choose which fonts to use for this view below. "
293 "Otherwise the default TDE font will be used, in bold style for the header and "
294 "normal style for the data."
297 tabs->addTab( fntTab, i18n(
"&Fonts") );
300 TQVBox *behaviourTab =
new TQVBox(
this );
301 behaviourTab->setMargin( margin );
302 behaviourTab->setSpacing( spacing );
304 cbShowEmptyFields =
new TQCheckBox( i18n(
"Show &empty fields"), behaviourTab );
305 cbShowFieldLabels =
new TQCheckBox( i18n(
"Show field &labels"), behaviourTab );
307 behaviourTab->setStretchFactor(
new TQWidget( behaviourTab ), 1 );
309 tabs->addTab( behaviourTab, i18n(
"Be&havior") );
313 void CardViewLookNFeelPage::updateFontLabel( TQFont fnt, TQLabel *l )
316 l->setText( TQString( fnt.family() +
" %1" ).arg( fnt.pointSize() ) );
319 #include "configurecardviewdialog.moc"
Card View Advanced LookNFeel settings widget: this is a tabbed widget with 3 tabs: Fonts text font he...