mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-16 13:02:27 -04:00
Added new settings which will be replace soon as possible Preferences
Changend Quit RetroShare MessageBox with "Yes" and not more with "OK" git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1412 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c99e03f376
commit
6abadc6375
36 changed files with 8708 additions and 27 deletions
137
retroshare-gui/src/gui/settings/AppearancePage.cpp
Executable file
137
retroshare-gui/src/gui/settings/AppearancePage.cpp
Executable file
|
@ -0,0 +1,137 @@
|
|||
/****************************************************************
|
||||
* 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
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
|
||||
#include <rshare.h>
|
||||
#include "AppearancePage.h"
|
||||
|
||||
|
||||
/** Constructor */
|
||||
AppearancePage::AppearancePage(QWidget * parent, Qt::WFlags flags)
|
||||
: QWidget(parent, flags)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
/* Create RshareSettings object */
|
||||
_settings = new RshareSettings();
|
||||
|
||||
connect(ui.styleSheetCombo, SIGNAL(clicked()), this, SLOT(loadStyleSheet()));
|
||||
|
||||
/* 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());
|
||||
}
|
||||
|
||||
ui.styleSheetCombo->setCurrentIndex(ui.styleSheetCombo->findText("Default"));
|
||||
//loadStyleSheet("Default");
|
||||
loadqss();
|
||||
|
||||
load();
|
||||
|
||||
|
||||
/* Hide platform specific features */
|
||||
#ifdef Q_WS_WIN
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Saves the changes on this page */
|
||||
bool
|
||||
AppearancePage::save(QString &errmsg)
|
||||
{
|
||||
Q_UNUSED(errmsg);
|
||||
QString languageCode =
|
||||
LanguageSupport::languageCode(ui.cmboLanguage->currentText());
|
||||
|
||||
_settings->setLanguageCode(languageCode);
|
||||
_settings->setInterfaceStyle(ui.cmboStyle->currentText());
|
||||
_settings->setSheetName(ui.styleSheetCombo->currentText());
|
||||
|
||||
/* Set to new style */
|
||||
Rshare::setStyle(ui.cmboStyle->currentText());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Loads the settings for this page */
|
||||
void
|
||||
AppearancePage::load()
|
||||
{
|
||||
|
||||
int index = ui.cmboLanguage->findData(_settings->getLanguageCode());
|
||||
ui.cmboLanguage->setCurrentIndex(index);
|
||||
|
||||
index = ui.cmboStyle->findData(Rshare::style().toLower());
|
||||
ui.cmboStyle->setCurrentIndex(index);
|
||||
|
||||
ui.styleSheetCombo->setCurrentIndex(ui.styleSheetCombo->findText(_settings->getSheetName()));
|
||||
|
||||
/** load saved internal styleSheet **/
|
||||
//QFile file(":/qss/" + (_settings->getSheetName().toLower()) + ".qss");
|
||||
|
||||
/** load saved extern Stylesheets **/
|
||||
QFile file(QApplication::applicationDirPath() + "/qss/" + (_settings->getSheetName().toLower()) + ".qss");
|
||||
|
||||
file.open(QFile::ReadOnly);
|
||||
QString styleSheet = QLatin1String(file.readAll());
|
||||
qApp->setStyleSheet(styleSheet);
|
||||
|
||||
}
|
||||
|
||||
void AppearancePage::on_styleSheetCombo_activated(const QString &sheetName)
|
||||
{
|
||||
loadStyleSheet(sheetName);
|
||||
}
|
||||
|
||||
void AppearancePage::loadStyleSheet(const QString &sheetName)
|
||||
{
|
||||
/** internal Stylesheets **/
|
||||
//QFile file(":/qss/" + sheetName.toLower() + ".qss");
|
||||
|
||||
/** extern Stylesheets **/
|
||||
QFile file(QApplication::applicationDirPath() + "/qss/" + sheetName.toLower() + ".qss");
|
||||
|
||||
file.open(QFile::ReadOnly);
|
||||
QString styleSheet = QLatin1String(file.readAll());
|
||||
|
||||
|
||||
qApp->setStyleSheet(styleSheet);
|
||||
|
||||
}
|
||||
|
||||
void AppearancePage::loadqss()
|
||||
{
|
||||
|
||||
QFileInfoList slist = QDir(QApplication::applicationDirPath() + "/qss/").entryInfoList();
|
||||
foreach(QFileInfo st, slist)
|
||||
{
|
||||
if(st.fileName() != "." && st.fileName() != ".." && st.isFile())
|
||||
ui.styleSheetCombo->addItem(st.fileName().remove(".qss"));
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue