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
This commit is contained in:
thunder2 2011-06-15 00:40:07 +00:00
parent 25b888d31f
commit 2a82826fba
27 changed files with 213 additions and 355 deletions

View File

@ -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 \

View File

@ -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)

View File

@ -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);

View File

@ -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()

View File

@ -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;
};

View File

@ -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<SharedDirInfo>::const_iterator it;
std::list<SharedDirInfo> 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);
}

View File

@ -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

View File

@ -611,13 +611,10 @@
<string>Shared Directories</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="dirList"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="checkBox">
<widget class="QCheckBox" name="shareDownloadDirectoryCB">
<property name="enabled">
<bool>true</bool>
</property>
@ -630,7 +627,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="editButton">
<widget class="QPushButton" name="editShareButton">
<property name="text">
<string>Edit Share</string>
</property>
@ -717,12 +714,24 @@ you plug it in.</string>
</layout>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<tabstops>
<tabstop>incomingDir</tabstop>
<tabstop>incomingButton</tabstop>
<tabstop>dirList</tabstop>
</tabstops>
<resources>
<include location="../images.qrc"/>

View File

@ -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)

View File

@ -22,13 +22,9 @@
#ifndef FORUMPAGE_H
#define FORUMPAGE_H
#include <QtGui/QWidget>
#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;
};

View File

@ -26,7 +26,6 @@
#include "configpage.h"
#include "ui_GeneralPage.h"
class GeneralPage : public ConfigPage
{
Q_OBJECT

View File

@ -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)

View File

@ -22,8 +22,6 @@
#ifndef MESSAGEPAGE_H
#define MESSAGEPAGE_H
#include <QtGui/QWidget>
#include <stdint.h>
#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 */

View File

@ -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()
{
}

View File

@ -22,27 +22,22 @@
#ifndef NETWORKPAGE_H
#define NETWORKPAGE_H
#include <QtGui/QWidget>
#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

View File

@ -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) {

View File

@ -40,9 +40,6 @@ public:
uint32_t m_nId;
protected:
void closeEvent (QCloseEvent * event);
private slots:
void OnOK();
void OnCancel();

View File

@ -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()
{
}

View File

@ -22,38 +22,27 @@
#ifndef NOTIFYPAGE_H
#define NOTIFYPAGE_H
#include <QFileDialog>
#include <QtGui/QWidget>
#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

View File

@ -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)

View File

@ -20,20 +20,18 @@
****************************************************************/
#ifndef SERVERPAGE_H
# define SERVERPAGE_H
# include <QtGui/QWidget>
#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

View File

@ -80,10 +80,3 @@ void TransferPage::updateQueueSize(int s)
{
rsFiles->setQueueSize(s) ;
}
void TransferPage::closeEvent (QCloseEvent * event)
{
QWidget::closeEvent(event);
}

View File

@ -47,8 +47,6 @@ class TransferPage: public ConfigPage
private:
void closeEvent (QCloseEvent * event);
Ui::TransferPage ui;
};

View File

@ -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;
}

View File

@ -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

View File

@ -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<ConfigPage *> (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<ConfigPage *>(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();
}

View File

@ -50,8 +50,6 @@ class RSettingsWin: public QDialog, private Ui::Settings
void saveChanges();
private:
void loadSettings();
void closeEvent (QCloseEvent * event);
void initStackedWidget();
private: