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

KDEUI

  • sources
  • kde-4.14
  • kdelibs
  • kdeui
  • fonts
kfontdialog.cpp
Go to the documentation of this file.
1 /*
2 
3 Requires the Qt widget libraries, available at no cost at
4 http://www.troll.no
5 
6 Copyright (C) 1996 Bernd Johannes Wuebben <wuebben@kde.org>
7 Copyright (c) 1999 Preston Brown <pbrown@kde.org>
8 Copyright (c) 1999 Mario Weilguni <mweilguni@kde.org>
9 
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public
12 License as published by the Free Software Foundation; either
13 version 2 of the License, or (at your option) any later version.
14 
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details.
19 
20 You should have received a copy of the GNU Library General Public License
21 along with this library; see the file COPYING.LIB. If not, write to
22 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, USA.
24 */
25 
26 #include "kfontdialog.h"
27 
28 #include <config.h>
29 
30 #include <stdio.h>
31 #include <stdlib.h>
32 
33 
34 #include <QtGui/QComboBox>
35 #include <QtGui/QCheckBox>
36 #include <QtCore/QFile>
37 #include <QtGui/QFont>
38 #include <QtGui/QLabel>
39 #include <QtGui/QLayout>
40 #include <QtGui/QScrollBar>
41 #include <QtCore/QMutableStringListIterator>
42 #include <QtGui/QFontDatabase>
43 #include <QList>
44 #include <QtGui/QGroupBox>
45 #include <kcharsets.h>
46 #include <kconfig.h>
47 #include <kdialog.h>
48 #include <kglobal.h>
49 #include <kglobalsettings.h>
50 #include <klistwidget.h>
51 #include <klocale.h>
52 #include <kstandarddirs.h>
53 #include <kdebug.h>
54 #include <knuminput.h>
55 #include <kconfiggroup.h>
56 
57 class KFontDialog::Private
58 {
59 public:
60  Private()
61  : chooser( 0 )
62  {
63  }
64 
65  KFontChooser *chooser;
66 };
67 
68 KFontDialog::KFontDialog( QWidget *parent,
69  const KFontChooser::DisplayFlags& flags,
70  const QStringList &fontList,
71  Qt::CheckState *sizeIsRelativeState )
72  : KDialog( parent ),
73  d( new Private )
74 {
75  setCaption( i18n("Select Font") );
76  setButtons( Ok | Cancel );
77  setDefaultButton(Ok);
78  d->chooser = new KFontChooser( this, flags, fontList, 8,
79  sizeIsRelativeState );
80  d->chooser->setObjectName( "fontChooser" );
81 
82  connect( d->chooser , SIGNAL(fontSelected(QFont)) , this , SIGNAL(fontSelected(QFont)) );
83 
84  setMainWidget( d->chooser );
85 }
86 
87 KFontDialog::~KFontDialog()
88 {
89  delete d;
90 }
91 
92 void KFontDialog::setFont( const QFont &font, bool onlyFixed)
93 {
94  d->chooser->setFont(font, onlyFixed);
95 }
96 
97 QFont KFontDialog::font() const
98 {
99  return d->chooser->font();
100 }
101 
102 void KFontDialog::setSizeIsRelative( Qt::CheckState relative )
103 {
104  d->chooser->setSizeIsRelative( relative );
105 }
106 
107 Qt::CheckState KFontDialog::sizeIsRelative() const
108 {
109  return d->chooser->sizeIsRelative();
110 }
111 
112 
113 int KFontDialog::getFontDiff( QFont &theFont,
114  KFontChooser::FontDiffFlags& diffFlags,
115  const KFontChooser::DisplayFlags& flags,
116  QWidget *parent,
117  Qt::CheckState *sizeIsRelativeState )
118 {
119  KFontDialog dlg( parent, flags | KFontChooser::ShowDifferences,
120  QStringList(), sizeIsRelativeState );
121  dlg.setModal( true );
122  dlg.setObjectName( "Font Selector" );
123  dlg.setFont( theFont, flags & KFontChooser::FixedFontsOnly );
124 
125  int result = dlg.exec();
126  if( result == Accepted )
127  {
128  theFont = dlg.d->chooser->font();
129  diffFlags = dlg.d->chooser->fontDiffFlags();
130  if( sizeIsRelativeState )
131  *sizeIsRelativeState = dlg.d->chooser->sizeIsRelative();
132  }
133  return result;
134 }
135 
136 int KFontDialog::getFont( QFont &theFont,
137  const KFontChooser::DisplayFlags& flags,
138  QWidget *parent,
139  Qt::CheckState *sizeIsRelativeState )
140 {
141  KFontDialog dlg( parent, flags, QStringList(), sizeIsRelativeState );
142  dlg.setModal( true );
143  dlg.setObjectName( "Font Selector" );
144  dlg.setFont( theFont, flags & KFontChooser::FixedFontsOnly );
145 
146  int result = dlg.exec();
147  if( result == Accepted )
148  {
149  theFont = dlg.d->chooser->font();
150  if( sizeIsRelativeState )
151  *sizeIsRelativeState = dlg.d->chooser->sizeIsRelative();
152  }
153  return result;
154 }
155 
156 
157 int KFontDialog::getFontAndText( QFont &theFont, QString &theString,
158  const KFontChooser::DisplayFlags& flags,
159  QWidget *parent,
160  Qt::CheckState *sizeIsRelativeState )
161 {
162  KFontDialog dlg( parent, flags,
163  QStringList(), sizeIsRelativeState );
164  dlg.setModal( true );
165  dlg.setObjectName( "Font and Text Selector" );
166  dlg.setFont( theFont, flags & KFontChooser::FixedFontsOnly );
167 
168  int result = dlg.exec();
169  if( result == Accepted )
170  {
171  theFont = dlg.d->chooser->font();
172  theString = dlg.d->chooser->sampleText();
173  if( sizeIsRelativeState )
174  *sizeIsRelativeState = dlg.d->chooser->sizeIsRelative();
175  }
176  return result;
177 }
178 
179 
180 #include "kfontdialog.moc"
kfontdialog.h
KFontDialog::fontSelected
void fontSelected(const QFont &font)
Emitted whenever the currently selected font changes.
kdialog.h
i18n
QString i18n(const char *text)
knuminput.h
KFontDialog::sizeIsRelative
Qt::CheckState sizeIsRelative() const
Definition: kfontdialog.cpp:107
QWidget
kcharsets.h
QDialog::setModal
void setModal(bool modal)
kdebug.h
KFontDialog::font
QFont font() const
Definition: kfontdialog.cpp:97
KFontDialog::getFont
static int getFont(QFont &theFont, const KFontChooser::DisplayFlags &flags=KFontChooser::NoDisplayFlags, QWidget *parent=0L, Qt::CheckState *sizeIsRelativeState=0L)
Creates a modal font dialog, lets the user choose a font, and returns when the dialog is closed...
Definition: kfontdialog.cpp:136
kglobalsettings.h
KFontDialog::setSizeIsRelative
void setSizeIsRelative(Qt::CheckState relative)
Sets the state of the checkbox indicating whether the font size is to be interpreted as relative size...
Definition: kfontdialog.cpp:102
QFont
KDialog::Cancel
Show Cancel-button. (this button reject()s the dialog; result set to QDialog::Rejected) ...
Definition: kdialog.h:144
kconfig.h
KFontDialog::getFontAndText
static int getFontAndText(QFont &theFont, QString &theString, const KFontChooser::DisplayFlags &flags=KFontChooser::NoDisplayFlags, QWidget *parent=0L, Qt::CheckState *sizeIsRelativeState=0L)
When you are not only interested in the font selected, but also in the example string typed in...
Definition: kfontdialog.cpp:157
QDialog::exec
int exec()
KDialog
A dialog base class with standard buttons and predefined layouts.
Definition: kdialog.h:128
klocale.h
KDialog::setCaption
virtual void setCaption(const QString &caption)
Make a KDE compliant caption.
Definition: kdialog.cpp:469
KDialog::setMainWidget
void setMainWidget(QWidget *widget)
Sets the main widget of the dialog.
Definition: kdialog.cpp:338
KFontDialog::KFontDialog
KFontDialog(QWidget *parent=0, const KFontChooser::DisplayFlags &flags=KFontChooser::NoDisplayFlags, const QStringList &fontlist=QStringList(), Qt::CheckState *sizeIsRelativeState=0)
Constructs a font selection dialog.
Definition: kfontdialog.cpp:68
kglobal.h
KFontChooser::ShowDifferences
Definition: kfontchooser.h:84
KFontDialog::setFont
void setFont(const QFont &font, bool onlyFixed=false)
Sets the currently selected font in the dialog.
Definition: kfontdialog.cpp:92
KFontChooser::FixedFontsOnly
Definition: kfontchooser.h:82
KFontDialog::~KFontDialog
~KFontDialog()
Definition: kfontdialog.cpp:87
QObject::setObjectName
void setObjectName(const QString &name)
QDialog::result
int result() const
KFontDialog
A font selection dialog.
Definition: kfontdialog.h:56
QString
KDialog::setButtons
void setButtons(ButtonCodes buttonMask)
Creates (or recreates) the button box and all the buttons in it.
Definition: kdialog.cpp:206
QStringList
KDialog::Ok
Show Ok button. (this button accept()s the dialog; result set to QDialog::Accepted) ...
Definition: kdialog.h:141
KDialog::setDefaultButton
void setDefaultButton(ButtonCode id)
Sets the button that will be activated when the Enter key is pressed.
Definition: kdialog.cpp:287
KFontChooser
A font selection widget.
Definition: kfontchooser.h:47
kstandarddirs.h
KFontDialog::getFontDiff
static int getFontDiff(QFont &theFont, KFontChooser::FontDiffFlags &diffFlags, const KFontChooser::DisplayFlags &flags=KFontChooser::NoDisplayFlags, QWidget *parent=0L, Qt::CheckState *sizeIsRelativeState=0L)
Creates a modal font difference dialog, lets the user choose a selection of changes that should be ma...
Definition: kfontdialog.cpp:113
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
klistwidget.h
kconfiggroup.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal