[kde-doc-english] [trojita] src/Gui: GUI: show a spinner when waiting for message source
Jan Kundrát
jkt at flaska.net
Thu Sep 5 12:14:54 UTC 2013
Git commit cd9797cc6be556514764ae8bdae46cb327f6aac4 by Jan Kundrát.
Committed on 04/09/2013 at 08:52.
Pushed by jkt into branch 'master'.
GUI: show a spinner when waiting for message source
M +10 -1 src/Gui/MessageSourceWidget.cpp
M +3 -1 src/Gui/MessageSourceWidget.h
http://commits.kde.org/trojita/cd9797cc6be556514764ae8bdae46cb327f6aac4
diff --git a/src/Gui/MessageSourceWidget.cpp b/src/Gui/MessageSourceWidget.cpp
index 51bf47a..23650b3 100644
--- a/src/Gui/MessageSourceWidget.cpp
+++ b/src/Gui/MessageSourceWidget.cpp
@@ -22,16 +22,23 @@
#include "MessageSourceWidget.h"
#include <QModelIndex>
+#include "Gui/Spinner.h"
#include "Imap/Model/FullMessageCombiner.h"
namespace Gui
{
MessageSourceWidget::MessageSourceWidget(QWidget *parent, const QModelIndex &messageIndex):
- QWebView(parent)
+ QWebView(parent), m_combiner(0), m_loadingSpinner(0)
{
Q_ASSERT(messageIndex.isValid());
page()->setNetworkAccessManager(0);
+
+ m_loadingSpinner = new Spinner(this);
+ m_loadingSpinner->setText(tr("Fetching\nMessage"));
+ m_loadingSpinner->setType(Spinner::Sun);
+ m_loadingSpinner->start(250);
+
m_combiner = new Imap::Mailbox::FullMessageCombiner(messageIndex, this);
connect(m_combiner, SIGNAL(completed()), this, SLOT(slotCompleted()));
connect(m_combiner, SIGNAL(failed(QString)), this, SLOT(slotError(QString)));
@@ -40,11 +47,13 @@ MessageSourceWidget::MessageSourceWidget(QWidget *parent, const QModelIndex &mes
void MessageSourceWidget::slotCompleted()
{
+ m_loadingSpinner->stop();
setContent(m_combiner->data(), QLatin1String("text/plain"));
}
void MessageSourceWidget::slotError(const QString &message)
{
+ m_loadingSpinner->stop();
setContent(message.toUtf8(), QLatin1String("text/plain; charset=utf-8"));
}
diff --git a/src/Gui/MessageSourceWidget.h b/src/Gui/MessageSourceWidget.h
index 7f2cbf7..f619440 100644
--- a/src/Gui/MessageSourceWidget.h
+++ b/src/Gui/MessageSourceWidget.h
@@ -38,6 +38,8 @@ namespace Mailbox
namespace Gui
{
+class Spinner;
+
class MessageSourceWidget : public QWebView
{
Q_OBJECT
@@ -50,7 +52,7 @@ private slots:
private:
Imap::Mailbox::FullMessageCombiner *m_combiner;
-
+ Spinner *m_loadingSpinner;
};
}
More information about the kde-doc-english
mailing list