• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDEUI

kfontdialog.cpp

Go to the documentation of this file.
00001 /*
00002 
00003 Requires the Qt widget libraries, available at no cost at
00004 http://www.troll.no
00005 
00006 Copyright (C) 1996 Bernd Johannes Wuebben  <wuebben@kde.org>
00007 Copyright (c) 1999 Preston Brown <pbrown@kde.org>
00008 Copyright (c) 1999 Mario Weilguni <mweilguni@kde.org>
00009 
00010 This library is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU Library General Public
00012 License as published by the Free Software Foundation; either
00013 version 2 of the License, or (at your option) any later version.
00014 
00015 This library is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 Library General Public License for more details.
00019 
00020 You should have received a copy of the GNU Library General Public License
00021 along with this library; see the file COPYING.LIB.  If not, write to
00022 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00023 Boston, MA 02110-1301, USA.
00024 */
00025 
00026 #include "kfontdialog.h"
00027 
00028 #include <config.h>
00029 
00030 #include <stdio.h>
00031 #include <stdlib.h>
00032 
00033 
00034 #include <QtGui/QComboBox>
00035 #include <QtGui/QCheckBox>
00036 #include <QtCore/QFile>
00037 #include <QtGui/QFont>
00038 #include <QtGui/QLabel>
00039 #include <QtGui/QLayout>
00040 #include <QtGui/QLineEdit>
00041 #include <QtGui/QScrollBar>
00042 #include <QtCore/QMutableStringListIterator>
00043 #include <QtGui/QFontDatabase>
00044 #include <QList>
00045 #include <QtGui/QGroupBox>
00046 #include <kcharsets.h>
00047 #include <kconfig.h>
00048 #include <kdialog.h>
00049 #include <kglobal.h>
00050 #include <kglobalsettings.h>
00051 #include <klistwidget.h>
00052 #include <klocale.h>
00053 #include <kstandarddirs.h>
00054 #include <kdebug.h>
00055 #include <knuminput.h>
00056 #include <kconfiggroup.h>
00057 
00058 class KFontDialog::Private
00059 {
00060 public:
00061     Private()
00062         : chooser( 0 )
00063     {
00064     }
00065 
00066     KFontChooser *chooser;
00067 };
00068 
00069 KFontDialog::KFontDialog( QWidget *parent,
00070                           const KFontChooser::DisplayFlags& flags,
00071                           const QStringList &fontList,
00072                           Qt::CheckState *sizeIsRelativeState )
00073     : KDialog( parent ),
00074       d( new Private )
00075 {
00076     setCaption( i18n("Select Font") );
00077     setButtons( Ok | Cancel );
00078     setDefaultButton(Ok);
00079     d->chooser = new KFontChooser( this, flags, fontList, 8,
00080                                    sizeIsRelativeState );
00081     d->chooser->setObjectName( "fontChooser" );
00082 
00083     connect( d->chooser , SIGNAL(fontSelected(const QFont&)) , this , SIGNAL(fontSelected(const QFont&)) );
00084 
00085     setMainWidget( d->chooser );
00086 }
00087 
00088 KFontDialog::~KFontDialog()
00089 {
00090    delete d;
00091 }
00092 
00093 void KFontDialog::setFont( const QFont &font, bool onlyFixed)
00094 {
00095     d->chooser->setFont(font, onlyFixed);
00096 }
00097 
00098 QFont KFontDialog::font() const
00099 {
00100      return d->chooser->font();
00101 }
00102 
00103 void KFontDialog::setSizeIsRelative( Qt::CheckState relative )
00104 {
00105     d->chooser->setSizeIsRelative( relative );
00106 }
00107 
00108 Qt::CheckState KFontDialog::sizeIsRelative() const
00109 {
00110     return d->chooser->sizeIsRelative();
00111 }
00112 
00113 
00114 int KFontDialog::getFontDiff( QFont &theFont,
00115                               KFontChooser::FontDiffFlags& diffFlags,
00116                               const KFontChooser::DisplayFlags& flags,
00117                               QWidget *parent,
00118                               Qt::CheckState *sizeIsRelativeState )
00119 {
00120     KFontDialog dlg( parent, flags | KFontChooser::ShowDifferences,
00121                      QStringList(), sizeIsRelativeState );
00122     dlg.setModal( true );
00123     dlg.setObjectName( "Font Selector" );
00124     dlg.setFont( theFont, flags & KFontChooser::FixedFontsOnly );
00125 
00126     int result = dlg.exec();
00127     if( result == Accepted )
00128     {
00129         theFont = dlg.d->chooser->font();
00130         diffFlags = dlg.d->chooser->fontDiffFlags();
00131         if( sizeIsRelativeState )
00132             *sizeIsRelativeState = dlg.d->chooser->sizeIsRelative();
00133     }
00134     return result;
00135 }
00136 
00137 int KFontDialog::getFont( QFont &theFont,
00138                           const KFontChooser::DisplayFlags& flags,
00139                           QWidget *parent,
00140                           Qt::CheckState *sizeIsRelativeState )
00141 {
00142     KFontDialog dlg( parent, flags, QStringList(), sizeIsRelativeState );
00143     dlg.setModal( true );
00144     dlg.setObjectName( "Font Selector" );
00145     dlg.setFont( theFont, flags & KFontChooser::FixedFontsOnly );
00146 
00147     int result = dlg.exec();
00148     if( result == Accepted )
00149     {
00150         theFont = dlg.d->chooser->font();
00151         if( sizeIsRelativeState )
00152             *sizeIsRelativeState = dlg.d->chooser->sizeIsRelative();
00153     }
00154     return result;
00155 }
00156 
00157 
00158 int KFontDialog::getFontAndText( QFont &theFont, QString &theString,
00159                                  const KFontChooser::DisplayFlags& flags,
00160                                  QWidget *parent,
00161                                  Qt::CheckState *sizeIsRelativeState )
00162 {
00163     KFontDialog dlg( parent, flags,
00164                      QStringList(), sizeIsRelativeState );
00165     dlg.setModal( true );
00166     dlg.setObjectName( "Font and Text Selector" );
00167     dlg.setFont( theFont, flags & KFontChooser::FixedFontsOnly );
00168 
00169     int result = dlg.exec();
00170     if( result == Accepted )
00171     {
00172         theFont   = dlg.d->chooser->font();
00173         theString = dlg.d->chooser->sampleText();
00174         if( sizeIsRelativeState )
00175             *sizeIsRelativeState = dlg.d->chooser->sizeIsRelative();
00176     }
00177     return result;
00178 }
00179 
00180 
00181 #include "kfontdialog.moc"

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal