diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index 8b0942816..64499ec38 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -1,4 +1,4 @@ -CONFIG += qt gui uic qrc resources uitools debug # pluginmgr release version_detail_linux +CONFIG += qt gui uic qrc resources uitools debug pluginmgr #release version_detail_linux newsettings QT += network xml script TEMPLATE = app TARGET = RetroShare @@ -533,7 +533,44 @@ pluginmgr { } - +newsettings { + SOURCES += gui/settings/rsettingswin.cpp \ + gui/settings/GeneralPage.cpp \ + gui/settings/DirectoriesPage.cpp \ + gui/settings/ServerPage.cpp \ + gui/settings/NetworkPage.cpp \ + gui/settings/NotifyPage.cpp \ + gui/settings/CryptoPage.cpp \ + gui/settings/AppearancePage.cpp \ + gui/settings/FileAssociationsPage.cpp \ + gui/settings/SoundPage.cpp \ + gui/settings/AddFileAssociationDialog.cpp + + HEADERS += gui/settings/rsettingswin.h \ + gui/settings/GeneralPage.h \ + gui/settings/DirectoriesPage.h \ + gui/settings/ServerPage.h \ + gui/settings/NetworkPage.h \ + gui/settings/NotifyPage.h \ + gui/settings/CryptoPage.h \ + gui/settings/AppearancePage.h \ + gui/settings/FileAssociationsPage.h \ + gui/settings/SoundPage.h \ + gui/settings/AddFileAssociationDialog.h + + FORMS += gui/settings/settings.ui \ + gui/settings/GeneralPage.ui \ + gui/settings/DirectoriesPage.ui \ + gui/settings/ServerPage.ui \ + gui/settings/NetworkPage.ui \ + gui/settings/NotifyPage.ui \ + gui/settings/CryptoPage.ui \ + gui/settings/AppearancePage.ui \ + gui/settings/SoundPage.ui + + DEFINES *= NEWSETTINGS + +} diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 012a58d2d..6da653ba7 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -56,7 +56,11 @@ #include "statusbar/ratesstatus.h" #include "Preferences/PreferencesWindow.h" -//#include "Settings/gsettingswin.h" + +#ifdef NEWSETTINGS +#include "settings/rsettingswin.h" +#endif + #include "util/rsversion.h" #include "rsiface/rsiface.h" @@ -149,8 +153,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) connect(ui.actionSMPlayer, SIGNAL(triggered()), this, SLOT( showsmplayer()) ); connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT( showabout()) ); connect(ui.actionColor, SIGNAL(triggered()), this, SLOT( setStyle()) ); - //connect(ui.actionSettings, SIGNAL(triggered()), this, SLOT( showSettings()) ); - + /** adjusted quit behaviour: trigger a warning that can be switched off in the saved config file RetroShare.conf */ @@ -234,6 +237,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) createPageAction(QIcon(IMAGE_PLUGINS), tr("Plugins"), grp)); #endif + /* Create the toolbar */ ui.toolBar->addActions(grp->actions()); ui.toolBar->addSeparator(); @@ -243,6 +247,10 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) #else addAction(new QAction(QIcon(IMAGE_UNFINISHED), tr("Unfinished"), ui.toolBar), SLOT(showApplWindow())); #endif + +#ifdef NEWSETTINGS + addAction(new QAction(QIcon(IMAGE_OPTIONS), tr("Options"), ui.toolBar_2), SLOT(showSettings())); +#endif /* Select the first action */ grp->actions()[0]->setChecked(true); @@ -465,14 +473,16 @@ MainWindow::showMess(MainWindow::Page page) /** Shows Options */ -//void MainWindow::showSettings() -//{ -// static GSettingsWin *win = new GSettingsWin(this); -// if (win->isHidden()) -// win->setNewPage(0); -// win->show(); -// win->activateWindow(); -//} +#ifdef NEWSETTINGS +void MainWindow::showSettings() +{ + static RSettingsWin *win = new RSettingsWin(this); + if (win->isHidden()) + win->setNewPage(0); + win->show(); + win->activateWindow(); +} +#endif /** Shows Messenger window */ void MainWindow::showMessengerWindow() @@ -535,7 +545,7 @@ void MainWindow::doQuit() queryWrn.clear(); queryWrn.append(tr("Do you really want to exit RetroShare ?")); - if ((QMessageBox::question(this, tr("Really quit ? "),queryWrn,QMessageBox::Ok|QMessageBox::No, QMessageBox::Ok))== QMessageBox::Ok) + if ((QMessageBox::question(this, tr("Really quit ? "),queryWrn,QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes) { qApp->quit(); } diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index ce5ed8fc2..c60c3f431 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -43,7 +43,6 @@ #endif #include "Preferences/PreferencesWindow.h" -//#include "Settings/gsettingswin.h" #include "bwgraph/bwgraph.h" #include "help/browser/helpbrowser.h" #include "games/qbackgammon/bgwindow.h" @@ -139,7 +138,7 @@ private slots: void showsmplayer(); void showabout(); void openShareManager(); - void displaySystrayMsg(const QString&,const QString&) ; + void displaySystrayMsg(const QString&,const QString&) ; /** Displays the help browser and displays the most recently viewed help * topic. */ @@ -151,8 +150,9 @@ private slots: * to page. */ void showPreferencesWindow(PreferencesWindow::Page page = PreferencesWindow::General); void showMess(MainWindow::Page page = MainWindow::Messages); - -// void showSettings(); +#ifdef NEWSETTINGS + void showSettings(); +#endif void setStyle(); /** Called when user attempts to quit via quit button*/ diff --git a/retroshare-gui/src/gui/MainWindow.ui b/retroshare-gui/src/gui/MainWindow.ui index ee7038195..84fabafcd 100644 --- a/retroshare-gui/src/gui/MainWindow.ui +++ b/retroshare-gui/src/gui/MainWindow.ui @@ -1133,15 +1133,6 @@ About - - - - :/images/settings.png:/images/settings.png - - - Settings - - diff --git a/retroshare-gui/src/gui/images/security-high-32.png b/retroshare-gui/src/gui/images/security-high-32.png new file mode 100755 index 000000000..95e73d93e Binary files /dev/null and b/retroshare-gui/src/gui/images/security-high-32.png differ diff --git a/retroshare-gui/src/gui/settings/AddFileAssociationDialog.cpp b/retroshare-gui/src/gui/settings/AddFileAssociationDialog.cpp new file mode 100755 index 000000000..b34e1097e --- /dev/null +++ b/retroshare-gui/src/gui/settings/AddFileAssociationDialog.cpp @@ -0,0 +1,228 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2009 The RetroShare Team, Oleksiy Bilyanskyy + * + * 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 "AddFileAssociationDialog.h" + +//#include "rshare.h" // for Rshare::dataDirectory() method +//#include "rsharesettings.h" +#include //for win registry access +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + +//============================================================================ + +AddFileAssociationDialog::AddFileAssociationDialog(bool onlyEdit, + QWidget* parent) + :QDialog(parent) +{ + fileTypeLabel = new QLabel(); + fileTypeLabel->setText(tr("File type(extension):")); + + + fileTypeEdit = new QLineEdit(); + fileTypeEdit->setEnabled( !onlyEdit ); + fileTypeEdit->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + fileTypeEdit->setFixedWidth(50); + connect(fileTypeEdit, SIGNAL( textEdited( const QString& )), + this , SLOT( fileTypeEdited(const QString & )) ) ; + + loadSystemDefault = new QPushButton(); + loadSystemDefault->setText(tr("Use default command")); + loadSystemDefault->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + loadSystemDefault->setEnabled( fileTypeEdit && + (!(fileTypeEdit->text().isEmpty())) ) ; + connect(loadSystemDefault, SIGNAL(clicked()), + this, SLOT(loadSystemDefaultCommand())); + loadSystemDefault->setVisible(false); //the button sholud remain unvisivle, + //until it will work properly + + commandLabel = new QLabel(); + commandLabel->setText(tr("Command")); + + commandEdit = new QLineEdit; + + selectExecutable = new QPushButton(); + selectExecutable->setText("..."); + selectExecutable->setFixedWidth(30); + + QHBoxLayout* ftlay = new QHBoxLayout(); + ftlay->addWidget( fileTypeLabel ); + ftlay->addWidget( fileTypeEdit ); + + buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok + | QDialogButtonBox::Cancel ); + connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + + QGridLayout* mainLay = new QGridLayout(); + mainLay->addWidget(fileTypeLabel,0,0,1,1, Qt::AlignLeft); + mainLay->addWidget(fileTypeEdit,0,1,1,1, Qt::AlignLeft); + mainLay->addWidget(loadSystemDefault, 0,2,1,2,Qt::AlignRight); + mainLay->addWidget( commandLabel, 1,0,1,1, Qt::AlignLeft); + mainLay->addWidget( commandEdit, 1,1,1,2); + mainLay->addWidget( selectExecutable, 1,3,1,1); + mainLay->addWidget( buttonBox, 2,1,1,4, Qt::AlignLeft); + + mainLay->setColumnStretch(2,1); + mainLay->setRowStretch(2,1); + + this->setLayout( mainLay ); + + //TODO: in the next line we have to count a real height of the dialog; + // It's not good to use a hardcoded const value; + this->resize(600,200);//this->height()); + +} + +//============================================================================ + +void +AddFileAssociationDialog::fileTypeEdited(const QString & text ) +{ + loadSystemDefault->setEnabled( !( text.isEmpty() ) ); +} + +//============================================================================ + +void +AddFileAssociationDialog::setFileType(QString ft) +{ + fileTypeEdit->setText(ft); +} + +//============================================================================ + +void +AddFileAssociationDialog::loadSystemDefaultCommand() +{ + qDebug() << " lsdc is here"; + + QString fileExt = cleanFileType(fileTypeEdit->text()) ; + //fileExt.prepend('/'); + fileExt.append("/."); + qDebug() << " fileExt is " << fileExt; + QSettings reg("HKEY_CLASSES_ROOT", QSettings::NativeFormat); + + if (reg.contains(fileExt)) + { + QString appKey = reg.value(fileExt).toString(); + qDebug() << " got app key " << appKey; + appKey.append("/shell/open/command/."); + QString command = reg.value(appKey, "-").toString(); + if (command!="-") + { + qDebug() << " got command :" << command ; + commandEdit->setText( command ); + return; + } + } + + QMessageBox::warning(this, tr("RetroShare"), + tr("Sorry, can't determine system " + "default command for this file\n"), + QMessageBox::Ok); + + +} + +//============================================================================ + +QString +AddFileAssociationDialog::cleanFileType(QString ft) +{ + QString result = ft; + + //-- first remove possible filder names from received filename. (like + // "like "/moviedir/file.avi", we will leave only "file.avi" + int ti; + // dirs may be separated with "/" + ti = result.lastIndexOf('/'); + if (ti > -1) + { + result.remove(0,ti+1); + } + + // or "\" + ti = result.lastIndexOf('\\'); + if (ti > -1) + { + result.remove(0,ti+1); + } + + //-- then, if it is filename (like "file.avi"), we'll have to remove + //-- the name (ans leave just ".avi") + ti = result.lastIndexOf('.'); + if (ti > -1) + { + result.remove(0,ti); + return result; + } + + //-- also, if filename still is not prepended with dot, do it + if ((!result.isEmpty()) && (result.at(0)!='.')) + result.prepend('.'); + + //-- that's all + return result; +} + +//============================================================================ + +QString +AddFileAssociationDialog::resultCommand() +{ + return commandEdit->text(); +} + +//============================================================================ + +QString +AddFileAssociationDialog::resultFileType() +{ + return cleanFileType( fileTypeEdit->text() ) ; +} + +//============================================================================ + +void +AddFileAssociationDialog::setCommand(QString cmd) +{ + commandEdit->setText( cmd ); +} + +//============================================================================ + +//============================================================================ + + diff --git a/retroshare-gui/src/gui/settings/AddFileAssociationDialog.h b/retroshare-gui/src/gui/settings/AddFileAssociationDialog.h new file mode 100755 index 000000000..823a86426 --- /dev/null +++ b/retroshare-gui/src/gui/settings/AddFileAssociationDialog.h @@ -0,0 +1,80 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2009 The RetroShare Team, Oleksiy Bilyanskyy + * + * 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 __AddFileAssociationDialog__ +#define __AddFileAssociationDialog__ + + +#include +#include + +class QPushButton; +class QDialogButtonBox; + +class QLabel; +class QLineEdit; + +//============================================================================= +//! A dialog for specifying file type and associated command +class AddFileAssociationDialog: public QDialog +{ + Q_OBJECT +public: + //! constructor + + //! if (onlyEdit == true), user woll not be able to change file type, + //! only command (used for editing existing commands) + AddFileAssociationDialog( bool onlyEdit = false, QWidget *parent = 0 ) ; + virtual ~AddFileAssociationDialog(){}; + void setFileType(QString ft); + void setCommand(QString cmd); + + //! Gets file type (file extension) from given filename (or other string) + + //! "file type" has to be like '.png'(some symbols, prepended by a dot) + static QString cleanFileType(QString ft); + + QString resultCommand(); + QString resultFileType(); + +protected: + //QTabWidget *tabWidget; + QLabel* fileTypeLabel; + QLineEdit* fileTypeEdit; + QPushButton* loadSystemDefault; + QPushButton* selectExecutable; + QLabel* commandLabel; + QLineEdit* commandEdit; + QDialogButtonBox *buttonBox; + +protected slots: + void fileTypeEdited(const QString & text ); + + //! On win32, loads default command from system registry. + + //! Unfinished. Is not used in current version. + void loadSystemDefaultCommand(); + + +}; + +#endif + diff --git a/retroshare-gui/src/gui/settings/AppearancePage.cpp b/retroshare-gui/src/gui/settings/AppearancePage.cpp new file mode 100755 index 000000000..fbd5041d5 --- /dev/null +++ b/retroshare-gui/src/gui/settings/AppearancePage.cpp @@ -0,0 +1,137 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006 - 2009 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 +#include "AppearancePage.h" + + +/** Constructor */ +AppearancePage::AppearancePage(QWidget * parent, Qt::WFlags flags) + : QWidget(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 */ + foreach (QString code, LanguageSupport::languageCodes()) { + ui.cmboLanguage->addItem(QIcon(":/images/flags/" + code + ".png"), + LanguageSupport::languageName(code), + code); + } + 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 + +#endif +} + +/** Saves the changes on this page */ +bool +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; +} + + + +/** Loads the settings for this page */ +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())); + + /** 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); + +} + +void AppearancePage::on_styleSheetCombo_activated(const QString &sheetName) +{ + loadStyleSheet(sheetName); +} + +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() +{ + + QFileInfoList slist = QDir(QApplication::applicationDirPath() + "/qss/").entryInfoList(); + foreach(QFileInfo st, slist) + { + if(st.fileName() != "." && st.fileName() != ".." && st.isFile()) + ui.styleSheetCombo->addItem(st.fileName().remove(".qss")); + } + +} \ No newline at end of file diff --git a/retroshare-gui/src/gui/settings/AppearancePage.h b/retroshare-gui/src/gui/settings/AppearancePage.h new file mode 100755 index 000000000..35295f84c --- /dev/null +++ b/retroshare-gui/src/gui/settings/AppearancePage.h @@ -0,0 +1,66 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006 - 2009 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. + ****************************************************************/ + +#ifndef _APPERARANCEPAGE_H +#define _APPERARANCEPAGE_H + +#include +#include +#include + +#include "gui/Preferences/rsharesettings.h" +#include + +#include "ui_AppearancePage.h" + +class AppearancePage : public QWidget +{ + Q_OBJECT + + public: + /** Default Constructor */ + AppearancePage(QWidget * parent = 0, Qt::WFlags flags = 0); + /** Default Destructor */ + ~AppearancePage() {} + + /** Saves the changes on this page */ + bool save(QString &errmsg); + /** Loads the settings for this page */ + void load(); + + private slots: + + 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(); + + /** Qt Designer generated object */ + Ui::AppearancePage ui; +}; + +#endif + diff --git a/retroshare-gui/src/gui/settings/AppearancePage.ui b/retroshare-gui/src/gui/settings/AppearancePage.ui new file mode 100755 index 000000000..bed75fd15 --- /dev/null +++ b/retroshare-gui/src/gui/settings/AppearancePage.ui @@ -0,0 +1,786 @@ + + AppearancePage + + + + 0 + 0 + 410 + 300 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 192 + 192 + 192 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 104 + 104 + 104 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 104 + 104 + 104 + + + + + + + 255 + 255 + 255 + + + + + + + 104 + 104 + 104 + + + + + + + 240 + 240 + 240 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + Arial + 8 + 50 + false + false + false + false + + + + Qt::NoContextMenu + + + + 6 + + + 6 + + + 6 + + + 6 + + + 0 + + + 0 + + + + + + 0 + 75 + + + + Qt::NoContextMenu + + + Language + + + + + 10 + 44 + 341 + 26 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 6 + + + 6 + + + + + Qt::Horizontal + + + + 300 + 16 + + + + + + + + + 150 + 0 + + + + Qt::NoContextMenu + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Arial'; font-size:10pt; font-weight:400; font-style:normal; text-decoration:none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Choose the language used in RetroShare</p></body></html> + + + false + + + + 24 + 16 + + + + + + + + + + 10 + 27 + 591 + 17 + + + + Qt::NoContextMenu + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-size:8pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Changes to language will only take effect after restarting RetroShare!</p></body></html> + + + + + + + + + 0 + 64 + + + + Qt::NoContextMenu + + + + + + Style + + + + + 10 + 24 + 341 + 26 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 6 + + + 6 + + + + + + 150 + 0 + + + + Qt::NoContextMenu + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Arial'; font-size:10pt; font-weight:400; font-style:normal; text-decoration:none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Choose RetroShare's interface style</p></body></html> + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 64 + + + + Style Sheet + + + + + 11 + 20 + 341 + 25 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 6 + + + 6 + + + + + Qt::Horizontal + + + + 181 + 20 + + + + + + + + + 150 + 0 + + + + + + + + + + + + Qt::Vertical + + + + 361 + 61 + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/settings/CryptoPage.cpp b/retroshare-gui/src/gui/settings/CryptoPage.cpp new file mode 100755 index 000000000..fc6309274 --- /dev/null +++ b/retroshare-gui/src/gui/settings/CryptoPage.cpp @@ -0,0 +1,143 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006 - 2009 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 "rsiface/rspeers.h" //for rsPeers variable +#include "rsiface/rsiface.h" + +#include +#include + +#include +#include "CryptoPage.h" + +#include +#include +#include + +/** Constructor */ +CryptoPage::CryptoPage(QWidget * parent, Qt::WFlags flags) + : QWidget(parent, flags) +{ + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); + + /* Create RshareSettings object */ + _settings = new RshareSettings(); + + connect(ui.copykeyButton, SIGNAL(clicked()), this, SLOT(copyPublicKey())); + connect(ui.exportkeyButton, SIGNAL(clicked()), this, SLOT(exportPublicKey())); + + + loadPublicKey(); + + + /* Hide platform specific features */ +#ifdef Q_WS_WIN + +#endif +} + +void +CryptoPage::closeEvent (QCloseEvent * event) +{ + + QWidget::closeEvent(event); +} + +/** Saves the changes on this page */ +bool +CryptoPage::save(QString &errmsg) +{ + return true; +} + +/** Loads the settings for this page */ +void +CryptoPage::load() +{ + +} + +/** Loads ouer default Puplickey */ +void +CryptoPage::loadPublicKey() +{ + //std::cerr << "CryptoPage() getting Invite" << std::endl; + + std::string invite = rsPeers->GetRetroshareInvite(); + + RsPeerDetails ownDetail; + rsPeers->getPeerDetails(rsPeers->getOwnId(), ownDetail); + invite += LOCAL_IP; + invite += ownDetail.localAddr + ":"; + std::ostringstream out; + out << ownDetail.localPort; + invite += out.str() + ";"; + invite += "\n"; + invite += EXT_IP; + invite += ownDetail.extAddr + ":"; + std::ostringstream out2; + out2 << ownDetail.extPort; + invite += out2.str() + ";"; + + ui.certtextEdit->setText(QString::fromStdString(invite)); + ui.certtextEdit->setReadOnly(true); + ui.certtextEdit->setMinimumHeight(200); + + //std::cerr << "CryptoPage() getting Invite: " << invite << std::endl; + +} + +void +CryptoPage::copyPublicKey() +{ + QMessageBox::information(this, + tr("RetroShare"), + 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()); + +} + +void +CryptoPage::exportPublicKey() +{ + qDebug() << " exportPulicKey"; + + QString qdir = QFileDialog::getSaveFileName(this, + "Please choose a filename", + QDir::homePath(), + "RetroShare Certificate (*.pqi)"); + + if ( rsPeers->SaveCertificateToFile(rsPeers->getOwnId(), qdir.toStdString()) ) + { + QMessageBox::information(this, tr("RetroShare"), + tr("Certificate file successfully created"), + QMessageBox::Ok, QMessageBox::Ok); + } + else + { + QMessageBox::information(this, tr("RetroShare"), + tr("Sorry, certificate file creation failed"), + QMessageBox::Ok, QMessageBox::Ok); + } +} diff --git a/retroshare-gui/src/gui/settings/CryptoPage.h b/retroshare-gui/src/gui/settings/CryptoPage.h new file mode 100755 index 000000000..b3af83201 --- /dev/null +++ b/retroshare-gui/src/gui/settings/CryptoPage.h @@ -0,0 +1,70 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006 - 2009 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. + ****************************************************************/ + +#ifndef _CRYPTOPAGE_H +#define _CRYPTOPAGE_H + +#include +#include + +#include +#include "gui/connect/ConnectFriendWizard.h" + +#include "ui_CryptoPage.h" + +class CryptoPage : public QWidget +{ + Q_OBJECT + + public: + /** Default Constructor */ + CryptoPage(QWidget * parent = 0, Qt::WFlags flags = 0); + /** 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(); + + void exportPublicKey(); + + + private: + /** A RshareSettings object used for saving/loading settings */ + RshareSettings* _settings; + + void closeEvent (QCloseEvent * event); + + + /** Qt Designer generated object */ + Ui::CryptoPage ui; +}; + +#endif + diff --git a/retroshare-gui/src/gui/settings/CryptoPage.ui b/retroshare-gui/src/gui/settings/CryptoPage.ui new file mode 100755 index 000000000..8ce4f9b71 --- /dev/null +++ b/retroshare-gui/src/gui/settings/CryptoPage.ui @@ -0,0 +1,590 @@ + + + CryptoPage + + + + 0 + 0 + 542 + 355 + + + + + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 192 + 192 + 192 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 104 + 104 + 104 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 104 + 104 + 104 + + + + + + + 255 + 255 + 255 + + + + + + + 104 + 104 + 104 + + + + + + + 240 + 240 + 240 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + Arial + 8 + 50 + false + false + false + false + + + + Qt::NoContextMenu + + + + + + + + Public Key + + + + + + + + + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Export my Key as file</p></body></html> + + + Export Key + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copy my Key to Clipboard</p></body></html> + + + Copy Key + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + Qt::Vertical + + + + 58 + 298 + + + + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/settings/DirectoriesPage.cpp b/retroshare-gui/src/gui/settings/DirectoriesPage.cpp new file mode 100755 index 000000000..b0abcee42 --- /dev/null +++ b/retroshare-gui/src/gui/settings/DirectoriesPage.cpp @@ -0,0 +1,217 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006 - 2009 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 "DirectoriesPage.h" +#include "rshare.h" +#include "rsiface/rsfiles.h" + +#include + + +DirectoriesPage::DirectoriesPage(QWidget * parent, Qt::WFlags flags) + : QWidget(parent, flags) +{ + ui.setupUi(this); + setAttribute(Qt::WA_QuitOnClose, false); + + load(); + + connect(ui.addButton, SIGNAL(clicked( bool ) ), this , SLOT( addShareDirectory() ) ); + connect(ui.removeButton, SIGNAL(clicked( bool ) ), this , SLOT( removeShareDirectory() ) ); + 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))); + + ui.addButton->setToolTip(tr("Add a Share Directory")); + ui.removeButton->setToolTip(tr("Remove Shared Directory")); + ui.incomingButton->setToolTip(tr("Browse")); + ui.partialButton->setToolTip(tr("Browse")); + + if (rsFiles->getShareDownloadDirectory()) + { + ui.checkBox->setDown(true); /* signal not emitted */ + } + else + { + ui.checkBox->setDown(false); /* signal not emitted */ + } + + /* Hide platform specific features */ +#ifdef Q_WS_WIN + +#endif +} + +void +DirectoriesPage::closeEvent (QCloseEvent * event) +{ + QWidget::closeEvent(event); +} + + +/** 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 */ + if (ui.checkBox->isChecked()) + { + std::list::const_iterator it; + std::list dirs; + rsFiles->getSharedDirectories(dirs); + + if (dirs.end() == std::find(dirs.begin(), dirs.end(), rsFiles->getDownloadDirectory())) + { + rsFiles->shareDownloadDirectory(); + } + rsFiles->setShareDownloadDirectory(true); + } + else + { + rsFiles->unshareDownloadDirectory(); + rsFiles->setShareDownloadDirectory(false); + } + + return true; + +} + +/** Loads the settings for this page */ +void DirectoriesPage::load() +{ + std::list::const_iterator it; + std::list dirs; + rsFiles->getSharedDirectories(dirs); + + /* get a link to the table */ + QListWidget *listWidget = ui.dirList; + + /* remove old items ??? */ + listWidget->clear(); + + for(it = dirs.begin(); it != dirs.end(); it++) + { + /* (0) Dir Name */ + listWidget->addItem(QString::fromStdString(*it)); + } + + ui.incomingDir->setText(QString::fromStdString(rsFiles->getDownloadDirectory())); + ui.partialsDir->setText(QString::fromStdString(rsFiles->getPartialsDirectory())); + + listWidget->update(); /* update display */ + +} + +void DirectoriesPage::addShareDirectory() +{ + + /* select a dir + */ + + int ind; + QString qdir = QFileDialog::getExistingDirectory(this, tr("Add Shared Directory"), "", + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + ind=qdir.lastIndexOf("/"); + + /* add it to the server */ + std::string dir = qdir.toStdString(); + if (dir != "") + { + rsFiles->addSharedDirectory(dir); + load(); + } +} + +void DirectoriesPage::removeShareDirectory() +{ + /* id current dir */ + /* ask for removal */ + QListWidget *listWidget = ui.dirList; + QListWidgetItem *qdir = listWidget -> currentItem(); + if (qdir) + { + rsFiles->removeSharedDirectory( qdir->text().toStdString()); + load(); + } +} + +void DirectoriesPage::setIncomingDirectory() +{ + QString qdir = QFileDialog::getExistingDirectory(this, tr("Set Incoming Directory"), "", + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + + std::string dir = qdir.toStdString(); + if (dir != "") + { + rsFiles->setDownloadDirectory(dir); + if (ui.checkBox->isChecked()) + { + std::list::const_iterator it; + std::list dirs; + rsFiles->getSharedDirectories(dirs); + + if (dirs.end() == std::find(dirs.begin(), dirs.end(), rsFiles->getDownloadDirectory())) + { + rsFiles->shareDownloadDirectory(); + } + } + } + load(); +} + +void DirectoriesPage::setPartialsDirectory() +{ + QString qdir = QFileDialog::getExistingDirectory(this, tr("Set Partials Directory"), "", + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + + std::string dir = qdir.toStdString(); + if (dir != "") + { + rsFiles->setPartialsDirectory(dir); + } + load(); +} + +void DirectoriesPage::shareDownloadDirectory(int state) +{ + if (state == Qt::Checked) + { + std::list::const_iterator it; + std::list dirs; + rsFiles->getSharedDirectories(dirs); + + if (dirs.end() == std::find(dirs.begin(), dirs.end(), rsFiles->getDownloadDirectory())) + { + rsFiles->shareDownloadDirectory(); + } + rsFiles->setShareDownloadDirectory(true); + } + else + { + rsFiles->unshareDownloadDirectory(); + rsFiles->setShareDownloadDirectory(false); + } + load(); +} + + diff --git a/retroshare-gui/src/gui/settings/DirectoriesPage.h b/retroshare-gui/src/gui/settings/DirectoriesPage.h new file mode 100755 index 000000000..960e78f40 --- /dev/null +++ b/retroshare-gui/src/gui/settings/DirectoriesPage.h @@ -0,0 +1,63 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006 - 2009 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. + ****************************************************************/ + +#ifndef DIRECTORIESPAGE_H +# define DIRECTORIESPAGE_H + +#include +#include +#include + + +# include "ui_DirectoriesPage.h" + +class DirectoriesPage: public QWidget +{ + 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 */ + void load(); + + + + private slots: + + void addShareDirectory(); + void removeShareDirectory(); + void setIncomingDirectory(); + void setPartialsDirectory(); + void shareDownloadDirectory(int state); + + private: + + void closeEvent (QCloseEvent * event); + + Ui::DirectoriesPage ui; +}; + +#endif // !GENERALPAGE_H + diff --git a/retroshare-gui/src/gui/settings/DirectoriesPage.ui b/retroshare-gui/src/gui/settings/DirectoriesPage.ui new file mode 100755 index 000000000..7466ceaa9 --- /dev/null +++ b/retroshare-gui/src/gui/settings/DirectoriesPage.ui @@ -0,0 +1,711 @@ + + + DirectoriesPage + + + + 0 + 0 + 452 + 349 + + + + + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 192 + 192 + 192 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 104 + 104 + 104 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 104 + 104 + 104 + + + + + + + 255 + 255 + 255 + + + + + + + 104 + 104 + 104 + + + + + + + 240 + 240 + 240 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + Arial + 10 + 50 + false + false + false + false + + + + true + + + Qt::NoContextMenu + + + + 6 + + + 0 + + + + + Shared Directories + + + + + + + + + + 34 + 34 + + + + + 34 + 34 + + + + + + + + :/images/directoryadd_24x24_shadow.png:/images/directoryadd_24x24_shadow.png + + + + 24 + 24 + + + + + + + + + 34 + 34 + + + + + 34 + 34 + + + + + + + + :/images/directoryremove_24x24_shadow.png:/images/directoryremove_24x24_shadow.png + + + + 24 + 24 + + + + + + + + Qt::Vertical + + + + 20 + 71 + + + + + + + + true + + + Automatically share incoming directory (Recommanded) + + + true + + + + + + + + + + Incoming Directory + + + + + + true + + + + + + + + 31 + 31 + + + + + 31 + 31 + + + + + + + + :/images/directoryselect_24x24_shadow.png:/images/directoryselect_24x24_shadow.png + + + + 24 + 24 + + + + + + + + + + + Partials Direcrtory + + + + + + true + + + + + + + + 31 + 31 + + + + + 31 + 31 + + + + + + + + :/images/directoryselect_24x24_shadow.png:/images/directoryselect_24x24_shadow.png + + + + 24 + 24 + + + + + + + + + + + incomingDir + incomingButton + dirList + addButton + removeButton + + + + + + diff --git a/retroshare-gui/src/gui/settings/FileAssociationsPage.cpp b/retroshare-gui/src/gui/settings/FileAssociationsPage.cpp new file mode 100755 index 000000000..6122532ae --- /dev/null +++ b/retroshare-gui/src/gui/settings/FileAssociationsPage.cpp @@ -0,0 +1,379 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2009 The RetroShare Team, Oleksiy Bilyanskyy + * + * 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 "FileAssociationsPage.h" +#include "AddFileAssociationDialog.h" +//#include "rshare.h" // for Rshare::dataDirectory() method +#include "gui/Preferences/rsharesettings.h" + +#include +#include + +#include +#include +#include +#include + +//#include +//#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include + +#include +#include +//#include + +//============================================================================ + +FileAssociationsPage::FileAssociationsPage(QWidget * parent, Qt::WFlags flags) + : QWidget(parent, flags) +//:QFrame() +{ + QVBoxLayout* pageLay = new QVBoxLayout(this); + + toolBar = new QToolBar("actions", this); + newAction = new QAction(QIcon(":/images/add_24x24.png"), tr("&New"), this); + //newAction->setShortcut(tr("Ctrl+N")); + newAction->setStatusTip(tr("Add new Association")); + connect(newAction, SIGNAL(triggered()), this, SLOT(addnew())); + toolBar->addAction(newAction); + + editAction = new QAction(QIcon(":/images/kcmsystem24.png"), + tr("&Edit"), this); + editAction->setStatusTip(tr("Edit this Association")); + connect(editAction, SIGNAL(triggered()), this, SLOT(edit())); + toolBar->addAction(editAction); + + removeAction = new QAction(QIcon(":/images/edit_remove24.png"), + tr("&Remove"), this); + removeAction->setStatusTip(tr("Remove this Association")); + connect(removeAction, SIGNAL(triggered()), this, SLOT(remove())); + toolBar->addAction( removeAction ); + + pageLay->addWidget( toolBar ); + + 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)) ); + connect( table, SIGNAL( cellClicked(int, int)), + this, SLOT( tableCellActivated(int, int)) ); + +// connect( table, SIGNAL( cellChanged(int, int)), +// this, SLOT( tableCellActivated(int, int)) ); +// +// connect( table, SIGNAL( cellDoubleClicked(int, int)), +// this, SLOT( tableCellActivated(int, int)) ); +// +// connect( table, SIGNAL( cellEntered(int, int)), +// this, SLOT( tableCellActivated(int, int)) ); +// +// connect( table, SIGNAL( cellPressed(int, int)), +// this, SLOT( tableCellActivated(int, int)) ); + + +// connect( table, SIGNAL( itemClicked(QTableWidgetItem*)), +// this, SLOT( tableItemActivated(QTableWidgetItem*)) ); + + pageLay->addWidget(table); + +// addNewAssotiationButton = new QPushButton; +// addNewAssotiationButton->setText(tr("Add..")); +// QHBoxLayout* anbLay = new QHBoxLayout; +// anbLay->addStretch(); +// anbLay->addWidget(addNewAssotiationButton); +// pageLay->addLayout(anbLay); +// connect( addNewAssotiationButton, SIGNAL( clicked() ), +// this, SLOT( testButtonClicked() ) ); + + settings = new RshareSettings(); + //new QSettings( qApp->applicationDirPath()+"/sett.ini", + // QSettings::IniFormat); + settings->beginGroup("FileAssociations"); + + + +} + +//============================================================================ + +FileAssociationsPage::~FileAssociationsPage() +{ + delete settings ; +} + +//============================================================================ + +bool +FileAssociationsPage::save (QString &errmsg) +{ + //RshareSettings* settings = new RshareSettings(); + + +// settings->beginGroup("FileAssotiations"); +// settings->setValue(".s01", "s01 test"); +// settings->setValue(".s02", "s02 test"); +// settings->setValue(".s03", "s03 test"); +// settings->setValue(".s04", "s04 test"); +// QMap::const_iterator ati = ations.constBegin(); +// while (ati != ations.constEnd()) +// { +// settings->setValue( ati.key(), ati.value() ); +// qDebug() << " - " << ati.key() << ati.value() << "\n" ; +// ati++; +// } +// +// settings->endGroup(); + + settings->sync(); + +// delete settings; +/* */ + return true; +} + +//============================================================================ + +void +FileAssociationsPage::load() +{ + //RshareSettings* settings = new RshareSettings(); +// QSettings* settings = new QSettings( qApp->applicationDirPath()+"/sett.ini", +// QSettings::IniFormat); +// +// settings->beginGroup("FileAssotiations"); + QStringList keys = settings->allKeys(); + + table->setRowCount( keys.count() ); + + int rowi = 0; + QStringList::const_iterator ki; + for(ki=keys.constBegin(); ki!=keys.constEnd(); ki++) + { + QString val = (settings->value(*ki, "")).toString(); + + addNewItemToTable( rowi, 0, *ki ); + addNewItemToTable( rowi, 1, val ); + + rowi++; + } + + //delete settings; + if (keys.count()==0) + { + removeAction->setEnabled(false); + editAction->setEnabled(false); + } + + table->selectRow(0); +} + +//============================================================================ + +void +FileAssociationsPage::remove() +{ + int currentRow = table->currentRow() ; + QTableWidgetItem const * titem = table->item( currentRow,0); + QString key = (titem->data(QTableWidgetItem::Type)).toString(); + + settings->remove(key); + table->removeRow( currentRow ); + + if ( table->rowCount()==0 ) + { + removeAction->setEnabled(false); + editAction->setEnabled(false); + } +} + +//============================================================================ + +void +FileAssociationsPage::addnew() +{ + AddFileAssociationDialog afad(false, this);//'add file assotiations' dialog + + int currentRow = table->currentRow() ; + QTableWidgetItem* titem; + + int ti = afad.exec(); + + if (ti==QDialog::Accepted) + { + QString currType = afad.resultFileType() ; + QString currCmd = afad.resultCommand() ; + + + if ( !settings->contains(currType) )//new item should be added only if + { // it wasn't entered before. + int nridx = table->rowCount();//new row index + table->setRowCount(nridx+1); + addNewItemToTable(nridx,0, currType) ; + addNewItemToTable(nridx,1, currCmd); + } + else + { + for(int rowi=0; rowirowCount(); rowi++) + { + titem = table->item( rowi, 0); + if (titem->data(QTableWidgetItem::Type).toString()==currType) + { + titem = table->item( rowi, 1); + titem->setData(QTableWidgetItem::Type, currCmd); + break; + } + } + } + + settings->setValue(currType, currCmd); + + removeAction->setEnabled(true); + editAction->setEnabled(true); + } +} + +//============================================================================ + +void +FileAssociationsPage::edit() +{ + AddFileAssociationDialog afad(true, this);//'add file assotiations' dialog + + int currentRow = table->currentRow() ; + QTableWidgetItem* titem; + + titem = table->item( currentRow,0); + QString currType = (titem->data(QTableWidgetItem::Type)).toString(); + titem = table->item( currentRow,1); + 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); + } +} + +//============================================================================ + +void +FileAssociationsPage::tableCellActivated ( int row, int column ) +{ + table->selectRow(row); +} + +//============================================================================ + +void +FileAssociationsPage::tableItemActivated ( QTableWidgetItem * item ) +{ + qDebug() << "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\n"; + QMessageBox::information(this, + tr(" Friend Help"), + tr("You this")); + table->selectRow(table->row(item)); + +} + +//============================================================================ + +void +FileAssociationsPage::addNewItemToTable(int row, int column, + QString itemText) +{ + QTableWidgetItem* tmpitem ; + + tmpitem = new QTableWidgetItem(itemText) ; + tmpitem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + // | Qt::ItemIsUserCheckable); + table->setItem(row, column, tmpitem ); +} + +//============================================================================ + +void +FileAssociationsPage::testButtonClicked() +{ + AddFileAssociationDialog afad(this);// = new AddFileAssotiationDialog(); + +// commented code below is a test for +// AddFileAssotiationDialog::loadSystemDefaultCommand(QString ft) method +// QString tmps; +// tmps = "/home/folder/file"; +// qDebug() << " for " << tmps <<" is " << afad.cleanFileType(tmps); +// tmps = "/home/folder/file.avi"; +// qDebug() << " for " << tmps <<" is " << afad.cleanFileType(tmps); +// tmps = "file.avi"; +// qDebug() << " for " << tmps <<" is " << afad.cleanFileType(tmps); +// tmps = ".file"; +// qDebug() << " for " << tmps <<" is " << afad.cleanFileType(tmps); +// tmps = "c:\\home\\folder\\file"; +// qDebug() << " for " << tmps <<" is " << afad.cleanFileType(tmps); +// tmps = "/home/folder/.file"; +// qDebug() << " for " << tmps <<" is " << afad.cleanFileType(tmps); +// tmps = "D:\\folder\\file.asd.avi"; +// qDebug() << " for " << tmps <<" is " << afad.cleanFileType(tmps); + + + + int ti = afad.exec(); + + if (ti==QDialog::Accepted) + { + qDebug() << " dialog was accepted"; + QProcess::execute(afad.resultCommand());//, + //QStringList("D:\\prog\\eclipse_workspace\\tapp-fa\\tt.txt") ); + qDebug() << " process finished?"; + } + else + if (ti == QDialog::Rejected) + qDebug() << " dialog rejected" ; + else + qDebug() << "dialog returned something else" ; + + +} + +//============================================================================ + + + diff --git a/retroshare-gui/src/gui/settings/FileAssociationsPage.h b/retroshare-gui/src/gui/settings/FileAssociationsPage.h new file mode 100755 index 000000000..7b5ee87ca --- /dev/null +++ b/retroshare-gui/src/gui/settings/FileAssociationsPage.h @@ -0,0 +1,93 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2009 The RetroShare Team, Oleksiy Bilyanskyy + * + * 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 __FileAssociationsPage__ +#define __FileAssociationsPage__ + +//#include "configpage.h" + +#include +#include +#include +//#include + +//#include +//#include + +class QToolBar; +class QAction; +class QTableWidget; +class QTableWidgetItem; +class QPushButton; +class QDialogButtonBox; + + +class QLabel; +class QLineEdit; + +//class QSettings; +class RshareSettings; + +//============================================================================= +//! Dialog for setting file assotiations for RS + +//! 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 +{ + Q_OBJECT + +public: + FileAssociationsPage(QWidget * parent = 0, Qt::WFlags flags = 0); + virtual ~FileAssociationsPage(); + + void load(); + bool save (QString &errmsg); + +protected: + QToolBar* toolBar; + + QAction* newAction; + QAction* editAction; + QAction* removeAction; + + QTableWidget* table; + QPushButton* addNewAssotiationButton; + QString settingsFileName; + + RshareSettings* settings; +// QSettings* settings; + + void addNewItemToTable(int row, int column, QString itemText); + +protected slots: + void remove(); + void addnew(); + void edit(); + void tableCellActivated ( int row, int column ); + void tableItemActivated ( QTableWidgetItem * item ) ; + void testButtonClicked();//! slot for debuggin purposes, nnot really used +}; + + + +#endif diff --git a/retroshare-gui/src/gui/settings/GeneralPage.cpp b/retroshare-gui/src/gui/settings/GeneralPage.cpp new file mode 100755 index 000000000..a1dfc4c8b --- /dev/null +++ b/retroshare-gui/src/gui/settings/GeneralPage.cpp @@ -0,0 +1,90 @@ +/**************************************************************** + * 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. + ****************************************************************/ + +#include "GeneralPage.h" +#include "rshare.h" +#include + +#include + +GeneralPage::GeneralPage(QWidget * parent, Qt::WFlags flags) + : QWidget(parent, flags) +{ + ui.setupUi(this); + setAttribute(Qt::WA_QuitOnClose, false); + setWindowTitle(windowTitle() + QLatin1String(" - General")); + + + /* Create RshareSettings object */ + _settings = new RshareSettings(); + + + /* Hide platform specific features */ +#ifndef Q_WS_WIN + ui.chkRunRetroshareAtSystemStartup->setVisible(false); +#endif ´ +} + +void +GeneralPage::closeEvent (QCloseEvent * event) +{ + + QWidget::closeEvent(event); +} + + +/** Saves the changes on this page */ +bool +GeneralPage::save(QString &errmsg) +{ + _settings->setValue(QString::fromUtf8("StartMinimized"), startMinimized()); + + _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()); +} + +bool GeneralPage::startMinimized() const { + if(ui.checkStartMinimized->isChecked()) return true; + return ui.checkStartMinimized->isChecked(); +} + +/** Called when the "show on startup" checkbox is toggled. */ +void +GeneralPage::toggleShowOnStartup(bool checked) +{ + //RshareSettings _settings; + _settings->setShowMainWindowAtStart(checked); +} + + diff --git a/retroshare-gui/src/gui/settings/GeneralPage.h b/retroshare-gui/src/gui/settings/GeneralPage.h new file mode 100755 index 000000000..15490c355 --- /dev/null +++ b/retroshare-gui/src/gui/settings/GeneralPage.h @@ -0,0 +1,66 @@ +/**************************************************************** + * 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 GENERALPAGE_H +# define GENERALPAGE_H + +#include +#include + +#include "gui/Preferences/rsharesettings.h" +#include "lang/languagesupport.h" + +# include +# include "ui_GeneralPage.h" + +class GeneralPage: public QWidget +{ + Q_OBJECT + + public: + GeneralPage(QWidget * parent = 0, Qt::WFlags flags = 0); + ~GeneralPage() {} + + /** Saves the changes on this page */ + bool save(QString &errmsg); + /** Loads the settings for this page */ + void load(); + + bool startMinimized() const; + + private slots: + + /** Called when the "show on startup" checkbox is toggled. */ + void toggleShowOnStartup(bool checked); + + private: + /** A VidaliaSettings object used for saving/loading settings */ + RshareSettings* _settings; + + + void closeEvent (QCloseEvent * event); + + Ui::GeneralPage ui; +}; + +#endif // !GENERALPAGE_H + diff --git a/retroshare-gui/src/gui/settings/GeneralPage.ui b/retroshare-gui/src/gui/settings/GeneralPage.ui new file mode 100755 index 000000000..9d10185a7 --- /dev/null +++ b/retroshare-gui/src/gui/settings/GeneralPage.ui @@ -0,0 +1,560 @@ + + + GeneralPage + + + + 0 + 0 + 413 + 267 + + + + + 0 + 64 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 192 + 192 + 192 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 104 + 104 + 104 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 104 + 104 + 104 + + + + + + + 255 + 255 + 255 + + + + + + + 104 + 104 + 104 + + + + + + + 240 + 240 + 240 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + Arial + 10 + 50 + false + false + false + false + + + + Qt::NoContextMenu + + + + 6 + + + 0 + + + + + + 0 + 80 + + + + Startup + + + + + + Start RetroShare when my system starts + + + + + + + Start minimized + + + true + + + + + + + + + + Qt::Vertical + + + + 401 + 91 + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/settings/NetworkPage.cpp b/retroshare-gui/src/gui/settings/NetworkPage.cpp new file mode 100755 index 000000000..5209ec2bb --- /dev/null +++ b/retroshare-gui/src/gui/settings/NetworkPage.cpp @@ -0,0 +1,53 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006, crypton + * + * 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 "NetworkPage.h" +#include "rshare.h" + +NetworkPage::NetworkPage(QWidget * parent, Qt::WFlags flags) + : QWidget(parent, flags) +{ + ui.setupUi(this); + setAttribute(Qt::WA_QuitOnClose, false); + +} + +void +NetworkPage::closeEvent (QCloseEvent * event) +{ + QWidget::closeEvent(event); +} + + +/** Saves the changes on this page */ +bool +NetworkPage::save(QString &errmsg) +{ + +} + +/** Loads the settings for this page */ +void +NetworkPage::load() +{ + +} + diff --git a/retroshare-gui/src/gui/settings/NetworkPage.h b/retroshare-gui/src/gui/settings/NetworkPage.h new file mode 100755 index 000000000..a3b576e06 --- /dev/null +++ b/retroshare-gui/src/gui/settings/NetworkPage.h @@ -0,0 +1,47 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006, crypton + * + * 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 NETWORKPAGE_H +#define NETWORKPAGE_H + +#include +#include "ui_NetworkPage.h" + +class NetworkPage: public QWidget +{ + 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; +}; + +#endif // !NETWROKPAGE_H + diff --git a/retroshare-gui/src/gui/settings/NetworkPage.ui b/retroshare-gui/src/gui/settings/NetworkPage.ui new file mode 100755 index 000000000..cbdc5cc51 --- /dev/null +++ b/retroshare-gui/src/gui/settings/NetworkPage.ui @@ -0,0 +1,506 @@ + + NetworkPage + + + + 0 + 0 + 398 + 389 + + + + + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 192 + 192 + 192 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 104 + 104 + 104 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 104 + 104 + 104 + + + + + + + 255 + 255 + 255 + + + + + + + 104 + 104 + 104 + + + + + + + 240 + 240 + 240 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + Arial + 8 + 50 + false + false + false + false + + + + Qt::NoContextMenu + + + + + + + diff --git a/retroshare-gui/src/gui/settings/NotifyPage.cpp b/retroshare-gui/src/gui/settings/NotifyPage.cpp new file mode 100755 index 000000000..92d993099 --- /dev/null +++ b/retroshare-gui/src/gui/settings/NotifyPage.cpp @@ -0,0 +1,162 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006 - 2009 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 +#include "NotifyPage.h" +#include +#include + +#include "rsiface/rsnotify.h" + +#include + + +/** Constructor */ +NotifyPage::NotifyPage(QWidget * parent, Qt::WFlags flags) + : QWidget(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(); + + load(); + + //QTimer *timer = new QTimer(this); + //timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus())); + //timer->start(1000); + + + /* Hide platform specific features */ +#ifdef Q_WS_WIN + +#endif +} + +void +NotifyPage::closeEvent (QCloseEvent * event) +{ + QWidget::closeEvent(event); +} + +/** Saves the changes on this page */ +bool +NotifyPage::save(QString &errmsg) +{ + /* extract from rsNotify the flags */ + + uint notifyflags = 0; + uint newsflags = 0; + uint chatflags = 0; + + if (ui.popup_Connect->isChecked()) + notifyflags |= RS_POPUP_CONNECT; + + if (ui.popup_NewMsg->isChecked()) + notifyflags |= RS_POPUP_MSG; + + //if (ui.popup_NewChat->isChecked()) + notifyflags |= RS_POPUP_CHAT; + + //if (ui.popup_Call->isChecked()) + // notifyflags |= RS_POPUP_CALL; + + + if (ui.notify_Peers->isChecked()) + newsflags |= RS_FEED_TYPE_PEER; + if (ui.notify_Channels->isChecked()) + newsflags |= RS_FEED_TYPE_CHAN; + if (ui.notify_Forums->isChecked()) + newsflags |= RS_FEED_TYPE_FORUM; + if (ui.notify_Blogs->isChecked()) + newsflags |= RS_FEED_TYPE_BLOG; + if (ui.notify_Chat->isChecked()) + newsflags |= RS_FEED_TYPE_CHAT; + if (ui.notify_Messages->isChecked()) + newsflags |= RS_FEED_TYPE_MSG; + if (ui.notify_Downloads->isChecked()) + newsflags |= RS_FEED_TYPE_FILES; + + if (ui.chat_NewWindow->isChecked()) + chatflags |= RS_CHAT_OPEN_NEW; + if (ui.chat_Reopen->isChecked()) + chatflags |= RS_CHAT_REOPEN; + if (ui.chat_Focus->isChecked()) + chatflags |= RS_CHAT_FOCUS; + + _settings->setNotifyFlags(notifyflags); + _settings->setNewsFeedFlags(newsflags); + _settings->setChatFlags(chatflags); + + load(); + return true; +} + + +/** Loads the settings for this page */ +void NotifyPage::load() +{ + /* extract from rsNotify the flags */ + + uint notifyflags = _settings->getNotifyFlags(); + uint newsflags = _settings->getNewsFeedFlags(); + uint chatflags = _settings->getChatFlags(); + + ui.popup_Connect->setChecked(notifyflags & RS_POPUP_CONNECT); + ui.popup_NewMsg->setChecked(notifyflags & RS_POPUP_MSG); + ui.systray_GroupChat->setChecked(true) ; + //ui.popup_NewChat->setChecked(notifyflags & RS_POPUP_CHAT); + //ui.popup_Call->setChecked(notifyflags & RS_POPUP_CALL); + + ui.notify_Peers->setChecked(newsflags & RS_FEED_TYPE_PEER); + ui.notify_Channels->setChecked(newsflags & RS_FEED_TYPE_CHAN); + ui.notify_Forums->setChecked(newsflags & RS_FEED_TYPE_FORUM); + ui.notify_Blogs->setChecked(newsflags & RS_FEED_TYPE_BLOG); + ui.notify_Chat->setChecked(newsflags & RS_FEED_TYPE_CHAT); + ui.notify_Messages->setChecked(newsflags & RS_FEED_TYPE_MSG); + ui.notify_Downloads->setChecked(newsflags & RS_FEED_TYPE_FILES); + + ui.chat_NewWindow->setChecked(chatflags & RS_CHAT_OPEN_NEW); + ui.chat_Reopen->setChecked(chatflags & RS_CHAT_REOPEN); + ui.chat_Focus->setChecked(chatflags & RS_CHAT_FOCUS); + + + /* disable ones that don't work yet */ + ui.notify_Chat->setEnabled(false); + ui.notify_Blogs->setEnabled(false); + ui.notify_Downloads->setEnabled(false); + ui.systray_GroupChat->setEnabled(false); + //ui.popup_NewChat->setEnabled(false); +} + + +/** Loads the settings for this page */ +void NotifyPage::updateStatus() +{ + +} + + + diff --git a/retroshare-gui/src/gui/settings/NotifyPage.h b/retroshare-gui/src/gui/settings/NotifyPage.h new file mode 100755 index 000000000..88af73d4c --- /dev/null +++ b/retroshare-gui/src/gui/settings/NotifyPage.h @@ -0,0 +1,65 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006 - 2009 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. + ****************************************************************/ + +#ifndef NOTIFYPAGE_H +#define NOTIFYPAGE_H + +#include +#include + +#include "gui/Preferences/rsharesettings.h" + + +#include "ui_NotifyPage.h" + +class NotifyPage : public QWidget +{ + Q_OBJECT + + public: + /** Default Constructor */ + NotifyPage(QWidget * parent = 0, Qt::WFlags flags = 0); + ~NotifyPage() {} + /** Default Destructor */ + + /** Saves the changes on this page */ + bool save(QString &errmsg); + /** Loads the settings for this page */ + void load(); + + public slots: + void updateStatus(); + + private slots: + + private: + + void closeEvent (QCloseEvent * event); + + /** A RshareSettings object used for saving/loading settings */ + RshareSettings* _settings; + + /** Qt Designer generated object */ + Ui::NotifyPage ui; +}; + +#endif // !NOTIFYPAGE_H + diff --git a/retroshare-gui/src/gui/settings/NotifyPage.ui b/retroshare-gui/src/gui/settings/NotifyPage.ui new file mode 100755 index 000000000..ab46b8d60 --- /dev/null +++ b/retroshare-gui/src/gui/settings/NotifyPage.ui @@ -0,0 +1,686 @@ + + + NotifyPage + + + + 0 + 0 + 388 + 425 + + + + + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 192 + 192 + 192 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 104 + 104 + 104 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 104 + 104 + 104 + + + + + + + 255 + 255 + 255 + + + + + + + 104 + 104 + 104 + + + + + + + 240 + 240 + 240 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + Arial + 10 + 50 + false + false + false + false + + + + Qt::NoContextMenu + + + + + + + + + + News Feed + + + + 0 + + + 6 + + + + + Peers + + + + + + + Channels + + + + + + + Forums + + + + + + + Chat + + + + + + + Blogs + + + + + + + Messages + + + + + + + Downloads + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Toasters + + + + 9 + + + 9 + + + + + Peer Connect + + + + + + + New Message + + + + + + + + + + Private Chat + + + + + + Open Window for new Peer Chat + + + + + + + Reopen if closed by user: + + + + + + + Grab Focus when chat arrives + + + + + + + + + + Group chat + + + + + + Display systray message + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 130 + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp new file mode 100755 index 000000000..ec65e947b --- /dev/null +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -0,0 +1,363 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006, crypton + * + * 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 "ServerPage.h" +#include "rshare.h" + +#include +#include + +#include "rsiface/rsiface.h" +#include "rsiface/rspeers.h" + +#include + +ServerPage::ServerPage(QWidget * parent, Qt::WFlags flags) + : QWidget(parent, flags) +{ + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); + + connect( ui.netModeComboBox, SIGNAL( activated ( int ) ), this, SLOT( toggleUPnP( ) ) ); + connect( ui.allowIpDeterminationCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleIpDetermination(bool) ) ); + + QTimer *timer = new QTimer(this); + timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus())); + timer->start(1000); + + load(); + updateStatus(); + + bool b = rsPeers->getAllowServerIPDetermination() ; + ui.allowIpDeterminationCB->setChecked(b) ; + ui.IPServersLV->setEnabled(b) ; + + std::list ip_servers ; + rsPeers->getIPServersList(ip_servers) ; + + for(std::list::const_iterator it(ip_servers.begin());it!=ip_servers.end();++it) + ui.IPServersLV->addItem(QString::fromStdString(*it)) ; + + /* Hide platform specific features */ +#ifdef Q_WS_WIN + +#endif +} + +void ServerPage::toggleIpDetermination(bool b) +{ + rsPeers->allowServerIPDetermination(b) ; + ui.IPServersLV->setEnabled(b) ; +} + +void +ServerPage::closeEvent (QCloseEvent * event) +{ + QWidget::closeEvent(event); +} + + +/** Saves the changes on this page */ +bool +ServerPage::save(QString &errmsg) +{ + +/* save the server address */ +/* save local address */ +/* save the url for DNS access */ + +/* restart server */ + +/* save all? */ + saveAddresses(); + return true; +} + +/** Loads the settings for this page */ +void ServerPage::load() +{ + + /* load up configuration from rsPeers */ + RsPeerDetails detail; + if (!rsPeers->getPeerDetails(rsPeers->getOwnId(), detail)) + { + return; + } + + /* set net mode */ + int netIndex = 0; + switch(detail.tryNetMode) + { + case RS_NETMODE_EXT: + netIndex = 2; + break; + case RS_NETMODE_UDP: + netIndex = 1; + break; + default: + case RS_NETMODE_UPNP: + netIndex = 0; + break; + } + ui.netModeComboBox->setCurrentIndex(netIndex); + + /* set dht/disc */ + netIndex = 1; + if (detail.visState & RS_VS_DHT_ON) + { + netIndex = 0; + } + ui.dhtComboBox->setCurrentIndex(netIndex); + + netIndex = 1; + if (detail.visState & RS_VS_DISC_ON) + { + netIndex = 0; + } + ui.discComboBox->setCurrentIndex(netIndex); + + rsiface->lockData(); /* Lock Interface */ + + ui.totalDownloadRate->setValue(rsiface->getConfig().maxDownloadDataRate); + ui.totalUploadRate->setValue(rsiface->getConfig().maxUploadDataRate); + + rsiface->unlockData(); /* UnLock Interface */ + + + toggleUPnP(); + + + /* Addresses must be set here - otherwise can't edit it */ + /* set local address */ + ui.localAddress->setText(QString::fromStdString(detail.localAddr)); + ui.localPort -> setValue(detail.localPort); + /* set the server address */ + ui.extAddress->setText(QString::fromStdString(detail.extAddr)); + ui.extPort -> setValue(detail.extPort); +} + +/** Loads the settings for this page */ +void ServerPage::updateStatus() +{ + + /* load up configuration from rsPeers */ + RsPeerDetails detail; + if (!rsPeers->getPeerDetails(rsPeers->getOwnId(), detail)) + { + return; + } + + /* only update if can't edit */ + if (!ui.localPort->isEnabled()) + { + /* set local address */ + ui.localPort -> setValue(detail.localPort); + ui.extPort -> setValue(detail.extPort); + } + + /* set local address */ + ui.localAddress->setText(QString::fromStdString(detail.localAddr)); + /* set the server address */ + ui.extAddress->setText(QString::fromStdString(detail.extAddr)); + +#if 0 + /* set status */ + std::ostringstream out; + out << "Attempted Network Mode: "; + switch(detail.tryNetMode) + { + case RS_NETMODE_EXT: + out << "External Forwarded Port (UltraPEER Mode)"; + break; + case RS_NETMODE_UDP: + out << "Firewalled"; + break; + default: + case RS_NETMODE_UPNP: + + out << "Automatic: UPnP Forwarded Port"; + break; + } + out << std::endl; + out << "Actual Network Mode: "; + switch(detail.netMode) + { + case RS_NETMODE_EXT: + out << "External Forwarded Port (UltraPEER Mode)"; + break; + case RS_NETMODE_UDP: + out << "Firewalled"; + break; + case RS_NETMODE_UPNP: + out << "Automatic: UPnP Forwarded Port"; + break; + default: + case RS_NETMODE_UNREACHABLE: + out << "Unreachable: Firewalled by Symmetric NAT"; + break; + } + out << std::endl; + out << "\tLocal Address: " << detail.localAddr; + out << ":" << detail.localPort; + out << std::endl; + out << "\tExternal Address: " << detail.extAddr; + out << ":" << detail.extPort; + out << std::endl; + + out << "UPnP Status: "; + out << std::endl; + + out << "DHT Status: "; + if (detail.visState & RS_VS_DHT_ON) + out << " Enabled"; + else + out << " Disabled"; + out << std::endl; + + out << "Discovery Status: "; + if (detail.visState & RS_VS_DISC_ON) + out << " Enabled"; + else + out << " Disabled"; + out << std::endl; + + + if (detail.netMode == RS_NETMODE_UNREACHABLE) + { + ui.netStatusBox->setTextColor( Qt::red ); + } + else + { + ui.netStatusBox->setTextColor( Qt::black ); + } + + ui.netStatusBox->setText(QString::fromStdString(out.str())); + ui.netStatusBox ->setReadOnly(true); +#endif + + + + +} + +void ServerPage::toggleUPnP() +{ + /* switch on the radioButton */ + bool settingChangeable = false; + if (0 != ui.netModeComboBox->currentIndex()) + { + settingChangeable = true; + } + + if (settingChangeable) + { + ui.dhtComboBox->setEnabled(true); + // disabled until we've got it all working. + //ui.discComboBox->setEnabled(true); + ui.discComboBox->setEnabled(false); + + ui.localAddress->setEnabled(false); + ui.localPort -> setEnabled(true); + ui.extAddress -> setEnabled(false); + ui.extPort -> setEnabled(true); + } + else + { + ui.dhtComboBox->setEnabled(false); + ui.discComboBox->setEnabled(false); + + ui.localAddress->setEnabled(false); + ui.localPort -> setEnabled(false); + ui.extAddress -> setEnabled(false); + ui.extPort -> setEnabled(false); + } +} + +void ServerPage::saveAddresses() +{ + QString str; + + bool saveAddr = false; + + + RsPeerDetails detail; + std::string ownId = rsPeers->getOwnId(); + + if (!rsPeers->getPeerDetails(ownId, detail)) + { + return; + } + + int netIndex = ui.netModeComboBox->currentIndex(); + + /* Check if netMode has changed */ + int netMode = 0; + switch(netIndex) + { + case 2: + netMode = RS_NETMODE_EXT; + break; + case 1: + netMode = RS_NETMODE_UDP; + break; + default: + case 0: + netMode = RS_NETMODE_UPNP; + break; + } + + if (detail.tryNetMode != netMode) + { + rsPeers->setNetworkMode(ownId, netMode); + } + + int visState = 0; + /* Check if vis has changed */ + if (0 == ui.discComboBox->currentIndex()) + { + visState |= RS_VS_DISC_ON; + } + + if (0 == ui.dhtComboBox->currentIndex()) + { + visState |= RS_VS_DHT_ON; + } + + if (visState != detail.visState) + { + rsPeers->setVisState(ownId, visState); + } + + if (0 != netIndex) + { + saveAddr = true; + } + + if (saveAddr) + { + rsPeers->setLocalAddress(rsPeers->getOwnId(), ui.localAddress->text().toStdString(), ui.localPort->value()); + rsPeers->setExtAddress(rsPeers->getOwnId(), ui.extAddress->text().toStdString(), ui.extPort->value()); + } + + rsicontrol->ConfigSetDataRates( ui.totalDownloadRate->value(), ui.totalUploadRate->value() ); + load(); +} + diff --git a/retroshare-gui/src/gui/settings/ServerPage.h b/retroshare-gui/src/gui/settings/ServerPage.h new file mode 100755 index 000000000..acb56908d --- /dev/null +++ b/retroshare-gui/src/gui/settings/ServerPage.h @@ -0,0 +1,58 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006, crypton + * + * 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 SERVERPAGE_H +# define SERVERPAGE_H + +# include +# include "ui_ServerPage.h" + +class ServerPage: public QWidget +{ + 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 */ + void load(); + +public slots: + void updateStatus(); + +private slots: + void saveAddresses(); + void toggleUPnP(); + void toggleIpDetermination(bool) ; + + + private: + + void closeEvent (QCloseEvent * event); + + Ui::ServerPage ui; +}; + +#endif // !SERVERPAGE_H + diff --git a/retroshare-gui/src/gui/settings/ServerPage.ui b/retroshare-gui/src/gui/settings/ServerPage.ui new file mode 100755 index 000000000..5f116934f --- /dev/null +++ b/retroshare-gui/src/gui/settings/ServerPage.ui @@ -0,0 +1,803 @@ + + + ServerPage + + + + 0 + 0 + 467 + 448 + + + + + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 192 + 192 + 192 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 104 + 104 + 104 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 104 + 104 + 104 + + + + + + + 255 + 255 + 255 + + + + + + + 104 + 104 + 104 + + + + + + + 240 + 240 + 240 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + Qt::NoContextMenu + + + + 6 + + + 0 + + + + + + 0 + 0 + + + + Network Configuration (takes effect after restart) + + + + + + + + + Automatic + + + + + Firewalled + + + + + Forwarded Port + + + + + + + + + + + DHT Enabled + + + + + DHT Disabled + + + + + + + + + Discovery Enabled + + + + + Discovery Disabled + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 0 + + + + Network Configuration + + + + + + + 0 + 0 + + + + Network Configuration + + + + + + + + + + Local Address + + + + + + + External Address + + + + + + + + + + + + + + Port: + + + + + + + 0 + + + 65535 + + + 7812 + + + + + + + + + + Port: + + + + + + + 0 + + + 65535 + + + 7812 + + + + + + + + + + + + + + + IP Service + + + + + + IP check service + + + + + + If you unckeck this, RetroShare can only determine your IP +when you connect to somebody. Leaving this checked helps +connecting when you have few friends. It also helps if you're +behind a firewall or a VPN. + + + Allow RetroShare to ask my ip to these websites: + + + true + + + + + + + QAbstractItemView::NoEditTriggers + + + + + + + + + + + + + + + 0 + 0 + + + + Transfer Rates + + + + + + 6 + + + 0 + + + + + Download (KB/s) + + + + + + + 1 + + + 12500 + + + 1 + + + + + + + + + 6 + + + + + Upload (KB/s) + + + + + + + 1 + + + 12500 + + + 1 + + + + + + + + + + + + localAddress + localPort + extPort + totalDownloadRate + + + + diff --git a/retroshare-gui/src/gui/settings/SoundPage.cpp b/retroshare-gui/src/gui/settings/SoundPage.cpp new file mode 100644 index 000000000..4532af674 --- /dev/null +++ b/retroshare-gui/src/gui/settings/SoundPage.cpp @@ -0,0 +1,174 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006 - 2009 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 +#include "SoundPage.h" + + +/** Constructor */ +SoundPage::SoundPage(QWidget * parent, Qt::WFlags flags) + : QWidget(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())); + connect(ui.cmd_openFile_4,SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile4())); + connect(ui.cmd_openFile_5,SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile5())); + connect(ui.cmd_openFile_6,SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile6())); + + /* Hide platform specific features */ +#ifdef Q_WS_WIN + +#endif +} + +/** Saves the changes on this page */ +bool +SoundPage::save(QString &errmsg) +{ + _settings->beginGroup("Sound"); + _settings->beginGroup("Enable"); + _settings->setValue("User_go_Online",ui.checkBoxSound->isChecked()); + _settings->setValue("User_go_Offline",ui.checkBoxSound_2->isChecked()); + _settings->setValue("FileSend_Finished",ui.checkBoxSound_3->isChecked()); + _settings->setValue("FileRecive_Incoming",ui.checkBoxSound_4->isChecked()); + _settings->setValue("FileRecive_Finished",ui.checkBoxSound_5->isChecked()); + _settings->setValue("NewChatMessage",ui.checkBoxSound_6->isChecked()); + _settings->endGroup(); + _settings->beginGroup("SoundFilePath"); + _settings->setValue("User_go_Online",ui.txt_SoundFile->text()); + _settings->setValue("User_go_Offline",ui.txt_SoundFile2->text()); + _settings->setValue("FileSend_Finished",ui.txt_SoundFile3->text()); + _settings->setValue("FileRecive_Incoming",ui.txt_SoundFile4->text()); + _settings->setValue("FileRecive_Finished",ui.txt_SoundFile5->text()); + _settings->setValue("NewChatMessage",ui.txt_SoundFile6->text()); + _settings->endGroup(); + _settings->endGroup(); + + return true; +} + + + +/** Loads the settings for this page */ +void +SoundPage::load() +{ + _settings->beginGroup("Sound"); + _settings->beginGroup("SoundFilePath"); + ui.txt_SoundFile->setText(_settings->value("User_go_Online","").toString()); + ui.txt_SoundFile2->setText(_settings->value("User_go_Offline","").toString()); + ui.txt_SoundFile3->setText(_settings->value("FileSend_Finished","").toString()); + ui.txt_SoundFile4->setText(_settings->value("FileRecive_Incoming","").toString()); + ui.txt_SoundFile5->setText(_settings->value("FileRecive_Finished","").toString()); + ui.txt_SoundFile6->setText(_settings->value("NewChatMessage","").toString()); + + if(!ui.txt_SoundFile->text().isEmpty())ui.checkBoxSound->setEnabled(true); + if(!ui.txt_SoundFile2->text().isEmpty())ui.checkBoxSound_2->setEnabled(true); + if(!ui.txt_SoundFile3->text().isEmpty())ui.checkBoxSound_3->setEnabled(true); + if(!ui.txt_SoundFile4->text().isEmpty())ui.checkBoxSound_4->setEnabled(true); + if(!ui.txt_SoundFile5->text().isEmpty())ui.checkBoxSound_5->setEnabled(true); + if(!ui.txt_SoundFile6->text().isEmpty())ui.checkBoxSound_6->setEnabled(true); + + _settings->endGroup(); + + _settings->beginGroup("Enable"); + ui.checkBoxSound->setChecked(_settings->value("User_go_Online",false).toBool()); + ui.checkBoxSound_2->setChecked(_settings->value("User_go_Offline",false).toBool()); + ui.checkBoxSound_3->setChecked(_settings->value("FileSend_Finished",false).toBool()); + 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(); +} + +void SoundPage::on_cmd_openFile() +{ + + ui.txt_SoundFile->setText(QFileDialog::getOpenFileName(this,"Open File", ".", "wav (*.wav)")); + if(ui.txt_SoundFile->text().isEmpty()){ + ui.checkBoxSound->setChecked(false); + ui.checkBoxSound->setEnabled(false); + } + else + ui.checkBoxSound->setEnabled(true); +} + +void SoundPage::on_cmd_openFile2() +{ + ui.txt_SoundFile2->setText(QFileDialog::getOpenFileName(this,"Open File", ".", "wav (*.wav)")); + if(ui.txt_SoundFile2->text().isEmpty()){ + ui.checkBoxSound_2->setChecked(false); + ui.checkBoxSound_2->setEnabled(false); + } + else + ui.checkBoxSound_2->setEnabled(true); + +} +void SoundPage::on_cmd_openFile3() +{ + ui.txt_SoundFile3->setText(QFileDialog::getOpenFileName(this,"Open File", ".", "wav (*.wav)")); + if(ui.txt_SoundFile3->text().isEmpty()){ + ui.checkBoxSound_3->setChecked(false); + ui.checkBoxSound_3->setEnabled(false); + } + else + ui.checkBoxSound_3->setEnabled(true); +} +void SoundPage::on_cmd_openFile4() +{ + ui.txt_SoundFile4->setText(QFileDialog::getOpenFileName(this,"Open File", ".", "wav (*.wav)")); + if(ui.txt_SoundFile4->text().isEmpty()){ + ui.checkBoxSound_4->setChecked(false); + ui.checkBoxSound_4->setEnabled(false); + } + else + ui.checkBoxSound_4->setEnabled(true); +} +void SoundPage::on_cmd_openFile5() +{ + ui.txt_SoundFile5->setText(QFileDialog::getOpenFileName(this,"Open File", ".", "wav (*.wav)")); + if(ui.txt_SoundFile5->text().isEmpty()){ + ui.checkBoxSound_5->setChecked(false); + ui.checkBoxSound_5->setEnabled(false); + } + else + ui.checkBoxSound_5->setEnabled(true); +} +void SoundPage::on_cmd_openFile6() +{ + ui.txt_SoundFile6->setText(QFileDialog::getOpenFileName(this,"Open File", ".", "wav (*.wav)")); + if(ui.txt_SoundFile6->text().isEmpty()){ + ui.checkBoxSound_6->setChecked(false); + ui.checkBoxSound_6->setEnabled(false); + } + else + ui.checkBoxSound_6->setEnabled(true); + +} diff --git a/retroshare-gui/src/gui/settings/SoundPage.h b/retroshare-gui/src/gui/settings/SoundPage.h new file mode 100644 index 000000000..14b222e39 --- /dev/null +++ b/retroshare-gui/src/gui/settings/SoundPage.h @@ -0,0 +1,64 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006 - 2009 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. + ****************************************************************/ + +#ifndef _SOUNDPAGE_H +#define _SOUNDPAGE_H + +#include + +#include + +#include "ui_SoundPage.h" + +class SoundPage : public QWidget +{ + Q_OBJECT + +public: + /** Default Constructor */ + SoundPage(QWidget * parent = 0, Qt::WFlags flags = 0); + /** Default Destructor */ + ~SoundPage() {} + + /** Saves the changes on this page */ + bool save(QString &errmsg); + /** Loads the settings for this page */ + void load(); + +private slots: + + void on_cmd_openFile(); + void on_cmd_openFile2(); + void on_cmd_openFile3(); + void on_cmd_openFile4(); + void on_cmd_openFile5(); + void on_cmd_openFile6(); + +private: + /** A RshareSettings object used for saving/loading settings */ + RshareSettings* _settings; + + /** Qt Designer generated object */ + Ui::SoundPage ui; +}; + +#endif + diff --git a/retroshare-gui/src/gui/settings/SoundPage.ui b/retroshare-gui/src/gui/settings/SoundPage.ui new file mode 100644 index 000000000..29e9d857a --- /dev/null +++ b/retroshare-gui/src/gui/settings/SoundPage.ui @@ -0,0 +1,814 @@ + + + SoundPage + + + + 0 + 0 + 468 + 407 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 192 + 192 + 192 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 104 + 104 + 104 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 104 + 104 + 104 + + + + + + + 255 + 255 + 255 + + + + + + + 104 + 104 + 104 + + + + + + + 240 + 240 + 240 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + Arial + 8 + 50 + false + false + false + false + + + + Qt::NoContextMenu + + + + + + Sound Events + + + + + 10 + 20 + 421 + 81 + + + + User + + + + false + + + + 10 + 20 + 80 + 23 + + + + go Online + + + + + false + + + + 10 + 50 + 80 + 23 + + + + go Offline + + + + + false + + + + 90 + 20 + 281 + 24 + + + + + + false + + + + 90 + 50 + 281 + 24 + + + + + + + 380 + 20 + 31 + 21 + + + + ... + + + + + + 380 + 50 + 31 + 21 + + + + ... + + + + + + + 10 + 100 + 421 + 61 + + + + FileSend + + + + false + + + + 90 + 20 + 281 + 24 + + + + + + + 380 + 20 + 31 + 21 + + + + ... + + + + + false + + + + 10 + 20 + 80 + 23 + + + + Finished + + + + + + + 10 + 160 + 421 + 91 + + + + FileRecive + + + + false + + + + 10 + 20 + 80 + 23 + + + + Incoming + + + + + false + + + + 90 + 20 + 281 + 24 + + + + + + + 380 + 20 + 31 + 21 + + + + ... + + + + + + 380 + 50 + 31 + 21 + + + + ... + + + + + false + + + + 10 + 50 + 80 + 23 + + + + Finished + + + + + false + + + + 90 + 50 + 281 + 24 + + + + + + + + 10 + 260 + 421 + 111 + + + + Chatmessage + + + + + 380 + 20 + 31 + 21 + + + + ... + + + + + false + + + + 10 + 20 + 80 + 23 + + + + New + + + + + false + + + + 90 + 20 + 281 + 24 + + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp new file mode 100644 index 000000000..d8ada2349 --- /dev/null +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -0,0 +1,186 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006 -2009 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 "GeneralPage.h" +#include "DirectoriesPage.h" +#include "ServerPage.h" +#include "NetworkPage.h" +#include "NotifyPage.h" +#include "CryptoPage.h" +#include "AppearancePage.h" +#include "FileAssociationsPage.h" +#include "SoundPage.h" + +#define IMAGE_GENERAL ":/images/kcmsystem24.png" + + +#include "rsettingswin.h" + +RSettingsWin::RSettingsWin(QWidget * parent, Qt::WFlags flags) + : QDialog(parent, flags) +{ + setupUi(this); + setAttribute(Qt::WA_QuitOnClose, false); + setModal(false); + + initStackedWidget(); + + connect(listWidget, SIGNAL(currentRowChanged(int)), + this, SLOT(setNewPage(int))); + + connect(okButton, SIGNAL(clicked( bool )), this, SLOT( saveChanges()) ); + + +} + +void +RSettingsWin::closeEvent (QCloseEvent * event) +{ + + QWidget::closeEvent(event); +} + +void +RSettingsWin::initStackedWidget() +{ + stackedWidget->setCurrentIndex(-1); + stackedWidget->removeWidget(stackedWidget->widget(0)); + + stackedWidget->addWidget(new GeneralPage(false)); + stackedWidget->addWidget(new NetworkPage()); + stackedWidget->addWidget(new ServerPage()); + stackedWidget->addWidget(new DirectoriesPage()); + stackedWidget->addWidget(new NotifyPage()); + stackedWidget->addWidget(new CryptoPage()); + stackedWidget->addWidget(new AppearancePage()); + stackedWidget->addWidget(new FileAssociationsPage() ); + stackedWidget->addWidget(new SoundPage() ); + + setNewPage(General); + +} + +void +RSettingsWin::setNewPage(int page) +{ + QString text; + + switch (page) + { + case General: + 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")); + break; + case Server: + text = tr("Server"); + pageicon->setPixmap(QPixmap(":/images/server_24x24.png")); + break; + case Notify: + text = tr("Notify"); + pageicon->setPixmap(QPixmap(":/images/status_unknown.png")); + break; + case Security: + text = tr("Security"); + pageicon->setPixmap(QPixmap(":/images/encrypted32.png")); + break; + case Appearance: + text = tr("Appearance"); + pageicon->setPixmap(QPixmap(":/images/looknfeel.png")); + break; + case Fileassociations: + text = tr("File Associations"); + pageicon->setPixmap(QPixmap(":/images/filetype-association.png")); + break; + case Sound: + text = tr("Sound"); + pageicon->setPixmap(QPixmap(":/images/sound.png")); + break; + default: + text = tr("UnknownPage");// impossible case + } + + pageName->setText(text); //tr("%1").arg( + stackedWidget->setCurrentIndex(page); + listWidget->setCurrentRow(page); +} + +/** Saves changes made to settings. */ +void +RSettingsWin::saveChanges() +{ + 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(page))) {saveOk = gp->save(errmsg);} + else + if (NULL !=(np = dynamic_cast(page))) {saveOk = np->save(errmsg);} + else + if (NULL !=(sp = dynamic_cast(page))) {saveOk = sp->save(errmsg);} + else + if (NULL !=(cp = dynamic_cast(page))) {saveOk = cp->save(errmsg);} + else + if (NULL !=(nfp = dynamic_cast(page))) {saveOk = nfp->save(errmsg);} + else if (NULL !=(ap = dynamic_cast(page))) {saveOk = ap->save(errmsg);} + + + 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); + + /* Don't process the rest of the pages */ + return; + } + } + + + /* call to RsIface save function.... */ + //rsicontrol -> ConfigSave(); + + QDialog::close(); +} + + + + diff --git a/retroshare-gui/src/gui/settings/rsettingswin.h b/retroshare-gui/src/gui/settings/rsettingswin.h new file mode 100755 index 000000000..3ce20d262 --- /dev/null +++ b/retroshare-gui/src/gui/settings/rsettingswin.h @@ -0,0 +1,52 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006 - 2009 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. + ****************************************************************/ + +#ifndef RSETTINGSWIN_HPP_ +# define RSETTINGSWIN_HPP_ + +# include +# include "ui_settings.h" + + +class RSettingsWin: public QDialog, private Ui::Settings +{ + Q_OBJECT + + public: + enum PageType { General = 0, Network, Server, + Directories, Notify, Security, Appearance, Fileassociations, Sound }; + + RSettingsWin(QWidget * parent = 0, Qt::WFlags flags = 0); + ~RSettingsWin() {} + + public slots: + //! Go to a specific part of the control panel. + void setNewPage(int page); + + private: + void closeEvent (QCloseEvent * event); + void initStackedWidget(); + + /** Called when user clicks "Save Settings" */ + void saveChanges(); +}; + +#endif // !RSETTINGSWIN_HPP_ diff --git a/retroshare-gui/src/gui/settings/settings.ui b/retroshare-gui/src/gui/settings/settings.ui new file mode 100755 index 000000000..c14331320 --- /dev/null +++ b/retroshare-gui/src/gui/settings/settings.ui @@ -0,0 +1,331 @@ + + + Settings + + + + 0 + 0 + 458 + 366 + + + + Settings + + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + false + + + + 24 + 24 + + + + Qt::ElideMiddle + + + QListView::Static + + + QListView::TopToBottom + + + false + + + QListView::Fixed + + + QListView::SinglePass + + + + 100 + 24 + + + + QListView::ListMode + + + 0 + + + true + + + -1 + + + + General + + + + :/images/kcmsystem24.png:/images/kcmsystem24.png + + + + + Network + + + + :/images/network.png:/images/network.png + + + + + Server + + + + :/images/server_24x24.png:/images/server_24x24.png + + + + + Directories + + + + :/images/folder_doments.png:/images/folder_doments.png + + + + + Notify + + + + :/images/status_unknown.png:/images/status_unknown.png + + + + + Security + + + + :/images/encrypted32.png:/images/encrypted32.png + + + + + Appearance + + + + :/images/looknfeel.png:/images/looknfeel.png + + + + + File Associations + + + + :/images/filetype-association.png:/images/filetype-association.png + + + + + Sound + + + + :/images/sound.png:/images/sound.png + + + + + + + + + + + 32 + 32 + + + + + + + + + + + + 0 + 0 + + + + + Sans Serif + 11 + 75 + false + true + false + false + + + + + + + + + + + Qt::Horizontal + + + + + + + + + 0 + + + + + + + + Qt::Horizontal + + + + + + + 6 + + + 0 + + + + + Qt::Horizontal + + + + 312 + 31 + + + + + + + + + 0 + 22 + + + + Cancel + + + + + + + false + + + + 0 + 22 + + + + Apply + + + + + + + + 0 + 22 + + + + OK + + + + + + + + + + + + + okButton + clicked() + Settings + accept() + + + 278 + 253 + + + 96 + 254 + + + + + canceButton + clicked() + Settings + reject() + + + 369 + 253 + + + 179 + 282 + + + + +