| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | | - |
| 22 | | - |
| 23 | | - |
| 24 | | - |
| 25 | | - |
| 26 | | - |
| 27 | | - |
| 28 | | - |
| 29 | | - |
| 30 | | - |
| 31 | | - |
| 32 | | - |
| 33 | | - |
| 34 | | - |
| 35 | | - |
| 36 | | - |
| 37 | | - |
| 38 | | - |
| 39 | | - |
| 40 | #include "qwindowdefs.h" | - |
| 41 | | - |
| 42 | #ifndef QT_NO_FONTDIALOG | - |
| 43 | | - |
| 44 | #include "qfontdialog.h" | - |
| 45 | #include "qfontdialog_p.h" | - |
| 46 | | - |
| 47 | #include <qapplication.h> | - |
| 48 | #include <qcheckbox.h> | - |
| 49 | #include <qcombobox.h> | - |
| 50 | #include <qevent.h> | - |
| 51 | #include <qfontdatabase.h> | - |
| 52 | #include <qgroupbox.h> | - |
| 53 | #include <qlabel.h> | - |
| 54 | #include <qlayout.h> | - |
| 55 | #include <qlineedit.h> | - |
| 56 | #include <qpushbutton.h> | - |
| 57 | #include <qstyle.h> | - |
| 58 | #include <qdialogbuttonbox.h> | - |
| 59 | #include <qheaderview.h> | - |
| 60 | #include <qlistview.h> | - |
| 61 | #include <qstringlistmodel.h> | - |
| 62 | #include <qvalidator.h> | - |
| 63 | #include <private/qdialog_p.h> | - |
| 64 | #include <private/qfont_p.h> | - |
| 65 | | - |
| 66 | QT_BEGIN_NAMESPACE | - |
| 67 | | - |
| 68 | class QFontListView : public QListView | - |
| 69 | { | - |
| 70 | Q_OBJECT | - |
| 71 | public: | - |
| 72 | QFontListView(QWidget *parent); | - |
| 73 | inline QStringListModel *model() const { | - |
| 74 | return static_cast<QStringListModel *>(QListView::model()); | - |
| 75 | } | - |
| 76 | inline void setCurrentItem(int item) { | - |
| 77 | QListView::setCurrentIndex(static_cast<QAbstractListModel*>(model())->index(item)); | - |
| 78 | } | - |
| 79 | inline int currentItem() const { | - |
| 80 | return QListView::currentIndex().row(); | - |
| 81 | } | - |
| 82 | inline int count() const { | - |
| 83 | return model()->rowCount(); | - |
| 84 | } | - |
| 85 | inline QString currentText() const { | - |
| 86 | int row = QListView::currentIndex().row(); | - |
| 87 | return row < 0 ? QString() : model()->stringList().at(row); | - |
| 88 | } | - |
| 89 | void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) Q_DECL_OVERRIDE { | - |
| 90 | QListView::currentChanged(current, previous); | - |
| 91 | if (current.isValid()) | - |
| 92 | emit highlighted(current.row()); | - |
| 93 | } | - |
| 94 | QString text(int i) const { | - |
| 95 | return model()->stringList().at(i); | - |
| 96 | } | - |
| 97 | signals: | - |
| 98 | void highlighted(int); | - |
| 99 | }; | - |
| 100 | | - |
| 101 | QFontListView::QFontListView(QWidget *parent) | - |
| 102 | : QListView(parent) | - |
| 103 | { | - |
| 104 | setModel(new QStringListModel(parent)); | - |
| 105 | setEditTriggers(NoEditTriggers); | - |
| 106 | } | - |
| 107 | | - |
| 108 | static const Qt::WindowFlags DefaultWindowFlags = | - |
| 109 | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; | - |
| 110 | | - |
| 111 | QFontDialogPrivate::QFontDialogPrivate() | - |
| 112 | : writingSystem(QFontDatabase::Any), | - |
| 113 | options(QSharedPointer<QFontDialogOptions>::create()) | - |
| 114 | { | - |
| 115 | } | - |
| 116 | | - |
| 117 | QFontDialogPrivate::~QFontDialogPrivate() | - |
| 118 | { | - |
| 119 | } | - |
| 120 | | - |
| 121 | | - |
| 122 | | - |
| 123 | | - |
| 124 | | - |
| 125 | | - |
| 126 | | - |
| 127 | | - |
| 128 | | - |
| 129 | | - |
| 130 | | - |
| 131 | | - |
| 132 | | - |
| 133 | | - |
| 134 | | - |
| 135 | | - |
| 136 | | - |
| 137 | | - |
| 138 | | - |
| 139 | | - |
| 140 | | - |
| 141 | | - |
| 142 | | - |
| 143 | | - |
| 144 | | - |
| 145 | | - |
| 146 | | - |
| 147 | | - |
| 148 | | - |
| 149 | | - |
| 150 | | - |
| 151 | | - |
| 152 | | - |
| 153 | | - |
| 154 | | - |
| 155 | | - |
| 156 | | - |
| 157 | QFontDialog::QFontDialog(QWidget *parent) | - |
| 158 | : QDialog(*new QFontDialogPrivate, parent, DefaultWindowFlags) | - |
| 159 | { | - |
| 160 | Q_D(QFontDialog); | - |
| 161 | d->init(); | - |
| 162 | } | - |
| 163 | | - |
| 164 | | - |
| 165 | | - |
| 166 | | - |
| 167 | | - |
| 168 | | - |
| 169 | | - |
| 170 | QFontDialog::QFontDialog(const QFont &initial, QWidget *parent) | - |
| 171 | : QDialog(*new QFontDialogPrivate, parent, DefaultWindowFlags) | - |
| 172 | { | - |
| 173 | Q_D(QFontDialog); | - |
| 174 | d->init(); | - |
| 175 | setCurrentFont(initial); | - |
| 176 | } | - |
| 177 | | - |
| 178 | void QFontDialogPrivate::init() | - |
| 179 | { | - |
| 180 | Q_Q(QFontDialog); | - |
| 181 | | - |
| 182 | q->setSizeGripEnabled(true); | - |
| 183 | q->setWindowTitle(QFontDialog::tr("Select Font")); | - |
| 184 | | - |
| 185 | | - |
| 186 | familyEdit = new QLineEdit(q); | - |
| 187 | familyEdit->setReadOnly(true); | - |
| 188 | familyList = new QFontListView(q); | - |
| 189 | familyEdit->setFocusProxy(familyList); | - |
| 190 | | - |
| 191 | familyAccel = new QLabel(q); | - |
| 192 | #ifndef QT_NO_SHORTCUT | - |
| 193 | familyAccel->setBuddy(familyList); | - |
| 194 | #endif | - |
| 195 | familyAccel->setIndent(2); | - |
| 196 | | - |
| 197 | styleEdit = new QLineEdit(q); | - |
| 198 | styleEdit->setReadOnly(true); | - |
| 199 | styleList = new QFontListView(q); | - |
| 200 | styleEdit->setFocusProxy(styleList); | - |
| 201 | | - |
| 202 | styleAccel = new QLabel(q); | - |
| 203 | #ifndef QT_NO_SHORTCUT | - |
| 204 | styleAccel->setBuddy(styleList); | - |
| 205 | #endif | - |
| 206 | styleAccel->setIndent(2); | - |
| 207 | | - |
| 208 | sizeEdit = new QLineEdit(q); | - |
| 209 | sizeEdit->setFocusPolicy(Qt::ClickFocus); | - |
| 210 | QIntValidator *validator = new QIntValidator(1, 512, q); | - |
| 211 | sizeEdit->setValidator(validator); | - |
| 212 | sizeList = new QFontListView(q); | - |
| 213 | | - |
| 214 | sizeAccel = new QLabel(q); | - |
| 215 | #ifndef QT_NO_SHORTCUT | - |
| 216 | sizeAccel->setBuddy(sizeEdit); | - |
| 217 | #endif | - |
| 218 | sizeAccel->setIndent(2); | - |
| 219 | | - |
| 220 | | - |
| 221 | effects = new QGroupBox(q); | - |
| 222 | QVBoxLayout *vbox = new QVBoxLayout(effects); | - |
| 223 | strikeout = new QCheckBox(effects); | - |
| 224 | vbox->addWidget(strikeout); | - |
| 225 | underline = new QCheckBox(effects); | - |
| 226 | vbox->addWidget(underline); | - |
| 227 | | - |
| 228 | sample = new QGroupBox(q); | - |
| 229 | QHBoxLayout *hbox = new QHBoxLayout(sample); | - |
| 230 | sampleEdit = new QLineEdit(sample); | - |
| 231 | sampleEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored)); | - |
| 232 | sampleEdit->setAlignment(Qt::AlignCenter); | - |
| 233 | | - |
| 234 | | - |
| 235 | sampleEdit->setText(QLatin1String("AaBbYyZz")); | - |
| 236 | hbox->addWidget(sampleEdit); | - |
| 237 | | - |
| 238 | writingSystemCombo = new QComboBox(q); | - |
| 239 | | - |
| 240 | writingSystemAccel = new QLabel(q); | - |
| 241 | #ifndef QT_NO_SHORTCUT | - |
| 242 | writingSystemAccel->setBuddy(writingSystemCombo); | - |
| 243 | #endif | - |
| 244 | writingSystemAccel->setIndent(2); | - |
| 245 | | - |
| 246 | size = 0; | - |
| 247 | smoothScalable = false; | - |
| 248 | | - |
| 249 | QObject::connect(writingSystemCombo, SIGNAL(activated(int)), q, SLOT(_q_writingSystemHighlighted(int))); | - |
| 250 | QObject::connect(familyList, SIGNAL(highlighted(int)), q, SLOT(_q_familyHighlighted(int))); | - |
| 251 | QObject::connect(styleList, SIGNAL(highlighted(int)), q, SLOT(_q_styleHighlighted(int))); | - |
| 252 | QObject::connect(sizeList, SIGNAL(highlighted(int)), q, SLOT(_q_sizeHighlighted(int))); | - |
| 253 | QObject::connect(sizeEdit, SIGNAL(textChanged(QString)), q, SLOT(_q_sizeChanged(QString))); | - |
| 254 | | - |
| 255 | QObject::connect(strikeout, SIGNAL(clicked()), q, SLOT(_q_updateSample())); | - |
| 256 | QObject::connect(underline, SIGNAL(clicked()), q, SLOT(_q_updateSample())); | - |
| 257 | | - |
| 258 | for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) { | - |
| 259 | QFontDatabase::WritingSystem ws = QFontDatabase::WritingSystem(i); | - |
| 260 | QString writingSystemName = QFontDatabase::writingSystemName(ws); | - |
| 261 | if (writingSystemName.isEmpty()) | - |
| 262 | break; | - |
| 263 | writingSystemCombo->addItem(writingSystemName); | - |
| 264 | } | - |
| 265 | | - |
| 266 | updateFamilies(); | - |
| 267 | if (familyList->count() != 0) { | - |
| 268 | familyList->setCurrentItem(0); | - |
| 269 | sizeList->setCurrentItem(0); | - |
| 270 | } | - |
| 271 | | - |
| 272 | | - |
| 273 | QGridLayout *mainGrid = new QGridLayout(q); | - |
| 274 | | - |
| 275 | int spacing = mainGrid->spacing(); | - |
| 276 | if (spacing >= 0) { | - |
| 277 | mainGrid->setSpacing(0); | - |
| 278 | | - |
| 279 | mainGrid->setColumnMinimumWidth(1, spacing); | - |
| 280 | mainGrid->setColumnMinimumWidth(3, spacing); | - |
| 281 | | - |
| 282 | int margin = 0; | - |
| 283 | mainGrid->getContentsMargins(0, 0, 0, &margin); | - |
| 284 | | - |
| 285 | mainGrid->setRowMinimumHeight(3, margin); | - |
| 286 | mainGrid->setRowMinimumHeight(6, 2); | - |
| 287 | mainGrid->setRowMinimumHeight(8, margin); | - |
| 288 | } | - |
| 289 | | - |
| 290 | mainGrid->addWidget(familyAccel, 0, 0); | - |
| 291 | mainGrid->addWidget(familyEdit, 1, 0); | - |
| 292 | mainGrid->addWidget(familyList, 2, 0); | - |
| 293 | | - |
| 294 | mainGrid->addWidget(styleAccel, 0, 2); | - |
| 295 | mainGrid->addWidget(styleEdit, 1, 2); | - |
| 296 | mainGrid->addWidget(styleList, 2, 2); | - |
| 297 | | - |
| 298 | mainGrid->addWidget(sizeAccel, 0, 4); | - |
| 299 | mainGrid->addWidget(sizeEdit, 1, 4); | - |
| 300 | mainGrid->addWidget(sizeList, 2, 4); | - |
| 301 | | - |
| 302 | mainGrid->setColumnStretch(0, 38); | - |
| 303 | mainGrid->setColumnStretch(2, 24); | - |
| 304 | mainGrid->setColumnStretch(4, 10); | - |
| 305 | | - |
| 306 | mainGrid->addWidget(effects, 4, 0); | - |
| 307 | | - |
| 308 | mainGrid->addWidget(sample, 4, 2, 4, 3); | - |
| 309 | | - |
| 310 | mainGrid->addWidget(writingSystemAccel, 5, 0); | - |
| 311 | mainGrid->addWidget(writingSystemCombo, 7, 0); | - |
| 312 | | - |
| 313 | buttonBox = new QDialogButtonBox(q); | - |
| 314 | mainGrid->addWidget(buttonBox, 9, 0, 1, 5); | - |
| 315 | | - |
| 316 | QPushButton *button | - |
| 317 | = static_cast<QPushButton *>(buttonBox->addButton(QDialogButtonBox::Ok)); | - |
| 318 | QObject::connect(buttonBox, SIGNAL(accepted()), q, SLOT(accept())); | - |
| 319 | button->setDefault(true); | - |
| 320 | | - |
| 321 | buttonBox->addButton(QDialogButtonBox::Cancel); | - |
| 322 | QObject::connect(buttonBox, SIGNAL(rejected()), q, SLOT(reject())); | - |
| 323 | | - |
| 324 | #if defined(Q_OS_WINCE) | - |
| 325 | q->resize(180, 120); | - |
| 326 | #else | - |
| 327 | q->resize(500, 360); | - |
| 328 | #endif // Q_OS_WINCE | - |
| 329 | | - |
| 330 | sizeEdit->installEventFilter(q); | - |
| 331 | familyList->installEventFilter(q); | - |
| 332 | styleList->installEventFilter(q); | - |
| 333 | sizeList->installEventFilter(q); | - |
| 334 | | - |
| 335 | familyList->setFocus(); | - |
| 336 | retranslateStrings(); | - |
| 337 | sampleEdit->setObjectName(QLatin1String("qt_fontDialog_sampleEdit")); | - |
| 338 | } | - |
| 339 | | - |
| 340 | | - |
| 341 | | - |
| 342 | | - |
| 343 | | - |
| 344 | | - |
| 345 | QFontDialog::~QFontDialog() | - |
| 346 | { | - |
| 347 | } | - |
| 348 | | - |
| 349 | | - |
| 350 | | - |
| 351 | | - |
| 352 | | - |
| 353 | | - |
| 354 | | - |
| 355 | | - |
| 356 | | - |
| 357 | | - |
| 358 | | - |
| 359 | | - |
| 360 | | - |
| 361 | | - |
| 362 | | - |
| 363 | | - |
| 364 | | - |
| 365 | | - |
| 366 | | - |
| 367 | | - |
| 368 | | - |
| 369 | | - |
| 370 | | - |
| 371 | | - |
| 372 | | - |
| 373 | QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title, | - |
| 374 | FontDialogOptions options) | - |
| 375 | { | - |
| 376 | return QFontDialogPrivate::getFont(ok, initial, parent, title, options); | - |
| 377 | } | - |
| 378 | | - |
| 379 | | - |
| 380 | | - |
| 381 | | - |
| 382 | | - |
| 383 | | - |
| 384 | | - |
| 385 | | - |
| 386 | | - |
| 387 | | - |
| 388 | | - |
| 389 | | - |
| 390 | | - |
| 391 | | - |
| 392 | | - |
| 393 | | - |
| 394 | | - |
| 395 | | - |
| 396 | | - |
| 397 | | - |
| 398 | | - |
| 399 | QFont QFontDialog::getFont(bool *ok, QWidget *parent) | - |
| 400 | { | - |
| 401 | QFont initial; | - |
| 402 | return QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0); | - |
| 403 | } | - |
| 404 | | - |
| 405 | QFont QFontDialogPrivate::getFont(bool *ok, const QFont &initial, QWidget *parent, | - |
| 406 | const QString &title, QFontDialog::FontDialogOptions options) | - |
| 407 | { | - |
| 408 | QFontDialog dlg(parent); | - |
| 409 | dlg.setOptions(options); | - |
| 410 | dlg.setCurrentFont(initial); | - |
| 411 | if (!title.isEmpty()) | - |
| 412 | dlg.setWindowTitle(title); | - |
| 413 | | - |
| 414 | int ret = (dlg.exec() || (options & QFontDialog::NoButtons)); | - |
| 415 | if (ok) | - |
| 416 | *ok = !!ret; | - |
| 417 | if (ret) { | - |
| 418 | return dlg.selectedFont(); | - |
| 419 | } else { | - |
| 420 | return initial; | - |
| 421 | } | - |
| 422 | } | - |
| 423 | | - |
| 424 | | - |
| 425 | | - |
| 426 | | - |
| 427 | | - |
| 428 | | - |
| 429 | | - |
| 430 | | - |
| 431 | bool QFontDialog::eventFilter(QObject *o , QEvent *e) | - |
| 432 | { | - |
| 433 | Q_D(QFontDialog); | - |
| 434 | if (e->type() == QEvent::KeyPress) { | - |
| 435 | QKeyEvent *k = (QKeyEvent *)e; | - |
| 436 | if (o == d->sizeEdit && | - |
| 437 | (k->key() == Qt::Key_Up || | - |
| 438 | k->key() == Qt::Key_Down || | - |
| 439 | k->key() == Qt::Key_PageUp || | - |
| 440 | k->key() == Qt::Key_PageDown)) { | - |
| 441 | | - |
| 442 | int ci = d->sizeList->currentItem(); | - |
| 443 | (void)QApplication::sendEvent(d->sizeList, k); | - |
| 444 | | - |
| 445 | if (ci != d->sizeList->currentItem() | - |
| 446 | && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this)) | - |
| 447 | d->sizeEdit->selectAll(); | - |
| 448 | return true; | - |
| 449 | } else if ((o == d->familyList || o == d->styleList) && | - |
| 450 | (k->key() == Qt::Key_Return || k->key() == Qt::Key_Enter)) { | - |
| 451 | k->accept(); | - |
| 452 | accept(); | - |
| 453 | return true; | - |
| 454 | } | - |
| 455 | } else if (e->type() == QEvent::FocusIn | - |
| 456 | && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this)) { | - |
| 457 | if (o == d->familyList) | - |
| 458 | d->familyEdit->selectAll(); | - |
| 459 | else if (o == d->styleList) | - |
| 460 | d->styleEdit->selectAll(); | - |
| 461 | else if (o == d->sizeList) | - |
| 462 | d->sizeEdit->selectAll(); | - |
| 463 | } else if (e->type() == QEvent::MouseButtonPress && o == d->sizeList) { | - |
| 464 | d->sizeEdit->setFocus(); | - |
| 465 | } | - |
| 466 | return QDialog::eventFilter(o, e); | - |
| 467 | } | - |
| 468 | | - |
| 469 | void QFontDialogPrivate::initHelper(QPlatformDialogHelper *h) | - |
| 470 | { | - |
| 471 | QFontDialog *d = q_func(); | - |
| 472 | QObject::connect(h, SIGNAL(currentFontChanged(QFont)), d, SIGNAL(currentFontChanged(QFont))); | - |
| 473 | QObject::connect(h, SIGNAL(fontSelected(QFont)), d, SIGNAL(fontSelected(QFont))); | - |
| 474 | static_cast<QPlatformFontDialogHelper *>(h)->setOptions(options); | - |
| 475 | } | - |
| 476 | | - |
| 477 | void QFontDialogPrivate::helperPrepareShow(QPlatformDialogHelper *) | - |
| 478 | { | - |
| 479 | options->setWindowTitle(q_func()->windowTitle()); | - |
| 480 | } | - |
| 481 | | - |
| 482 | | - |
| 483 | | - |
| 484 | | - |
| 485 | | - |
| 486 | | - |
| 487 | void QFontDialogPrivate::updateFamilies() | - |
| 488 | { | - |
| 489 | Q_Q(QFontDialog); | - |
| 490 | | - |
| 491 | enum match_t { MATCH_NONE = 0, MATCH_LAST_RESORT = 1, MATCH_APP = 2, MATCH_FAMILY = 3 }; | - |
| 492 | | - |
| 493 | const QFontDialog::FontDialogOptions scalableMask = (QFontDialog::ScalableFonts | QFontDialog::NonScalableFonts); | - |
| 494 | const QFontDialog::FontDialogOptions spacingMask = (QFontDialog::ProportionalFonts | QFontDialog::MonospacedFonts); | - |
| 495 | const QFontDialog::FontDialogOptions options = q->options(); | - |
| 496 | | - |
| 497 | QFontDatabase fdb; | - |
| 498 | | - |
| 499 | QStringList familyNames; | - |
| 500 | foreach (const QString &family,auto families = fdb.families(writingSystem))); | - |
| 501 | for (const QString &family : families) { | - |
| 502 | if (fdb.isPrivateFamily(family))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 503 | continue; never executed: continue; | 0 |
| 504 | | - |
| 505 | if ((options & scalableMask) && (options & scalableMask) != scalableMask) {| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 506 | if (bool(options & QFontDialog::ScalableFonts) != fdb.isSmoothlyScalable(family))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 507 | continue; never executed: continue; | 0 |
| 508 | } never executed: end of block | 0 |
| 509 | if ((options & spacingMask) && (options & spacingMask) != spacingMask) {| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 510 | if (bool(options & QFontDialog::MonospacedFonts) != fdb.isFixedPitch(family))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 511 | continue; never executed: continue; | 0 |
| 512 | } never executed: end of block | 0 |
| 513 | familyNames << family; | - |
| 514 | } never executed: end of block | 0 |
| 515 | | - |
| 516 | familyList->model()->setStringList(familyNames); | - |
| 517 | | - |
| 518 | QString foundryName1, familyName1, foundryName2, familyName2; | - |
| 519 | int bestFamilyMatch = -1; | - |
| 520 | match_t bestFamilyType = MATCH_NONE; | - |
| 521 | | - |
| 522 | QFont f; | - |
| 523 | | - |
| 524 | | - |
| 525 | QFontDatabase::parseFontName(family, foundryName1, familyName1); | - |
| 526 | | - |
| 527 | QStringList::const_iterator it = familyNames.constBegin(); | - |
| 528 | int i = 0; | - |
| 529 | for(; it != familyNames.constEnd(); ++it, ++i) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 530 | QFontDatabase::parseFontName(*it, foundryName2, familyName2); | - |
| 531 | | - |
| 532 | | - |
| 533 | if (familyName1 == familyName2) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 534 | bestFamilyType = MATCH_FAMILY; | - |
| 535 | if (foundryName1 == foundryName2) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 536 | bestFamilyMatch = i; | - |
| 537 | break; never executed: break; | 0 |
| 538 | } | - |
| 539 | if (bestFamilyMatch < MATCH_FAMILY)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 540 | bestFamilyMatch = i; never executed: bestFamilyMatch = i; | 0 |
| 541 | } never executed: end of block | 0 |
| 542 | | - |
| 543 | | - |
| 544 | match_t type = MATCH_NONE; | - |
| 545 | if (bestFamilyType <= MATCH_NONE && familyName2 == f.lastResortFamily())| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 546 | type = MATCH_LAST_RESORT; never executed: type = MATCH_LAST_RESORT; | 0 |
| 547 | if (bestFamilyType <= MATCH_LAST_RESORT && familyName2 == f.family())| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 548 | type = MATCH_APP; never executed: type = MATCH_APP; | 0 |
| 549 | | - |
| 550 | if (type != MATCH_NONE) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 551 | bestFamilyType = type; | - |
| 552 | bestFamilyMatch = i; | - |
| 553 | } never executed: end of block | 0 |
| 554 | } never executed: end of block | 0 |
| 555 | | - |
| 556 | if (i != -1 && bestFamilyType != MATCH_NONE)| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 557 | familyList->setCurrentItem(bestFamilyMatch); never executed: familyList->setCurrentItem(bestFamilyMatch); | 0 |
| 558 | else | - |
| 559 | familyList->setCurrentItem(0); never executed: familyList->setCurrentItem(0); | 0 |
| 560 | familyEdit->setText(familyList->currentText()); | - |
| 561 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 562 | && familyList->hasFocus())| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 563 | familyEdit->selectAll(); never executed: familyEdit->selectAll(); | 0 |
| 564 | | - |
| 565 | updateStyles(); | - |
| 566 | } never executed: end of block | 0 |
| 567 | | - |
| 568 | | - |
| 569 | | - |
| 570 | | - |
| 571 | | - |
| 572 | void QFontDialogPrivate::updateStyles() | - |
| 573 | { | - |
| 574 | Q_Q(QFontDialog); | - |
| 575 | QStringList styles = fdb.styles(familyList->currentText()); | - |
| 576 | styleList->model()->setStringList(styles); | - |
| 577 | | - |
| 578 | if (styles.isEmpty()) { | - |
| 579 | styleEdit->clear(); | - |
| 580 | smoothScalable = false; | - |
| 581 | } else { | - |
| 582 | if (!style.isEmpty()) { | - |
| 583 | bool found = false; | - |
| 584 | bool first = true; | - |
| 585 | QString cstyle = style; | - |
| 586 | | - |
| 587 | redo: | - |
| 588 | for (int i = 0; i < (int)styleList->count(); i++) { | - |
| 589 | if (cstyle == styleList->text(i)) { | - |
| 590 | styleList->setCurrentItem(i); | - |
| 591 | found = true; | - |
| 592 | break; | - |
| 593 | } | - |
| 594 | } | - |
| 595 | if (!found && first) { | - |
| 596 | if (cstyle.contains(QLatin1String("Italic"))) { | - |
| 597 | cstyle.replace(QLatin1String("Italic"), QLatin1String("Oblique")); | - |
| 598 | first = false; | - |
| 599 | goto redo; | - |
| 600 | } else if (cstyle.contains(QLatin1String("Oblique"))) { | - |
| 601 | cstyle.replace(QLatin1String("Oblique"), QLatin1String("Italic")); | - |
| 602 | first = false; | - |
| 603 | goto redo; | - |
| 604 | } | - |
| 605 | } | - |
| 606 | if (!found) | - |
| 607 | styleList->setCurrentItem(0); | - |
| 608 | } else { | - |
| 609 | styleList->setCurrentItem(0); | - |
| 610 | } | - |
| 611 | | - |
| 612 | styleEdit->setText(styleList->currentText()); | - |
| 613 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) | - |
| 614 | && styleList->hasFocus()) | - |
| 615 | styleEdit->selectAll(); | - |
| 616 | | - |
| 617 | smoothScalable = fdb.isSmoothlyScalable(familyList->currentText(), styleList->currentText()); | - |
| 618 | } | - |
| 619 | | - |
| 620 | updateSizes(); | - |
| 621 | } | - |
| 622 | | - |
| 623 | | - |
| 624 | | - |
| 625 | | - |
| 626 | | - |
| 627 | | - |
| 628 | | - |
| 629 | void QFontDialogPrivate::updateSizes() | - |
| 630 | { | - |
| 631 | Q_Q(QFontDialog); | - |
| 632 | | - |
| 633 | if (!familyList->currentText().isEmpty()) { | - |
| 634 | QList<int> sizes = fdb.pointSizes(familyList->currentText(), styleList->currentText()); | - |
| 635 | | - |
| 636 | int i = 0; | - |
| 637 | int current = -1; | - |
| 638 | QStringList str_sizes; | - |
| 639 | str_sizes.reserve(sizes.size()); | - |
| 640 | for(QList<int>::const_iterator it = sizes.constBegin(); it != sizes.constEnd(); ++it) { | - |
| 641 | str_sizes.append(QString::number(*it)); | - |
| 642 | if (current == -1 && *it == size) | - |
| 643 | current = i; | - |
| 644 | ++i; | - |
| 645 | } | - |
| 646 | sizeList->model()->setStringList(str_sizes); | - |
| 647 | if (current != -1) | - |
| 648 | sizeList->setCurrentItem(current); | - |
| 649 | | - |
| 650 | const QSignalBlocker blocker(sizeEdit); | - |
| 651 | sizeEdit->setText((smoothScalable ? QString::number(size) : sizeList->currentText())); | - |
| 652 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) | - |
| 653 | && sizeList->hasFocus()) | - |
| 654 | sizeEdit->selectAll(); | - |
| 655 | } else { | - |
| 656 | sizeEdit->clear(); | - |
| 657 | } | - |
| 658 | | - |
| 659 | _q_updateSample(); | - |
| 660 | } | - |
| 661 | | - |
| 662 | void QFontDialogPrivate::_q_updateSample() | - |
| 663 | { | - |
| 664 | | - |
| 665 | int pSize = sizeEdit->text().toInt(); | - |
| 666 | QFont newFont(fdb.font(familyList->currentText(), style, pSize)); | - |
| 667 | newFont.setStrikeOut(strikeout->isChecked()); | - |
| 668 | newFont.setUnderline(underline->isChecked()); | - |
| 669 | | - |
| 670 | if (familyList->currentText().isEmpty()) | - |
| 671 | sampleEdit->clear(); | - |
| 672 | | - |
| 673 | updateSampleFont(newFont); | - |
| 674 | } | - |
| 675 | | - |
| 676 | void QFontDialogPrivate::updateSampleFont(const QFont &newFont) | - |
| 677 | { | - |
| 678 | Q_Q(QFontDialog); | - |
| 679 | if (newFont != sampleEdit->font()) { | - |
| 680 | sampleEdit->setFont(newFont); | - |
| 681 | emit q->currentFontChanged(newFont); | - |
| 682 | } | - |
| 683 | } | - |
| 684 | | - |
| 685 | | - |
| 686 | | - |
| 687 | | - |
| 688 | void QFontDialogPrivate::_q_writingSystemHighlighted(int index) | - |
| 689 | { | - |
| 690 | writingSystem = QFontDatabase::WritingSystem(index); | - |
| 691 | sampleEdit->setText(fdb.writingSystemSample(writingSystem)); | - |
| 692 | updateFamilies(); | - |
| 693 | } | - |
| 694 | | - |
| 695 | | - |
| 696 | | - |
| 697 | | - |
| 698 | void QFontDialogPrivate::_q_familyHighlighted(int i) | - |
| 699 | { | - |
| 700 | Q_Q(QFontDialog); | - |
| 701 | family = familyList->text(i); | - |
| 702 | familyEdit->setText(family); | - |
| 703 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) | - |
| 704 | && familyList->hasFocus()) | - |
| 705 | familyEdit->selectAll(); | - |
| 706 | | - |
| 707 | updateStyles(); | - |
| 708 | } | - |
| 709 | | - |
| 710 | | - |
| 711 | | - |
| 712 | | - |
| 713 | | - |
| 714 | | - |
| 715 | void QFontDialogPrivate::_q_styleHighlighted(int index) | - |
| 716 | { | - |
| 717 | Q_Q(QFontDialog); | - |
| 718 | QString s = styleList->text(index); | - |
| 719 | styleEdit->setText(s); | - |
| 720 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) | - |
| 721 | && styleList->hasFocus()) | - |
| 722 | styleEdit->selectAll(); | - |
| 723 | | - |
| 724 | style = s; | - |
| 725 | | - |
| 726 | updateSizes(); | - |
| 727 | } | - |
| 728 | | - |
| 729 | | - |
| 730 | | - |
| 731 | | - |
| 732 | | - |
| 733 | | - |
| 734 | void QFontDialogPrivate::_q_sizeHighlighted(int index) | - |
| 735 | { | - |
| 736 | Q_Q(QFontDialog); | - |
| 737 | QString s = sizeList->text(index); | - |
| 738 | sizeEdit->setText(s); | - |
| 739 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) | - |
| 740 | && sizeEdit->hasFocus()) | - |
| 741 | sizeEdit->selectAll(); | - |
| 742 | | - |
| 743 | size = s.toInt(); | - |
| 744 | _q_updateSample(); | - |
| 745 | } | - |
| 746 | | - |
| 747 | | - |
| 748 | | - |
| 749 | | - |
| 750 | | - |
| 751 | | - |
| 752 | | - |
| 753 | void QFontDialogPrivate::_q_sizeChanged(const QString &s) | - |
| 754 | { | - |
| 755 | | - |
| 756 | int size = s.toInt(); | - |
| 757 | if (this->size == size) | - |
| 758 | return; | - |
| 759 | | - |
| 760 | this->size = size; | - |
| 761 | if (sizeList->count() != 0) { | - |
| 762 | int i; | - |
| 763 | for (i = 0; i < sizeList->count() - 1; i++) { | - |
| 764 | if (sizeList->text(i).toInt() >= this->size) | - |
| 765 | break; | - |
| 766 | } | - |
| 767 | const QSignalBlocker blocker(sizeList); | - |
| 768 | if (sizeList->text(i).toInt() == this->size) | - |
| 769 | sizeList->setCurrentItem(i); | - |
| 770 | else | - |
| 771 | sizeList->clearSelection(); | - |
| 772 | } | - |
| 773 | _q_updateSample(); | - |
| 774 | } | - |
| 775 | | - |
| 776 | void QFontDialogPrivate::retranslateStrings() | - |
| 777 | { | - |
| 778 | familyAccel->setText(QFontDialog::tr("&Font")); | - |
| 779 | styleAccel->setText(QFontDialog::tr("Font st&yle")); | - |
| 780 | sizeAccel->setText(QFontDialog::tr("&Size")); | - |
| 781 | effects->setTitle(QFontDialog::tr("Effects")); | - |
| 782 | strikeout->setText(QFontDialog::tr("Stri&keout")); | - |
| 783 | underline->setText(QFontDialog::tr("&Underline")); | - |
| 784 | sample->setTitle(QFontDialog::tr("Sample")); | - |
| 785 | writingSystemAccel->setText(QFontDialog::tr("Wr&iting System")); | - |
| 786 | } | - |
| 787 | | - |
| 788 | | - |
| 789 | | - |
| 790 | | - |
| 791 | void QFontDialog::changeEvent(QEvent *e) | - |
| 792 | { | - |
| 793 | Q_D(QFontDialog); | - |
| 794 | if (e->type() == QEvent::LanguageChange) { | - |
| 795 | d->retranslateStrings(); | - |
| 796 | } | - |
| 797 | QDialog::changeEvent(e); | - |
| 798 | } | - |
| 799 | | - |
| 800 | | - |
| 801 | | - |
| 802 | | - |
| 803 | | - |
| 804 | | - |
| 805 | | - |
| 806 | | - |
| 807 | | - |
| 808 | | - |
| 809 | | - |
| 810 | | - |
| 811 | | - |
| 812 | | - |
| 813 | | - |
| 814 | void QFontDialog::setCurrentFont(const QFont &font) | - |
| 815 | { | - |
| 816 | Q_D(QFontDialog); | - |
| 817 | d->family = font.family(); | - |
| 818 | d->style = d->fdb.styleString(font); | - |
| 819 | d->size = font.pointSize(); | - |
| 820 | if (d->size == -1) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 821 | QFontInfo fi(font); | - |
| 822 | d->size = fi.pointSize(); | - |
| 823 | } never executed: end of block | 0 |
| 824 | d->strikeout->setChecked(font.strikeOut()); | - |
| 825 | d->underline->setChecked(font.underline()); | - |
| 826 | d->updateFamilies(); | - |
| 827 | if (d->canBeNativeDialog()) {if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 828 | helper->setCurrentFont(font); never executed: helper->setCurrentFont(font); | 0 |
| } never executed: end of block }never executed: end of block | |
| 830 | | - |
| 831 | | - |
| 832 | | - |
| 833 | | - |
| 834 | | - |
| 835 | | - |
| 836 | | - |
| 837 | | - |
| 838 | QFont QFontDialog::currentFont() const | - |
| 839 | { | - |
| 840 | Q_D(const QFontDialog); | - |
| 841 | if (d->canBeNativeDialog()) {if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 842 | return helper->currentFont(); never executed: return helper->currentFont(); | 0 |
| 843 | }return d->sampleEdit->font(); never executed: return d->sampleEdit->font(); | 0 |
| 844 | } | - |
| 845 | | - |
| 846 | | - |
| 847 | | - |
| 848 | | - |
| 849 | | - |
| 850 | | - |
| 851 | | - |
| 852 | | - |
| 853 | | - |
| 854 | QFont QFontDialog::selectedFont() const | - |
| 855 | { | - |
| 856 | Q_D(const QFontDialog); | - |
| 857 | return d->selectedFont; | - |
| 858 | } | - |
| 859 | | - |
| 860 | | - |
| 861 | | - |
| 862 | | - |
| 863 | | - |
| 864 | | - |
| 865 | | - |
| 866 | | - |
| 867 | | - |
| 868 | | - |
| 869 | | - |
| 870 | | - |
| 871 | | - |
| 872 | | - |
| 873 | | - |
| 874 | | - |
| 875 | | - |
| 876 | | - |
| 877 | | - |
| 878 | | - |
| 879 | | - |
| 880 | | - |
| 881 | | - |
| 882 | | - |
| 883 | | - |
| 884 | | - |
| 885 | | - |
| 886 | | - |
| 887 | | - |
| 888 | | - |
| 889 | | - |
| 890 | | - |
| 891 | | - |
| 892 | void QFontDialog::setOption(FontDialogOption option, bool on) | - |
| 893 | { | - |
| 894 | const QFontDialog::FontDialogOptions previousOptions = options(); | - |
| 895 | if (!(previousOptions & option) != !on) | - |
| 896 | setOptions(previousOptions ^ option); | - |
| 897 | } | - |
| 898 | | - |
| 899 | | - |
| 900 | | - |
| 901 | | - |
| 902 | | - |
| 903 | | - |
| 904 | | - |
| 905 | bool QFontDialog::testOption(FontDialogOption option) const | - |
| 906 | { | - |
| 907 | Q_D(const QFontDialog); | - |
| 908 | return d->options->testOption(static_cast<QFontDialogOptions::FontDialogOption>(option)); | - |
| 909 | } | - |
| 910 | | - |
| 911 | | - |
| 912 | | - |
| 913 | | - |
| 914 | | - |
| 915 | | - |
| 916 | | - |
| 917 | | - |
| 918 | | - |
| 919 | | - |
| 920 | | - |
| 921 | | - |
| 922 | | - |
| 923 | | - |
| 924 | void QFontDialog::setOptions(FontDialogOptions options) | - |
| 925 | { | - |
| 926 | Q_D(QFontDialog); | - |
| 927 | | - |
| 928 | if (QFontDialog::options() == options) | - |
| 929 | return; | - |
| 930 | | - |
| 931 | d->options->setOptions(QFontDialogOptions::FontDialogOptions(int(options))); | - |
| 932 | d->buttonBox->setVisible(!(options & NoButtons)); | - |
| 933 | } | - |
| 934 | | - |
| 935 | QFontDialog::FontDialogOptions QFontDialog::options() const | - |
| 936 | { | - |
| 937 | Q_D(const QFontDialog); | - |
| 938 | return QFontDialog::FontDialogOptions(int(d->options->options())); | - |
| 939 | } | - |
| 940 | | - |
| 941 | | - |
| 942 | | - |
| 943 | | - |
| 944 | | - |
| 945 | | - |
| 946 | | - |
| 947 | | - |
| 948 | | - |
| 949 | | - |
| 950 | void QFontDialog::open(QObject *receiver, const char *member) | - |
| 951 | { | - |
| 952 | Q_D(QFontDialog); | - |
| 953 | connect(this, SIGNAL(fontSelected(QFont)), receiver, member); | - |
| 954 | d->receiverToDisconnectOnClose = receiver; | - |
| 955 | d->memberToDisconnectOnClose = member; | - |
| 956 | QDialog::open(); | - |
| 957 | } | - |
| 958 | | - |
| 959 | | - |
| 960 | | - |
| 961 | | - |
| 962 | | - |
| 963 | | - |
| 964 | | - |
| 965 | | - |
| 966 | | - |
| 967 | | - |
| 968 | | - |
| 969 | | - |
| 970 | | - |
| 971 | | - |
| 972 | | - |
| 973 | | - |
| 974 | | - |
| 975 | | - |
| 976 | | - |
| 977 | | - |
| 978 | | - |
| 979 | | - |
| 980 | | - |
| 981 | | - |
| 982 | | - |
| 983 | | - |
| 984 | | - |
| 985 | | - |
| 986 | | - |
| 987 | | - |
| 988 | | - |
| 989 | | - |
| 990 | | - |
| 991 | void QFontDialog::setVisible(bool visible) | - |
| 992 | { | - |
| 993 | if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden) != visible) | - |
| 994 | return; | - |
| 995 | Q_D(QFontDialog); | - |
| 996 | if (d->canBeNativeDialog()) | - |
| 997 | d->setNativeDialogVisible(visible); | - |
| 998 | if (d->nativeDialogInUse) { | - |
| 999 | | - |
| 1000 | | - |
| 1001 | setAttribute(Qt::WA_DontShowOnScreen, true); | - |
| 1002 | } else { | - |
| 1003 | d->nativeDialogInUse = false; | - |
| 1004 | setAttribute(Qt::WA_DontShowOnScreen, false); | - |
| 1005 | } | - |
| 1006 | QDialog::setVisible(visible); | - |
| 1007 | } | - |
| 1008 | | - |
| 1009 | | - |
| 1010 | | - |
| 1011 | | - |
| 1012 | | - |
| 1013 | | - |
| 1014 | | - |
| 1015 | | - |
| 1016 | void QFontDialog::done(int result) | - |
| 1017 | { | - |
| 1018 | Q_D(QFontDialog); | - |
| 1019 | QDialog::done(result); | - |
| 1020 | if (result == Accepted) { | - |
| 1021 | | - |
| 1022 | QFont selectedFont = currentFont(); | - |
| 1023 | if(selectedFont != d->selectedFont) | - |
| 1024 | emit(currentFontChanged(selectedFont)); | - |
| 1025 | d->selectedFont = selectedFont; | - |
| 1026 | emit fontSelected(d->selectedFont); | - |
| 1027 | } else | - |
| 1028 | d->selectedFont = QFont(); | - |
| 1029 | if (d->receiverToDisconnectOnClose) { | - |
| 1030 | disconnect(this, SIGNAL(fontSelected(QFont)), | - |
| 1031 | d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); | - |
| 1032 | d->receiverToDisconnectOnClose = 0; | - |
| 1033 | } | - |
| 1034 | d->memberToDisconnectOnClose.clear(); | - |
| 1035 | } | - |
| 1036 | | - |
| 1037 | bool QFontDialogPrivate::canBeNativeDialog() const | - |
| 1038 | { | - |
| 1039 | | - |
| 1040 | | - |
| 1041 | const QDialog * const q = static_cast<const QDialog*>(q_ptr); | - |
| 1042 | if (nativeDialogInUse)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 1043 | return true; never executed: return true; | 0 |
| 1044 | if (QCoreApplication::testAttribute(Qt::AA_DontUseNativeDialogs)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 1045 | ||| TRUE | never evaluated | | FALSE | never evaluated |
q->testAttribute(Qt::WA_DontShowOnScreen))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| return false;| TRUE | never evaluated | | FALSE | never evaluated |
| |
| if| TRUE | never evaluated | | FALSE | never evaluated |
)| TRUE | never evaluated | | FALSE | never evaluated |
| |
| 1046 | ||| TRUE | never evaluated | | FALSE | never evaluated |
(options->options() & QFontDialog::DontUseNativeDialog))) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 1047 | return false; never executed: return false; | 0 |
| 1048 | } | - |
| 1049 | | - |
| 1050 | QLatin1String staticName(QFontDialog::staticMetaObject.className()); | - |
| 1051 | QLatin1String dynamicName(q->metaObject()->className()); | - |
| 1052 | return (staticName == dynamicName); never executed: return (staticName == dynamicName); | 0 |
| 1053 | } | - |
| 1054 | | - |
| 1055 | QT_END_NAMESPACE | - |
| 1056 | | - |
| 1057 | #include "qfontdialog.moc" | - |
| 1058 | #include "moc_qfontdialog.cpp" | - |
| 1059 | | - |
| 1060 | #endif // QT_NO_FONTDIALOG | - |
| | |