freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][reorg-widgets] 5 commits: * Makefile: App


From: Charlie Jiang (@cqjjjzr)
Subject: [Git][freetype/freetype-demos][reorg-widgets] 5 commits: * Makefile: Append CPPFLAGS to CFLAGS so that they work in `graph`.
Date: Tue, 28 Jun 2022 13:03:28 +0000

Charlie Jiang pushed to branch reorg-widgets at FreeType / FreeType Demo Programs

Commits:

  • 8d329489
    by Hugh McMaster at 2022-06-21T12:59:07-04:00
    * Makefile: Append CPPFLAGS to CFLAGS so that they work in `graph`.
    
  • 23a41ca7
    by Charlie Jiang at 2022-06-28T12:27:45+00:00
    [ftinspect] Eliminate compile warnings.
    
    * src/ftinspect/engine.hpp: Use `uintptr_t` as type for `faceCounter`
    instead of `int`.
    
    * src/ftinspect/engine.cpp: Changing all casts to use `FTC_IDType` type
    (=`uintptr_t`) we defined.
    
    Fixes #10.
    
  • 66d6925b
    by Charlie Jiang at 2022-06-28T12:37:52+00:00
    * /src/ftinspect/.gitignore: Ignore Visual Studio specific files.
    
    This is for `ftinspect`.
    
  • bfbed48e
    by Charlie Jiang at 2022-06-28T12:37:52+00:00
    [ftinspect] Drop QMake, add CMake.
    
    * src/ftinspect/CMakeLists.txt: Add CMake build file for `ftinspect`.
    
    * src/ftinspect/ftinspect.pro: Remove QMake build file.
    
    Fixes #11
    
  • 197d5432
    by Charlie Jiang at 2022-06-28T20:59:53+08:00
    [ftinspect] Re-organize custom widgets.
    
    * src/ftinspect/maingui.hpp: Switch from individual widget files to the newly
    merged one.
    
    * src/ftinspect/widgets/custom_widgets.{cpp, hpp}: All 4 custom widgets.
    
    * src/ftinspect/widgets/qcomboboxx.{cpp, hpp}: Merged into custom_widgets..
    
    * src/ftinspect/widgets/qgraphicsviewx.{cpp, hpp}: Merged into custom_widgets.
    
    * src/ftinspect/widgets/qpushbottonx.{cpp, hpp}: Merged into custom_widgets.
    
    * src/ftinspect/widgets/qspinbox.{cpp, hpp}: Merged into custom_widgets.
    
    Those widgets could be considered "auxiliary components", and are pretty far
    from the core logic. Therefore, they should be made less "loud" (it's 8 source
    files out of 23 in total - more than 1/3 !).
    

16 changed files:

Changes:

  • Makefile
    ... ... @@ -125,6 +125,10 @@ else
    125 125
         SRC_DIR := $(TOP_DIR_2)/src
    
    126 126
       endif
    
    127 127
     
    
    128
    +  # Append any system-defined CPPFLAGS (e.g. hardening flags) to CFLAGS.
    
    129
    +  #
    
    130
    +  CFLAGS += $(CPPFLAGS)
    
    131
    +
    
    128 132
       ifeq ($(PLATFORM),unixdev)
    
    129 133
         # `FT_DEMO_CFLAGS` comes from FreeType's `configure` script (via
    
    130 134
         # `builds/unix/unix-cc.mk`), holding additional flags to compile the
    
    ... ... @@ -143,7 +147,6 @@ else
    143 147
     
    
    144 148
       COMPILE = $(CC) $(ANSIFLAGS) \
    
    145 149
                       $(INCLUDES:%=$I%) \
    
    146
    -                  $(CPPFLAGS) \
    
    147 150
                       $(CFLAGS) \
    
    148 151
                       $(FT_DEMO_CFLAGS)
    
    149 152
     
    

  • src/ftinspect/.gitignore
    ... ... @@ -4,3 +4,8 @@ ftinspect
    4 4
     moc_*.cpp
    
    5 5
     moc_*.h
    
    6 6
     .qmake.stash
    
    7
    +
    
    8
    +# Visual Studio specific
    
    9
    +out
    
    10
    +.vs
    
    11
    +CMakeSettings.json

  • src/ftinspect/CMakeLists.txt
    1
    +cmake_minimum_required (VERSION 3.0)
    
    2
    +cmake_policy(SET CMP0074 NEW)
    
    3
    +set(CMAKE_CXX_STANDARD 11)
    
    4
    +
    
    5
    +project("ftinspect")
    
    6
    +
    
    7
    +if (WIN32)
    
    8
    +  add_compile_options("/utf-8")
    
    9
    +endif ()
    
    10
    +
    
    11
    +set(CMAKE_AUTOMOC ON)
    
    12
    +set(CMAKE_AUTORCC ON)
    
    13
    +set(CMAKE_AUTOUIC ON)
    
    14
    +
    
    15
    +find_package(Qt5 COMPONENTS Widgets REQUIRED)
    
    16
    +find_package(Freetype REQUIRED)
    
    17
    +
    
    18
    +add_executable(ftinspect
    
    19
    +  "ftinspect.cpp"
    
    20
    +  "maingui.cpp"
    
    21
    +  
    
    22
    +  "engine/engine.cpp"
    
    23
    +
    
    24
    +  "rendering/glyphbitmap.cpp"
    
    25
    +  "rendering/glyphoutline.cpp"
    
    26
    +  "rendering/glyphpointnumbers.cpp"
    
    27
    +  "rendering/glyphpoints.cpp"
    
    28
    +  "rendering/grid.cpp"
    
    29
    +
    
    30
    +  "widgets/custom_widgets.cpp"
    
    31
    +)
    
    32
    +target_link_libraries(ftinspect
    
    33
    +  Qt5::Core Qt5::Widgets
    
    34
    +  Freetype::Freetype
    
    35
    +)

  • src/ftinspect/engine/engine.cpp
    ... ... @@ -259,7 +259,7 @@ Engine::numberOfFaces(int fontIndex)
    259 259
       long numFaces = -1;
    
    260 260
     
    
    261 261
       // search triplet (fontIndex, 0, 0)
    
    262
    -  FTC_FaceID ftcFaceID = reinterpret_cast<void*>
    
    262
    +  FTC_FaceID ftcFaceID = reinterpret_cast<FTC_FaceID>
    
    263 263
                                (faceIDMap.value(FaceID(fontIndex,
    
    264 264
                                                        0,
    
    265 265
                                                        0)));
    
    ... ... @@ -272,7 +272,7 @@ Engine::numberOfFaces(int fontIndex)
    272 272
       else
    
    273 273
       {
    
    274 274
         // not found; try to load triplet (fontIndex, 0, 0)
    
    275
    -    ftcFaceID = reinterpret_cast<void*>(faceCounter);
    
    275
    +    ftcFaceID = reinterpret_cast<FTC_FaceID>(faceCounter);
    
    276 276
         faceIDMap.insert(FaceID(fontIndex, 0, 0),
    
    277 277
                          faceCounter++);
    
    278 278
     
    
    ... ... @@ -299,7 +299,7 @@ Engine::numberOfNamedInstances(int fontIndex,
    299 299
       int numNamedInstances = -1;
    
    300 300
     
    
    301 301
       // search triplet (fontIndex, faceIndex, 0)
    
    302
    -  FTC_FaceID ftcFaceID = reinterpret_cast<void*>
    
    302
    +  FTC_FaceID ftcFaceID = reinterpret_cast<FTC_FaceID>
    
    303 303
                                (faceIDMap.value(FaceID(fontIndex,
    
    304 304
                                                        faceIndex,
    
    305 305
                                                        0)));
    
    ... ... @@ -312,7 +312,7 @@ Engine::numberOfNamedInstances(int fontIndex,
    312 312
       else
    
    313 313
       {
    
    314 314
         // not found; try to load triplet (fontIndex, faceIndex, 0)
    
    315
    -    ftcFaceID = reinterpret_cast<void*>(faceCounter);
    
    315
    +    ftcFaceID = reinterpret_cast<FTC_FaceID>(faceCounter);
    
    316 316
         faceIDMap.insert(FaceID(fontIndex, faceIndex, 0),
    
    317 317
                          faceCounter++);
    
    318 318
     
    
    ... ... @@ -340,7 +340,7 @@ Engine::loadFont(int fontIndex,
    340 340
       update();
    
    341 341
     
    
    342 342
       // search triplet (fontIndex, faceIndex, namedInstanceIndex)
    
    343
    -  scaler.face_id = reinterpret_cast<void*>
    
    343
    +  scaler.face_id = reinterpret_cast<FTC_FaceID>
    
    344 344
                          (faceIDMap.value(FaceID(fontIndex,
    
    345 345
                                                  faceIndex,
    
    346 346
                                                  namedInstanceIndex)));
    
    ... ... @@ -354,7 +354,7 @@ Engine::loadFont(int fontIndex,
    354 354
       {
    
    355 355
         // not found; try to load triplet
    
    356 356
         // (fontIndex, faceIndex, namedInstanceIndex)
    
    357
    -    scaler.face_id = reinterpret_cast<void*>(faceCounter);
    
    357
    +    scaler.face_id = reinterpret_cast<FTC_FaceID>(faceCounter);
    
    358 358
         faceIDMap.insert(FaceID(fontIndex,
    
    359 359
                                 faceIndex,
    
    360 360
                                 namedInstanceIndex),
    
    ... ... @@ -400,7 +400,7 @@ Engine::removeFont(int fontIndex)
    400 400
     {
    
    401 401
       // we iterate over all triplets that contain the given font index
    
    402 402
       // and remove them
    
    403
    -  QMap<FaceID, int>::iterator iter
    
    403
    +  QMap<FaceID, FTC_IDType>::iterator iter
    
    404 404
         = faceIDMap.lowerBound(FaceID(fontIndex, 0, 0));
    
    405 405
     
    
    406 406
       for (;;)
    
    ... ... @@ -412,7 +412,7 @@ Engine::removeFont(int fontIndex)
    412 412
         if (faceID.fontIndex != fontIndex)
    
    413 413
           break;
    
    414 414
     
    
    415
    -    FTC_FaceID ftcFaceID = reinterpret_cast<void*>(iter.value());
    
    415
    +    FTC_FaceID ftcFaceID = reinterpret_cast<FTC_FaceID>(iter.value());
    
    416 416
         FTC_Manager_RemoveFaceID(cacheManager, ftcFaceID);
    
    417 417
     
    
    418 418
         iter = faceIDMap.erase(iter);
    

  • src/ftinspect/engine/engine.hpp
    ... ... @@ -76,8 +76,9 @@ public:
    76 76
     private:
    
    77 77
       MainGUI* gui;
    
    78 78
     
    
    79
    -  int faceCounter; // a running number used to initialize `faceIDMap'
    
    80
    -  QMap<FaceID, int> faceIDMap;
    
    79
    +  using FTC_IDType = uintptr_t;
    
    80
    +  FTC_IDType faceCounter; // a running number used to initialize `faceIDMap'
    
    81
    +  QMap<FaceID, FTC_IDType> faceIDMap;
    
    81 82
     
    
    82 83
       QString curFamilyName;
    
    83 84
       QString curStyleName;
    

  • src/ftinspect/ftinspect.pro deleted
    1
    -# ftinspect.pro
    
    2
    -
    
    3
    -QMAKE_CXXFLAGS += -isystem ../../../freetype/include
    
    4
    -
    
    5
    -# To avoid conflicts with the FreeType version compiled into or used by Qt,
    
    6
    -# we use the static library.
    
    7
    -#
    
    8
    -# You should adapt this to your setup.
    
    9
    -unix|macx {
    
    10
    -  LIBS += ../../../freetype/objs/.libs/libfreetype.a
    
    11
    -
    
    12
    -  CONFIG += link_pkgconfig
    
    13
    -  PKGCONFIG += libpng harfbuzz zlib bzip2 libbrotlidec librsvg-2.0
    
    14
    -}
    
    15
    -win32 {
    
    16
    -  LIBS += ../../../freetyp2/objs/vc2010/freetype.lib
    
    17
    -  LIBS += -lpng -lharfbuzz -lz -lbz2 -lm -lbrotlidec -lrsvg-2
    
    18
    -}
    
    19
    -
    
    20
    -CONFIG += qt debug
    
    21
    -
    
    22
    -SOURCES += \
    
    23
    -  engine/engine.cpp \
    
    24
    -  rendering/glyphbitmap.cpp \
    
    25
    -  rendering/glyphoutline.cpp \
    
    26
    -  rendering/glyphpointnumbers.cpp \
    
    27
    -  rendering/glyphpoints.cpp \
    
    28
    -  rendering/grid.cpp \
    
    29
    -  widgets/qcomboboxx.cpp \
    
    30
    -  widgets/qgraphicsviewx.cpp \
    
    31
    -  widgets/qpushbuttonx.cpp \
    
    32
    -  widgets/qspinboxx.cpp \
    
    33
    -  ftinspect.cpp \
    
    34
    -  maingui.cpp
    
    35
    -
    
    36
    -HEADERS += \
    
    37
    -  engine/engine.hpp \
    
    38
    -  rendering/glyphbitmap.hpp \
    
    39
    -  rendering/glyphoutline.hpp \
    
    40
    -  rendering/glyphpointnumbers.hpp \
    
    41
    -  rendering/glyphpoints.hpp \
    
    42
    -  rendering/grid.hpp \
    
    43
    -  widgets/qcomboboxx.hpp \
    
    44
    -  widgets/qgraphicsviewx.hpp \
    
    45
    -  widgets/qpushbuttonx.hpp \
    
    46
    -  widgets/qspinboxx.hpp \
    
    47
    -  maingui.hpp
    
    48
    -
    
    49
    -TARGET = ftinspect
    
    50
    -
    
    51
    -QT += widgets
    
    52
    -
    
    53
    -
    
    54
    -# end of ftinpect.pro

  • src/ftinspect/maingui.hpp
    ... ... @@ -10,10 +10,7 @@
    10 10
     #include "rendering/glyphoutline.hpp"
    
    11 11
     #include "rendering/glyphpointnumbers.hpp"
    
    12 12
     #include "rendering/glyphpoints.hpp"
    
    13
    -#include "widgets/qcomboboxx.hpp"
    
    14
    -#include "widgets/qgraphicsviewx.hpp"
    
    15
    -#include "widgets/qpushbuttonx.hpp"
    
    16
    -#include "widgets/qspinboxx.hpp"
    
    13
    +#include "widgets/custom_widgets.hpp"
    
    17 14
     
    
    18 15
     #include <QAction>
    
    19 16
     #include <QCheckBox>
    

  • src/ftinspect/meson.build
    ... ... @@ -26,20 +26,14 @@ if qt5_dep.found()
    26 26
         'rendering/glyphpointnumbers.cpp',
    
    27 27
         'rendering/glyphpoints.cpp',
    
    28 28
         'rendering/grid.cpp',
    
    29
    -    'widgets/qcomboboxx.cpp',
    
    30
    -    'widgets/qgraphicsviewx.cpp',
    
    31
    -    'widgets/qpushbuttonx.cpp',
    
    32
    -    'widgets/qspinboxx.cpp',
    
    29
    +    'widgets/custom_widgets.cpp',
    
    33 30
         'ftinspect.cpp',
    
    34 31
         'maingui.cpp',
    
    35 32
       ])
    
    36 33
     
    
    37 34
       moc_files = qt5.preprocess(
    
    38 35
         moc_headers: [
    
    39
    -      'widgets/qcomboboxx.hpp',
    
    40
    -      'widgets/qgraphicsviewx.hpp',
    
    41
    -      'widgets/qpushbuttonx.hpp',
    
    42
    -      'widgets/qspinboxx.hpp',
    
    36
    +      'widgets/custom_widgets.hpp',
    
    43 37
           'maingui.hpp',
    
    44 38
         ],
    
    45 39
         dependencies: qt5_dep)
    

  • src/ftinspect/widgets/qspinboxx.cppsrc/ftinspect/widgets/custom_widgets.cpp
    1
    -// qspinboxx.cpp
    
    1
    +// custom_widgets.cpp
    
    2 2
     
    
    3 3
     // Copyright (C) 2016-2022 by Werner Lemberg.
    
    4 4
     
    
    5
    +#include "custom_widgets.hpp"
    
    5 6
     
    
    6
    -#include "qspinboxx.hpp"
    
    7
    +#include <QStandardItemModel>
    
    8
    +#include <QScrollBar>
    
    9
    +#include <QStyleOptionButton>
    
    7 10
     
    
    11
    +// ----------------------------
    
    12
    +// >>>>>>>> QComboBoxx <<<<<<<<
    
    13
    +// ----------------------------
    
    14
    +
    
    15
    +void
    
    16
    +QComboBoxx::setItemEnabled(int index,
    
    17
    +                           bool enable)
    
    18
    +{
    
    19
    +  const QStandardItemModel* itemModel =
    
    20
    +    qobject_cast<const QStandardItemModel*>(model());
    
    21
    +  QStandardItem* item = itemModel->item(index);
    
    22
    +
    
    23
    +  if (enable)
    
    24
    +  {
    
    25
    +    item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
    
    26
    +    item->setData(QVariant(),
    
    27
    +                  Qt::TextColorRole);
    
    28
    +  }
    
    29
    +  else
    
    30
    +  {
    
    31
    +    item->setFlags(item->flags()
    
    32
    +                   & ~(Qt::ItemIsSelectable | Qt::ItemIsEnabled));
    
    33
    +    // clear item data in order to use default color;
    
    34
    +    // this visually greys out the item
    
    35
    +    item->setData(palette().color(QPalette::Disabled, QPalette::Text),
    
    36
    +                  Qt::TextColorRole);
    
    37
    +  }
    
    38
    +}
    
    39
    +
    
    40
    +// --------------------------------
    
    41
    +// >>>>>>>> QGraphicsViewx <<<<<<<<
    
    42
    +// --------------------------------
    
    43
    +
    
    44
    +QGraphicsViewx::QGraphicsViewx()
    
    45
    +: lastBottomLeftPointInitialized(false)
    
    46
    +{
    
    47
    +  // empty
    
    48
    +}
    
    49
    +
    
    50
    +
    
    51
    +void
    
    52
    +QGraphicsViewx::scrollContentsBy(int dx,
    
    53
    +                                 int dy)
    
    54
    +{
    
    55
    +  QGraphicsView::scrollContentsBy(dx, dy);
    
    56
    +  lastBottomLeftPoint = viewport()->rect().bottomLeft();
    
    57
    +}
    
    58
    +
    
    59
    +
    
    60
    +void
    
    61
    +QGraphicsViewx::resizeEvent(QResizeEvent* event)
    
    62
    +{
    
    63
    +  QGraphicsView::resizeEvent(event);
    
    64
    +
    
    65
    +  // XXX I don't know how to properly initialize this value,
    
    66
    +  //     thus the hack with the boolean
    
    67
    +  if (!lastBottomLeftPointInitialized)
    
    68
    +  {
    
    69
    +    lastBottomLeftPoint = viewport()->rect().bottomLeft();
    
    70
    +    lastBottomLeftPointInitialized = true;
    
    71
    +  }
    
    72
    +
    
    73
    +  QPointF currentBottomLeftPoint = viewport()->rect().bottomLeft();
    
    74
    +  int verticalPosition = verticalScrollBar()->value();
    
    75
    +  verticalScrollBar()->setValue(static_cast<int>(
    
    76
    +                                  verticalPosition
    
    77
    +                                  - (currentBottomLeftPoint.y()
    
    78
    +                                     - lastBottomLeftPoint.y())));
    
    79
    +}
    
    80
    +
    
    81
    +// ------------------------------
    
    82
    +// >>>>>>>> QPushButtonx <<<<<<<<
    
    83
    +// ------------------------------
    
    84
    +
    
    85
    +// code derived from Qt 4.8.7, function `QPushButton::sizeHint',
    
    86
    +// file `src/gui/widgets/qpushbutton.cpp'
    
    87
    +
    
    88
    +QPushButtonx::QPushButtonx(const QString &text,
    
    89
    +                           QWidget *parent)
    
    90
    +: QPushButton(text, parent)
    
    91
    +{
    
    92
    +  QStyleOptionButton opt;
    
    93
    +  opt.initFrom(this);
    
    94
    +  QString s(this->text());
    
    95
    +  QFontMetrics fm = fontMetrics();
    
    96
    +  QSize sz = fm.size(Qt::TextShowMnemonic, s);
    
    97
    +  opt.rect.setSize(sz);
    
    98
    +
    
    99
    +  sz = style()->sizeFromContents(QStyle::CT_PushButton,
    
    100
    +                                 &opt,
    
    101
    +                                 sz,
    
    102
    +                                 this);
    
    103
    +  setFixedWidth(sz.width());
    
    104
    +}
    
    105
    +
    
    106
    +// ---------------------------
    
    107
    +// >>>>>>>> QSpinBoxx <<<<<<<<
    
    108
    +// ---------------------------
    
    8 109
     
    
    9 110
     // we want to mark the center of a pixel square with a single dot or a small
    
    10 111
     // cross; starting with a certain magnification we thus only use even values
    
    ... ... @@ -82,4 +183,4 @@ QSpinBoxx::stepBy(int steps)
    82 183
     }
    
    83 184
     
    
    84 185
     
    
    85
    -// end of qspinboxx.cpp
    186
    +// end of custom_widgets.cpp

  • src/ftinspect/widgets/qgraphicsviewx.hppsrc/ftinspect/widgets/custom_widgets.hpp
    1
    -// qgraphicsviewx.hpp
    
    1
    +// custom_widgets.hpp
    
    2 2
     
    
    3 3
     // Copyright (C) 2016-2022 by Werner Lemberg.
    
    4 4
     
    
    5
    -
    
    6 5
     #pragma once
    
    7 6
     
    
    7
    +#include <QComboBox>
    
    8 8
     #include <QGraphicsView>
    
    9
    +#include <QPushButton>
    
    10
    +#include <QSpinBox>
    
    11
    +#include <QString>
    
    12
    +
    
    13
    +// We need to define a series of custom Qt widgets to satisfy.
    
    14
    +// Basically those custom widgets are derived classes from Qt-provided components,
    
    15
    +// with minor changes.
    
    16
    +// Because all those derived classes are pretty tiny and not core logic, they're
    
    17
    +// organized into one single hpp/cpp pair.
    
    18
    +
    
    19
    +// we want to grey out items in a combo box;
    
    20
    +// since Qt doesn't provide a function for this we derive a class
    
    21
    +class QComboBoxx
    
    22
    +: public QComboBox
    
    23
    +{
    
    24
    +  Q_OBJECT
    
    25
    +
    
    26
    +public:
    
    27
    +  void setItemEnabled(int index,
    
    28
    +                      bool enable);
    
    29
    +};
    
    9 30
     
    
    10 31
     
    
    11 32
     // we want to anchor the view at the bottom left corner
    
    ... ... @@ -29,4 +50,29 @@ private:
    29 50
     };
    
    30 51
     
    
    31 52
     
    
    32
    -// end of qgraphicsviewx.hpp
    53
    +// we want buttons that are horizontally as small as possible
    
    54
    +class QPushButtonx
    
    55
    +: public QPushButton
    
    56
    +{
    
    57
    +  Q_OBJECT
    
    58
    +
    
    59
    +public:
    
    60
    +  QPushButtonx(const QString& text,
    
    61
    +               QWidget* = 0);
    
    62
    +  virtual ~QPushButtonx(){}
    
    63
    +};
    
    64
    +
    
    65
    +
    
    66
    +// we want to have our own `stepBy' function for the zoom spin box
    
    67
    +class QSpinBoxx
    
    68
    +: public QSpinBox
    
    69
    +{
    
    70
    +  Q_OBJECT
    
    71
    +
    
    72
    +public:
    
    73
    +  void stepBy(int val);
    
    74
    +  int valueFromText(const QString& text) const;
    
    75
    +};
    
    76
    +
    
    77
    +
    
    78
    +// end of custom_widgets.hpp

  • src/ftinspect/widgets/qcomboboxx.cpp deleted
    1
    -// qcomboboxx.cpp
    
    2
    -
    
    3
    -// Copyright (C) 2016-2022 by Werner Lemberg.
    
    4
    -
    
    5
    -
    
    6
    -#include "qcomboboxx.hpp"
    
    7
    -
    
    8
    -#include <QStandardItemModel>
    
    9
    -
    
    10
    -
    
    11
    -void
    
    12
    -QComboBoxx::setItemEnabled(int index,
    
    13
    -                           bool enable)
    
    14
    -{
    
    15
    -  const QStandardItemModel* itemModel =
    
    16
    -    qobject_cast<const QStandardItemModel*>(model());
    
    17
    -  QStandardItem* item = itemModel->item(index);
    
    18
    -
    
    19
    -  if (enable)
    
    20
    -  {
    
    21
    -    item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
    
    22
    -    item->setData(QVariant(),
    
    23
    -                  Qt::TextColorRole);
    
    24
    -  }
    
    25
    -  else
    
    26
    -  {
    
    27
    -    item->setFlags(item->flags()
    
    28
    -                   & ~(Qt::ItemIsSelectable | Qt::ItemIsEnabled));
    
    29
    -    // clear item data in order to use default color;
    
    30
    -    // this visually greys out the item
    
    31
    -    item->setData(palette().color(QPalette::Disabled, QPalette::Text),
    
    32
    -                  Qt::TextColorRole);
    
    33
    -  }
    
    34
    -}
    
    35
    -
    
    36
    -
    
    37
    -// end of qcomboboxx.cpp

  • src/ftinspect/widgets/qcomboboxx.hpp deleted
    1
    -// qcomboboxx.hpp
    
    2
    -
    
    3
    -// Copyright (C) 2016-2022 by Werner Lemberg.
    
    4
    -
    
    5
    -
    
    6
    -#pragma once
    
    7
    -
    
    8
    -#include <QComboBox>
    
    9
    -
    
    10
    -
    
    11
    -// we want to grey out items in a combo box;
    
    12
    -// since Qt doesn't provide a function for this we derive a class
    
    13
    -class QComboBoxx
    
    14
    -: public QComboBox
    
    15
    -{
    
    16
    -  Q_OBJECT
    
    17
    -
    
    18
    -public:
    
    19
    -  void setItemEnabled(int index,
    
    20
    -                      bool enable);
    
    21
    -};
    
    22
    -
    
    23
    -
    
    24
    -// end of qcomboboxx.hpp

  • src/ftinspect/widgets/qgraphicsviewx.cpp deleted
    1
    -// qgraphicsviewx.hpp
    
    2
    -
    
    3
    -// Copyright (C) 2016-2022 by Werner Lemberg.
    
    4
    -
    
    5
    -
    
    6
    -#include "qgraphicsviewx.hpp"
    
    7
    -
    
    8
    -#include <QScrollBar>
    
    9
    -
    
    10
    -
    
    11
    -QGraphicsViewx::QGraphicsViewx()
    
    12
    -: lastBottomLeftPointInitialized(false)
    
    13
    -{
    
    14
    -  // empty
    
    15
    -}
    
    16
    -
    
    17
    -
    
    18
    -void
    
    19
    -QGraphicsViewx::scrollContentsBy(int dx,
    
    20
    -                                 int dy)
    
    21
    -{
    
    22
    -  QGraphicsView::scrollContentsBy(dx, dy);
    
    23
    -  lastBottomLeftPoint = viewport()->rect().bottomLeft();
    
    24
    -}
    
    25
    -
    
    26
    -
    
    27
    -void
    
    28
    -QGraphicsViewx::resizeEvent(QResizeEvent* event)
    
    29
    -{
    
    30
    -  QGraphicsView::resizeEvent(event);
    
    31
    -
    
    32
    -  // XXX I don't know how to properly initialize this value,
    
    33
    -  //     thus the hack with the boolean
    
    34
    -  if (!lastBottomLeftPointInitialized)
    
    35
    -  {
    
    36
    -    lastBottomLeftPoint = viewport()->rect().bottomLeft();
    
    37
    -    lastBottomLeftPointInitialized = true;
    
    38
    -  }
    
    39
    -
    
    40
    -  QPointF currentBottomLeftPoint = viewport()->rect().bottomLeft();
    
    41
    -  int verticalPosition = verticalScrollBar()->value();
    
    42
    -  verticalScrollBar()->setValue(static_cast<int>(
    
    43
    -                                  verticalPosition
    
    44
    -                                  - (currentBottomLeftPoint.y()
    
    45
    -                                     - lastBottomLeftPoint.y())));
    
    46
    -}
    
    47
    -
    
    48
    -
    
    49
    -// end of qgraphicsviewx.cpp

  • src/ftinspect/widgets/qpushbuttonx.cpp deleted
    1
    -// qpushbuttonx.cpp
    
    2
    -
    
    3
    -// Copyright (C) 2016-2022 by Werner Lemberg.
    
    4
    -
    
    5
    -
    
    6
    -#include "qpushbuttonx.hpp"
    
    7
    -
    
    8
    -#include <QStyleOptionButton>
    
    9
    -
    
    10
    -
    
    11
    -// code derived from Qt 4.8.7, function `QPushButton::sizeHint',
    
    12
    -// file `src/gui/widgets/qpushbutton.cpp'
    
    13
    -
    
    14
    -QPushButtonx::QPushButtonx(const QString &text,
    
    15
    -                           QWidget *parent)
    
    16
    -: QPushButton(text, parent)
    
    17
    -{
    
    18
    -  QStyleOptionButton opt;
    
    19
    -  opt.initFrom(this);
    
    20
    -  QString s(this->text());
    
    21
    -  QFontMetrics fm = fontMetrics();
    
    22
    -  QSize sz = fm.size(Qt::TextShowMnemonic, s);
    
    23
    -  opt.rect.setSize(sz);
    
    24
    -
    
    25
    -  sz = style()->sizeFromContents(QStyle::CT_PushButton,
    
    26
    -                                 &opt,
    
    27
    -                                 sz,
    
    28
    -                                 this);
    
    29
    -  setFixedWidth(sz.width());
    
    30
    -}
    
    31
    -
    
    32
    -
    
    33
    -// end of qpushbuttonx.cpp

  • src/ftinspect/widgets/qpushbuttonx.hpp deleted
    1
    -// qpushbuttonx.hpp
    
    2
    -
    
    3
    -// Copyright (C) 2016-2022 by Werner Lemberg.
    
    4
    -
    
    5
    -
    
    6
    -#pragma once
    
    7
    -
    
    8
    -#include <QPushButton>
    
    9
    -
    
    10
    -
    
    11
    -// we want buttons that are horizontally as small as possible
    
    12
    -class QPushButtonx
    
    13
    -: public QPushButton
    
    14
    -{
    
    15
    -  Q_OBJECT
    
    16
    -
    
    17
    -public:
    
    18
    -  QPushButtonx(const QString& text,
    
    19
    -               QWidget* = 0);
    
    20
    -  virtual ~QPushButtonx(){}
    
    21
    -};
    
    22
    -
    
    23
    -
    
    24
    -// end of qpushbuttonx.hpp

  • src/ftinspect/widgets/qspinboxx.hpp deleted
    1
    -// qspinboxx.hpp
    
    2
    -
    
    3
    -// Copyright (C) 2016-2022 by Werner Lemberg.
    
    4
    -
    
    5
    -
    
    6
    -#pragma once
    
    7
    -
    
    8
    -#include <QSpinBox>
    
    9
    -#include <QString>
    
    10
    -
    
    11
    -
    
    12
    -// we want to have our own `stepBy' function for the zoom spin box
    
    13
    -class QSpinBoxx
    
    14
    -: public QSpinBox
    
    15
    -{
    
    16
    -  Q_OBJECT
    
    17
    -
    
    18
    -public:
    
    19
    -  void stepBy(int val);
    
    20
    -  int valueFromText(const QString& text) const;
    
    21
    -};
    
    22
    -
    
    23
    -
    
    24
    -// qspinboxx.hpp


  • reply via email to

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