From 2a82826fbaa9e5af6a79c28d096859857f3cdb1b Mon Sep 17 00:00:00 2001 From: thunder2 Date: Wed, 15 Jun 2011 00:40:07 +0000 Subject: [PATCH] Reworked settings dialog. The settings page loads the data with the first show. The dialog now starts faster. Cleaned DirectoriesPage, removed the directory list and save the data with the OK button. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4265 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/RetroShare.pro | 2 + retroshare-gui/src/gui/settings/ChatPage.cpp | 6 - retroshare-gui/src/gui/settings/ChatPage.h | 1 - .../src/gui/settings/CryptoPage.cpp | 20 +- retroshare-gui/src/gui/settings/CryptoPage.h | 8 - .../src/gui/settings/DirectoriesPage.cpp | 183 +++++++----------- .../src/gui/settings/DirectoriesPage.h | 29 +-- .../src/gui/settings/DirectoriesPage.ui | 21 +- retroshare-gui/src/gui/settings/ForumPage.cpp | 6 - retroshare-gui/src/gui/settings/ForumPage.h | 6 - retroshare-gui/src/gui/settings/GeneralPage.h | 1 - .../src/gui/settings/MessagePage.cpp | 7 - retroshare-gui/src/gui/settings/MessagePage.h | 3 - .../src/gui/settings/NetworkPage.cpp | 26 +-- retroshare-gui/src/gui/settings/NetworkPage.h | 15 +- retroshare-gui/src/gui/settings/NewTag.cpp | 5 - retroshare-gui/src/gui/settings/NewTag.h | 3 - .../src/gui/settings/NotifyPage.cpp | 13 -- retroshare-gui/src/gui/settings/NotifyPage.h | 37 ++-- .../src/gui/settings/ServerPage.cpp | 7 - retroshare-gui/src/gui/settings/ServerPage.h | 30 ++- .../src/gui/settings/TransferPage.cpp | 7 - .../src/gui/settings/TransferPage.h | 2 - .../src/gui/settings/configpage.cpp | 44 +++++ retroshare-gui/src/gui/settings/configpage.h | 15 +- .../src/gui/settings/rsettingswin.cpp | 69 +++---- .../src/gui/settings/rsettingswin.h | 2 - 27 files changed, 213 insertions(+), 355 deletions(-) create mode 100644 retroshare-gui/src/gui/settings/configpage.cpp diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index 8522c4002..4c9983d4f 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -280,6 +280,7 @@ HEADERS += rshare.h \ gui/settings/RsharePeerSettings.h \ gui/settings/rsettings.h \ gui/settings/rsettingswin.h \ + gui/settings/configpage.h \ gui/settings/GeneralPage.h \ gui/settings/DirectoriesPage.h \ gui/settings/ServerPage.h \ @@ -528,6 +529,7 @@ SOURCES += main.cpp \ gui/common/RSTreeView.cpp \ gui/style/RSStyle.cpp \ gui/style/StyleDialog.cpp \ + gui/settings/configpage.cpp \ gui/settings/rsharesettings.cpp \ gui/settings/RsharePeerSettings.cpp \ gui/settings/rsettings.cpp \ diff --git a/retroshare-gui/src/gui/settings/ChatPage.cpp b/retroshare-gui/src/gui/settings/ChatPage.cpp index 0d0f74c68..4ea9ff6a0 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.cpp +++ b/retroshare-gui/src/gui/settings/ChatPage.cpp @@ -91,12 +91,6 @@ ChatPage::ChatPage(QWidget * parent, Qt::WFlags flags) #endif } -void -ChatPage::closeEvent (QCloseEvent * event) -{ - QWidget::closeEvent(event); -} - /** Saves the changes on this page */ bool ChatPage::save(QString &errmsg) diff --git a/retroshare-gui/src/gui/settings/ChatPage.h b/retroshare-gui/src/gui/settings/ChatPage.h index f2479d0f9..3704ed389 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.h +++ b/retroshare-gui/src/gui/settings/ChatPage.h @@ -50,7 +50,6 @@ class ChatPage : public ConfigPage void on_historyList_currentRowChanged(int currentRow); private: - void closeEvent (QCloseEvent * event); void setPreviewMessages(QString &stylePath, QString styleVariant, QTextBrowser *textBrowser); void fillPreview(QListWidget *listWidget, QComboBox *comboBox, QTextBrowser *textBrowser); diff --git a/retroshare-gui/src/gui/settings/CryptoPage.cpp b/retroshare-gui/src/gui/settings/CryptoPage.cpp index 9340f8187..9fbb52f66 100755 --- a/retroshare-gui/src/gui/settings/CryptoPage.cpp +++ b/retroshare-gui/src/gui/settings/CryptoPage.cpp @@ -40,10 +40,6 @@ CryptoPage::CryptoPage(QWidget * parent, Qt::WFlags flags) connect(ui.copykeyButton, SIGNAL(clicked()), this, SLOT(copyPublicKey())); connect(ui.saveButton, SIGNAL(clicked()), this, SLOT(fileSaveAs())); - - loadPublicKey(); - - /* Hide platform specific features */ #ifdef Q_WS_WIN @@ -54,13 +50,6 @@ CryptoPage::~CryptoPage() { } -void -CryptoPage::closeEvent (QCloseEvent * event) -{ - - QWidget::closeEvent(event); -} - /** Saves the changes on this page */ bool CryptoPage::save(QString &errmsg) @@ -72,13 +61,7 @@ CryptoPage::save(QString &errmsg) void CryptoPage::load() { - -} - -/** Loads ouer default Puplickey */ -void -CryptoPage::loadPublicKey() -{ + /* Loads ouer default Puplickey */ QFont font("Courier New",9,50,false) ; ui.certtextEdit->setFont(font) ; @@ -96,7 +79,6 @@ CryptoPage::copyPublicKey() " friend via email or some other way")); QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(ui.certtextEdit->toPlainText()); - } bool CryptoPage::fileSave() diff --git a/retroshare-gui/src/gui/settings/CryptoPage.h b/retroshare-gui/src/gui/settings/CryptoPage.h index 14da8235c..9ca39b9f5 100755 --- a/retroshare-gui/src/gui/settings/CryptoPage.h +++ b/retroshare-gui/src/gui/settings/CryptoPage.h @@ -35,30 +35,22 @@ class CryptoPage : public ConfigPage /** Default Destructor */ ~CryptoPage(); - /** Saves the changes on this page */ bool save(QString &errmsg); /** Loads the settings for this page */ void load(); private slots: - - void loadPublicKey(); - void copyPublicKey(); bool fileSave(); bool fileSaveAs(); - private: - void closeEvent (QCloseEvent * event); - void setCurrentFileName(const QString &fileName); QString fileName; - /** Qt Designer generated object */ Ui::CryptoPage ui; }; diff --git a/retroshare-gui/src/gui/settings/DirectoriesPage.cpp b/retroshare-gui/src/gui/settings/DirectoriesPage.cpp index 78d38dda3..96f426273 100755 --- a/retroshare-gui/src/gui/settings/DirectoriesPage.cpp +++ b/retroshare-gui/src/gui/settings/DirectoriesPage.cpp @@ -32,30 +32,14 @@ DirectoriesPage::DirectoriesPage(QWidget * parent, Qt::WFlags flags) : ConfigPage(parent, flags) { ui.setupUi(this); - setAttribute(Qt::WA_QuitOnClose, false); - - ui.checkBox->setChecked(rsFiles->getShareDownloadDirectory()); /* signal not emitted */ - - uint32_t t = rsFiles->rememberHashFilesDuration() ; - bool b = rsFiles->rememberHashFiles() ; - - ui.rememberHashesSB->setValue(t) ; - ui.rememberHashesCB->setChecked(b) ; - - int u = rsFiles->watchPeriod() ; - ui.autoCheckDirectoriesDelay_SB->setValue(abs(u)) ; - ui.autoCheckDirectories_CB->setChecked(u>0) ; - ui.autoCheckDirectoriesDelay_SB->setEnabled(u>0) ; connect(ui.incomingButton, SIGNAL(clicked( bool ) ), this , SLOT( setIncomingDirectory() ) ); connect(ui.partialButton, SIGNAL(clicked( bool ) ), this , SLOT( setPartialsDirectory() ) ); - connect(ui.checkBox, SIGNAL(stateChanged(int)), this, SLOT(shareDownloadDirectory(int))); - connect(ui.editButton, SIGNAL(clicked()), this, SLOT(editDirectories())); + connect(ui.editShareButton, SIGNAL(clicked()), this, SLOT(editDirectories())); connect(ui.cleanHashCachePB, SIGNAL(clicked()), this, SLOT(clearHashCache())); - connect(ui.rememberHashesCB, SIGNAL(toggled(bool)), this, SLOT(toggleRememberHashes(bool))); - connect(ui.rememberHashesSB, SIGNAL(valueChanged(int)), this, SLOT(setRememberHashesDuration(int))); - connect(ui.autoCheckDirectoriesDelay_SB, SIGNAL(valueChanged(int)), this, SLOT(setAutoCheckDirectoriesDelay(int))); - connect(ui.autoCheckDirectories_CB, SIGNAL(toggled(bool)), this, SLOT(toggleAutoCheckDirectories(bool))); + connect(ui.rememberHashesCB, SIGNAL(clicked(bool)), this, SLOT(clickedRememberHashes(bool))); + connect(ui.rememberHashesCB, SIGNAL(clicked(bool)), this, SLOT(toggleRememberHashes())); + connect(ui.autoCheckDirectories_CB, SIGNAL(clicked(bool)), this, SLOT(toggleAutoCheckDirectories(bool))); /* Hide platform specific features */ #ifdef Q_WS_WIN @@ -63,62 +47,15 @@ DirectoriesPage::DirectoriesPage(QWidget * parent, Qt::WFlags flags) #endif } -void DirectoriesPage::setAutoCheckDirectoriesDelay(int b) -{ - rsFiles->setWatchPeriod(ui.autoCheckDirectoriesDelay_SB->value()) ; -} -void DirectoriesPage::toggleAutoCheckDirectories(bool b) -{ - if(!b) - { - rsFiles->setWatchPeriod(-ui.autoCheckDirectoriesDelay_SB->value()) ; - ui.autoCheckDirectoriesDelay_SB->setEnabled(false) ; - } - else - { - rsFiles->setWatchPeriod(ui.autoCheckDirectoriesDelay_SB->value()) ; - ui.autoCheckDirectoriesDelay_SB->setEnabled(true) ; - } -} - -void DirectoriesPage::setRememberHashesDuration(int d) -{ - rsFiles->setRememberHashFilesDuration(d) ; -} - -void DirectoriesPage::toggleRememberHashes(bool b) -{ - if(!b) - { - if(QMessageBox::question(NULL,"Cache cleaning confirmation","The will forget any former hash of non shared files. Do you confirm ?") == QMessageBox::Ok) - { - rsFiles->clearHashCache() ; - rsFiles->setRememberHashFiles(b) ; - ui.rememberHashesSB->setEnabled(false) ; - ui.cleanHashCachePB->setEnabled(false) ; - } - else - ui.rememberHashesCB->setChecked(true) ; - } - else - { - rsFiles->setRememberHashFiles(true) ; - ui.rememberHashesSB->setEnabled(true) ; - ui.cleanHashCachePB->setEnabled(true) ; - } -} - - void DirectoriesPage::clearHashCache() { - if(QMessageBox::question(NULL,"Cache cleaning confirmation","The will forget any former hash of non shared files. Do you confirm ?", QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) + if(QMessageBox::question(this,"Cache cleaning confirmation","The will forget any former hash of non shared files. Do you confirm ?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) rsFiles->clearHashCache() ; } -void -DirectoriesPage::closeEvent (QCloseEvent * event) +void DirectoriesPage::toggleAutoCheckDirectories(bool b) { - QWidget::closeEvent(event); + ui.autoCheckDirectoriesDelay_SB->setEnabled(b); } void DirectoriesPage::editDirectories() @@ -126,13 +63,54 @@ void DirectoriesPage::editDirectories() ShareManager::showYourself() ; } +void DirectoriesPage::clickedRememberHashes(bool b) +{ + if (!b) { + if (QMessageBox::question(this,"Cache cleaning confirmation","The will forget any former hash of non shared files. Do you confirm ?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No) { + ui.rememberHashesCB->setChecked(true); + } + } +} + +void DirectoriesPage::toggleRememberHashes() +{ + bool b = ui.rememberHashesCB->isChecked(); + ui.rememberHashesSB->setEnabled(b); + ui.cleanHashCachePB->setEnabled(b); +} + /** Saves the changes on this page */ bool DirectoriesPage::save(QString &errmsg) { - /* this is usefull especially when shared incoming files is - * default option and when the user don't check/uncheck the - * checkBox, so no signal is emitted to update the shared list */ - rsFiles->shareDownloadDirectory(ui.checkBox->isChecked()); + rsFiles->setRememberHashFilesDuration(ui.rememberHashesSB->value()); + rsFiles->setWatchPeriod(ui.autoCheckDirectoriesDelay_SB->value()); + + 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); + } + + if (ui.rememberHashesCB->isChecked()) { + rsFiles->setRememberHashFiles(true); + } else { + rsFiles->setRememberHashFiles(false); + rsFiles->clearHashCache() ; + } + + if (ui.autoCheckDirectories_CB->isChecked()) { + rsFiles->setWatchPeriod(ui.autoCheckDirectoriesDelay_SB->value()); + } else { + rsFiles->setWatchPeriod(-ui.autoCheckDirectoriesDelay_SB->value()); + } + + rsFiles->shareDownloadDirectory(ui.shareDownloadDirectoryCB->isChecked()); return true; } @@ -140,64 +118,37 @@ bool DirectoriesPage::save(QString &errmsg) /** Loads the settings for this page */ void DirectoriesPage::load() { - std::list::const_iterator it; - std::list dirs; - rsFiles->getSharedDirectories(dirs); + ui.shareDownloadDirectoryCB->setChecked(rsFiles->getShareDownloadDirectory()); - /* get a link to the table */ - QListWidget *listWidget = ui.dirList; + ui.rememberHashesSB->setValue(rsFiles->rememberHashFilesDuration()); + ui.rememberHashesCB->setChecked(rsFiles->rememberHashFiles()); + toggleRememberHashes(); - /* save current index */ - QModelIndex rootIndex = listWidget->rootIndex(); - - /* remove old items ??? */ - listWidget->clear(); - - for(it = dirs.begin(); it != dirs.end(); it++) - { - /* (0) Dir Name */ - listWidget->addItem(QString::fromUtf8((*it).filename.c_str())); - } - - /* set saved index */ - listWidget->setCurrentIndex(rootIndex); + int u = rsFiles->watchPeriod() ; + ui.autoCheckDirectoriesDelay_SB->setValue(abs(u)) ; + ui.autoCheckDirectories_CB->setChecked(u>0) ; + ui.autoCheckDirectoriesDelay_SB->setEnabled(u>0) ; ui.incomingDir->setText(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str())); ui.partialsDir->setText(QString::fromUtf8(rsFiles->getPartialsDirectory().c_str())); - - listWidget->update(); /* update display */ } void DirectoriesPage::setIncomingDirectory() { QString qdir = QFileDialog::getExistingDirectory(this, tr("Set Incoming Directory"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); - - std::string dir = qdir.toUtf8().constData(); - if (dir != "") - { - rsFiles->setDownloadDirectory(dir); - if (ui.checkBox->isChecked()) - { - rsFiles->shareDownloadDirectory(true); - } + if (qdir.isEmpty()) { + return; } - load(); + + ui.incomingDir->setText(qdir); } void DirectoriesPage::setPartialsDirectory() { QString qdir = QFileDialog::getExistingDirectory(this, tr("Set Partials Directory"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); - - std::string dir = qdir.toUtf8().constData(); - if (dir != "") - { - rsFiles->setPartialsDirectory(dir); + if (qdir.isEmpty()) { + return; } - load(); -} -void DirectoriesPage::shareDownloadDirectory(int state) -{ - rsFiles->shareDownloadDirectory(state == Qt::Checked); - load(); + ui.partialsDir->setText(qdir); } diff --git a/retroshare-gui/src/gui/settings/DirectoriesPage.h b/retroshare-gui/src/gui/settings/DirectoriesPage.h index 07c612b6b..3f035c836 100755 --- a/retroshare-gui/src/gui/settings/DirectoriesPage.h +++ b/retroshare-gui/src/gui/settings/DirectoriesPage.h @@ -20,7 +20,7 @@ ****************************************************************/ #ifndef DIRECTORIESPAGE_H -# define DIRECTORIESPAGE_H +#define DIRECTORIESPAGE_H #include "configpage.h" #include "ui_DirectoriesPage.h" @@ -29,34 +29,25 @@ class DirectoriesPage: public ConfigPage { Q_OBJECT - public: - DirectoriesPage(QWidget * parent = 0, Qt::WFlags flags = 0); - // ~DirectoriesPage() {} +public: + DirectoriesPage(QWidget * parent = 0, Qt::WFlags flags = 0); /** Saves the changes on this page */ bool save(QString &errmsg); /** Loads the settings for this page */ void load(); - - - private slots: - +private slots: void editDirectories() ; void setIncomingDirectory(); void setPartialsDirectory(); - void shareDownloadDirectory(int state); - void clearHashCache() ; - void setRememberHashesDuration(int) ; - void toggleRememberHashes(bool) ; - void setAutoCheckDirectoriesDelay(int) ; - void toggleAutoCheckDirectories(bool) ; + void clearHashCache(); + void clickedRememberHashes(bool); + void toggleRememberHashes(); + void toggleAutoCheckDirectories(bool); - private: - - void closeEvent (QCloseEvent * event); - - Ui::DirectoriesPage ui; +private: + Ui::DirectoriesPage ui; }; #endif // !GENERALPAGE_H diff --git a/retroshare-gui/src/gui/settings/DirectoriesPage.ui b/retroshare-gui/src/gui/settings/DirectoriesPage.ui index 1e2ed7771..79238f049 100755 --- a/retroshare-gui/src/gui/settings/DirectoriesPage.ui +++ b/retroshare-gui/src/gui/settings/DirectoriesPage.ui @@ -611,13 +611,10 @@ Shared Directories - - - - + true @@ -630,7 +627,7 @@ - + Edit Share @@ -717,12 +714,24 @@ you plug it in. + + + + Qt::Vertical + + + + 20 + 40 + + + + incomingDir incomingButton - dirList diff --git a/retroshare-gui/src/gui/settings/ForumPage.cpp b/retroshare-gui/src/gui/settings/ForumPage.cpp index 56ad7af35..98a49a124 100644 --- a/retroshare-gui/src/gui/settings/ForumPage.cpp +++ b/retroshare-gui/src/gui/settings/ForumPage.cpp @@ -37,12 +37,6 @@ ForumPage::~ForumPage() { } -void -ForumPage::closeEvent (QCloseEvent * event) -{ - QWidget::closeEvent(event); -} - /** Saves the changes on this page */ bool ForumPage::save(QString &errmsg) diff --git a/retroshare-gui/src/gui/settings/ForumPage.h b/retroshare-gui/src/gui/settings/ForumPage.h index 2604ac19a..c381e5601 100644 --- a/retroshare-gui/src/gui/settings/ForumPage.h +++ b/retroshare-gui/src/gui/settings/ForumPage.h @@ -22,13 +22,9 @@ #ifndef FORUMPAGE_H #define FORUMPAGE_H -#include - #include "configpage.h" #include "ui_ForumPage.h" -#include "NewTag.h" - class ForumPage : public ConfigPage { Q_OBJECT @@ -43,8 +39,6 @@ public: void load(); private: - void closeEvent (QCloseEvent * event); - Ui::ForumPage ui; }; diff --git a/retroshare-gui/src/gui/settings/GeneralPage.h b/retroshare-gui/src/gui/settings/GeneralPage.h index 35f299f8c..dc4bc2f21 100755 --- a/retroshare-gui/src/gui/settings/GeneralPage.h +++ b/retroshare-gui/src/gui/settings/GeneralPage.h @@ -26,7 +26,6 @@ #include "configpage.h" #include "ui_GeneralPage.h" - class GeneralPage : public ConfigPage { Q_OBJECT diff --git a/retroshare-gui/src/gui/settings/MessagePage.cpp b/retroshare-gui/src/gui/settings/MessagePage.cpp index 3c8814490..b713daab0 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.cpp +++ b/retroshare-gui/src/gui/settings/MessagePage.cpp @@ -34,7 +34,6 @@ MessagePage::MessagePage(QWidget * parent, Qt::WFlags flags) : ConfigPage(parent, flags) { ui.setupUi(this); - setAttribute(Qt::WA_QuitOnClose, false); m_pTags = new MsgTagType; @@ -57,12 +56,6 @@ MessagePage::~MessagePage() delete(m_pTags); } -void -MessagePage::closeEvent (QCloseEvent * event) -{ - QWidget::closeEvent(event); -} - /** Saves the changes on this page */ bool MessagePage::save(QString &errmsg) diff --git a/retroshare-gui/src/gui/settings/MessagePage.h b/retroshare-gui/src/gui/settings/MessagePage.h index b15dfbd34..662cb4660 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.h +++ b/retroshare-gui/src/gui/settings/MessagePage.h @@ -22,8 +22,6 @@ #ifndef MESSAGEPAGE_H #define MESSAGEPAGE_H -#include - #include #include "configpage.h" @@ -53,7 +51,6 @@ private slots: void currentRowChangedTag(int row); private: - void closeEvent (QCloseEvent * event); void fillTags(); /* Pointer for not include of rsmsgs.h */ diff --git a/retroshare-gui/src/gui/settings/NetworkPage.cpp b/retroshare-gui/src/gui/settings/NetworkPage.cpp index 10c855c8e..56025cefe 100755 --- a/retroshare-gui/src/gui/settings/NetworkPage.cpp +++ b/retroshare-gui/src/gui/settings/NetworkPage.cpp @@ -30,24 +30,16 @@ NetworkPage::NetworkPage(QWidget * parent, Qt::WFlags flags) } -void -NetworkPage::closeEvent (QCloseEvent * event) +/** Saves the changes on this page */ +bool +NetworkPage::save(QString &errmsg) { - QWidget::closeEvent(event); + return true; } - -/** Saves the changes on this page */ -bool -NetworkPage::save(QString &errmsg) -{ - return true; -} - -/** Loads the settings for this page */ -void -NetworkPage::load() -{ - -} +/** Loads the settings for this page */ +void +NetworkPage::load() +{ +} diff --git a/retroshare-gui/src/gui/settings/NetworkPage.h b/retroshare-gui/src/gui/settings/NetworkPage.h index 6ed27a812..2702ddbc3 100755 --- a/retroshare-gui/src/gui/settings/NetworkPage.h +++ b/retroshare-gui/src/gui/settings/NetworkPage.h @@ -22,27 +22,22 @@ #ifndef NETWORKPAGE_H #define NETWORKPAGE_H -#include - #include "configpage.h" #include "ui_NetworkPage.h" class NetworkPage : public ConfigPage { - public: - NetworkPage(QWidget * parent = 0, Qt::WFlags flags = 0); - ~NetworkPage() {} +public: + NetworkPage(QWidget * parent = 0, Qt::WFlags flags = 0); + ~NetworkPage() {} /** Saves the changes on this page */ bool save(QString &errmsg); /** Loads the settings for this page */ void load(); - private: - - void closeEvent (QCloseEvent * event); - - Ui::NetworkPage ui; +private: + Ui::NetworkPage ui; }; #endif // !NETWROKPAGE_H diff --git a/retroshare-gui/src/gui/settings/NewTag.cpp b/retroshare-gui/src/gui/settings/NewTag.cpp index 683cd70d2..21910c5af 100644 --- a/retroshare-gui/src/gui/settings/NewTag.cpp +++ b/retroshare-gui/src/gui/settings/NewTag.cpp @@ -64,11 +64,6 @@ NewTag::NewTag(MsgTagType &Tags, uint32_t nId /*= 0*/, QWidget *parent, Qt::WFla showColor (m_Color); } -void NewTag::closeEvent (QCloseEvent * event) -{ - QDialog::closeEvent(event); -} - void NewTag::OnOK() { if (m_nId == 0) { diff --git a/retroshare-gui/src/gui/settings/NewTag.h b/retroshare-gui/src/gui/settings/NewTag.h index 3f9ec1ca8..9092d3aad 100644 --- a/retroshare-gui/src/gui/settings/NewTag.h +++ b/retroshare-gui/src/gui/settings/NewTag.h @@ -40,9 +40,6 @@ public: uint32_t m_nId; -protected: - void closeEvent (QCloseEvent * event); - private slots: void OnOK(); void OnCancel(); diff --git a/retroshare-gui/src/gui/settings/NotifyPage.cpp b/retroshare-gui/src/gui/settings/NotifyPage.cpp index 901ba77fb..bc3bbe42f 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.cpp +++ b/retroshare-gui/src/gui/settings/NotifyPage.cpp @@ -35,8 +35,6 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WFlags flags) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); - setAttribute(Qt::WA_QuitOnClose, false); - setWindowTitle(windowTitle() + QLatin1String(" - Notify")); /* Hide platform specific features */ #ifdef Q_WS_WIN @@ -48,12 +46,6 @@ NotifyPage::~NotifyPage() { } -void -NotifyPage::closeEvent (QCloseEvent * event) -{ - QWidget::closeEvent(event); -} - /** Saves the changes on this page */ bool NotifyPage::save(QString &errmsg) @@ -189,8 +181,3 @@ void NotifyPage::load() ui.spinBoxToasterXMargin->setValue(margin.x()); ui.spinBoxToasterYMargin->setValue(margin.y()); } - -/** Loads the settings for this page */ -void NotifyPage::updateStatus() -{ -} diff --git a/retroshare-gui/src/gui/settings/NotifyPage.h b/retroshare-gui/src/gui/settings/NotifyPage.h index 4a99e14d2..d984ccc38 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.h +++ b/retroshare-gui/src/gui/settings/NotifyPage.h @@ -22,38 +22,27 @@ #ifndef NOTIFYPAGE_H #define NOTIFYPAGE_H -#include -#include - #include "configpage.h" #include "ui_NotifyPage.h" class NotifyPage : public ConfigPage { - Q_OBJECT + Q_OBJECT - public: - /** Default Constructor */ - NotifyPage(QWidget * parent = 0, Qt::WFlags flags = 0); - /** Default Destructor */ - ~NotifyPage(); +public: + /** Default Constructor */ + NotifyPage(QWidget *parent = 0, Qt::WFlags flags = 0); + /** Default Destructor */ + ~NotifyPage(); - /** Saves the changes on this page */ - bool save(QString &errmsg); - /** Loads the settings for this page */ - void load(); + /** Saves the changes on this page */ + bool save(QString &errmsg); + /** Loads the settings for this page */ + void load(); - public slots: - void updateStatus(); - - private slots: - - private: - - void closeEvent (QCloseEvent * event); - - /** Qt Designer generated object */ - Ui::NotifyPage ui; +private: + /** Qt Designer generated object */ + Ui::NotifyPage ui; }; #endif // !NOTIFYPAGE_H diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp index 72fc7b641..ed1c30847 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.cpp +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -86,13 +86,6 @@ void ServerPage::toggleTunnelConnection(bool b) rsPeers->allowTunnelConnection(b) ; } -void -ServerPage::closeEvent (QCloseEvent * event) -{ - QWidget::closeEvent(event); -} - - /** Saves the changes on this page */ bool ServerPage::save(QString &errmsg) diff --git a/retroshare-gui/src/gui/settings/ServerPage.h b/retroshare-gui/src/gui/settings/ServerPage.h index 7e10244c4..05ec80f5c 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.h +++ b/retroshare-gui/src/gui/settings/ServerPage.h @@ -20,20 +20,18 @@ ****************************************************************/ #ifndef SERVERPAGE_H -# define SERVERPAGE_H - -# include +#define SERVERPAGE_H #include "configpage.h" #include "ui_ServerPage.h" class ServerPage: public ConfigPage { - Q_OBJECT + Q_OBJECT - public: - ServerPage(QWidget * parent = 0, Qt::WFlags flags = 0); - ~ServerPage() {} +public: + ServerPage(QWidget * parent = 0, Qt::WFlags flags = 0); + ~ServerPage() {} /** Saves the changes on this page */ bool save(QString &errmsg); @@ -41,20 +39,16 @@ class ServerPage: public ConfigPage void load(); public slots: - void updateStatus(); + void updateStatus(); private slots: - void saveAddresses(); - void toggleUPnP(); - void toggleIpDetermination(bool) ; - void toggleTunnelConnection(bool) ; + void saveAddresses(); + void toggleUPnP(); + void toggleIpDetermination(bool) ; + void toggleTunnelConnection(bool) ; - - private: - - void closeEvent (QCloseEvent * event); - - Ui::ServerPage ui; +private: + Ui::ServerPage ui; }; #endif // !SERVERPAGE_H diff --git a/retroshare-gui/src/gui/settings/TransferPage.cpp b/retroshare-gui/src/gui/settings/TransferPage.cpp index b3521d6ce..c799f1849 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.cpp +++ b/retroshare-gui/src/gui/settings/TransferPage.cpp @@ -80,10 +80,3 @@ void TransferPage::updateQueueSize(int s) { rsFiles->setQueueSize(s) ; } - -void TransferPage::closeEvent (QCloseEvent * event) -{ - QWidget::closeEvent(event); -} - - diff --git a/retroshare-gui/src/gui/settings/TransferPage.h b/retroshare-gui/src/gui/settings/TransferPage.h index 7540560bd..ddb2aaf7a 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.h +++ b/retroshare-gui/src/gui/settings/TransferPage.h @@ -47,8 +47,6 @@ class TransferPage: public ConfigPage private: - void closeEvent (QCloseEvent * event); - Ui::TransferPage ui; }; diff --git a/retroshare-gui/src/gui/settings/configpage.cpp b/retroshare-gui/src/gui/settings/configpage.cpp new file mode 100644 index 000000000..cc7de9495 --- /dev/null +++ b/retroshare-gui/src/gui/settings/configpage.cpp @@ -0,0 +1,44 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006 - 2010 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 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#include "configpage.h" + +ConfigPage::ConfigPage(QWidget *parent, Qt::WFlags flags) : QWidget(parent, flags) +{ + loaded = false; +} + +void ConfigPage::showEvent(QShowEvent *event) +{ + if (loaded) { + return; + } + + loaded = true; + + /* Load the settings */ + load(); +} + +bool ConfigPage::wasLoaded() +{ + return loaded; +} diff --git a/retroshare-gui/src/gui/settings/configpage.h b/retroshare-gui/src/gui/settings/configpage.h index 0e87e505a..d1091a036 100644 --- a/retroshare-gui/src/gui/settings/configpage.h +++ b/retroshare-gui/src/gui/settings/configpage.h @@ -1,7 +1,7 @@ /**************************************************************** - * This file is distributed under the following license: - * - * Copyright (c) 2006-2007, crypton + * This file is distributed under the following license: + * + * Copyright (c) 2006-2007, crypton * Copyright (c) 2006, Matt Edman, Justin Hipple * * This program is free software; you can redistribute it and/or @@ -30,13 +30,20 @@ class ConfigPage : public QWidget { public: /** Default Constructor */ - ConfigPage(QWidget *parent = 0, Qt::WFlags flags = 0) : QWidget(parent, flags) {} + ConfigPage(QWidget *parent = 0, Qt::WFlags flags = 0); /** Pure virtual method. Subclassed pages load their config settings here. */ virtual void load() = 0; /** 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(); + +protected: + void showEvent(QShowEvent * event); + + bool loaded; }; #endif diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index d1300ff09..efceb8c22 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -62,12 +62,6 @@ RSettingsWin::~RSettingsWin() _instance = NULL; } -void -RSettingsWin::closeEvent (QCloseEvent * event) -{ - QWidget::closeEvent(event); -} - /*static*/ void RSettingsWin::showYourself(QWidget *parent, PageType page /*= LastPage*/) { if(_instance == NULL) { @@ -121,8 +115,6 @@ RSettingsWin::initStackedWidget() stackedWidget->addWidget(new AppearancePage()); stackedWidget->addWidget(new SoundPage() ); - loadSettings(); /* load saved settings */ - setNewPage(General); } @@ -135,31 +127,31 @@ RSettingsWin::setNewPage(int page) { case General: text = tr("General"); - pageicon->setPixmap(QPixmap(":/images/kcmsystem24.png")); + pageicon->setPixmap(QPixmap(":/images/kcmsystem24.png")); break; case Directories: text = tr("Directories"); - pageicon->setPixmap(QPixmap(":/images/folder_doments.png")); + pageicon->setPixmap(QPixmap(":/images/folder_doments.png")); break; case Server: text = tr("Server"); - pageicon->setPixmap(QPixmap(":/images/server_24x24.png")); + pageicon->setPixmap(QPixmap(":/images/server_24x24.png")); break; case Transfer: text = tr("Transfer"); - pageicon->setPixmap(QPixmap(":/images/ktorrent32.png")); + pageicon->setPixmap(QPixmap(":/images/ktorrent32.png")); break; case Notify: text = tr("Notify"); - pageicon->setPixmap(QPixmap(":/images/status_unknown.png")); + pageicon->setPixmap(QPixmap(":/images/status_unknown.png")); break; case Security: text = tr("Security"); - pageicon->setPixmap(QPixmap(":/images/encrypted32.png")); + pageicon->setPixmap(QPixmap(":/images/encrypted32.png")); break; case Message: text = tr("Message"); - pageicon->setPixmap(QPixmap(":/images/evolution.png")); + pageicon->setPixmap(QPixmap(":/images/evolution.png")); break; case Forum: text = tr("Forum"); @@ -167,20 +159,20 @@ RSettingsWin::setNewPage(int page) break; case Chat: text = tr("Chat"); - pageicon->setPixmap(QPixmap(":/images/chat_24.png")); + pageicon->setPixmap(QPixmap(":/images/chat_24.png")); break; case Appearance: text = tr("Appearance"); - pageicon->setPixmap(QPixmap(":/images/looknfeel.png")); + pageicon->setPixmap(QPixmap(":/images/looknfeel.png")); break; /*// #ifndef RS_RELEASE_VERSION case Fileassociations: text = tr("File Associations"); - pageicon->setPixmap(QPixmap(":/images/filetype-association.png")); + pageicon->setPixmap(QPixmap(":/images/filetype-association.png")); break;*/ case Sound: text = tr("Sound"); - pageicon->setPixmap(QPixmap(":/images/sound.png")); + pageicon->setPixmap(QPixmap(":/images/sound.png")); break; // #endif default: @@ -192,19 +184,6 @@ RSettingsWin::setNewPage(int page) listWidget->setCurrentRow(page); } -void -RSettingsWin::loadSettings() -{ - /* Call each config page's load() method to load its data */ - int i, count = stackedWidget->count(); - for (i = 0; i < count; i++) { - ConfigPage *page = dynamic_cast (stackedWidget->widget(i)); - if (page) { - page->load(); - } - } -} - /** Saves changes made to settings. */ void RSettingsWin::saveChanges() @@ -216,25 +195,25 @@ RSettingsWin::saveChanges() for (i = 0; i < count; i++) { ConfigPage *page = dynamic_cast(stackedWidget->widget(i)); + if (page && page->wasLoaded()) { + if (!page->save(errmsg)) + { + /* Display the offending page */ + stackedWidget->setCurrentWidget(page); - if(page && !page->save(errmsg)) - { - /* Display the offending page */ - 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); - /* 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; + /* Don't process the rest of the pages */ + return; + } } } /* call to RsIface save function.... */ //rsicontrol -> ConfigSave(); - QDialog::close(); + close(); } - diff --git a/retroshare-gui/src/gui/settings/rsettingswin.h b/retroshare-gui/src/gui/settings/rsettingswin.h index f1084804b..3d390b85a 100755 --- a/retroshare-gui/src/gui/settings/rsettingswin.h +++ b/retroshare-gui/src/gui/settings/rsettingswin.h @@ -50,8 +50,6 @@ class RSettingsWin: public QDialog, private Ui::Settings void saveChanges(); private: - void loadSettings(); - void closeEvent (QCloseEvent * event); void initStackedWidget(); private: