diff options
author | Rohan Garg <rohan@kde.org> | 2013-08-08 10:45:22 +0530 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-20 20:09:20 +0200 |
commit | e2322c885f6dd67834c5110c6b7e2b63ea8b6186 (patch) | |
tree | f3d42b0f3060dbdf7b30f3acd44c39dc5a89332b /src/widgets/widgets | |
parent | 692bee634e9add44ae38fe2e4dd140319687facd (diff) |
Extend QStyle API with a SH_Splitter_OpaqueResize styleHint
Currently the default for QSplitter::opaqueResize is hard coded,
which is less than ideal. Instead this should be provided as a
style hint via QStyle so as to give a more uniform look to all
applications.
Change-Id: I5711811f7b672e36aafcd292ed320308570a0390
Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qsplitter.cpp | 19 | ||||
-rw-r--r-- | src/widgets/widgets/qsplitter_p.h | 3 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index 031763b80c..1f3646ea6e 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -1404,19 +1404,24 @@ int QSplitter::closestLegalPosition(int pos, int index) \property QSplitter::opaqueResize \brief whether resizing is opaque - Opaque resizing is on by default. + The default resize behavior is style dependent (determined by the + SH_Splitter_OpaqueResize style hint). However, you can override it + by calling setOpaqueResize() + + \sa QStyle::StyleHint */ bool QSplitter::opaqueResize() const { Q_D(const QSplitter); - return d->opaque; + return d->opaqueResizeSet ? d->opaque : style()->styleHint(QStyle::SH_Splitter_OpaqueResize, 0, this); } void QSplitter::setOpaqueResize(bool on) { Q_D(QSplitter); + d->opaqueResizeSet = true; d->opaque = on; } @@ -1589,7 +1594,7 @@ static const qint32 SplitterMagic = 0xff; QByteArray QSplitter::saveState() const { Q_D(const QSplitter); - int version = 0; + int version = 1; QByteArray data; QDataStream stream(&data, QIODevice::WriteOnly); @@ -1605,6 +1610,7 @@ QByteArray QSplitter::saveState() const stream << qint32(handleWidth()); stream << opaqueResize(); stream << qint32(orientation()); + stream << d->opaqueResizeSet; return data; } @@ -1627,7 +1633,7 @@ QByteArray QSplitter::saveState() const bool QSplitter::restoreState(const QByteArray &state) { Q_D(QSplitter); - int version = 0; + int version = 1; QByteArray sd = state; QDataStream stream(&sd, QIODevice::ReadOnly); QList<int> list; @@ -1638,7 +1644,7 @@ bool QSplitter::restoreState(const QByteArray &state) stream >> marker; stream >> v; - if (marker != SplitterMagic || v != version) + if (marker != SplitterMagic || v > version) return false; stream >> list; @@ -1657,6 +1663,9 @@ bool QSplitter::restoreState(const QByteArray &state) setOrientation(Qt::Orientation(i)); d->doResize(); + if (v >= 1) + stream >> d->opaqueResizeSet; + return true; } diff --git a/src/widgets/widgets/qsplitter_p.h b/src/widgets/widgets/qsplitter_p.h index f1e050b8f6..0d0e134f58 100644 --- a/src/widgets/widgets/qsplitter_p.h +++ b/src/widgets/widgets/qsplitter_p.h @@ -83,7 +83,7 @@ class QSplitterPrivate : public QFramePrivate Q_DECLARE_PUBLIC(QSplitter) public: QSplitterPrivate() : rubberBand(0), opaque(true), firstShow(true), - childrenCollapsible(true), compatMode(false), handleWidth(-1), blockChildAdd(false) {} + childrenCollapsible(true), compatMode(false), handleWidth(-1), blockChildAdd(false), opaqueResizeSet(false) {} QPointer<QRubberBand> rubberBand; mutable QList<QSplitterLayoutStruct *> list; @@ -94,6 +94,7 @@ public: bool compatMode : 8; int handleWidth; bool blockChildAdd; + bool opaqueResizeSet; inline int pick(const QPoint &pos) const { return orient == Qt::Horizontal ? pos.x() : pos.y(); } |