diff options
author | Jens Bache-Wiig <jbache@trolltech.com> | 2010-05-07 12:26:01 +0200 |
---|---|---|
committer | Jens Bache-Wiig <jbache@trolltech.com> | 2010-05-07 12:33:48 +0200 |
commit | 344b4b38879b6373ab7ca8394c7273fa0f36096f (patch) | |
tree | 22a0ca136e5dab1ef6d67b709e7513e5784ef793 /src/libs/utils/detailsbutton.cpp | |
parent | 66b970413129ef756872f489bde47995b57ff903 (diff) | |
download | qt-creator-344b4b38879b6373ab7ca8394c7273fa0f36096f.tar.gz |
Make the toolboxes in Projects Mode nicer
I did a couple of changes to make these more subtle.
- Moved inside the details widget
- Made them fade in and out
- Hide up/down buttons when not required
Note, there are some pending changes to Qt to disable
the graphicsevent cache that can cause issues when
scrolling items.
Reviewed-by: thorbjorn
Diffstat (limited to 'src/libs/utils/detailsbutton.cpp')
-rw-r--r-- | src/libs/utils/detailsbutton.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/libs/utils/detailsbutton.cpp b/src/libs/utils/detailsbutton.cpp index cd038d09f9..d255f9245c 100644 --- a/src/libs/utils/detailsbutton.cpp +++ b/src/libs/utils/detailsbutton.cpp @@ -38,10 +38,34 @@ using namespace Utils; +FadingPanel::FadingPanel(QWidget *parent) : QWidget(parent), m_opacityEffect(0) + +{ + m_opacityEffect = new QGraphicsOpacityEffect; + m_opacityEffect->setOpacity(0); + setGraphicsEffect(m_opacityEffect); + + // Workaround for issue with QGraphicsEffect. GraphicsEffect + // currently clears with Window color. Remove if flickering + // no longer occurs on fade-in + QPalette pal; + pal.setBrush(QPalette::All, QPalette::Window, Qt::transparent); + setPalette(pal); +} + +void FadingPanel::fadeTo(float value) +{ + QPropertyAnimation *animation = new QPropertyAnimation(m_opacityEffect, "opacity"); + animation->setDuration(200); + animation->setEndValue(value); + animation->start(QAbstractAnimation::DeleteWhenStopped); +} + DetailsButton::DetailsButton(QWidget *parent) : QAbstractButton(parent), m_fader(0) { setCheckable(true); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + setText(tr("Details")); } QSize DetailsButton::sizeHint() const @@ -114,7 +138,6 @@ QPixmap DetailsButton::cacheRendering(const QSize &size, bool checked) p.setRenderHint(QPainter::Antialiasing, true); p.translate(0.5, 0.5); p.setPen(Qt::NoPen); - QColor color = palette().highlight().color(); if(!checked) { lg.setColorAt(0, QColor(0, 0, 0, 10)); lg.setColorAt(1, QColor(0, 0, 0, 16)); @@ -133,12 +156,11 @@ QPixmap DetailsButton::cacheRendering(const QSize &size, bool checked) p.setPen(palette().color(QPalette::Text)); - QString text = tr("Details"); - QRect textRect = p.fontMetrics().boundingRect(text); + QRect textRect = p.fontMetrics().boundingRect(text()); textRect.setWidth(textRect.width() + 15); textRect.moveCenter(rect().center()); - p.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, text); + p.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, text()); int arrowsize = 15; QStyleOption arrowOpt; |