mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
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:
parent
25b888d31f
commit
2a82826fba
@ -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 \
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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);
|
||||
if (qdir.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string dir = qdir.toUtf8().constData();
|
||||
if (dir != "")
|
||||
{
|
||||
rsFiles->setDownloadDirectory(dir);
|
||||
if (ui.checkBox->isChecked())
|
||||
{
|
||||
rsFiles->shareDownloadDirectory(true);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
load();
|
||||
if (qdir.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
void DirectoriesPage::shareDownloadDirectory(int state)
|
||||
{
|
||||
rsFiles->shareDownloadDirectory(state == Qt::Checked);
|
||||
load();
|
||||
ui.partialsDir->setText(qdir);
|
||||
}
|
||||
|
@ -31,31 +31,22 @@ class DirectoriesPage: public ConfigPage
|
||||
|
||||
public:
|
||||
DirectoriesPage(QWidget * parent = 0, Qt::WFlags flags = 0);
|
||||
// ~DirectoriesPage() {}
|
||||
|
||||
/** Saves the changes on this page */
|
||||
bool save(QString &errmsg);
|
||||
/** Loads the settings for this page */
|
||||
void load();
|
||||
|
||||
|
||||
|
||||
private slots:
|
||||
|
||||
void editDirectories() ;
|
||||
void setIncomingDirectory();
|
||||
void setPartialsDirectory();
|
||||
void shareDownloadDirectory(int state);
|
||||
void clearHashCache();
|
||||
void setRememberHashesDuration(int) ;
|
||||
void toggleRememberHashes(bool) ;
|
||||
void setAutoCheckDirectoriesDelay(int) ;
|
||||
void clickedRememberHashes(bool);
|
||||
void toggleRememberHashes();
|
||||
void toggleAutoCheckDirectories(bool);
|
||||
|
||||
private:
|
||||
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
||||
Ui::DirectoriesPage ui;
|
||||
};
|
||||
|
||||
|
@ -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"/>
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "configpage.h"
|
||||
#include "ui_GeneralPage.h"
|
||||
|
||||
|
||||
class GeneralPage : public ConfigPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -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)
|
||||
|
@ -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 */
|
||||
|
@ -30,13 +30,6 @@ NetworkPage::NetworkPage(QWidget * parent, Qt::WFlags flags)
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
NetworkPage::closeEvent (QCloseEvent * event)
|
||||
{
|
||||
QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
|
||||
/** Saves the changes on this page */
|
||||
bool
|
||||
NetworkPage::save(QString &errmsg)
|
||||
@ -48,6 +41,5 @@ NetworkPage::save(QString &errmsg)
|
||||
void
|
||||
NetworkPage::load()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,6 @@
|
||||
#ifndef NETWORKPAGE_H
|
||||
#define NETWORKPAGE_H
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
#include "configpage.h"
|
||||
#include "ui_NetworkPage.h"
|
||||
|
||||
@ -39,9 +37,6 @@ class NetworkPage : public ConfigPage
|
||||
void load();
|
||||
|
||||
private:
|
||||
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
||||
Ui::NetworkPage ui;
|
||||
};
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -40,9 +40,6 @@ public:
|
||||
|
||||
uint32_t m_nId;
|
||||
|
||||
protected:
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
||||
private slots:
|
||||
void OnOK();
|
||||
void OnCancel();
|
||||
|
@ -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()
|
||||
{
|
||||
}
|
||||
|
@ -22,9 +22,6 @@
|
||||
#ifndef NOTIFYPAGE_H
|
||||
#define NOTIFYPAGE_H
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
#include "configpage.h"
|
||||
#include "ui_NotifyPage.h"
|
||||
|
||||
@ -43,15 +40,7 @@ class NotifyPage : public ConfigPage
|
||||
/** 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;
|
||||
};
|
||||
|
@ -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)
|
||||
|
@ -22,8 +22,6 @@
|
||||
#ifndef SERVERPAGE_H
|
||||
#define SERVERPAGE_H
|
||||
|
||||
# include <QtGui/QWidget>
|
||||
|
||||
#include "configpage.h"
|
||||
#include "ui_ServerPage.h"
|
||||
|
||||
@ -49,11 +47,7 @@ private slots:
|
||||
void toggleIpDetermination(bool) ;
|
||||
void toggleTunnelConnection(bool) ;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
||||
Ui::ServerPage ui;
|
||||
};
|
||||
|
||||
|
@ -80,10 +80,3 @@ void TransferPage::updateQueueSize(int s)
|
||||
{
|
||||
rsFiles->setQueueSize(s) ;
|
||||
}
|
||||
|
||||
void TransferPage::closeEvent (QCloseEvent * event)
|
||||
{
|
||||
QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,8 +47,6 @@ class TransferPage: public ConfigPage
|
||||
|
||||
private:
|
||||
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
||||
Ui::TransferPage ui;
|
||||
};
|
||||
|
||||
|
44
retroshare-gui/src/gui/settings/configpage.cpp
Normal file
44
retroshare-gui/src/gui/settings/configpage.cpp
Normal 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;
|
||||
}
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
@ -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,8 +195,8 @@ RSettingsWin::saveChanges()
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
ConfigPage *page = dynamic_cast<ConfigPage *>(stackedWidget->widget(i));
|
||||
|
||||
if(page && !page->save(errmsg))
|
||||
if (page && page->wasLoaded()) {
|
||||
if (!page->save(errmsg))
|
||||
{
|
||||
/* Display the offending page */
|
||||
stackedWidget->setCurrentWidget(page);
|
||||
@ -231,10 +210,10 @@ RSettingsWin::saveChanges()
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* call to RsIface save function.... */
|
||||
//rsicontrol -> ConfigSave();
|
||||
|
||||
QDialog::close();
|
||||
close();
|
||||
}
|
||||
|
||||
|
@ -50,8 +50,6 @@ class RSettingsWin: public QDialog, private Ui::Settings
|
||||
void saveChanges();
|
||||
|
||||
private:
|
||||
void loadSettings();
|
||||
void closeEvent (QCloseEvent * event);
|
||||
void initStackedWidget();
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user