forked from qt-creator/qt-creator
Updated hover and pressed appearance for sidebar
This commit is contained in:
@@ -58,13 +58,6 @@ FancyToolButton::FancyToolButton(QWidget *parent)
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
}
|
||||
|
||||
void FancySeparator::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
QPainter painter(this);
|
||||
painter.fillRect(rect(), Qt::red);
|
||||
}
|
||||
|
||||
bool FancyToolButton::event(QEvent *e)
|
||||
{
|
||||
switch(e->type()) {
|
||||
@@ -99,41 +92,37 @@ void FancyToolButton::paintEvent(QPaintEvent *event)
|
||||
bool isTitledAction = defaultAction()->property("titledAction").toBool();
|
||||
|
||||
#ifndef Q_WS_MAC // Mac UIs usually don't hover
|
||||
if (m_fader > 0 && isEnabled() && !isDown()) {
|
||||
if (m_fader > 0 && isEnabled() && !isDown() && !isChecked()) {
|
||||
painter.save();
|
||||
QColor whiteOverlay(Qt::white);
|
||||
whiteOverlay.setAlpha(int(10 * m_fader));
|
||||
QRect roundRect = rect().adjusted(5, 3, -5, -3);
|
||||
painter.translate(0.5, 0.5);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setBrush(whiteOverlay);
|
||||
whiteOverlay.setAlpha(int(20*m_fader));
|
||||
painter.setPen(whiteOverlay);
|
||||
painter.drawRoundedRect(roundRect, 3, 3);
|
||||
int fader = int(40 * m_fader);
|
||||
QLinearGradient grad(rect().topLeft(), rect().topRight());
|
||||
grad.setColorAt(0, Qt::transparent);
|
||||
grad.setColorAt(0.5, QColor(255, 255, 255, fader));
|
||||
grad.setColorAt(1, Qt::transparent);
|
||||
painter.fillRect(rect(), grad);
|
||||
painter.setPen(QPen(grad, 1.0));
|
||||
painter.drawLine(rect().topLeft(), rect().topRight());
|
||||
painter.drawLine(rect().bottomLeft(), rect().bottomRight());
|
||||
painter.restore();
|
||||
}
|
||||
#endif
|
||||
|
||||
} else
|
||||
#endif
|
||||
if (isDown() || isChecked()) {
|
||||
painter.save();
|
||||
QColor color(Qt::black);
|
||||
color.setAlpha(15);
|
||||
QRect roundRect = rect().adjusted(5, 3, -5, -3);
|
||||
painter.translate(0.5, 0.5);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setPen(QColor(255, 255, 255, 20));
|
||||
static int rounding = 3;
|
||||
painter.drawRoundedRect(roundRect.adjusted(-1, -1, 1, 1), rounding, rounding);
|
||||
painter.setPen(QColor(0, 0, 0, 20));
|
||||
painter.setBrush(QColor(0, 0, 0, 15));
|
||||
painter.drawRoundedRect(roundRect.adjusted(1, 1, 0, 0), rounding, rounding);
|
||||
color.setAlpha(75);
|
||||
painter.setPen(color);
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
painter.drawRoundedRect(roundRect, 3, 3);
|
||||
QLinearGradient grad(rect().topLeft(), rect().topRight());
|
||||
grad.setColorAt(0, Qt::transparent);
|
||||
grad.setColorAt(0.5, QColor(0, 0, 0, 50));
|
||||
grad.setColorAt(1, Qt::transparent);
|
||||
painter.fillRect(rect(), grad);
|
||||
painter.setPen(QPen(grad, 1.0));
|
||||
painter.drawLine(rect().topLeft(), rect().topRight());
|
||||
painter.drawLine(rect().topLeft(), rect().topRight());
|
||||
painter.drawLine(rect().topLeft() + QPoint(0,1), rect().topRight() + QPoint(0,1));
|
||||
painter.drawLine(rect().bottomLeft(), rect().bottomRight());
|
||||
painter.drawLine(rect().bottomLeft(), rect().bottomRight());
|
||||
painter.drawLine(rect().topLeft() - QPoint(0,1), rect().topRight() - QPoint(0,1));
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
QPixmap borderPixmap;
|
||||
QMargins margins;
|
||||
|
||||
@@ -192,6 +181,7 @@ void FancyToolButton::paintEvent(QPaintEvent *event)
|
||||
opt.rect = rect().adjusted(rect().width() - 18, 0, -10, 0);
|
||||
Utils::StyleHelper::drawArrow(QStyle::PE_IndicatorArrowRight, &painter, &opt);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FancyActionBar::paintEvent(QPaintEvent *event)
|
||||
|
||||
@@ -63,22 +63,6 @@ private slots:
|
||||
void actionChanged();
|
||||
};
|
||||
|
||||
class FancySeparator: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FancySeparator(QWidget *parent = 0) :
|
||||
QWidget(parent)
|
||||
{
|
||||
setMinimumHeight(2);
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
}
|
||||
void paintEvent(QPaintEvent *event);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class FancyActionBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -57,7 +57,7 @@ void FancyTab::fadeIn()
|
||||
{
|
||||
QPropertyAnimation *animation;
|
||||
animation = new QPropertyAnimation(this, "fader");
|
||||
animation->setDuration(90);
|
||||
animation->setDuration(70);
|
||||
animation->setEndValue(50);
|
||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ void FancyTab::fadeOut()
|
||||
{
|
||||
QPropertyAnimation *animation;
|
||||
animation = new QPropertyAnimation(this, "fader");
|
||||
animation->setDuration(185);
|
||||
animation->setDuration(200);
|
||||
animation->setEndValue(0);
|
||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
@@ -275,26 +275,6 @@ void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
|
||||
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||
painter->setPen(QColor(255, 255, 255, 50));
|
||||
painter->drawLine(rect.bottomLeft() + QPoint(0,1), rect.bottomRight() + QPoint(0,1));
|
||||
} else {
|
||||
if (enabled) {
|
||||
painter->save();
|
||||
QColor whiteOverlay(Qt::white);
|
||||
whiteOverlay.setAlpha(int(m_tabs[tabIndex]->fader()/2));
|
||||
painter->fillRect(rect, whiteOverlay);
|
||||
painter->setPen(whiteOverlay);
|
||||
painter->drawLine(rect.topLeft(), rect.topRight());
|
||||
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||
|
||||
/* QRect roundRect = rect.adjusted(5, 3, -5, -3);
|
||||
painter->translate(0.5, 0.5);
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
painter->setBrush(whiteOverlay);
|
||||
whiteOverlay.setAlpha(int(m_tabs[tabIndex]->fader()));
|
||||
painter->setPen(whiteOverlay);
|
||||
painter->drawRoundedRect(roundRect, 3, 3);
|
||||
*/
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
|
||||
QString tabText(this->tabText(tabIndex));
|
||||
@@ -314,12 +294,27 @@ void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
|
||||
painter->setPen(selected ? Utils::StyleHelper::panelTextColor() : QColor(255, 255, 255, 120));
|
||||
}
|
||||
|
||||
if (!selected && enabled) {
|
||||
painter->save();
|
||||
int fader = int(m_tabs[tabIndex]->fader());
|
||||
QLinearGradient grad(rect.topLeft(), rect.topRight());
|
||||
grad.setColorAt(0, Qt::transparent);
|
||||
grad.setColorAt(0.5, QColor(255, 255, 255, fader));
|
||||
grad.setColorAt(1, Qt::transparent);
|
||||
painter->fillRect(rect, grad);
|
||||
painter->setPen(QPen(grad, 1.0));
|
||||
painter->drawLine(rect.topLeft(), rect.topRight());
|
||||
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
|
||||
tabIconRect.adjust(0, 4, 0, -textHeight);
|
||||
int iconSize = qMin(tabIconRect.width(), tabIconRect.height());
|
||||
if (iconSize > 4)
|
||||
style()->drawItemPixmap(painter, tabIconRect, Qt::AlignCenter | Qt::AlignVCenter,
|
||||
tabIcon(tabIndex).pixmap(tabIconRect.size(), enabled ? QIcon::Normal : QIcon::Disabled));
|
||||
|
||||
painter->translate(0, -1);
|
||||
painter->drawText(tabTextRect, textFlags, tabText);
|
||||
painter->restore();
|
||||
|
||||
Reference in New Issue
Block a user