Skip to content
Snippets Groups Projects
Commit 6e8bc0cf authored by Jens Bache-Wiig's avatar Jens Bache-Wiig
Browse files

Fixes: Improved sidebar looks and layout

Details:
-Centered all the text labels.
-Added shadow on title text.
-Made progressbar go all the way and placed the button on top.
-Added some spacing between warning and error icons.
-Improved cosmetics on progress bar itself.
parent fda09bbc
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,7 @@ ProgressBar::ProgressBar(QWidget *parent) ...@@ -40,6 +40,7 @@ ProgressBar::ProgressBar(QWidget *parent)
: QProgressBar(parent), m_error(false) : QProgressBar(parent), m_error(false)
{ {
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
setMouseTracking(true);
} }
ProgressBar::~ProgressBar() ProgressBar::~ProgressBar()
...@@ -88,6 +89,11 @@ void ProgressBar::mousePressEvent(QMouseEvent *event) ...@@ -88,6 +89,11 @@ void ProgressBar::mousePressEvent(QMouseEvent *event)
QProgressBar::mousePressEvent(event); QProgressBar::mousePressEvent(event);
} }
void ProgressBar::mouseMoveEvent(QMouseEvent *)
{
update();
}
void ProgressBar::paintEvent(QPaintEvent *) void ProgressBar::paintEvent(QPaintEvent *)
{ {
// TODO move font into stylehelper // TODO move font into stylehelper
...@@ -117,13 +123,20 @@ void ProgressBar::paintEvent(QPaintEvent *) ...@@ -117,13 +123,20 @@ void ProgressBar::paintEvent(QPaintEvent *)
p.setPen(QColor(255, 255, 255, 70)); p.setPen(QColor(255, 255, 255, 70));
p.drawLine(0, 1, size().width(), 1); p.drawLine(0, 1, size().width(), 1);
QRect textRect = rect();
textRect.setHeight(h+5);
p.setPen(QColor(30, 30, 30, 80));
p.drawText(textRect, Qt::AlignHCenter | Qt::AlignBottom, m_title);
p.translate(0, -1);
p.setPen(StyleHelper::panelTextColor()); p.setPen(StyleHelper::panelTextColor());
p.drawText(QPoint(7, h+1), m_title); p.drawText(textRect, Qt::AlignHCenter | Qt::AlignBottom, m_title);
p.translate(0, 1);
m_progressHeight = h-4; m_progressHeight = h-4;
m_progressHeight += ((m_progressHeight % 2) + 1) % 2; // make odd m_progressHeight += ((m_progressHeight % 2) + 1) % 2; // make odd
// draw outer rect // draw outer rect
QRect rect(INDENT, h+6, size().width()-2*INDENT-m_progressHeight+1, m_progressHeight-1); QRect rect(INDENT - 1, h+6, size().width()-2*INDENT, m_progressHeight-1);
p.setPen(StyleHelper::panelTextColor()); p.setPen(StyleHelper::panelTextColor());
p.drawRect(rect); p.drawRect(rect);
...@@ -131,7 +144,7 @@ void ProgressBar::paintEvent(QPaintEvent *) ...@@ -131,7 +144,7 @@ void ProgressBar::paintEvent(QPaintEvent *)
QColor c = StyleHelper::panelTextColor(); QColor c = StyleHelper::panelTextColor();
c.setAlpha(180); c.setAlpha(180);
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
p.setBrush(c);
QRect inner = rect.adjusted(2, 2, -1, -1); QRect inner = rect.adjusted(2, 2, -1, -1);
inner.adjust(0, 0, qRound((percent - 1) * inner.width()), 0); inner.adjust(0, 0, qRound((percent - 1) * inner.width()), 0);
if (m_error) { if (m_error) {
...@@ -142,19 +155,34 @@ void ProgressBar::paintEvent(QPaintEvent *) ...@@ -142,19 +155,34 @@ void ProgressBar::paintEvent(QPaintEvent *)
if (inner.width() < 10) if (inner.width() < 10)
inner.adjust(0, 0, 10 - inner.width(), 0); inner.adjust(0, 0, 10 - inner.width(), 0);
} else if (value() == maximum()) { } else if (value() == maximum()) {
QColor green(140, 255, 140, 180); c = QColor(120, 245, 90, 180);
p.setBrush(green);
} }
QLinearGradient grad(inner.topLeft(), inner.bottomLeft());
grad.setColorAt(0, c.lighter(114));
grad.setColorAt(0.5, c.lighter(104));
grad.setColorAt(0.51, c.darker(108));
grad.setColorAt(1, c.darker(120));
p.setBrush(grad);
p.drawRect(inner); p.drawRect(inner);
if (value() < maximum() && !m_error) { if (value() < maximum() && !m_error) {
// draw cancel thingy QColor cancelOutline = StyleHelper::panelTextColor();
// TODO this is quite ugly at the moment p.setPen(cancelOutline);
p.setPen(StyleHelper::panelTextColor()); QRect cancelRect(rect.right() - m_progressHeight + 2, rect.top(), m_progressHeight-1, rect.height());
p.setBrush(QBrush(Qt::NoBrush)); if (cancelRect.contains(mapFromGlobal(QCursor::pos())))
QRect cancelRect(size().width()-INDENT-m_progressHeight+3, h+6+1, m_progressHeight-3, m_progressHeight-3); p.setBrush(QColor(230, 90, 40, 190));
else
p.setBrush(Qt::NoBrush);
p.drawRect(cancelRect); p.drawRect(cancelRect);
p.setPen(c);
p.setPen(QPen(QColor(0, 0, 0, 70), 3));
p.drawLine(cancelRect.center()+QPoint(-1,-1), cancelRect.center()+QPoint(+3,+3));
p.drawLine(cancelRect.center()+QPoint(+3,-1), cancelRect.center()+QPoint(-1,+3));
p.setPen(StyleHelper::panelTextColor());
p.drawLine(cancelRect.center()+QPoint(-1,-1), cancelRect.center()+QPoint(+3,+3)); p.drawLine(cancelRect.center()+QPoint(-1,-1), cancelRect.center()+QPoint(+3,+3));
p.drawLine(cancelRect.center()+QPoint(+3,-1), cancelRect.center()+QPoint(-1,+3)); p.drawLine(cancelRect.center()+QPoint(+3,-1), cancelRect.center()+QPoint(-1,+3));
} }
......
...@@ -49,6 +49,7 @@ public: ...@@ -49,6 +49,7 @@ public:
bool hasError() const; bool hasError() const;
QSize sizeHint() const; QSize sizeHint() const;
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *);
void mouseMoveEvent(QMouseEvent *);
signals: signals:
void clicked(); void clicked();
......
...@@ -46,8 +46,8 @@ BuildProgress::BuildProgress(TaskWindow *taskWindow) ...@@ -46,8 +46,8 @@ BuildProgress::BuildProgress(TaskWindow *taskWindow)
m_taskWindow(taskWindow) m_taskWindow(taskWindow)
{ {
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(0); layout->setContentsMargins(8, 2, 0, 2);
layout->setSpacing(0); layout->setSpacing(2);
setLayout(layout); setLayout(layout);
QHBoxLayout *errorLayout = new QHBoxLayout; QHBoxLayout *errorLayout = new QHBoxLayout;
errorLayout->setSpacing(4); errorLayout->setSpacing(4);
......
...@@ -124,6 +124,7 @@ void BaseFileFind::searchFinished() ...@@ -124,6 +124,7 @@ void BaseFileFind::searchFinished()
QWidget *BaseFileFind::createProgressWidget() QWidget *BaseFileFind::createProgressWidget()
{ {
m_resultLabel = new QLabel; m_resultLabel = new QLabel;
m_resultLabel->setAlignment(Qt::AlignCenter);
// ### TODO this setup should be done by style // ### TODO this setup should be done by style
QFont f = m_resultLabel->font(); QFont f = m_resultLabel->font();
f.setBold(true); f.setBold(true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment