Changeset 74

Show
Ignore:
Timestamp:
01/12/06 18:37:22 (3 years ago)
Author:
edmanm
Message:

Create an instance of TorControl? as a member of MainWindow? and then pass a
pointer to that instance to each child dialog (that needs access to Tor) in
its constructor.

Location:
trunk/src/gui
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/about.cpp

    r73 r74  
    2424#include "about.h" 
    2525 
    26 AboutDialog::AboutDialog(QWidget *parent) 
     26AboutDialog::AboutDialog(TorControl *torControl, QWidget *parent) 
    2727: QDialog(parent) 
    2828{ 
     
    3232  ui.lblVidaliaVersion->setText(VidaliaSettings::getVersion()); 
    3333 
    34 /* FIXME Need access to global TorControl object to retrieve version */ 
    35 /* 
    36   QString* errmsg; 
    37   QString torVersion = TorControl::getTorVersion(errmsg); 
    38   if (errmsg) { 
    39     ui.lblTorVersion->setText("Unknown"); 
    40   } else { 
    41     ui.lblTorVersion->setText(torVersion); 
    42   } 
    43 */ 
     34  /* Access the TorControl object to retrieve version */ 
     35  ui.lblTorVersion->setText(torControl->getTorVersion()); 
    4436 
    4537  /* Get Qt's version number */ 
    4638  ui.lblQtVersion->setText(QT_VERSION_STR); 
    4739} 
     40 
  • trunk/src/gui/about.h

    r73 r74  
    2727#include "ui_aboutdialog.h" 
    2828#include "../config/vidaliasettings.h" 
    29 // #include "../control/torcontrol.h" 
     29#include "../control/torcontrol.h" 
    3030 
    3131class AboutDialog : public QDialog 
     
    3434 
    3535public: 
    36     AboutDialog(QWidget *parent = 0); 
     36    AboutDialog(TorControl *torControl, QWidget *parent = 0); 
    3737 
    3838private: 
  • trunk/src/gui/mainwindow.cpp

    r73 r74  
    3333  createActions(); 
    3434  createMenus(); 
     35  
     36  /* Create a new TorControl object, used to communicate with and manipulate Tor */ 
     37  _torControl = new TorControl(); 
    3538   
    3639  /* Put an icon in the system tray to indicate the status of Tor */ 
     
    3841                           tr("Tor is Started"), _trayMenu, this); 
    3942  _trayIcon->show(); 
     43} 
     44 
     45MainWindow::~MainWindow() 
     46{ 
     47  if (_torControl) { 
     48    delete _torControl; 
     49  } 
    4050} 
    4151 
     
    131141void MainWindow::about() 
    132142{ 
    133   AboutDialog* aboutDialog = new AboutDialog(this); 
     143  AboutDialog* aboutDialog = new AboutDialog(_torControl, this); 
    134144  aboutDialog->show(); 
    135145} 
     146 
  • trunk/src/gui/mainwindow.h

    r68 r74  
    2727#include <QMainWindow> 
    2828 
     29#include "../control/torcontrol.h" 
     30 
    2931#include "tray/trayicon.h" 
    3032#include "about.h" 
     
    3638public: 
    3739  MainWindow(); 
    38  
     40  ~MainWindow(); 
     41   
    3942private slots: 
    4043  void start(); 
     
    4649  void createActions(); 
    4750 
     51  TorControl* _torControl; 
     52   
    4853  TrayIcon* _trayIcon; 
    4954