forked from blue/squawk
rookie shaky messages history request in progress animation
This commit is contained in:
parent
c295fa1c1d
commit
e32c1177c3
@ -202,21 +202,23 @@ void Conversation::onSliderValueChanged(int value)
|
|||||||
scroll = down;
|
scroll = down;
|
||||||
} else {
|
} else {
|
||||||
if (!requestingHistory && value == 0) {
|
if (!requestingHistory && value == 0) {
|
||||||
m_ui->historyStatus->setPixmap(Shared::icon("view-refresh", true).pixmap(25));
|
|
||||||
requestingHistory = true;
|
requestingHistory = true;
|
||||||
|
line->showBusyIndicator();
|
||||||
emit requestArchive(line->firstMessageId());
|
emit requestArchive(line->firstMessageId());
|
||||||
}
|
scroll = keep;
|
||||||
|
} else {
|
||||||
scroll = nothing;
|
scroll = nothing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Conversation::responseArchive(const std::list<Shared::Message> list)
|
void Conversation::responseArchive(const std::list<Shared::Message> list)
|
||||||
{
|
{
|
||||||
requestingHistory = false;
|
requestingHistory = false;
|
||||||
scroll = keep;
|
scroll = keep;
|
||||||
|
|
||||||
m_ui->historyStatus->clear();
|
line->hideBusyIndicator();
|
||||||
for (std::list<Shared::Message>::const_iterator itr = list.begin(), end = list.end(); itr != end; ++itr) {
|
for (std::list<Shared::Message>::const_iterator itr = list.begin(), end = list.end(); itr != end; ++itr) {
|
||||||
addMessage(*itr);
|
addMessage(*itr);
|
||||||
}
|
}
|
||||||
@ -226,8 +228,9 @@ void Conversation::showEvent(QShowEvent* event)
|
|||||||
{
|
{
|
||||||
if (!everShown) {
|
if (!everShown) {
|
||||||
everShown = true;
|
everShown = true;
|
||||||
m_ui->historyStatus->setPixmap(Shared::icon("view-refresh", true).pixmap(25));
|
line->showBusyIndicator();
|
||||||
requestingHistory = true;
|
requestingHistory = true;
|
||||||
|
scroll = keep;
|
||||||
emit requestArchive(line->firstMessageId());
|
emit requestArchive(line->firstMessageId());
|
||||||
}
|
}
|
||||||
emit shown();
|
emit shown();
|
||||||
|
@ -31,11 +31,27 @@ MessageLine::MessageLine(bool p_room, QWidget* parent):
|
|||||||
myName(),
|
myName(),
|
||||||
palNames(),
|
palNames(),
|
||||||
views(),
|
views(),
|
||||||
room(p_room)
|
room(p_room),
|
||||||
|
busyLabel(),
|
||||||
|
busyLayout(),
|
||||||
|
busyShown(false),
|
||||||
|
rotation()
|
||||||
{
|
{
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
setBackgroundRole(QPalette::Base);
|
setBackgroundRole(QPalette::Base);
|
||||||
layout->addStretch();
|
layout->addStretch();
|
||||||
|
|
||||||
|
busyLabel.setPixmap(Shared::icon("view-refresh", true).pixmap(50));
|
||||||
|
busyLayout.addStretch();
|
||||||
|
busyLayout.addWidget(&busyLabel);
|
||||||
|
busyLayout.addStretch();
|
||||||
|
|
||||||
|
busyLabel.hide();
|
||||||
|
rotation.setDuration(500);
|
||||||
|
rotation.setStartValue(0.0f);
|
||||||
|
rotation.setEndValue(180.0f);
|
||||||
|
rotation.setLoopCount(-1);
|
||||||
|
connect(&rotation, SIGNAL(valueChanged(const QVariant&)), this, SLOT(onAnimationValueChanged(const QVariant&)));
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageLine::~MessageLine()
|
MessageLine::~MessageLine()
|
||||||
@ -72,6 +88,10 @@ MessageLine::Position MessageLine::message(const Shared::Message& msg)
|
|||||||
res = middle;
|
res = middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (busyShown) {
|
||||||
|
index += 1;
|
||||||
|
}
|
||||||
|
|
||||||
QVBoxLayout* vBox = new QVBoxLayout();
|
QVBoxLayout* vBox = new QVBoxLayout();
|
||||||
QHBoxLayout* hBox = new QHBoxLayout();
|
QHBoxLayout* hBox = new QHBoxLayout();
|
||||||
QWidget* message = new QWidget();
|
QWidget* message = new QWidget();
|
||||||
@ -184,3 +204,34 @@ QString MessageLine::firstMessageId() const
|
|||||||
return messageOrder.begin()->second->getId();
|
return messageOrder.begin()->second->getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageLine::showBusyIndicator()
|
||||||
|
{
|
||||||
|
if (!busyShown) {
|
||||||
|
layout->insertLayout(0, &busyLayout);
|
||||||
|
busyShown = true;
|
||||||
|
rotation.start();
|
||||||
|
busyLabel.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageLine::hideBusyIndicator()
|
||||||
|
{
|
||||||
|
if (busyShown) {
|
||||||
|
busyLabel.hide();
|
||||||
|
rotation.stop();
|
||||||
|
layout->removeItem(&busyLayout);
|
||||||
|
busyShown = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageLine::onAnimationValueChanged(const QVariant& value)
|
||||||
|
{
|
||||||
|
QTransform r;
|
||||||
|
r.rotate(value.toReal());
|
||||||
|
QPixmap pxm = Shared::icon("view-refresh", true).pixmap(50).transformed(r, Qt::SmoothTransformation);
|
||||||
|
int dw = pxm.width() - 50;
|
||||||
|
int dh = pxm.height() - 50;
|
||||||
|
pxm = pxm.copy(dw/2, dh/2, 50, 50);
|
||||||
|
busyLabel.setPixmap(pxm);
|
||||||
|
}
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
|
#include <QIcon>
|
||||||
|
#include <QVariantAnimation>
|
||||||
#include "../global.h"
|
#include "../global.h"
|
||||||
|
|
||||||
class MessageLine : public QWidget
|
class MessageLine : public QWidget
|
||||||
@ -71,6 +73,13 @@ private:
|
|||||||
std::map<QString, QString> palNames;
|
std::map<QString, QString> palNames;
|
||||||
std::deque<QHBoxLayout*> views;
|
std::deque<QHBoxLayout*> views;
|
||||||
bool room;
|
bool room;
|
||||||
|
QLabel busyLabel;
|
||||||
|
QHBoxLayout busyLayout;
|
||||||
|
bool busyShown;
|
||||||
|
QVariantAnimation rotation;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onAnimationValueChanged(const QVariant& value);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESSAGELINE_H
|
#endif // MESSAGELINE_H
|
||||||
|
Loading…
Reference in New Issue
Block a user