20 #include "tdefontrequester.h"
23 #include <tqpushbutton.h>
25 #include <tqtooltip.h>
26 #include <tqwhatsthis.h>
28 #include <tdefontdialog.h>
32 bool onlyFixed ) : TQWidget( parent, name ),
33 m_onlyFixed( onlyFixed )
37 m_sampleLabel =
new TQLabel(
this,
"m_sampleLabel" );
38 m_button =
new TQPushButton( i18n(
"Choose..." ),
this,
"m_button" );
40 m_sampleLabel->setFrameStyle( TQFrame::StyledPanel | TQFrame::Sunken );
41 setFocusProxy( m_button );
43 layout->addWidget( m_sampleLabel, 1 );
44 layout->addWidget( m_button );
46 connect( m_button, TQ_SIGNAL( clicked() ), TQ_SLOT( buttonClicked() ) );
55 m_onlyFixed = onlyFixed;
73 void TDEFontRequester::buttonClicked()
77 if ( result == KDialog::Accepted )
84 void TDEFontRequester::displaySampleText()
86 m_sampleLabel->setFont( m_selFont );
88 int size = m_selFont.pointSize();
90 size = m_selFont.pixelSize();
92 if ( m_sampleText.isEmpty() )
93 m_sampleLabel->setText( TQString(
"%1 %2" ).arg( m_selFont.family() )
96 m_sampleLabel->setText( m_sampleText );
99 void TDEFontRequester::setToolTip()
101 TQToolTip::remove( m_button );
102 TQToolTip::add( m_button, i18n(
"Click to select a font" ) );
104 TQToolTip::remove( m_sampleLabel );
105 TQWhatsThis::remove( m_sampleLabel );
107 if ( m_title.isNull() )
109 TQToolTip::add( m_sampleLabel, i18n(
"Preview of the selected font" ) );
110 TQWhatsThis::add( m_sampleLabel,
111 i18n(
"This is a preview of the selected font. You can change it"
112 " by clicking the \"Choose...\" button." ) );
116 TQToolTip::add( m_sampleLabel,
117 i18n(
"Preview of the \"%1\" font" ).arg( m_title ) );
118 TQWhatsThis::add( m_sampleLabel,
119 i18n(
"This is a preview of the \"%1\" font. You can change it"
120 " by clicking the \"Choose...\" button." ).arg( m_title ) );
124 #include "tdefontrequester.moc"
static int spacingHint()
Return the number of pixels you shall use between widgets inside a dialog according to the KDE standa...
static int getFont(TQFont &theFont, bool onlyFixed=false, TQWidget *parent=0L, bool makeFrame=true, TQButton::ToggleState *sizeIsRelativeState=0L)
Creates a modal font dialog, lets the user choose a font, and returns when the dialog is closed.
void fontSelected(const TQFont &font)
Emitted when a new font has been selected in the underlying dialog.
virtual void setSampleText(const TQString &text)
Sets the sample text.
virtual void setFont(const TQFont &font, bool onlyFixed=false)
Sets the currently selected font in the requester.
TDEFontRequester(TQWidget *parent=0L, const char *name=0L, bool onlyFixed=false)
Constructs a font requester widget.
virtual void setTitle(const TQString &title)
Set the title for the widget that will be used in the tooltip and what's this text.