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.
|
|
|
|
****************************************************************/
|
|
|
|
|
2010-04-08 07:55:10 -04:00
|
|
|
#include <iostream>
|
|
|
|
#include <rshare.h>
|
2010-08-06 05:40:23 -04:00
|
|
|
#include <retroshare/rsinit.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"
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2009-08-17 17:19:50 -04:00
|
|
|
/** Constructor */
|
2009-07-23 13:11:51 -04:00
|
|
|
GeneralPage::GeneralPage(QWidget * parent, Qt::WFlags flags)
|
2009-08-19 18:15:16 -04:00
|
|
|
: ConfigPage(parent, flags)
|
2009-07-23 13:11:51 -04:00
|
|
|
{
|
2009-08-17 17:19:50 -04:00
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
ui.setupUi(this);
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-04-08 07:55:10 -04:00
|
|
|
connect(ui.autoLogin, SIGNAL(clicked()), this, SLOT(setAutoLogin()));
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2009-08-17 17:19:50 -04:00
|
|
|
/* Hide platform specific features */
|
2009-07-23 13:11:51 -04:00
|
|
|
#ifndef Q_WS_WIN
|
|
|
|
ui.chkRunRetroshareAtSystemStartup->setVisible(false);
|
2010-01-27 19:34:33 -05:00
|
|
|
|
2009-08-19 18:15:16 -04:00
|
|
|
#endif
|
2010-04-08 07:55:10 -04:00
|
|
|
|
|
|
|
ui.autoLogin->setChecked(RsInit::getAutoLogin());
|
|
|
|
|
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
|
|
|
}
|
2009-07-23 13:11:51 -04:00
|
|
|
|
|
|
|
/** Saves the changes on this page */
|
|
|
|
bool
|
|
|
|
GeneralPage::save(QString &errmsg)
|
2009-08-19 18:15:16 -04:00
|
|
|
{
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->setValue(QString::fromUtf8("StartMinimized"), startMinimized());
|
2009-08-17 17:19:50 -04:00
|
|
|
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->setValue(QString::fromUtf8("doQuit"), quit());
|
2009-09-08 08:34:18 -04:00
|
|
|
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->setValue(QString::fromUtf8("ClosetoTray"), closetoTray());
|
2010-01-08 11:32:10 -05:00
|
|
|
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->setRunRetroshareOnBoot(
|
2009-07-23 13:11:51 -04:00
|
|
|
ui.chkRunRetroshareAtSystemStartup->isChecked());
|
2010-07-21 14:48:33 -04:00
|
|
|
|
|
|
|
Settings->setMaxTimeBeforeIdle(ui.spinBox->value());
|
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 */
|
|
|
|
void
|
|
|
|
GeneralPage::load()
|
2009-08-19 18:15:16 -04:00
|
|
|
{
|
2010-05-20 17:53:27 -04:00
|
|
|
ui.chkRunRetroshareAtSystemStartup->setChecked(Settings->runRetroshareOnBoot());
|
2009-08-19 18:15:16 -04:00
|
|
|
|
2010-05-20 17:53:27 -04:00
|
|
|
ui.checkStartMinimized->setChecked(Settings->value(QString::fromUtf8("StartMinimized"), false).toBool());
|
2009-08-17 17:19:50 -04:00
|
|
|
|
2010-05-20 17:53:27 -04:00
|
|
|
ui.checkQuit->setChecked(Settings->value(QString::fromUtf8("doQuit"), false).toBool());
|
2009-09-08 08:34:18 -04:00
|
|
|
|
2010-05-20 17:53:27 -04:00
|
|
|
ui.checkClosetoTray->setChecked(Settings->value(QString::fromUtf8("ClosetoTray"), false).toBool());
|
2010-07-21 14:48:33 -04:00
|
|
|
|
|
|
|
ui.spinBox->setValue(Settings->getMaxTimeBeforeIdle());
|
2009-08-19 18:15:16 -04:00
|
|
|
|
2010-01-08 11:32:10 -05:00
|
|
|
|
2009-08-17 17:19:50 -04:00
|
|
|
}
|
2009-08-19 18:15:16 -04:00
|
|
|
|
2009-08-17 17:19:50 -04:00
|
|
|
bool GeneralPage::quit() const {
|
|
|
|
if(ui.checkQuit->isChecked()) return true;
|
|
|
|
return ui.checkQuit->isChecked();
|
2009-07-23 13:11:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GeneralPage::startMinimized() const {
|
|
|
|
if(ui.checkStartMinimized->isChecked()) return true;
|
|
|
|
return ui.checkStartMinimized->isChecked();
|
|
|
|
}
|
|
|
|
|
2009-09-08 08:34:18 -04:00
|
|
|
bool GeneralPage::closetoTray() const {
|
|
|
|
if(ui.checkClosetoTray->isChecked()) return true;
|
|
|
|
return ui.checkClosetoTray->isChecked();
|
|
|
|
}
|
|
|
|
|
2010-01-08 11:32:10 -05:00
|
|
|
|
2009-07-23 13:11:51 -04:00
|
|
|
/** Called when the "show on startup" checkbox is toggled. */
|
|
|
|
void
|
|
|
|
GeneralPage::toggleShowOnStartup(bool checked)
|
|
|
|
{
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->setShowMainWindowAtStart(checked);
|
2009-07-23 13:11:51 -04:00
|
|
|
}
|
2010-04-08 07:55:10 -04:00
|
|
|
|
|
|
|
void GeneralPage::setAutoLogin(){
|
|
|
|
RsInit::setAutoLogin(ui.autoLogin->isChecked());
|
|
|
|
}
|