appearancepage.cpp

Go to the documentation of this file.
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 appearancepage.cpp
00024  * \version $Id: appearancepage.cpp 530 2006-03-30 19:09:35Z hipplej $
00025  * \brief Displays Vidalia language and style settings
00026  */
00027 
00028 #include <vidalia.h>
00029 #include "appearancepage.h"
00030 
00031 
00032 /** Default Constructor */
00033 AppearancePage::AppearancePage(QWidget *parent)
00034 : ConfigPage(parent)
00035 {
00036   /* Invoke Designer-generated object setup routine */
00037   ui.setupUi(this);
00038 
00039   /* Create VidaliaSettings object */
00040   _settings = new VidaliaSettings();
00041 
00042   /* Populate combo boxes */
00043   foreach (QString code, LanguageSupport::languageCodes()) {
00044     ui.cmboLanguage->addItem(QIcon(":/images/flags/" + code + ".png"),
00045                              LanguageSupport::languageName(code),
00046                              code);
00047   }
00048   foreach (QString style, QStyleFactory::keys()) {
00049     ui.cmboStyle->addItem(style, style.toLower());
00050   }
00051 }
00052 
00053 /** Destructor */
00054 AppearancePage::~AppearancePage()
00055 {
00056   delete _settings;
00057 }
00058 
00059 /** Saves the changes on this page */
00060 bool
00061 AppearancePage::save(QString &errmsg)
00062 {
00063   Q_UNUSED(errmsg);
00064   QString languageCode =
00065     LanguageSupport::languageCode(ui.cmboLanguage->currentText());
00066   
00067   _settings->setLanguageCode(languageCode);
00068   _settings->setInterfaceStyle(ui.cmboStyle->currentText());
00069  
00070   /* Set to new style */
00071   Vidalia::setStyle(ui.cmboStyle->currentText());
00072   return true;
00073 }
00074   
00075 /** Loads the settings for this page */
00076 void
00077 AppearancePage::load()
00078 {
00079   int index = ui.cmboLanguage->findData(_settings->getLanguageCode());
00080   ui.cmboLanguage->setCurrentIndex(index);
00081   
00082   index = ui.cmboStyle->findData(Vidalia::style().toLower());
00083   ui.cmboStyle->setCurrentIndex(index);
00084 }
00085 

Generated on Mon Oct 23 20:08:15 2006 for Vidalia by  doxygen 1.5.0