diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-03-30 11:33:45 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-03-30 13:47:35 (GMT) |
commit | e20d18f1982dde2b0fa9bd262e5aadd1e451a7fa (patch) | |
tree | dff54c6720e57718626946437047591c52b0e377 /src/gui/widgets | |
parent | efbbb0ea53dfb8350f3f9b46dd5dc934051cedc7 (diff) | |
download | Qt-e20d18f1982dde2b0fa9bd262e5aadd1e451a7fa.zip Qt-e20d18f1982dde2b0fa9bd262e5aadd1e451a7fa.tar.gz Qt-e20d18f1982dde2b0fa9bd262e5aadd1e451a7fa.tar.bz2 |
Allow styling of pressed splitter
Task-number: 206494
Reviewed-by: Jens Bache-Wiig
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/qsplitter.cpp | 12 | ||||
-rw-r--r-- | src/gui/widgets/qsplitter_p.h | 9 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/gui/widgets/qsplitter.cpp b/src/gui/widgets/qsplitter.cpp index bf8af35..06774bc 100644 --- a/src/gui/widgets/qsplitter.cpp +++ b/src/gui/widgets/qsplitter.cpp @@ -119,7 +119,6 @@ QSplitterHandle::QSplitterHandle(Qt::Orientation orientation, QSplitter *parent) { Q_D(QSplitterHandle); d->s = parent; - d->hover = false; setOrientation(orientation); } @@ -269,8 +268,11 @@ void QSplitterHandle::mouseMoveEvent(QMouseEvent *e) void QSplitterHandle::mousePressEvent(QMouseEvent *e) { Q_D(QSplitterHandle); - if (e->button() == Qt::LeftButton) + if (e->button() == Qt::LeftButton) { d->mouseOffset = d->pick(e->pos()); + d->pressed = true; + update(); + } } /*! @@ -285,6 +287,10 @@ void QSplitterHandle::mouseReleaseEvent(QMouseEvent *e) d->s->setRubberBand(-1); moveSplitter(pos); } + if (e->button() == Qt::LeftButton) { + d->pressed = false; + update(); + } } /*! @@ -303,6 +309,8 @@ void QSplitterHandle::paintEvent(QPaintEvent *) opt.state = QStyle::State_None; if (d->hover) opt.state |= QStyle::State_MouseOver; + if (d->pressed) + opt.state |= QStyle::State_Sunken; if (isEnabled()) opt.state |= QStyle::State_Enabled; parentWidget()->style()->drawControl(QStyle::CE_Splitter, &opt, &p, d->s); diff --git a/src/gui/widgets/qsplitter_p.h b/src/gui/widgets/qsplitter_p.h index 5cc43af..9f6fe0c 100644 --- a/src/gui/widgets/qsplitter_p.h +++ b/src/gui/widgets/qsplitter_p.h @@ -131,16 +131,17 @@ class QSplitterHandlePrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QSplitterHandle) public: - QSplitterHandlePrivate() : orient(Qt::Horizontal), opaq(false), s(0), mouseOffset(0) {} + QSplitterHandlePrivate() : s(0), orient(Qt::Horizontal), mouseOffset(0), opaq(false), hover(false), pressed(false) {} inline int pick(const QPoint &pos) const { return orient == Qt::Horizontal ? pos.x() : pos.y(); } - Qt::Orientation orient; - bool opaq; QSplitter *s; - bool hover; + Qt::Orientation orient; int mouseOffset; + bool opaq : 1; + bool hover : 1; + bool pressed : 1; }; QT_END_NAMESPACE |