OSDN Git Service

QIcon documentation update
authorIvailo Monev <xakepa10@gmail.com>
Wed, 24 May 2023 21:40:07 +0000 (00:40 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Wed, 24 May 2023 21:40:07 +0000 (00:40 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/gui/image/qicon.cpp
src/gui/image/qiconengine.cpp

index 3efb017..6d05a89 100644 (file)
@@ -64,13 +64,13 @@ QT_BEGIN_NAMESPACE
 */
 
 /*!
-  \enum QIcon::State
+    \enum QIcon::State
 
-  This enum describes the state for which a pixmap is intended to be
-  used. The \e state can be:
+    This enum describes the state for which a pixmap is intended to be
+    used. The \e state can be:
 
-  \value Off  Display the pixmap when the widget is in an "off" state
-  \value On  Display the pixmap when the widget is in an "on" state
+    \value Off  Display the pixmap when the widget is in an "off" state
+    \value On  Display the pixmap when the widget is in an "on" state
 */
 
 static QAtomicInt serialNumCounter(1);
@@ -388,73 +388,73 @@ bool QPixmapIconEngine::write(QDataStream &out) const
 }
 
 /*!
-  \class QIcon
+    \class QIcon
 
-  \brief The QIcon class provides scalable icons in different modes
-  and states.
+    \brief The QIcon class provides scalable icons in different modes
+    and states.
 
-  \ingroup painting
-  \ingroup shared
+    \ingroup painting
+    \ingroup shared
 
 
-  A QIcon can generate smaller, larger, active, and disabled pixmaps
-  from the set of pixmaps it is given. Such pixmaps are used by Qt
-  widgets to show an icon representing a particular action.
+    A QIcon can generate smaller, larger, active, and disabled pixmaps
+    from the set of pixmaps it is given. Such pixmaps are used by Qt
+    widgets to show an icon representing a particular action.
 
-  The simplest use of QIcon is to create one from a QPixmap file or
-  resource, and then use it, allowing Qt to work out all the required
-  icon styles and sizes. For example:
+    The simplest use of QIcon is to create one from a QPixmap file or
+    resource, and then use it, allowing Qt to work out all the required
+    icon styles and sizes. For example:
 
-  \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 0
+    \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 0
 
-  To undo a QIcon, simply set a null icon in its place:
+    To undo a QIcon, simply set a null icon in its place:
 
-  \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 1
+    \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 1
 
-  Use the QImageReader::supportedImageFormats() and
-  QImageWriter::supportedImageFormats() functions to retrieve a
-  complete list of the supported file formats.
-
-  When you retrieve a pixmap using pixmap(QSize, Mode, State), and no
-  pixmap for this given size, mode and state has been added with
-  addFile() or addPixmap(), then QIcon will generate one on the
-  fly. This pixmap generation happens in a QIconEngine. The default
-  engine scales pixmaps down if required, but never up, and it uses
-  the current style to calculate a disabled appearance. By using
-  custom icon engines, you can customize every aspect of generated
-  icons. With QIconEnginePluginV2 it is possible to register different
-  icon engines for different file suffixes, making it possible for
-  third parties to provide additional icon engines to those included
-  with Qt.
-
-  \note Since Qt 4.2, an icon engine that supports SVG is included.
-
-  \section1 Making Classes that Use QIcon
-
-  If you write your own widgets that have an option to set a small
-  pixmap, consider allowing a QIcon to be set for that pixmap.  The
-  Qt class QToolButton is an example of such a widget.
-
-  Provide a method to set a QIcon, and when you draw the icon, choose
-  whichever pixmap is appropriate for the current state of your widget.
-  For example:
-  \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 2
-
-  You might also make use of the \c Active mode, perhaps making your
-  widget \c Active when the mouse is over the widget (see \l
-  QWidget::enterEvent()), while the mouse is pressed pending the
-  release that will activate the function, or when it is the currently
-  selected item. If the widget can be toggled, the "On" mode might be
-  used to draw a different icon.
-
-  \img icon.png QIcon
+    Use the QImageReader::supportedImageFormats() and
+    QImageWriter::supportedImageFormats() functions to retrieve a
+    complete list of the supported file formats.
 
-  \sa {fowler}{GUI Design Handbook: Iconic Label}, {Icons Example}
+    When you retrieve a pixmap using pixmap(QSize, Mode, State), and no
+    pixmap for this given size, mode and state has been added with
+    addFile() or addPixmap(), then QIcon will generate one on the
+    fly. This pixmap generation happens in a QIconEngine. The default
+    engine scales pixmaps down if required, but never up, and it uses
+    the current style to calculate a disabled appearance. By using
+    custom icon engines, you can customize every aspect of generated
+    icons. With QIconEnginePluginV2 it is possible to register different
+    icon engines for different file suffixes, making it possible for
+    third parties to provide additional icon engines to those included
+    with Qt.
+
+    \note Since Qt 4.2, an icon engine that supports SVG is included.
+
+    \section1 Making Classes that Use QIcon
+
+    If you write your own widgets that have an option to set a small
+    pixmap, consider allowing a QIcon to be set for that pixmap.  The
+    Qt class QToolButton is an example of such a widget.
+
+    Provide a method to set a QIcon, and when you draw the icon, choose
+    whichever pixmap is appropriate for the current state of your widget.
+    For example:
+    \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 2
+
+    You might also make use of the \c Active mode, perhaps making your
+    widget \c Active when the mouse is over the widget (see \l
+    QWidget::enterEvent()), while the mouse is pressed pending the
+    release that will activate the function, or when it is the currently
+    selected item. If the widget can be toggled, the "On" mode might be
+    used to draw a different icon.
+
+    \img icon.png QIcon
+
+    \sa {fowler}{GUI Design Handbook: Iconic Label}, {Icons Example}
 */
 
 
 /*!
-  Constructs a null icon.
+    Constructs a null icon.
 */
 QIcon::QIcon()
     : d(nullptr)
@@ -462,8 +462,8 @@ QIcon::QIcon()
 }
 
 /*!
-  Constructs an icon from a \a pixmap.
- */
+    Constructs an icon from a \a pixmap.
+*/
 QIcon::QIcon(const QPixmap &pixmap)
     : d(nullptr)
 {
@@ -471,7 +471,7 @@ QIcon::QIcon(const QPixmap &pixmap)
 }
 
 /*!
-  Constructs a copy of \a other. This is very fast.
+    Constructs a copy of \a other. This is very fast.
 */
 QIcon::QIcon(const QIcon &other)
     : d(other.d)
@@ -543,7 +543,7 @@ QIcon &QIcon::operator=(const QIcon &other)
 */
 
 /*!
-   Returns the icon as a QVariant.
+    Returns the icon as a QVariant.
 */
 QIcon::operator QVariant() const
 {
@@ -571,11 +571,11 @@ qint64 QIcon::cacheKey() const
 }
 
 /*!
-  Returns a pixmap with the requested \a size, \a mode, and \a
-  state, generating one if necessary. The pixmap might be smaller than
-  requested, but never larger.
+    Returns a pixmap with the requested \a size, \a mode, and \a
+    state, generating one if necessary. The pixmap might be smaller than
+    requested, but never larger.
 
-  \sa actualSize(), paint()
+    \sa actualSize(), paint()
 */
 QPixmap QIcon::pixmap(const QSize &size, Mode mode, State state) const
 {
@@ -602,11 +602,12 @@ QPixmap QIcon::pixmap(const QSize &size, Mode mode, State state) const
     than requested, but never larger.
 */
 
-/*!  Returns the actual size of the icon for the requested \a size, \a
-  mode, and \a state. The result might be smaller than requested, but
-  never larger.
+/*!
+    Returns the actual size of the icon for the requested \a size, \a
+    mode, and \a state. The result might be smaller than requested, but
+    never larger.
 
-  \sa pixmap(), paint()
+    \sa pixmap(), paint()
 */
 QSize QIcon::actualSize(const QSize &size, Mode mode, State state) const
 {
@@ -652,7 +653,8 @@ bool QIcon::isNull() const
     return !d;
 }
 
-/*! \internal
+/*!
+    \internal
  */
 void QIcon::detach()
 {
@@ -691,14 +693,15 @@ void QIcon::addPixmap(const QPixmap &pixmap, Mode mode, State state)
 }
 
 
-/*!  Adds an image from the file with the given \a fileName to the
-     icon, as a specialization for \a size, \a mode and \a state. The
-     file will be loaded on demand. Note: custom icon engines are free
-     to ignore additionally added pixmaps.
+/*!
+    Adds an image from the file with the given \a fileName to the
+    icon, as a specialization for \a size, \a mode and \a state. The
+    file will be loaded on demand. Note: custom icon engines are free
+    to ignore additionally added pixmaps.
 
-     If \a fileName contains a relative path (e.g. the filename only)
-     the relevant file must be found relative to the runtime working
-     directory.
+    If \a fileName contains a relative path (e.g. the filename only)
+    the relevant file must be found relative to the runtime working
+    directory.
 
     The file name can be either refer to an actual file on disk or to
     one of the application's embedded resources. See the
@@ -791,20 +794,16 @@ void QIcon::setThemeSearchPaths(const QStringList &paths)
 }
 
 /*!
-  \since 4.6
-
-  Returns the search paths for icon themes.
+    \since 4.6
 
-  The default value will depend on the platform:
+    Returns the search paths for icon themes.
 
-  On X11, the search path will use the XDG_DATA_DIRS environment
-  variable if available.
+    The default value will depend on the platform:
 
-  By default all platforms will have the resource directory
-  \c{:\icons} as a fallback. You can use "rcc -project" to generate a
-  resource file from your icon theme.
+    On X11, the search path will use the XDG_DATA_DIRS environment
+    variable if available.
 
-  \sa setThemeSearchPaths(), fromTheme(), setThemeName()
+    \sa setThemeSearchPaths(), fromTheme(), setThemeName()
 */
 QStringList QIcon::themeSearchPaths()
 {
index 0cde7d2..dd65a2b 100644 (file)
 QT_BEGIN_NAMESPACE
 
 /*!
-  \class QIconEngine
+    \class QIconEngine
 
-  \brief The QIconEngine class provides an abstract base class for QIcon renderers.
+    \brief The QIconEngine class provides an abstract base class for QIcon renderers.
 
-  \ingroup painting
+    \ingroup painting
 
-  An icon engine provides the rendering functions for a QIcon. Each icon has a
-  corresponding icon engine that is responsible for drawing the icon with a
-  requested size, mode and state.
+    An icon engine provides the rendering functions for a QIcon. Each icon has a
+    corresponding icon engine that is responsible for drawing the icon with a
+    requested size, mode and state.
 
-  The icon is rendered by the paint() function, and the icon can additionally be
-  obtained as a pixmap with the pixmap() function (the default implementation
-  simply uses paint() to achieve this). The addPixmap() function can be used to
-  add new pixmaps to the icon engine, and is used by QIcon to add specialized
-  custom pixmaps.
+    The icon is rendered by the paint() function, and the icon can additionally be
+    obtained as a pixmap with the pixmap() function (the default implementation
+    simply uses paint() to achieve this). The addPixmap() function can be used to
+    add new pixmaps to the icon engine, and is used by QIcon to add specialized
+    custom pixmaps.
 
-  The paint(), pixmap(), and addPixmap() functions are all virtual, and can
-  therefore be reimplemented in subclasses of QIconEngine.
-
-  \sa QIconEnginePlugin
+    The paint(), pixmap(), and addPixmap() functions are all virtual, and can
+    therefore be reimplemented in subclasses of QIconEngine.
 
+    \sa QIconEnginePlugin
 */
 
 /*!
-  \fn virtual void QIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) = 0;
+    \fn virtual void QIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) = 0;
 
-  Uses the given \a painter to paint the icon with the required \a mode and
-  \a state into the rectangle \a rect.
+    Uses the given \a painter to paint the icon with the required \a mode and
+    \a state into the rectangle \a rect.
 */
 
-/*!  Returns the actual size of the icon the engine provides for the
-  requested \a size, \a mode and \a state. The default implementation
-  returns the given \a size.
- */
+/*!
+    Returns the actual size of the icon the engine provides for the
+    requested \a size, \a mode and \a state. The default implementation
+    returns the given \a size.
+*/
 QSize QIconEngine::actualSize(const QSize &size, QIcon::Mode /*mode*/, QIcon::State /*state*/)
 {
     return size;
@@ -66,17 +66,16 @@ QSize QIconEngine::actualSize(const QSize &size, QIcon::Mode /*mode*/, QIcon::St
 
 
 /*!
-  Destroys the icon engine.
- */
+    Destroys the icon engine.
+*/
 QIconEngine::~QIconEngine()
 {
 }
 
-
 /*!
-  Returns the icon as a pixmap with the required \a size, \a mode,
-  and \a state. The default implementation creates a new pixmap and
-  calls paint() to fill it.
+    Returns the icon as a pixmap with the required \a size, \a mode,
+    and \a state. The default implementation creates a new pixmap and
+    calls paint() to fill it.
 */
 QPixmap QIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
 {
@@ -89,32 +88,33 @@ QPixmap QIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State st
 }
 
 /*!
-  Called by QIcon::addPixmap(). Adds a specialized \a pixmap for the given
-  \a mode and \a state. The default pixmap-based engine stores any supplied
-  pixmaps, and it uses them instead of scaled pixmaps if the size of a pixmap
-  matches the size of icon requested. Custom icon engines that implement
-  scalable vector formats are free to ignores any extra pixmaps.
- */
+    Called by QIcon::addPixmap(). Adds a specialized \a pixmap for the given
+    \a mode and \a state. The default pixmap-based engine stores any supplied
+    pixmaps, and it uses them instead of scaled pixmaps if the size of a pixmap
+    matches the size of icon requested. Custom icon engines that implement
+    scalable vector formats are free to ignores any extra pixmaps.
+*/
 void QIconEngine::addPixmap(const QPixmap &/*pixmap*/, QIcon::Mode /*mode*/, QIcon::State /*state*/)
 {
 }
 
 
-/*!  Called by QIcon::addFile(). Adds a specialized pixmap from the
-  file with the given \a fileName, \a size, \a mode and \a state. The
-  default pixmap-based engine stores any supplied file names, and it
-  loads the pixmaps on demand instead of using scaled pixmaps if the
-  size of a pixmap matches the size of icon requested. Custom icon
-  engines that implement scalable vector formats are free to ignores
-  any extra files.
- */
+/*!
+    Called by QIcon::addFile(). Adds a specialized pixmap from the
+    file with the given \a fileName, \a size, \a mode and \a state. The
+    default pixmap-based engine stores any supplied file names, and it
+    loads the pixmaps on demand instead of using scaled pixmaps if the
+    size of a pixmap matches the size of icon requested. Custom icon
+    engines that implement scalable vector formats are free to ignores
+    any extra files.
+*/
 void QIconEngine::addFile(const QString &/*fileName*/, const QSize &/*size*/, QIcon::Mode /*mode*/, QIcon::State /*state*/)
 {
 }
 
 /*!
     Returns a key that identifies this icon engine.
- */
+*/
 QString QIconEngine::key() const
 {
     return QString();
@@ -122,7 +122,7 @@ QString QIconEngine::key() const
 
 /*!
     Returns a clone of this icon engine.
- */
+*/
 QIconEngine *QIconEngine::clone() const
 {
     return 0;
@@ -133,7 +133,7 @@ QIconEngine *QIconEngine::clone() const
     true if the contents were read; otherwise returns false.
 
     QIconEngine's default implementation always return false.
- */
+*/
 bool QIconEngine::read(QDataStream &)
 {
     return false;
@@ -144,7 +144,7 @@ bool QIconEngine::read(QDataStream &)
     Returns true if the contents were written; otherwise returns false.
 
     QIconEngine's default implementation always return false.
- */
+*/
 bool QIconEngine::write(QDataStream &) const
 {
     return false;
@@ -158,7 +158,7 @@ bool QIconEngine::write(QDataStream &) const
 
     \note This is a helper method and depends on icon engine support, it
     may not work with all icon engines.
- */
+*/
 QList<QSize> QIconEngine::availableSizes(QIcon::Mode mode, QIcon::State state) const
 {
     return QList<QSize>();
@@ -171,7 +171,7 @@ QList<QSize> QIconEngine::availableSizes(QIcon::Mode mode, QIcon::State state) c
 
     \note This is a helper method and depends on icon engine support, it
     may not work with all icon engines.
- */
+*/
 QString QIconEngine::iconName() const
 {
     return QString();