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"
|
2014-05-29 12:15:26 -04:00
|
|
|
#include "gui/MainWindow.h"
|
|
|
|
#include "gui/statusbar/SoundStatus.h"
|
|
|
|
#include "gui/statusbar/ToasterDisable.h"
|
2014-11-02 15:29:06 -05:00
|
|
|
#include "gui/statusbar/SysTrayStatus.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
|
|
|
|
2014-05-29 12:15:26 -04:00
|
|
|
MainWindow *pMainWindow = MainWindow::getInstance();
|
2014-05-09 22:38:47 -04:00
|
|
|
connect(ui.cmboStyleSheet, SIGNAL(activated(int)), this, SLOT(loadStyleSheet(int)));
|
2014-05-29 12:15:26 -04:00
|
|
|
connect(ui.checkBoxStatusCompactMode, SIGNAL(toggled(bool)), pMainWindow, SLOT(setCompactStatusMode(bool)));
|
|
|
|
connect(ui.checkBoxHideSoundStatus, SIGNAL(toggled(bool)), pMainWindow->soundStatusInstance(), SLOT(setHidden(bool)));
|
|
|
|
connect(ui.checkBoxHideToasterDisable, SIGNAL(toggled(bool)), pMainWindow->toasterDisableInstance(), SLOT(setHidden(bool)));
|
2014-11-02 15:29:06 -05:00
|
|
|
connect(ui.checkBoxShowSystrayOnStatus, SIGNAL(toggled(bool)), pMainWindow->sysTrayStatusInstance(), SLOT(setVisible(bool)));
|
2015-09-01 08:43:29 -04:00
|
|
|
connect(ui.checkBoxDisableSysTrayToolTip, SIGNAL(toggled(bool)), pMainWindow, SLOT(toggleStatusToolTip(bool)));
|
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"
|
2014-05-09 22:38:47 -04:00
|
|
|
ui.cmboStyleSheet->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()) {
|
2014-05-09 22:38:47 -04:00
|
|
|
ui.cmboStyleSheet->addItem(name, styleSheets[name]);
|
2012-08-24 19:35:57 -04:00
|
|
|
}
|
2009-07-23 13:11:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** 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());
|
2014-05-09 22:38:47 -04:00
|
|
|
Settings->setSheetName(ui.cmboStyleSheet->itemData(ui.cmboStyleSheet->currentIndex()).toString());
|
|
|
|
Settings->setPageButtonLoc(ui.rbtPageOnToolBar->isChecked());
|
|
|
|
Settings->setActionButtonLoc(ui.rbtActionOnToolBar->isChecked());
|
|
|
|
switch (ui.cmboTollButtonsStyle->currentIndex())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
Settings->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
Settings->setToolButtonStyle(Qt::ToolButtonTextOnly);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
Settings->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
default:
|
|
|
|
Settings->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
|
|
}
|
|
|
|
switch (ui.cmboTollButtonsSize->currentIndex())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
Settings->setToolButtonSize(8);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
Settings->setToolButtonSize(16);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
default:
|
|
|
|
Settings->setToolButtonSize(24);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
Settings->setToolButtonSize(32);
|
2015-06-29 12:08:17 -04:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
Settings->setToolButtonSize(64);
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
Settings->setToolButtonSize(128);
|
|
|
|
}
|
2014-05-10 14:05:18 -04:00
|
|
|
switch (ui.cmboListItemSize->currentIndex())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
Settings->setListItemIconSize(8);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
Settings->setListItemIconSize(16);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
default:
|
|
|
|
Settings->setListItemIconSize(24);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
Settings->setListItemIconSize(32);
|
2015-06-29 12:08:17 -04:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
Settings->setListItemIconSize(64);
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
Settings->setListItemIconSize(128);
|
|
|
|
}
|
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
|
|
|
|
2014-05-29 12:15:26 -04:00
|
|
|
Settings->setValueToGroup("StatusBar", "CompactMode", QVariant(ui.checkBoxStatusCompactMode->isChecked()));
|
|
|
|
Settings->setValueToGroup("StatusBar", "HideSound", QVariant(ui.checkBoxHideSoundStatus->isChecked()));
|
|
|
|
Settings->setValueToGroup("StatusBar", "HideToaster", QVariant(ui.checkBoxHideToasterDisable->isChecked()));
|
2014-11-02 15:29:06 -05:00
|
|
|
Settings->setValueToGroup("StatusBar", "ShowSysTrayOnStatusBar", QVariant(ui.checkBoxShowSystrayOnStatus->isChecked()));
|
2015-09-01 08:43:29 -04:00
|
|
|
Settings->setValueToGroup("StatusBar", "DisableSysTrayToolTip", QVariant(ui.checkBoxDisableSysTrayToolTip->isChecked()));
|
2015-09-01 20:09:39 -04:00
|
|
|
MainWindow::getInstance()->toggleStatusToolTip(ui.checkBoxDisableSysTrayToolTip->isChecked());
|
2014-05-29 12:15:26 -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);
|
|
|
|
|
2014-05-09 22:38:47 -04:00
|
|
|
index = ui.cmboStyleSheet->findData(Settings->getSheetName());
|
2012-08-24 19:35:57 -04:00
|
|
|
if (index == -1) {
|
|
|
|
/* set standard "no style sheet" */
|
2014-05-09 22:38:47 -04:00
|
|
|
index = ui.cmboStyleSheet->findData("");
|
|
|
|
}
|
|
|
|
ui.cmboStyleSheet->setCurrentIndex(index);
|
|
|
|
|
|
|
|
ui.rbtPageOnToolBar->setChecked(Settings->getPageButtonLoc());
|
|
|
|
ui.rbtPageOnListItem->setChecked(!Settings->getPageButtonLoc());
|
|
|
|
ui.rbtActionOnToolBar->setChecked(Settings->getActionButtonLoc());
|
|
|
|
ui.rbtActionOnListItem->setChecked(!Settings->getActionButtonLoc());
|
|
|
|
switch (Settings->getToolButtonStyle())
|
|
|
|
{
|
|
|
|
case Qt::ToolButtonIconOnly:
|
|
|
|
ui.cmboTollButtonsStyle->setCurrentIndex(0);
|
|
|
|
break;
|
|
|
|
case Qt::ToolButtonTextOnly:
|
|
|
|
ui.cmboTollButtonsStyle->setCurrentIndex(1);
|
|
|
|
break;
|
|
|
|
case Qt::ToolButtonTextBesideIcon:
|
|
|
|
ui.cmboTollButtonsStyle->setCurrentIndex(2);
|
|
|
|
break;
|
|
|
|
case Qt::ToolButtonTextUnderIcon:
|
|
|
|
default:
|
|
|
|
ui.cmboTollButtonsStyle->setCurrentIndex(3);
|
|
|
|
}
|
|
|
|
switch (Settings->getToolButtonSize())
|
|
|
|
{
|
|
|
|
case 8:
|
|
|
|
ui.cmboTollButtonsSize->setCurrentIndex(0);
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
ui.cmboTollButtonsSize->setCurrentIndex(1);
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
default:
|
|
|
|
ui.cmboTollButtonsSize->setCurrentIndex(2);
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
ui.cmboTollButtonsSize->setCurrentIndex(3);
|
2015-06-29 12:08:17 -04:00
|
|
|
break;
|
|
|
|
case 64:
|
|
|
|
ui.cmboTollButtonsSize->setCurrentIndex(4);
|
|
|
|
break;
|
|
|
|
case 128:
|
|
|
|
ui.cmboTollButtonsSize->setCurrentIndex(5);
|
|
|
|
}
|
2014-05-10 14:05:18 -04:00
|
|
|
switch (Settings->getListItemIconSize())
|
|
|
|
{
|
|
|
|
case 8:
|
|
|
|
ui.cmboListItemSize->setCurrentIndex(0);
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
ui.cmboListItemSize->setCurrentIndex(1);
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
default:
|
|
|
|
ui.cmboListItemSize->setCurrentIndex(2);
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
ui.cmboListItemSize->setCurrentIndex(3);
|
2015-06-29 12:08:17 -04:00
|
|
|
break;
|
|
|
|
case 64:
|
|
|
|
ui.cmboListItemSize->setCurrentIndex(4);
|
|
|
|
break;
|
|
|
|
case 128:
|
|
|
|
ui.cmboListItemSize->setCurrentIndex(5);
|
|
|
|
}
|
2014-05-29 12:15:26 -04:00
|
|
|
|
|
|
|
ui.checkBoxStatusCompactMode->setChecked(Settings->valueFromGroup("StatusBar", "CompactMode", QVariant(false)).toBool());
|
|
|
|
ui.checkBoxHideSoundStatus->setChecked(Settings->valueFromGroup("StatusBar", "HideSound", QVariant(false)).toBool());
|
|
|
|
ui.checkBoxHideToasterDisable->setChecked(Settings->valueFromGroup("StatusBar", "HideToaster", QVariant(false)).toBool());
|
2014-11-02 15:29:06 -05:00
|
|
|
ui.checkBoxShowSystrayOnStatus->setChecked(Settings->valueFromGroup("StatusBar", "ShowSysTrayOnStatusBar", QVariant(false)).toBool());
|
2015-09-01 08:43:29 -04:00
|
|
|
ui.checkBoxDisableSysTrayToolTip->setChecked(Settings->valueFromGroup("StatusBar", "DisableSysTrayToolTip", QVariant(false)).toBool());
|
2014-05-29 12:15:26 -04:00
|
|
|
|
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
|
|
|
{
|
2014-05-09 22:38:47 -04:00
|
|
|
Rshare::loadStyleSheet(ui.cmboStyleSheet->itemData(index).toString());
|
2009-08-19 18:15:16 -04:00
|
|
|
}
|