Mercurial > hg > easaier-soundaccess
view widgets/ConnectionStatus.cpp @ 282:d9319859a4cf tip
(none)
author | benoitrigolleau |
---|---|
date | Fri, 31 Oct 2008 11:00:24 +0000 |
parents | c7965aaaedfd |
children |
line wrap: on
line source
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ /* Sound Access EASAIER client application. Silogic 2007. Laure Bajard. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the file COPYING included with this distribution for more information. */ #include "ConnectionStatus.h" #include <QAction> #include <QHBoxLayout> ConnectionStatus::ConnectionStatus(HttpClient *httpClient, const QString & title, QWidget * parent) : QToolBar(title, parent), m_httpClient(httpClient), m_iconStatus(0), m_actionStatus(0) { m_iconConnected = new QIcon(":/icons/connected.png"); m_iconNotConnected = new QIcon(":/icons/notconnected.png"); setIcon(m_httpClient->state()); m_actionStatus = addAction(*m_iconStatus, tr("Connection state")); m_downloadProgress.setMaximum(100); m_downloadProgress.setMinimum(0); addWidget(&m_downloadProgress); connect(m_httpClient, SIGNAL(stateChanged(int)), this, SLOT(setIcon(int))); connect(m_httpClient, SIGNAL(dataReadProgress( int, int)), this, SLOT(updateProgressBar(int, int))); } ConnectionStatus::~ConnectionStatus() {} void ConnectionStatus::setIcon(int state) { switch (state) { case QHttp::Unconnected : case QHttp::Closing : { m_iconStatus = m_iconNotConnected; m_downloadProgress.hide(); break; } case QHttp::HostLookup : case QHttp::Connecting : case QHttp::Sending : case QHttp::Connected : { m_iconStatus = m_iconConnected; m_downloadProgress.hide(); break; } case QHttp::Reading : { m_iconStatus = m_iconConnected; m_downloadProgress.setVisible(true); } default: break; } if (m_actionStatus) m_actionStatus->setIcon(*m_iconStatus); } void ConnectionStatus::updateProgressBar(int done, int total) { m_downloadProgress.setValue(((double)done/total)*100); }