2008-08-14 20:23:27 -04:00
|
|
|
/****************************************************************
|
2010-01-27 17:31:25 -05:00
|
|
|
* This file is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (c) 2006-2007, crypton
|
2008-08-14 20:23:27 -04:00
|
|
|
* Copyright (c) 2006, Matt Edman, Justin Hipple
|
|
|
|
*
|
|
|
|
* 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
|
2014-07-24 12:52:11 -04:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2008-08-14 20:23:27 -04:00
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QStyleFactory>
|
2010-11-04 09:09:08 -04:00
|
|
|
#include <QWidget>
|
2008-08-14 20:23:27 -04:00
|
|
|
#include <lang/languagesupport.h>
|
|
|
|
#include <rshare.h>
|
|
|
|
|
|
|
|
#include "rsharesettings.h"
|
2010-11-04 09:09:08 -04:00
|
|
|
#include "gui/MainWindow.h"
|
2008-08-14 20:23:27 -04:00
|
|
|
|
2010-08-06 05:40:23 -04:00
|
|
|
#include <retroshare/rsnotify.h>
|
2011-04-14 17:59:51 -04:00
|
|
|
#include <retroshare/rspeers.h>
|
2008-12-07 09:19:13 -05:00
|
|
|
|
2008-08-14 20:23:27 -04:00
|
|
|
#if defined(Q_WS_WIN)
|
|
|
|
#include <util/win32.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Retroshare's Settings */
|
|
|
|
#define SETTING_LANGUAGE "LanguageCode"
|
|
|
|
#define SETTING_STYLE "InterfaceStyle"
|
|
|
|
#define SETTING_SHEETNAME "SheetName"
|
2014-05-09 22:38:47 -04:00
|
|
|
#define SETTING_PAGEBUTTONLOC "PageButtonLocation"
|
|
|
|
#define SETTING_ACTIONBUTTONLOC "ActionButtonLocation"
|
|
|
|
#define SETTING_TOOLBUTTONSTYLE "ToolButtonStyle"
|
|
|
|
#define SETTING_TOOLBUTTONSIZE "ToolButtonSize"
|
2014-05-10 14:05:18 -04:00
|
|
|
#define SETTING_LISTITEMICONSIZE "ListItemIconSize"
|
2008-08-14 20:23:27 -04:00
|
|
|
|
|
|
|
#define SETTING_DATA_DIRECTORY "DataDirectory"
|
|
|
|
#define SETTING_BWGRAPH_FILTER "StatisticDialog/BWLineFilter"
|
|
|
|
#define SETTING_BWGRAPH_OPACITY "StatisticDialog/Opacity"
|
|
|
|
#define SETTING_BWGRAPH_ALWAYS_ON_TOP "StatisticDialog/AlwaysOnTop"
|
|
|
|
|
2008-12-07 09:19:13 -05:00
|
|
|
#define SETTING_NEWSFEED_FLAGS "NewsFeedFlags"
|
|
|
|
#define SETTING_CHAT_FLAGS "ChatFlags"
|
|
|
|
#define SETTING_NOTIFY_FLAGS "NotifyFlags"
|
2009-03-01 10:18:34 -05:00
|
|
|
#define SETTING_CHAT_AVATAR "ChatAvatar"
|
2008-12-07 09:19:13 -05:00
|
|
|
|
2008-08-14 20:23:27 -04:00
|
|
|
/* Default Retroshare Settings */
|
|
|
|
#define DEFAULT_OPACITY 100
|
|
|
|
|
|
|
|
#if defined(Q_OS_WIN32)
|
|
|
|
#define STARTUP_REG_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\Run"
|
|
|
|
#define RETROSHARE_REG_KEY "RetroShare"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Default bandwidth graph settings */
|
|
|
|
#define DEFAULT_BWGRAPH_FILTER (BWGRAPH_SEND|BWGRAPH_REC)
|
|
|
|
#define DEFAULT_BWGRAPH_ALWAYS_ON_TOP false
|
|
|
|
|
2014-05-09 22:38:47 -04:00
|
|
|
/* values for ToolButtonStyle */
|
|
|
|
#define SETTING_VALUE_TOOLBUTTONSTYLE_ICONONLY 1
|
|
|
|
#define SETTING_VALUE_TOOLBUTTONSTYLE_TEXTONLY 2
|
|
|
|
#define SETTING_VALUE_TOOLBUTTONSTYLE_TEXTBESIDEICON 3
|
|
|
|
#define SETTING_VALUE_TOOLBUTTONSTYLE_TEXTUNDERICON 4
|
|
|
|
|
2010-05-20 17:53:27 -04:00
|
|
|
// the one and only global settings object
|
|
|
|
RshareSettings *Settings = NULL;
|
|
|
|
|
2011-10-14 17:16:34 -04:00
|
|
|
/*static*/ void RshareSettings::Create(bool forceCreateNew)
|
2010-05-20 17:53:27 -04:00
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
if (Settings && (forceCreateNew || Settings->m_bValid == false)) {
|
|
|
|
// recreate with correct path
|
|
|
|
delete (Settings);
|
|
|
|
Settings = NULL;
|
|
|
|
}
|
|
|
|
if (Settings == NULL) {
|
|
|
|
Settings = new RshareSettings ();
|
|
|
|
}
|
2010-01-27 17:31:25 -05:00
|
|
|
}
|
2008-08-14 20:23:27 -04:00
|
|
|
|
|
|
|
/** Default Constructor */
|
2010-06-14 09:32:13 -04:00
|
|
|
RshareSettings::RshareSettings()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
m_maxTimeBeforeIdle = -1;
|
2010-07-21 03:39:14 -04:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
initSettings();
|
2010-01-27 17:31:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::initSettings()
|
2008-08-14 20:23:27 -04:00
|
|
|
{
|
|
|
|
#if defined(Q_WS_MAC)
|
2014-07-24 12:52:11 -04:00
|
|
|
setDefault(SETTING_STYLE, "macintosh (aqua)");
|
2008-08-14 20:23:27 -04:00
|
|
|
#else
|
2014-07-24 12:52:11 -04:00
|
|
|
static QStringList styles = QStyleFactory::keys();
|
2008-08-14 20:23:27 -04:00
|
|
|
#if defined(Q_WS_WIN)
|
2014-07-24 12:52:11 -04:00
|
|
|
if (styles.contains("windowsvista", Qt::CaseInsensitive))
|
|
|
|
setDefault(SETTING_STYLE, "windowsvista");
|
|
|
|
else if (styles.contains("windowsxp", Qt::CaseInsensitive))
|
|
|
|
setDefault(SETTING_STYLE, "windowsxp");
|
|
|
|
else
|
2008-08-14 20:23:27 -04:00
|
|
|
#endif
|
2014-07-24 12:52:11 -04:00
|
|
|
{
|
|
|
|
if (styles.contains("cleanlooks", Qt::CaseInsensitive))
|
|
|
|
setDefault(SETTING_STYLE, "cleanlooks");
|
|
|
|
else
|
|
|
|
setDefault(SETTING_STYLE, "plastique");
|
|
|
|
}
|
2008-08-14 20:23:27 -04:00
|
|
|
#endif
|
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
setDefault(SETTING_LANGUAGE, LanguageSupport::defaultLanguageCode());
|
|
|
|
setDefault(SETTING_SHEETNAME, ":Standard");
|
2008-12-07 09:19:13 -05:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
/* defaults here are not ideal.... but dusent matter */
|
2008-12-07 09:19:13 -05:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
uint defChat = RS_CHAT_OPEN;
|
|
|
|
// This is not default... RS_CHAT_FOCUS.
|
2008-12-07 09:19:13 -05:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
uint defNotify = (RS_POPUP_CONNECT | RS_POPUP_MSG);
|
2008-12-07 09:19:13 -05:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
uint defNewsFeed = (RS_FEED_TYPE_PEER |
|
|
|
|
// RS_FEED_TYPE_CHAN | RS_FEED_TYPE_FORUM | RS_FEED_TYPE_BLOG |
|
|
|
|
RS_FEED_TYPE_CHAT | RS_FEED_TYPE_MSG |
|
|
|
|
RS_FEED_TYPE_FILES | RS_FEED_TYPE_SECURITY);
|
2008-12-07 09:19:13 -05:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
setDefault(SETTING_NEWSFEED_FLAGS, defNewsFeed);
|
|
|
|
setDefault(SETTING_CHAT_FLAGS, defChat);
|
|
|
|
setDefault(SETTING_NOTIFY_FLAGS, defNotify);
|
2010-06-15 12:51:48 -04:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
setDefault("DisplayTrayGroupChat", true);
|
|
|
|
setDefault("AddFeedsAtEnd", false);
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Gets the currently preferred language code for Rshare. */
|
|
|
|
QString RshareSettings::getLanguageCode()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value(SETTING_LANGUAGE).toString();
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Sets the preferred language code. */
|
|
|
|
void RshareSettings::setLanguageCode(QString languageCode)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue(SETTING_LANGUAGE, languageCode);
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Gets the interface style key (e.g., "windows", "motif", etc.) */
|
|
|
|
QString RshareSettings::getInterfaceStyle()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value(SETTING_STYLE).toString();
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Sets the interface style key. */
|
|
|
|
void RshareSettings::setInterfaceStyle(QString styleKey)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue(SETTING_STYLE, styleKey);
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Gets the sheetname.*/
|
|
|
|
QString RshareSettings::getSheetName()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value(SETTING_SHEETNAME).toString();
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
/** Sets the sheetname.*/
|
|
|
|
void RshareSettings::setSheetName(QString sheet)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue(SETTING_SHEETNAME, sheet);
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
2014-05-09 22:38:47 -04:00
|
|
|
/** Gets the page button Location.*/
|
|
|
|
bool RshareSettings::getPageButtonLoc()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value(SETTING_PAGEBUTTONLOC, false).toBool();
|
2014-05-09 22:38:47 -04:00
|
|
|
}
|
|
|
|
/** Sets the page button Location.*/
|
|
|
|
void RshareSettings::setPageButtonLoc(bool onToolBar)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue(SETTING_PAGEBUTTONLOC, onToolBar);
|
2014-05-09 22:38:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Gets the action button Location.*/
|
|
|
|
bool RshareSettings::getActionButtonLoc()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value(SETTING_ACTIONBUTTONLOC, true).toBool();
|
2014-05-09 22:38:47 -04:00
|
|
|
}
|
|
|
|
/** Sets the action button Location.*/
|
|
|
|
void RshareSettings::setActionButtonLoc(bool onToolBar)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue(SETTING_ACTIONBUTTONLOC, onToolBar);
|
2014-05-09 22:38:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Gets the tool button's style.*/
|
|
|
|
Qt::ToolButtonStyle RshareSettings::getToolButtonStyle()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
int intValue=value(SETTING_TOOLBUTTONSTYLE, SETTING_VALUE_TOOLBUTTONSTYLE_TEXTUNDERICON).toInt();
|
|
|
|
switch (intValue)
|
|
|
|
{
|
|
|
|
case SETTING_VALUE_TOOLBUTTONSTYLE_ICONONLY:
|
|
|
|
return Qt::ToolButtonIconOnly;
|
|
|
|
case SETTING_VALUE_TOOLBUTTONSTYLE_TEXTONLY:
|
|
|
|
return Qt::ToolButtonTextOnly;
|
|
|
|
case SETTING_VALUE_TOOLBUTTONSTYLE_TEXTBESIDEICON:
|
|
|
|
return Qt::ToolButtonTextBesideIcon;
|
|
|
|
case SETTING_VALUE_TOOLBUTTONSTYLE_TEXTUNDERICON:
|
|
|
|
default:
|
|
|
|
return Qt::ToolButtonTextUnderIcon;
|
|
|
|
}
|
2014-05-09 22:38:47 -04:00
|
|
|
}
|
|
|
|
/** Sets the tool button's style.*/
|
|
|
|
void RshareSettings::setToolButtonStyle(Qt::ToolButtonStyle style)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
switch (style)
|
|
|
|
{
|
|
|
|
case Qt::ToolButtonIconOnly:
|
|
|
|
setValue(SETTING_TOOLBUTTONSTYLE, SETTING_VALUE_TOOLBUTTONSTYLE_ICONONLY);
|
|
|
|
break;
|
|
|
|
case Qt::ToolButtonTextOnly:
|
|
|
|
setValue(SETTING_TOOLBUTTONSTYLE, SETTING_VALUE_TOOLBUTTONSTYLE_TEXTONLY);
|
|
|
|
break;
|
|
|
|
case Qt::ToolButtonTextBesideIcon:
|
|
|
|
setValue(SETTING_TOOLBUTTONSTYLE, SETTING_VALUE_TOOLBUTTONSTYLE_TEXTBESIDEICON);
|
|
|
|
break;
|
|
|
|
case Qt::ToolButtonTextUnderIcon:
|
|
|
|
default:
|
|
|
|
setValue(SETTING_TOOLBUTTONSTYLE, SETTING_VALUE_TOOLBUTTONSTYLE_TEXTUNDERICON);
|
|
|
|
}
|
2014-05-09 22:38:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Gets the tool button's size.*/
|
|
|
|
int RshareSettings::getToolButtonSize()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
int intValue=value(SETTING_TOOLBUTTONSIZE, 24).toInt();
|
|
|
|
switch (intValue)
|
|
|
|
{
|
|
|
|
case 8:
|
|
|
|
return 8;
|
|
|
|
case 16:
|
|
|
|
return 16;
|
|
|
|
case 24:
|
|
|
|
default:
|
|
|
|
return 24;
|
|
|
|
case 32:
|
|
|
|
return 32;
|
|
|
|
}
|
2014-05-09 22:38:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Sets the tool button's size.*/
|
|
|
|
void RshareSettings::setToolButtonSize(int size)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
switch (size)
|
|
|
|
{
|
|
|
|
case 8:
|
|
|
|
setValue(SETTING_TOOLBUTTONSIZE, 8);
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
setValue(SETTING_TOOLBUTTONSIZE, 16);
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
default:
|
|
|
|
setValue(SETTING_TOOLBUTTONSIZE, 24);
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
setValue(SETTING_TOOLBUTTONSIZE, 32);
|
|
|
|
}
|
2014-05-09 22:38:47 -04:00
|
|
|
}
|
2014-05-10 14:05:18 -04:00
|
|
|
|
|
|
|
/** Gets the list item icon's size.*/
|
|
|
|
int RshareSettings::getListItemIconSize()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
int intValue=value(SETTING_LISTITEMICONSIZE, 24).toInt();
|
|
|
|
switch (intValue)
|
|
|
|
{
|
|
|
|
case 8:
|
|
|
|
return 8;
|
|
|
|
case 16:
|
|
|
|
return 16;
|
|
|
|
case 24:
|
|
|
|
default:
|
|
|
|
return 24;
|
|
|
|
case 32:
|
|
|
|
return 32;
|
|
|
|
}
|
2014-05-10 14:05:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Sets the list item icon's size.*/
|
|
|
|
void RshareSettings::setListItemIconSize(int size)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
switch (size)
|
|
|
|
{
|
|
|
|
case 8:
|
|
|
|
setValue(SETTING_LISTITEMICONSIZE, 8);
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
setValue(SETTING_LISTITEMICONSIZE, 16);
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
default:
|
|
|
|
setValue(SETTING_LISTITEMICONSIZE, 24);
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
setValue(SETTING_LISTITEMICONSIZE, 32);
|
|
|
|
}
|
2014-05-10 14:05:18 -04:00
|
|
|
}
|
|
|
|
|
2010-12-02 19:54:40 -05:00
|
|
|
static QString getKeyForLastDir(RshareSettings::enumLastDir type)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
switch (type) {
|
|
|
|
case RshareSettings::LASTDIR_EXTRAFILE:
|
|
|
|
return "ExtraFile";
|
|
|
|
case RshareSettings::LASTDIR_CERT:
|
|
|
|
return "Certificate";
|
|
|
|
case RshareSettings::LASTDIR_HISTORY:
|
|
|
|
return "History";
|
|
|
|
case RshareSettings::LASTDIR_IMAGES:
|
|
|
|
return "Images";
|
|
|
|
case RshareSettings::LASTDIR_MESSAGES:
|
|
|
|
return "Messages";
|
|
|
|
case RshareSettings::LASTDIR_BLOGS:
|
|
|
|
return "Messages";
|
|
|
|
case RshareSettings::LASTDIR_SOUNDS:
|
|
|
|
return "SOUNDS";
|
|
|
|
}
|
|
|
|
return "";
|
2010-12-02 19:54:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
QString RshareSettings::getLastDir(enumLastDir type)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
QString key = getKeyForLastDir(type);
|
|
|
|
if (key.isEmpty()) {
|
|
|
|
return "";
|
|
|
|
}
|
2010-12-02 19:54:40 -05:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
return valueFromGroup("LastDir", key).toString();
|
2010-12-02 19:54:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setLastDir(enumLastDir type, const QString &lastDir)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
QString key = getKeyForLastDir(type);
|
|
|
|
if (key.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
2010-12-02 19:54:40 -05:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
setValueToGroup("LastDir", key, lastDir);
|
2010-12-02 19:54:40 -05:00
|
|
|
}
|
|
|
|
|
2008-08-14 20:23:27 -04:00
|
|
|
/** Returns the bandwidth line filter. */
|
|
|
|
uint RshareSettings::getBWGraphFilter()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value(SETTING_BWGRAPH_FILTER, DEFAULT_BWGRAPH_FILTER).toUInt();
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Saves the setting for whether or not the given line will be graphed */
|
|
|
|
void RshareSettings::setBWGraphFilter(uint line, bool status)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
uint filter = getBWGraphFilter();
|
|
|
|
filter = (status ? (filter | line) : (filter & ~(line)));
|
|
|
|
setValue(SETTING_BWGRAPH_FILTER, filter);
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Get the level of opacity for the BandwidthGraph window. */
|
|
|
|
int RshareSettings::getBWGraphOpacity()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value(SETTING_BWGRAPH_OPACITY, DEFAULT_OPACITY).toInt();
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Set the level of opacity for the BandwidthGraph window. */
|
|
|
|
void RshareSettings::setBWGraphOpacity(int value)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue(SETTING_BWGRAPH_OPACITY, value);
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Gets whether the bandwidth graph is always on top when displayed. */
|
|
|
|
bool RshareSettings::getBWGraphAlwaysOnTop()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value(SETTING_BWGRAPH_ALWAYS_ON_TOP,
|
|
|
|
DEFAULT_BWGRAPH_ALWAYS_ON_TOP).toBool();
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Sets whether the bandwidth graph is always on top when displayed. */
|
|
|
|
void RshareSettings::setBWGraphAlwaysOnTop(bool alwaysOnTop)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue(SETTING_BWGRAPH_ALWAYS_ON_TOP, alwaysOnTop);
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Returns true if RetroShare's main window should be visible when the
|
|
|
|
* application starts. */
|
2010-12-13 15:34:07 -05:00
|
|
|
bool RshareSettings::getStartMinimized()
|
2008-08-14 20:23:27 -04:00
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value("StartMinimized", false).toBool();
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Sets whether to show RetroShare's main window when the application starts. */
|
2010-12-13 15:34:07 -05:00
|
|
|
void RshareSettings::setStartMinimized(bool startMinimized)
|
2008-08-14 20:23:27 -04:00
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue("StartMinimized", startMinimized);
|
2010-12-13 15:34:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool RshareSettings::getCloseToTray()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value("CloseToTray", true).toBool();
|
2010-12-13 15:34:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setCloseToTray(bool closeToTray)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue("CloseToTray", closeToTray);
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
2008-12-07 09:19:13 -05:00
|
|
|
/** Setting for Notify / Chat and NewsFeeds **/
|
|
|
|
uint RshareSettings::getNewsFeedFlags()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value(SETTING_NEWSFEED_FLAGS).toUInt();
|
2008-12-07 09:19:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setNewsFeedFlags(uint flags)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue(SETTING_NEWSFEED_FLAGS, flags);
|
2008-12-07 09:19:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
uint RshareSettings::getChatFlags()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value(SETTING_CHAT_FLAGS).toUInt();
|
2008-12-07 09:19:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setChatFlags(uint flags)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue(SETTING_CHAT_FLAGS, flags);
|
2008-12-07 09:19:13 -05:00
|
|
|
}
|
|
|
|
|
2012-10-27 11:59:12 -04:00
|
|
|
uint RshareSettings::getChatLobbyFlags()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value("ChatLobbyFlags").toUInt();
|
2012-10-27 11:59:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setChatLobbyFlags(uint flags)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue("ChatLobbyFlags", flags);
|
2012-10-27 11:59:12 -04:00
|
|
|
}
|
|
|
|
|
2008-12-07 09:19:13 -05:00
|
|
|
uint RshareSettings::getNotifyFlags()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value(SETTING_NOTIFY_FLAGS).toUInt();
|
2008-12-07 09:19:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setNotifyFlags(uint flags)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue(SETTING_NOTIFY_FLAGS, flags);
|
2008-12-07 09:19:13 -05:00
|
|
|
}
|
|
|
|
|
2012-04-26 19:41:14 -04:00
|
|
|
uint RshareSettings::getMessageFlags()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value("MessageFlags").toUInt();
|
2012-04-26 19:41:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setMessageFlags(uint flags)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue("MessageFlags", flags);
|
2012-04-26 19:41:14 -04:00
|
|
|
}
|
|
|
|
|
2012-07-30 09:27:40 -04:00
|
|
|
bool RshareSettings::getDisplayTrayChatLobby()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value("DisplayTrayChatLobby").toBool();
|
2012-07-30 09:27:40 -04:00
|
|
|
}
|
|
|
|
|
2010-06-15 12:51:48 -04:00
|
|
|
bool RshareSettings::getDisplayTrayGroupChat()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value("DisplayTrayGroupChat").toBool();
|
2010-06-15 12:51:48 -04:00
|
|
|
}
|
|
|
|
|
2012-07-30 09:27:40 -04:00
|
|
|
void RshareSettings::setDisplayTrayChatLobby(bool bValue)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue("DisplayTrayChatLobby", bValue);
|
2012-07-30 09:27:40 -04:00
|
|
|
}
|
|
|
|
|
2010-06-15 12:51:48 -04:00
|
|
|
void RshareSettings::setDisplayTrayGroupChat(bool bValue)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue("DisplayTrayGroupChat", bValue);
|
2010-06-15 12:51:48 -04:00
|
|
|
}
|
|
|
|
|
2010-09-01 16:54:24 -04:00
|
|
|
bool RshareSettings::getAddFeedsAtEnd()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value("AddFeedsAtEnd").toBool();
|
2010-09-01 16:54:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setAddFeedsAtEnd(bool bValue)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue("AddFeedsAtEnd", bValue);
|
2010-09-01 16:54:24 -04:00
|
|
|
}
|
|
|
|
|
2010-09-04 10:23:30 -04:00
|
|
|
bool RshareSettings::getChatSendMessageWithCtrlReturn()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return valueFromGroup("Chat", "SendMessageWithCtrlReturn", false).toBool();
|
2010-09-04 10:23:30 -04:00
|
|
|
}
|
|
|
|
|
2014-05-26 17:51:53 -04:00
|
|
|
void RshareSettings::setChatSendMessageWithCtrlReturn(bool bValue)
|
|
|
|
{
|
|
|
|
setValueToGroup("Chat", "SendMessageWithCtrlReturn", bValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setChatSearchCharToStartSearch(int iValue)
|
|
|
|
{
|
|
|
|
setValueToGroup("Chat", "SearchCharToStartSearch", iValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
int RshareSettings::getChatSearchCharToStartSearch()
|
|
|
|
{
|
|
|
|
return valueFromGroup("Chat", "SearchCharToStartSearch", 4).toUInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setChatSearchCaseSensitively(bool bValue)
|
|
|
|
{
|
|
|
|
setValueToGroup("Chat", "SearchCaseSensitively", bValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RshareSettings::getChatSearchCaseSensitively()
|
|
|
|
{
|
|
|
|
return valueFromGroup("Chat", "SearchCaseSensitively", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setChatSearchWholeWords(bool bValue)
|
|
|
|
{
|
|
|
|
setValueToGroup("Chat", "SearchWholeWords", bValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RshareSettings::getChatSearchWholeWords()
|
|
|
|
{
|
|
|
|
return valueFromGroup("Chat", "SearchWholeWords", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setChatSearchMoveToCursor(bool bValue)
|
|
|
|
{
|
|
|
|
setValueToGroup("Chat", "SearchMoveToCursor", bValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RshareSettings::getChatSearchMoveToCursor()
|
|
|
|
{
|
|
|
|
return valueFromGroup("Chat", "SearchMoveToCursor", true).toBool();
|
|
|
|
}
|
2014-07-24 12:52:11 -04:00
|
|
|
|
2014-05-26 17:51:53 -04:00
|
|
|
void RshareSettings::setChatSearchSearchWithoutLimit(bool bValue)
|
|
|
|
{
|
|
|
|
setValueToGroup("Chat", "SearchSearchWithoutLimit", bValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RshareSettings::getChatSearchSearchWithoutLimit()
|
|
|
|
{
|
|
|
|
return valueFromGroup("Chat", "SearchSearchWithoutLimit", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setChatSearchMaxSearchLimitColor(uint uiValue)
|
|
|
|
{
|
|
|
|
setValueToGroup("Chat", "SearchMaxSearchLimitColor", uiValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint RshareSettings::getChatSearchMaxSearchLimitColor()
|
|
|
|
{
|
|
|
|
return valueFromGroup("Chat", "SearchMaxSearchLimitColor", 40).toUInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setChatSearchFoundColor(QRgb rgbValue)
|
|
|
|
{
|
|
|
|
setValueToGroup("Chat", "SearchMaxSearchFoundColor", QString::number(rgbValue));
|
|
|
|
}
|
|
|
|
QRgb RshareSettings::getChatSearchFoundColor()
|
|
|
|
{
|
|
|
|
return valueFromGroup("Chat", "SearchMaxSearchFoundColor", QString::number(QColor(255,255,150).rgba())).toUInt();
|
|
|
|
}
|
|
|
|
|
2010-12-10 16:49:38 -05:00
|
|
|
RshareSettings::enumToasterPosition RshareSettings::getToasterPosition()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return (enumToasterPosition) value("ToasterPosition", TOASTERPOS_BOTTOMRIGHT).toInt();
|
2010-12-10 16:49:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setToasterPosition(enumToasterPosition position)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue("ToasterPosition", position);
|
2010-12-10 16:49:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
QPoint RshareSettings::getToasterMargin()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return value("ToasterMargin", QPoint(10, 10)).toPoint();
|
2010-12-10 16:49:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setToasterMargin(QPoint margin)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue("ToasterMargin", margin);
|
2010-12-10 16:49:38 -05:00
|
|
|
}
|
|
|
|
|
2010-09-10 14:38:46 -04:00
|
|
|
QString RshareSettings::getChatScreenFont()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return valueFromGroup("Chat", "ChatScreenFont").toString();
|
2010-09-10 14:38:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setChatScreenFont(const QString &font)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValueToGroup("Chat", "ChatScreenFont", font);
|
2010-09-10 14:38:46 -04:00
|
|
|
}
|
|
|
|
|
2010-09-07 19:19:27 -04:00
|
|
|
void RshareSettings::getPublicChatStyle(QString &stylePath, QString &styleVariant)
|
2010-09-07 11:49:31 -04:00
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
stylePath = valueFromGroup("Chat", "StylePublic", ":/qss/chat/standard/public").toString();
|
|
|
|
// Correct changed standard path for older RetroShare versions before 31.01.2012 (can be removed later)
|
|
|
|
if (stylePath == ":/qss/chat/public") {
|
|
|
|
stylePath = ":/qss/chat/standard/public";
|
|
|
|
}
|
|
|
|
styleVariant = valueFromGroup("Chat", "StylePublicVariant", "").toString();
|
2010-09-07 11:49:31 -04:00
|
|
|
}
|
|
|
|
|
2010-09-10 14:38:46 -04:00
|
|
|
void RshareSettings::setPublicChatStyle(const QString &stylePath, const QString &styleVariant)
|
2010-09-07 11:49:31 -04:00
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValueToGroup("Chat", "StylePublic", stylePath);
|
|
|
|
setValueToGroup("Chat", "StylePublicVariant", styleVariant);
|
2010-09-07 11:49:31 -04:00
|
|
|
}
|
|
|
|
|
2010-09-07 19:19:27 -04:00
|
|
|
void RshareSettings::getPrivateChatStyle(QString &stylePath, QString &styleVariant)
|
2010-09-07 11:49:31 -04:00
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
stylePath = valueFromGroup("Chat", "StylePrivate", ":/qss/chat/standard/private").toString();
|
|
|
|
// Correct changed standard path for older RetroShare versions before 31.01.2012 (can be removed later)
|
|
|
|
if (stylePath == ":/qss/chat/private") {
|
|
|
|
stylePath = ":/qss/chat/standard/private";
|
|
|
|
}
|
|
|
|
styleVariant = valueFromGroup("Chat", "StylePrivateVariant", "").toString();
|
2010-09-07 11:49:31 -04:00
|
|
|
}
|
|
|
|
|
2010-09-10 14:38:46 -04:00
|
|
|
void RshareSettings::setPrivateChatStyle(const QString &stylePath, const QString &styleVariant)
|
2010-09-07 11:49:31 -04:00
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValueToGroup("Chat", "StylePrivate", stylePath);
|
|
|
|
setValueToGroup("Chat", "StylePrivateVariant", styleVariant);
|
2010-09-07 11:49:31 -04:00
|
|
|
}
|
|
|
|
|
2010-09-07 19:19:27 -04:00
|
|
|
void RshareSettings::getHistoryChatStyle(QString &stylePath, QString &styleVariant)
|
2010-09-07 11:49:31 -04:00
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
stylePath = valueFromGroup("Chat", "StyleHistory", ":/qss/chat/standard/history").toString();
|
|
|
|
// Correct changed standard path for older RetroShare versions before 31.01.2012 (can be removed later)
|
|
|
|
if (stylePath == ":/qss/chat/history") {
|
|
|
|
stylePath = ":/qss/chat/standard/history";
|
|
|
|
}
|
|
|
|
styleVariant = valueFromGroup("Chat", "StylePrivateVariant", "").toString();
|
2010-09-07 11:49:31 -04:00
|
|
|
}
|
|
|
|
|
2010-09-10 14:38:46 -04:00
|
|
|
void RshareSettings::setHistoryChatStyle(const QString &stylePath, const QString &styleVariant)
|
2010-09-07 11:49:31 -04:00
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValueToGroup("Chat", "StyleHistory", stylePath);
|
|
|
|
setValueToGroup("Chat", "StylePrivateVariant", styleVariant);
|
2010-09-07 11:49:31 -04:00
|
|
|
}
|
2013-09-27 17:18:44 -04:00
|
|
|
int RshareSettings::getLobbyChatHistoryCount()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return valueFromGroup("Chat", "LobbyChatHistoryCount", 0).toInt();
|
2013-09-27 17:18:44 -04:00
|
|
|
}
|
2010-09-07 11:49:31 -04:00
|
|
|
|
2013-09-27 17:18:44 -04:00
|
|
|
void RshareSettings::setLobbyChatHistoryCount(int value)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValueToGroup("Chat", "LobbyChatHistoryCount", value);
|
2013-09-27 17:18:44 -04:00
|
|
|
}
|
2010-11-04 07:14:47 -04:00
|
|
|
int RshareSettings::getPublicChatHistoryCount()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return valueFromGroup("Chat", "PublicChatHistoryCount", 0).toInt();
|
2010-11-04 07:14:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setPublicChatHistoryCount(int value)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValueToGroup("Chat", "PublicChatHistoryCount", value);
|
2010-11-04 07:14:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int RshareSettings::getPrivateChatHistoryCount()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return valueFromGroup("Chat", "PrivateChatHistoryCount", 20).toInt();
|
2010-11-04 07:14:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setPrivateChatHistoryCount(int value)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValueToGroup("Chat", "PrivateChatHistoryCount", value);
|
2010-11-04 07:14:47 -04:00
|
|
|
}
|
|
|
|
|
2010-05-18 14:02:51 -04:00
|
|
|
/** Returns true if RetroShare is set to run on system boot. */
|
2008-08-14 20:23:27 -04:00
|
|
|
bool
|
2010-12-11 17:46:14 -05:00
|
|
|
RshareSettings::runRetroshareOnBoot(bool &minimized)
|
2008-08-14 20:23:27 -04:00
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
minimized = false;
|
2010-12-11 17:46:14 -05:00
|
|
|
|
2008-08-14 20:23:27 -04:00
|
|
|
#if defined(Q_WS_WIN)
|
2014-07-24 12:52:11 -04:00
|
|
|
QString value = win32_registry_get_key_value(STARTUP_REG_KEY, RETROSHARE_REG_KEY);
|
|
|
|
|
|
|
|
if (!value.isEmpty()) {
|
|
|
|
/* Simple check for "-m" */
|
|
|
|
minimized = value.contains(" -m");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2008-08-14 20:23:27 -04:00
|
|
|
#else
|
2014-07-24 12:52:11 -04:00
|
|
|
/* Platforms other than windows aren't supported yet */
|
|
|
|
return false;
|
2008-08-14 20:23:27 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-05-18 14:02:51 -04:00
|
|
|
/** If <b>run</b> is set to true, then RetroShare will run on system boot. */
|
2008-08-14 20:23:27 -04:00
|
|
|
void
|
2010-12-11 17:46:14 -05:00
|
|
|
RshareSettings::setRunRetroshareOnBoot(bool run, bool minimized)
|
2008-08-14 20:23:27 -04:00
|
|
|
{
|
|
|
|
#if defined(Q_WS_WIN)
|
2014-07-24 12:52:11 -04:00
|
|
|
if (run) {
|
|
|
|
QString value = "\"" + QDir::convertSeparators(QCoreApplication::applicationFilePath()) + "\"";
|
2010-12-11 17:46:14 -05:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
if (minimized) {
|
|
|
|
value += " -m";
|
|
|
|
}
|
2010-12-11 17:46:14 -05:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
win32_registry_set_key_value(STARTUP_REG_KEY, RETROSHARE_REG_KEY, value);
|
|
|
|
} else {
|
|
|
|
win32_registry_remove_key(STARTUP_REG_KEY, RETROSHARE_REG_KEY);
|
|
|
|
}
|
2008-08-14 20:23:27 -04:00
|
|
|
#else
|
2014-07-24 12:52:11 -04:00
|
|
|
/* Platforms othe rthan windows aren't supported yet */
|
|
|
|
Q_UNUSED(run);
|
|
|
|
Q_UNUSED(minimized);
|
2011-04-14 17:59:51 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-08-12 10:06:29 -04:00
|
|
|
#if defined(Q_WS_WIN)
|
2011-04-14 17:59:51 -04:00
|
|
|
static QString getAppPathForProtocol()
|
|
|
|
{
|
|
|
|
return "\"" + QDir::convertSeparators(QCoreApplication::applicationFilePath()) + "\" -r \"%1\"";
|
|
|
|
}
|
2011-08-12 10:06:29 -04:00
|
|
|
#endif
|
2011-04-14 17:59:51 -04:00
|
|
|
|
|
|
|
/** Returns true if retroshare:// is registered as protocol */
|
|
|
|
bool RshareSettings::getRetroShareProtocol()
|
|
|
|
{
|
|
|
|
#if defined(Q_WS_WIN)
|
|
|
|
/* Check key */
|
|
|
|
QSettings retroshare("HKEY_CLASSES_ROOT\\retroshare", QSettings::NativeFormat);
|
|
|
|
if (retroshare.contains("Default")) {
|
|
|
|
/* Check profile */
|
2014-03-21 10:50:34 -04:00
|
|
|
if (retroshare.value("Profile").toString().toStdString() == rsPeers->getOwnId().toStdString()) {
|
2011-04-14 17:59:51 -04:00
|
|
|
/* Check app path */
|
|
|
|
QSettings command("HKEY_CLASSES_ROOT\\retroshare\\shell\\open\\command", QSettings::NativeFormat);
|
|
|
|
if (command.value("Default").toString() == getAppPathForProtocol()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
/* Platforms other than windows aren't supported yet */
|
|
|
|
#endif
|
2011-04-14 19:58:30 -04:00
|
|
|
return false;
|
2011-04-14 17:59:51 -04:00
|
|
|
}
|
|
|
|
|
2011-08-16 20:06:44 -04:00
|
|
|
/** Returns true if the user can set retroshare as protocol */
|
|
|
|
bool RshareSettings::canSetRetroShareProtocol()
|
|
|
|
{
|
|
|
|
#if defined(Q_WS_WIN)
|
|
|
|
QSettings retroshare("HKEY_CLASSES_ROOT\\retroshare", QSettings::NativeFormat);
|
|
|
|
return retroshare.isWritable();
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
/** Register retroshare:// as protocol */
|
2011-08-16 20:06:44 -04:00
|
|
|
bool RshareSettings::setRetroShareProtocol(bool value)
|
2011-04-14 17:59:51 -04:00
|
|
|
{
|
|
|
|
#if defined(Q_WS_WIN)
|
|
|
|
if (value) {
|
|
|
|
QSettings retroshare("HKEY_CLASSES_ROOT\\retroshare", QSettings::NativeFormat);
|
|
|
|
retroshare.setValue("Default", "URL: RetroShare protocol");
|
2011-08-16 20:06:44 -04:00
|
|
|
|
|
|
|
QSettings::Status state = retroshare.status();
|
|
|
|
if (state == QSettings::AccessError) {
|
|
|
|
return false;
|
|
|
|
}
|
2011-04-14 17:59:51 -04:00
|
|
|
retroshare.setValue("URL Protocol", "");
|
2014-03-21 10:50:34 -04:00
|
|
|
retroshare.setValue("Profile", QString::fromStdString(rsPeers->getOwnId().toStdString()));
|
2011-04-14 17:59:51 -04:00
|
|
|
|
|
|
|
QSettings command("HKEY_CLASSES_ROOT\\retroshare\\shell\\open\\command", QSettings::NativeFormat);
|
|
|
|
command.setValue("Default", getAppPathForProtocol());
|
2011-08-16 20:06:44 -04:00
|
|
|
state = command.status();
|
2011-04-14 17:59:51 -04:00
|
|
|
} else {
|
|
|
|
QSettings retroshare("HKEY_CLASSES_ROOT", QSettings::NativeFormat);
|
|
|
|
retroshare.remove("retroshare");
|
2011-08-16 20:06:44 -04:00
|
|
|
|
|
|
|
QSettings::Status state = retroshare.status();
|
|
|
|
if (state == QSettings::AccessError) {
|
|
|
|
return false;
|
|
|
|
}
|
2011-04-14 17:59:51 -04:00
|
|
|
}
|
2011-08-16 20:06:44 -04:00
|
|
|
|
|
|
|
return true;
|
2011-04-14 17:59:51 -04:00
|
|
|
#else
|
2011-08-16 20:06:44 -04:00
|
|
|
/* Platforms other than windows aren't supported yet */
|
2011-04-14 17:59:51 -04:00
|
|
|
Q_UNUSED(value);
|
2011-08-16 20:06:44 -04:00
|
|
|
|
|
|
|
return false;
|
2008-08-14 20:23:27 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Saving Generic Widget Size / Location */
|
|
|
|
|
|
|
|
void RshareSettings::saveWidgetInformation(QWidget *widget)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
beginGroup("widgetInformation");
|
|
|
|
beginGroup(widget->objectName());
|
2008-08-14 20:23:27 -04:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
setValue("size", widget->size());
|
|
|
|
setValue("pos", widget->pos());
|
2008-08-14 20:23:27 -04:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
endGroup();
|
|
|
|
endGroup();
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::saveWidgetInformation(QMainWindow *widget, QToolBar *toolBar)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
beginGroup("widgetInformation");
|
|
|
|
beginGroup(widget->objectName());
|
|
|
|
|
|
|
|
setValue("toolBarArea", widget->toolBarArea(toolBar));
|
2008-08-14 20:23:27 -04:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
endGroup();
|
|
|
|
endGroup();
|
2008-08-14 20:23:27 -04:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
saveWidgetInformation(widget);
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::loadWidgetInformation(QWidget *widget)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
beginGroup("widgetInformation");
|
|
|
|
beginGroup(widget->objectName());
|
2008-08-14 20:23:27 -04:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
widget->resize(value("size", widget->size()).toSize());
|
|
|
|
widget->move(value("pos", QPoint(200, 200)).toPoint());
|
|
|
|
|
|
|
|
endGroup();
|
|
|
|
endGroup();
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::loadWidgetInformation(QMainWindow *widget, QToolBar *toolBar)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
beginGroup("widgetInformation");
|
|
|
|
beginGroup(widget->objectName());
|
|
|
|
|
|
|
|
widget->addToolBar((Qt::ToolBarArea) value("toolBarArea", Qt::TopToolBarArea).toInt(),
|
|
|
|
toolBar);
|
|
|
|
|
|
|
|
endGroup();
|
|
|
|
endGroup();
|
|
|
|
|
|
|
|
loadWidgetInformation(widget);
|
2008-08-14 20:23:27 -04:00
|
|
|
}
|
|
|
|
|
2010-11-04 07:14:47 -04:00
|
|
|
/* MainWindow */
|
|
|
|
int RshareSettings::getLastPageInMainWindow ()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return valueFromGroup("MainWindow", "LastPage", MainWindow::Network).toInt();
|
2010-11-04 07:14:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setLastPageInMainWindow (int value)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValueToGroup("MainWindow", "LastPage", value);
|
2010-11-04 07:14:47 -04:00
|
|
|
}
|
|
|
|
|
2011-01-07 11:56:57 -05:00
|
|
|
uint RshareSettings::getStatusBarFlags()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
/* Default = All but disc status */
|
|
|
|
return valueFromGroup("MainWindow", "StatusBarFlags", 0xFFFFFFFF ^ STATUSBAR_DISC).toUInt();
|
2011-01-07 11:56:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setStatusBarFlags(uint flags)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValueToGroup("MainWindow", "StatusBarFlags", flags);
|
2011-01-07 11:56:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setStatusBarFlag(uint flag, bool enable)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
uint flags = getStatusBarFlags();
|
2011-01-07 11:56:57 -05:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
if (enable) {
|
|
|
|
flags |= flag;
|
|
|
|
} else {
|
|
|
|
flags &= ~flag;
|
|
|
|
}
|
2011-01-07 11:56:57 -05:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
setStatusBarFlags(flags);
|
2011-01-07 11:56:57 -05:00
|
|
|
}
|
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
/* Message */
|
2010-05-23 13:21:30 -04:00
|
|
|
bool RshareSettings::getMsgSetToReadOnActivate ()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return valueFromGroup("Message", "SetMsgToReadOnActivate", true).toBool();
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
|
|
|
|
2013-01-05 21:30:10 -05:00
|
|
|
void RshareSettings::setMsgSetToReadOnActivate (bool value)
|
2010-05-23 13:21:30 -04:00
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValueToGroup("Message", "SetMsgToReadOnActivate", value);
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
2010-07-21 03:39:14 -04:00
|
|
|
|
2013-09-23 15:53:26 -04:00
|
|
|
bool RshareSettings::getMsgLoadEmbeddedImages()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return valueFromGroup("Message", "LoadEmbeddedImages", false).toBool();
|
2013-09-23 15:53:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setMsgLoadEmbeddedImages(bool value)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValueToGroup("Message", "LoadEmbeddedImages", value);
|
2013-09-23 15:53:26 -04:00
|
|
|
}
|
|
|
|
|
2011-06-03 20:46:02 -04:00
|
|
|
RshareSettings::enumMsgOpen RshareSettings::getMsgOpen()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
enumMsgOpen value = (enumMsgOpen) valueFromGroup("Message", "msgOpen", MSG_OPEN_TAB).toInt();
|
2011-06-03 20:46:02 -04:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
switch (value) {
|
|
|
|
case MSG_OPEN_TAB:
|
|
|
|
case MSG_OPEN_WINDOW:
|
|
|
|
return value;
|
|
|
|
}
|
2011-06-03 20:46:02 -04:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
return MSG_OPEN_TAB;
|
2011-06-03 20:46:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setMsgOpen(enumMsgOpen value)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
switch (value) {
|
|
|
|
case MSG_OPEN_TAB:
|
|
|
|
case MSG_OPEN_WINDOW:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
value = MSG_OPEN_TAB;
|
|
|
|
}
|
2011-06-03 20:46:02 -04:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
setValueToGroup("Message", "msgOpen", value);
|
2011-06-03 20:46:02 -04:00
|
|
|
}
|
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
/* Forum */
|
2010-08-08 18:58:10 -04:00
|
|
|
bool RshareSettings::getForumMsgSetToReadOnActivate ()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return valueFromGroup("Forum", "SetMsgToReadOnActivate", true).toBool();
|
2010-08-08 18:58:10 -04:00
|
|
|
}
|
|
|
|
|
2013-01-05 21:30:10 -05:00
|
|
|
void RshareSettings::setForumMsgSetToReadOnActivate(bool value)
|
2010-08-08 18:58:10 -04:00
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValueToGroup("Forum", "SetMsgToReadOnActivate", value);
|
2010-08-08 18:58:10 -04:00
|
|
|
}
|
|
|
|
|
2013-01-05 21:30:10 -05:00
|
|
|
bool RshareSettings::getForumExpandNewMessages()
|
2010-08-08 18:58:10 -04:00
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
return valueFromGroup("Forum", "ExpandNewMessages", true).toBool();
|
2010-08-08 18:58:10 -04:00
|
|
|
}
|
|
|
|
|
2013-01-05 21:30:10 -05:00
|
|
|
void RshareSettings::setForumExpandNewMessages(bool value)
|
2010-08-08 18:58:10 -04:00
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
setValueToGroup("Forum", "ExpandNewMessages", value);
|
2013-01-05 21:30:10 -05:00
|
|
|
}
|
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
bool RshareSettings::getForumLoadEmbeddedImages()
|
|
|
|
{
|
|
|
|
return valueFromGroup("Forum", "LoadEmbeddedImages", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setForumLoadEmbeddedImages(bool value)
|
|
|
|
{
|
|
|
|
setValueToGroup("Forum", "LoadEmbeddedImages", value);
|
|
|
|
}
|
|
|
|
|
2014-08-06 13:41:22 -04:00
|
|
|
/* Channel */
|
|
|
|
bool RshareSettings::getChannelLoadThread()
|
|
|
|
{
|
|
|
|
return valueFromGroup("Channel", "LoadThread", true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setChannelLoadThread(bool value)
|
|
|
|
{
|
|
|
|
setValueToGroup("Channel", "LoadThread", value);
|
|
|
|
}
|
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
/* GroupFrame settings */
|
2014-07-24 10:54:23 -04:00
|
|
|
static QString groupFrameSettingsTypeToString(GroupFrameSettings::Type type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case GroupFrameSettings::Nothing:
|
|
|
|
return "";
|
|
|
|
case GroupFrameSettings::Forum:
|
|
|
|
return "Forum";
|
|
|
|
case GroupFrameSettings::Channel:
|
|
|
|
return "Channel";
|
|
|
|
case GroupFrameSettings::Posted:
|
|
|
|
return "Posted";
|
|
|
|
}
|
2010-08-08 18:58:10 -04:00
|
|
|
|
2014-07-24 10:54:23 -04:00
|
|
|
return "";
|
2014-07-14 17:29:51 -04:00
|
|
|
}
|
|
|
|
|
2014-07-24 10:54:23 -04:00
|
|
|
bool RshareSettings::getGroupFrameSettings(GroupFrameSettings::Type type, GroupFrameSettings &groupFrameSettings)
|
2014-07-14 17:29:51 -04:00
|
|
|
{
|
2014-07-24 10:54:23 -04:00
|
|
|
QString group = groupFrameSettingsTypeToString(type);
|
|
|
|
if (group.isEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-14 17:29:51 -04:00
|
|
|
|
2014-07-24 10:54:23 -04:00
|
|
|
groupFrameSettings.mOpenAllInNewTab = valueFromGroup(group, "OpenAllInNewTab", false).toBool();
|
|
|
|
groupFrameSettings.mHideTabBarWithOneTab = valueFromGroup(group, "HideTabBarWithOneTab", true).toBool();
|
2014-05-08 13:17:48 -04:00
|
|
|
|
2014-07-24 10:54:23 -04:00
|
|
|
return true;
|
2014-05-08 13:17:48 -04:00
|
|
|
}
|
|
|
|
|
2014-07-24 10:54:23 -04:00
|
|
|
void RshareSettings::setGroupFrameSettings(GroupFrameSettings::Type type, const GroupFrameSettings &groupFrameSettings)
|
2014-07-14 17:29:51 -04:00
|
|
|
{
|
2014-07-24 10:54:23 -04:00
|
|
|
QString group = groupFrameSettingsTypeToString(type);
|
|
|
|
if (group.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
2014-07-14 17:29:51 -04:00
|
|
|
|
2014-07-24 10:54:23 -04:00
|
|
|
setValueToGroup(group, "OpenAllInNewTab", groupFrameSettings.mOpenAllInNewTab);
|
|
|
|
setValueToGroup(group, "HideTabBarWithOneTab", groupFrameSettings.mHideTabBarWithOneTab);
|
2014-07-14 17:29:51 -04:00
|
|
|
}
|
|
|
|
|
2010-07-21 03:39:14 -04:00
|
|
|
/* time before idle */
|
|
|
|
uint RshareSettings::getMaxTimeBeforeIdle()
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
if (m_maxTimeBeforeIdle == -1) {
|
|
|
|
m_maxTimeBeforeIdle = value("maxTimeBeforeIdle", 300).toUInt();
|
|
|
|
}
|
2010-07-21 03:39:14 -04:00
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
return m_maxTimeBeforeIdle;
|
2010-07-21 03:39:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setMaxTimeBeforeIdle(uint nValue)
|
|
|
|
{
|
2014-07-24 12:52:11 -04:00
|
|
|
m_maxTimeBeforeIdle = nValue;
|
|
|
|
setValue("maxTimeBeforeIdle", nValue);
|
2013-09-23 15:53:26 -04:00
|
|
|
}
|