2009-07-23 17:11:51 +00:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 - 2009 RetroShare Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2009-08-19 22:15:16 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2009-07-23 17:11:51 +00:00
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#include "DirectoriesPage.h"
|
2009-08-17 20:19:02 +00:00
|
|
|
#include "gui/ShareManager.h"
|
2010-10-31 20:35:31 +00:00
|
|
|
#include <QMessageBox>
|
2009-08-17 20:19:02 +00:00
|
|
|
|
2009-07-23 17:11:51 +00:00
|
|
|
#include "rshare.h"
|
2010-08-06 09:40:23 +00:00
|
|
|
#include <retroshare/rsfiles.h>
|
2009-07-23 17:11:51 +00:00
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
2013-10-18 21:10:33 +00:00
|
|
|
DirectoriesPage::DirectoriesPage(QWidget * parent, Qt::WindowFlags flags)
|
2009-08-19 22:15:16 +00:00
|
|
|
: ConfigPage(parent, flags)
|
2009-07-23 17:11:51 +00:00
|
|
|
{
|
|
|
|
ui.setupUi(this);
|
2011-03-28 21:52:21 +00:00
|
|
|
|
2010-04-24 22:09:47 +00:00
|
|
|
connect(ui.incomingButton, SIGNAL(clicked( bool ) ), this , SLOT( setIncomingDirectory() ) );
|
|
|
|
connect(ui.partialButton, SIGNAL(clicked( bool ) ), this , SLOT( setPartialsDirectory() ) );
|
2011-06-15 00:40:07 +00:00
|
|
|
connect(ui.editShareButton, SIGNAL(clicked()), this, SLOT(editDirectories()));
|
|
|
|
connect(ui.autoCheckDirectories_CB, SIGNAL(clicked(bool)), this, SLOT(toggleAutoCheckDirectories(bool)));
|
2009-07-23 17:11:51 +00:00
|
|
|
}
|
|
|
|
|
2011-03-28 21:52:21 +00:00
|
|
|
void DirectoriesPage::toggleAutoCheckDirectories(bool b)
|
|
|
|
{
|
2011-06-15 00:40:07 +00:00
|
|
|
ui.autoCheckDirectoriesDelay_SB->setEnabled(b);
|
2011-03-28 21:52:21 +00:00
|
|
|
}
|
|
|
|
|
2011-06-15 00:40:07 +00:00
|
|
|
void DirectoriesPage::editDirectories()
|
2010-10-31 20:35:31 +00:00
|
|
|
{
|
2011-06-15 00:40:07 +00:00
|
|
|
ShareManager::showYourself() ;
|
2010-10-31 20:35:31 +00:00
|
|
|
}
|
|
|
|
|
2009-07-23 17:11:51 +00:00
|
|
|
/** Saves the changes on this page */
|
2011-08-12 14:06:29 +00:00
|
|
|
bool DirectoriesPage::save(QString &/*errmsg*/)
|
2009-07-23 17:11:51 +00:00
|
|
|
{
|
2011-06-15 00:40:07 +00:00
|
|
|
std::string dir = ui.incomingDir->text().toUtf8().constData();
|
|
|
|
if (!dir.empty())
|
|
|
|
{
|
|
|
|
rsFiles->setDownloadDirectory(dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
dir = ui.partialsDir->text().toUtf8().constData();
|
|
|
|
if (!dir.empty())
|
|
|
|
{
|
|
|
|
rsFiles->setPartialsDirectory(dir);
|
|
|
|
}
|
|
|
|
|
2016-09-18 18:34:39 +02:00
|
|
|
rsFiles->setWatchEnabled(ui.autoCheckDirectories_CB->isChecked()) ;
|
|
|
|
rsFiles->setWatchPeriod(ui.autoCheckDirectoriesDelay_SB->value());
|
2011-06-15 00:40:07 +00:00
|
|
|
|
|
|
|
rsFiles->shareDownloadDirectory(ui.shareDownloadDirectoryCB->isChecked());
|
2009-07-23 17:11:51 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2009-08-19 22:15:16 +00:00
|
|
|
|
2009-07-23 17:11:51 +00:00
|
|
|
/** Loads the settings for this page */
|
|
|
|
void DirectoriesPage::load()
|
|
|
|
{
|
2011-06-15 00:40:07 +00:00
|
|
|
ui.shareDownloadDirectoryCB->setChecked(rsFiles->getShareDownloadDirectory());
|
2009-07-23 17:11:51 +00:00
|
|
|
|
2011-06-15 00:40:07 +00:00
|
|
|
int u = rsFiles->watchPeriod() ;
|
2016-09-18 18:34:39 +02:00
|
|
|
ui.autoCheckDirectoriesDelay_SB->setValue(u) ;
|
|
|
|
ui.autoCheckDirectories_CB->setChecked(rsFiles->watchEnabled()) ; ;
|
2010-04-24 22:09:47 +00:00
|
|
|
|
2010-09-27 21:42:26 +00:00
|
|
|
ui.incomingDir->setText(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()));
|
|
|
|
ui.partialsDir->setText(QString::fromUtf8(rsFiles->getPartialsDirectory().c_str()));
|
2009-07-23 17:11:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DirectoriesPage::setIncomingDirectory()
|
|
|
|
{
|
2011-03-06 20:19:16 +00:00
|
|
|
QString qdir = QFileDialog::getExistingDirectory(this, tr("Set Incoming Directory"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
2011-06-15 00:40:07 +00:00
|
|
|
if (qdir.isEmpty()) {
|
|
|
|
return;
|
2009-07-23 17:11:51 +00:00
|
|
|
}
|
2011-06-15 00:40:07 +00:00
|
|
|
|
|
|
|
ui.incomingDir->setText(qdir);
|
2009-07-23 17:11:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DirectoriesPage::setPartialsDirectory()
|
|
|
|
{
|
2011-03-06 20:19:16 +00:00
|
|
|
QString qdir = QFileDialog::getExistingDirectory(this, tr("Set Partials Directory"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
2011-06-15 00:40:07 +00:00
|
|
|
if (qdir.isEmpty()) {
|
|
|
|
return;
|
2009-07-23 17:11:51 +00:00
|
|
|
}
|
|
|
|
|
2011-06-15 00:40:07 +00:00
|
|
|
ui.partialsDir->setText(qdir);
|
2012-04-03 19:35:11 +00:00
|
|
|
}
|