freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2-demos] master d980c71 39/41: [ftinspect] Format `src/ftinspec


From: Werner Lemberg
Subject: [freetype2-demos] master d980c71 39/41: [ftinspect] Format `src/ftinspect/widgets/*`.
Date: Mon, 3 Oct 2022 11:27:05 -0400 (EDT)

branch: master
commit d980c71d4dbd5e360111ea156ccdbea6a2ee4fb7
Author: Werner Lemberg <wl@gnu.org>
Commit: Werner Lemberg <wl@gnu.org>

    [ftinspect] Format `src/ftinspect/widgets/*`.
---
 src/ftinspect/widgets/charmapcombobox.cpp    |  14 +--
 src/ftinspect/widgets/charmapcombobox.hpp    |   8 +-
 src/ftinspect/widgets/customwidgets.cpp      |  18 +--
 src/ftinspect/widgets/customwidgets.hpp      |  31 ++---
 src/ftinspect/widgets/fontsizeselector.cpp   |  58 ++++++----
 src/ftinspect/widgets/fontsizeselector.hpp   |  19 ++-
 src/ftinspect/widgets/glyphindexselector.cpp |  22 ++--
 src/ftinspect/widgets/glyphindexselector.hpp |  25 ++--
 src/ftinspect/widgets/tripletselector.cpp    | 165 ++++++++++++++-------------
 src/ftinspect/widgets/tripletselector.hpp    |   7 +-
 10 files changed, 206 insertions(+), 161 deletions(-)

diff --git a/src/ftinspect/widgets/charmapcombobox.cpp 
b/src/ftinspect/widgets/charmapcombobox.cpp
index dadb483..d5da35b 100644
--- a/src/ftinspect/widgets/charmapcombobox.cpp
+++ b/src/ftinspect/widgets/charmapcombobox.cpp
@@ -3,7 +3,6 @@
 // Copyright (C) 2022 by Charlie Jiang.
 
 #include "charmapcombobox.hpp"
-
 #include "../engine/engine.hpp"
 
 
@@ -50,25 +49,26 @@ CharMapComboBox::repopulate()
 
 
 #define EncodingRole (Qt::UserRole + 10)
+
 void
 CharMapComboBox::repopulate(std::vector<CharMapInfo>& charMaps)
 {
   if (charMaps_ == charMaps)
   {
-    charMaps_ = charMaps; // Still need to substitute because ptr may differ
+    charMaps_ = charMaps; // Still need to substitute because ptr may differ.
     return;
   }
   charMaps_ = charMaps;
   int oldIndex = currentIndex();
   unsigned oldEncoding = 0u;
 
-  // Using additional UserRole to store encoding id
+  // Using additional UserRole to store encoding ID.
   auto oldEncodingV = itemData(oldIndex, EncodingRole);
   if (oldEncodingV.isValid() && oldEncodingV.canConvert<unsigned>())
     oldEncoding = oldEncodingV.value<unsigned>();
 
   { // This brace isn't for the `if` statement!
-    // suppress events during updating
+    // Suppress events during updating.
     QSignalBlocker selectorBlocker(this);
 
     clear();
@@ -77,7 +77,7 @@ CharMapComboBox::repopulate(std::vector<CharMapInfo>& 
charMaps)
       addItem(tr("Glyph Order"));
       setItemData(0, 0u, EncodingRole);
     }
-    
+
     int newIndex = 0;
     for (auto& map : charMaps)
     {
@@ -97,8 +97,8 @@ CharMapComboBox::repopulate(std::vector<CharMapInfo>& 
charMaps)
         newIndex = i;
     }
 
-    // this shouldn't emit any event either, because force repainting
-    // will happen later, so embrace it into blocker block
+    // This shouldn't emit any event either because force repainting
+    // will happen later, so embrace it into blocker block.
     setCurrentIndex(newIndex);
     updateToolTip();
   }
diff --git a/src/ftinspect/widgets/charmapcombobox.hpp 
b/src/ftinspect/widgets/charmapcombobox.hpp
index bebdbf8..ee6178e 100644
--- a/src/ftinspect/widgets/charmapcombobox.hpp
+++ b/src/ftinspect/widgets/charmapcombobox.hpp
@@ -7,15 +7,21 @@
 #include "../engine/charmap.hpp"
 
 #include <vector>
+
 #include <QComboBox>
 
+
 class Engine;
+
 class CharMapComboBox
 : public QComboBox
 {
   Q_OBJECT
+
 public:
-  CharMapComboBox(QWidget* parent, Engine* engine, bool haveGlyphOrder = true);
+  CharMapComboBox(QWidget* parent,
+                  Engine* engine,
+                  bool haveGlyphOrder = true);
   ~CharMapComboBox() override = default;
 
   bool haveGlyphOrder_;
diff --git a/src/ftinspect/widgets/customwidgets.cpp 
b/src/ftinspect/widgets/customwidgets.cpp
index 2a02573..5b7a69f 100644
--- a/src/ftinspect/widgets/customwidgets.cpp
+++ b/src/ftinspect/widgets/customwidgets.cpp
@@ -5,16 +5,18 @@
 #include "customwidgets.hpp"
 
 #include <qevent.h>
-#include <QStandardItemModel>
 #include <QScrollBar>
+#include <QStandardItemModel>
 #include <QStyleOptionButton>
 
+
 // --------------------------------
 // >>>>>>>> QGraphicsViewx <<<<<<<<
 // --------------------------------
 
 QGraphicsViewx::QGraphicsViewx(QWidget* parent)
-: QGraphicsView(parent), lastBottomLeftPointInitialized_(false)
+: QGraphicsView(parent),
+  lastBottomLeftPointInitialized_(false)
 {
   // empty
 }
@@ -62,18 +64,20 @@ QGraphicsViewx::resizeEvent(QResizeEvent* event)
                                      - lastBottomLeftPoint_.y())));
 }
 
+
 // ---------------------------
 // >>>>>>>> ZoomSpinBox <<<<<<<<
 // ---------------------------
 
-// we want to mark the center of a pixel square with a single dot or a small
+// We want to mark the center of a pixel square with a single dot or a small
 // cross; starting with a certain magnification we thus only use even values
-// so that we can do that symmetrically
+// so that we can do that symmetrically.
 // This behaviour is only for the singular view grid.
 
-
-ZoomSpinBox::ZoomSpinBox(QWidget* parent, bool continuousView)
-: QDoubleSpinBox(parent), continuousView_(continuousView)
+ZoomSpinBox::ZoomSpinBox(QWidget* parent,
+                         bool continuousView)
+: QDoubleSpinBox(parent),
+  continuousView_(continuousView)
 {
   setKeyboardTracking(false);
   if (continuousView)
diff --git a/src/ftinspect/widgets/customwidgets.hpp 
b/src/ftinspect/widgets/customwidgets.hpp
index a584ffb..fbc8d01 100644
--- a/src/ftinspect/widgets/customwidgets.hpp
+++ b/src/ftinspect/widgets/customwidgets.hpp
@@ -7,18 +7,19 @@
 #include <QComboBox>
 #include <QGraphicsView>
 #include <QPushButton>
-#include <QSpinBox>
 #include <QScrollArea>
+#include <QSpinBox>
 #include <QString>
 
-// We need to define a series of custom Qt widgets to satisfy.
-// Basically those custom widgets are derived classes from Qt-provided 
components,
-// with minor changes.
-// Because all those derived classes are pretty tiny and not core logic, 
they're
-// organized into one single hpp/cpp pair.
 
-// we want to anchor the view at the bottom left corner
-// while the windows gets resized
+// We need to define a series of custom Qt widgets to satisfy our needs.
+// Basically, those custom widgets are derived classes from Qt-provided
+// components, with minor changes.  Because all those derived classes are
+// pretty tiny and not core logic, they are organized into one single
+// hpp/cpp file pair.
+
+// We want to anchor the view at the bottom left corner while the windows
+// gets resized.
 class QGraphicsViewx
 : public QGraphicsView
 {
@@ -43,18 +44,17 @@ private:
 };
 
 
-// we want to have our own `stepBy' function for the zoom spin box
+// We want to have our own `stepBy` function for the zoom spin box.
 class ZoomSpinBox
 : public QDoubleSpinBox
 {
   Q_OBJECT
 
 public:
-  /*
-   * The ContinuousView mode for `ZoomSpinBox` will change the range to
-   * 0.25~50, and the single step to 0.25.
-   */
-  ZoomSpinBox(QWidget* parent, bool continuousView);
+  // The ContinuousView mode for `ZoomSpinBox` will change the range to
+  // 0.25~50, and the single step to 0.25.
+  ZoomSpinBox(QWidget* parent,
+              bool continuousView);
   void stepBy(int val) override;
   double valueFromText(const QString& text) const override;
 
@@ -65,7 +65,8 @@ private:
 
 // https://bugreports.qt.io/browse/QTBUG-10459
 // https://phabricator.kde.org/D14692
-class UnboundScrollArea : public QScrollArea
+class UnboundScrollArea
+: public QScrollArea
 {
   Q_OBJECT
 
diff --git a/src/ftinspect/widgets/fontsizeselector.cpp 
b/src/ftinspect/widgets/fontsizeselector.cpp
index 575fe12..91ae30b 100644
--- a/src/ftinspect/widgets/fontsizeselector.cpp
+++ b/src/ftinspect/widgets/fontsizeselector.cpp
@@ -3,15 +3,16 @@
 // Copyright (C) 2022 by Charlie Jiang.
 
 #include "fontsizeselector.hpp"
-
 #include "../engine/engine.hpp"
 
 #include <algorithm>
 
-FontSizeSelector::FontSizeSelector(QWidget* parent, 
+
+FontSizeSelector::FontSizeSelector(QWidget* parent,
                                    bool zoomNewLine,
                                    bool continuousView)
-: QWidget(parent), continuousView_(continuousView)
+: QWidget(parent),
+  continuousView_(continuousView)
 {
   createLayout(zoomNewLine);
   createConnections();
@@ -80,7 +81,7 @@ FontSizeSelector::reloadFromFont(Engine* engine)
   unitsComboBox_->setEnabled(!bitmapOnly_);
   sizeDoubleSpinBox_->setKeyboardTracking(!bitmapOnly_);
 
-  if (bitmapOnly_) 
+  if (bitmapOnly_)
   {
     QSignalBlocker blocker(this);
     unitsComboBox_->setCurrentIndex(Units_px);
@@ -92,7 +93,7 @@ FontSizeSelector::reloadFromFont(Engine* engine)
 void
 FontSizeSelector::applyToEngine(Engine* engine)
 {
-  // Spinbox value cannot become negative
+  // Spinbox value cannot become negative.
   engine->setDPI(dpiSpinBox_->value());
 
   if (unitsComboBox_->currentIndex() == Units_px)
@@ -141,7 +142,7 @@ FontSizeSelector::handleKeyEvent(QKeyEvent const* keyEvent)
   auto key = keyEvent->key();
   if ((modifiers == Qt::ShiftModifier
        || modifiers == (Qt::ShiftModifier | Qt::KeypadModifier))
-      && (key == Qt::Key_Plus 
+      && (key == Qt::Key_Plus
           || key == Qt::Key_Minus
           || key == Qt::Key_Underscore
           || key == Qt::Key_Equal
@@ -235,13 +236,14 @@ FontSizeSelector::createLayout(bool zoomNewLine)
   zoomLabel_->setBuddy(zoomSpinBox_);
 
   // Tooltips
-  sizeDoubleSpinBox_->setToolTip(
-    tr("Size value (will be limited to available sizes if\nthe current font "
-       "is not scalable)."));
-  unitsComboBox_->setToolTip(tr("Unit for the size value (force to pixel if\n"
-                                "the current font is not scalable)."));
-  dpiSpinBox_->setToolTip(
-    tr("DPI for the point size value (only valid when the unit is point)."));
+  sizeDoubleSpinBox_->setToolTip(tr(
+    "Size value (will be limited to available sizes if\n"
+    "the current font is not scalable)."));
+  unitsComboBox_->setToolTip(tr(
+    "Unit for the size value (force to pixel if\n"
+    "the current font is not scalable)."));
+  dpiSpinBox_->setToolTip(tr(
+    "DPI for the point size value (only valid when the unit is point)."));
   zoomSpinBox_->setToolTip(tr("Adjust zoom."));
 
   // Layouting
@@ -279,14 +281,22 @@ FontSizeSelector::createLayout(bool zoomNewLine)
 void
 FontSizeSelector::createConnections()
 {
-  connect(sizeDoubleSpinBox_, 
QOverload<double>::of(&QDoubleSpinBox::valueChanged),
-          this, &FontSizeSelector::checkFixedSizeAndEmit);
-  connect(unitsComboBox_, QOverload<int>::of(&QComboBox::currentIndexChanged),
-          this, &FontSizeSelector::checkUnits);
-  connect(dpiSpinBox_, QOverload<int>::of(&QSpinBox::valueChanged),
-          this, &FontSizeSelector::checkFixedSizeAndEmit);
-  connect(zoomSpinBox_, QOverload<double>::of(&ZoomSpinBox::valueChanged),
-          this, &FontSizeSelector::valueChanged);
+  connect(sizeDoubleSpinBox_,
+          QOverload<double>::of(&QDoubleSpinBox::valueChanged),
+          this,
+          &FontSizeSelector::checkFixedSizeAndEmit);
+  connect(unitsComboBox_,
+          QOverload<int>::of(&QComboBox::currentIndexChanged),
+          this,
+          &FontSizeSelector::checkUnits);
+  connect(dpiSpinBox_,
+          QOverload<int>::of(&QSpinBox::valueChanged),
+          this,
+          &FontSizeSelector::checkFixedSizeAndEmit);
+  connect(zoomSpinBox_,
+          QOverload<double>::of(&ZoomSpinBox::valueChanged),
+          this,
+          &FontSizeSelector::valueChanged);
 }
 
 
@@ -320,7 +330,7 @@ FontSizeSelector::checkFixedSizeAndEmit()
       // Value not available, find next value.
       if (intNewValue > lastValue_)
       {
-        // find next larger value...
+        // Find next larger value...
         auto it = std::upper_bound(fixedSizes_.begin(), fixedSizes_.end(),
                                    lastValue_);
         if (it == fixedSizes_.end())
@@ -330,11 +340,11 @@ FontSizeSelector::checkFixedSizeAndEmit()
       }
       else
       {
-        // find next smaller value...
+        // Find next smaller value...
         auto it = std::lower_bound(fixedSizes_.begin(), fixedSizes_.end(),
                                    lastValue_);
 
-        // there's no element >= lastValue => all elements < last value
+        // There's no element >= lastValue => all elements < last value.
         if (it == fixedSizes_.begin())
           sizeDoubleSpinBox_->setValue(fixedSizes_.front());
         else
diff --git a/src/ftinspect/widgets/fontsizeselector.hpp 
b/src/ftinspect/widgets/fontsizeselector.hpp
index 4f0dc46..5c09bcf 100644
--- a/src/ftinspect/widgets/fontsizeselector.hpp
+++ b/src/ftinspect/widgets/fontsizeselector.hpp
@@ -7,21 +7,26 @@
 #include "customwidgets.hpp"
 
 #include <vector>
+
+#include <QBoxLayout>
 #include <QComboBox>
 #include <QDoubleSpinBox>
 #include <QLabel>
-#include <QWidget>
-#include <QBoxLayout>
 #include <QWheelEvent>
+#include <QWidget>
+
 
 class Engine;
-class FontSizeSelector : public QWidget
+class FontSizeSelector
+: public QWidget
 {
   Q_OBJECT
 
 public:
   // For the continuous view mode, see `ZoomSpinBox`'s documentation.
-  FontSizeSelector(QWidget* parent, bool zoomNewLine, bool continuousView);
+  FontSizeSelector(QWidget* parent,
+                   bool zoomNewLine,
+                   bool continuousView);
   ~FontSizeSelector() override = default;
 
   enum Units : int
@@ -34,6 +39,7 @@ public:
   double selectedSize();
   Units selectedUnit();
   double zoomFactor();
+
   //////// Setters
   void setSizePixel(int sizePixel);
   void setSizePoint(double sizePoint);
@@ -48,7 +54,8 @@ public:
   void installEventFilterForWidget(QWidget* widget);
 
 protected:
-  bool eventFilter(QObject* watched, QEvent* event) override;
+  bool eventFilter(QObject* watched,
+                   QEvent* event) override;
 
 signals:
   void valueChanged();
@@ -63,7 +70,7 @@ private:
   QSpinBox* dpiSpinBox_;
   ZoomSpinBox* zoomSpinBox_;
 
-  // Sometimes we need to split 2 lines
+  // Sometimes we need to split 2 lines.
   QHBoxLayout* upLayout_;
   QHBoxLayout* downLayout_;
   QVBoxLayout* mainLayout_;
diff --git a/src/ftinspect/widgets/glyphindexselector.cpp 
b/src/ftinspect/widgets/glyphindexselector.cpp
index 3b7abcc..3408e81 100644
--- a/src/ftinspect/widgets/glyphindexselector.cpp
+++ b/src/ftinspect/widgets/glyphindexselector.cpp
@@ -3,11 +3,11 @@
 // Copyright (C) 2022 Charlie Jiang.
 
 #include "glyphindexselector.hpp"
-
 #include "../uihelper.hpp"
 
 #include <climits>
 
+
 GlyphIndexSelector::GlyphIndexSelector(QWidget* parent)
 : QWidget(parent)
 {
@@ -23,7 +23,7 @@ void
 GlyphIndexSelector::setMinMax(int min,
                               int max)
 {
-  // Don't emit events during setting
+  // Don't emit events during setting.
   auto eventState = blockSignals(true);
   indexSpinBox_->setMinimum(min);
   indexSpinBox_->setMaximum(qBound(0, max, INT_MAX));
@@ -53,15 +53,16 @@ GlyphIndexSelector::setSingleMode(bool singleMode)
 
 
 void
-GlyphIndexSelector::setCurrentIndex(int index, bool forceUpdate)
+GlyphIndexSelector::setCurrentIndex(int index,
+                                    bool forceUpdate)
 {
-  // to avoid unnecessary update, if force update is enabled
-  // then the `setValue` shouldn't trigger update signal from `this`
-  // but we still need `updateLabel`, so block `this` only
+  // To avoid unnecessary updates: if force-update is enabled,
+  // `setValue` shouldn't trigger the update signal from `this`.
+  // However, we still need `updateLabel`, so block `this` only.
   auto state = blockSignals(forceUpdate);
   indexSpinBox_->setValue(index);
   blockSignals(state);
-  
+
   if (forceUpdate)
     emit currentIndexChanged(indexSpinBox_->value());
 }
@@ -91,7 +92,7 @@ GlyphIndexSelector::resizeEvent(QResizeEvent* event)
     if (width() < minimumWidth)
       navigationWidget_->setVisible(false);
   }
-  else if (navigationWidget_->minimumSizeHint().width() + minimumWidth 
+  else if (navigationWidget_->minimumSizeHint().width() + minimumWidth
            <= width())
     navigationWidget_->setVisible(true);
 }
@@ -150,7 +151,7 @@ GlyphIndexSelector::createLayout()
   toP100Button_ = new QPushButton("+100", this);
   toP1000Button_ = new QPushButton("+1000", this);
   toEndButton_ = new QPushButton(">|", this);
-  
+
   indexSpinBox_ = new QSpinBox(this);
   indexSpinBox_->setCorrectionMode(QAbstractSpinBox::CorrectToNearestValue);
   indexSpinBox_->setButtonSymbols(QAbstractSpinBox::NoButtons);
@@ -206,10 +207,11 @@ GlyphIndexSelector::createLayout()
   setLayout(layout_);
 }
 
+
 void
 GlyphIndexSelector::createConnections()
 {
-  connect(indexSpinBox_, QOverload<int>::of(&QSpinBox::valueChanged), 
+  connect(indexSpinBox_, QOverload<int>::of(&QSpinBox::valueChanged),
           this, &GlyphIndexSelector::emitValueChanged);
 
   glyphNavigationMapper_ = new QSignalMapper(this);
diff --git a/src/ftinspect/widgets/glyphindexselector.hpp 
b/src/ftinspect/widgets/glyphindexselector.hpp
index 9ef1d08..ccb7ea1 100644
--- a/src/ftinspect/widgets/glyphindexselector.hpp
+++ b/src/ftinspect/widgets/glyphindexselector.hpp
@@ -5,29 +5,34 @@
 #pragma once
 
 #include <functional>
-#include <QWidget>
-#include <QPushButton>
-#include <QSpinBox>
-#include <QSignalMapper>
+
 #include <QHBoxLayout>
 #include <QLabel>
+#include <QPushButton>
+#include <QSignalMapper>
+#include <QSpinBox>
+#include <QWidget>
+
 
 class GlyphIndexSelector
 : public QWidget
 {
   Q_OBJECT
+
 public:
   GlyphIndexSelector(QWidget* parent);
   ~GlyphIndexSelector() override = default;
 
-  // Will never trigger repaint!
-  void setMinMax(int min, int max);
+  // Never triggers repaint!
+  void setMinMax(int min,
+                 int max);
   void setShowingCount(int showingCount);
 
-  // Single mode will display single glyph index instead of a range.
+  // Single mode displays single glyph index instead of a range.
   void setSingleMode(bool singleMode);
 
-  void setCurrentIndex(int index, bool forceUpdate = false);
+  void setCurrentIndex(int index,
+                       bool forceUpdate = false);
   int currentIndex();
 
   void setNumberRenderer(std::function<QString(int)> renderer);
@@ -37,13 +42,13 @@ signals:
 
 protected:
   void resizeEvent(QResizeEvent* event) override;
-  
+
 private:
   bool singleMode_ = true;
   int showingCount_;
   std::function<QString(int)> numberRenderer_;
 
-  // min, max and current status are held by `indexSpinBox_`
+  // Minimum, maximum, and current status are held by `indexSpinBox_`.
   QWidget* navigationWidget_;
   QPushButton* toEndButton_;
   QPushButton* toM1000Button_;
diff --git a/src/ftinspect/widgets/tripletselector.cpp 
b/src/ftinspect/widgets/tripletselector.cpp
index d92ce3f..d8a25ba 100644
--- a/src/ftinspect/widgets/tripletselector.cpp
+++ b/src/ftinspect/widgets/tripletselector.cpp
@@ -3,11 +3,11 @@
 // Copyright (C) 2022 by Charlie Jiang.
 
 #include "tripletselector.hpp"
-
 #include "../engine/engine.hpp"
 
 #include <functional>
 
+
 TripletSelector::TripletSelector(QWidget* parent,
                                  Engine* engine)
 : QWidget(parent),
@@ -35,7 +35,7 @@ TripletSelector::repopulateFonts()
     QSignalBlocker blk2(faceComboBox_);
     QSignalBlocker blk3(niComboBox_);
     fontComboBox_->clear();
-    
+
     auto& ffm = engine_->fontFileManager();
     auto newSize = ffm.size();
     for (int i = 0; i < newSize; i++)
@@ -51,7 +51,7 @@ TripletSelector::repopulateFonts()
 
     if (newSize > oldSize)
     {
-      // if we have new fonts, set the current index to the first new one
+      // If we have new fonts, set the current index to the first new one.
       fontComboBox_->setCurrentIndex(oldSize);
     }
     else if (newSize < oldSize)
@@ -62,13 +62,13 @@ TripletSelector::repopulateFonts()
         oldIndex = -1;
       fontComboBox_->setCurrentIndex(oldIndex);
     }
-    else // failed to open, retain
+    else // Failed to open, retain.
       fontComboBox_->setCurrentIndex(oldIndex);
 
-    // Note no signal will be emitted from any combobox until this block ends
+    // Note: no signal is emitted from any combobox until this block ends.
   }
 
-  // This will check buttons & reload the triplet
+  // This checks buttons & reloads the triplet.
   repopulateFaces();
 }
 
@@ -76,7 +76,7 @@ TripletSelector::repopulateFonts()
 void
 TripletSelector::repopulateFaces(bool fontSwitched)
 {
-  // Avoid unnecessary recreating, to reduce interruption of user oper
+  // Avoid unnecessary recreating to reduce interruption of user operations.
   auto needToRecreate = fontSwitched;
   auto oldSize = faceComboBox_->count();
 
@@ -85,9 +85,9 @@ TripletSelector::repopulateFaces(bool fontSwitched)
 
   if (fontIndex < 0 || newSize < 0)
   {
-    // Clear and go
+    // Clear and go.
     faceComboBox_->clear();
-    // This will check buttons & reload the triplet
+    // This checks buttons & reloads the triplet.
     repopulateNamedInstances(fontSwitched);
     return;
   }
@@ -106,8 +106,8 @@ TripletSelector::repopulateFaces(bool fontSwitched)
 
   if (!needToRecreate)
   {
-    // no need to refersh the combobox
-    // This will check buttons & reload the triplet
+    // No need to refresh the combobox.
+    // This checks buttons & reloads the triplet.
     repopulateNamedInstances(fontSwitched);
     return;
   }
@@ -125,10 +125,10 @@ TripletSelector::repopulateFaces(bool fontSwitched)
     }
 
     faceComboBox_->setCurrentIndex(0);
-    // Note no signal will be emitted from any combobox until this block ends
+    // Note: no signal gets emitted from any combobox until this block ends.
   }
 
-  // This will check buttons & reload the triplet
+  // This checks buttons & reloads the triplet.
   repopulateNamedInstances(true);
 }
 
@@ -136,8 +136,8 @@ TripletSelector::repopulateFaces(bool fontSwitched)
 void
 TripletSelector::repopulateNamedInstances(bool fontSwitched)
 {
-  // Avoid unnecessary recreating, to reduce interruption of user oper
-  // Similar to `repopulateFaces`
+  // Avoid unnecessary recreating to reduce interruption of user operations.
+  // Similar to `repopulateFaces`.
   auto needToRecreate = fontSwitched;
   auto oldSize = niComboBox_->count();
 
@@ -147,7 +147,7 @@ TripletSelector::repopulateNamedInstances(bool fontSwitched)
 
   if (fontIndex < 0 || faceIndex < 0 || newSize < 0)
   {
-    // Clear and go, don't forget checking buttons and loading triplet
+    // Clear and go, and don't forget checking buttons and loading triplet.
     niComboBox_->clear();
     checkButtons();
     loadTriplet();
@@ -170,7 +170,7 @@ TripletSelector::repopulateNamedInstances(bool fontSwitched)
 
   if (!needToRecreate)
   {
-    // no need to refersh the combobox
+    // No need to refresh the combobox.
     checkButtons();
     loadTriplet();
     return;
@@ -190,7 +190,7 @@ TripletSelector::repopulateNamedInstances(bool fontSwitched)
     }
 
     niComboBox_->setCurrentIndex(0);
-    // Note no signal will be emitted from any combobox until this block ends
+    // Note: no signal is emitted from any combobox until this block ends.
   }
 
   checkButtons();
@@ -206,7 +206,7 @@ TripletSelector::closeCurrentFont()
     return;
   engine_->fontFileManager().remove(idx);
 
-  // show next font after deletion, i.e., retain index if possible
+  // Show next font after deletion, i.e., retain index if possible.
   int num = engine_->numberOfOpenedFonts();
   if (num)
   {
@@ -217,7 +217,7 @@ TripletSelector::closeCurrentFont()
     idx = -1;
 
   {
-    // Shut up when repopulating
+    // Shut up when repopulating.
     QSignalBlocker blockerThis(this);
     QSignalBlocker blockerComboBox(fontComboBox_);
     repopulateFonts();
@@ -246,12 +246,12 @@ TripletSelector::updateFont()
 
   if (num <= 0 || idx >= num)
   {
-    // out of sync: this shouldn't happen
+    // Out of sync: this shouldn't happen.
     repopulateFonts();
     return;
   }
 
-  // This will check buttons & reload the triplet
+  // This checks buttons & reloads the triplet.
   repopulateFaces();
 }
 
@@ -261,15 +261,15 @@ TripletSelector::updateFace()
 {
   auto idx = faceComboBox_->currentIndex();
   auto num = engine_->numberOfFaces(fontComboBox_->currentIndex());
-  
+
   if (idx >= num)
   {
-    // out of sync
+    // Out of sync.
     repopulateFaces();
     return;
   }
 
-  // This will check buttons & reload the triplet
+  // This checks buttons & reloads the triplet.
   repopulateNamedInstances();
 }
 
@@ -280,10 +280,10 @@ TripletSelector::updateNI()
   auto idx = niComboBox_->currentIndex();
   auto num = engine_->numberOfNamedInstances(fontComboBox_->currentIndex(),
                                              faceComboBox_->currentIndex());
-  
+
   if (idx >= num)
   {
-    // out of sync
+    // Out of sync.
     repopulateNamedInstances();
     return;
   }
@@ -323,51 +323,56 @@ TripletSelector::createLayout()
 {
   fontComboBox_ = new QComboBox(this);
   faceComboBox_ = new QComboBox(this);
-  niComboBox_   = new QComboBox(this);
+  niComboBox_ = new QComboBox(this);
 
   fontComboBox_->setPlaceholderText(tr("No font open"));
   faceComboBox_->setPlaceholderText(tr("No face available"));
   niComboBox_->setPlaceholderText(tr("No named instance available"));
-  
+
   closeFontButton_ = new QToolButton(this);
-  fontUpButton_    = new QToolButton(this);
-  faceUpButton_    = new QToolButton(this);
-  niUpButton_      = new QToolButton(this);
-  fontDownButton_  = new QToolButton(this);
-  faceDownButton_  = new QToolButton(this);
-  niDownButton_    = new QToolButton(this);
+  fontUpButton_ = new QToolButton(this);
+  faceUpButton_ = new QToolButton(this);
+  niUpButton_ = new QToolButton(this);
+  fontDownButton_ = new QToolButton(this);
+  faceDownButton_ = new QToolButton(this);
+  niDownButton_ = new QToolButton(this);
 
   closeFontButton_->setText(tr("Close"));
-  fontUpButton_   ->setText(tr("\xE2\x86\x91"));
-  faceUpButton_   ->setText(tr("\xE2\x86\x91"));
-  niUpButton_     ->setText(tr("\xE2\x86\x91"));
-  fontDownButton_ ->setText(tr("\xE2\x86\x93"));
-  faceDownButton_ ->setText(tr("\xE2\x86\x93"));
-  niDownButton_   ->setText(tr("\xE2\x86\x93"));
-  
-  fontComboBox_   ->setSizePolicy(QSizePolicy::Minimum, 
QSizePolicy::Expanding);
-  faceComboBox_   ->setSizePolicy(QSizePolicy::Minimum, 
QSizePolicy::Expanding);
-  niComboBox_     ->setSizePolicy(QSizePolicy::Minimum, 
QSizePolicy::Expanding);
-  closeFontButton_->setSizePolicy(QSizePolicy::Maximum, 
QSizePolicy::Expanding);
-  fontUpButton_   ->setFixedSize(30, 30);
-  faceUpButton_   ->setFixedSize(30, 30);
-  niUpButton_     ->setFixedSize(30, 30);
-  fontDownButton_ ->setFixedSize(30, 30);
-  faceDownButton_ ->setFixedSize(30, 30);
-  niDownButton_   ->setFixedSize(30, 30);
+  fontUpButton_->setText(tr("\xE2\x86\x91"));
+  faceUpButton_->setText(tr("\xE2\x86\x91"));
+  niUpButton_->setText(tr("\xE2\x86\x91"));
+  fontDownButton_->setText(tr("\xE2\x86\x93"));
+  faceDownButton_->setText(tr("\xE2\x86\x93"));
+  niDownButton_->setText(tr("\xE2\x86\x93"));
+
+  fontComboBox_->setSizePolicy(QSizePolicy::Minimum,
+                               QSizePolicy::Expanding);
+  faceComboBox_->setSizePolicy(QSizePolicy::Minimum,
+                               QSizePolicy::Expanding);
+  niComboBox_->setSizePolicy(QSizePolicy::Minimum,
+                             QSizePolicy::Expanding);
+  closeFontButton_->setSizePolicy(QSizePolicy::Maximum,
+                                  QSizePolicy::Expanding);
+
+  fontUpButton_->setFixedSize(30, 30);
+  faceUpButton_->setFixedSize(30, 30);
+  niUpButton_->setFixedSize(30, 30);
+  fontDownButton_->setFixedSize(30, 30);
+  faceDownButton_->setFixedSize(30, 30);
+  niDownButton_->setFixedSize(30, 30);
 
   // Tooltips
   fontComboBox_->setToolTip(tr("Current font"));
   faceComboBox_->setToolTip(tr("Current subfont (face)"));
-  niComboBox_->setToolTip(
-    tr("Current named instance (only available for variable fonts)"));
+  niComboBox_->setToolTip(tr(
+    "Current named instance (only available for variable fonts)"));
   closeFontButton_->setToolTip(tr("Close current font"));
-  fontUpButton_   ->setToolTip(tr("Previous font"));
-  faceUpButton_   ->setToolTip(tr("Previous subfont (face)"));
-  niUpButton_     ->setToolTip(tr("Previous named instance"));
-  fontDownButton_ ->setToolTip(tr("Next font"));
-  faceDownButton_ ->setToolTip(tr("Next subfont (face)"));
-  niDownButton_   ->setToolTip(tr("Next named instance"));
+  fontUpButton_->setToolTip(tr("Previous font"));
+  faceUpButton_->setToolTip(tr("Previous subfont (face)"));
+  niUpButton_->setToolTip(tr("Previous named instance"));
+  fontDownButton_->setToolTip(tr("Next font"));
+  faceDownButton_->setToolTip(tr("Next subfont (face)"));
+  niDownButton_->setToolTip(tr("Next named instance"));
 
   // Layouting
   layout_ = new QHBoxLayout;
@@ -401,25 +406,25 @@ TripletSelector::createConnections()
   connect(niComboBox_, QOverload<int>::of(&QComboBox::currentIndexChanged),
           this, &TripletSelector::updateNI);
 
-  connect(closeFontButton_, &QToolButton::clicked, 
+  connect(closeFontButton_, &QToolButton::clicked,
           this, &TripletSelector::closeCurrentFont);
-  connect(fontUpButton_   , &QToolButton::clicked, 
-          this, 
+  connect(fontUpButton_, &QToolButton::clicked,
+          this,
           std::bind(&TripletSelector::previousComboBoxItem, fontComboBox_));
-  connect(faceUpButton_   , &QToolButton::clicked, 
-          this, 
+  connect(faceUpButton_, &QToolButton::clicked,
+          this,
           std::bind(&TripletSelector::previousComboBoxItem, faceComboBox_));
-  connect(niUpButton_     , &QToolButton::clicked, 
-          this, 
+  connect(niUpButton_, &QToolButton::clicked,
+          this,
           std::bind(&TripletSelector::previousComboBoxItem, niComboBox_));
-  connect(fontDownButton_ , &QToolButton::clicked, 
-          this, 
+  connect(fontDownButton_, &QToolButton::clicked,
+          this,
           std::bind(&TripletSelector::nextComboBoxItem, fontComboBox_));
-  connect(faceDownButton_ , &QToolButton::clicked, 
+  connect(faceDownButton_, &QToolButton::clicked,
           this,
           std::bind(&TripletSelector::nextComboBoxItem, faceComboBox_));
-  connect(niDownButton_   , &QToolButton::clicked, 
-          this, 
+  connect(niDownButton_, &QToolButton::clicked,
+          this,
           std::bind(&TripletSelector::nextComboBoxItem, niComboBox_));
 
   connect(&engine_->fontFileManager(), &FontFileManager::currentFileChanged,
@@ -430,7 +435,7 @@ TripletSelector::createConnections()
 void
 TripletSelector::loadTriplet()
 {
-  // we do lazy computation of FT_Face objects
+  // We do lazy computation of `FT_Face` objects.
 
   // TODO really?
   auto fontIndex = fontComboBox_->currentIndex();
@@ -458,14 +463,14 @@ TripletSelector::loadTriplet()
     instanceIndex = 0;
 
   engine_->loadFont(fontIndex, faceIndex, instanceIndex);
-  
-  // TODO: This may messes up with bitmap-only fonts.
+
+  // TODO: This may mess up with bitmap-only fonts.
   if (!engine_->fontValid())
   {
-    // there might be various reasons why the current
+    // There might be various reasons why the current
     // (file, face, instance) triplet is invalid or missing;
     // we thus start our timer to periodically test
-    // whether the font starts working
+    // whether the font starts working.
     if (faceIndex >= 0 && faceIndex < engine_->numberOfOpenedFonts())
       engine_->fontFileManager().timerStart();
   }
@@ -479,7 +484,8 @@ TripletSelector::nextComboBoxItem(QComboBox* c)
 {
   if (c->currentIndex() < 0 || c->currentIndex() >= c->count() - 1)
     return;
-  // No need to handle further steps, the event handler will take care of these
+  // No need to handle further steps,
+  // the event handler will take care of these.
   c->setCurrentIndex(c->currentIndex() + 1);
 }
 
@@ -489,7 +495,8 @@ TripletSelector::previousComboBoxItem(QComboBox* c)
 {
   if (c->currentIndex() <= 0)
     return;
-  // No need to handle further steps, the event handler will take care of these
+  // No need to handle further steps,
+  // the event handler will take care of these.
   c->setCurrentIndex(c->currentIndex() - 1);
 }
 
diff --git a/src/ftinspect/widgets/tripletselector.hpp 
b/src/ftinspect/widgets/tripletselector.hpp
index 693f1ad..6689d2d 100644
--- a/src/ftinspect/widgets/tripletselector.hpp
+++ b/src/ftinspect/widgets/tripletselector.hpp
@@ -5,13 +5,16 @@
 #pragma once
 
 #include <vector>
-#include <QWidget>
+
+#include <QBoxLayout>
 #include <QComboBox>
 #include <QPushButton>
 #include <QToolButton>
-#include <QBoxLayout>
+#include <QWidget>
+
 
 class Engine;
+
 class TripletSelector
 : public QWidget
 {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]