Vidalia 0.2.15
BandwidthGraph.h
Go to the documentation of this file.
00001 /*
00002 **  This file is part of Vidalia, and is subject to the license terms in the
00003 **  LICENSE file, found in the top level directory of this distribution. If you
00004 **  did not receive the LICENSE file with this file, you may obtain it from the
00005 **  Vidalia source package distributed by the Vidalia Project at
00006 **  http://www.torproject.org/projects/vidalia.html. No part of Vidalia, 
00007 **  including this file, may be copied, modified, propagated, or distributed 
00008 **  except according to the terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file BandwidthGraph.h
00013 ** \brief Displays a graph of Tor's bandwidth usage
00014 */
00015 
00016 #ifndef _BWGRAPH_H
00017 #define _BWGRAPH_H
00018 
00019 #include "ui_BandwidthGraph.h"
00020 #include "VidaliaWindow.h"
00021 #include "VidaliaSettings.h"
00022 #include "TorControl.h"
00023 
00024 #include <QDateTime>
00025 #include <QEvent>
00026 
00027 /** Redraw graph every 1000ms **/
00028 #define REFRESH_RATE    1000
00029 
00030 
00031 class BandwidthGraph : public VidaliaWindow
00032 {
00033   Q_OBJECT
00034 
00035 public:
00036   /** Default constructor */
00037   BandwidthGraph(QWidget *parent = 0, Qt::WFlags flags = 0);
00038 
00039 public slots:
00040   /** Overloaded QWidget.show */
00041   void showWindow();
00042 
00043 protected:
00044   /** Called when the user changes the UI translation. */
00045   virtual void retranslateUi();
00046 
00047 private slots:
00048   /** Adds new data to the graph */
00049   void updateGraph(quint64 bytesRead, quint64 bytesWritten);
00050   /** Called when settings button is toggled */
00051   void showSettingsFrame(bool show);
00052   /** Called when the settings button is toggled */
00053   void setOpacity(int value);
00054   /** Called when the user saves settings */
00055   void saveChanges();
00056   /** Called when the user cancels changes settings */
00057   void cancelChanges();
00058   /** Called when the reset button is pressed */
00059   void reset();
00060   
00061 private:
00062   /** Create and bind actions to events **/
00063   void createActions();
00064   /** Loads the saved Bandwidth Graph settings */
00065   void loadSettings();
00066 
00067   /** A TorControl object used to talk to Tor. */
00068   TorControl* _torControl;
00069   /** A VidaliaSettings object that handles getting/saving settings */
00070   VidaliaSettings* _settings;
00071   
00072   /** Qt Designer generated object */
00073   Ui::BandwidthGraph ui;
00074 };
00075 
00076 #endif
00077