From e25756316df7c336c643c165a77041357e27167c Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 4 Mar 2017 00:01:21 +0100 Subject: [PATCH] merged Directories settings page into Transfers and renamed it Files --- .../src/gui/settings/TransferPage.cpp | 101 ++++++++-- .../src/gui/settings/TransferPage.h | 14 +- .../src/gui/settings/TransferPage.ui | 185 +++++++++++++++++- .../src/gui/settings/rsettingswin.cpp | 1 - 4 files changed, 276 insertions(+), 25 deletions(-) diff --git a/retroshare-gui/src/gui/settings/TransferPage.cpp b/retroshare-gui/src/gui/settings/TransferPage.cpp index c30d6ebfd..76a01632d 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.cpp +++ b/retroshare-gui/src/gui/settings/TransferPage.cpp @@ -25,6 +25,8 @@ #include +#include +#include #include #include #include @@ -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()); } diff --git a/retroshare-gui/src/gui/settings/TransferPage.h b/retroshare-gui/src/gui/settings/TransferPage.h index eca52ace5..d7f7c4da7 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.h +++ b/retroshare-gui/src/gui/settings/TransferPage.h @@ -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; diff --git a/retroshare-gui/src/gui/settings/TransferPage.ui b/retroshare-gui/src/gui/settings/TransferPage.ui index 5d69fcdba..474e6f3b5 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.ui +++ b/retroshare-gui/src/gui/settings/TransferPage.ui @@ -6,11 +6,186 @@ 0 0 - 754 - 512 + 1126 + 1099 - + + + + + Shared Directories + + + + + + + + true + + + Automatically share incoming directory (Recommended) + + + true + + + + + + + Edit Share + + + + + + + + + + + + + + Auto-check shared directories every + + + true + + + + + + + minute(s) + + + 1 + + + 5000 + + + 10 + + + + + + + + + <html><head/><body><p>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.</p></body></html> + + + follow symbolic links + + + true + + + + + + + + + + Incoming Directory + + + + + + true + + + + + + + + 31 + 31 + + + + + 31 + 31 + + + + Browse + + + + + + + :/images/directoryselect_24x24_shadow.png:/images/directoryselect_24x24_shadow.png + + + + 24 + 24 + + + + + + + + + + + Partials Directory + + + + + + true + + + + + + + + 31 + 31 + + + + + 31 + 31 + + + + Browse + + + + + + + :/images/directoryselect_24x24_shadow.png:/images/directoryselect_24x24_shadow.png + + + + 24 + 24 + + + + + + + @@ -199,6 +374,8 @@ p, li { white-space: pre-wrap; } - + + + diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index 5dd1b8eb0..7c166b17e 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -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