Commit 3f1be148 authored by mae's avatar mae
Browse files

a bit more scaling for the action bar.

parent 8f358494
......@@ -77,27 +77,47 @@ FancyToolButton::FancyToolButton(QWidget *parent)
, m_buttonElements(buttonElementsMap())
{
setAttribute(Qt::WA_Hover, true);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
}
void FancyToolButton::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter p(this);
QSize sh(sizeHint());
double scale = (double)height() / sh.height();
if (scale < 1) {
p.save();
p.scale(1, scale);
}
p.drawPicture(0, 0, m_buttonElements.value(svgIdButtonBase));
p.drawPicture(0, 0, m_buttonElements.value(isDown() ? svgIdButtonPressedBase : svgIdButtonNormalBase));
#ifndef Q_WS_MAC // Mac UIs usually don't hover
if (underMouse() && isEnabled())
p.drawPicture(0, 0, m_buttonElements.value(svgIdButtonHoverOverlay));
#endif
if (scale < 1)
p.restore();
if (!icon().isNull()) {
icon().paint(&p, rect());
} else {
const int margin = 4;
p.drawText(rect().adjusted(margin, margin, -margin, -margin), Qt::AlignCenter | Qt::TextWordWrap, text());
}
if (scale < 1) {
p.scale(1, scale);
}
if (!isEnabled())
if (isEnabled()) {
p.drawPicture(0, 0, m_buttonElements.value(isDown() ?
svgIdButtonPressedOverlay : svgIdButtonNormalOverlay));
} else {
p.drawPicture(0, 0, m_buttonElements.value(svgIdButtonDisabledOverlay));
p.drawPicture(0, 0, m_buttonElements.value(isDown() ? svgIdButtonPressedOverlay : svgIdButtonNormalOverlay));
}
}
void FancyActionBar::paintEvent(QPaintEvent *event)
......@@ -110,6 +130,11 @@ QSize FancyToolButton::sizeHint() const
return m_buttonElements.value(svgIdButtonBase).boundingRect().size();
}
QSize FancyToolButton::minimumSizeHint() const
{
return QSize(8, 8);
}
FancyActionBar::FancyActionBar(QWidget *parent)
: QWidget(parent)
{
......
......@@ -48,6 +48,7 @@ public:
void paintEvent(QPaintEvent *event);
QSize sizeHint() const;
QSize minimumSizeHint() const;
private:
const QMap<QString, QPicture> &m_buttonElements;
......
......@@ -305,12 +305,12 @@ FancyTabWidget::FancyTabWidget(QWidget *parent)
bar->setFixedHeight(StyleHelper::navigationWidgetHeight());
selectionLayout->addWidget(bar);
selectionLayout->addWidget(m_tabBar);
selectionLayout->addWidget(m_tabBar, 1);
m_selectionWidget->setLayout(selectionLayout);
m_selectionWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
m_cornerWidgetContainer = new QWidget(this);
m_cornerWidgetContainer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
m_cornerWidgetContainer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
m_cornerWidgetContainer->setAutoFillBackground(false);
QVBoxLayout *cornerWidgetLayout = new QVBoxLayout;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment