29 #include <QGraphicsOpacityEffect>
30 #include <QGuiApplication>
31 #include <QPaintEvent>
33 #include <QPropertyAnimation>
34 #include <QStyleOption>
36 using namespace Utils;
39 const bool FlatProjectsMode(
false);
40 const QColor DetailsButtonBackgroundColorHover(
"#eff0f1");
44 :
FadingPanel(parent), m_opacityEffect(new QGraphicsOpacityEffect)
53 pal.setBrush(QPalette::All, QPalette::Window, Qt::transparent);
64 QPropertyAnimation* animation =
new QPropertyAnimation(
m_opacityEffect,
"opacity");
65 animation->setDuration(200);
66 animation->setEndValue(value);
67 animation->start(QAbstractAnimation::DeleteWhenStopped);
78 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
79 setText(tr(
"Details"));
86 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
87 const int w = fontMetrics().horizontalAdvance(text()) + 32;
89 const int w = fontMetrics().width(text()) + 32;
100 QPropertyAnimation* animation =
new QPropertyAnimation(
this,
"fader");
101 animation->setDuration(200);
102 animation->setEndValue(1.0);
103 animation->start(QAbstractAnimation::DeleteWhenStopped);
105 case QEvent::Leave: {
106 QPropertyAnimation* animation =
new QPropertyAnimation(
this,
"fader");
107 animation->setDuration(200);
108 animation->setEndValue(0.0);
109 animation->start(QAbstractAnimation::DeleteWhenStopped);
112 return QAbstractButton::event(e);
119 QWidget::paintEvent(e);
125 QColor c = DetailsButtonBackgroundColorHover;
126 c.setAlpha(
int(
m_fader * c.alpha()));
129 if (!FlatProjectsMode)
130 r.adjust(1, 1, -2, -2);
142 != contentsRect().size())
148 p.setBrush(QColor(0, 0, 0, 20));
149 p.drawRoundedRect(rect().adjusted(1, 1, -1, -1), 1, 1);
152 QStyleOptionFocusRect option;
153 option.initFrom(
this);
154 style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &p,
this);
160 const qreal pixelRatio = devicePixelRatio();
161 QPixmap pixmap(size * pixelRatio);
162 pixmap.setDevicePixelRatio(pixelRatio);
163 pixmap.fill(Qt::transparent);
165 p.setRenderHint(QPainter::Antialiasing,
true);
166 p.translate(0.5, 0.5);
168 if (!FlatProjectsMode) {
170 lg.setCoordinateMode(QGradient::ObjectBoundingMode);
171 lg.setFinalStop(0, 1);
173 lg.setColorAt(0, QColor(0, 0, 0, 10));
174 lg.setColorAt(1, QColor(0, 0, 0, 16));
176 lg.setColorAt(0, QColor(255, 255, 255, 0));
177 lg.setColorAt(1, QColor(255, 255, 255, 50));
180 p.setPen(QColor(255, 255, 255, 140));
181 p.drawRoundedRect(1, 1, size.width() - 3, size.height() - 3, 1, 1);
182 p.setPen(QPen(QColor(0, 0, 0, 40)));
183 p.drawLine(0, 1, 0, size.height() - 2);
185 p.drawLine(1, size.height() - 1, size.width() - 1, size.height() - 1);
188 p.drawRoundedRect(0, 0, size.width(), size.height(), 1, 1);
191 p.setPen(palette().color(QPalette::Text));
193 QRect textRect = p.fontMetrics().boundingRect(text());
194 textRect.setWidth(textRect.width() + 15);
195 textRect.setHeight(textRect.height() + 4);
196 textRect.moveCenter(rect().center());
198 p.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, text());
201 QStyleOption arrowOpt;
202 arrowOpt.initFrom(
this);
203 QPalette pal = arrowOpt.palette;
204 pal.setBrush(QPalette::All, QPalette::Text, QColor(0, 0, 0));
206 QRect(size.width() - arrowsize - 6, height() / 2 - arrowsize / 2, arrowsize, arrowsize);
207 arrowOpt.palette = pal;
208 style()->drawPrimitive(checked ? QStyle::PE_IndicatorArrowUp : QStyle::PE_IndicatorArrowDown,
209 &arrowOpt, &p,
this);