Changeset View
Changeset View
Standalone View
Standalone View
src/kfontchooser.cpp
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Line(s) | 94 | // QStringList fontList; | |||
---|---|---|---|---|---|
124 | QCheckBox *styleCheckbox = nullptr; | 124 | QCheckBox *styleCheckbox = nullptr; | ||
125 | QCheckBox *sizeCheckbox = nullptr; | 125 | QCheckBox *sizeCheckbox = nullptr; | ||
126 | QLabel *sizeLabel = nullptr; | 126 | QLabel *sizeLabel = nullptr; | ||
127 | QListWidget *familyListBox = nullptr; | 127 | QListWidget *familyListBox = nullptr; | ||
128 | QListWidget *styleListBox = nullptr; | 128 | QListWidget *styleListBox = nullptr; | ||
129 | QListWidget *sizeListBox = nullptr; | 129 | QListWidget *sizeListBox = nullptr; | ||
130 | QCheckBox *sizeIsRelativeCheckBox = nullptr; | 130 | QCheckBox *sizeIsRelativeCheckBox = nullptr; | ||
131 | 131 | | |||
132 | QCheckBox *onlyFixedCheckbox = nullptr; | ||||
133 | | ||||
132 | QFont selFont; | 134 | QFont selFont; | ||
133 | 135 | | |||
134 | QString selectedStyle; | 136 | QString selectedStyle; | ||
135 | qreal selectedSize; | 137 | qreal selectedSize; | ||
136 | 138 | | |||
137 | QString standardSizeAtCustom; | 139 | QString standardSizeAtCustom; | ||
138 | int customSizeRow; | 140 | int customSizeRow; | ||
139 | 141 | | |||
▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Line(s) | 172 | { | |||
336 | 338 | | |||
337 | connect(sizeOfFont, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [this](const double size) { | 339 | connect(sizeOfFont, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [this](const double size) { | ||
338 | _k_size_value_slot(size); | 340 | _k_size_value_slot(size); | ||
339 | }); | 341 | }); | ||
340 | 342 | | |||
341 | connect(sizeListBox, &QListWidget::currentTextChanged, [this](const QString &size) { | 343 | connect(sizeListBox, &QListWidget::currentTextChanged, [this](const QString &size) { | ||
342 | _k_size_chosen_slot(size); | 344 | _k_size_chosen_slot(size); | ||
343 | }); | 345 | }); | ||
344 | 346 | | |||
345 | if (flags & ShowDifferences) { | 347 | if (flags & ShowDifferences) { | ||
bport: This comment is still valid ? | |||||
Yes, that's after setting the font family/style/size list views and the size DoubleSpinBox. ahmadsamir: Yes, that's after setting the font family/style/size list views and the size DoubleSpinBox. | |||||
346 | connect(sizeCheckbox, &QAbstractButton::toggled, sizeListBox, &QWidget::setEnabled); | 348 | connect(sizeCheckbox, &QAbstractButton::toggled, sizeListBox, &QWidget::setEnabled); | ||
347 | connect(sizeCheckbox, &QAbstractButton::toggled, sizeOfFont, &QWidget::setEnabled); | 349 | connect(sizeCheckbox, &QAbstractButton::toggled, sizeOfFont, &QWidget::setEnabled); | ||
348 | } | 350 | } | ||
349 | 351 | | |||
350 | // Add the font preview into the lower part of mainLayout | 352 | // Add the font preview into the lower part of mainLayout | ||
351 | sampleEdit = new QTextEdit(page); | 353 | sampleEdit = new QTextEdit(page); | ||
352 | sampleEdit->setAcceptRichText(false); | 354 | sampleEdit->setAcceptRichText(false); | ||
353 | QFont tmpFont(q->font().family(), 64, QFont::Black); | 355 | QFont tmpFont(q->font().family(), 64, QFont::Black); | ||
Show All 10 Lines | 365 | KFontChooser::tr("This sample text illustrates the current settings. " | |||
364 | "You may edit it to test special characters."); | 366 | "You may edit it to test special characters."); | ||
365 | sampleEdit->setWhatsThis(sampleEditWhatsThisText); | 367 | sampleEdit->setWhatsThis(sampleEditWhatsThisText); | ||
366 | 368 | | |||
367 | connect(q, &KFontChooser::fontSelected, q, [this](const QFont &font) { | 369 | connect(q, &KFontChooser::fontSelected, q, [this](const QFont &font) { | ||
368 | _k_displaySample(font); | 370 | _k_displaySample(font); | ||
369 | }); | 371 | }); | ||
370 | 372 | | |||
371 | mainLayout->addWidget(sampleEdit); | 373 | mainLayout->addWidget(sampleEdit); | ||
374 | | ||||
375 | // Add a checkbox to toggle showing only monospace/fixed-width fonts | ||||
376 | onlyFixedCheckbox = new QCheckBox(KFontChooser::tr("Show only monospaced fonts", "@option:check")); | ||||
377 | onlyFixedCheckbox->setEnabled(flags ^ ShowDifferences); | ||||
378 | onlyFixedCheckbox->setChecked(usingFixed); | ||||
379 | | ||||
380 | connect(onlyFixedCheckbox, &QAbstractButton::toggled, q, [this](const bool state) { | ||||
381 | q->setFont(selFont, state); | ||||
382 | }); | ||||
383 | | ||||
384 | if (flags & ShowDifferences) { // In this mode follow the state of the familyCheckbox | ||||
bport: I think there you can connect directly to setEnabled, you don't need a lambda | |||||
385 | connect(familyCheckbox, &QAbstractButton::toggled, onlyFixedCheckbox, &QWidget::setEnabled); | ||||
386 | } | ||||
387 | mainLayout->addWidget(onlyFixedCheckbox); | ||||
388 | | ||||
372 | // Finished setting up the chooser layout | 389 | // Finished setting up the chooser layout | ||
373 | 390 | | |||
374 | // lets initialize the display if possible | 391 | // lets initialize the display if possible | ||
375 | if (usingFixed) { | 392 | if (usingFixed) { | ||
376 | q->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont), usingFixed); | 393 | q->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont), usingFixed); | ||
377 | } else { | 394 | } else { | ||
dfaure: would `true` be more readable?
(same for the previous line, actually) | |||||
Indeed; however onlyFixedCheckbox->setChecked(usingFixed) doesn't need to be in that if block at all. ahmadsamir: Indeed; however onlyFixedCheckbox->setChecked(usingFixed) doesn't need to be in that if block… | |||||
378 | q->setFont(QGuiApplication::font(), usingFixed); | 395 | q->setFont(QGuiApplication::font(), usingFixed); | ||
379 | } | 396 | } | ||
380 | 397 | | |||
381 | // check or uncheck or gray out the "relative" checkbox | 398 | // check or uncheck or gray out the "relative" checkbox | ||
382 | if (sizeIsRelativeState && sizeIsRelativeCheckBox) { | 399 | if (sizeIsRelativeState && sizeIsRelativeCheckBox) { | ||
383 | q->setSizeIsRelative(*sizeIsRelativeState); | 400 | q->setSizeIsRelative(*sizeIsRelativeState); | ||
384 | } | 401 | } | ||
385 | 402 | | |||
▲ Show 20 Lines • Show All 600 Lines • Show Last 20 Lines |
This comment is still valid ?