appearancepage.cpp

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.vidalia-project.net/. No part of Vidalia, including this file,
00007 **  may be copied, modified, propagated, or distributed except according to the
00008 **  terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file appearancepage.cpp
00013 ** \version $Id: appearancepage.cpp 2362 2008-02-29 04:30:11Z edmanm $
00014 ** \brief Displays Vidalia language and style settings
00015 */
00016 
00017 #include <vidalia.h>
00018 #include "appearancepage.h"
00019 
00020 
00021 /** Default Constructor */
00022 AppearancePage::AppearancePage(QWidget *parent)
00023 : ConfigPage(parent, tr("Appearance"))
00024 {
00025   /* Invoke Designer-generated object setup routine */
00026   ui.setupUi(this);
00027 
00028   /* Create VidaliaSettings object */
00029   _settings = new VidaliaSettings();
00030 
00031   /* Populate combo boxes */
00032   foreach (QString code, LanguageSupport::languageCodes()) {
00033     ui.cmboLanguage->addItem(LanguageSupport::languageName(code),
00034                              code);
00035   }
00036   foreach (QString style, QStyleFactory::keys()) {
00037     ui.cmboStyle->addItem(style, style.toLower());
00038   }
00039 }
00040 
00041 /** Destructor */
00042 AppearancePage::~AppearancePage()
00043 {
00044   delete _settings;
00045 }
00046 
00047 /** Saves the changes on this page */
00048 bool
00049 AppearancePage::save(QString &errmsg)
00050 {
00051   Q_UNUSED(errmsg);
00052   QString languageCode =
00053     LanguageSupport::languageCode(ui.cmboLanguage->currentText());
00054   
00055   _settings->setLanguageCode(languageCode);
00056   _settings->setInterfaceStyle(ui.cmboStyle->currentText());
00057  
00058   /* Set to new style */
00059   Vidalia::setStyle(ui.cmboStyle->currentText());
00060   return true;
00061 }
00062   
00063 /** Loads the settings for this page */
00064 void
00065 AppearancePage::load()
00066 {
00067   int index = ui.cmboLanguage->findData(_settings->getLanguageCode());
00068   ui.cmboLanguage->setCurrentIndex(index);
00069   
00070   index = ui.cmboStyle->findData(Vidalia::style().toLower());
00071   ui.cmboStyle->setCurrentIndex(index);
00072 }
00073 

Generated on Wed Nov 26 21:03:57 2008 for Vidalia by  doxygen 1.5.6