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