merged Directories settings page into Transfers and renamed it Files

This commit is contained in:
csoler 2017-03-04 00:01:21 +01:00
parent 8bdf4f3dad
commit e25756316d
4 changed files with 276 additions and 25 deletions

View File

@ -25,6 +25,8 @@
#include <iostream>
#include <util/misc.h>
#include <gui/ShareManager.h>
#include <retroshare/rsiface.h>
#include <retroshare/rsfiles.h>
#include <retroshare/rspeers.h>
@ -35,31 +37,23 @@ TransferPage::TransferPage(QWidget * parent, Qt::WindowFlags flags)
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
ui._queueSize_SB->setValue(rsFiles->getQueueSize()) ;
switch(rsFiles->defaultChunkStrategy())
{
case FileChunksInfo::CHUNK_STRATEGY_STREAMING: ui._defaultStrategy_CB->setCurrentIndex(0) ; break ;
case FileChunksInfo::CHUNK_STRATEGY_PROGRESSIVE: ui._defaultStrategy_CB->setCurrentIndex(1) ; break ;
case FileChunksInfo::CHUNK_STRATEGY_RANDOM: ui._defaultStrategy_CB->setCurrentIndex(2) ; break ;
}
switch(rsFiles->defaultEncryptionPolicy())
{
case RS_FILE_CTRL_ENCRYPTION_POLICY_PERMISSIVE: ui._e2e_encryption_CB->setCurrentIndex(0) ; break ;
case RS_FILE_CTRL_ENCRYPTION_POLICY_STRICT : ui._e2e_encryption_CB->setCurrentIndex(1) ; break ;
}
ui._diskSpaceLimit_SB->setValue(rsFiles->freeDiskSpaceLimit()) ;
QObject::connect(ui._queueSize_SB,SIGNAL(valueChanged(int)),this,SLOT(updateQueueSize(int))) ;
QObject::connect(ui._defaultStrategy_CB,SIGNAL(activated(int)),this,SLOT(updateDefaultStrategy(int))) ;
QObject::connect(ui._e2e_encryption_CB,SIGNAL(activated(int)),this,SLOT(updateEncryptionPolicy(int))) ;
QObject::connect(ui._diskSpaceLimit_SB,SIGNAL(valueChanged(int)),this,SLOT(updateDiskSizeLimit(int))) ;
QObject::connect(ui._max_tr_up_per_sec_SB, SIGNAL( valueChanged( int ) ), this, SLOT( updateMaxTRUpRate(int) ) );
ui._max_tr_up_per_sec_SB->setValue(rsTurtle->getMaxTRForwardRate()) ;
QObject::connect(ui.incomingButton, SIGNAL(clicked( bool ) ), this , SLOT( setIncomingDirectory() ) );
QObject::connect(ui.partialButton, SIGNAL(clicked( bool ) ), this , SLOT( setPartialsDirectory() ) );
QObject::connect(ui.editShareButton, SIGNAL(clicked()), this, SLOT(editDirectories()));
QObject::connect(ui.autoCheckDirectories_CB, SIGNAL(clicked(bool)), this, SLOT(toggleAutoCheckDirectories(bool)));
QObject::connect(ui.autoCheckDirectories_CB, SIGNAL(toggled(bool)), this,SLOT(updateAutoCheckDirectories())) ;
QObject::connect(ui.autoCheckDirectoriesDelay_SB,SIGNAL(valueChanged(int)),this,SLOT(updateAutoScanDirectoriesPeriod())) ;
QObject::connect(ui.shareDownloadDirectoryCB, SIGNAL(toggled(bool)), this,SLOT(updateShareDownloadDirectory())) ;
QObject::connect(ui.followSymLinks_CB, SIGNAL(toggled(bool)), this,SLOT(updateFollowSymLinks())) ;
}
void TransferPage::updateMaxTRUpRate(int b)
{
rsTurtle->setMaxTRForwardRate(b) ;
@ -77,6 +71,37 @@ void TransferPage::updateEncryptionPolicy(int b)
}
}
void TransferPage::load()
{
whileBlocking(ui.shareDownloadDirectoryCB)->setChecked(rsFiles->getShareDownloadDirectory());
int u = rsFiles->watchPeriod() ;
whileBlocking(ui.autoCheckDirectoriesDelay_SB)->setValue(u) ;
whileBlocking(ui.autoCheckDirectories_CB)->setChecked(rsFiles->watchEnabled()) ; ;
whileBlocking(ui.incomingDir)->setText(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()));
whileBlocking(ui.partialsDir)->setText(QString::fromUtf8(rsFiles->getPartialsDirectory().c_str()));
whileBlocking(ui.followSymLinks_CB)->setChecked(rsFiles->followSymLinks());
whileBlocking(ui._queueSize_SB)->setValue(rsFiles->getQueueSize()) ;
switch(rsFiles->defaultChunkStrategy())
{
case FileChunksInfo::CHUNK_STRATEGY_STREAMING: whileBlocking(ui._defaultStrategy_CB)->setCurrentIndex(0) ; break ;
case FileChunksInfo::CHUNK_STRATEGY_PROGRESSIVE: whileBlocking(ui._defaultStrategy_CB)->setCurrentIndex(1) ; break ;
case FileChunksInfo::CHUNK_STRATEGY_RANDOM: whileBlocking(ui._defaultStrategy_CB)->setCurrentIndex(2) ; break ;
}
switch(rsFiles->defaultEncryptionPolicy())
{
case RS_FILE_CTRL_ENCRYPTION_POLICY_PERMISSIVE: whileBlocking(ui._e2e_encryption_CB)->setCurrentIndex(0) ; break ;
case RS_FILE_CTRL_ENCRYPTION_POLICY_STRICT : whileBlocking(ui._e2e_encryption_CB)->setCurrentIndex(1) ; break ;
}
whileBlocking(ui._diskSpaceLimit_SB)->setValue(rsFiles->freeDiskSpaceLimit()) ;
whileBlocking(ui._max_tr_up_per_sec_SB)->setValue(rsTurtle->getMaxTRForwardRate()) ;
}
void TransferPage::updateDefaultStrategy(int i)
{
switch(i)
@ -102,3 +127,43 @@ void TransferPage::updateQueueSize(int s)
{
rsFiles->setQueueSize(s) ;
}
void TransferPage::setIncomingDirectory()
{
QString qdir = QFileDialog::getExistingDirectory(this, tr("Set Incoming Directory"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (qdir.isEmpty()) {
return;
}
ui.incomingDir->setText(qdir);
std::string dir = ui.incomingDir->text().toUtf8().constData();
if(!dir.empty())
rsFiles->setDownloadDirectory(dir);
}
void TransferPage::setPartialsDirectory()
{
QString qdir = QFileDialog::getExistingDirectory(this, tr("Set Partials Directory"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (qdir.isEmpty()) {
return;
}
ui.partialsDir->setText(qdir);
std::string dir = ui.partialsDir->text().toUtf8().constData();
if (!dir.empty())
rsFiles->setPartialsDirectory(dir);
}
void TransferPage::toggleAutoCheckDirectories(bool b)
{
ui.autoCheckDirectoriesDelay_SB->setEnabled(b);
}
void TransferPage::editDirectories()
{
ShareManager::showYourself() ;
}
void TransferPage::updateAutoCheckDirectories() { rsFiles->setWatchEnabled(ui.autoCheckDirectories_CB->isChecked()) ; }
void TransferPage::updateAutoScanDirectoriesPeriod() { rsFiles->setWatchPeriod(ui.autoCheckDirectoriesDelay_SB->value()); }
void TransferPage::updateShareDownloadDirectory() { rsFiles->shareDownloadDirectory(ui.shareDownloadDirectoryCB->isChecked());}
void TransferPage::updateFollowSymLinks() { rsFiles->setFollowSymLinks(ui.followSymLinks_CB->isChecked()); }

View File

@ -36,10 +36,10 @@ class TransferPage: public ConfigPage
~TransferPage() {}
/** Loads the settings for this page */
virtual void load() {}
virtual void load() ;
virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/filesharing.svg") ; }
virtual QString pageName() const { return tr("File transfer") ; }
virtual QString pageName() const { return tr("Files") ; }
virtual QString helpText() const { return ""; }
public slots:
@ -49,6 +49,16 @@ class TransferPage: public ConfigPage
void updateMaxTRUpRate(int);
void updateEncryptionPolicy(int);
void editDirectories() ;
void setIncomingDirectory();
void setPartialsDirectory();
void toggleAutoCheckDirectories(bool);
void updateAutoCheckDirectories() ;
void updateAutoScanDirectoriesPeriod() ;
void updateShareDownloadDirectory() ;
void updateFollowSymLinks() ;
private:
Ui::TransferPage ui;

View File

@ -6,11 +6,186 @@
<rect>
<x>0</x>
<y>0</y>
<width>754</width>
<height>512</height>
<width>1126</width>
<height>1099</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Shared Directories</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="shareDownloadDirectoryCB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Automatically share incoming directory (Recommended)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="editShareButton">
<property name="text">
<string>Edit Share</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="autoCheckDirectories_CB">
<property name="text">
<string>Auto-check shared directories every </string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="autoCheckDirectoriesDelay_SB">
<property name="suffix">
<string> minute(s)</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>5000</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="followSymLinks_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Tells Retroshare to follow the links. Loops and duplicate directories are automatically taken care of. If unchecked, Retroshare will just ignore symbolic links to both files and directories.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>follow symbolic links</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Incoming Directory</string>
</property>
<layout class="QGridLayout" name="_3">
<item row="0" column="0">
<widget class="QLineEdit" name="incomingDir">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="incomingButton">
<property name="minimumSize">
<size>
<width>31</width>
<height>31</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>31</width>
<height>31</height>
</size>
</property>
<property name="toolTip">
<string>Browse</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/directoryselect_24x24_shadow.png</normaloff>:/images/directoryselect_24x24_shadow.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Partials Directory</string>
</property>
<layout class="QGridLayout" name="_2">
<item row="0" column="0">
<widget class="QLineEdit" name="partialsDir">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="partialButton">
<property name="minimumSize">
<size>
<width>31</width>
<height>31</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>31</width>
<height>31</height>
</size>
</property>
<property name="toolTip">
<string>Browse</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/directoryselect_24x24_shadow.png</normaloff>:/images/directoryselect_24x24_shadow.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
@ -199,6 +374,8 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -150,7 +150,6 @@ SettingsPage::initStackedWidget()
addPage(new PostedPage()); // POSTED RENAME TO LINKS
addPage(new NotifyPage()); // NOTIFY
addPage(new RelayPage() ); // RELAY SHOUD BE INSIDE NETWORK AS A TAB
addPage(new DirectoriesPage()); // DIRECOTIRES, SHOULD BE INSIDE FILE TRANSFER AS A TAB
addPage(new PluginsPage() ); // PLUGINS
addPage(new AppearancePage()); // APPEARENCE
addPage(new SoundPage() ); // SOUND