Commit 281ff844 authored by kenneth@webkit.org's avatar kenneth@webkit.org

[Qt] Show progress reaching 100% for loads.

Reviewed by Ariya Hidayat.

* QtLauncher/locationedit.cpp:
(LocationEdit::LocationEdit):
(LocationEdit::setProgress):
(LocationEdit::reset):
(LocationEdit::paintEvent):
* QtLauncher/locationedit.h:

git-svn-id: svn://svn.chromium.org/blink/trunk@54072 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c1eb43d7
2010-01-29 Kenneth Rohde Christiansen <kenneth@webkit.org>
Reviewed by Ariya Hidayat.
[Qt] Show progress reaching 100% for loads.
* QtLauncher/locationedit.cpp:
(LocationEdit::LocationEdit):
(LocationEdit::setProgress):
(LocationEdit::reset):
(LocationEdit::paintEvent):
* QtLauncher/locationedit.h:
2010-01-29 Andreas Kling <andreas.kling@nokia.com>
Reviewed by Kenneth Rohde Christiansen.
......
......@@ -28,33 +28,45 @@
#include "locationedit.h"
LocationEdit::LocationEdit(QWidget* parent)
: QLineEdit(parent),
m_progress(0)
: QLineEdit(parent)
, m_progress(0)
{
m_clearTimer.setSingleShot(true);
connect(&m_clearTimer, SIGNAL(timeout()), this, SLOT(reset()));
}
void LocationEdit::setProgress(int progress)
{
m_clearTimer.stop();
m_progress = progress;
update();
}
void LocationEdit::reset()
{
setProgress(0);
}
void LocationEdit::paintEvent(QPaintEvent* ev)
{
QColor backgroundColor = QApplication::palette().color(QPalette::Base);
QColor progressColor = QColor(120, 180, 240);
QPalette p = palette();
if (!m_progress || m_progress == 100)
if (!m_progress)
p.setBrush(QPalette::Base, backgroundColor);
else {
QLinearGradient gradient(0, 0, width(), 0);
gradient.setColorAt(0, progressColor);
gradient.setColorAt(((double)m_progress) / 100, progressColor);
gradient.setColorAt(((double)m_progress) / 100 + 0.001, backgroundColor);
gradient.setColorAt(((double) m_progress) / 100, progressColor);
if (m_progress != 100)
gradient.setColorAt((double) m_progress / 100 + 0.001, backgroundColor);
p.setBrush(QPalette::Base, gradient);
}
setPalette(p);
QLineEdit::paintEvent(ev);
if (m_progress == 100)
m_clearTimer.start(100);
}
......@@ -39,11 +39,15 @@ public:
public slots:
void setProgress(int progress);
private slots:
void reset();
protected:
void paintEvent(QPaintEvent*);
virtual void paintEvent(QPaintEvent*);
private:
int m_progress;
QTimer m_clearTimer;
};
#endif
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