44 #ifndef QT_NO_FONTDIALOG 65 #include <private/qdialog_p.h> 66 #include <private/qfont_p.h> 69 #include <QtGui/qdesktopwidget.h> 187 nativeDialogInUse =
false;
191 q->setSizeGripEnabled(
true);
196 familyEdit->setReadOnly(
true);
200 familyAccel =
new QLabel(q);
201 #ifndef QT_NO_SHORTCUT 204 familyAccel->setIndent(2);
207 styleEdit->setReadOnly(
true);
209 styleEdit->setFocusProxy(styleList);
211 styleAccel =
new QLabel(q);
212 #ifndef QT_NO_SHORTCUT 213 styleAccel->setBuddy(styleList);
215 styleAccel->setIndent(2);
220 sizeEdit->setValidator(validator);
223 sizeAccel =
new QLabel(q);
224 #ifndef QT_NO_SHORTCUT 225 sizeAccel->setBuddy(sizeEdit);
227 sizeAccel->setIndent(2);
249 writingSystemAccel =
new QLabel(q);
250 #ifndef QT_NO_SHORTCUT 251 writingSystemAccel->setBuddy(writingSystemCombo);
253 writingSystemAccel->setIndent(2);
256 smoothScalable =
false;
270 if (writingSystemName.
isEmpty())
272 writingSystemCombo->addItem(writingSystemName);
282 int spacing = mainGrid->
spacing();
317 mainGrid->
addWidget(writingSystemAccel, 5, 0);
318 mainGrid->
addWidget(writingSystemCombo, 7, 0);
321 mainGrid->
addWidget(buttonBox, 9, 0, 1, 5);
331 #if defined(Q_WS_WINCE) 333 #elif defined(Q_WS_S60) 339 sizeEdit->installEventFilter(q);
341 styleList->installEventFilter(q);
342 sizeList->installEventFilter(q);
345 retranslateStrings();
358 d->closeCocoaFontPanel();
474 if (o ==
d->sizeEdit &&
480 int ci =
d->sizeList->currentItem();
483 if (ci !=
d->sizeList->currentItem()
485 d->sizeEdit->selectAll();
487 }
else if ((o ==
d->familyList || o ==
d->styleList) &&
495 if (o ==
d->familyList)
496 d->familyEdit->selectAll();
497 else if (o ==
d->styleList)
498 d->styleEdit->selectAll();
499 else if (o ==
d->sizeList)
500 d->sizeEdit->selectAll();
502 d->sizeEdit->setFocus();
516 enum match_t { MATCH_NONE = 0, MATCH_LAST_RESORT = 1, MATCH_APP = 2, MATCH_FAMILY = 3 };
518 QStringList familyNames = fdb.families(writingSystem);
520 familyList->model()->setStringList(familyNames);
522 QString foundryName1, familyName1, foundryName2, familyName2;
523 int bestFamilyMatch = -1;
524 match_t bestFamilyType = MATCH_NONE;
533 for(; it != familyNames.
constEnd(); ++
it, ++i) {
537 if (familyName1 == familyName2) {
538 bestFamilyType = MATCH_FAMILY;
539 if (foundryName1 == foundryName2) {
543 if (bestFamilyMatch < MATCH_FAMILY)
548 match_t
type = MATCH_NONE;
550 type = MATCH_LAST_RESORT;
551 if (bestFamilyType <= MATCH_LAST_RESORT && familyName2 == f.
family())
554 if (type != MATCH_NONE) {
555 bestFamilyType =
type;
560 if (i != -1 && bestFamilyType != MATCH_NONE)
564 familyEdit->setText(
familyList->currentText());
567 familyEdit->selectAll();
580 styleList->model()->setStringList(styles);
584 smoothScalable =
false;
586 if (!
style.isEmpty()) {
592 for (
int i = 0; i < (int)styleList->count(); i++) {
593 if (cstyle == styleList->text(i)) {
594 styleList->setCurrentItem(i);
599 if (!found && first) {
611 styleList->setCurrentItem(0);
613 styleList->setCurrentItem(0);
616 styleEdit->setText(styleList->currentText());
618 && styleList->hasFocus())
619 styleEdit->selectAll();
621 smoothScalable = fdb.isSmoothlyScalable(
familyList->currentText(), styleList->currentText());
648 if (current == -1 && *
it >=
size)
652 sizeList->model()->setStringList(str_sizes);
655 current = sizeList->count() - 1;
657 sizeList->setCurrentItem(current);
659 sizeEdit->blockSignals(
true);
662 && sizeList->hasFocus())
663 sizeEdit->selectAll();
664 sizeEdit->blockSignals(
false);
675 int pSize = sizeEdit->text().toInt();
683 updateSampleFont(newFont);
689 if (newFont != sampleEdit->font()) {
690 sampleEdit->setFont(newFont);
691 emit q->currentFontChanged(newFont);
701 sampleEdit->setText(fdb.writingSystemSample(writingSystem));
712 familyEdit->setText(family);
715 familyEdit->selectAll();
728 QString s = styleList->text(index);
729 styleEdit->setText(s);
731 && styleList->hasFocus())
732 styleEdit->selectAll();
747 QString s = sizeList->text(index);
748 sizeEdit->setText(s);
750 && sizeEdit->hasFocus())
751 sizeEdit->selectAll();
770 if (this->size == size)
774 if (sizeList->count() != 0) {
776 for (i = 0; i < sizeList->count() - 1; i++) {
777 if (sizeList->text(i).toInt() >= this->
size)
780 sizeList->blockSignals(
true);
781 sizeList->setCurrentItem(i);
782 sizeList->blockSignals(
false);
810 d->retranslateStrings();
839 d->style =
d->fdb.styleString(font);
868 return d->sampleEdit->font();
882 return d->selectedFont;
912 if (!(
d->opts & option) != !on)
925 return (
d->opts & option) != 0;
948 FontDialogOptions changed = (options ^
d->opts);
953 d->buttonBox->setVisible(!(options &
NoButtons));
983 d->receiverToDisconnectOnClose = receiver;
984 d->memberToDisconnectOnClose = member;
1032 if (
d->canBeNativeDialog()){
1033 if (
d->setVisible_sys(visible)){
1034 d->nativeDialogInUse =
true;
1039 d->nativeDialogInUse =
false;
1061 if(selectedFont !=
d->selectedFont)
1066 d->selectedFont =
QFont();
1067 if (
d->receiverToDisconnectOnClose) {
1069 d->receiverToDisconnectOnClose,
d->memberToDisconnectOnClose);
1070 d->receiverToDisconnectOnClose = 0;
1072 d->memberToDisconnectOnClose.clear();
1079 if (nativeDialogInUse)
1088 return (staticName == dynamicName);
1119 #include "qfontdialog.moc" 1120 #include "moc_qfontdialog.cpp" 1122 #endif // QT_NO_FONTDIALOG static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QFontDialog(QWidget *parent=0)
Constructs a standard font dialog.
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
The QKeyEvent class describes a key event.
#define QT_END_NAMESPACE
This macro expands to.
QFontListView(QWidget *parent)
Q_CORE_EXPORT QTextStream & ws(QTextStream &s)
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
void currentFontChanged(const QFont &font)
This signal is emitted when the current font is changed.
#define it(className, varName)
The QDialog class is the base class of dialog windows.
bool underline() const
Returns true if underline has been set; otherwise returns false.
int exec()
Shows the dialog as a modal dialog, blocking until the user closes it.
void setUnderline(bool)
If enable is true, sets underline on; otherwise sets underline off.
QString & replace(int i, int len, QChar after)
QStringListModel * model() const
virtual void accept()
Hides the modal dialog and sets the result code to Accepted.
void setEditTriggers(EditTriggers triggers)
virtual void reject()
Hides the modal dialog and sets the result code to Rejected.
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
void setColumnMinimumWidth(int column, int minSize)
Sets the minimum width of column column to minSize pixels.
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
QString lastResortFamily() const
Returns the "last resort" font family name.
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
void _q_sizeHighlighted(int)
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
static QFont getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title, QFontDialog::FontDialogOptions options)
static void parseFontName(const QString &name, QString &foundry, QString &family)
The QString class provides a Unicode character string.
void fontSelected(const QFont &font)
This signal is emitted when a font has been selected.
The QStringListModel class provides a model that supplies strings to views.
The QObject class is the base class of all Qt objects.
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=0)
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment...
The QIntValidator class provides a validator that ensures a string contains a valid integer within a ...
QStringList stringList() const
Returns the string list used by the model to store data.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
static bool sharedFontPanelAvailable
static QFont getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title, FontDialogOptions options)
Executes a modal font dialog and returns a font.
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
Reimplemented Function
virtual void setModel(QAbstractItemModel *model)
Sets the model for the view to present.
int key() const
Returns the code of the key that was pressed or released.
friend class const_iterator
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
static QStringList familyList(const QFontDef &req)
void setCurrentItem(int item)
void _q_writingSystemHighlighted(int)
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
void setStrikeOut(bool)
If enable is true, sets strikeout on; otherwise sets strikeout off.
FontDialogOptions options() const
int row() const
Returns the row this model index refers to.
void _q_styleHighlighted(int)
QFont currentFont() const
const T & at(int i) const
Returns the item at index position i in the list.
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
This slot is called when a new item becomes the current item.
The QStringList class provides a list of strings.
The QComboBox widget is a combined button and popup list.
void setOptions(FontDialogOptions options)
void setRowMinimumHeight(int row, int minSize)
Sets the minimum height of row row to minSize pixels.
void setCurrentIndex(const QModelIndex &index)
Sets the current item to be the item at index.
void rejected()
This signal is emitted when the dialog has been rejected either by the user or by calling reject() or...
int spacing() const
If the vertical spacing is equal to the horizontal spacing, this function returns that value; otherwi...
void _q_familyHighlighted(int)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
void changeEvent(QEvent *event)
Reimplemented Function
The QGroupBox widget provides a group box frame with a title.
QModelIndex currentIndex() const
Returns the model index of the current item.
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void clear()
Removes all items from the list.
The QFontDialog class provides a dialog widget for selecting a font.
The QFontInfo class provides general information about fonts.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
void setVisible(bool visible)
Reimplemented Function
void retranslateStrings()
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
void done(int result)
Closes the dialog and sets its result code to result.
virtual void done(int)
Closes the dialog and sets its result code to r.
static void setFont(void *delegate, const QFont &font)
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
void _q_sizeChanged(const QString &)
This slot is called if the user changes the font size.
void updateSizes()
Updates the contents of the "font size" list box.
FontDialogOption
This enum specifies various options that affect the look and feel of a font dialog.
int rowCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of rows in the model.
The QListView class provides a list or icon view onto a model.
void setColumnStretch(int column, int stretch)
Sets the stretch factor of column column to stretch.
void setCurrentFont(const QFont &font)
Sets the font highlighted in the QFontDialog to the given font.
bool testOption(FontDialogOption option) const
Returns true if the given option is enabled; otherwise, returns false.
The QFont class specifies a font used for drawing text.
void getContentsMargins(int *left, int *top, int *right, int *bottom) const
QString family() const
Returns the requested font family name, i.e.
bool eventFilter(QObject *, QEvent *)
Reimplemented Function
QObject * parent() const
Returns a pointer to the parent object.
int result() const
In general returns the modal dialog's result code, Accepted or Rejected.
The QGridLayout class lays out widgets in a grid.
The QModelIndex class is used to locate data in a data model.
QString currentText() const
The QLabel widget provides a text or image display.
The QHBoxLayout class lines up widgets horizontally.
The QLineEdit widget is a one-line text editor.
static const Qt::WindowFlags DefaultWindowFlags
void accepted()
This signal is emitted when the dialog has been accepted either by the user or by calling accept() or...
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
int pointSize() const
Returns the point size of the font.
void open()
Shows the dialog as a window modal dialog, returning immediately.
The QVBoxLayout class lines up widgets vertically.
bool eventFilter(QObject *object, QEvent *event)
An event filter to make the Up, Down, PageUp and PageDown keys work correctly in the line edits...
void addWidget(QWidget *w)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString writingSystemName(WritingSystem writingSystem)
Returns the names the writingSystem (e.g.
bool strikeOut() const
Returns true if strikeout has been set; otherwise returns false.
QAbstractItemModel * model() const
Returns the model that this view is presenting.
The QCheckBox widget provides a checkbox with a text label.
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
void setVisible(bool visible)
Reimplemented Function
void setSpacing(int spacing)
This function sets both the vertical and horizontal spacing to spacing.
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
QString text(int i) const
void setOption(FontDialogOption option, bool on=true)
Sets the given option to be enabled if on is true; otherwise, clears the given option.
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
int pointSize() const
Returns the point size of the matched window system font.
void updateSampleFont(const QFont &newFont)
QFont selectedFont() const
Returns the font that the user selected by clicking the OK or equivalent button.