summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/styles')
-rw-r--r--src/widgets/styles/qcommonstyle.cpp10
-rw-r--r--src/widgets/styles/qfusionstyle.cpp6
-rw-r--r--src/widgets/styles/qstyleoption.cpp26
-rw-r--r--src/widgets/styles/qstyleoption.h23
4 files changed, 52 insertions, 13 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index ff115596bf..a2f52562c8 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -1682,11 +1682,11 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
p->setFont(fnt);
fm = QFontMetrics((p->font()));
}
- QString text;
- if (header->textElideMode != Qt::ElideNone)
- text = fm.elidedText(header->text, header->textElideMode, rect.width());
- else
- text = header->text;
+ QString text = header->text;
+ if (const QStyleOptionHeaderV2 *headerV2 = qstyleoption_cast<const QStyleOptionHeaderV2 *>(header)) {
+ if (headerV2->textElideMode != Qt::ElideNone)
+ text = fm.elidedText(header->text, headerV2->textElideMode, rect.width());
+ }
proxy()->drawItemText(p, rect, header->textAlignment, header->palette,
header->state.testFlag(State_Enabled), text, QPalette::ButtonText);
}
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index d2eb5e25cc..5772c7d4c4 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -1280,10 +1280,12 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
painter->save();
// Draws the header in tables.
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
+ const QStyleOptionHeaderV2 *headerV2 = qstyleoption_cast<const QStyleOptionHeaderV2 *>(option);
QString pixmapName = QStyleHelper::uniqueName(QLatin1String("headersection"), option, option->rect.size());
pixmapName += QString::number(- int(header->position));
pixmapName += QString::number(- int(header->orientation));
- pixmapName += QString::number(- int(header->isSectionDragTarget));
+ if (headerV2)
+ pixmapName += QString::number(- int(headerV2->isSectionDragTarget));
QPixmap cache;
if (!QPixmapCache::find(pixmapName, &cache)) {
@@ -1294,7 +1296,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
QColor buttonColor = d->buttonColor(option->palette);
QColor gradientStartColor = buttonColor.lighter(104);
QColor gradientStopColor = buttonColor.darker(102);
- if (header->isSectionDragTarget) {
+ if (headerV2 && headerV2->isSectionDragTarget) {
gradientStopColor = gradientStartColor.darker(130);
gradientStartColor = gradientStartColor.darker(130);
}
diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index 933603dd7e..33071b0724 100644
--- a/src/widgets/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
@@ -748,11 +748,33 @@ QStyleOptionHeader::QStyleOptionHeader(int version)
section(0), textAlignment(Qt::AlignLeft), iconAlignment(Qt::AlignLeft),
position(QStyleOptionHeader::Beginning),
selectedPosition(QStyleOptionHeader::NotAdjacent), sortIndicator(None),
- orientation(Qt::Horizontal), textElideMode(Qt::ElideNone), isSectionDragTarget(false), unused(0)
+ orientation(Qt::Horizontal)
{
}
/*!
+ \class QStyleOptionHeaderV2
+ \brief The QStyleOptionHeaderV2 class is used to describe the
+ parameters for drawing a header.
+*/
+
+/*!
+ Constructs a QStyleOptionHeaderV2, initializing the members
+ variables to their default values.
+*/
+QStyleOptionHeaderV2::QStyleOptionHeaderV2()
+ : QStyleOptionHeaderV2(QStyleOptionHeader::Version)
+{
+}
+
+/*!
+ \internal
+*/
+QStyleOptionHeaderV2::QStyleOptionHeaderV2(int version)
+: QStyleOptionHeader(version), textElideMode(Qt::ElideNone), isSectionDragTarget(false), unused(0)
+{}
+
+/*!
\variable QStyleOptionHeader::orientation
\brief the header's orientation (horizontal or vertical)
@@ -892,7 +914,7 @@ QStyleOptionHeader::QStyleOptionHeader(int version)
*/
/*!
- \variable QStyleOptionHeader::textElideMode
+ \variable QStyleOptionHeaderV2::textElideMode
\brief where ellipsis should be added for text that is too long to fit
into an item
diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h
index 677a04c04b..0f41211521 100644
--- a/src/widgets/styles/qstyleoption.h
+++ b/src/widgets/styles/qstyleoption.h
@@ -219,10 +219,7 @@ public:
SectionPosition position;
SelectedPosition selectedPosition;
SortIndicator sortIndicator;
- Qt::Orientation orientation:2;
- Qt::TextElideMode textElideMode:2;
- bool isSectionDragTarget:1;
- int unused:27;
+ Qt::Orientation orientation;
QStyleOptionHeader();
QStyleOptionHeader(const QStyleOptionHeader &other) : QStyleOption(Version, Type) { *this = other; }
@@ -232,6 +229,24 @@ protected:
QStyleOptionHeader(int version);
};
+class Q_WIDGETS_EXPORT QStyleOptionHeaderV2 : public QStyleOptionHeader
+{
+public:
+ enum StyleOptionType { Type = SO_Header };
+ enum StyleOptionVersion { Version = 2 };
+
+ QStyleOptionHeaderV2();
+ QStyleOptionHeaderV2(const QStyleOptionHeaderV2 &other) : QStyleOptionHeader(Version) { *this = other; }
+ QStyleOptionHeaderV2 &operator=(const QStyleOptionHeaderV2 &) = default;
+
+ Qt::TextElideMode textElideMode:2;
+ bool isSectionDragTarget:1;
+ int unused:29;
+
+protected:
+ QStyleOptionHeaderV2(int version);
+};
+
class Q_WIDGETS_EXPORT QStyleOptionButton : public QStyleOption
{
public: