# HG changeset patch # User lbajardsilogic # Date 1179155663 0 # Node ID c7965aaaedfdd0a371b593bd7411c88ddd6d7f0c # Parent 56561ff50d2ea784946c7b2252d5053db1c5fe9d add connectionStatus toolbar diff -r 56561ff50d2e -r c7965aaaedfd widgets/ConnectionStatus.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgets/ConnectionStatus.cpp Mon May 14 15:14:23 2007 +0000 @@ -0,0 +1,86 @@ +/* -*- 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 +#include + +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); +} \ No newline at end of file diff -r 56561ff50d2e -r c7965aaaedfd widgets/ConnectionStatus.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgets/ConnectionStatus.h Mon May 14 15:14:23 2007 +0000 @@ -0,0 +1,47 @@ +/* -*- 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. +*/ + +#ifndef _CONNECTION_STATUS_H_ +#define _CONNECTION_STATUS_H_ + +#include +#include + +#include "data/fileio/HttpClient.h" + +class ConnectionStatus : public QToolBar //public QMenu //public QWidget +{ + Q_OBJECT + +public: + ConnectionStatus(HttpClient *httpClient, const QString & title, QWidget * parent = 0); + virtual ~ConnectionStatus(); + +private slots: + void setIcon(int state); + void updateProgressBar(int done, int total); + +private: + + HttpClient *m_httpClient; + + QIcon *m_iconStatus; + QAction *m_actionStatus; + + QIcon *m_iconConnected; + QIcon *m_iconNotConnected; + + QProgressBar m_downloadProgress; +}; + +#endif \ No newline at end of file diff -r 56561ff50d2e -r c7965aaaedfd widgets/svwidgets.vcproj --- a/widgets/svwidgets.vcproj Mon May 14 15:13:03 2007 +0000 +++ b/widgets/svwidgets.vcproj Mon May 14 15:14:23 2007 +0000 @@ -186,6 +186,10 @@ > + + @@ -372,6 +376,32 @@ + + + + + + + + + + diff -r 56561ff50d2e -r c7965aaaedfd widgets/widgets.pro --- a/widgets/widgets.pro Mon May 14 15:13:03 2007 +0000 +++ b/widgets/widgets.pro Mon May 14 15:14:23 2007 +0000 @@ -41,7 +41,8 @@ QueryResultsWidget.h \ SearchWidget.h \ WidgetGallery.h \ - ConnectionSettings.h + ConnectionSettings.h \ + ConnectionStatus.h SOURCES += AudioDial.cpp \ Fader.cpp \ ItemEditDialog.cpp \ @@ -69,4 +70,5 @@ QueryResultsWidget.cpp \ SearchWidget.cpp \ WidgetGallery.cpp \ - ConnectionSettings.cpp + ConnectionSettings.cpp \ + ConnectionStatus.cpp