2009-07-23 13:11:51 -04:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 - 2009 RetroShare Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2009-08-19 18:15:16 -04:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2009-07-23 13:11:51 -04:00
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
2010-07-23 14:52:58 -04:00
|
|
|
#include <QStyleFactory>
|
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QDir>
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-07-23 14:52:58 -04:00
|
|
|
#include "lang/languagesupport.h"
|
2009-07-23 13:11:51 -04:00
|
|
|
#include <rshare.h>
|
|
|
|
#include "AppearancePage.h"
|
2010-05-11 16:02:52 -04:00
|
|
|
#include "rsharesettings.h"
|
2009-07-23 13:11:51 -04:00
|
|
|
|
|
|
|
/** Constructor */
|
2013-10-18 17:10:33 -04:00
|
|
|
AppearancePage::AppearancePage(QWidget * parent, Qt::WindowFlags flags)
|
2012-08-24 19:35:57 -04:00
|
|
|
: ConfigPage(parent, flags)
|
2009-07-23 13:11:51 -04:00
|
|
|
{
|
2012-08-24 19:35:57 -04:00
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
ui.setupUi(this);
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2012-08-24 19:35:57 -04:00
|
|
|
connect(ui.styleSheetCombo, SIGNAL(activated(int)), this, SLOT(loadStyleSheet(int)));
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2012-08-24 19:35:57 -04:00
|
|
|
/* Populate combo boxes */
|
|
|
|
foreach (QString code, LanguageSupport::languageCodes()) {
|
|
|
|
ui.cmboLanguage->addItem(QIcon(":/images/flags/" + code + ".png"), LanguageSupport::languageName(code), code);
|
|
|
|
}
|
|
|
|
foreach (QString style, QStyleFactory::keys()) {
|
|
|
|
ui.cmboStyle->addItem(style, style.toLower());
|
|
|
|
}
|
2009-08-19 18:15:16 -04:00
|
|
|
|
2012-08-24 19:35:57 -04:00
|
|
|
// add empty entry representing "no style sheet"
|
|
|
|
ui.styleSheetCombo->addItem("", "");
|
2009-08-19 18:15:16 -04:00
|
|
|
|
2012-08-24 19:35:57 -04:00
|
|
|
QMap<QString, QString> styleSheets;
|
|
|
|
Rshare::getAvailableStyleSheets(styleSheets);
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2012-08-24 19:35:57 -04:00
|
|
|
foreach (QString name, styleSheets.keys()) {
|
|
|
|
ui.styleSheetCombo->addItem(name, styleSheets[name]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Hide platform specific features */
|
|
|
|
#ifdef Q_WS_WIN
|
2009-07-23 13:11:51 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Saves the changes on this page */
|
2012-08-24 19:35:57 -04:00
|
|
|
bool AppearancePage::save(QString &errmsg)
|
2009-07-23 13:11:51 -04:00
|
|
|
{
|
2012-08-24 19:35:57 -04:00
|
|
|
Q_UNUSED(errmsg);
|
2009-08-19 18:15:16 -04:00
|
|
|
|
2012-08-24 19:35:57 -04:00
|
|
|
QString languageCode = LanguageSupport::languageCode(ui.cmboLanguage->currentText());
|
2009-08-19 18:15:16 -04:00
|
|
|
|
2012-08-24 19:35:57 -04:00
|
|
|
Settings->setLanguageCode(languageCode);
|
|
|
|
Settings->setInterfaceStyle(ui.cmboStyle->currentText());
|
|
|
|
Settings->setSheetName(ui.styleSheetCombo->itemData(ui.styleSheetCombo->currentIndex()).toString());
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2012-08-24 19:35:57 -04:00
|
|
|
/* Set to new style */
|
|
|
|
Rshare::setStyle(ui.cmboStyle->currentText());
|
2009-08-19 18:15:16 -04:00
|
|
|
|
2012-08-24 19:35:57 -04:00
|
|
|
return true;
|
2009-07-23 13:11:51 -04:00
|
|
|
}
|
|
|
|
|
2012-08-24 19:35:57 -04:00
|
|
|
/** Loads the settings for this page */
|
|
|
|
void AppearancePage::load()
|
2009-07-23 13:11:51 -04:00
|
|
|
{
|
2012-08-24 19:35:57 -04:00
|
|
|
int index = ui.cmboLanguage->findData(Settings->getLanguageCode());
|
|
|
|
ui.cmboLanguage->setCurrentIndex(index);
|
|
|
|
|
|
|
|
index = ui.cmboStyle->findData(Rshare::style().toLower());
|
|
|
|
ui.cmboStyle->setCurrentIndex(index);
|
|
|
|
|
|
|
|
index = ui.styleSheetCombo->findData(Settings->getSheetName());
|
|
|
|
if (index == -1) {
|
|
|
|
/* set standard "no style sheet" */
|
|
|
|
index = ui.styleSheetCombo->findData("");
|
|
|
|
}
|
|
|
|
ui.styleSheetCombo->setCurrentIndex(index);
|
2009-07-23 13:11:51 -04:00
|
|
|
}
|
|
|
|
|
2012-08-24 19:35:57 -04:00
|
|
|
void AppearancePage::loadStyleSheet(int index)
|
2009-07-23 13:11:51 -04:00
|
|
|
{
|
2012-08-24 19:35:57 -04:00
|
|
|
Rshare::loadStyleSheet(ui.styleSheetCombo->itemData(index).toString());
|
2009-08-19 18:15:16 -04:00
|
|
|
}
|