Charlie Jiang pushed to branch gsoc-2022-chariri at FreeType / FreeType Demo Programs
Commits:
-
b38b2921
by Charlie Jiang at 2022-07-02T20:33:18+08:00
7 changed files:
- src/ftinspect/maingui.cpp
- src/ftinspect/models/ttsettingscomboboxmodel.cpp
- src/ftinspect/models/ttsettingscomboboxmodel.hpp
- src/ftinspect/panels/settingpanel.cpp
- src/ftinspect/panels/settingpanel.hpp
- src/ftinspect/widgets/custom_widgets.cpp
- src/ftinspect/widgets/custom_widgets.hpp
Changes:
... | ... | @@ -553,12 +553,12 @@ void |
553 | 553 | MainGUI::createLayout()
|
554 | 554 | {
|
555 | 555 | // left side
|
556 | - fontFilenameLabel_ = new QLabel;
|
|
556 | + fontFilenameLabel_ = new QLabel(this);
|
|
557 | 557 | |
558 | 558 | infoLeftLayout_ = new QHBoxLayout;
|
559 | 559 | infoLeftLayout_->addWidget(fontFilenameLabel_);
|
560 | 560 | |
561 | - settingPanel_ = new SettingPanel(engine_);
|
|
561 | + settingPanel_ = new SettingPanel(this, engine_);
|
|
562 | 562 | |
563 | 563 | leftLayout_ = new QVBoxLayout;
|
564 | 564 | leftLayout_->addLayout(infoLeftLayout_);
|
... | ... | @@ -566,7 +566,7 @@ MainGUI::createLayout() |
566 | 566 | |
567 | 567 | // we don't want to expand the left side horizontally;
|
568 | 568 | // to change the policy we have to use a widget wrapper
|
569 | - leftWidget_ = new QWidget;
|
|
569 | + leftWidget_ = new QWidget(this);
|
|
570 | 570 | leftWidget_->setLayout(leftLayout_);
|
571 | 571 | |
572 | 572 | QSizePolicy leftWidgetPolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
... | ... | @@ -577,11 +577,11 @@ MainGUI::createLayout() |
577 | 577 | leftWidget_->setSizePolicy(leftWidgetPolicy);
|
578 | 578 | |
579 | 579 | // right side
|
580 | - glyphIndexLabel_ = new QLabel;
|
|
581 | - glyphNameLabel_ = new QLabel;
|
|
582 | - fontNameLabel_ = new QLabel;
|
|
580 | + glyphIndexLabel_ = new QLabel(this);
|
|
581 | + glyphNameLabel_ = new QLabel(this);
|
|
582 | + fontNameLabel_ = new QLabel(this);
|
|
583 | 583 | |
584 | - glyphScene_ = new QGraphicsScene;
|
|
584 | + glyphScene_ = new QGraphicsScene(this);
|
|
585 | 585 | glyphScene_->addItem(new Grid(gridPen_, axisPen_));
|
586 | 586 | |
587 | 587 | currentGlyphBitmapItem_ = NULL;
|
... | ... | @@ -589,7 +589,7 @@ MainGUI::createLayout() |
589 | 589 | currentGlyphPointsItem_ = NULL;
|
590 | 590 | currentGlyphPointNumbersItem_ = NULL;
|
591 | 591 | |
592 | - glyphView_ = new QGraphicsViewx;
|
|
592 | + glyphView_ = new QGraphicsViewx(this);
|
|
593 | 593 | glyphView_->setRenderHint(QPainter::Antialiasing, true);
|
594 | 594 | glyphView_->setDragMode(QGraphicsView::ScrollHandDrag);
|
595 | 595 | glyphView_->setOptimizationFlags(QGraphicsView::DontSavePainterState);
|
... | ... | @@ -597,7 +597,7 @@ MainGUI::createLayout() |
597 | 597 | glyphView_->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
598 | 598 | glyphView_->setScene(glyphScene_);
|
599 | 599 | |
600 | - sizeLabel_ = new QLabel(tr("Size "));
|
|
600 | + sizeLabel_ = new QLabel(tr("Size "), this);
|
|
601 | 601 | sizeLabel_->setAlignment(Qt::AlignRight);
|
602 | 602 | sizeDoubleSpinBox_ = new QDoubleSpinBox;
|
603 | 603 | sizeDoubleSpinBox_->setAlignment(Qt::AlignRight);
|
... | ... | @@ -605,42 +605,43 @@ MainGUI::createLayout() |
605 | 605 | sizeDoubleSpinBox_->setRange(1, 500);
|
606 | 606 | sizeLabel_->setBuddy(sizeDoubleSpinBox_);
|
607 | 607 | |
608 | - unitsComboBox_ = new QComboBox;
|
|
608 | + unitsComboBox_ = new QComboBox(this);
|
|
609 | 609 | unitsComboBox_->insertItem(Units_px, "px");
|
610 | 610 | unitsComboBox_->insertItem(Units_pt, "pt");
|
611 | 611 | |
612 | - dpiLabel_ = new QLabel(tr("DPI "));
|
|
612 | + dpiLabel_ = new QLabel(tr("DPI "), this);
|
|
613 | 613 | dpiLabel_->setAlignment(Qt::AlignRight);
|
614 | - dpiSpinBox_ = new QSpinBox;
|
|
614 | + dpiSpinBox_ = new QSpinBox(this);
|
|
615 | 615 | dpiSpinBox_->setAlignment(Qt::AlignRight);
|
616 | 616 | dpiSpinBox_->setRange(10, 600);
|
617 | 617 | dpiLabel_->setBuddy(dpiSpinBox_);
|
618 | 618 | |
619 | - toStartButtonx_ = new QPushButtonx("|<");
|
|
620 | - toM1000Buttonx_ = new QPushButtonx("-1000");
|
|
621 | - toM100Buttonx_ = new QPushButtonx("-100");
|
|
622 | - toM10Buttonx_ = new QPushButtonx("-10");
|
|
623 | - toM1Buttonx_ = new QPushButtonx("-1");
|
|
624 | - toP1Buttonx_ = new QPushButtonx("+1");
|
|
625 | - toP10Buttonx_ = new QPushButtonx("+10");
|
|
626 | - toP100Buttonx_ = new QPushButtonx("+100");
|
|
627 | - toP1000Buttonx_ = new QPushButtonx("+1000");
|
|
628 | - toEndButtonx_ = new QPushButtonx(">|");
|
|
629 | - |
|
630 | - zoomLabel_ = new QLabel(tr("Zoom Factor"));
|
|
619 | + toStartButtonx_ = new QPushButtonx("|<", this);
|
|
620 | + toM1000Buttonx_ = new QPushButtonx("-1000", this);
|
|
621 | + toM100Buttonx_ = new QPushButtonx("-100", this);
|
|
622 | + toM10Buttonx_ = new QPushButtonx("-10", this);
|
|
623 | + toM1Buttonx_ = new QPushButtonx("-1", this);
|
|
624 | + toP1Buttonx_ = new QPushButtonx("+1", this);
|
|
625 | + toP10Buttonx_ = new QPushButtonx("+10", this);
|
|
626 | + toP100Buttonx_ = new QPushButtonx("+100", this);
|
|
627 | + toP1000Buttonx_ = new QPushButtonx("+1000", this);
|
|
628 | + toEndButtonx_ = new QPushButtonx(">|", this);
|
|
629 | + |
|
630 | + zoomLabel_ = new QLabel(tr("Zoom Factor"), this);
|
|
631 | 631 | zoomLabel_->setAlignment(Qt::AlignRight);
|
632 | - zoomSpinBox_ = new QSpinBoxx;
|
|
632 | + zoomSpinBox_ = new QSpinBoxx(this);
|
|
633 | 633 | zoomSpinBox_->setAlignment(Qt::AlignRight);
|
634 | 634 | zoomSpinBox_->setRange(1, 1000 - 1000 % 64);
|
635 | 635 | zoomSpinBox_->setKeyboardTracking(false);
|
636 | 636 | zoomLabel_->setBuddy(zoomSpinBox_);
|
637 | 637 | |
638 | - previousFontButton_ = new QPushButton(tr("Previous Font"));
|
|
639 | - nextFontButton_ = new QPushButton(tr("Next Font"));
|
|
640 | - previousFaceButton_ = new QPushButton(tr("Previous Face"));
|
|
641 | - nextFaceButton_ = new QPushButton(tr("Next Face"));
|
|
642 | - previousNamedInstanceButton_ = new QPushButton(tr("Previous Named Instance"));
|
|
643 | - nextNamedInstanceButton_ = new QPushButton(tr("Next Named Instance"));
|
|
638 | + previousFontButton_ = new QPushButton(tr("Previous Font"), this);
|
|
639 | + nextFontButton_ = new QPushButton(tr("Next Font"), this);
|
|
640 | + previousFaceButton_ = new QPushButton(tr("Previous Face"), this);
|
|
641 | + nextFaceButton_ = new QPushButton(tr("Next Face"), this);
|
|
642 | + previousNamedInstanceButton_
|
|
643 | + = new QPushButton(tr("Previous Named Instance"), this);
|
|
644 | + nextNamedInstanceButton_ = new QPushButton(tr("Next Named Instance"), this);
|
|
644 | 645 | |
645 | 646 | infoRightLayout = new QGridLayout;
|
646 | 647 | infoRightLayout->addWidget(glyphIndexLabel_, 0, 0);
|
... | ... | @@ -697,7 +698,7 @@ MainGUI::createLayout() |
697 | 698 | rightLayout_->addLayout(fontLayout);
|
698 | 699 | |
699 | 700 | // for symmetry with the left side use a widget also
|
700 | - rightWidget_ = new QWidget;
|
|
701 | + rightWidget_ = new QWidget(this);
|
|
701 | 702 | rightWidget_->setLayout(rightLayout_);
|
702 | 703 | |
703 | 704 | // the whole thing
|
... | ... | @@ -705,7 +706,7 @@ MainGUI::createLayout() |
705 | 706 | ftinspectLayout_->addWidget(leftWidget_);
|
706 | 707 | ftinspectLayout_->addWidget(rightWidget_);
|
707 | 708 | |
708 | - ftinspectWidget_ = new QWidget;
|
|
709 | + ftinspectWidget_ = new QWidget(this);
|
|
709 | 710 | ftinspectWidget_->setLayout(ftinspectLayout_);
|
710 | 711 | setCentralWidget(ftinspectWidget_);
|
711 | 712 | setWindowTitle("ftinspect");
|
... | ... | @@ -17,7 +17,8 @@ |
17 | 17 | //
|
18 | 18 | /////////////////////////////////////////////////////////////////////////////
|
19 | 19 | |
20 | -HintingModeComboBoxModel::HintingModeComboBoxModel()
|
|
20 | +HintingModeComboBoxModel::HintingModeComboBoxModel(QObject* parent)
|
|
21 | +: QAbstractListModel(parent)
|
|
21 | 22 | {
|
22 | 23 | items_[HintingMode_TrueType_v35] = {
|
23 | 24 | HintingEngineType_TrueType,
|
... | ... | @@ -196,6 +197,12 @@ HintingModeComboBoxModel::setCurrentEngineType(HintingEngineType type) |
196 | 197 | /////////////////////////////////////////////////////////////////////////////
|
197 | 198 | |
198 | 199 | |
200 | +SimpleComboBoxModel::SimpleComboBoxModel(QObject* parent)
|
|
201 | +: QAbstractListModel(parent)
|
|
202 | +{
|
|
203 | +}
|
|
204 | + |
|
205 | + |
|
199 | 206 | int
|
200 | 207 | SimpleComboBoxModel::rowCount(const QModelIndex& parent) const
|
201 | 208 | {
|
... | ... | @@ -232,7 +239,8 @@ SimpleComboBoxModel::indexToValue(int index) |
232 | 239 | /////////////////////////////////////////////////////////////////////////////
|
233 | 240 | |
234 | 241 | |
235 | -LCDFilterComboBoxModel::LCDFilterComboBoxModel()
|
|
242 | +LCDFilterComboBoxModel::LCDFilterComboBoxModel(QObject* parent)
|
|
243 | +: SimpleComboBoxModel(parent)
|
|
236 | 244 | {
|
237 | 245 | items_[LCDFilter_Default] = {
|
238 | 246 | FT_LCD_FILTER_DEFAULT,
|
... | ... | @@ -260,7 +268,8 @@ LCDFilterComboBoxModel::LCDFilterComboBoxModel() |
260 | 268 | /////////////////////////////////////////////////////////////////////////////
|
261 | 269 | |
262 | 270 | |
263 | -AntiAliasingComboBoxModel::AntiAliasingComboBoxModel()
|
|
271 | +AntiAliasingComboBoxModel::AntiAliasingComboBoxModel(QObject* parent)
|
|
272 | +: SimpleComboBoxModel(parent)
|
|
264 | 273 | {
|
265 | 274 | items_[AntiAliasing_None] = {
|
266 | 275 | FT_LOAD_TARGET_MONO,
|
... | ... | @@ -25,7 +25,7 @@ public: |
25 | 25 | QString displayName;
|
26 | 26 | };
|
27 | 27 | |
28 | - HintingModeComboBoxModel();
|
|
28 | + explicit HintingModeComboBoxModel(QObject* parent);
|
|
29 | 29 | ~HintingModeComboBoxModel() = default;
|
30 | 30 | |
31 | 31 | int rowCount(const QModelIndex& parent) const;
|
... | ... | @@ -82,7 +82,7 @@ public: |
82 | 82 | QString displayName;
|
83 | 83 | };
|
84 | 84 | |
85 | - SimpleComboBoxModel() {}
|
|
85 | + explicit SimpleComboBoxModel(QObject* parent);
|
|
86 | 86 | ~SimpleComboBoxModel() = default;
|
87 | 87 | |
88 | 88 | int rowCount(const QModelIndex& parent) const;
|
... | ... | @@ -107,7 +107,7 @@ public: |
107 | 107 | QString displayName;
|
108 | 108 | };
|
109 | 109 | |
110 | - LCDFilterComboBoxModel();
|
|
110 | + explicit LCDFilterComboBoxModel(QObject* parent);
|
|
111 | 111 | ~LCDFilterComboBoxModel() = default;
|
112 | 112 | |
113 | 113 | public:
|
... | ... | @@ -127,7 +127,7 @@ class AntiAliasingComboBoxModel |
127 | 127 | public:
|
128 | 128 | enum AntiAliasing : int;
|
129 | 129 | |
130 | - AntiAliasingComboBoxModel();
|
|
130 | + explicit AntiAliasingComboBoxModel(QObject* parent);
|
|
131 | 131 | ~AntiAliasingComboBoxModel() = default;
|
132 | 132 |
|
133 | 133 | QVariant data(const QModelIndex& index,
|
... | ... | @@ -5,8 +5,8 @@ |
5 | 5 | |
6 | 6 | #include "settingpanel.hpp"
|
7 | 7 | |
8 | -SettingPanel::SettingPanel(Engine* engine)
|
|
9 | -: engine_(engine)
|
|
8 | +SettingPanel::SettingPanel(QWidget* parent, Engine* engine)
|
|
9 | +: QWidget(parent), engine_(engine)
|
|
10 | 10 | {
|
11 | 11 | createLayout();
|
12 | 12 | setDefaults();
|
... | ... | @@ -278,35 +278,35 @@ SettingPanel::createConnections() |
278 | 278 | void
|
279 | 279 | SettingPanel::createLayout()
|
280 | 280 | {
|
281 | - hintingCheckBox_ = new QCheckBox(tr("Hinting"));
|
|
281 | + hintingCheckBox_ = new QCheckBox(tr("Hinting"), this);
|
|
282 | 282 | |
283 | - hintingModeLabel_ = new QLabel(tr("Hinting Mode"));
|
|
283 | + hintingModeLabel_ = new QLabel(tr("Hinting Mode"), this);
|
|
284 | 284 | hintingModeLabel_->setAlignment(Qt::AlignRight);
|
285 | 285 | |
286 | - hintingModeComboBoxModel_ = new HintingModeComboBoxModel;
|
|
287 | - hintingModeComboBox_ = new QComboBox;
|
|
286 | + hintingModeComboBoxModel_ = new HintingModeComboBoxModel(this);
|
|
287 | + hintingModeComboBox_ = new QComboBox(this);
|
|
288 | 288 | hintingModeComboBox_->setModel(hintingModeComboBoxModel_);
|
289 | 289 | hintingModeLabel_->setBuddy(hintingModeComboBox_);
|
290 | 290 | |
291 | - autoHintingCheckBox_ = new QCheckBox(tr("Auto-Hinting"));
|
|
292 | - horizontalHintingCheckBox_ = new QCheckBox(tr("Horizontal Hinting"));
|
|
293 | - verticalHintingCheckBox_ = new QCheckBox(tr("Vertical Hinting"));
|
|
294 | - blueZoneHintingCheckBox_ = new QCheckBox(tr("Blue-Zone Hinting"));
|
|
295 | - segmentDrawingCheckBox_ = new QCheckBox(tr("Segment Drawing"));
|
|
291 | + autoHintingCheckBox_ = new QCheckBox(tr("Auto-Hinting"), this);
|
|
292 | + horizontalHintingCheckBox_ = new QCheckBox(tr("Horizontal Hinting"), this);
|
|
293 | + verticalHintingCheckBox_ = new QCheckBox(tr("Vertical Hinting"), this);
|
|
294 | + blueZoneHintingCheckBox_ = new QCheckBox(tr("Blue-Zone Hinting"), this);
|
|
295 | + segmentDrawingCheckBox_ = new QCheckBox(tr("Segment Drawing"), this);
|
|
296 | 296 | |
297 | - antiAliasingLabel_ = new QLabel(tr("Anti-Aliasing"));
|
|
297 | + antiAliasingLabel_ = new QLabel(tr("Anti-Aliasing"), this);
|
|
298 | 298 | antiAliasingLabel_->setAlignment(Qt::AlignRight);
|
299 | 299 | |
300 | - antiAliasingComboBoxModel_ = new AntiAliasingComboBoxModel;
|
|
301 | - antiAliasingComboBox_ = new QComboBox;
|
|
300 | + antiAliasingComboBoxModel_ = new AntiAliasingComboBoxModel(this);
|
|
301 | + antiAliasingComboBox_ = new QComboBox(this);
|
|
302 | 302 | antiAliasingComboBox_->setModel(antiAliasingComboBoxModel_);
|
303 | 303 | antiAliasingLabel_->setBuddy(antiAliasingComboBox_);
|
304 | 304 | |
305 | 305 | lcdFilterLabel_ = new QLabel(tr("LCD Filter"));
|
306 | 306 | lcdFilterLabel_->setAlignment(Qt::AlignRight);
|
307 | 307 | |
308 | - lcdFilterComboboxModel_ = new LCDFilterComboBoxModel;
|
|
309 | - lcdFilterComboBox_ = new QComboBox;
|
|
308 | + lcdFilterComboboxModel_ = new LCDFilterComboBoxModel(this);
|
|
309 | + lcdFilterComboBox_ = new QComboBox(this);
|
|
310 | 310 | lcdFilterComboBox_->setModel(lcdFilterComboboxModel_);
|
311 | 311 | lcdFilterLabel_->setBuddy(lcdFilterComboBox_);
|
312 | 312 | |
... | ... | @@ -328,18 +328,18 @@ SettingPanel::createLayout() |
328 | 328 | antiAliasingComboBox_->setMinimumWidth(width);
|
329 | 329 | lcdFilterComboBox_->setMinimumWidth(width);
|
330 | 330 | |
331 | - gammaLabel_ = new QLabel(tr("Gamma"));
|
|
331 | + gammaLabel_ = new QLabel(tr("Gamma"), this);
|
|
332 | 332 | gammaLabel_->setAlignment(Qt::AlignRight);
|
333 | - gammaSlider_ = new QSlider(Qt::Horizontal);
|
|
333 | + gammaSlider_ = new QSlider(Qt::Horizontal, this);
|
|
334 | 334 | gammaSlider_->setRange(0, 30); // in 1/10th
|
335 | 335 | gammaSlider_->setTickPosition(QSlider::TicksBelow);
|
336 | 336 | gammaSlider_->setTickInterval(5);
|
337 | 337 | gammaLabel_->setBuddy(gammaSlider_);
|
338 | 338 | |
339 | - showBitmapCheckBox_ = new QCheckBox(tr("Show Bitmap"));
|
|
340 | - showPointsCheckBox_ = new QCheckBox(tr("Show Points"));
|
|
341 | - showPointNumbersCheckBox_ = new QCheckBox(tr("Show Point Numbers"));
|
|
342 | - showOutlinesCheckBox_ = new QCheckBox(tr("Show Outlines"));
|
|
339 | + showBitmapCheckBox_ = new QCheckBox(tr("Show Bitmap"), this);
|
|
340 | + showPointsCheckBox_ = new QCheckBox(tr("Show Points"), this);
|
|
341 | + showPointNumbersCheckBox_ = new QCheckBox(tr("Show Point Numbers"), this);
|
|
342 | + showOutlinesCheckBox_ = new QCheckBox(tr("Show Outlines"), this);
|
|
343 | 343 | |
344 | 344 | hintingModeLayout_ = new QHBoxLayout;
|
345 | 345 | hintingModeLayout_->addWidget(hintingModeLabel_);
|
... | ... | @@ -399,12 +399,12 @@ SettingPanel::createLayout() |
399 | 399 | generalTabLayout_->addLayout(pointNumbersLayout_);
|
400 | 400 | generalTabLayout_->addWidget(showOutlinesCheckBox_);
|
401 | 401 | |
402 | - generalTab_ = new QWidget;
|
|
402 | + generalTab_ = new QWidget(this);
|
|
403 | 403 | generalTab_->setLayout(generalTabLayout_);
|
404 | 404 | |
405 | - mmgxTab_ = new QWidget;
|
|
405 | + mmgxTab_ = new QWidget(this);
|
|
406 | 406 | |
407 | - tab_ = new QTabWidget;
|
|
407 | + tab_ = new QTabWidget(this);
|
|
408 | 408 | tab_->addTab(generalTab_, tr("General"));
|
409 | 409 | tab_->addTab(mmgxTab_, tr("MM/GX"));
|
410 | 410 |
... | ... | @@ -19,7 +19,7 @@ class SettingPanel |
19 | 19 | {
|
20 | 20 | Q_OBJECT
|
21 | 21 | public:
|
22 | - SettingPanel(Engine* engine);
|
|
22 | + SettingPanel(QWidget* parent, Engine* engine);
|
|
23 | 23 | ~SettingPanel() = default;
|
24 | 24 | |
25 | 25 | void syncSettings();
|
... | ... | @@ -12,8 +12,8 @@ |
12 | 12 | // >>>>>>>> QGraphicsViewx <<<<<<<<
|
13 | 13 | // --------------------------------
|
14 | 14 | |
15 | -QGraphicsViewx::QGraphicsViewx()
|
|
16 | -: lastBottomLeftPointInitialized_(false)
|
|
15 | +QGraphicsViewx::QGraphicsViewx(QWidget* parent)
|
|
16 | +: QGraphicsView(parent), lastBottomLeftPointInitialized_(false)
|
|
17 | 17 | {
|
18 | 18 | // empty
|
19 | 19 | }
|
... | ... | @@ -104,6 +104,12 @@ QSpinBoxx::valueFromText(const QString& text) const |
104 | 104 | }
|
105 | 105 | |
106 | 106 | |
107 | +QSpinBoxx::QSpinBoxx(QWidget* parent)
|
|
108 | +: QSpinBox(parent)
|
|
109 | +{
|
|
110 | +}
|
|
111 | + |
|
112 | + |
|
107 | 113 | void
|
108 | 114 | QSpinBoxx::stepBy(int steps)
|
109 | 115 | {
|
... | ... | @@ -24,7 +24,7 @@ class QGraphicsViewx |
24 | 24 | Q_OBJECT
|
25 | 25 | |
26 | 26 | public:
|
27 | - QGraphicsViewx();
|
|
27 | + QGraphicsViewx(QWidget* parent);
|
|
28 | 28 | |
29 | 29 | protected:
|
30 | 30 | void resizeEvent(QResizeEvent* event);
|
... | ... | @@ -57,6 +57,7 @@ class QSpinBoxx |
57 | 57 | Q_OBJECT
|
58 | 58 | |
59 | 59 | public:
|
60 | + QSpinBoxx(QWidget* parent);
|
|
60 | 61 | void stepBy(int val);
|
61 | 62 | int valueFromText(const QString& text) const;
|
62 | 63 | };
|