From bd379e6b8963332725919d5fb624445a33b5c744 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 28 Jan 2017 18:13:38 +0100 Subject: [PATCH] changed a few pages to not requiring to call save() --- .../src/gui/settings/ChannelPage.cpp | 15 ++-- retroshare-gui/src/gui/settings/ChannelPage.h | 5 +- .../src/gui/settings/CryptoPage.cpp | 7 -- retroshare-gui/src/gui/settings/CryptoPage.h | 8 +- .../src/gui/settings/DirectoriesPage.cpp | 39 ++++------ .../src/gui/settings/DirectoriesPage.h | 7 +- .../src/gui/settings/FileAssociationsPage.cpp | 32 -------- .../src/gui/settings/FileAssociationsPage.h | 1 - retroshare-gui/src/gui/settings/ForumPage.cpp | 23 +++--- retroshare-gui/src/gui/settings/ForumPage.h | 8 +- .../src/gui/settings/GeneralPage.cpp | 76 ++++++++++--------- retroshare-gui/src/gui/settings/GeneralPage.h | 41 ++++++---- .../gui/settings/GroupFrameSettingsWidget.cpp | 21 ++++- .../gui/settings/GroupFrameSettingsWidget.h | 6 +- .../src/gui/settings/PluginsPage.cpp | 7 -- retroshare-gui/src/gui/settings/PluginsPage.h | 2 - .../src/gui/settings/PostedPage.cpp | 9 +-- retroshare-gui/src/gui/settings/PostedPage.h | 2 - retroshare-gui/src/gui/settings/RelayPage.cpp | 24 ++++-- retroshare-gui/src/gui/settings/RelayPage.h | 4 +- .../src/gui/settings/rsettingswin.cpp | 34 +-------- .../src/gui/settings/rsettingswin.h | 7 +- .../src/retroshare-gui/configpage.h | 5 +- 23 files changed, 166 insertions(+), 217 deletions(-) diff --git a/retroshare-gui/src/gui/settings/ChannelPage.cpp b/retroshare-gui/src/gui/settings/ChannelPage.cpp index ca6c55031..c0de1ac60 100644 --- a/retroshare-gui/src/gui/settings/ChannelPage.cpp +++ b/retroshare-gui/src/gui/settings/ChannelPage.cpp @@ -30,21 +30,18 @@ ChannelPage::ChannelPage(QWidget * parent, Qt::WindowFlags flags) /* Initialize GroupFrameSettingsWidget */ ui.groupFrameSettingsWidget->setOpenAllInNewTabText(tr("Open each channel in a new tab")); + + connect(ui.loadThreadCheckBox,SIGNAL(toggled(bool)),this,SLOT(updateLoadThread)) ; + + ui.groupFrameSettingsWidget->setType(GroupFrameSettings::Channel) ; } +void ChannelPage::updateLoadThread() { Settings->setChannelLoadThread(ui.loadThreadCheckBox->isChecked()); } + ChannelPage::~ChannelPage() { } -/** Saves the changes on this page */ -bool ChannelPage::save(QString &/*errmsg*/) -{ - Settings->setChannelLoadThread(ui.loadThreadCheckBox->isChecked()); - ui.groupFrameSettingsWidget->saveSettings(GroupFrameSettings::Channel); - - return true; -} - /** Loads the settings for this page */ void ChannelPage::load() { diff --git a/retroshare-gui/src/gui/settings/ChannelPage.h b/retroshare-gui/src/gui/settings/ChannelPage.h index 40e343fc0..69e28455b 100644 --- a/retroshare-gui/src/gui/settings/ChannelPage.h +++ b/retroshare-gui/src/gui/settings/ChannelPage.h @@ -33,8 +33,6 @@ public: ChannelPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); ~ChannelPage(); - /** Saves the changes on this page */ - virtual bool save(QString &errmsg); /** Loads the settings for this page */ virtual void load(); @@ -42,6 +40,9 @@ public: virtual QString pageName() const { return tr("Channels") ; } virtual QString helpText() const { return ""; } +protected slots: + void updateLoadThread() ; + private: Ui::ChannelPage ui; }; diff --git a/retroshare-gui/src/gui/settings/CryptoPage.cpp b/retroshare-gui/src/gui/settings/CryptoPage.cpp index 8cca2756c..1aa30b520 100755 --- a/retroshare-gui/src/gui/settings/CryptoPage.cpp +++ b/retroshare-gui/src/gui/settings/CryptoPage.cpp @@ -92,13 +92,6 @@ CryptoPage::~CryptoPage() { } -/** Saves the changes on this page */ -bool -CryptoPage::save(QString &/*errmsg*/) -{ - return true; -} - /** Loads the settings for this page */ void CryptoPage::load() diff --git a/retroshare-gui/src/gui/settings/CryptoPage.h b/retroshare-gui/src/gui/settings/CryptoPage.h index a1bcb42f0..fb07b0da7 100755 --- a/retroshare-gui/src/gui/settings/CryptoPage.h +++ b/retroshare-gui/src/gui/settings/CryptoPage.h @@ -35,8 +35,6 @@ class CryptoPage : public ConfigPage /** Default Destructor */ ~CryptoPage(); - /** Saves the changes on this page */ - virtual bool save(QString &errmsg); /** Loads the settings for this page */ virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/profile.svg") ; } @@ -46,9 +44,9 @@ class CryptoPage : public ConfigPage private slots: virtual void load(); void copyPublicKey(); - void copyRSLink() ; - virtual void showEvent ( QShowEvent * event ); - void profilemanager(); + void copyRSLink() ; + virtual void showEvent ( QShowEvent * event ); + void profilemanager(); bool fileSave(); bool fileSaveAs(); void showStats(); diff --git a/retroshare-gui/src/gui/settings/DirectoriesPage.cpp b/retroshare-gui/src/gui/settings/DirectoriesPage.cpp index c3c466980..7fdd90cbb 100755 --- a/retroshare-gui/src/gui/settings/DirectoriesPage.cpp +++ b/retroshare-gui/src/gui/settings/DirectoriesPage.cpp @@ -37,6 +37,11 @@ DirectoriesPage::DirectoriesPage(QWidget * parent, Qt::WindowFlags flags) connect(ui.partialButton, SIGNAL(clicked( bool ) ), this , SLOT( setPartialsDirectory() ) ); connect(ui.editShareButton, SIGNAL(clicked()), this, SLOT(editDirectories())); connect(ui.autoCheckDirectories_CB, SIGNAL(clicked(bool)), this, SLOT(toggleAutoCheckDirectories(bool))); + + connect(ui.autoCheckDirectories_CB, SIGNAL(toggled(bool)), this,SLOT(updateAutoCheckDirectories())) ; + connect(ui.autoCheckDirectoriesDelay_SB,SIGNAL(valueChanged(int)),this,SLOT(updateAutoScanDirectoriesPeriod())) ; + connect(ui.shareDownloadDirectoryCB, SIGNAL(toggled(bool)), this,SLOT(updateShareDownloadDirectory())) ; + connect(ui.followSymLinks_CB, SIGNAL(toggled(bool)), this,SLOT(updateFollowSymLinks())) ; } void DirectoriesPage::toggleAutoCheckDirectories(bool b) @@ -49,29 +54,10 @@ void DirectoriesPage::editDirectories() ShareManager::showYourself() ; } -/** Saves the changes on this page */ -bool DirectoriesPage::save(QString &/*errmsg*/) -{ - 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); - } - - rsFiles->setWatchEnabled(ui.autoCheckDirectories_CB->isChecked()) ; - rsFiles->setWatchPeriod(ui.autoCheckDirectoriesDelay_SB->value()); - - rsFiles->shareDownloadDirectory(ui.shareDownloadDirectoryCB->isChecked()); - rsFiles->setFollowSymLinks(ui.followSymLinks_CB->isChecked()); - - return true; -} +void DirectoriesPage::updateAutoCheckDirectories() { rsFiles->setWatchEnabled(ui.autoCheckDirectories_CB->isChecked()) ; } +void DirectoriesPage::updateAutoScanDirectoriesPeriod() { rsFiles->setWatchPeriod(ui.autoCheckDirectoriesDelay_SB->value()); } +void DirectoriesPage::updateShareDownloadDirectory() { rsFiles->shareDownloadDirectory(ui.shareDownloadDirectoryCB->isChecked());} +void DirectoriesPage::updateFollowSymLinks() { rsFiles->setFollowSymLinks(ui.followSymLinks_CB->isChecked()); } /** Loads the settings for this page */ void DirectoriesPage::load() @@ -95,6 +81,10 @@ void DirectoriesPage::setIncomingDirectory() } ui.incomingDir->setText(qdir); + std::string dir = ui.incomingDir->text().toUtf8().constData(); + + if(!dir.empty()) + rsFiles->setDownloadDirectory(dir); } void DirectoriesPage::setPartialsDirectory() @@ -105,4 +95,7 @@ void DirectoriesPage::setPartialsDirectory() } ui.partialsDir->setText(qdir); + std::string dir = ui.partialsDir->text().toUtf8().constData(); + if (!dir.empty()) + rsFiles->setPartialsDirectory(dir); } diff --git a/retroshare-gui/src/gui/settings/DirectoriesPage.h b/retroshare-gui/src/gui/settings/DirectoriesPage.h index ffeb1bf34..dfb0f15cd 100755 --- a/retroshare-gui/src/gui/settings/DirectoriesPage.h +++ b/retroshare-gui/src/gui/settings/DirectoriesPage.h @@ -32,8 +32,6 @@ class DirectoriesPage: public ConfigPage public: DirectoriesPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); - /** Saves the changes on this page */ - virtual bool save(QString &errmsg); /** Loads the settings for this page */ virtual void load(); @@ -47,6 +45,11 @@ private slots: void setPartialsDirectory(); void toggleAutoCheckDirectories(bool); + void updateAutoCheckDirectories() ; + void updateAutoScanDirectoriesPeriod() ; + void updateShareDownloadDirectory() ; + void updateFollowSymLinks() ; + private: Ui::DirectoriesPage ui; }; diff --git a/retroshare-gui/src/gui/settings/FileAssociationsPage.cpp b/retroshare-gui/src/gui/settings/FileAssociationsPage.cpp index 95bd33cf1..d8f5f003c 100755 --- a/retroshare-gui/src/gui/settings/FileAssociationsPage.cpp +++ b/retroshare-gui/src/gui/settings/FileAssociationsPage.cpp @@ -131,38 +131,6 @@ FileAssociationsPage::~FileAssociationsPage() { } -//============================================================================ - -bool -FileAssociationsPage::save (QString &/*errmsg*/) -{ -// RshareSettings settings; - - -// settings.beginGroup("FileAssotiations"); -// settings.setValue(".s01", "s01 test"); -// settings.setValue(".s02", "s02 test"); -// settings.setValue(".s03", "s03 test"); -// settings.setValue(".s04", "s04 test"); -// QMap::const_iterator ati = ations.constBegin(); -// while (ati != ations.constEnd()) -// { -// settings.setValue( ati.key(), ati.value() ); -// qDebug() << " - " << ati.key() << ati.value() << "\n" ; -// ++ati; -// } -// -// settings.endGroup(); - -// settings.sync(); - -// delete settings; -/* */ - return true; -} - -//============================================================================ - void FileAssociationsPage::load() { diff --git a/retroshare-gui/src/gui/settings/FileAssociationsPage.h b/retroshare-gui/src/gui/settings/FileAssociationsPage.h index 769dbabb0..078a437e0 100755 --- a/retroshare-gui/src/gui/settings/FileAssociationsPage.h +++ b/retroshare-gui/src/gui/settings/FileAssociationsPage.h @@ -52,7 +52,6 @@ public: virtual ~FileAssociationsPage(); virtual void load(); - virtual bool save (QString &errmsg); virtual QPixmap iconPixmap() const { return QPixmap(":/images/filetype-association.png") ; } virtual QString pageName() const { return tr("Associations") ; } diff --git a/retroshare-gui/src/gui/settings/ForumPage.cpp b/retroshare-gui/src/gui/settings/ForumPage.cpp index 90ff1f176..d7681762e 100644 --- a/retroshare-gui/src/gui/settings/ForumPage.cpp +++ b/retroshare-gui/src/gui/settings/ForumPage.cpp @@ -30,24 +30,23 @@ ForumPage::ForumPage(QWidget * parent, Qt::WindowFlags flags) /* Initialize GroupFrameSettingsWidget */ ui.groupFrameSettingsWidget->setOpenAllInNewTabText(tr("Open each forum in a new tab")); + + connect(ui.setMsgToReadOnActivate,SIGNAL(toggled(bool)),this,SLOT(updateMsgReadOnActivate())) ; + connect(ui.expandNewMessages , SIGNAL(toggled(bool)), this, SLOT( updateExpandNewMessages())); + connect(ui.loadEmbeddedImages , SIGNAL(toggled(bool)), this, SLOT(updateLoadEmbeddedImage() )); + connect(ui.loadEmoticons , SIGNAL(toggled(bool)), this, SLOT( updateLoadEmoticons() )); + + ui.groupFrameSettingsWidget->setType(GroupFrameSettings::Forum) ; } ForumPage::~ForumPage() { } -/** Saves the changes on this page */ -bool ForumPage::save(QString &/*errmsg*/) -{ - Settings->setForumMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked()); - Settings->setForumExpandNewMessages(ui.expandNewMessages->isChecked()); - Settings->setForumLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked()); - Settings->setForumLoadEmoticons(ui.loadEmoticons->isChecked()); - - ui.groupFrameSettingsWidget->saveSettings(GroupFrameSettings::Forum); - - return true; -} +void ForumPage::updateMsgReadOnActivate() { Settings->setForumMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked()); } +void ForumPage::updateExpandNewMessages() { Settings->setForumExpandNewMessages( ui.expandNewMessages ->isChecked());} +void ForumPage::updateLoadEmbeddedImages() { Settings->setForumLoadEmbeddedImages( ui.loadEmbeddedImages ->isChecked());} +void ForumPage::updateLoadEmoticons() { Settings->setForumLoadEmoticons( ui.loadEmoticons ->isChecked()); } /** Loads the settings for this page */ void ForumPage::load() diff --git a/retroshare-gui/src/gui/settings/ForumPage.h b/retroshare-gui/src/gui/settings/ForumPage.h index 6e1082a19..d4ca206e1 100644 --- a/retroshare-gui/src/gui/settings/ForumPage.h +++ b/retroshare-gui/src/gui/settings/ForumPage.h @@ -33,8 +33,6 @@ public: ForumPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); ~ForumPage(); - /** Saves the changes on this page */ - virtual bool save(QString &errmsg); /** Loads the settings for this page */ virtual void load(); @@ -42,6 +40,12 @@ public: virtual QString pageName() const { return tr("Forum") ; } virtual QString helpText() const { return ""; } +protected slots: + void updateMsgReadOnActivate(); + void updateExpandNewMessages(); + void updateLoadEmbeddedImages(); + void updateLoadEmoticons(); + private: Ui::ForumPage ui; }; diff --git a/retroshare-gui/src/gui/settings/GeneralPage.cpp b/retroshare-gui/src/gui/settings/GeneralPage.cpp index 7aa5f016f..a4a8b461d 100755 --- a/retroshare-gui/src/gui/settings/GeneralPage.cpp +++ b/retroshare-gui/src/gui/settings/GeneralPage.cpp @@ -38,8 +38,6 @@ GeneralPage::GeneralPage(QWidget * parent, Qt::WindowFlags flags) : /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); - /* Connect signals */ - connect(ui.runStartWizard_PB,SIGNAL(clicked()), this,SLOT(runStartWizard())) ; /* Hide platform specific features */ #ifdef Q_OS_WIN @@ -82,6 +80,10 @@ GeneralPage::GeneralPage(QWidget * parent, Qt::WindowFlags flags) : ui.autoLogin->setEnabled(false); ui.autoLogin->setToolTip(tr("Your RetroShare build has auto-login disabled.")); #endif // RS_AUTOLOGIN + + /* Connect signals */ + connect(ui.runStartWizard_PB,SIGNAL(clicked()), this,SLOT(runStartWizard())) ; + connect(ui.checkAdvanced,SIGNAL(toggled(bool)), this,SLOT(updateAdvancedMode())) ; } /** Destructor */ @@ -93,48 +95,48 @@ void GeneralPage::runStartWizard() QuickStartWizard(this).exec(); } -/** Saves the changes on this page */ -bool GeneralPage::save(QString &/*errmsg*/) +void GeneralPage::updateAdvancedMode() +{ + 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); + } +} + +void GeneralPage::updateUseLocalServer() { Settings->setUseLocalServer(ui.useLocalServer->isChecked()); } +void GeneralPage::updateMaxTimeBeforeIdle(){ Settings->setMaxTimeBeforeIdle(ui.idleSpinBox->value()); } +void GeneralPage::updateStartMinimized() { Settings->setStartMinimized(ui.checkStartMinimized->isChecked()); } +void GeneralPage::updateDoQuit() { Settings->setValue("doQuit", ui.checkQuit->isChecked()); } +void GeneralPage::updateCloseToTray() { Settings->setCloseToTray(ui.checkCloseToTray->isChecked()); } +void GeneralPage::updateAutoLogin() { RsInit::setAutoLogin(ui.autoLogin->isChecked());} +void GeneralPage::updateRunRSOnBoot() { #ifdef Q_OS_WIN #ifndef QT_DEBUG Settings->setRunRetroshareOnBoot(ui.chkRunRetroshareAtSystemStartup->isChecked(), ui.chkRunRetroshareAtSystemStartupMinimized->isChecked()); #endif #endif +} - Settings->setStartMinimized(ui.checkStartMinimized->isChecked()); - - 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); - } - - Settings->setValue("doQuit", ui.checkQuit->isChecked()); - Settings->setCloseToTray(ui.checkCloseToTray->isChecked()); - RsInit::setAutoLogin(ui.autoLogin->isChecked()); - - if (ui.registerRetroShareProtocol->isChecked() != Settings->getRetroShareProtocol()) { - QString error =""; - if (Settings->setRetroShareProtocol(ui.registerRetroShareProtocol->isChecked(), error) == false) { - if (ui.registerRetroShareProtocol->isChecked()) { - QMessageBox::critical(this, tr("Error"), tr("Could not add retroshare:// as protocol.").append("\n").append(error)); - } else { - QMessageBox::critical(this, tr("Error"), tr("Could not remove retroshare:// protocol.").append("\n").append(error)); - } - } - } - - Settings->setUseLocalServer(ui.useLocalServer->isChecked()); - - Settings->setMaxTimeBeforeIdle(ui.idleSpinBox->value()); - - return true; +void GeneralPage::updateRegisterRSProtocol() +{ + if (ui.registerRetroShareProtocol->isChecked() != Settings->getRetroShareProtocol()) + { + QString error =""; + if (Settings->setRetroShareProtocol(ui.registerRetroShareProtocol->isChecked(), error) == false) { + if (ui.registerRetroShareProtocol->isChecked()) { + QMessageBox::critical(this, tr("Error"), tr("Could not add retroshare:// as protocol.").append("\n").append(error)); + } else { + QMessageBox::critical(this, tr("Error"), tr("Could not remove retroshare:// protocol.").append("\n").append(error)); + } + } + } } /** Loads the settings for this page */ diff --git a/retroshare-gui/src/gui/settings/GeneralPage.h b/retroshare-gui/src/gui/settings/GeneralPage.h index fd7b90a33..d28146915 100755 --- a/retroshare-gui/src/gui/settings/GeneralPage.h +++ b/retroshare-gui/src/gui/settings/GeneralPage.h @@ -28,28 +28,37 @@ class GeneralPage : public ConfigPage { - Q_OBJECT + Q_OBJECT public: - /** Default Constructor */ - GeneralPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); - /** Default Destructor */ - ~GeneralPage(); + /** Default Constructor */ + GeneralPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + /** Default Destructor */ + ~GeneralPage(); - /** Saves the changes on this page */ - virtual bool save(QString &errmsg); - /** Loads the settings for this page */ - virtual void load(); + /** Saves the changes on this page */ + /** Loads the settings for this page */ + virtual void load(); - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/general.svg") ; } - virtual QString pageName() const { return tr("General") ; } - virtual QString helpText() const { return ""; } + virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/general.svg") ; } + virtual QString pageName() const { return tr("General") ; } + virtual QString helpText() const { return ""; } + +public slots: + void runStartWizard() ; + void updateAdvancedMode(); + void updateUseLocalServer() ; + void updateMaxTimeBeforeIdle(); + void updateStartMinimized() ; + void updateDoQuit() ; + void updateCloseToTray() ; + void updateAutoLogin() ; + void updateRunRSOnBoot() ; + void updateRegisterRSProtocol(); - public slots: - void runStartWizard() ; private: - /** Qt Designer generated object */ - Ui::GeneralPage ui; + /** Qt Designer generated object */ + Ui::GeneralPage ui; }; #endif diff --git a/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.cpp b/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.cpp index 5b55ff689..ad5e06c5c 100644 --- a/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.cpp +++ b/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.cpp @@ -1,3 +1,5 @@ +#include + #include "GroupFrameSettingsWidget.h" #include "ui_GroupFrameSettingsWidget.h" @@ -7,7 +9,11 @@ GroupFrameSettingsWidget::GroupFrameSettingsWidget(QWidget *parent) : { ui->setupUi(this); + mType = GroupFrameSettings::Nothing ; mEnable = true; + + connect(ui->openAllInNewTabCheckBox, SIGNAL(toggled(bool)),this,SLOT(saveSettings())) ; + connect(ui->hideTabBarWithOneTabCheckBox,SIGNAL(toggled(bool)),this,SLOT(saveSettings())) ; } GroupFrameSettingsWidget::~GroupFrameSettingsWidget() @@ -22,6 +28,8 @@ void GroupFrameSettingsWidget::setOpenAllInNewTabText(const QString &text) void GroupFrameSettingsWidget::loadSettings(GroupFrameSettings::Type type) { + mType = type ; + GroupFrameSettings groupFrameSettings; if (Settings->getGroupFrameSettings(type, groupFrameSettings)) { ui->openAllInNewTabCheckBox->setChecked(groupFrameSettings.mOpenAllInNewTab); @@ -32,13 +40,20 @@ void GroupFrameSettingsWidget::loadSettings(GroupFrameSettings::Type type) } } -void GroupFrameSettingsWidget::saveSettings(GroupFrameSettings::Type type) +void GroupFrameSettingsWidget::saveSettings() { - if (mEnable) { + if(mType == GroupFrameSettings::Nothing) + { + std::cerr << "(EE) No type initialized for groupFrameSettings. This is a bug." << std::endl; + return; + } + + if (mEnable) + { GroupFrameSettings groupFrameSettings; groupFrameSettings.mOpenAllInNewTab = ui->openAllInNewTabCheckBox->isChecked(); groupFrameSettings.mHideTabBarWithOneTab = ui->hideTabBarWithOneTabCheckBox->isChecked(); - Settings->setGroupFrameSettings(type, groupFrameSettings); + Settings->setGroupFrameSettings(mType, groupFrameSettings); } } diff --git a/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.h b/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.h index 418a9f9e6..aa7eb1b82 100644 --- a/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.h +++ b/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.h @@ -20,11 +20,15 @@ public: void setOpenAllInNewTabText(const QString &text); void loadSettings(GroupFrameSettings::Type type); - void saveSettings(GroupFrameSettings::Type type); + + void setType(GroupFrameSettings::Type type) { mType = type ; } +protected slots: + void saveSettings(); private: bool mEnable; Ui::GroupFrameSettingsWidget *ui; + GroupFrameSettings::Type mType ; }; #endif // GROUPFRAMESETTINGSWIDGET_H diff --git a/retroshare-gui/src/gui/settings/PluginsPage.cpp b/retroshare-gui/src/gui/settings/PluginsPage.cpp index 39bd39a4a..cdc326ec0 100644 --- a/retroshare-gui/src/gui/settings/PluginsPage.cpp +++ b/retroshare-gui/src/gui/settings/PluginsPage.cpp @@ -210,13 +210,6 @@ PluginsPage::~PluginsPage() { } -/** Saves the changes on this page */ -bool PluginsPage::save(QString &/*errmsg*/) -{ - // nothing to save for now. - return true; -} - /** Loads the settings for this page */ void PluginsPage::load() { diff --git a/retroshare-gui/src/gui/settings/PluginsPage.h b/retroshare-gui/src/gui/settings/PluginsPage.h index 08354ca68..0d8f72dac 100644 --- a/retroshare-gui/src/gui/settings/PluginsPage.h +++ b/retroshare-gui/src/gui/settings/PluginsPage.h @@ -32,8 +32,6 @@ class PluginsPage : public ConfigPage PluginsPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); ~PluginsPage(); - /** Saves the changes on this page */ - virtual bool save(QString &errmsg); /** Loads the settings for this page */ virtual void load(); diff --git a/retroshare-gui/src/gui/settings/PostedPage.cpp b/retroshare-gui/src/gui/settings/PostedPage.cpp index 30b18f24d..76b3411b0 100644 --- a/retroshare-gui/src/gui/settings/PostedPage.cpp +++ b/retroshare-gui/src/gui/settings/PostedPage.cpp @@ -32,20 +32,13 @@ PostedPage::PostedPage(QWidget * parent, Qt::WindowFlags flags) /* Initialize GroupFrameSettingsWidget */ ui->groupFrameSettingsWidget->setOpenAllInNewTabText(tr("Open each topic in a new tab")); + ui->groupFrameSettingsWidget->setType(GroupFrameSettings::Posted); } PostedPage::~PostedPage() { } -/** Saves the changes on this page */ -bool PostedPage::save(QString &/*errmsg*/) -{ - ui->groupFrameSettingsWidget->saveSettings(GroupFrameSettings::Posted); - - return true; -} - /** Loads the settings for this page */ void PostedPage::load() { diff --git a/retroshare-gui/src/gui/settings/PostedPage.h b/retroshare-gui/src/gui/settings/PostedPage.h index 73a454c5f..bc2cb8aa0 100644 --- a/retroshare-gui/src/gui/settings/PostedPage.h +++ b/retroshare-gui/src/gui/settings/PostedPage.h @@ -36,8 +36,6 @@ public: PostedPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); ~PostedPage(); - /** Saves the changes on this page */ - virtual bool save(QString &errmsg); /** Loads the settings for this page */ virtual void load(); diff --git a/retroshare-gui/src/gui/settings/RelayPage.cpp b/retroshare-gui/src/gui/settings/RelayPage.cpp index a7cc7e041..258bc05aa 100644 --- a/retroshare-gui/src/gui/settings/RelayPage.cpp +++ b/retroshare-gui/src/gui/settings/RelayPage.cpp @@ -51,6 +51,16 @@ RelayPage::RelayPage(QWidget * parent, Qt::WindowFlags flags) QObject::connect(ui.enableCheckBox,SIGNAL(stateChanged(int)),this,SLOT(updateEnabled())); QObject::connect(ui.serverCheckBox,SIGNAL(stateChanged(int)),this,SLOT(updateEnabled())); + + QObject::connect(ui.noFriendSpinBox,SIGNAL(valueChanged(int)),this,SLOT(updateTotals())); + QObject::connect(ui.bandFriendSpinBox,SIGNAL(valueChanged(int)),this,SLOT(updateTotals())); + QObject::connect(ui.noFOFSpinBox,SIGNAL(valueChanged(int)),this,SLOT(updateTotals())); + QObject::connect(ui.bandFOFSpinBox,SIGNAL(valueChanged(int)),this,SLOT(updateTotals())); + QObject::connect(ui.noGeneralSpinBox,SIGNAL(valueChanged(int)),this,SLOT(updateTotals())); + QObject::connect(ui.bandGeneralSpinBox,SIGNAL(valueChanged(int)),this,SLOT(updateTotals())); + + QObject::connect(ui.enableCheckBox,SIGNAL(toggled(bool)),this,SLOT(updateRelayMode())); + QObject::connect(ui.serverCheckBox,SIGNAL(toggled(bool)),this,SLOT(updateRelayMode())); } QString RelayPage::helpText() const @@ -66,10 +76,8 @@ QString RelayPage::helpText() const is encrypted and authenticated by the two relayed nodes.

") ; } - /** Saves the changes on this page */ -bool RelayPage::save(QString &/*errmsg*/) +void RelayPage::updateTotals() { - int nFriends = ui.noFriendSpinBox->value(); int friendBandwidth = ui.bandFriendSpinBox->value(); @@ -85,7 +93,12 @@ bool RelayPage::save(QString &/*errmsg*/) rsDht->setRelayAllowance(RSDHT_RELAY_CLASS_FRIENDS, nFriends, 1024 * friendBandwidth); rsDht->setRelayAllowance(RSDHT_RELAY_CLASS_FOF, nFOF, 1024 * fofBandwidth); rsDht->setRelayAllowance(RSDHT_RELAY_CLASS_GENERAL, nGeneral, 1024 * genBandwidth); +} +/** Saves the changes on this page */ + +void RelayPage::updateRelayMode() +{ uint32_t relayMode = 0; if (ui.enableCheckBox->isChecked()) { @@ -106,7 +119,6 @@ bool RelayPage::save(QString &/*errmsg*/) } rsDht->setRelayMode(relayMode); - return true; } /** Loads the settings for this page */ @@ -182,13 +194,9 @@ void RelayPage::updateRelayOptions() int genBandwidth = ui.bandGeneralSpinBox->value(); ui.totalFriendLineEdit->setText(QString::number(nFriends * friendBandwidth * 2)); - ui.totalFOFLineEdit->setText(QString::number(nFOF * fofBandwidth * 2)); - ui.totalGeneralLineEdit->setText(QString::number(nGeneral * genBandwidth * 2)); - ui.totalBandwidthLineEdit->setText(QString::number((nFriends * friendBandwidth + nFOF * fofBandwidth + nGeneral * genBandwidth) * 2)); - ui.noTotalLineEdit->setText(QString::number(nFriends + nFOF + nGeneral)); } diff --git a/retroshare-gui/src/gui/settings/RelayPage.h b/retroshare-gui/src/gui/settings/RelayPage.h index d88dbd07b..5c8036926 100644 --- a/retroshare-gui/src/gui/settings/RelayPage.h +++ b/retroshare-gui/src/gui/settings/RelayPage.h @@ -35,8 +35,6 @@ class RelayPage: public ConfigPage RelayPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); ~RelayPage() {} - /** Saves the changes on this page */ - virtual bool save(QString &/*errmsg*/); /** Loads the settings for this page */ virtual void load(); @@ -51,6 +49,8 @@ class RelayPage: public ConfigPage void addServer(); void removeServer(); void loadServers(); + void updateTotals(); + void updateRelayMode(); private: diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index 50052eaa1..1b88cbb53 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -141,7 +141,7 @@ SettingsPage::initStackedWidget() ui.stackedWidget->setCurrentIndex(-1); ui.stackedWidget->removeWidget(ui.stackedWidget->widget(0)); - addPage(new GeneralPage(0)); + addPage(new GeneralPage()); addPage(new ServerPage()); addPage(new TransferPage()); addPage(new RelayPage() ); @@ -211,39 +211,11 @@ SettingsPage::setNewPage(int page) } /** Saves changes made to settings. */ -void -SettingsPage::saveChanges() +void SettingsPage::notifySettingsChanged() { - QString errmsg; - - /* Call each config page's save() method to save its data */ - int i, count = ui.stackedWidget->count(); - for (i = 0; i < count; i++) - { - ConfigPage *page = dynamic_cast(ui.stackedWidget->widget(i)); - if (page && page->wasLoaded()) { - if (!page->save(errmsg)) - { - /* Display the offending page */ - ui.stackedWidget->setCurrentWidget(page); - - /* Show the user what went wrong */ - QMessageBox::warning(this, - tr("Error Saving Configuration on page")+" "+QString::number(i), errmsg, - QMessageBox::Ok, QMessageBox::NoButton); - - /* Don't process the rest of the pages */ - return; - } - } - } - /* call to RsIface save function.... */ //rsicontrol -> ConfigSave(); - if (NotifyQt::getInstance()) { + if (NotifyQt::getInstance()) NotifyQt::getInstance()->notifySettingsChanged(); - } - - close(); } diff --git a/retroshare-gui/src/gui/settings/rsettingswin.h b/retroshare-gui/src/gui/settings/rsettingswin.h index 51371f8f7..eff14f31b 100755 --- a/retroshare-gui/src/gui/settings/rsettingswin.h +++ b/retroshare-gui/src/gui/settings/rsettingswin.h @@ -58,8 +58,10 @@ public slots: void setNewPage(int page); private slots: - /** Called when user clicks "Save Settings" */ - void saveChanges(); + void notifySettingsChanged(); + + // Called when user clicks "Save Settings" + //void saveChanges(); //void dialogFinished(int result); private: @@ -67,7 +69,6 @@ private: private: FloatingHelpBrowser *mHelpBrowser; - //static RSettingsWin *_instance; static int lastPage; /* UI - from Designer */ diff --git a/retroshare-gui/src/retroshare-gui/configpage.h b/retroshare-gui/src/retroshare-gui/configpage.h index 1299f2b3f..ecb292740 100644 --- a/retroshare-gui/src/retroshare-gui/configpage.h +++ b/retroshare-gui/src/retroshare-gui/configpage.h @@ -23,6 +23,7 @@ #ifndef _CONFIGPAGE_H #define _CONFIGPAGE_H +#include #include class ConfigPage : public QWidget @@ -37,8 +38,6 @@ class ConfigPage : public QWidget /** Pure virtual method. Subclassed pages save their config settings here * and return true if everything was saved successfully. */ - virtual bool save(QString &errmsg) = 0; - bool wasLoaded() { return loaded ; } // Icon to be used to display the config page. @@ -53,6 +52,8 @@ class ConfigPage : public QWidget // virtual QString helpText() const = 0; +private: + virtual bool save(QString &errmsg) { std::cerr << "(EE) save() shoud not be called!" << std::endl; return true;} protected: virtual void showEvent(QShowEvent * /*event*/) {