mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-19 04:44:21 -05:00
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:
parent
39882161b1
commit
19920e95bc
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -26,14 +26,14 @@
|
||||
|
||||
/** Constructor */
|
||||
AppearancePage::AppearancePage(QWidget * parent, Qt::WFlags flags)
|
||||
: QWidget(parent, flags)
|
||||
: ConfigPage(parent, flags)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
/* Create RshareSettings object */
|
||||
_settings = new RshareSettings();
|
||||
|
||||
|
||||
connect(ui.styleSheetCombo, SIGNAL(clicked()), this, SLOT(loadStyleSheet()));
|
||||
|
||||
/* Populate combo boxes */
|
||||
@ -45,13 +45,13 @@ AppearancePage::AppearancePage(QWidget * parent, Qt::WFlags flags)
|
||||
foreach (QString style, QStyleFactory::keys()) {
|
||||
ui.cmboStyle->addItem(style, style.toLower());
|
||||
}
|
||||
|
||||
|
||||
ui.styleSheetCombo->setCurrentIndex(ui.styleSheetCombo->findText("Default"));
|
||||
//loadStyleSheet("Default");
|
||||
loadqss();
|
||||
|
||||
|
||||
load();
|
||||
|
||||
|
||||
|
||||
/* Hide platform specific features */
|
||||
#ifdef Q_WS_WIN
|
||||
@ -66,11 +66,11 @@ AppearancePage::save(QString &errmsg)
|
||||
Q_UNUSED(errmsg);
|
||||
QString languageCode =
|
||||
LanguageSupport::languageCode(ui.cmboLanguage->currentText());
|
||||
|
||||
|
||||
_settings->setLanguageCode(languageCode);
|
||||
_settings->setInterfaceStyle(ui.cmboStyle->currentText());
|
||||
_settings->setSheetName(ui.styleSheetCombo->currentText());
|
||||
|
||||
|
||||
/* Set to new style */
|
||||
Rshare::setStyle(ui.cmboStyle->currentText());
|
||||
return true;
|
||||
@ -82,21 +82,21 @@ AppearancePage::save(QString &errmsg)
|
||||
void
|
||||
AppearancePage::load()
|
||||
{
|
||||
|
||||
|
||||
int index = ui.cmboLanguage->findData(_settings->getLanguageCode());
|
||||
ui.cmboLanguage->setCurrentIndex(index);
|
||||
|
||||
|
||||
index = ui.cmboStyle->findData(Rshare::style().toLower());
|
||||
ui.cmboStyle->setCurrentIndex(index);
|
||||
|
||||
ui.styleSheetCombo->setCurrentIndex(ui.styleSheetCombo->findText(_settings->getSheetName()));
|
||||
|
||||
|
||||
ui.styleSheetCombo->setCurrentIndex(ui.styleSheetCombo->findText(_settings->getSheetName()));
|
||||
|
||||
/** load saved internal styleSheet **/
|
||||
//QFile file(":/qss/" + (_settings->getSheetName().toLower()) + ".qss");
|
||||
|
||||
|
||||
/** load saved extern Stylesheets **/
|
||||
QFile file(QApplication::applicationDirPath() + "/qss/" + (_settings->getSheetName().toLower()) + ".qss");
|
||||
|
||||
|
||||
file.open(QFile::ReadOnly);
|
||||
QString styleSheet = QLatin1String(file.readAll());
|
||||
qApp->setStyleSheet(styleSheet);
|
||||
@ -112,16 +112,16 @@ void AppearancePage::loadStyleSheet(const QString &sheetName)
|
||||
{
|
||||
/** internal Stylesheets **/
|
||||
//QFile file(":/qss/" + sheetName.toLower() + ".qss");
|
||||
|
||||
|
||||
/** extern Stylesheets **/
|
||||
QFile file(QApplication::applicationDirPath() + "/qss/" + sheetName.toLower() + ".qss");
|
||||
|
||||
|
||||
file.open(QFile::ReadOnly);
|
||||
QString styleSheet = QLatin1String(file.readAll());
|
||||
|
||||
|
||||
|
||||
qApp->setStyleSheet(styleSheet);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void AppearancePage::loadqss()
|
||||
@ -133,5 +133,5 @@ void AppearancePage::loadqss()
|
||||
if(st.fileName() != "." && st.fileName() != ".." && st.isFile())
|
||||
ui.styleSheetCombo->addItem(st.fileName().remove(".qss"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -29,9 +29,10 @@
|
||||
#include "gui/Preferences/rsharesettings.h"
|
||||
#include <lang/languagesupport.h>
|
||||
|
||||
#include "configpage.h"
|
||||
#include "ui_AppearancePage.h"
|
||||
|
||||
class AppearancePage : public QWidget
|
||||
class AppearancePage : public ConfigPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -50,11 +51,11 @@ class AppearancePage : public QWidget
|
||||
|
||||
void on_styleSheetCombo_activated(const QString &styleSheetName);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
/** A RshareSettings object used for saving/loading settings */
|
||||
RshareSettings* _settings;
|
||||
|
||||
|
||||
void loadStyleSheet(const QString &sheetName);
|
||||
void loadqss();
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
/** Constructor */
|
||||
CryptoPage::CryptoPage(QWidget * parent, Qt::WFlags flags)
|
||||
: QWidget(parent, flags)
|
||||
: ConfigPage(parent, flags)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
@ -114,7 +114,7 @@ CryptoPage::copyPublicKey()
|
||||
tr("Your Public Key is copied to Clipbard, paste and send it to your"
|
||||
"friend via email or some other way"));
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(ui.certtextEdit->toPlainText());
|
||||
clipboard->setText(ui.certtextEdit->toPlainText());
|
||||
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -28,9 +28,10 @@
|
||||
#include <gui/Preferences/rsharesettings.h>
|
||||
#include "gui/connect/ConnectFriendWizard.h"
|
||||
|
||||
#include "configpage.h"
|
||||
#include "ui_CryptoPage.h"
|
||||
|
||||
class CryptoPage : public QWidget
|
||||
class CryptoPage : public ConfigPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -54,11 +55,11 @@ class CryptoPage : public QWidget
|
||||
|
||||
void exportPublicKey();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
/** A RshareSettings object used for saving/loading settings */
|
||||
RshareSettings* _settings;
|
||||
|
||||
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -27,15 +27,14 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
DirectoriesPage::DirectoriesPage(QWidget * parent, Qt::WFlags flags)
|
||||
: QWidget(parent, flags)
|
||||
: ConfigPage(parent, flags)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
setAttribute(Qt::WA_QuitOnClose, false);
|
||||
|
||||
load();
|
||||
|
||||
|
||||
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)));
|
||||
@ -108,7 +107,7 @@ bool DirectoriesPage::save(QString &errmsg)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** Loads the settings for this page */
|
||||
void DirectoriesPage::load()
|
||||
{
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -26,17 +26,17 @@
|
||||
#include <QWidget>
|
||||
#include <QtGui>
|
||||
|
||||
#include "configpage.h"
|
||||
#include "ui_DirectoriesPage.h"
|
||||
|
||||
# include "ui_DirectoriesPage.h"
|
||||
|
||||
class DirectoriesPage: public QWidget
|
||||
class DirectoriesPage: public ConfigPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
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 */
|
||||
@ -45,7 +45,7 @@ class DirectoriesPage: public QWidget
|
||||
|
||||
|
||||
private slots:
|
||||
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void addShareDirectory();
|
||||
void removeShareDirectory();
|
||||
@ -57,9 +57,9 @@ class DirectoriesPage: public QWidget
|
||||
void shareDownloadDirectory(int state);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
||||
|
||||
Ui::DirectoriesPage ui;
|
||||
};
|
||||
|
||||
|
@ -54,7 +54,7 @@
|
||||
//============================================================================
|
||||
|
||||
FileAssociationsPage::FileAssociationsPage(QWidget * parent, Qt::WFlags flags)
|
||||
: QWidget(parent, flags)
|
||||
: ConfigPage(parent, flags)
|
||||
//:QFrame()
|
||||
{
|
||||
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->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("File type") ) );
|
||||
|
||||
|
||||
table->setHorizontalHeaderItem(1, new QTableWidgetItem("Command") );
|
||||
connect( table, SIGNAL( cellActivated(int, int)),
|
||||
this, SLOT( tableCellActivated(int, int)) );
|
||||
@ -194,7 +194,7 @@ FileAssociationsPage::load()
|
||||
removeAction->setEnabled(false);
|
||||
editAction->setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
table->selectRow(0);
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ FileAssociationsPage::addnew()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
settings->setValue(currType, currCmd);
|
||||
|
||||
removeAction->setEnabled(true);
|
||||
@ -279,17 +279,17 @@ FileAssociationsPage::edit()
|
||||
QString currCmd = (titem->data(QTableWidgetItem::Type)).toString();
|
||||
afad.setCommand(currCmd);
|
||||
afad.setFileType(currType);
|
||||
|
||||
|
||||
int ti = afad.exec();
|
||||
|
||||
if (ti==QDialog::Accepted)
|
||||
{
|
||||
currCmd = afad.resultCommand() ;
|
||||
titem = table->item( currentRow,1);
|
||||
|
||||
|
||||
titem->setData(QTableWidgetItem::Type, currCmd);
|
||||
|
||||
settings->setValue(currType, currCmd);
|
||||
settings->setValue(currType, currCmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#ifndef __FileAssociationsPage__
|
||||
#define __FileAssociationsPage__
|
||||
|
||||
//#include "configpage.h"
|
||||
#include "configpage.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
@ -52,11 +52,11 @@ class RshareSettings;
|
||||
//! With this config page user can specify, what programs should be executed
|
||||
//! to open some types of files. Here 'type' means 'file extension'(and
|
||||
//! 'file extension' means 'some symbols after last dot in filename').
|
||||
class FileAssociationsPage : public QWidget
|
||||
class FileAssociationsPage : public ConfigPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
FileAssociationsPage(QWidget * parent = 0, Qt::WFlags flags = 0);
|
||||
virtual ~FileAssociationsPage();
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -26,14 +26,14 @@
|
||||
|
||||
/** Constructor */
|
||||
GeneralPage::GeneralPage(QWidget * parent, Qt::WFlags flags)
|
||||
: QWidget(parent, flags)
|
||||
: ConfigPage(parent, flags)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
/* Create RshareSettings object */
|
||||
_settings = new RshareSettings();
|
||||
|
||||
|
||||
load();
|
||||
|
||||
/* Hide platform specific features */
|
||||
@ -41,7 +41,7 @@ GeneralPage::GeneralPage(QWidget * parent, Qt::WFlags flags)
|
||||
ui.chkRunRetroshareAtSystemStartup->setVisible(false);
|
||||
//ui.autologincheckBox->setEnabled(false) ;
|
||||
//ui.autologincheckBox->setChecked(false) ;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Destructor */
|
||||
@ -53,30 +53,30 @@ GeneralPage::GeneralPage(QWidget * parent, Qt::WFlags flags)
|
||||
/** Saves the changes on this page */
|
||||
bool
|
||||
GeneralPage::save(QString &errmsg)
|
||||
{
|
||||
{
|
||||
_settings->setValue(QString::fromUtf8("StartMinimized"), startMinimized());
|
||||
|
||||
_settings->setValue(QString::fromUtf8("doQuit"), quit());
|
||||
|
||||
|
||||
_settings->setRunRetroshareOnBoot(
|
||||
ui.chkRunRetroshareAtSystemStartup->isChecked());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** Loads the settings for this page */
|
||||
void
|
||||
GeneralPage::load()
|
||||
{
|
||||
{
|
||||
ui.chkRunRetroshareAtSystemStartup->setChecked(
|
||||
_settings->runRetroshareOnBoot());
|
||||
|
||||
|
||||
ui.checkStartMinimized->setChecked(_settings->value(QString::fromUtf8("StartMinimized"), false).toBool());
|
||||
|
||||
ui.checkQuit->setChecked(_settings->value(QString::fromUtf8("doQuit"), false).toBool());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool GeneralPage::quit() const {
|
||||
if(ui.checkQuit->isChecked()) return true;
|
||||
return ui.checkQuit->isChecked();
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -29,17 +29,18 @@
|
||||
|
||||
#include "gui/Preferences/rsharesettings.h"
|
||||
|
||||
#include "configpage.h"
|
||||
#include "ui_GeneralPage.h"
|
||||
|
||||
|
||||
class GeneralPage : public QWidget
|
||||
class GeneralPage : public ConfigPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
GeneralPage(QWidget * parent = 0, Qt::WFlags flags = 0);
|
||||
/** Default Destructor */
|
||||
/** Default Destructor */
|
||||
~GeneralPage() {}
|
||||
|
||||
/** Saves the changes on this page */
|
||||
@ -54,13 +55,13 @@ private slots:
|
||||
|
||||
/** Called when the "show on startup" checkbox is toggled. */
|
||||
void toggleShowOnStartup(bool checked);
|
||||
|
||||
|
||||
private:
|
||||
/** A RetroShare Settings object used for saving/loading settings */
|
||||
RshareSettings *_settings;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::GeneralPage ui;
|
||||
};
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#include "rshare.h"
|
||||
|
||||
NetworkPage::NetworkPage(QWidget * parent, Qt::WFlags flags)
|
||||
: QWidget(parent, flags)
|
||||
: ConfigPage(parent, flags)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
setAttribute(Qt::WA_QuitOnClose, false);
|
||||
@ -41,9 +41,9 @@ NetworkPage::closeEvent (QCloseEvent * event)
|
||||
bool
|
||||
NetworkPage::save(QString &errmsg)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** Loads the settings for this page */
|
||||
void
|
||||
NetworkPage::load()
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -23,23 +23,25 @@
|
||||
#define NETWORKPAGE_H
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
#include "configpage.h"
|
||||
#include "ui_NetworkPage.h"
|
||||
|
||||
class NetworkPage: public QWidget
|
||||
class NetworkPage : public ConfigPage
|
||||
{
|
||||
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;
|
||||
};
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -32,13 +32,13 @@
|
||||
|
||||
/** Constructor */
|
||||
NotifyPage::NotifyPage(QWidget * parent, Qt::WFlags flags)
|
||||
: QWidget(parent, flags)
|
||||
: ConfigPage(parent, flags)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
setAttribute(Qt::WA_QuitOnClose, false);
|
||||
setWindowTitle(windowTitle() + QLatin1String(" - Notify"));
|
||||
|
||||
|
||||
/* Create RshareSettings object */
|
||||
_settings = new RshareSettings();
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -27,13 +27,13 @@
|
||||
|
||||
#include "gui/Preferences/rsharesettings.h"
|
||||
|
||||
|
||||
#include "configpage.h"
|
||||
#include "ui_NotifyPage.h"
|
||||
|
||||
class NotifyPage : public QWidget
|
||||
class NotifyPage : public ConfigPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
NotifyPage(QWidget * parent = 0, Qt::WFlags flags = 0);
|
||||
@ -51,9 +51,9 @@ class NotifyPage : public QWidget
|
||||
private slots:
|
||||
|
||||
private:
|
||||
|
||||
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
||||
|
||||
/** A RshareSettings object used for saving/loading settings */
|
||||
RshareSettings* _settings;
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
#include <QTimer>
|
||||
|
||||
ServerPage::ServerPage(QWidget * parent, Qt::WFlags flags)
|
||||
: QWidget(parent, flags)
|
||||
: ConfigPage(parent, flags)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
@ -154,7 +154,7 @@ void ServerPage::load()
|
||||
|
||||
|
||||
toggleUPnP();
|
||||
|
||||
|
||||
|
||||
/* Addresses must be set here - otherwise can't edit it */
|
||||
/* set local address */
|
||||
@ -262,7 +262,7 @@ void ServerPage::updateStatus()
|
||||
|
||||
ui.netStatusBox->setText(QString::fromStdString(out.str()));
|
||||
ui.netStatusBox ->setReadOnly(true);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -23,16 +23,18 @@
|
||||
# define SERVERPAGE_H
|
||||
|
||||
# include <QtGui/QWidget>
|
||||
# include "ui_ServerPage.h"
|
||||
|
||||
class ServerPage: public QWidget
|
||||
#include "configpage.h"
|
||||
#include "ui_ServerPage.h"
|
||||
|
||||
class ServerPage: public ConfigPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ServerPage(QWidget * parent = 0, Qt::WFlags flags = 0);
|
||||
~ServerPage() {}
|
||||
|
||||
|
||||
/** Saves the changes on this page */
|
||||
bool save(QString &errmsg);
|
||||
/** Loads the settings for this page */
|
||||
@ -45,13 +47,13 @@ private slots:
|
||||
void saveAddresses();
|
||||
void toggleUPnP();
|
||||
void toggleIpDetermination(bool) ;
|
||||
void showTurtleRouterDialog();
|
||||
void showTurtleRouterDialog();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
||||
|
||||
Ui::ServerPage ui;
|
||||
};
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -26,14 +26,14 @@
|
||||
|
||||
/** Constructor */
|
||||
SoundPage::SoundPage(QWidget * parent, Qt::WFlags flags)
|
||||
: QWidget(parent, flags)
|
||||
: ConfigPage(parent, flags)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
/* Create RshareSettings object */
|
||||
_settings = new RshareSettings();
|
||||
|
||||
|
||||
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_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_5->setChecked(_settings->value("FileRecive_Finished",false).toBool());
|
||||
ui.checkBoxSound_6->setChecked(_settings->value("NewChatMessage",false).toBool());
|
||||
_settings->endGroup();
|
||||
_settings->endGroup();
|
||||
_settings->endGroup();
|
||||
}
|
||||
|
||||
@ -123,10 +123,10 @@ void SoundPage::on_cmd_openFile()
|
||||
void SoundPage::on_cmd_openFile2()
|
||||
{
|
||||
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->setEnabled(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
ui.checkBoxSound_2->setEnabled(true);
|
||||
|
||||
@ -170,5 +170,5 @@ void SoundPage::on_cmd_openFile6()
|
||||
}
|
||||
else
|
||||
ui.checkBoxSound_6->setEnabled(true);
|
||||
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -26,15 +26,16 @@
|
||||
|
||||
#include <gui/Preferences/rsharesettings.h>
|
||||
|
||||
#include "configpage.h"
|
||||
#include "ui_SoundPage.h"
|
||||
|
||||
class SoundPage : public QWidget
|
||||
class SoundPage : public ConfigPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
SoundPage(QWidget * parent = 0, Qt::WFlags flags = 0);
|
||||
SoundPage(QWidget * parent = 0, Qt::WFlags flags = 0);
|
||||
/** Default Destructor */
|
||||
~SoundPage() {}
|
||||
|
||||
@ -51,7 +52,7 @@ private slots:
|
||||
void on_cmd_openFile4();
|
||||
void on_cmd_openFile5();
|
||||
void on_cmd_openFile6();
|
||||
|
||||
|
||||
private:
|
||||
/** A RshareSettings object used for saving/loading settings */
|
||||
RshareSettings* _settings;
|
||||
|
43
retroshare-gui/src/gui/settings/configpage.h
Normal file
43
retroshare-gui/src/gui/settings/configpage.h
Normal 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
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -43,18 +43,20 @@ RSettingsWin::RSettingsWin(QWidget * parent, Qt::WFlags flags)
|
||||
|
||||
initStackedWidget();
|
||||
|
||||
connect(listWidget, SIGNAL(currentRowChanged(int)),
|
||||
this, SLOT(setNewPage(int)));
|
||||
|
||||
connect(listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(setNewPage(int)));
|
||||
connect(okButton, SIGNAL(clicked( bool )), this, SLOT( saveChanges()) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RSettingsWin::showWindow(int page)
|
||||
{
|
||||
setNewPage(page);
|
||||
QDialog::show();
|
||||
}
|
||||
|
||||
void
|
||||
RSettingsWin::closeEvent (QCloseEvent * event)
|
||||
{
|
||||
|
||||
QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
@ -64,8 +66,7 @@ RSettingsWin::initStackedWidget()
|
||||
stackedWidget->setCurrentIndex(-1);
|
||||
stackedWidget->removeWidget(stackedWidget->widget(0));
|
||||
|
||||
stackedWidget->addWidget(new GeneralPage(false));
|
||||
stackedWidget->addWidget(new NetworkPage());
|
||||
stackedWidget->addWidget(new GeneralPage(false));
|
||||
stackedWidget->addWidget(new ServerPage());
|
||||
stackedWidget->addWidget(new DirectoriesPage());
|
||||
stackedWidget->addWidget(new NotifyPage());
|
||||
@ -73,9 +74,8 @@ RSettingsWin::initStackedWidget()
|
||||
stackedWidget->addWidget(new AppearancePage());
|
||||
stackedWidget->addWidget(new FileAssociationsPage() );
|
||||
stackedWidget->addWidget(new SoundPage() );
|
||||
|
||||
|
||||
setNewPage(General);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@ -89,10 +89,6 @@ RSettingsWin::setNewPage(int page)
|
||||
text = tr("General");
|
||||
pageicon->setPixmap(QPixmap(":/images/kcmsystem24.png"));
|
||||
break;
|
||||
case Network:
|
||||
text = tr("Network");
|
||||
pageicon->setPixmap(QPixmap(":/images/network32.png"));
|
||||
break;
|
||||
case Directories:
|
||||
text = tr("Directories");
|
||||
pageicon->setPixmap(QPixmap(":/images/folder_doments.png"));
|
||||
@ -124,8 +120,8 @@ RSettingsWin::setNewPage(int page)
|
||||
default:
|
||||
text = tr("UnknownPage");// impossible case
|
||||
}
|
||||
|
||||
pageName->setText(text); //tr("%1").arg(
|
||||
|
||||
pageName->setText(text);
|
||||
stackedWidget->setCurrentIndex(page);
|
||||
listWidget->setCurrentRow(page);
|
||||
}
|
||||
@ -134,53 +130,31 @@ RSettingsWin::setNewPage(int page)
|
||||
void
|
||||
RSettingsWin::saveChanges()
|
||||
{
|
||||
bool saveOk;
|
||||
QString errmsg;
|
||||
bool saveOk;
|
||||
QString errmsg;
|
||||
|
||||
GeneralPage *gp;
|
||||
NetworkPage *np;
|
||||
CryptoPage *cp;
|
||||
ServerPage *sp;
|
||||
NotifyPage *nfp;
|
||||
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);}
|
||||
/* Call each config page's save() method to save its data */
|
||||
int i, count = stackedWidget->count();
|
||||
for (i = 0; i < count; i++) {
|
||||
ConfigPage *page = (ConfigPage *) stackedWidget->widget(i);
|
||||
saveOk = page->save(errmsg);
|
||||
|
||||
if (!saveOk) {
|
||||
/* Display the offending page */
|
||||
stackedWidget->setCurrentWidget(page);
|
||||
|
||||
if (!saveOk) {
|
||||
/* Display the offending page */
|
||||
stackedWidget->setCurrentWidget(page);
|
||||
|
||||
/* Show the user what went wrong */
|
||||
QMessageBox::warning(this,
|
||||
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 */
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* Don't process the rest of the pages */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* call to RsIface save function.... */
|
||||
//rsicontrol -> ConfigSave();
|
||||
|
||||
/* call to RsIface save function.... */
|
||||
//rsicontrol -> ConfigSave();
|
||||
|
||||
QDialog::close();
|
||||
QDialog::close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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,
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
@ -31,22 +31,25 @@ class RSettingsWin: public QDialog, private Ui::Settings
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum PageType { General = 0, Network, Server,
|
||||
Directories, Notify, Security, Appearance, Fileassociations, Sound };
|
||||
enum PageType { General = 0, Server,
|
||||
Directories, Notify, Security, Appearance, Fileassociations, Sound };
|
||||
|
||||
RSettingsWin(QWidget * parent = 0, Qt::WFlags flags = 0);
|
||||
~RSettingsWin() {}
|
||||
|
||||
void showWindow(int page);
|
||||
|
||||
public slots:
|
||||
//! Go to a specific part of the control panel.
|
||||
void setNewPage(int page);
|
||||
|
||||
private slots:
|
||||
/** Called when user clicks "Save Settings" */
|
||||
void saveChanges();
|
||||
|
||||
private:
|
||||
void closeEvent (QCloseEvent * event);
|
||||
void initStackedWidget();
|
||||
|
||||
/** Called when user clicks "Save Settings" */
|
||||
void saveChanges();
|
||||
};
|
||||
|
||||
#endif // !RSETTINGSWIN_HPP_
|
||||
|
@ -87,15 +87,6 @@
|
||||
<normaloff>:/images/kcmsystem24.png</normaloff>:/images/kcmsystem24.png</iconset>
|
||||
</property>
|
||||
</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>
|
||||
<property name="text">
|
||||
<string>Server</string>
|
||||
|
Loading…
Reference in New Issue
Block a user