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.
|
|
|
|
****************************************************************/
|
|
|
|
|
2015-10-20 22:00:15 -04:00
|
|
|
#include <math.h>
|
2008-08-14 20:23:27 -04:00
|
|
|
#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
|
|
|
|
2015-08-29 15:31:01 -04:00
|
|
|
#if defined(Q_OS_WIN)
|
2008-08-14 20:23:27 -04:00
|
|
|
#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
|
|
|
|
|
2015-08-29 15:31:01 -04:00
|
|
|
#if defined(Q_OS_WIN)
|
2008-08-14 20:23:27 -04:00
|
|
|
#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
|
|
|
{
|
2016-06-02 07:22:24 -04:00
|
|
|
#ifdef Q_OS_LINUX
|
|
|
|
// use GTK as default style on linux
|
2015-05-19 20:05:47 -04:00
|
|
|
setDefault(SETTING_STYLE, "GTK+");
|
|
|
|
#else
|
2015-08-29 15:31:01 -04:00
|
|
|
#if defined(Q_OS_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();
|
2015-08-29 15:31:01 -04:00
|
|
|
#if defined(Q_OS_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");
|
|
|
|
}
|
2015-05-19 20:05:47 -04:00
|
|
|
#endif
|
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);
|
2015-06-16 14:41:13 -04:00
|
|
|
uint defNewsFeed = (RS_FEED_TYPE_MSG | RS_FEED_TYPE_FILES | RS_FEED_TYPE_SECURITY | RS_FEED_TYPE_SECURITY_IP);
|
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()
|
|
|
|
{
|
2015-05-19 20:05:47 -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()
|
|
|
|
{
|
2015-04-19 11:34:14 -04:00
|
|
|
return value(SETTING_PAGEBUTTONLOC, true).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
|
|
|
}
|
|
|
|
|
2015-10-20 22:00:15 -04:00
|
|
|
int RshareSettings::computeBestIconSize(int n_sizes,int *sizes,int recommended_size)
|
|
|
|
{
|
|
|
|
float default_size = QFontMetricsF(QWidget().font()).height()/16.0 * recommended_size ;
|
|
|
|
float closest_ratio_dist = 10000.0f ;
|
|
|
|
int best_default_size = sizes[0] ;
|
|
|
|
|
|
|
|
for(int i=0;i<n_sizes;++i)
|
|
|
|
{
|
|
|
|
float ratio = default_size / sizes[i] ;
|
|
|
|
|
|
|
|
if(fabsf(ratio - 1.0f) < closest_ratio_dist)
|
|
|
|
{
|
|
|
|
closest_ratio_dist = fabsf(ratio-1.0f) ;
|
|
|
|
best_default_size = sizes[i] ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return best_default_size ;
|
|
|
|
}
|
|
|
|
|
2014-05-09 22:38:47 -04:00
|
|
|
/** Gets the tool button's size.*/
|
|
|
|
int RshareSettings::getToolButtonSize()
|
|
|
|
{
|
2015-10-20 22:00:15 -04:00
|
|
|
static int sizes[6] = { 8,16,24,32,64,128 } ;
|
|
|
|
|
|
|
|
return value(SETTING_TOOLBUTTONSIZE, computeBestIconSize(6,sizes,24)).toInt();
|
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);
|
2015-06-29 12:08:17 -04:00
|
|
|
break;
|
|
|
|
case 64:
|
|
|
|
setValue(SETTING_TOOLBUTTONSIZE, 64);
|
|
|
|
break;
|
|
|
|
case 128:
|
|
|
|
setValue(SETTING_TOOLBUTTONSIZE, 128);
|
|
|
|
break;
|
|
|
|
}
|
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()
|
|
|
|
{
|
2015-10-20 22:00:15 -04:00
|
|
|
static int sizes[6] = { 8,16,24,32,64,128 } ;
|
|
|
|
|
|
|
|
return value(SETTING_LISTITEMICONSIZE, computeBestIconSize(6,sizes,24)).toInt();
|
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);
|
2015-06-29 12:08:17 -04:00
|
|
|
break ;
|
|
|
|
case 64:
|
|
|
|
setValue(SETTING_LISTITEMICONSIZE, 64);
|
|
|
|
break ;
|
|
|
|
case 128:
|
|
|
|
setValue(SETTING_LISTITEMICONSIZE, 128);
|
|
|
|
break ;
|
|
|
|
}
|
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";
|
2016-08-09 17:32:25 -04:00
|
|
|
case RshareSettings::LASTDIR_PLUGIN:
|
|
|
|
return "PLUGIN";
|
2014-07-24 12:52:11 -04:00
|
|
|
}
|
|
|
|
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-10-01 10:55:35 -04:00
|
|
|
return value("MessageFlags", RS_MESSAGE_CONNECT_ATTEMPT).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-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);
|
|
|
|
}
|
|
|
|
|
2017-01-20 14:26:50 -05:00
|
|
|
bool RshareSettings::getChatDoNotSendIsTyping()
|
|
|
|
{
|
|
|
|
return valueFromGroup("Chat", "DoNotSendIsTyping", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setChatDoNotSendIsTyping(bool bValue)
|
|
|
|
{
|
|
|
|
setValueToGroup("Chat", "DoNotSendIsTyping", bValue);
|
|
|
|
}
|
|
|
|
|
2016-01-27 14:27:44 -05:00
|
|
|
bool RshareSettings::getChatSendAsPlainTextByDef()
|
|
|
|
{
|
|
|
|
return valueFromGroup("Chat", "SendAsPlainTextByDef", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setChatSendAsPlainTextByDef(bool bValue)
|
|
|
|
{
|
|
|
|
setValueToGroup("Chat", "SendAsPlainTextByDef", bValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RshareSettings::getChatSearchShowBarByDefault()
|
|
|
|
{
|
|
|
|
return valueFromGroup("Chat", "SearchShowBarByDefault", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setChatSearchShowBarByDefault(bool bValue)
|
|
|
|
{
|
|
|
|
setValueToGroup("Chat", "SearchShowBarByDefault", bValue);
|
|
|
|
}
|
|
|
|
|
2014-05-26 17:51:53 -04:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2016-08-09 17:32:25 -04:00
|
|
|
bool RshareSettings::getChatLoadEmbeddedImages()
|
|
|
|
{
|
|
|
|
return valueFromGroup("Chat", "LoadEmbeddedImages", true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setChatLoadEmbeddedImages(bool value)
|
|
|
|
{
|
|
|
|
setValueToGroup("Chat", "LoadEmbeddedImages", value);
|
|
|
|
}
|
|
|
|
|
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-10-25 13:09:06 -04:00
|
|
|
stylePath = valueFromGroup("Chat", "StylePublic", ":/qss/chat/compact/public").toString();
|
2014-07-24 12:52:11 -04:00
|
|
|
// 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";
|
|
|
|
}
|
2014-10-25 13:09:06 -04:00
|
|
|
styleVariant = valueFromGroup("Chat", "StylePublicVariant", "Colored").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
|
|
|
|
2015-08-29 15:31:01 -04:00
|
|
|
#if defined(Q_OS_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
|
|
|
{
|
2015-08-29 15:31:01 -04:00
|
|
|
#if defined(Q_OS_WIN)
|
2014-07-24 12:52:11 -04:00
|
|
|
if (run) {
|
2015-08-29 15:31:01 -04:00
|
|
|
QString value = "\"" + QDir::toNativeSeparators(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
|
|
|
|
}
|
|
|
|
|
|
|
|
static QString getAppPathForProtocol()
|
|
|
|
{
|
2016-03-01 07:08:33 -05:00
|
|
|
#if defined(Q_OS_WIN)
|
2015-08-29 15:31:01 -04:00
|
|
|
return "\"" + QDir::toNativeSeparators(QCoreApplication::applicationFilePath()) + "\" -r \"%1\"";
|
2016-03-01 07:08:33 -05:00
|
|
|
#elif defined(Q_OS_LINUX)
|
|
|
|
return QDir::toNativeSeparators(QCoreApplication::applicationFilePath()) + " %U";
|
2011-08-12 10:06:29 -04:00
|
|
|
#endif
|
2016-03-01 07:08:33 -05:00
|
|
|
}
|
2011-04-14 17:59:51 -04:00
|
|
|
|
|
|
|
/** Returns true if retroshare:// is registered as protocol */
|
|
|
|
bool RshareSettings::getRetroShareProtocol()
|
|
|
|
{
|
2015-08-29 15:31:01 -04:00
|
|
|
#if defined(Q_OS_WIN)
|
2011-04-14 17:59:51 -04:00
|
|
|
/* Check key */
|
2016-03-01 07:08:33 -05:00
|
|
|
QSettings retroshare("HKEY_CURRENT_USER\\Software\\Classes\\retroshare", QSettings::NativeFormat);
|
2011-04-14 17:59:51 -04:00
|
|
|
if (retroshare.contains("Default")) {
|
2016-03-01 07:08:33 -05:00
|
|
|
/* URL Protocol */
|
|
|
|
if (retroshare.contains("URL Protocol")) {
|
2011-04-14 17:59:51 -04:00
|
|
|
/* Check app path */
|
2016-03-01 07:08:33 -05:00
|
|
|
QSettings command("HKEY_CURRENT_USER\\Software\\Classes\\retroshare\\shell\\open\\command", QSettings::NativeFormat);
|
2011-04-14 17:59:51 -04:00
|
|
|
if (command.value("Default").toString() == getAppPathForProtocol()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-03-01 07:08:33 -05:00
|
|
|
#elif defined(Q_OS_LINUX)
|
2016-10-08 06:12:26 -04:00
|
|
|
QFile desktop("/usr/share/applications/retroshare06.desktop");
|
|
|
|
if (!desktop.exists()) {
|
|
|
|
desktop.setFileName("/usr/share/applications/RetroShare06.desktop");
|
|
|
|
}
|
2016-03-01 07:08:33 -05:00
|
|
|
if (desktop.exists()) {
|
|
|
|
desktop.open(QIODevice::ReadOnly | QIODevice::Text);
|
|
|
|
QTextStream in(&desktop);
|
|
|
|
QStringList lines;
|
|
|
|
while(!in.atEnd()) {
|
|
|
|
lines << in.readLine();
|
|
|
|
}
|
|
|
|
desktop.close();
|
|
|
|
if (lines.contains("Exec=" + getAppPathForProtocol()))
|
2016-10-13 07:26:44 -04:00
|
|
|
if (lines.contains("MimeType=x-scheme-handler/retroshare;"))
|
2016-03-01 07:08:33 -05:00
|
|
|
return true;
|
|
|
|
}
|
2011-04-14 17:59:51 -04:00
|
|
|
#else
|
2016-03-01 07:08:33 -05:00
|
|
|
/* Platforms not supported yet */
|
2011-04-14 17:59:51 -04:00
|
|
|
#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()
|
|
|
|
{
|
2015-08-29 15:31:01 -04:00
|
|
|
#if defined(Q_OS_WIN)
|
2016-03-01 07:08:33 -05:00
|
|
|
QSettings classRoot("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
|
|
|
|
return classRoot.isWritable();
|
|
|
|
#elif defined(Q_OS_LINUX)
|
|
|
|
return RshareSettings::getRetroShareProtocol();
|
2011-08-16 20:06:44 -04:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-07-24 12:52:11 -04:00
|
|
|
/** Register retroshare:// as protocol */
|
2016-03-01 07:08:33 -05:00
|
|
|
bool RshareSettings::setRetroShareProtocol(bool value, QString &error)
|
2011-04-14 17:59:51 -04:00
|
|
|
{
|
2016-03-01 07:08:33 -05:00
|
|
|
error = "";
|
2015-08-29 15:31:01 -04:00
|
|
|
#if defined(Q_OS_WIN)
|
2011-04-14 17:59:51 -04:00
|
|
|
if (value) {
|
2016-03-01 07:08:33 -05:00
|
|
|
QSettings retroshare("HKEY_CURRENT_USER\\Software\\Classes\\retroshare", QSettings::NativeFormat);
|
2011-04-14 17:59:51 -04:00
|
|
|
retroshare.setValue("Default", "URL: RetroShare protocol");
|
2011-08-16 20:06:44 -04:00
|
|
|
|
|
|
|
QSettings::Status state = retroshare.status();
|
|
|
|
if (state == QSettings::AccessError) {
|
2016-03-01 07:08:33 -05:00
|
|
|
error = tr("Registry Access Error. Maybe you need Administrator right.");
|
2011-08-16 20:06:44 -04:00
|
|
|
return false;
|
|
|
|
}
|
2011-04-14 17:59:51 -04:00
|
|
|
retroshare.setValue("URL Protocol", "");
|
|
|
|
|
2016-03-01 07:08:33 -05:00
|
|
|
QSettings command("HKEY_CURRENT_USER\\Software\\Classes\\retroshare\\shell\\open\\command", QSettings::NativeFormat);
|
2011-04-14 17:59:51 -04:00
|
|
|
command.setValue("Default", getAppPathForProtocol());
|
2011-08-16 20:06:44 -04:00
|
|
|
state = command.status();
|
2011-04-14 17:59:51 -04:00
|
|
|
} else {
|
2016-03-01 07:08:33 -05:00
|
|
|
QSettings classRoot("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
|
|
|
|
classRoot.remove("retroshare");
|
2011-08-16 20:06:44 -04:00
|
|
|
|
2016-03-01 07:08:33 -05:00
|
|
|
QSettings::Status state = classRoot.status();
|
2011-08-16 20:06:44 -04:00
|
|
|
if (state == QSettings::AccessError) {
|
2016-03-01 07:08:33 -05:00
|
|
|
error = tr("Registry Access Error. Maybe you need Administrator right.");
|
2011-08-16 20:06:44 -04:00
|
|
|
return false;
|
|
|
|
}
|
2011-04-14 17:59:51 -04:00
|
|
|
}
|
2011-08-16 20:06:44 -04:00
|
|
|
|
2016-03-01 07:08:33 -05:00
|
|
|
return true;
|
|
|
|
#elif defined(Q_OS_LINUX)
|
|
|
|
/* RetroShare protocol is always activated for Linux */
|
|
|
|
Q_UNUSED(value);
|
2011-08-16 20:06:44 -04:00
|
|
|
return true;
|
2011-04-14 17:59:51 -04:00
|
|
|
#else
|
2016-03-01 07:08:33 -05:00
|
|
|
/* Platforms not 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
|
|
|
|
}
|
|
|
|
|
2016-03-01 07:08:33 -05:00
|
|
|
/** Returns true if this instance have to run Local Server*/
|
|
|
|
bool RshareSettings::getUseLocalServer()
|
|
|
|
{
|
|
|
|
return value("UseLocalServer", true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Sets whether to run Local Server */
|
|
|
|
void RshareSettings::setUseLocalServer(bool value)
|
|
|
|
{
|
|
|
|
if (value != getUseLocalServer()) {
|
|
|
|
setValue("UseLocalServer", value);
|
|
|
|
Rshare::updateLocalServer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-14 20:23:27 -04:00
|
|
|
/** 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();
|
|
|
|
}
|
2017-01-18 15:22:38 -05:00
|
|
|
bool RshareSettings::getForumLoadEmoticons()
|
|
|
|
{
|
|
|
|
return valueFromGroup("Forum", "LoadEmoticons", false).toBool();
|
|
|
|
}
|
2014-07-24 12:52:11 -04:00
|
|
|
void RshareSettings::setForumLoadEmbeddedImages(bool value)
|
|
|
|
{
|
|
|
|
setValueToGroup("Forum", "LoadEmbeddedImages", value);
|
|
|
|
}
|
2017-01-18 15:22:38 -05:00
|
|
|
void RshareSettings::setForumLoadEmoticons(bool value)
|
|
|
|
{
|
|
|
|
setValueToGroup("Forum", "LoadEmoticons", 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
|
|
|
}
|
2015-04-24 10:31:13 -04:00
|
|
|
|
|
|
|
bool RshareSettings::getWebinterfaceEnabled()
|
|
|
|
{
|
|
|
|
return valueFromGroup("Webinterface", "enabled", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setWebinterfaceEnabled(bool enabled)
|
|
|
|
{
|
|
|
|
setValueToGroup("Webinterface", "enabled", enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t RshareSettings::getWebinterfacePort()
|
|
|
|
{
|
|
|
|
return valueFromGroup("Webinterface", "port", 9090).toUInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setWebinterfacePort(uint16_t port)
|
|
|
|
{
|
|
|
|
setValueToGroup("Webinterface", "port", port);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RshareSettings::getWebinterfaceAllowAllIps()
|
|
|
|
{
|
|
|
|
return valueFromGroup("Webinterface", "allowAllIps", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RshareSettings::setWebinterfaceAllowAllIps(bool allow_all)
|
|
|
|
{
|
|
|
|
setValueToGroup("Webinterface", "allowAllIps", allow_all);
|
|
|
|
}
|
2017-02-25 17:52:57 -05:00
|
|
|
|
2017-02-25 18:16:36 -05:00
|
|
|
bool RshareSettings::getPageAlreadyDisplayed(const QString& page_name)
|
2017-02-25 17:52:57 -05:00
|
|
|
{
|
2017-02-25 18:16:36 -05:00
|
|
|
return valueFromGroup("PageAlreadyDisplayed",page_name,false).toBool();
|
2017-02-25 17:52:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-25 18:16:36 -05:00
|
|
|
void RshareSettings::setPageAlreadyDisplayed(const QString& page_name,bool b)
|
2017-02-25 17:52:57 -05:00
|
|
|
{
|
2017-02-25 18:16:36 -05:00
|
|
|
return setValueToGroup("PageAlreadyDisplayed",page_name,b);
|
2017-02-25 17:52:57 -05:00
|
|
|
}
|