mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-14 08:59:50 -05:00
changed a few pages to not requiring to call save()
This commit is contained in:
parent
53a1993842
commit
bd379e6b89
@ -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()
|
||||
{
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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()
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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<QString, QString>::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()
|
||||
{
|
||||
|
@ -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") ; }
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <iostream>
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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.</p>") ;
|
||||
}
|
||||
|
||||
/** 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));
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
||||
|
@ -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<ConfigPage *>(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();
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -23,6 +23,7 @@
|
||||
#ifndef _CONFIGPAGE_H
|
||||
#define _CONFIGPAGE_H
|
||||
|
||||
#include <iostream>
|
||||
#include <QWidget>
|
||||
|
||||
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*/)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user