23 #include "fonthelpers_p.h"
24 #include "sampleedit_p.h"
26 #include <QtGui/QCheckBox>
27 #include <QtGui/QLabel>
28 #include <QtGui/QLayout>
29 #include <QtGui/QSplitter>
30 #include <QtGui/QScrollBar>
31 #include <QtGui/QFontDatabase>
32 #include <QtGui/QGroupBox>
49 #define I18NC_NOX i18nc
54 for(
int i=0; i<list->count(); i++ )
56 int itemWidth = list->visualItemRect(list->item(i)).width();
58 itemWidth += list->fontMetrics().width(
' ') * 2;
59 w = qMax(w,itemWidth);
61 if( w == 0 ) { w = 40; }
62 w += list->frameWidth() * 2;
63 w += list->verticalScrollBar()->sizeHint().width();
69 int w = list->count() > 0 ? list->visualItemRect(list->item(0)).height() :
70 list->fontMetrics().lineSpacing();
72 if( w < 0 ) { w = 10; }
73 if( numVisibleEntry <= 0 ) { numVisibleEntry = 4; }
74 return ( w * numVisibleEntry + 2 * list->frameWidth() );
82 class KFontChooser::Private
88 m_palette.setColor(QPalette::Active, QPalette::Text, Qt::black);
89 m_palette.setColor(QPalette::Active, QPalette::Base, Qt::white);
90 signalsAllowed =
true;
100 void fillFamilyListBox(
bool onlyFixedFonts =
false);
101 int nearestSizeRow(qreal val,
bool customize);
103 qreal setupSizeListBox(
const QString& family,
const QString& style);
108 void _k_toggled_checkbox();
109 void _k_family_chosen_slot(
const QString&);
110 void _k_size_chosen_slot(
const QString&);
111 void _k_style_chosen_slot(
const QString&);
112 void _k_displaySample(
const QFont &
font);
113 void _k_showXLFDArea(
bool);
114 void _k_size_value_slot(
double);
119 bool signalsAllowed:1;
125 SampleEdit *sampleEdit;
130 QCheckBox *familyCheckbox;
131 QCheckBox *styleCheckbox;
132 QCheckBox *sizeCheckbox;
137 QCheckBox *sizeIsRelativeCheckBox;
157 const DisplayFlags& flags,
160 Qt::CheckState *sizeIsRelativeState )
165 setWhatsThis(
i18nc(
"@info:whatsthis",
"Here you can choose the font to be used." ));
169 QVBoxLayout *topLayout =
new QVBoxLayout(
this );
170 topLayout->setMargin( 0 );
176 QSplitter *splitter =
new QSplitter(Qt::Vertical,
this);
177 splitter->setChildrenCollapsible(
false);
178 topLayout->addWidget(splitter);
183 QGridLayout *gridLayout;
188 splitter->addWidget(page);
189 gridLayout =
new QGridLayout( page );
195 splitter->addWidget(page);
196 gridLayout =
new QGridLayout( page );
197 gridLayout->setMargin( 0 );
203 QHBoxLayout *familyLayout =
new QHBoxLayout();
204 familyLayout->addSpacing( checkBoxGap );
206 d->familyCheckbox =
new QCheckBox(
i18nc(
"@option:check",
"Font"), page);
207 connect(d->familyCheckbox, SIGNAL(toggled(
bool)),
208 this, SLOT(_k_toggled_checkbox()));
209 familyLayout->addWidget(d->familyCheckbox, 0, Qt::AlignLeft);
210 d->familyCheckbox->setWhatsThis(
i18nc(
"@info:whatsthis",
"Enable this checkbox to change the font family settings."));
211 d->familyCheckbox->setToolTip(
i18nc(
"@info:tooltip",
"Change font family?") );
214 d->familyCheckbox = 0;
215 d->familyLabel =
new QLabel(
i18nc(
"@label",
"Font:"), page );
216 familyLayout->addWidget(d->familyLabel, 1, Qt::AlignLeft);
218 gridLayout->addLayout(familyLayout, row, 0 );
220 QHBoxLayout *styleLayout =
new QHBoxLayout();
221 if ( flags & ShowDifferences ) {
222 d->styleCheckbox =
new QCheckBox(
i18nc(
"@option:check",
"Font style"), page);
223 connect(d->styleCheckbox, SIGNAL(toggled(
bool)),
224 this, SLOT(_k_toggled_checkbox()));
225 styleLayout->addWidget(d->styleCheckbox, 0, Qt::AlignLeft);
226 d->styleCheckbox->setWhatsThis(
i18nc(
"@info:whatsthis",
"Enable this checkbox to change the font style settings."));
227 d->styleCheckbox->setToolTip(
i18nc(
"@info:tooltip",
"Change font style?"));
230 d->styleCheckbox = 0;
231 d->styleLabel =
new QLabel(
i18n(
"Font style:"), page );
232 styleLayout->addWidget(d->styleLabel, 1, Qt::AlignLeft);
234 styleLayout->addSpacing( checkBoxGap );
235 gridLayout->addLayout(styleLayout, row, 1 );
237 QHBoxLayout *sizeLayout =
new QHBoxLayout();
238 if ( flags & ShowDifferences ) {
239 d->sizeCheckbox =
new QCheckBox(
i18nc(
"@option:check",
"Size"),page);
240 connect(d->sizeCheckbox, SIGNAL(toggled(
bool)),
241 this, SLOT(_k_toggled_checkbox()));
242 sizeLayout->addWidget(d->sizeCheckbox, 0, Qt::AlignLeft);
243 d->sizeCheckbox->setWhatsThis(
i18nc(
"@info:whatsthis",
"Enable this checkbox to change the font size settings."));
244 d->sizeCheckbox->setToolTip(
i18nc(
"@info:tooltip",
"Change font size?"));
248 d->sizeLabel =
new QLabel(
i18nc(
"@label:listbox Font size",
"Size:"), page );
249 sizeLayout->addWidget(d->sizeLabel, 1, Qt::AlignLeft);
251 sizeLayout->addSpacing( checkBoxGap );
252 sizeLayout->addSpacing( checkBoxGap );
253 gridLayout->addLayout(sizeLayout, row, 2 );
261 d->familyListBox->setEnabled( flags ^ ShowDifferences );
262 gridLayout->addWidget( d->familyListBox, row, 0 );
263 QString fontFamilyWhatsThisText (
264 i18nc(
"@info:whatsthis",
"Here you can choose the font family to be used." ));
265 d->familyListBox->setWhatsThis(fontFamilyWhatsThisText );
267 if ( flags & ShowDifferences ) {
268 d->familyCheckbox->setWhatsThis(fontFamilyWhatsThisText );
270 d->familyLabel->setWhatsThis(fontFamilyWhatsThisText );
273 connect(d->familyListBox, SIGNAL(currentTextChanged(
QString)),
274 this, SLOT(_k_family_chosen_slot(
QString)));
275 if ( !fontList.isEmpty() ) {
276 d->setFamilyBoxItems(fontList);
280 d->fillFamilyListBox( flags & FixedFontsOnly );
284 d->familyListBox->setMinimumHeight(
288 d->styleListBox->setEnabled( flags ^ ShowDifferences );
289 gridLayout->addWidget(d->styleListBox, row, 1);
290 d->styleListBox->setWhatsThis(
i18nc(
"@info:whatsthis",
"Here you can choose the font style to be used." ));
291 if ( flags & ShowDifferences ) {
292 ((
QWidget *)d->styleCheckbox)->setWhatsThis(fontFamilyWhatsThisText );
294 ((
QWidget *)d->styleLabel)->setWhatsThis( fontFamilyWhatsThisText );
298 d->styleListBox->addItem(
I18NC_NOX(
"QFontDatabase",
"Normal"));
299 d->styleListBox->addItem(
i18nc(
"@item font",
"Italic"));
300 d->styleListBox->addItem(
i18nc(
"@item font",
"Oblique"));
301 d->styleListBox->addItem(
i18nc(
"@item font",
"Bold"));
302 d->styleListBox->addItem(
i18nc(
"@item font",
"Bold Italic"));
304 d->styleListBox->setMinimumHeight(
307 connect(d->styleListBox, SIGNAL(currentTextChanged(
QString)),
308 this, SLOT(_k_style_chosen_slot(
QString)));
313 d->sizeOfFont->setMinimum(4);
314 d->sizeOfFont->setMaximum(999);
315 d->sizeOfFont->setDecimals(1);
316 d->sizeOfFont->setSingleStep(1);
317 d->sizeOfFont->setSliderEnabled(
false);
319 d->sizeListBox->setEnabled( flags ^ ShowDifferences );
320 d->sizeOfFont->setEnabled( flags ^ ShowDifferences );
321 if( sizeIsRelativeState ) {
323 i18nc(
"@item font size",
"Relative");
324 QString sizeIsRelativeCBToolTipText =
325 i18n(
"Font size<br /><i>fixed</i> or <i>relative</i><br />to environment");
326 QString sizeIsRelativeCBWhatsThisText =
327 i18n(
"Here you can switch between fixed font size and font size "
328 "to be calculated dynamically and adjusted to changing "
329 "environment (e.g. widget dimensions, paper size)." );
330 d->sizeIsRelativeCheckBox =
new QCheckBox( sizeIsRelativeCBText,
332 d->sizeIsRelativeCheckBox->setTristate( flags & ShowDifferences );
333 QGridLayout *sizeLayout2 =
new QGridLayout();
335 gridLayout->addLayout(sizeLayout2, row, 2);
336 sizeLayout2->setColumnStretch( 1, 1 );
337 sizeLayout2->addWidget( d->sizeOfFont, 0, 0, 1, 2);
338 sizeLayout2->addWidget(d->sizeListBox, 1,0, 1,2);
339 sizeLayout2->addWidget(d->sizeIsRelativeCheckBox, 2, 0, Qt::AlignLeft);
340 d->sizeIsRelativeCheckBox->setWhatsThis(sizeIsRelativeCBWhatsThisText );
341 d->sizeIsRelativeCheckBox->setToolTip( sizeIsRelativeCBToolTipText );
344 d->sizeIsRelativeCheckBox = 0L;
345 QGridLayout *sizeLayout2 =
new QGridLayout();
347 gridLayout->addLayout(sizeLayout2, row, 2);
348 sizeLayout2->addWidget( d->sizeOfFont, 0, 0);
349 sizeLayout2->addWidget(d->sizeListBox, 1,0);
351 QString fontSizeWhatsThisText =
352 i18n(
"Here you can choose the font size to be used." );
353 d->sizeListBox->setWhatsThis(fontSizeWhatsThisText );
355 if ( flags & ShowDifferences ) {
356 ((
QWidget *)d->sizeCheckbox)->setWhatsThis(fontSizeWhatsThisText );
358 ((
QWidget *)d->sizeLabel)->setWhatsThis( fontSizeWhatsThisText );
365 d->sizeListBox->fontMetrics().maxWidth() );
366 d->sizeListBox->setMinimumHeight(
369 connect( d->sizeOfFont, SIGNAL(valueChanged(
double)),
370 this, SLOT(_k_size_value_slot(
double)));
372 connect( d->sizeListBox, SIGNAL(currentTextChanged(
QString)),
373 this, SLOT(_k_size_chosen_slot(
QString)) );
381 d->sampleEdit =
new SampleEdit(page);
382 d->sampleEdit->setAcceptRichText(
false);
384 d->sampleEdit->setFont(tmpFont);
385 d->sampleEdit->setMinimumHeight( d->sampleEdit->fontMetrics().lineSpacing() );
391 d->sampleEdit->setTextCursor(QTextCursor(d->sampleEdit->document()));
392 QString sampleEditWhatsThisText =
393 i18n(
"This sample text illustrates the current settings. "
394 "You may edit it to test special characters." );
395 d->sampleEdit->setWhatsThis(sampleEditWhatsThisText );
398 this, SLOT(_k_displaySample(
QFont)));
400 splitter->addWidget(d->sampleEdit);
407 if( flags & DisplayFrame )
410 topLayout->addWidget(page);
411 vbox =
new QVBoxLayout( page );
412 vbox->addSpacing( fontMetrics().lineSpacing() );
417 topLayout->addWidget(page);
418 vbox =
new QVBoxLayout( page );
419 vbox->setMargin( 0 );
421 vbox->addWidget( label );
425 vbox->addWidget( d->xlfdEdit );
433 if( sizeIsRelativeState && d->sizeIsRelativeCheckBox )
437 d->_k_showXLFDArea(cg.
readEntry(QLatin1String(
"fontSelectorShowXLFD"),
false));
440 d->sizeListBox->setFocus();
450 d->m_palette.setColor( QPalette::Active, QPalette::Text, col );
451 QPalette pal = d->sampleEdit->palette();
452 pal.setColor( QPalette::Active, QPalette::Text, col );
453 d->sampleEdit->setPalette( pal );
454 QTextCursor cursor = d->sampleEdit->textCursor();
455 d->sampleEdit->selectAll();
456 d->sampleEdit->setTextColor( col );
457 d->sampleEdit->setTextCursor( cursor );
462 return d->m_palette.color( QPalette::Active, QPalette::Text );
467 d->m_palette.setColor( QPalette::Active, QPalette::Base, col );
468 QPalette pal = d->sampleEdit->palette();
469 pal.setColor( QPalette::Active, QPalette::Base, col );
470 d->sampleEdit->setPalette( pal );
475 return d->m_palette.color( QPalette::Active, QPalette::Base );
481 if( d->sizeIsRelativeCheckBox ) {
482 if( Qt::PartiallyChecked == relative )
483 d->sizeIsRelativeCheckBox->setCheckState(Qt::PartiallyChecked);
485 d->sizeIsRelativeCheckBox->setCheckState( (Qt::Checked == relative ) ? Qt::Checked : Qt::Unchecked);
491 return d->sizeIsRelativeCheckBox
492 ? d->sizeIsRelativeCheckBox->checkState()
493 : Qt::PartiallyChecked;
498 return d->sampleEdit->toPlainText();
503 d->sampleEdit->setPlainText(text);
508 d->sampleEdit->setVisible( visible );
513 return minimumSizeHint();
521 d->familyListBox->setEnabled(state);
525 d->styleListBox->setEnabled(state);
529 d->sizeListBox->setEnabled(state);
530 d->sizeOfFont->setEnabled(state);
538 d->selectedSize=aFont.pointSizeF();
539 if (d->selectedSize == -1)
540 d->selectedSize = QFontInfo(aFont).pointSizeF();
542 if( onlyFixed != d->usingFixed)
544 d->usingFixed = onlyFixed;
545 d->fillFamilyListBox(d->usingFixed);
555 if ( d->familyCheckbox && d->familyCheckbox->isChecked() ) {
559 if ( d->styleCheckbox && d->styleCheckbox->isChecked() ) {
563 if ( d->sizeCheckbox && d->sizeCheckbox->isChecked() ) {
575 void KFontChooser::Private::_k_toggled_checkbox()
577 familyListBox->setEnabled( familyCheckbox->isChecked() );
578 styleListBox->setEnabled( styleCheckbox->isChecked() );
579 sizeListBox->setEnabled( sizeCheckbox->isChecked() );
580 sizeOfFont->setEnabled( sizeCheckbox->isChecked() );
583 void KFontChooser::Private::_k_family_chosen_slot(
const QString& family)
585 if ( !signalsAllowed ) {
588 signalsAllowed =
false;
591 if (family.isEmpty()) {
592 Q_ASSERT( familyListBox->currentItem() );
593 if (familyListBox->currentItem()) {
594 currentFamily = qtFamilies[familyListBox->currentItem()->text()];
598 currentFamily = qtFamilies[family];
604 if (styles.isEmpty()) {
606 styles.append(
I18NC_NOX(
"QFontDatabase",
"Normal"));
615 foreach (
const QString &style, styles) {
619 QFont testFont = dbase.font(currentFamily, style, 10);
620 if (dbase.styleString(testFont) != style) {
621 styles.removeAll(style);
631 if (!filteredStyles.contains(fstyle)) {
632 filteredStyles.append(fstyle);
633 qtStyles.insert(fstyle, style);
634 styleIDs.insert(fstyle, styleIdentifier(testFont));
637 styleListBox->clear();
638 styleListBox->addItems(filteredStyles);
641 int listPos = filteredStyles.indexOf(selectedStyle.isEmpty() ?
I18NC_NOX(
"QFontDatabase",
"Normal") : selectedStyle);
647 for (
int i = 0; i < 2; ++i) {
648 int pos = selectedStyle.indexOf(styleIt);
651 style.replace(pos, styleIt.length(), styleOb);
652 listPos = filteredStyles.indexOf(style);
653 if (listPos >= 0)
break;
655 qSwap(styleIt, styleOb);
658 styleListBox->setCurrentRow(listPos >= 0 ? listPos : 0);
659 QString currentStyle = qtStyles[styleListBox->currentItem()->text()];
662 qreal currentSize = setupSizeListBox(currentFamily, currentStyle);
663 sizeOfFont->setValue(currentSize);
665 selFont = dbase.font(currentFamily, currentStyle,
int(currentSize));
666 if (dbase.isSmoothlyScalable(currentFamily, currentStyle) && selFont.pointSize() == floor(currentSize)) {
667 selFont.setPointSizeF(currentSize);
669 emit q->fontSelected(selFont);
671 signalsAllowed =
true;
674 void KFontChooser::Private::_k_style_chosen_slot(
const QString& style)
676 if ( !signalsAllowed ) {
679 signalsAllowed =
false;
682 QString currentFamily = qtFamilies[familyListBox->currentItem()->text()];
684 if (style.isEmpty()) {
685 currentStyle = qtStyles[styleListBox->currentItem()->text()];
687 currentStyle = qtStyles[style];
691 qreal currentSize = setupSizeListBox(currentFamily, currentStyle);
692 sizeOfFont->setValue(currentSize);
694 selFont = dbase.font(currentFamily, currentStyle,
int(currentSize));
695 if (dbase.isSmoothlyScalable(currentFamily, currentStyle) && selFont.pointSize() == floor(currentSize)) {
696 selFont.setPointSizeF(currentSize);
698 emit q->fontSelected(selFont);
700 if (!style.isEmpty()) {
701 selectedStyle = currentStyle;
704 signalsAllowed =
true;
707 void KFontChooser::Private::_k_size_chosen_slot(
const QString& size)
709 if ( !signalsAllowed ) {
713 signalsAllowed =
false;
716 if (size.isEmpty()) {
723 if (customSizeRow >= 0 && selFont.pointSizeF() != currentSize) {
724 sizeListBox->item(customSizeRow)->setText(standardSizeAtCustom);
728 sizeOfFont->setValue(currentSize);
729 selFont.setPointSizeF(currentSize);
730 emit q->fontSelected(selFont);
732 if (!size.isEmpty()) {
733 selectedSize = currentSize;
736 signalsAllowed =
true;
739 void KFontChooser::Private::_k_size_value_slot(
double dval)
741 if ( !signalsAllowed ) {
744 signalsAllowed =
false;
747 qreal val = qreal(dval);
750 QString family = qtFamilies[familyListBox->currentItem()->text()];
751 QString style = qtStyles[styleListBox->currentItem()->text()];
754 if (customSizeRow >= 0 && sizeListBox->currentRow() == customSizeRow) {
755 sizeListBox->item(customSizeRow)->setText(standardSizeAtCustom);
759 bool canCustomize =
true;
762 if (!dbase.isSmoothlyScalable(family, style)) {
765 canCustomize =
false;
766 int nrows = sizeListBox->count();
767 int row = sizeListBox->currentRow();
769 if (val - selFont.pointSizeF() > 0) {
770 for (nrow = row + 1; nrow < nrows; ++nrow)
775 for (nrow = row - 1; nrow >= 0; --nrow)
780 nrow = nrow < 0 ? 0 : nrow >= nrows ? nrows - 1 : nrow;
783 sizeOfFont->setValue(val);
787 int row = nearestSizeRow(val, canCustomize);
788 sizeListBox->setCurrentRow(row);
791 selFont.setPointSizeF(val);
792 emit q->fontSelected( selFont );
794 signalsAllowed =
true;
797 void KFontChooser::Private::_k_displaySample(
const QFont& font )
799 sampleEdit->setFont(font);
802 xlfdEdit->setText(font.rawName());
803 xlfdEdit->setCursorPosition(0);
810 int KFontChooser::Private::nearestSizeRow (qreal val,
bool customize)
814 for (
int r = 0; r < sizeListBox->count(); ++r) {
816 if (qAbs(cval - val) < diff) {
817 diff = qAbs(cval - val);
822 if (customize && diff > 0) {
824 standardSizeAtCustom = sizeListBox->item(row)->text();
830 qreal KFontChooser::Private::fillSizeList (
const QList<qreal> &sizes_)
832 if ( !sizeListBox ) {
837 bool canCustomize =
false;
838 if (sizes.count() == 0) {
839 static const int c[] = {
849 for (
int i = 0; c[i]; ++i) {
858 sizeListBox->clear();
860 foreach (qreal size, sizes) {
870 int row = nearestSizeRow(selectedSize, canCustomize);
874 qreal KFontChooser::Private::setupSizeListBox (
const QString& family,
const QString& style)
878 if (dbase.isSmoothlyScalable(family, style)) {
885 QList<int> smoothSizes = dbase.smoothSizes(family, style);
886 foreach (
int size, smoothSizes) {
893 qreal bestFitSize = fillSizeList(sizes);
899 if ( !selectedSizeList.isEmpty() ) {
900 sizeListBox->setCurrentItem(selectedSizeList.first());
907 void KFontChooser::Private::setupDisplay()
910 QString family = selFont.family().toLower();
911 QString styleID = styleIdentifier(selFont);
912 qreal size = selFont.pointSizeF();
914 size = QFontInfo( selFont ).pointSizeF();
919 numEntries = familyListBox->count();
920 for (i = 0; i < numEntries; i++) {
921 if (family == qtFamilies[familyListBox->item(i)->text()].toLower()) {
922 familyListBox->setCurrentRow(i);
928 if ( i == numEntries )
930 if (family.contains(
'['))
932 family = family.left(family.indexOf(
'[')).trimmed();
933 for (i = 0; i < numEntries; i++) {
934 if (family == qtFamilies[familyListBox->item(i)->text()].toLower()) {
935 familyListBox->setCurrentRow(i);
943 if ( i == numEntries )
945 QString fallback = family+
" [";
946 for (i = 0; i < numEntries; i++) {
947 if (qtFamilies[familyListBox->item(i)->text()].toLower().startsWith(fallback)) {
948 familyListBox->setCurrentRow(i);
955 if ( i == numEntries )
957 for (i = 0; i < numEntries; i++) {
958 if (qtFamilies[familyListBox->item(i)->text()].toLower().startsWith(family)) {
959 familyListBox->setCurrentRow(i);
966 if ( i == numEntries ) {
967 familyListBox->setCurrentRow( 0 );
975 numEntries = styleListBox->count();
976 for (i = 0; i < numEntries; i++) {
977 if (styleID == styleIDs[styleListBox->item(i)->text()]) {
978 styleListBox->setCurrentRow(i);
982 if (i == numEntries) {
984 styleListBox->setCurrentRow(0);
990 QString currentFamily = qtFamilies[familyListBox->currentItem()->text()];
991 QString currentStyle = qtStyles[styleListBox->currentItem()->text()];
992 bool canCustomize = dbase.isSmoothlyScalable(currentFamily, currentStyle);
993 sizeListBox->setCurrentRow(nearestSizeRow(size, canCustomize));
996 sizeOfFont->setValue(
KGlobal::locale()->readNumber(sizeListBox->currentItem()->text()));
1002 QFontDatabase dbase;
1006 if (fontListCriteria)
1009 for (QStringList::const_iterator it = lstSys.constBegin(); it != lstSys.constEnd(); ++it)
1011 if ((fontListCriteria &
FixedWidthFonts) > 0 && !dbase.isFixedPitch(*it))
continue;
1013 !dbase.isBitmapScalable(*it))
continue;
1014 if ((fontListCriteria &
SmoothScalableFonts) > 0 && !dbase.isSmoothlyScalable(*it))
continue;
1015 lstFonts.append(*it);
1021 if (lstFonts.count() == 0)
1022 lstFonts.append(
"fixed");
1033 void KFontChooser::Private::setFamilyBoxItems(
const QStringList &fonts)
1035 signalsAllowed =
false;
1038 familyListBox->clear();
1039 familyListBox->addItems(trfonts);
1041 signalsAllowed =
true;
1044 void KFontChooser::Private::fillFamilyListBox(
bool onlyFixedFonts)
1047 getFontList(fontList, onlyFixedFonts?FixedWidthFonts:0);
1048 setFamilyBoxItems(fontList);
1051 void KFontChooser::Private::_k_showXLFDArea(
bool show)
1055 xlfdEdit->parentWidget()->show();
1059 xlfdEdit->parentWidget()->hide();
1069 QString KFontChooser::Private::styleIdentifier(
const QFont &font)
1071 const QChar comma(QLatin1Char(
','));
1072 return QString::number(font.weight()) + comma
1073 + QString::number((
int)font.style()) + comma
1074 +
QString::number(font.stretch());
1077 #include "kfontchooser.moc"
1078 #include "sampleedit_p.moc"
QString i18n(const char *text)
static QString formatFontSize(qreal size)
QString label(StandardShortcut id)
Returns a localized label for user-visible display.
static void getFontList(QStringList &list, uint fontListCriteria)
Creates a list of font strings.
void splitFontString(const QString &name, QString *family, QString *foundry)
void setColor(const QColor &col)
Sets the color to use in the preview.
KLocalizedString inContext(const QString &key, const QString &text) const
Qt::CheckState sizeIsRelative() const
void setSampleText(const QString &text)
Sets the sample text.
QString i18nc(const char *ctxt, const char *text)
FontDiffFlags fontDiffFlags() const
KSharedConfigPtr config()
QColor backgroundColor() const
void enableColumn(int column, bool state)
Enables or disable a font column in the chooser.
double readNumber(const QString &numStr, bool *ok=0) const
void setFont(const QFont &font, bool onlyFixed=false)
Sets the currently selected font in the chooser.
static int spacingHint()
Returns the number of pixels that should be used between widgets inside a dialog according to the KDE...
static int minimumListWidth(const QListWidget *list)
KFontChooser(QWidget *parent=0L, const DisplayFlags &flags=DisplayFrame, const QStringList &fontList=QStringList(), int visibleListSize=8, Qt::CheckState *sizeIsRelativeState=0L)
Constructs a font picker widget.
void setSizeIsRelative(Qt::CheckState relative)
Sets the state of the checkbox indicating whether the font size is to be interpreted as relative size...
An enhanced QLineEdit widget for inputting text.
static QFont generalFont()
Returns the default general font.
QString sampleText() const
virtual QSize sizeHint(void) const
Reimplemented for internal reasons.
QStringList translateFontNameList(const QStringList &names, QHash< QString, QString > *trToRawNames)
void setBackgroundColor(const QColor &col)
Sets the background color to use in the preview.
void fontSelected(const QFont &font)
Emitted whenever the selected font changes.
KLocalizedString ki18nc(const char *ctxt, const char *msg)
static int minimumListHeight(const QListWidget *list, int numVisibleEntry)
KLocalizedString subs(int a, int fieldWidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const
virtual ~KFontChooser()
Destructs the font chooser.
QString formatNumber(double num, int precision=-1) const
void setSampleBoxVisible(bool visible)
Shows or hides the sample text box.
T readEntry(const QString &key, const T &aDefault) const
static QFont fixedFont()
Returns the default fixed font.