00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file generalpage.cpp 00024 * \version $Id: generalpage.cpp 1563 2006-12-26 06:06:04Z edmanm $ 00025 * \brief General Tor and Vidalia configuration options 00026 */ 00027 00028 #include "generalpage.h" 00029 00030 /** Constructor */ 00031 GeneralPage::GeneralPage(QWidget *parent) 00032 : ConfigPage(parent) 00033 { 00034 /* Invoke the Qt Designer generated object setup routine */ 00035 ui.setupUi(this); 00036 00037 /* Create settings objects */ 00038 _vidaliaSettings = new VidaliaSettings; 00039 _torSettings = new TorSettings; 00040 00041 /* Bind event to actions */ 00042 connect(ui.btnBrowseTorExecutable, SIGNAL(clicked()), 00043 this, SLOT(browseTorPath())); 00044 00045 /* Hide platform specific features */ 00046 #ifndef Q_WS_WIN 00047 ui.chkRunWithSys->setVisible(false); 00048 #endif 00049 } 00050 00051 /** Destructor */ 00052 GeneralPage::~GeneralPage() 00053 { 00054 delete _vidaliaSettings; 00055 delete _torSettings; 00056 } 00057 00058 /* Open a QFileDialog to browse for Tor executable */ 00059 void 00060 GeneralPage::browseTorPath() 00061 { 00062 #if defined(Q_OS_WIN32) 00063 QString filter = tr("Executables (*.exe)"); 00064 #else 00065 QString filter = ""; 00066 #endif 00067 00068 /* Prompt the user for an executable file. If we're on windows, filter for 00069 * only .exe files. */ 00070 QString filename = QDir::convertSeparators( 00071 QFileDialog::getOpenFileName(this, 00072 tr("Select Path to Tor"), 00073 ui.lineTorExecutable->text(), 00074 filter)); 00075 if (!filename.isEmpty()) { 00076 ui.lineTorExecutable->setText(filename); 00077 } 00078 } 00079 00080 /* Saves all settings for this page */ 00081 bool 00082 GeneralPage::save(QString &errmsg) 00083 { 00084 Q_UNUSED(errmsg); 00085 _torSettings->setExecutable(ui.lineTorExecutable->text()); 00086 _vidaliaSettings->setRunTorAtStart(ui.chkRunTor->isChecked()); 00087 _vidaliaSettings->setRunVidaliaOnBoot(ui.chkRunWithSys->isChecked()); 00088 return true; 00089 } 00090 00091 /* Loads previously saved settings */ 00092 void 00093 GeneralPage::load() 00094 { 00095 ui.lineTorExecutable->setText(_torSettings->getExecutable()); 00096 ui.chkRunTor->setChecked(_vidaliaSettings->runTorAtStart()); 00097 ui.chkRunWithSys->setChecked(_vidaliaSettings->runVidaliaOnBoot()); 00098 } 00099