code refactoring and other small changes

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1558 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
alexandrut 2009-08-19 22:15:16 +00:00
parent 39882161b1
commit 19920e95bc
22 changed files with 204 additions and 186 deletions

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -26,14 +26,14 @@
/** Constructor */ /** Constructor */
AppearancePage::AppearancePage(QWidget * parent, Qt::WFlags flags) AppearancePage::AppearancePage(QWidget * parent, Qt::WFlags flags)
: QWidget(parent, flags) : ConfigPage(parent, flags)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
/* Create RshareSettings object */ /* Create RshareSettings object */
_settings = new RshareSettings(); _settings = new RshareSettings();
connect(ui.styleSheetCombo, SIGNAL(clicked()), this, SLOT(loadStyleSheet())); connect(ui.styleSheetCombo, SIGNAL(clicked()), this, SLOT(loadStyleSheet()));
/* Populate combo boxes */ /* Populate combo boxes */
@ -45,13 +45,13 @@ AppearancePage::AppearancePage(QWidget * parent, Qt::WFlags flags)
foreach (QString style, QStyleFactory::keys()) { foreach (QString style, QStyleFactory::keys()) {
ui.cmboStyle->addItem(style, style.toLower()); ui.cmboStyle->addItem(style, style.toLower());
} }
ui.styleSheetCombo->setCurrentIndex(ui.styleSheetCombo->findText("Default")); ui.styleSheetCombo->setCurrentIndex(ui.styleSheetCombo->findText("Default"));
//loadStyleSheet("Default"); //loadStyleSheet("Default");
loadqss(); loadqss();
load(); load();
/* Hide platform specific features */ /* Hide platform specific features */
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
@ -66,11 +66,11 @@ AppearancePage::save(QString &errmsg)
Q_UNUSED(errmsg); Q_UNUSED(errmsg);
QString languageCode = QString languageCode =
LanguageSupport::languageCode(ui.cmboLanguage->currentText()); LanguageSupport::languageCode(ui.cmboLanguage->currentText());
_settings->setLanguageCode(languageCode); _settings->setLanguageCode(languageCode);
_settings->setInterfaceStyle(ui.cmboStyle->currentText()); _settings->setInterfaceStyle(ui.cmboStyle->currentText());
_settings->setSheetName(ui.styleSheetCombo->currentText()); _settings->setSheetName(ui.styleSheetCombo->currentText());
/* Set to new style */ /* Set to new style */
Rshare::setStyle(ui.cmboStyle->currentText()); Rshare::setStyle(ui.cmboStyle->currentText());
return true; return true;
@ -82,21 +82,21 @@ AppearancePage::save(QString &errmsg)
void void
AppearancePage::load() AppearancePage::load()
{ {
int index = ui.cmboLanguage->findData(_settings->getLanguageCode()); int index = ui.cmboLanguage->findData(_settings->getLanguageCode());
ui.cmboLanguage->setCurrentIndex(index); ui.cmboLanguage->setCurrentIndex(index);
index = ui.cmboStyle->findData(Rshare::style().toLower()); index = ui.cmboStyle->findData(Rshare::style().toLower());
ui.cmboStyle->setCurrentIndex(index); ui.cmboStyle->setCurrentIndex(index);
ui.styleSheetCombo->setCurrentIndex(ui.styleSheetCombo->findText(_settings->getSheetName())); ui.styleSheetCombo->setCurrentIndex(ui.styleSheetCombo->findText(_settings->getSheetName()));
/** load saved internal styleSheet **/ /** load saved internal styleSheet **/
//QFile file(":/qss/" + (_settings->getSheetName().toLower()) + ".qss"); //QFile file(":/qss/" + (_settings->getSheetName().toLower()) + ".qss");
/** load saved extern Stylesheets **/ /** load saved extern Stylesheets **/
QFile file(QApplication::applicationDirPath() + "/qss/" + (_settings->getSheetName().toLower()) + ".qss"); QFile file(QApplication::applicationDirPath() + "/qss/" + (_settings->getSheetName().toLower()) + ".qss");
file.open(QFile::ReadOnly); file.open(QFile::ReadOnly);
QString styleSheet = QLatin1String(file.readAll()); QString styleSheet = QLatin1String(file.readAll());
qApp->setStyleSheet(styleSheet); qApp->setStyleSheet(styleSheet);
@ -112,16 +112,16 @@ void AppearancePage::loadStyleSheet(const QString &sheetName)
{ {
/** internal Stylesheets **/ /** internal Stylesheets **/
//QFile file(":/qss/" + sheetName.toLower() + ".qss"); //QFile file(":/qss/" + sheetName.toLower() + ".qss");
/** extern Stylesheets **/ /** extern Stylesheets **/
QFile file(QApplication::applicationDirPath() + "/qss/" + sheetName.toLower() + ".qss"); QFile file(QApplication::applicationDirPath() + "/qss/" + sheetName.toLower() + ".qss");
file.open(QFile::ReadOnly); file.open(QFile::ReadOnly);
QString styleSheet = QLatin1String(file.readAll()); QString styleSheet = QLatin1String(file.readAll());
qApp->setStyleSheet(styleSheet); qApp->setStyleSheet(styleSheet);
} }
void AppearancePage::loadqss() void AppearancePage::loadqss()
@ -133,5 +133,5 @@ void AppearancePage::loadqss()
if(st.fileName() != "." && st.fileName() != ".." && st.isFile()) if(st.fileName() != "." && st.fileName() != ".." && st.isFile())
ui.styleSheetCombo->addItem(st.fileName().remove(".qss")); ui.styleSheetCombo->addItem(st.fileName().remove(".qss"));
} }
} }

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -29,9 +29,10 @@
#include "gui/Preferences/rsharesettings.h" #include "gui/Preferences/rsharesettings.h"
#include <lang/languagesupport.h> #include <lang/languagesupport.h>
#include "configpage.h"
#include "ui_AppearancePage.h" #include "ui_AppearancePage.h"
class AppearancePage : public QWidget class AppearancePage : public ConfigPage
{ {
Q_OBJECT Q_OBJECT
@ -50,11 +51,11 @@ class AppearancePage : public QWidget
void on_styleSheetCombo_activated(const QString &styleSheetName); void on_styleSheetCombo_activated(const QString &styleSheetName);
private: private:
/** A RshareSettings object used for saving/loading settings */ /** A RshareSettings object used for saving/loading settings */
RshareSettings* _settings; RshareSettings* _settings;
void loadStyleSheet(const QString &sheetName); void loadStyleSheet(const QString &sheetName);
void loadqss(); void loadqss();

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -34,7 +34,7 @@
/** Constructor */ /** Constructor */
CryptoPage::CryptoPage(QWidget * parent, Qt::WFlags flags) CryptoPage::CryptoPage(QWidget * parent, Qt::WFlags flags)
: QWidget(parent, flags) : ConfigPage(parent, flags)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
@ -114,7 +114,7 @@ CryptoPage::copyPublicKey()
tr("Your Public Key is copied to Clipbard, paste and send it to your" tr("Your Public Key is copied to Clipbard, paste and send it to your"
"friend via email or some other way")); "friend via email or some other way"));
QClipboard *clipboard = QApplication::clipboard(); QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(ui.certtextEdit->toPlainText()); clipboard->setText(ui.certtextEdit->toPlainText());
} }

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -28,9 +28,10 @@
#include <gui/Preferences/rsharesettings.h> #include <gui/Preferences/rsharesettings.h>
#include "gui/connect/ConnectFriendWizard.h" #include "gui/connect/ConnectFriendWizard.h"
#include "configpage.h"
#include "ui_CryptoPage.h" #include "ui_CryptoPage.h"
class CryptoPage : public QWidget class CryptoPage : public ConfigPage
{ {
Q_OBJECT Q_OBJECT
@ -54,11 +55,11 @@ class CryptoPage : public QWidget
void exportPublicKey(); void exportPublicKey();
private: private:
/** A RshareSettings object used for saving/loading settings */ /** A RshareSettings object used for saving/loading settings */
RshareSettings* _settings; RshareSettings* _settings;
void closeEvent (QCloseEvent * event); void closeEvent (QCloseEvent * event);

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -27,15 +27,14 @@
#include <algorithm> #include <algorithm>
DirectoriesPage::DirectoriesPage(QWidget * parent, Qt::WFlags flags) DirectoriesPage::DirectoriesPage(QWidget * parent, Qt::WFlags flags)
: QWidget(parent, flags) : ConfigPage(parent, flags)
{ {
ui.setupUi(this); ui.setupUi(this);
setAttribute(Qt::WA_QuitOnClose, false); setAttribute(Qt::WA_QuitOnClose, false);
load(); load();
connect(ui.incomingButton, SIGNAL(clicked( bool ) ), this , SLOT( setIncomingDirectory() ) ); connect(ui.incomingButton, SIGNAL(clicked( bool ) ), this , SLOT( setIncomingDirectory() ) );
connect(ui.partialButton, SIGNAL(clicked( bool ) ), this , SLOT( setPartialsDirectory() ) ); connect(ui.partialButton, SIGNAL(clicked( bool ) ), this , SLOT( setPartialsDirectory() ) );
connect(ui.checkBox, SIGNAL(stateChanged(int)), this, SLOT(shareDownloadDirectory(int))); connect(ui.checkBox, SIGNAL(stateChanged(int)), this, SLOT(shareDownloadDirectory(int)));
@ -108,7 +107,7 @@ bool DirectoriesPage::save(QString &errmsg)
return true; return true;
} }
/** Loads the settings for this page */ /** Loads the settings for this page */
void DirectoriesPage::load() void DirectoriesPage::load()
{ {

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -26,17 +26,17 @@
#include <QWidget> #include <QWidget>
#include <QtGui> #include <QtGui>
#include "configpage.h"
#include "ui_DirectoriesPage.h"
# include "ui_DirectoriesPage.h" class DirectoriesPage: public ConfigPage
class DirectoriesPage: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
DirectoriesPage(QWidget * parent = 0, Qt::WFlags flags = 0); DirectoriesPage(QWidget * parent = 0, Qt::WFlags flags = 0);
// ~DirectoriesPage() {} // ~DirectoriesPage() {}
/** Saves the changes on this page */ /** Saves the changes on this page */
bool save(QString &errmsg); bool save(QString &errmsg);
/** Loads the settings for this page */ /** Loads the settings for this page */
@ -45,7 +45,7 @@ class DirectoriesPage: public QWidget
private slots: private slots:
#ifdef TO_REMOVE #ifdef TO_REMOVE
void addShareDirectory(); void addShareDirectory();
void removeShareDirectory(); void removeShareDirectory();
@ -57,9 +57,9 @@ class DirectoriesPage: public QWidget
void shareDownloadDirectory(int state); void shareDownloadDirectory(int state);
private: private:
void closeEvent (QCloseEvent * event); void closeEvent (QCloseEvent * event);
Ui::DirectoriesPage ui; Ui::DirectoriesPage ui;
}; };

View file

@ -54,7 +54,7 @@
//============================================================================ //============================================================================
FileAssociationsPage::FileAssociationsPage(QWidget * parent, Qt::WFlags flags) FileAssociationsPage::FileAssociationsPage(QWidget * parent, Qt::WFlags flags)
: QWidget(parent, flags) : ConfigPage(parent, flags)
//:QFrame() //:QFrame()
{ {
QVBoxLayout* pageLay = new QVBoxLayout(this); QVBoxLayout* pageLay = new QVBoxLayout(this);
@ -82,7 +82,7 @@ FileAssociationsPage::FileAssociationsPage(QWidget * parent, Qt::WFlags flags)
table = new QTableWidget(5,2,this);//default 5 rows, 2 columns table = new QTableWidget(5,2,this);//default 5 rows, 2 columns
table->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("File type") ) ); table->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("File type") ) );
table->setHorizontalHeaderItem(1, new QTableWidgetItem("Command") ); table->setHorizontalHeaderItem(1, new QTableWidgetItem("Command") );
connect( table, SIGNAL( cellActivated(int, int)), connect( table, SIGNAL( cellActivated(int, int)),
this, SLOT( tableCellActivated(int, int)) ); this, SLOT( tableCellActivated(int, int)) );
@ -194,7 +194,7 @@ FileAssociationsPage::load()
removeAction->setEnabled(false); removeAction->setEnabled(false);
editAction->setEnabled(false); editAction->setEnabled(false);
} }
table->selectRow(0); table->selectRow(0);
} }
@ -255,7 +255,7 @@ FileAssociationsPage::addnew()
} }
} }
} }
settings->setValue(currType, currCmd); settings->setValue(currType, currCmd);
removeAction->setEnabled(true); removeAction->setEnabled(true);
@ -279,17 +279,17 @@ FileAssociationsPage::edit()
QString currCmd = (titem->data(QTableWidgetItem::Type)).toString(); QString currCmd = (titem->data(QTableWidgetItem::Type)).toString();
afad.setCommand(currCmd); afad.setCommand(currCmd);
afad.setFileType(currType); afad.setFileType(currType);
int ti = afad.exec(); int ti = afad.exec();
if (ti==QDialog::Accepted) if (ti==QDialog::Accepted)
{ {
currCmd = afad.resultCommand() ; currCmd = afad.resultCommand() ;
titem = table->item( currentRow,1); titem = table->item( currentRow,1);
titem->setData(QTableWidgetItem::Type, currCmd); titem->setData(QTableWidgetItem::Type, currCmd);
settings->setValue(currType, currCmd); settings->setValue(currType, currCmd);
} }
} }

View file

@ -22,7 +22,7 @@
#ifndef __FileAssociationsPage__ #ifndef __FileAssociationsPage__
#define __FileAssociationsPage__ #define __FileAssociationsPage__
//#include "configpage.h" #include "configpage.h"
#include <QString> #include <QString>
#include <QWidget> #include <QWidget>
@ -52,11 +52,11 @@ class RshareSettings;
//! With this config page user can specify, what programs should be executed //! With this config page user can specify, what programs should be executed
//! to open some types of files. Here 'type' means 'file extension'(and //! to open some types of files. Here 'type' means 'file extension'(and
//! 'file extension' means 'some symbols after last dot in filename'). //! 'file extension' means 'some symbols after last dot in filename').
class FileAssociationsPage : public QWidget class FileAssociationsPage : public ConfigPage
{ {
Q_OBJECT Q_OBJECT
public: public:
FileAssociationsPage(QWidget * parent = 0, Qt::WFlags flags = 0); FileAssociationsPage(QWidget * parent = 0, Qt::WFlags flags = 0);
virtual ~FileAssociationsPage(); virtual ~FileAssociationsPage();

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -26,14 +26,14 @@
/** Constructor */ /** Constructor */
GeneralPage::GeneralPage(QWidget * parent, Qt::WFlags flags) GeneralPage::GeneralPage(QWidget * parent, Qt::WFlags flags)
: QWidget(parent, flags) : ConfigPage(parent, flags)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
/* Create RshareSettings object */ /* Create RshareSettings object */
_settings = new RshareSettings(); _settings = new RshareSettings();
load(); load();
/* Hide platform specific features */ /* Hide platform specific features */
@ -41,7 +41,7 @@ GeneralPage::GeneralPage(QWidget * parent, Qt::WFlags flags)
ui.chkRunRetroshareAtSystemStartup->setVisible(false); ui.chkRunRetroshareAtSystemStartup->setVisible(false);
//ui.autologincheckBox->setEnabled(false) ; //ui.autologincheckBox->setEnabled(false) ;
//ui.autologincheckBox->setChecked(false) ; //ui.autologincheckBox->setChecked(false) ;
#endif #endif
} }
/** Destructor */ /** Destructor */
@ -53,30 +53,30 @@ GeneralPage::GeneralPage(QWidget * parent, Qt::WFlags flags)
/** Saves the changes on this page */ /** Saves the changes on this page */
bool bool
GeneralPage::save(QString &errmsg) GeneralPage::save(QString &errmsg)
{ {
_settings->setValue(QString::fromUtf8("StartMinimized"), startMinimized()); _settings->setValue(QString::fromUtf8("StartMinimized"), startMinimized());
_settings->setValue(QString::fromUtf8("doQuit"), quit()); _settings->setValue(QString::fromUtf8("doQuit"), quit());
_settings->setRunRetroshareOnBoot( _settings->setRunRetroshareOnBoot(
ui.chkRunRetroshareAtSystemStartup->isChecked()); ui.chkRunRetroshareAtSystemStartup->isChecked());
return true; return true;
} }
/** Loads the settings for this page */ /** Loads the settings for this page */
void void
GeneralPage::load() GeneralPage::load()
{ {
ui.chkRunRetroshareAtSystemStartup->setChecked( ui.chkRunRetroshareAtSystemStartup->setChecked(
_settings->runRetroshareOnBoot()); _settings->runRetroshareOnBoot());
ui.checkStartMinimized->setChecked(_settings->value(QString::fromUtf8("StartMinimized"), false).toBool()); ui.checkStartMinimized->setChecked(_settings->value(QString::fromUtf8("StartMinimized"), false).toBool());
ui.checkQuit->setChecked(_settings->value(QString::fromUtf8("doQuit"), false).toBool()); ui.checkQuit->setChecked(_settings->value(QString::fromUtf8("doQuit"), false).toBool());
} }
bool GeneralPage::quit() const { bool GeneralPage::quit() const {
if(ui.checkQuit->isChecked()) return true; if(ui.checkQuit->isChecked()) return true;
return ui.checkQuit->isChecked(); return ui.checkQuit->isChecked();

View file

@ -16,7 +16,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -29,17 +29,18 @@
#include "gui/Preferences/rsharesettings.h" #include "gui/Preferences/rsharesettings.h"
#include "configpage.h"
#include "ui_GeneralPage.h" #include "ui_GeneralPage.h"
class GeneralPage : public QWidget class GeneralPage : public ConfigPage
{ {
Q_OBJECT Q_OBJECT
public: public:
/** Default Constructor */ /** Default Constructor */
GeneralPage(QWidget * parent = 0, Qt::WFlags flags = 0); GeneralPage(QWidget * parent = 0, Qt::WFlags flags = 0);
/** Default Destructor */ /** Default Destructor */
~GeneralPage() {} ~GeneralPage() {}
/** Saves the changes on this page */ /** Saves the changes on this page */
@ -54,13 +55,13 @@ private slots:
/** Called when the "show on startup" checkbox is toggled. */ /** Called when the "show on startup" checkbox is toggled. */
void toggleShowOnStartup(bool checked); void toggleShowOnStartup(bool checked);
private: private:
/** A RetroShare Settings object used for saving/loading settings */ /** A RetroShare Settings object used for saving/loading settings */
RshareSettings *_settings; RshareSettings *_settings;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::GeneralPage ui; Ui::GeneralPage ui;
}; };

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -23,7 +23,7 @@
#include "rshare.h" #include "rshare.h"
NetworkPage::NetworkPage(QWidget * parent, Qt::WFlags flags) NetworkPage::NetworkPage(QWidget * parent, Qt::WFlags flags)
: QWidget(parent, flags) : ConfigPage(parent, flags)
{ {
ui.setupUi(this); ui.setupUi(this);
setAttribute(Qt::WA_QuitOnClose, false); setAttribute(Qt::WA_QuitOnClose, false);
@ -41,9 +41,9 @@ NetworkPage::closeEvent (QCloseEvent * event)
bool bool
NetworkPage::save(QString &errmsg) NetworkPage::save(QString &errmsg)
{ {
return true;
} }
/** Loads the settings for this page */ /** Loads the settings for this page */
void void
NetworkPage::load() NetworkPage::load()

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -23,23 +23,25 @@
#define NETWORKPAGE_H #define NETWORKPAGE_H
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include "configpage.h"
#include "ui_NetworkPage.h" #include "ui_NetworkPage.h"
class NetworkPage: public QWidget class NetworkPage : public ConfigPage
{ {
public: public:
NetworkPage(QWidget * parent = 0, Qt::WFlags flags = 0); NetworkPage(QWidget * parent = 0, Qt::WFlags flags = 0);
~NetworkPage() {} ~NetworkPage() {}
/** Saves the changes on this page */ /** Saves the changes on this page */
bool save(QString &errmsg); bool save(QString &errmsg);
/** Loads the settings for this page */ /** Loads the settings for this page */
void load(); void load();
private: private:
void closeEvent (QCloseEvent * event); void closeEvent (QCloseEvent * event);
Ui::NetworkPage ui; Ui::NetworkPage ui;
}; };

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -32,13 +32,13 @@
/** Constructor */ /** Constructor */
NotifyPage::NotifyPage(QWidget * parent, Qt::WFlags flags) NotifyPage::NotifyPage(QWidget * parent, Qt::WFlags flags)
: QWidget(parent, flags) : ConfigPage(parent, flags)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
setAttribute(Qt::WA_QuitOnClose, false); setAttribute(Qt::WA_QuitOnClose, false);
setWindowTitle(windowTitle() + QLatin1String(" - Notify")); setWindowTitle(windowTitle() + QLatin1String(" - Notify"));
/* Create RshareSettings object */ /* Create RshareSettings object */
_settings = new RshareSettings(); _settings = new RshareSettings();

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -27,13 +27,13 @@
#include "gui/Preferences/rsharesettings.h" #include "gui/Preferences/rsharesettings.h"
#include "configpage.h"
#include "ui_NotifyPage.h" #include "ui_NotifyPage.h"
class NotifyPage : public QWidget class NotifyPage : public ConfigPage
{ {
Q_OBJECT Q_OBJECT
public: public:
/** Default Constructor */ /** Default Constructor */
NotifyPage(QWidget * parent = 0, Qt::WFlags flags = 0); NotifyPage(QWidget * parent = 0, Qt::WFlags flags = 0);
@ -51,9 +51,9 @@ class NotifyPage : public QWidget
private slots: private slots:
private: private:
void closeEvent (QCloseEvent * event); void closeEvent (QCloseEvent * event);
/** A RshareSettings object used for saving/loading settings */ /** A RshareSettings object used for saving/loading settings */
RshareSettings* _settings; RshareSettings* _settings;

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -33,7 +33,7 @@
#include <QTimer> #include <QTimer>
ServerPage::ServerPage(QWidget * parent, Qt::WFlags flags) ServerPage::ServerPage(QWidget * parent, Qt::WFlags flags)
: QWidget(parent, flags) : ConfigPage(parent, flags)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
@ -154,7 +154,7 @@ void ServerPage::load()
toggleUPnP(); toggleUPnP();
/* Addresses must be set here - otherwise can't edit it */ /* Addresses must be set here - otherwise can't edit it */
/* set local address */ /* set local address */
@ -262,7 +262,7 @@ void ServerPage::updateStatus()
ui.netStatusBox->setText(QString::fromStdString(out.str())); ui.netStatusBox->setText(QString::fromStdString(out.str()));
ui.netStatusBox ->setReadOnly(true); ui.netStatusBox ->setReadOnly(true);
#endif #endif

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -23,16 +23,18 @@
# define SERVERPAGE_H # define SERVERPAGE_H
# include <QtGui/QWidget> # include <QtGui/QWidget>
# include "ui_ServerPage.h"
class ServerPage: public QWidget #include "configpage.h"
#include "ui_ServerPage.h"
class ServerPage: public ConfigPage
{ {
Q_OBJECT Q_OBJECT
public: public:
ServerPage(QWidget * parent = 0, Qt::WFlags flags = 0); ServerPage(QWidget * parent = 0, Qt::WFlags flags = 0);
~ServerPage() {} ~ServerPage() {}
/** Saves the changes on this page */ /** Saves the changes on this page */
bool save(QString &errmsg); bool save(QString &errmsg);
/** Loads the settings for this page */ /** Loads the settings for this page */
@ -45,13 +47,13 @@ private slots:
void saveAddresses(); void saveAddresses();
void toggleUPnP(); void toggleUPnP();
void toggleIpDetermination(bool) ; void toggleIpDetermination(bool) ;
void showTurtleRouterDialog(); void showTurtleRouterDialog();
private: private:
void closeEvent (QCloseEvent * event); void closeEvent (QCloseEvent * event);
Ui::ServerPage ui; Ui::ServerPage ui;
}; };

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -26,14 +26,14 @@
/** Constructor */ /** Constructor */
SoundPage::SoundPage(QWidget * parent, Qt::WFlags flags) SoundPage::SoundPage(QWidget * parent, Qt::WFlags flags)
: QWidget(parent, flags) : ConfigPage(parent, flags)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
/* Create RshareSettings object */ /* Create RshareSettings object */
_settings = new RshareSettings(); _settings = new RshareSettings();
connect(ui.cmd_openFile, SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile())); connect(ui.cmd_openFile, SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile()));
connect(ui.cmd_openFile_2,SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile2())); connect(ui.cmd_openFile_2,SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile2()));
connect(ui.cmd_openFile_3,SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile3())); connect(ui.cmd_openFile_3,SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile3()));
@ -104,7 +104,7 @@ SoundPage::load()
ui.checkBoxSound_4->setChecked(_settings->value("FileRecive_Incoming",false).toBool()); ui.checkBoxSound_4->setChecked(_settings->value("FileRecive_Incoming",false).toBool());
ui.checkBoxSound_5->setChecked(_settings->value("FileRecive_Finished",false).toBool()); ui.checkBoxSound_5->setChecked(_settings->value("FileRecive_Finished",false).toBool());
ui.checkBoxSound_6->setChecked(_settings->value("NewChatMessage",false).toBool()); ui.checkBoxSound_6->setChecked(_settings->value("NewChatMessage",false).toBool());
_settings->endGroup(); _settings->endGroup();
_settings->endGroup(); _settings->endGroup();
} }
@ -123,10 +123,10 @@ void SoundPage::on_cmd_openFile()
void SoundPage::on_cmd_openFile2() void SoundPage::on_cmd_openFile2()
{ {
ui.txt_SoundFile2->setText(QFileDialog::getOpenFileName(this,"Open File", ".", "wav (*.wav)")); ui.txt_SoundFile2->setText(QFileDialog::getOpenFileName(this,"Open File", ".", "wav (*.wav)"));
if(ui.txt_SoundFile2->text().isEmpty()){ if(ui.txt_SoundFile2->text().isEmpty()){
ui.checkBoxSound_2->setChecked(false); ui.checkBoxSound_2->setChecked(false);
ui.checkBoxSound_2->setEnabled(false); ui.checkBoxSound_2->setEnabled(false);
} }
else else
ui.checkBoxSound_2->setEnabled(true); ui.checkBoxSound_2->setEnabled(true);
@ -170,5 +170,5 @@ void SoundPage::on_cmd_openFile6()
} }
else else
ui.checkBoxSound_6->setEnabled(true); ui.checkBoxSound_6->setEnabled(true);
} }

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -26,15 +26,16 @@
#include <gui/Preferences/rsharesettings.h> #include <gui/Preferences/rsharesettings.h>
#include "configpage.h"
#include "ui_SoundPage.h" #include "ui_SoundPage.h"
class SoundPage : public QWidget class SoundPage : public ConfigPage
{ {
Q_OBJECT Q_OBJECT
public: public:
/** Default Constructor */ /** Default Constructor */
SoundPage(QWidget * parent = 0, Qt::WFlags flags = 0); SoundPage(QWidget * parent = 0, Qt::WFlags flags = 0);
/** Default Destructor */ /** Default Destructor */
~SoundPage() {} ~SoundPage() {}
@ -51,7 +52,7 @@ private slots:
void on_cmd_openFile4(); void on_cmd_openFile4();
void on_cmd_openFile5(); void on_cmd_openFile5();
void on_cmd_openFile6(); void on_cmd_openFile6();
private: private:
/** A RshareSettings object used for saving/loading settings */ /** A RshareSettings object used for saving/loading settings */
RshareSettings* _settings; RshareSettings* _settings;

View file

@ -0,0 +1,43 @@
/****************************************************************
* 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
* 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.
****************************************************************/
#ifndef _CONFIGPAGE_H
#define _CONFIGPAGE_H
#include <QWidget>
class ConfigPage : public QWidget
{
public:
/** Default Constructor */
ConfigPage(QWidget *parent = 0, Qt::WFlags flags = 0) : QWidget(parent, flags) {}
/** 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;
};
#endif

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -43,18 +43,20 @@ RSettingsWin::RSettingsWin(QWidget * parent, Qt::WFlags flags)
initStackedWidget(); initStackedWidget();
connect(listWidget, SIGNAL(currentRowChanged(int)), connect(listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(setNewPage(int)));
this, SLOT(setNewPage(int)));
connect(okButton, SIGNAL(clicked( bool )), this, SLOT( saveChanges()) ); connect(okButton, SIGNAL(clicked( bool )), this, SLOT( saveChanges()) );
}
void
RSettingsWin::showWindow(int page)
{
setNewPage(page);
QDialog::show();
} }
void void
RSettingsWin::closeEvent (QCloseEvent * event) RSettingsWin::closeEvent (QCloseEvent * event)
{ {
QWidget::closeEvent(event); QWidget::closeEvent(event);
} }
@ -64,8 +66,7 @@ RSettingsWin::initStackedWidget()
stackedWidget->setCurrentIndex(-1); stackedWidget->setCurrentIndex(-1);
stackedWidget->removeWidget(stackedWidget->widget(0)); stackedWidget->removeWidget(stackedWidget->widget(0));
stackedWidget->addWidget(new GeneralPage(false)); stackedWidget->addWidget(new GeneralPage(false));
stackedWidget->addWidget(new NetworkPage());
stackedWidget->addWidget(new ServerPage()); stackedWidget->addWidget(new ServerPage());
stackedWidget->addWidget(new DirectoriesPage()); stackedWidget->addWidget(new DirectoriesPage());
stackedWidget->addWidget(new NotifyPage()); stackedWidget->addWidget(new NotifyPage());
@ -73,9 +74,8 @@ RSettingsWin::initStackedWidget()
stackedWidget->addWidget(new AppearancePage()); stackedWidget->addWidget(new AppearancePage());
stackedWidget->addWidget(new FileAssociationsPage() ); stackedWidget->addWidget(new FileAssociationsPage() );
stackedWidget->addWidget(new SoundPage() ); stackedWidget->addWidget(new SoundPage() );
setNewPage(General); setNewPage(General);
} }
void void
@ -89,10 +89,6 @@ RSettingsWin::setNewPage(int page)
text = tr("General"); text = tr("General");
pageicon->setPixmap(QPixmap(":/images/kcmsystem24.png")); pageicon->setPixmap(QPixmap(":/images/kcmsystem24.png"));
break; break;
case Network:
text = tr("Network");
pageicon->setPixmap(QPixmap(":/images/network32.png"));
break;
case Directories: case Directories:
text = tr("Directories"); text = tr("Directories");
pageicon->setPixmap(QPixmap(":/images/folder_doments.png")); pageicon->setPixmap(QPixmap(":/images/folder_doments.png"));
@ -124,8 +120,8 @@ RSettingsWin::setNewPage(int page)
default: default:
text = tr("UnknownPage");// impossible case text = tr("UnknownPage");// impossible case
} }
pageName->setText(text); //tr("%1").arg( pageName->setText(text);
stackedWidget->setCurrentIndex(page); stackedWidget->setCurrentIndex(page);
listWidget->setCurrentRow(page); listWidget->setCurrentRow(page);
} }
@ -134,53 +130,31 @@ RSettingsWin::setNewPage(int page)
void void
RSettingsWin::saveChanges() RSettingsWin::saveChanges()
{ {
bool saveOk; bool saveOk;
QString errmsg; QString errmsg;
GeneralPage *gp; /* Call each config page's save() method to save its data */
NetworkPage *np; int i, count = stackedWidget->count();
CryptoPage *cp; for (i = 0; i < count; i++) {
ServerPage *sp; ConfigPage *page = (ConfigPage *) stackedWidget->widget(i);
NotifyPage *nfp; saveOk = page->save(errmsg);
AppearancePage *ap;
/* Call each config page's save() method to save its data */
int i, count = stackedWidget->count();
for (i = 0; i < count; i++) {
QWidget *page = stackedWidget->widget(i);
if (NULL != (gp = dynamic_cast<GeneralPage *>(page))) {saveOk = gp->save(errmsg);}
else
if (NULL !=(np = dynamic_cast<NetworkPage *>(page))) {saveOk = np->save(errmsg);}
else
if (NULL !=(sp = dynamic_cast<ServerPage *>(page))) {saveOk = sp->save(errmsg);}
else
if (NULL !=(cp = dynamic_cast<CryptoPage *>(page))) {saveOk = cp->save(errmsg);}
else
if (NULL !=(nfp = dynamic_cast<NotifyPage *>(page))) {saveOk = nfp->save(errmsg);}
else if (NULL !=(ap = dynamic_cast<AppearancePage *>(page))) {saveOk = ap->save(errmsg);}
if (!saveOk) {
/* Display the offending page */
stackedWidget->setCurrentWidget(page);
if (!saveOk) { /* Show the user what went wrong */
/* Display the offending page */ QMessageBox::warning(this,
stackedWidget->setCurrentWidget(page); tr("Error Saving Configuration"), errmsg,
QMessageBox::Ok, QMessageBox::NoButton);
/* Show the user what went wrong */
QMessageBox::warning(this,
tr("Error Saving Configuration"), errmsg,
QMessageBox::Ok, QMessageBox::NoButton);
/* Don't process the rest of the pages */ /* Don't process the rest of the pages */
return; return;
} }
} }
/* call to RsIface save function.... */
//rsicontrol -> ConfigSave();
/* call to RsIface save function.... */ QDialog::close();
//rsicontrol -> ConfigSave();
QDialog::close();
} }

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -31,22 +31,25 @@ class RSettingsWin: public QDialog, private Ui::Settings
Q_OBJECT Q_OBJECT
public: public:
enum PageType { General = 0, Network, Server, enum PageType { General = 0, Server,
Directories, Notify, Security, Appearance, Fileassociations, Sound }; Directories, Notify, Security, Appearance, Fileassociations, Sound };
RSettingsWin(QWidget * parent = 0, Qt::WFlags flags = 0); RSettingsWin(QWidget * parent = 0, Qt::WFlags flags = 0);
~RSettingsWin() {} ~RSettingsWin() {}
void showWindow(int page);
public slots: public slots:
//! Go to a specific part of the control panel. //! Go to a specific part of the control panel.
void setNewPage(int page); void setNewPage(int page);
private slots:
/** Called when user clicks "Save Settings" */
void saveChanges();
private: private:
void closeEvent (QCloseEvent * event); void closeEvent (QCloseEvent * event);
void initStackedWidget(); void initStackedWidget();
/** Called when user clicks "Save Settings" */
void saveChanges();
}; };
#endif // !RSETTINGSWIN_HPP_ #endif // !RSETTINGSWIN_HPP_

View file

@ -87,15 +87,6 @@
<normaloff>:/images/kcmsystem24.png</normaloff>:/images/kcmsystem24.png</iconset> <normaloff>:/images/kcmsystem24.png</normaloff>:/images/kcmsystem24.png</iconset>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Network</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/network.png</normaloff>:/images/network.png</iconset>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>Server</string> <string>Server</string>