QStyle: make standardIcon() & layoutSpacing() virtual
Removes standardIconImplementation() and layoutSpacingImplementation() that were added in Qt 4 as a workaround for binary compatibility reasons. Change-Id: I45292dc6802310d6cda4f443bb7484b061af0138 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
parent
531b96f42e
commit
dd299a568b
5
dist/changes-5.0.0
vendored
5
dist/changes-5.0.0
vendored
@ -455,6 +455,11 @@ QtWidgets
|
|||||||
|
|
||||||
* QInputDialog::getInteger() has been obsoleted. Use QInputDialog::getInt() instead.
|
* QInputDialog::getInteger() has been obsoleted. Use QInputDialog::getInt() instead.
|
||||||
|
|
||||||
|
* In Qt 4, QStyle::standardIconImplementation() and layoutSpacingImplementation()
|
||||||
|
were introduced instead of making the corresponding methods virtual due to binary
|
||||||
|
compatibility reasons. QStyle::standardIcon() and layoutSpacing() have been made
|
||||||
|
(pure) virtual in Qt 5.
|
||||||
|
|
||||||
* In Qt 4, many QStyleOption subclasses were introduced in order to keep
|
* In Qt 4, many QStyleOption subclasses were introduced in order to keep
|
||||||
binary compatibility -- QStyleOption was designed to be extended this way,
|
binary compatibility -- QStyleOption was designed to be extended this way,
|
||||||
in fact it embeds a version number. In Qt 5 the various QStyleOption*V{2,3,4}
|
in fact it embeds a version number. In Qt 5 the various QStyleOption*V{2,3,4}
|
||||||
|
@ -2021,7 +2021,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
|
|||||||
|
|
||||||
Developers calling standardPixmap() should instead call standardIcon()
|
Developers calling standardPixmap() should instead call standardIcon()
|
||||||
Developers who re-implemented standardPixmap() should instead re-implement
|
Developers who re-implemented standardPixmap() should instead re-implement
|
||||||
the slot standardIconImplementation().
|
standardIcon().
|
||||||
|
|
||||||
\sa standardIcon()
|
\sa standardIcon()
|
||||||
*/
|
*/
|
||||||
@ -2213,6 +2213,9 @@ QPalette QStyle::standardPalette() const
|
|||||||
/*!
|
/*!
|
||||||
\since 4.1
|
\since 4.1
|
||||||
|
|
||||||
|
\fn QIcon QStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0,
|
||||||
|
const QWidget *widget = 0) const = 0;
|
||||||
|
|
||||||
Returns an icon for the given \a standardIcon.
|
Returns an icon for the given \a standardIcon.
|
||||||
|
|
||||||
The \a standardIcon is a standard pixmap which can follow some
|
The \a standardIcon is a standard pixmap which can follow some
|
||||||
@ -2220,57 +2223,15 @@ QPalette QStyle::standardPalette() const
|
|||||||
used to pass extra information required when defining the
|
used to pass extra information required when defining the
|
||||||
appropriate icon. The \a widget argument is optional and can also
|
appropriate icon. The \a widget argument is optional and can also
|
||||||
be used to aid the determination of the icon.
|
be used to aid the determination of the icon.
|
||||||
|
|
||||||
\warning Because of binary compatibility constraints, this
|
|
||||||
function is not virtual. If you want to provide your own icons in
|
|
||||||
a QStyle subclass, reimplement the standardIconImplementation()
|
|
||||||
slot in your subclass instead. The standardIcon() function will
|
|
||||||
dynamically detect the slot and call it.
|
|
||||||
|
|
||||||
\sa standardIconImplementation()
|
|
||||||
*/
|
*/
|
||||||
QIcon QStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option,
|
|
||||||
const QWidget *widget) const
|
|
||||||
{
|
|
||||||
QIcon result;
|
|
||||||
// ### Qt 4.1: invokeMethod should accept const functions, to avoid this dirty cast
|
|
||||||
QMetaObject::invokeMethod(const_cast<QStyle*>(this),
|
|
||||||
"standardIconImplementation", Qt::DirectConnection,
|
|
||||||
Q_RETURN_ARG(QIcon, result),
|
|
||||||
Q_ARG(StandardPixmap, standardIcon),
|
|
||||||
Q_ARG(const QStyleOption*, option),
|
|
||||||
Q_ARG(const QWidget*, widget));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\since 4.1
|
|
||||||
|
|
||||||
Returns an icon for the given \a standardIcon.
|
|
||||||
|
|
||||||
Reimplement this slot to provide your own icons in a QStyle
|
|
||||||
subclass; because of binary compatibility constraints, the
|
|
||||||
standardIcon() function (introduced in Qt 4.1) is not
|
|
||||||
virtual. Instead, standardIcon() will dynamically detect and call
|
|
||||||
\e this slot.
|
|
||||||
|
|
||||||
The \a standardIcon is a standard pixmap which can follow some
|
|
||||||
existing GUI style or guideline. The \a option argument can be
|
|
||||||
used to pass extra information required when defining the
|
|
||||||
appropriate icon. The \a widget argument is optional and can also
|
|
||||||
be used to aid the determination of the icon.
|
|
||||||
|
|
||||||
\sa standardIcon()
|
|
||||||
*/
|
|
||||||
QIcon QStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
|
|
||||||
const QWidget *widget) const
|
|
||||||
{
|
|
||||||
return QIcon(standardPixmap(standardIcon, option, widget));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\since 4.3
|
\since 4.3
|
||||||
|
|
||||||
|
\fn int QStyle::layoutSpacing(QSizePolicy::ControlType control1,
|
||||||
|
QSizePolicy::ControlType control2, Qt::Orientation orientation,
|
||||||
|
const QStyleOption *option = 0, const QWidget *widget = 0) const
|
||||||
|
|
||||||
Returns the spacing that should be used between \a control1 and
|
Returns the spacing that should be used between \a control1 and
|
||||||
\a control2 in a layout. \a orientation specifies whether the
|
\a control2 in a layout. \a orientation specifies whether the
|
||||||
controls are laid out side by side or stacked vertically. The \a
|
controls are laid out side by side or stacked vertically. The \a
|
||||||
@ -2282,35 +2243,8 @@ QIcon QStyle::standardIconImplementation(StandardPixmap standardIcon, const QSty
|
|||||||
PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
|
PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
|
||||||
negative value.
|
negative value.
|
||||||
|
|
||||||
For binary compatibility reasons, this function is not virtual.
|
\sa combinedLayoutSpacing()
|
||||||
If you want to specify custom layout spacings in a QStyle
|
|
||||||
subclass, implement a slot called layoutSpacingImplementation().
|
|
||||||
QStyle will discover the slot at run-time (using Qt's
|
|
||||||
\l{meta-object system}) and direct all calls to layoutSpacing()
|
|
||||||
to layoutSpacingImplementation().
|
|
||||||
|
|
||||||
\sa combinedLayoutSpacing(), layoutSpacingImplementation()
|
|
||||||
*/
|
*/
|
||||||
int QStyle::layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
|
|
||||||
Qt::Orientation orientation, const QStyleOption *option,
|
|
||||||
const QWidget *widget) const
|
|
||||||
{
|
|
||||||
Q_D(const QStyle);
|
|
||||||
if (d->layoutSpacingIndex == -1) {
|
|
||||||
d->layoutSpacingIndex = metaObject()->indexOfMethod(
|
|
||||||
"layoutSpacingImplementation(QSizePolicy::ControlType,QSizePolicy::ControlType,"
|
|
||||||
"Qt::Orientation,const QStyleOption*,const QWidget*)"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (d->layoutSpacingIndex < 0)
|
|
||||||
return -1;
|
|
||||||
int result = -1;
|
|
||||||
void *param[] = {&result, &control1, &control2, &orientation, &option, &widget};
|
|
||||||
|
|
||||||
const_cast<QStyle *>(this)->qt_metacall(QMetaObject::InvokeMetaMethod,
|
|
||||||
d->layoutSpacingIndex, param);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\since 4.3
|
\since 4.3
|
||||||
@ -2329,7 +2263,7 @@ int QStyle::layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::Contro
|
|||||||
PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
|
PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
|
||||||
negative value.
|
negative value.
|
||||||
|
|
||||||
\sa layoutSpacing(), layoutSpacingImplementation()
|
\sa layoutSpacing()
|
||||||
*/
|
*/
|
||||||
int QStyle::combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
|
int QStyle::combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
|
||||||
QSizePolicy::ControlTypes controls2, Qt::Orientation orientation,
|
QSizePolicy::ControlTypes controls2, Qt::Orientation orientation,
|
||||||
@ -2350,36 +2284,6 @@ int QStyle::combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
\since 4.3
|
|
||||||
|
|
||||||
This slot is called by layoutSpacing() to determine the spacing
|
|
||||||
that should be used between \a control1 and \a control2 in a
|
|
||||||
layout. \a orientation specifies whether the controls are laid
|
|
||||||
out side by side or stacked vertically. The \a option parameter
|
|
||||||
can be used to pass extra information about the parent widget.
|
|
||||||
The \a widget parameter is optional and can also be used if \a
|
|
||||||
option is 0.
|
|
||||||
|
|
||||||
If you want to provide custom layout spacings in a QStyle
|
|
||||||
subclass, implement a slot called layoutSpacingImplementation()
|
|
||||||
in your subclass. Be aware that this slot will only be called if
|
|
||||||
PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
|
|
||||||
negative value.
|
|
||||||
|
|
||||||
The default implementation returns -1.
|
|
||||||
|
|
||||||
\sa layoutSpacing(), combinedLayoutSpacing()
|
|
||||||
*/
|
|
||||||
int QStyle::layoutSpacingImplementation(QSizePolicy::ControlType /* control1 */,
|
|
||||||
QSizePolicy::ControlType /* control2 */,
|
|
||||||
Qt::Orientation /*orientation*/,
|
|
||||||
const QStyleOption * /* option */,
|
|
||||||
const QWidget * /* widget */) const
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
QT_BEGIN_INCLUDE_NAMESPACE
|
QT_BEGIN_INCLUDE_NAMESPACE
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
QT_END_INCLUDE_NAMESPACE
|
QT_END_INCLUDE_NAMESPACE
|
||||||
|
@ -784,8 +784,8 @@ public:
|
|||||||
virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt = 0,
|
virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt = 0,
|
||||||
const QWidget *widget = 0) const = 0;
|
const QWidget *widget = 0) const = 0;
|
||||||
|
|
||||||
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0,
|
virtual QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0,
|
||||||
const QWidget *widget = 0) const;
|
const QWidget *widget = 0) const = 0;
|
||||||
|
|
||||||
virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
|
virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
|
||||||
const QStyleOption *opt) const = 0;
|
const QStyleOption *opt) const = 0;
|
||||||
@ -802,24 +802,15 @@ public:
|
|||||||
static QRect alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment,
|
static QRect alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment,
|
||||||
const QSize &size, const QRect &rectangle);
|
const QSize &size, const QRect &rectangle);
|
||||||
|
|
||||||
int layoutSpacing(QSizePolicy::ControlType control1,
|
virtual int layoutSpacing(QSizePolicy::ControlType control1,
|
||||||
QSizePolicy::ControlType control2, Qt::Orientation orientation,
|
QSizePolicy::ControlType control2, Qt::Orientation orientation,
|
||||||
const QStyleOption *option = 0, const QWidget *widget = 0) const;
|
const QStyleOption *option = 0, const QWidget *widget = 0) const = 0;
|
||||||
int combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
|
int combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
|
||||||
QSizePolicy::ControlTypes controls2, Qt::Orientation orientation,
|
QSizePolicy::ControlTypes controls2, Qt::Orientation orientation,
|
||||||
QStyleOption *option = 0, QWidget *widget = 0) const;
|
QStyleOption *option = 0, QWidget *widget = 0) const;
|
||||||
|
|
||||||
const QStyle * proxy() const;
|
const QStyle * proxy() const;
|
||||||
|
|
||||||
protected Q_SLOTS:
|
|
||||||
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
|
|
||||||
const QWidget *widget = 0) const;
|
|
||||||
int layoutSpacingImplementation(QSizePolicy::ControlType control1,
|
|
||||||
QSizePolicy::ControlType control2,
|
|
||||||
Qt::Orientation orientation,
|
|
||||||
const QStyleOption *option = 0,
|
|
||||||
const QWidget *widget = 0) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(QStyle)
|
Q_DISABLE_COPY(QStyle)
|
||||||
friend class QWidget;
|
friend class QWidget;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user