ui: added loader animation gif to StatusBar
The loader animation can be activated by setting the showLoader flag on MessageStatus.
This commit is contained in:
@@ -1,8 +1,22 @@
|
||||
#include "qt/element/QtStatusBar.h"
|
||||
|
||||
#include <QMovie>
|
||||
|
||||
QtStatusBar::QtStatusBar()
|
||||
: m_text(this)
|
||||
{
|
||||
QMovie* movie = new QMovie("data/gui/statusbar_view/loader.gif");
|
||||
// if movie doesn't loop forever, force it to.
|
||||
if (movie->loopCount() != -1)
|
||||
{
|
||||
connect(movie, SIGNAL(finished()), movie, SLOT(start()));
|
||||
}
|
||||
movie->start();
|
||||
|
||||
m_loader.setMovie(movie);
|
||||
m_loader.hide();
|
||||
addWidget(&m_loader);
|
||||
|
||||
m_text.setText("");
|
||||
addWidget(&m_text);
|
||||
}
|
||||
@@ -11,7 +25,7 @@ QtStatusBar::~QtStatusBar()
|
||||
{
|
||||
}
|
||||
|
||||
void QtStatusBar::setText(const std::string& text, bool isError)
|
||||
void QtStatusBar::setText(const std::string& text, bool isError, bool showLoader)
|
||||
{
|
||||
if (isError)
|
||||
{
|
||||
@@ -22,5 +36,14 @@ void QtStatusBar::setText(const std::string& text, bool isError)
|
||||
m_text.setStyleSheet("");
|
||||
}
|
||||
|
||||
if (showLoader)
|
||||
{
|
||||
m_loader.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_loader.hide();
|
||||
}
|
||||
|
||||
m_text.setText(text.c_str());
|
||||
}
|
||||
|
||||
@@ -3,18 +3,20 @@
|
||||
|
||||
#include <string>
|
||||
#include <QStatusBar>
|
||||
#include <QProgressBar>
|
||||
#include <QLabel>
|
||||
|
||||
class QtStatusBar : public QStatusBar
|
||||
class QtStatusBar
|
||||
: public QStatusBar
|
||||
{
|
||||
public:
|
||||
QtStatusBar(void);
|
||||
~QtStatusBar(void);
|
||||
|
||||
void setText(const std::string& text, bool isError = false);
|
||||
void setText(const std::string& text, bool isError, bool showLoader);
|
||||
|
||||
private:
|
||||
QLabel m_text;
|
||||
QLabel m_loader;
|
||||
};
|
||||
|
||||
#endif // QT_STATUS_BAR_H
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
QtStatusBarView::QtStatusBarView(ViewLayout* viewLayout)
|
||||
: StatusBarView(viewLayout)
|
||||
, m_showMessageFunctor(std::bind(&QtStatusBarView::doShowMessage, this, std::placeholders::_1, std::placeholders::_2))
|
||||
, m_showMessageFunctor(std::bind(
|
||||
&QtStatusBarView::doShowMessage, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3))
|
||||
{
|
||||
QtMainView* mw = static_cast<QtMainView*>(viewLayout);
|
||||
m_widget = std::make_shared<QtStatusBar>();
|
||||
@@ -21,7 +22,6 @@ QtStatusBarView::~QtStatusBarView()
|
||||
|
||||
void QtStatusBarView::createWidgetWrapper()
|
||||
{
|
||||
//setWidgetWrapper(std::make_shared<QtViewWidgetWrapper>(m_widget));
|
||||
}
|
||||
|
||||
void QtStatusBarView::initView()
|
||||
@@ -32,12 +32,12 @@ void QtStatusBarView::refreshView()
|
||||
{
|
||||
}
|
||||
|
||||
void QtStatusBarView::doShowMessage(const std::string& message, bool isError)
|
||||
void QtStatusBarView::doShowMessage(const std::string& message, bool isError, bool showLoader)
|
||||
{
|
||||
m_widget->setText(message, isError);
|
||||
m_widget->setText(message, isError, showLoader);
|
||||
}
|
||||
|
||||
void QtStatusBarView::showMessage(const std::string& message, bool isError)
|
||||
void QtStatusBarView::showMessage(const std::string& message, bool isError, bool showLoader)
|
||||
{
|
||||
m_showMessageFunctor(message, isError);
|
||||
m_showMessageFunctor(message, isError, showLoader);
|
||||
}
|
||||
|
||||
@@ -20,12 +20,13 @@ public:
|
||||
virtual void refreshView();
|
||||
|
||||
// StatusBar view implementation
|
||||
virtual void showMessage(const std::string& message, bool isError);
|
||||
virtual void showMessage(const std::string& message, bool isError, bool showLoader);
|
||||
|
||||
private:
|
||||
void doShowMessage(const std::string& message, bool isError);
|
||||
void doShowMessage(const std::string& message, bool isError, bool showLoader);
|
||||
std::shared_ptr<QtStatusBar> m_widget;
|
||||
|
||||
QtThreadedFunctor<const std::string&, bool> m_showMessageFunctor;
|
||||
QtThreadedFunctor<const std::string&, bool, bool> m_showMessageFunctor;
|
||||
};
|
||||
|
||||
#endif // !QT_STATUS_BAR_VIEW_H
|
||||
|
||||
Reference in New Issue
Block a user