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

KDEUI

  • kdeui
  • fonts
kfontdialog.cpp
Go to the documentation of this file.
1/*
2
3Requires the Qt widget libraries, available at no cost at
4http://www.troll.no
5
6Copyright (C) 1996 Bernd Johannes Wuebben <wuebben@kde.org>
7Copyright (c) 1999 Preston Brown <pbrown@kde.org>
8Copyright (c) 1999 Mario Weilguni <mweilguni@kde.org>
9
10This library is free software; you can redistribute it and/or
11modify it under the terms of the GNU Library General Public
12License as published by the Free Software Foundation; either
13version 2 of the License, or (at your option) any later version.
14
15This library is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18Library General Public License for more details.
19
20You should have received a copy of the GNU Library General Public License
21along with this library; see the file COPYING.LIB. If not, write to
22the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23Boston, 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
57class KFontDialog::Private
58{
59public:
60 Private()
61 : chooser( 0 )
62 {
63 }
64
65 KFontChooser *chooser;
66};
67
68KFontDialog::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
87KFontDialog::~KFontDialog()
88{
89 delete d;
90}
91
92void KFontDialog::setFont( const QFont &font, bool onlyFixed)
93{
94 d->chooser->setFont(font, onlyFixed);
95}
96
97QFont KFontDialog::font() const
98{
99 return d->chooser->font();
100}
101
102void KFontDialog::setSizeIsRelative( Qt::CheckState relative )
103{
104 d->chooser->setSizeIsRelative( relative );
105}
106
107Qt::CheckState KFontDialog::sizeIsRelative() const
108{
109 return d->chooser->sizeIsRelative();
110}
111
112
113int 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
136int 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
157int 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"
KDialog
A dialog base class with standard buttons and predefined layouts.
Definition: kdialog.h:129
KDialog::setMainWidget
void setMainWidget(QWidget *widget)
Sets the main widget of the dialog.
Definition: kdialog.cpp:338
KDialog::setButtons
void setButtons(ButtonCodes buttonMask)
Creates (or recreates) the button box and all the buttons in it.
Definition: kdialog.cpp:206
KDialog::Ok
@ Ok
Show Ok button. (this button accept()s the dialog; result set to QDialog::Accepted)
Definition: kdialog.h:141
KDialog::Cancel
@ Cancel
Show Cancel-button. (this button reject()s the dialog; result set to QDialog::Rejected)
Definition: kdialog.h:144
KDialog::setDefaultButton
void setDefaultButton(ButtonCode id)
Sets the button that will be activated when the Enter key is pressed.
Definition: kdialog.cpp:287
KDialog::setCaption
virtual void setCaption(const QString &caption)
Make a KDE compliant caption.
Definition: kdialog.cpp:469
KFontChooser
A font selection widget.
Definition: kfontchooser.h:48
KFontChooser::ShowDifferences
@ ShowDifferences
Definition: kfontchooser.h:84
KFontChooser::FixedFontsOnly
@ FixedFontsOnly
Definition: kfontchooser.h:82
KFontDialog
A font selection dialog.
Definition: kfontdialog.h:56
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
KFontDialog::sizeIsRelative
Qt::CheckState sizeIsRelative() const
Definition: kfontdialog.cpp:107
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
KFontDialog::~KFontDialog
~KFontDialog()
Definition: kfontdialog.cpp:87
KFontDialog::font
QFont font() const
Definition: kfontdialog.cpp:97
KFontDialog::setFont
void setFont(const QFont &font, bool onlyFixed=false)
Sets the currently selected font in the dialog.
Definition: kfontdialog.cpp:92
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
KFontDialog::fontSelected
void fontSelected(const QFont &font)
Emitted whenever the currently selected font changes.
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
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
QWidget
kcharsets.h
kconfig.h
kconfiggroup.h
kdebug.h
kdialog.h
kfontdialog.h
kglobal.h
kglobalsettings.h
klistwidget.h
klocale.h
i18n
QString i18n(const char *text)
knuminput.h
kstandarddirs.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
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