2009-07-23 13:11:51 -04:00
|
|
|
/****************************************************************
|
|
|
|
* This file is distributed under the following license:
|
|
|
|
*
|
2009-08-17 17:19:50 -04:00
|
|
|
* Copyright (c) 2009 RetroShare Team
|
2009-07-23 13:11:51 -04:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2009-08-19 18:15:16 -04:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2009-07-23 13:11:51 -04:00
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
2011-08-16 20:06:44 -04:00
|
|
|
#include <QMessageBox>
|
2010-04-08 07:55:10 -04:00
|
|
|
#include <iostream>
|
|
|
|
#include <rshare.h>
|
2011-07-30 13:13:08 -04:00
|
|
|
#include "retroshare/rsinit.h"
|
|
|
|
#include "retroshare/rsconfig.h"
|
|
|
|
|
2009-08-17 17:19:50 -04:00
|
|
|
#include "GeneralPage.h"
|
2009-07-23 13:11:51 -04:00
|
|
|
#include <util/stringutil.h>
|
|
|
|
#include <QSystemTrayIcon>
|
2010-05-11 16:02:52 -04:00
|
|
|
#include "rsharesettings.h"
|
2013-02-22 16:42:27 -05:00
|
|
|
#include <gui/QuickStartWizard.h>
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2009-08-17 17:19:50 -04:00
|
|
|
/** Constructor */
|
2013-10-18 17:10:33 -04:00
|
|
|
GeneralPage::GeneralPage(QWidget * parent, Qt::WindowFlags flags)
|
2009-08-19 18:15:16 -04:00
|
|
|
: ConfigPage(parent, flags)
|
2009-07-23 13:11:51 -04:00
|
|
|
{
|
2011-08-16 20:06:44 -04:00
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
ui.setupUi(this);
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2013-08-08 08:46:32 -04:00
|
|
|
/* Connect signals */
|
|
|
|
connect(ui.runStartWizard_PB,SIGNAL(clicked()), this,SLOT(runStartWizard())) ;
|
|
|
|
|
2011-08-16 20:06:44 -04:00
|
|
|
/* Hide platform specific features */
|
2015-08-29 15:31:01 -04:00
|
|
|
#ifdef Q_OS_WIN
|
2013-08-08 08:46:32 -04:00
|
|
|
|
|
|
|
#ifdef QT_DEBUG
|
|
|
|
ui.chkRunRetroshareAtSystemStartup->setEnabled(false);
|
|
|
|
ui.chkRunRetroshareAtSystemStartupMinimized->setEnabled(false);
|
|
|
|
#endif
|
|
|
|
|
2011-08-16 20:06:44 -04:00
|
|
|
if (Settings->canSetRetroShareProtocol() == false) {
|
|
|
|
ui.enableRetroShareProtocol->setEnabled(false);
|
|
|
|
} else {
|
|
|
|
ui.adminLabel->setEnabled(false);
|
|
|
|
ui.adminLabel->setToolTip("");
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
ui.chkRunRetroshareAtSystemStartup->setVisible(false);
|
|
|
|
ui.chkRunRetroshareAtSystemStartupMinimized->setVisible(false);
|
|
|
|
ui.enableRetroShareProtocol->setVisible(false);
|
|
|
|
ui.adminLabel->setVisible(false);
|
2009-08-19 18:15:16 -04:00
|
|
|
#endif
|
2009-07-23 13:11:51 -04:00
|
|
|
}
|
|
|
|
|
2009-08-17 17:19:50 -04:00
|
|
|
/** Destructor */
|
2010-05-07 19:58:17 -04:00
|
|
|
GeneralPage::~GeneralPage()
|
2009-07-23 13:11:51 -04:00
|
|
|
{
|
2010-05-07 19:58:17 -04:00
|
|
|
}
|
2013-02-22 16:42:27 -05:00
|
|
|
void GeneralPage::runStartWizard()
|
|
|
|
{
|
|
|
|
QuickStartWizard(this).exec();
|
|
|
|
}
|
2009-07-23 13:11:51 -04:00
|
|
|
|
|
|
|
/** Saves the changes on this page */
|
2011-08-12 10:06:29 -04:00
|
|
|
bool GeneralPage::save(QString &/*errmsg*/)
|
2009-08-19 18:15:16 -04:00
|
|
|
{
|
2010-12-13 15:34:07 -05:00
|
|
|
Settings->setStartMinimized(ui.checkStartMinimized->isChecked());
|
|
|
|
Settings->setValue("doQuit", ui.checkQuit->isChecked());
|
2013-08-04 19:53:29 -04:00
|
|
|
Settings->setCloseToTray(ui.checkCloseToTray->isChecked());
|
2009-08-17 17:19:50 -04:00
|
|
|
|
2015-08-29 15:31:01 -04:00
|
|
|
#ifdef Q_OS_WIN
|
2013-08-08 08:46:32 -04:00
|
|
|
|
|
|
|
#ifndef QT_DEBUG
|
2010-12-11 17:46:14 -05:00
|
|
|
Settings->setRunRetroshareOnBoot(ui.chkRunRetroshareAtSystemStartup->isChecked(), ui.chkRunRetroshareAtSystemStartupMinimized->isChecked());
|
2013-08-08 08:46:32 -04:00
|
|
|
#endif
|
2011-04-14 17:59:51 -04:00
|
|
|
|
|
|
|
if (ui.enableRetroShareProtocol->isChecked() != Settings->getRetroShareProtocol()) {
|
2011-08-16 20:06:44 -04:00
|
|
|
if (Settings->setRetroShareProtocol(ui.enableRetroShareProtocol->isChecked()) == false) {
|
|
|
|
if (ui.enableRetroShareProtocol->isChecked()) {
|
|
|
|
QMessageBox::critical(this, tr("Error"), tr("Could not add retroshare:// as protocol."));
|
|
|
|
} else {
|
|
|
|
QMessageBox::critical(this, tr("Error"), tr("Could not remove retroshare:// protocol."));
|
|
|
|
}
|
|
|
|
}
|
2011-04-14 17:59:51 -04:00
|
|
|
}
|
2010-12-13 15:34:07 -05:00
|
|
|
#endif
|
|
|
|
|
2010-07-21 14:48:33 -04:00
|
|
|
Settings->setMaxTimeBeforeIdle(ui.spinBox->value());
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-12-13 15:34:07 -05:00
|
|
|
RsInit::setAutoLogin(ui.autoLogin->isChecked());
|
|
|
|
|
2011-07-30 13:13:08 -04:00
|
|
|
if (ui.checkAdvanced->isChecked())
|
|
|
|
{
|
|
|
|
std::string opt("YES");
|
|
|
|
rsConfig->setConfigurationOption(RS_CONFIG_ADVANCED, opt);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::string opt("NO");
|
|
|
|
rsConfig->setConfigurationOption(RS_CONFIG_ADVANCED, opt);
|
|
|
|
}
|
|
|
|
|
2009-07-23 13:11:51 -04:00
|
|
|
return true;
|
|
|
|
}
|
2009-08-19 18:15:16 -04:00
|
|
|
|
2009-07-23 13:11:51 -04:00
|
|
|
/** Loads the settings for this page */
|
2010-12-13 15:34:07 -05:00
|
|
|
void GeneralPage::load()
|
2009-08-19 18:15:16 -04:00
|
|
|
{
|
2015-08-29 15:31:01 -04:00
|
|
|
#ifdef Q_OS_WIN
|
2010-12-11 17:46:14 -05:00
|
|
|
bool minimized;
|
|
|
|
ui.chkRunRetroshareAtSystemStartup->setChecked(Settings->runRetroshareOnBoot(minimized));
|
|
|
|
ui.chkRunRetroshareAtSystemStartupMinimized->setChecked(minimized);
|
2011-04-14 17:59:51 -04:00
|
|
|
|
|
|
|
ui.enableRetroShareProtocol->setChecked(Settings->getRetroShareProtocol());
|
2010-12-13 15:34:07 -05:00
|
|
|
#endif
|
2009-08-19 18:15:16 -04:00
|
|
|
|
2010-12-13 15:34:07 -05:00
|
|
|
ui.checkStartMinimized->setChecked(Settings->getStartMinimized());
|
|
|
|
ui.checkQuit->setChecked(Settings->value("doQuit", false).toBool());
|
2009-08-17 17:19:50 -04:00
|
|
|
|
2013-08-04 19:53:29 -04:00
|
|
|
ui.checkCloseToTray->setChecked(Settings->getCloseToTray());
|
2010-07-21 14:48:33 -04:00
|
|
|
|
|
|
|
ui.spinBox->setValue(Settings->getMaxTimeBeforeIdle());
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-12-13 15:34:07 -05:00
|
|
|
ui.autoLogin->setChecked(RsInit::getAutoLogin());
|
2011-07-30 13:13:08 -04:00
|
|
|
|
|
|
|
bool advancedmode = false;
|
|
|
|
std::string advsetting;
|
|
|
|
if (rsConfig->getConfigurationOption(RS_CONFIG_ADVANCED, advsetting) && (advsetting == "YES"))
|
|
|
|
{
|
|
|
|
advancedmode = true;
|
|
|
|
}
|
|
|
|
ui.checkAdvanced->setChecked(advancedmode);
|
|
|
|
|
2010-04-08 07:55:10 -04:00
|
|
|
}
|