reworked settings

now there is only one global object for loading and saving settings

RshareSettings *Settings;

the class RSettings can be used too, but it is not prefered, because the default settings has no affect

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2964 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-05-20 21:53:27 +00:00
parent e68e6b54ef
commit 6baf56285b
39 changed files with 336 additions and 390 deletions

View File

@ -364,15 +364,13 @@ TBoard::TBoard(QWidget *parent) {
score = 0; score = 0;
level = 0; level = 0;
RshareSettings settings; maxScore = Settings->value("/about/maxsc").toInt();
maxScore = settings.value("/about/maxsc").toInt();
} }
TBoard::~TBoard() { TBoard::~TBoard() {
RshareSettings settings; int oldMax = Settings->value("/about/maxsc").toInt();
int oldMax = settings.value("/about/maxsc").toInt();
int newMax = qMax(maxScore, score); int newMax = qMax(maxScore, score);
if (oldMax < newMax) { if (oldMax < newMax) {
settings.setValue("/about/maxsc", newMax); Settings->setValue("/about/maxsc", newMax);
} }
} }

View File

@ -31,8 +31,6 @@
#include "rsiface/rsmsgs.h" #include "rsiface/rsmsgs.h"
#include "rsiface/rsforums.h" #include "rsiface/rsforums.h"
#include "settings/rsettings.h"
#include <sstream> #include <sstream>
#include <algorithm> #include <algorithm>
@ -109,6 +107,8 @@ ForumsDialog::ForumsDialog(QWidget *parent)
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
m_bProcessSettings = false;
connect( ui.forumTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( forumListCustomPopupMenu( QPoint ) ) ); connect( ui.forumTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( forumListCustomPopupMenu( QPoint ) ) );
connect( ui.threadTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( threadListCustomPopupMenu( QPoint ) ) ); connect( ui.threadTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( threadListCustomPopupMenu( QPoint ) ) );
@ -219,41 +219,46 @@ ForumsDialog::~ForumsDialog()
void ForumsDialog::processSettings(bool bLoad) void ForumsDialog::processSettings(bool bLoad)
{ {
m_bProcessSettings = true;
QHeaderView *pHeader = ui.threadTreeWidget->header () ; QHeaderView *pHeader = ui.threadTreeWidget->header () ;
RSettings settings(QString("ForumsDialog")); Settings->beginGroup(QString("ForumsDialog"));
if (bLoad) { if (bLoad) {
// load settings // load settings
// expandFiles // expandFiles
bool bValue = settings.value("expandButton", true).toBool(); bool bValue = Settings->value("expandButton", true).toBool();
ui.expandButton->setChecked(bValue); ui.expandButton->setChecked(bValue);
togglethreadview_internal(); togglethreadview_internal();
// filterColumn // filterColumn
int nValue = FilterColumnToComboBox(settings.value("filterColumn", true).toInt()); int nValue = FilterColumnToComboBox(Settings->value("filterColumn", true).toInt());
ui.filterColumnComboBox->setCurrentIndex(nValue); ui.filterColumnComboBox->setCurrentIndex(nValue);
// index of viewBox // index of viewBox
ui.viewBox->setCurrentIndex(settings.value("viewBox", VIEW_THREADED).toInt()); ui.viewBox->setCurrentIndex(Settings->value("viewBox", VIEW_THREADED).toInt());
// state of thread tree // state of thread tree
pHeader->restoreState(settings.value("ThreadTree").toByteArray()); pHeader->restoreState(Settings->value("ThreadTree").toByteArray());
// state of splitter // state of splitter
ui.splitter->restoreState(settings.value("Splitter").toByteArray()); ui.splitter->restoreState(Settings->value("Splitter").toByteArray());
ui.threadSplitter->restoreState(settings.value("threadSplitter").toByteArray()); ui.threadSplitter->restoreState(Settings->value("threadSplitter").toByteArray());
} else { } else {
// save settings // save settings
// state of thread tree // state of thread tree
settings.setValue("ThreadTree", pHeader->saveState()); Settings->setValue("ThreadTree", pHeader->saveState());
// state of splitter // state of splitter
settings.setValue("Splitter", ui.splitter->saveState()); Settings->setValue("Splitter", ui.splitter->saveState());
settings.setValue("threadSplitter", ui.threadSplitter->saveState()); Settings->setValue("threadSplitter", ui.threadSplitter->saveState());
} }
Settings->endGroup();
m_bProcessSettings = false;
} }
void ForumsDialog::forumListCustomPopupMenu( QPoint point ) void ForumsDialog::forumListCustomPopupMenu( QPoint point )
@ -344,8 +349,7 @@ void ForumsDialog::threadListCustomPopupMenu( QPoint point )
void ForumsDialog::togglethreadview() void ForumsDialog::togglethreadview()
{ {
// save state of button // save state of button
RSettings settings(QString("ForumsDialog")); Settings->setValueToGroup("ForumsDialog", "expandButton", ui.expandButton->isChecked());
settings.setValue("expandButton", ui.expandButton->isChecked());
togglethreadview_internal(); togglethreadview_internal();
} }
@ -1436,15 +1440,22 @@ void ForumsDialog::clearFilter()
void ForumsDialog::changedViewBox() void ForumsDialog::changedViewBox()
{ {
if (m_bProcessSettings) {
return;
}
// save index // save index
RSettings settings(QString("ForumsDialog")); Settings->setValueToGroup("ForumsDialog", "viewBox", ui.viewBox->currentIndex());
settings.setValue("viewBox", ui.viewBox->currentIndex());
insertThreads(); insertThreads();
} }
void ForumsDialog::filterColumnChanged() void ForumsDialog::filterColumnChanged()
{ {
if (m_bProcessSettings) {
return;
}
int nFilterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex()); int nFilterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex());
if (nFilterColumn == COLUMN_CONTENT) { if (nFilterColumn == COLUMN_CONTENT) {
// need content ... refill // need content ... refill
@ -1454,8 +1465,7 @@ void ForumsDialog::filterColumnChanged()
} }
// save index // save index
RSettings settings(QString("ForumsDialog")); Settings->setValueToGroup("ForumsDialog", "filterColumn", nFilterColumn);
settings.setValue("filterColumn", nFilterColumn);
} }
void ForumsDialog::FilterItems() void ForumsDialog::FilterItems()

View File

@ -95,6 +95,8 @@ private:
void FilterItems(); void FilterItems();
bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern, int nFilterColumn); bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern, int nFilterColumn);
bool m_bProcessSettings;
QTreeWidgetItem *YourForums; QTreeWidgetItem *YourForums;
QTreeWidgetItem *SubscribedForums; QTreeWidgetItem *SubscribedForums;
QTreeWidgetItem *PopularForums; QTreeWidgetItem *PopularForums;

View File

@ -23,7 +23,6 @@
#include <rsiface/rsinit.h> #include <rsiface/rsinit.h>
#include "GenCertDialog.h" #include "GenCertDialog.h"
#include "InfoDialog.h" #include "InfoDialog.h"
#include "gui/settings/rsharesettings.h"
#include <QAbstractEventDispatcher> #include <QAbstractEventDispatcher>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>

View File

@ -122,11 +122,9 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
/* Invoke the Qt Designer generated QObject setup routine */ /* Invoke the Qt Designer generated QObject setup routine */
ui.setupUi(this); ui.setupUi(this);
RshareSettings settings; if (Settings->value(QString::fromUtf8("FirstRun"), true).toBool())
if (settings.value(QString::fromUtf8("FirstRun"), true).toBool())
{ {
settings.setValue(QString::fromUtf8("FirstRun"), false); Settings->setValue(QString::fromUtf8("FirstRun"), false);
QuickStartWizard *qstartWizard = new QuickStartWizard(this); QuickStartWizard *qstartWizard = new QuickStartWizard(this);
qstartWizard->exec(); qstartWizard->exec();
} }
@ -573,9 +571,7 @@ void MainWindow::createActions()
*/ */
void MainWindow::doQuit() void MainWindow::doQuit()
{ {
RshareSettings settings; if(!Settings->value(QString::fromUtf8("doQuit"), false).toBool())
if(!settings.value(QString::fromUtf8("doQuit"), false).toBool())
{ {
QString queryWrn; QString queryWrn;
queryWrn.clear(); queryWrn.clear();
@ -603,9 +599,7 @@ void MainWindow::closeEvent(QCloseEvent *e)
{ {
static bool firstTime = true; static bool firstTime = true;
RshareSettings settings; if(!Settings->value(QString::fromUtf8("ClosetoTray"), false).toBool())
if(!settings.value(QString::fromUtf8("ClosetoTray"), false).toBool())
{ {
if (trayIcon->isVisible()) { if (trayIcon->isVisible()) {
if (firstTime) if (firstTime)

View File

@ -30,7 +30,6 @@
#include "rsiface/rspeers.h" #include "rsiface/rspeers.h"
#include "rsiface/rsfiles.h" #include "rsiface/rsfiles.h"
#include "settings/rsettings.h"
#include <QtGui> #include <QtGui>
/* Images for context menu icons */ /* Images for context menu icons */
@ -94,6 +93,8 @@ MessagesDialog::MessagesDialog(QWidget *parent)
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
m_bProcessSettings = false;
connect( ui.messagestreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messageslistWidgetCostumPopupMenu( QPoint ) ) ); connect( ui.messagestreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messageslistWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.msgList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgfilelistWidgetCostumPopupMenu( QPoint ) ) ); connect( ui.msgList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgfilelistWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.messagestreeView, SIGNAL(clicked ( const QModelIndex &) ) , this, SLOT( clicked( const QModelIndex & ) ) ); connect( ui.messagestreeView, SIGNAL(clicked ( const QModelIndex &) ) , this, SLOT( clicked( const QModelIndex & ) ) );
@ -245,37 +246,45 @@ MessagesDialog::~MessagesDialog()
void MessagesDialog::processSettings(bool bLoad) void MessagesDialog::processSettings(bool bLoad)
{ {
m_bProcessSettings = true;
QHeaderView *msgwheader = ui.messagestreeView->header () ; QHeaderView *msgwheader = ui.messagestreeView->header () ;
RSettings settings(QString("MessageDialog")); Settings->beginGroup(QString("MessageDialog"));
if (bLoad) { if (bLoad) {
// load settings // load settings
// expandFiles // expandFiles
bool bValue = settings.value("expandFiles", true).toBool(); bool bValue = Settings->value("expandFiles", true).toBool();
ui.expandFilesButton->setChecked(bValue); ui.expandFilesButton->setChecked(bValue);
ui.msgList->setVisible(bValue); ui.msgList->setVisible(bValue);
togglefileview_internal(); togglefileview_internal();
// filterColumn // filterColumn
int nValue = FilterColumnToComboBox(settings.value("filterColumn", true).toInt()); int nValue = FilterColumnToComboBox(Settings->value("filterColumn", true).toInt());
ui.filterColumnComboBox->setCurrentIndex(nValue); ui.filterColumnComboBox->setCurrentIndex(nValue);
// state of message tree // state of message tree
msgwheader->restoreState(settings.value("MessageTree").toByteArray()); msgwheader->restoreState(Settings->value("MessageTree").toByteArray());
// state of splitter // state of splitter
ui.msgSplitter_2->restoreState(settings.value("Splitter2").toByteArray()); ui.msgSplitter->restoreState(Settings->value("Splitter").toByteArray());
ui.msgSplitter_2->restoreState(Settings->value("Splitter2").toByteArray());
} else { } else {
// save settings // save settings
// state of message tree // state of message tree
settings.setValue("MessageTree", msgwheader->saveState()); Settings->setValue("MessageTree", msgwheader->saveState());
// state of splitter // state of splitter
settings.setValue("Splitter2", ui.msgSplitter_2->saveState()); Settings->setValue("Splitter", ui.msgSplitter->saveState());
Settings->setValue("Splitter2", ui.msgSplitter_2->saveState());
} }
Settings->endGroup();
m_bProcessSettings = false;
} }
// replaced by shortcut // replaced by shortcut
@ -582,8 +591,7 @@ void MessagesDialog::togglefileview_internal()
void MessagesDialog::togglefileview() void MessagesDialog::togglefileview()
{ {
// save state of files view // save state of files view
RSettings settings(QString("MessageDialog")); Settings->setValueToGroup("MessageDialog", "expandFiles", ui.expandFilesButton->isChecked());
settings.setValue("expandFiles", ui.expandFilesButton->isChecked());
togglefileview_internal(); togglefileview_internal();
} }
@ -1341,15 +1349,17 @@ void MessagesDialog::buttonsicononly()
ui.printbutton->setToolButtonStyle(Qt::ToolButtonIconOnly); ui.printbutton->setToolButtonStyle(Qt::ToolButtonIconOnly);
ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonIconOnly); ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
RSettings settings(QString("MessageDialog")); Settings->beginGroup(QString("MessageDialog"));
settings.setValue("ToolButon_Stlye1",ui.newmessageButton->toolButtonStyle()); Settings->setValue("ToolButon_Stlye1",ui.newmessageButton->toolButtonStyle());
settings.setValue("ToolButon_Stlye2",ui.removemessageButton->toolButtonStyle()); Settings->setValue("ToolButon_Stlye2",ui.removemessageButton->toolButtonStyle());
settings.setValue("ToolButon_Stlye3",ui.replymessageButton->toolButtonStyle()); Settings->setValue("ToolButon_Stlye3",ui.replymessageButton->toolButtonStyle());
settings.setValue("ToolButon_Stlye4",ui.replyallmessageButton->toolButtonStyle()); Settings->setValue("ToolButon_Stlye4",ui.replyallmessageButton->toolButtonStyle());
settings.setValue("ToolButon_Stlye5",ui.forwardmessageButton->toolButtonStyle()); Settings->setValue("ToolButon_Stlye5",ui.forwardmessageButton->toolButtonStyle());
settings.setValue("ToolButon_Stlye6",ui.printbutton->toolButtonStyle()); Settings->setValue("ToolButon_Stlye6",ui.printbutton->toolButtonStyle());
settings.setValue("ToolButon_Stlye7",ui.viewtoolButton->toolButtonStyle()); Settings->setValue("ToolButon_Stlye7",ui.viewtoolButton->toolButtonStyle());
Settings->endGroup();
} }
void MessagesDialog::buttonstextbesideicon() void MessagesDialog::buttonstextbesideicon()
@ -1362,23 +1372,21 @@ void MessagesDialog::buttonstextbesideicon()
ui.printbutton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); ui.printbutton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
RSettings settings(QString("MessageDialog")); Settings->beginGroup(QString("MessageDialog"));
settings.setValue("ToolButon_Stlye1",ui.newmessageButton->toolButtonStyle()); Settings->setValue("ToolButon_Stlye1",ui.newmessageButton->toolButtonStyle());
settings.setValue("ToolButon_Stlye2",ui.removemessageButton->toolButtonStyle()); Settings->setValue("ToolButon_Stlye2",ui.removemessageButton->toolButtonStyle());
settings.setValue("ToolButon_Stlye3",ui.replymessageButton->toolButtonStyle()); Settings->setValue("ToolButon_Stlye3",ui.replymessageButton->toolButtonStyle());
settings.setValue("ToolButon_Stlye4",ui.replyallmessageButton->toolButtonStyle()); Settings->setValue("ToolButon_Stlye4",ui.replyallmessageButton->toolButtonStyle());
settings.setValue("ToolButon_Stlye5",ui.forwardmessageButton->toolButtonStyle()); Settings->setValue("ToolButon_Stlye5",ui.forwardmessageButton->toolButtonStyle());
settings.setValue("ToolButon_Stlye6",ui.printbutton->toolButtonStyle()); Settings->setValue("ToolButon_Stlye6",ui.printbutton->toolButtonStyle());
settings.setValue("ToolButon_Stlye7",ui.viewtoolButton->toolButtonStyle()); Settings->setValue("ToolButon_Stlye7",ui.viewtoolButton->toolButtonStyle());
Settings->endGroup();
} }
void MessagesDialog::buttonstextundericon() void MessagesDialog::buttonstextundericon()
{ {
RshareSettings settings;
settings.beginGroup("MessageDialog");
ui.newmessageButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); ui.newmessageButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui.removemessageButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); ui.removemessageButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui.replymessageButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); ui.replymessageButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
@ -1387,24 +1395,24 @@ void MessagesDialog::buttonstextundericon()
ui.printbutton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); ui.printbutton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
settings.setValue("ToolButon_Stlye1",ui.newmessageButton->toolButtonStyle()); Settings->beginGroup("MessageDialog");
settings.setValue("ToolButon_Stlye2",ui.removemessageButton->toolButtonStyle());
settings.setValue("ToolButon_Stlye3",ui.replymessageButton->toolButtonStyle());
settings.setValue("ToolButon_Stlye4",ui.replyallmessageButton->toolButtonStyle());
settings.setValue("ToolButon_Stlye5",ui.forwardmessageButton->toolButtonStyle());
settings.setValue("ToolButon_Stlye6",ui.printbutton->toolButtonStyle());
settings.setValue("ToolButon_Stlye7",ui.viewtoolButton->toolButtonStyle());
settings.endGroup(); Settings->setValue("ToolButon_Stlye1",ui.newmessageButton->toolButtonStyle());
Settings->setValue("ToolButon_Stlye2",ui.removemessageButton->toolButtonStyle());
Settings->setValue("ToolButon_Stlye3",ui.replymessageButton->toolButtonStyle());
Settings->setValue("ToolButon_Stlye4",ui.replyallmessageButton->toolButtonStyle());
Settings->setValue("ToolButon_Stlye5",ui.forwardmessageButton->toolButtonStyle());
Settings->setValue("ToolButon_Stlye6",ui.printbutton->toolButtonStyle());
Settings->setValue("ToolButon_Stlye7",ui.viewtoolButton->toolButtonStyle());
Settings->endGroup();
} }
void MessagesDialog::loadToolButtonsettings() void MessagesDialog::loadToolButtonsettings()
{ {
RshareSettings settings; Settings->beginGroup("MessageDialog");
settings.beginGroup("MessageDialog"); if(Settings->value("ToolButon_Stlye1","0").toInt() == 0)
if(settings.value("ToolButon_Stlye1","0").toInt() == 0)
{ {
qDebug() << "ToolButon IconOnly"; qDebug() << "ToolButon IconOnly";
ui.newmessageButton->setToolButtonStyle(Qt::ToolButtonIconOnly); ui.newmessageButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
@ -1416,7 +1424,7 @@ void MessagesDialog::loadToolButtonsettings()
ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonIconOnly); ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
} }
else if (settings.value("ToolButon_Stlye1","2").toInt() ==2) else if (Settings->value("ToolButon_Stlye1","2").toInt() ==2)
{ {
qDebug() << "ToolButon TextBesideIcon"; qDebug() << "ToolButon TextBesideIcon";
ui.newmessageButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); ui.newmessageButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
@ -1428,7 +1436,7 @@ void MessagesDialog::loadToolButtonsettings()
ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
} }
else if(settings.value("ToolButon_Stlye1","3").toInt() ==3) else if(Settings->value("ToolButon_Stlye1","3").toInt() ==3)
{ {
qDebug() << "ToolButton TextUnderIcon"; qDebug() << "ToolButton TextUnderIcon";
ui.newmessageButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); ui.newmessageButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
@ -1440,7 +1448,7 @@ void MessagesDialog::loadToolButtonsettings()
ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
} }
settings.endGroup(); Settings->endGroup();
} }
void MessagesDialog::filterRegExpChanged() void MessagesDialog::filterRegExpChanged()
@ -1462,6 +1470,10 @@ void MessagesDialog::filterRegExpChanged()
void MessagesDialog::filterColumnChanged() void MessagesDialog::filterColumnChanged()
{ {
if (m_bProcessSettings) {
return;
}
int nFilterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex()); int nFilterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex());
if (nFilterColumn == COLUMN_CONTENT) { if (nFilterColumn == COLUMN_CONTENT) {
// need content ... refill // need content ... refill
@ -1470,8 +1482,7 @@ void MessagesDialog::filterColumnChanged()
proxyModel->setFilterKeyColumn(nFilterColumn); proxyModel->setFilterKeyColumn(nFilterColumn);
// save index // save index
RSettings settings(QString("MessageDialog")); Settings->setValueToGroup("MessageDialog", "filterColumn", nFilterColumn);
settings.setValue("filterColumn", nFilterColumn);
} }
void MessagesDialog::updateMessageSummaryList() void MessagesDialog::updateMessageSummaryList()

View File

@ -97,7 +97,7 @@ private slots:
void clearFilter(); void clearFilter();
private: private:
class QStandardItemModel *MessagesModel; class QStandardItemModel *MessagesModel;
QSortFilterProxyModel *proxyModel; QSortFilterProxyModel *proxyModel;
bool getCurrentMsg(std::string &cid, std::string &mid); bool getCurrentMsg(std::string &cid, std::string &mid);
@ -112,6 +112,8 @@ private:
void processSettings(bool bLoad); void processSettings(bool bLoad);
bool m_bProcessSettings;
std::string mCurrCertId; std::string mCurrCertId;
std::string mCurrMsgId; std::string mCurrMsgId;

View File

@ -804,8 +804,7 @@ void MessengerWindow::show()
void MessengerWindow::closeEvent (QCloseEvent * event) void MessengerWindow::closeEvent (QCloseEvent * event)
{ {
//RshareSettings config; //Settings->saveWidgetInformation(this);
//config.saveWidgetInformation(this);
hide(); hide();
event->ignore(); event->ignore();
@ -913,12 +912,7 @@ void MessengerWindow::loadmystatusmessage()
/** Save own status message */ /** Save own status message */
void MessengerWindow::savestatusmessage() void MessengerWindow::savestatusmessage()
{ {
RshareSettings settings; Settings->setValueToGroup("Profile", "StatusMessage",ui.messagelineEdit->text());
settings.beginGroup("Profile");
settings.setValue("StatusMessage",ui.messagelineEdit->text());
settings.endGroup();
rsMsgs->setCustomStateString(ui.messagelineEdit->text().toStdString()); rsMsgs->setCustomStateString(ui.messagelineEdit->text().toStdString());
} }

View File

@ -808,46 +808,31 @@ void NetworkDialog::updateNetworkStatus()
void NetworkDialog::on_actionTabsnorth_activated() void NetworkDialog::on_actionTabsnorth_activated()
{ {
RshareSettings settings;
settings.beginGroup("NetworkDialog");
ui.networkTab->setTabPosition(QTabWidget::North); ui.networkTab->setTabPosition(QTabWidget::North);
settings.setValue("TabWidget_Position",ui.networkTab->tabPosition()); Settings->setValueToGroup("NetworkDialog", "TabWidget_Position",ui.networkTab->tabPosition());
settings.endGroup();
} }
void NetworkDialog::on_actionTabssouth_activated() void NetworkDialog::on_actionTabssouth_activated()
{ {
RshareSettings settings;
settings.beginGroup("NetworkDialog");
ui.networkTab->setTabPosition(QTabWidget::South); ui.networkTab->setTabPosition(QTabWidget::South);
settings.setValue("TabWidget_Position",ui.networkTab->tabPosition()); Settings->setValueToGroup("NetworkDialog", "TabWidget_Position",ui.networkTab->tabPosition());
settings.endGroup();
} }
void NetworkDialog::on_actionTabswest_activated() void NetworkDialog::on_actionTabswest_activated()
{ {
RshareSettings settings;
settings.beginGroup("NetworkDialog");
ui.networkTab->setTabPosition(QTabWidget::West); ui.networkTab->setTabPosition(QTabWidget::West);
settings.setValue("TabWidget_Position",ui.networkTab->tabPosition()); Settings->setValueToGroup("NetworkDialog", "TabWidget_Position",ui.networkTab->tabPosition());
settings.endGroup();
} }
void NetworkDialog::on_actionTabsright_activated() void NetworkDialog::on_actionTabsright_activated()
{ {
RshareSettings settings;
settings.beginGroup("NetworkDialog");
ui.networkTab->setTabPosition(QTabWidget::East); ui.networkTab->setTabPosition(QTabWidget::East);
settings.setValue("TabWidget_Position",ui.networkTab->tabPosition()); Settings->setValueToGroup("NetworkDialog", "TabWidget_Position",ui.networkTab->tabPosition());
settings.endGroup();
} }
void NetworkDialog::on_actionTabsTriangular_activated() void NetworkDialog::on_actionTabsTriangular_activated()
@ -864,29 +849,28 @@ void NetworkDialog::on_actionTabsRounded_activated()
void NetworkDialog::loadtabsettings() void NetworkDialog::loadtabsettings()
{ {
RshareSettings settings; Settings->beginGroup("NetworkDialog");
settings.beginGroup("NetworkDialog");
if(settings.value("TabWidget_Position","0").toInt() == 0) if(Settings->value("TabWidget_Position","0").toInt() == 0)
{ {
qDebug() << "Tab North"; qDebug() << "Tab North";
ui.networkTab->setTabPosition(QTabWidget::North); ui.networkTab->setTabPosition(QTabWidget::North);
} }
else if (settings.value("TabWidget_Position","1").toInt() == 1) else if (Settings->value("TabWidget_Position","1").toInt() == 1)
{ {
qDebug() << "Tab South"; qDebug() << "Tab South";
ui.networkTab->setTabPosition(QTabWidget::South); ui.networkTab->setTabPosition(QTabWidget::South);
} }
else if (settings.value("TabWidget_Position","2").toInt() ==2) else if (Settings->value("TabWidget_Position","2").toInt() ==2)
{ {
qDebug() << "Tab West"; qDebug() << "Tab West";
ui.networkTab->setTabPosition(QTabWidget::West); ui.networkTab->setTabPosition(QTabWidget::West);
} }
else if(settings.value("TabWidget_Position","3").toInt() ==3) else if(Settings->value("TabWidget_Position","3").toInt() ==3)
{ {
qDebug() << "Tab East"; qDebug() << "Tab East";
ui.networkTab->setTabPosition(QTabWidget::East); ui.networkTab->setTabPosition(QTabWidget::East);
} }
settings.endGroup(); Settings->endGroup();
} }

View File

@ -74,9 +74,7 @@ void NewsFeed::updateFeed()
if (!rsNotify) if (!rsNotify)
return; return;
/** A RshareSettings object used for saving/loading settings */ uint flags = Settings->getNewsFeedFlags();
RshareSettings settings;
uint flags = settings.getNewsFeedFlags();
/* check for new messages */ /* check for new messages */
RsFeedItem fi; RsFeedItem fi;

View File

@ -149,20 +149,20 @@ PeersDialog::PeersDialog(QWidget *parent)
pxm.fill(_currentColor); pxm.fill(_currentColor);
ui.colorChatButton->setIcon(pxm); ui.colorChatButton->setIcon(pxm);
RSettings settings(QString("Chat")); Settings->beginGroup(QString("Chat"));
mCurrentFont.fromString(Settings->value(QString::fromUtf8("ChatScreenFont")).toString());
mCurrentFont.fromString(settings.value(QString::fromUtf8("ChatScreenFont")).toString());
ui.lineEdit->setFont(mCurrentFont); ui.lineEdit->setFont(mCurrentFont);
setChatInfo(tr("Welcome to RetroShare's group chat."), QString::fromUtf8("blue")); setChatInfo(tr("Welcome to RetroShare's group chat."), QString::fromUtf8("blue"));
if (settings.value(QString::fromUtf8("GroupChat_History"), true).toBool()) if (Settings->value(QString::fromUtf8("GroupChat_History"), true).toBool())
{ {
QStringList him; QStringList him;
historyKeeper.getMessages(him, "", "THIS", 8); historyKeeper.getMessages(him, "", "THIS", 8);
foreach(QString mess, him) foreach(QString mess, him)
ui.msgText->append(mess); ui.msgText->append(mess);
} }
Settings->endGroup();
//setChatInfo(mess, "green"); //setChatInfo(mess, "green");
@ -956,9 +956,7 @@ void PeersDialog::insertChat()
QTextEdit *msgWidget = ui.msgText; QTextEdit *msgWidget = ui.msgText;
std::list<ChatInfo>::iterator it; std::list<ChatInfo>::iterator it;
/** A RshareSettings object used for saving/loading settings */ uint chatflags = Settings->getChatFlags();
RshareSettings settings;
uint chatflags = settings.getChatFlags();
/* add in lines at the bottom */ /* add in lines at the bottom */
for(it = newchat.begin(); it != newchat.end(); it++) for(it = newchat.begin(); it != newchat.end(); it++)
@ -1015,10 +1013,10 @@ void PeersDialog::insertChat()
RsChat::embedHtml(doc, body, defEmbedAhref); RsChat::embedHtml(doc, body, defEmbedAhref);
// embed smileys // embed smileys
settings.beginGroup("Chat"); Settings->beginGroup("Chat");
if (settings.value(QString::fromUtf8("Emoteicons_GroupChat"), true).toBool()) if (Settings->value(QString::fromUtf8("Emoteicons_GroupChat"), true).toBool())
RsChat::embedHtml(doc, body, defEmbedImg); RsChat::embedHtml(doc, body, defEmbedImg);
settings.endGroup(); Settings->endGroup();
msgContents = doc.toString(-1); // -1 removes any annoying carriage return misinterpreted by QTextEdit msgContents = doc.toString(-1); // -1 removes any annoying carriage return misinterpreted by QTextEdit
extraTxt += msgContents; extraTxt += msgContents;
@ -1287,10 +1285,9 @@ void PeersDialog::setFont()
mCurrentFont.setItalic(ui.textitalicChatButton->isChecked()); mCurrentFont.setItalic(ui.textitalicChatButton->isChecked());
ui.lineEdit->setFont(mCurrentFont); ui.lineEdit->setFont(mCurrentFont);
ui.lineEdit->setTextColor(_currentColor); ui.lineEdit->setTextColor(_currentColor);
RshareSettings settings; Settings->beginGroup("Chat");
settings.beginGroup("Chat"); Settings->setValue(QString::fromUtf8("ChatScreenFont"), mCurrentFont.toString());
settings.setValue(QString::fromUtf8("ChatScreenFont"), mCurrentFont.toString()); Settings->endGroup();
settings.endGroup();
ui.lineEdit->setFocus(); ui.lineEdit->setFocus();
@ -1848,15 +1845,14 @@ void PeersDialog::setCurrentFileName(const QString &fileName)
////play sound when recv a message ////play sound when recv a message
void PeersDialog::playsound(){ void PeersDialog::playsound(){
RshareSettings settings; Settings->beginGroup("Sound");
settings.beginGroup("Sound"); Settings->beginGroup("SoundFilePath");
settings.beginGroup("SoundFilePath"); QString OnlineSound = Settings->value("NewChatMessage","").toString();
QString OnlineSound= settings.value("NewChatMessage","").toString(); Settings->endGroup();
settings.endGroup(); Settings->beginGroup("Enable");
settings.beginGroup("Enable"); bool flag = Settings->value("NewChatMessage",false).toBool();
bool flag= settings.value("NewChatMessage",false).toBool(); Settings->endGroup();
settings.endGroup(); Settings->endGroup();
settings.endGroup();
if(!OnlineSound.isEmpty()&&flag) if(!OnlineSound.isEmpty()&&flag)
if(QSound::isAvailable()) if(QSound::isAvailable())
QSound::play(OnlineSound); QSound::play(OnlineSound);

View File

@ -170,12 +170,9 @@ void QuickStartWizard::on_pushButtonSystemBack_clicked()
void QuickStartWizard::on_pushButtonSystemFinish_clicked() void QuickStartWizard::on_pushButtonSystemFinish_clicked()
{ {
RshareSettings settings; Settings->setValue(QString::fromUtf8("StartMinimized"), startMinimized());
settings.setValue(QString::fromUtf8("StartMinimized"), startMinimized()); Settings->setValue(QString::fromUtf8("doQuit"), quitbox());
Settings->setRunRetroshareOnBoot(ui.checkBoxRunRetroshareAtSystemStartup->isChecked());
settings.setValue(QString::fromUtf8("doQuit"), quitbox());
settings.setRunRetroshareOnBoot(ui.checkBoxRunRetroshareAtSystemStartup->isChecked());
saveChanges(); saveChanges();
@ -356,14 +353,11 @@ bool QuickStartWizard::messageBoxOk(QString msg)
void void
QuickStartWizard::loadGeneral() QuickStartWizard::loadGeneral()
{ {
RshareSettings settings; ui.checkBoxRunRetroshareAtSystemStartup->setChecked(Settings->runRetroshareOnBoot());
ui.checkBoxRunRetroshareAtSystemStartup->setChecked(settings.runRetroshareOnBoot()); ui.checkBoxStartMinimized->setChecked(Settings->value(QString::fromUtf8("StartMinimized"), false).toBool());
ui.checkBoxQuit->setChecked(Settings->value(QString::fromUtf8("doQuit"), false).toBool());
ui.checkBoxStartMinimized->setChecked(settings.value(QString::fromUtf8("StartMinimized"), false).toBool()); //ui.checkBoxQuickWizard->setChecked(settings.value(QString::fromUtf8("FirstRun"), false).toBool());
ui.checkBoxQuit->setChecked(settings.value(QString::fromUtf8("doQuit"), false).toBool());
//ui.checkBoxQuickWizard->setChecked(settings.value(QString::fromUtf8("FirstRun"), false).toBool());
} }
bool QuickStartWizard::quitbox() const { bool QuickStartWizard::quitbox() const {

View File

@ -104,8 +104,6 @@ SearchDialog::SearchDialog(QWidget *parent)
initialiseFileTypeMappings(); initialiseFileTypeMappings();
} }
RshareSettings rsharesettings;
connect(ui.toggleAdvancedSearchBtn, SIGNAL(clicked()), this, SLOT(showAdvSearchDialog())); connect(ui.toggleAdvancedSearchBtn, SIGNAL(clicked()), this, SLOT(showAdvSearchDialog()));
connect( ui.searchResultWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( searchtableWidgetCostumPopupMenu( QPoint ) ) ); connect( ui.searchResultWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( searchtableWidgetCostumPopupMenu( QPoint ) ) );
@ -447,9 +445,8 @@ void SearchDialog::hideEvent(QHideEvent * event)
void SearchDialog::toggleAdvancedSearchDialog(bool toggled) void SearchDialog::toggleAdvancedSearchDialog(bool toggled)
{ {
// record the users preference for future reference // record the users preference for future reference
RshareSettings rsharesettings;
QString key (UI_PREF_ADVANCED_SEARCH); QString key (UI_PREF_ADVANCED_SEARCH);
rsharesettings.setValue(key, QVariant(toggled)); Settings->setValue(key, QVariant(toggled));
showAdvSearchDialog(toggled); showAdvSearchDialog(toggled);
} }

View File

@ -728,19 +728,16 @@ SharedFilesDialog::fileAssotiationAction(const QString fileName)
{ {
QAction* result = 0; QAction* result = 0;
RshareSettings* settings = new RshareSettings(); Settings->beginGroup("FileAssotiations");
//QSettings* settings= new QSettings(qApp->applicationDirPath()+"/sett.ini",
// QSettings::IniFormat);
settings->beginGroup("FileAssotiations");
QString key = AddFileAssociationDialog::cleanFileType(currentFile) ; QString key = AddFileAssociationDialog::cleanFileType(currentFile) ;
if ( settings->contains(key) ) if ( Settings->contains(key) )
{ {
result = new QAction(QIcon(IMAGE_PLAY), tr( "Open File" ), this ); result = new QAction(QIcon(IMAGE_PLAY), tr( "Open File" ), this );
connect( result , SIGNAL( triggered() ), connect( result , SIGNAL( triggered() ),
this, SLOT( runCommandForFile() ) ); this, SLOT( runCommandForFile() ) );
currentCommand = (settings->value( key )).toString(); currentCommand = (Settings->value( key )).toString();
} }
else else
{ {
@ -750,7 +747,7 @@ SharedFilesDialog::fileAssotiationAction(const QString fileName)
this, SLOT( tryToAddNewAssotiation() ) ); this, SLOT( tryToAddNewAssotiation() ) );
} }
delete settings; Settings->endGroup();
return result; return result;
} }
@ -783,15 +780,10 @@ SharedFilesDialog::tryToAddNewAssotiation()
if (ti==QDialog::Accepted) if (ti==QDialog::Accepted)
{ {
RshareSettings settings;
//QSettings settings( qApp->applicationDirPath()+"/sett.ini",
// QSettings::IniFormat);
settings.beginGroup("FileAssotiations");
QString currType = afad.resultFileType() ; QString currType = afad.resultFileType() ;
QString currCmd = afad.resultCommand() ; QString currCmd = afad.resultCommand() ;
settings.setValue(currType, currCmd); Settings->setValueToGroup("FileAssotiations", currType, currCmd);
} }
} }

View File

@ -78,26 +78,23 @@ void SoundManager::event_NewChatMessage()
void SoundManager::reInit() void SoundManager::reInit()
{ {
RshareSettings settings; Settings->beginGroup("Sound");
Settings->beginGroup("Enable");
enable_eventUser_go_Online = Settings->value("User_go_Online",false).toBool();
enable_eventUser_go_Offline = Settings->value("User_go_Offline",false).toBool();
enable_eventFileSend_Finished = Settings->value("FileSend_Finished",false).toBool();
enable_eventFileRecive_Incoming = Settings->value("FileRecive_Incoming",false).toBool();
enable_eventFileRecive_Finished = Settings->value("FileRecive_Finished",false).toBool();
enable_eventNewChatMessage = Settings->value("NewChatMessage",false).toBool();
Settings->endGroup();
settings.beginGroup("Sound"); Settings->beginGroup("SoundFilePath");
settings.beginGroup("Enable"); SoundFileUser_go_Online = Settings->value("User_go_Online","").toString();
enable_eventUser_go_Online = settings.value("User_go_Online",false).toBool(); SoundFileUser_go_Offline = Settings->value("User_go_Offline","").toString();
enable_eventUser_go_Offline = settings.value("User_go_Offline",false).toBool(); SoundFileFileSend_Finished = Settings->value("FileSend_Finished","").toString();
enable_eventFileSend_Finished = settings.value("FileSend_Finished",false).toBool(); SoundFileFileRecive_Incoming = Settings->value("FileRecive_Incoming","").toString();
enable_eventFileRecive_Incoming = settings.value("FileRecive_Incoming",false).toBool(); SoundFileFileRecive_Finished = Settings->value("FileRecive_Finished","").toString();
enable_eventFileRecive_Finished = settings.value("FileRecive_Finished",false).toBool(); SoundFileNewChatMessage = Settings->value("NewChatMessage","").toString();
enable_eventNewChatMessage = settings.value("NewChatMessage",false).toBool(); Settings->endGroup();
settings.endGroup(); Settings->endGroup();
settings.beginGroup("SoundFilePath");
SoundFileUser_go_Online = settings.value("User_go_Online","").toString();
SoundFileUser_go_Offline =settings.value("User_go_Offline","").toString();
SoundFileFileSend_Finished = settings.value("FileSend_Finished","").toString();
SoundFileFileRecive_Incoming = settings.value("FileRecive_Incoming","").toString();
SoundFileFileRecive_Finished = settings.value("FileRecive_Finished","").toString();
SoundFileNewChatMessage = settings.value("NewChatMessage","").toString();
settings.endGroup();
settings.endGroup();
} }

View File

@ -42,8 +42,7 @@ StartDialog::StartDialog(QWidget *parent, Qt::WFlags flags)
ui.setupUi(this); ui.setupUi(this);
/* Create Bandwidth Graph related QObjects */ /* Create Bandwidth Graph related QObjects */
RshareSettings settings; Settings->loadWidgetInformation(this);
settings.loadWidgetInformation(this);
_rsLogoBar = NULL; _rsLogoBar = NULL;
@ -109,8 +108,7 @@ void StartDialog::show()
void StartDialog::closeEvent (QCloseEvent * event) void StartDialog::closeEvent (QCloseEvent * event)
{ {
RshareSettings settings; Settings->saveWidgetInformation(this);
settings.saveWidgetInformation(this);
QWidget::closeEvent(event); QWidget::closeEvent(event);
} }

View File

@ -56,9 +56,7 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
/* Invoke Qt Designer generated QObject setup routine */ /* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this); ui.setupUi(this);
RshareSettings settings; Settings->loadWidgetInformation(this);
settings.loadWidgetInformation(this);
this->move(qrand()%100, qrand()%100); //avoid to stack multiple popup chat windows on the same position this->move(qrand()%100, qrand()%100); //avoid to stack multiple popup chat windows on the same position
@ -229,8 +227,7 @@ void PopupChatDialog::flash()
void PopupChatDialog::closeEvent (QCloseEvent * event) void PopupChatDialog::closeEvent (QCloseEvent * event)
{ {
RshareSettings settings; Settings->saveWidgetInformation(this);
settings.saveWidgetInformation(this);
hide(); hide();
event->ignore(); event->ignore();
@ -291,8 +288,7 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci)
std::cout << "PopupChatDialog:addChatMsg message : " << message.toStdString() << std::endl; std::cout << "PopupChatDialog:addChatMsg message : " << message.toStdString() << std::endl;
#endif #endif
RSettings settings(QString("Chat")); if (Settings->valueFromGroup(QString("Chat"), QString::fromUtf8("Emoteicons_PrivatChat"), true).toBool())
if (settings.value(QString::fromUtf8("Emoteicons_PrivatChat"), true).toBool())
{ {
QHashIterator<QString, QString> i(smileys); QHashIterator<QString, QString> i(smileys);
while(i.hasNext()) while(i.hasNext())

View File

@ -42,8 +42,7 @@ CreateForumMsg::CreateForumMsg(std::string fId, std::string pId)
ui.setupUi(this); ui.setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true); setAttribute(Qt::WA_DeleteOnClose, true);
RshareSettings config; Settings->loadWidgetInformation(this);
config.loadWidgetInformation(this);
connect( ui.forumMessage, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( forumMessageCostumPopupMenu( QPoint ) ) ); connect( ui.forumMessage, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( forumMessageCostumPopupMenu( QPoint ) ) );
@ -179,14 +178,14 @@ void CreateForumMsg::createMsg()
close(); close();
} }
void CreateForumMsg::closeEvent (QCloseEvent * event)
{
Settings->saveWidgetInformation(this);
}
void CreateForumMsg::cancelMsg() void CreateForumMsg::cancelMsg()
{ {
close(); close();
return;
RshareSettings config;
config.saveWidgetInformation(this);
} }
void CreateForumMsg::loadEmoticonsForums() void CreateForumMsg::loadEmoticonsForums()

View File

@ -58,6 +58,8 @@ private slots:
void addFile(); void addFile();
void addAttachment(std::string); void addAttachment(std::string);
protected:
void closeEvent (QCloseEvent * event);
private: private:
/** Define the popup menus for the Context menu */ /** Define the popup menus for the Context menu */

View File

@ -56,8 +56,6 @@
HelpBrowser::HelpBrowser(QWidget *parent) HelpBrowser::HelpBrowser(QWidget *parent)
: RWindow("HelpBrowser", parent) : RWindow("HelpBrowser", parent)
{ {
RshareSettings _settings;
/* Invoke Qt Designer generated QObject setup routine */ /* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this); ui.setupUi(this);
#if defined(Q_WS_MAC) #if defined(Q_WS_MAC)

View File

@ -48,8 +48,7 @@ ChanMsgDialog::ChanMsgDialog(bool msg, QWidget *parent, Qt::WFlags flags)
setupViewActions(); setupViewActions();
setupInsertActions(); setupInsertActions();
RshareSettings config; Settings->loadWidgetInformation(this);
config.loadWidgetInformation(this);
setAttribute ( Qt::WA_DeleteOnClose, true ); setAttribute ( Qt::WA_DeleteOnClose, true );
@ -227,8 +226,7 @@ void ChanMsgDialog::closeEvent (QCloseEvent * event)
event->ignore(); event->ignore();
hide(); hide();
RshareSettings config; Settings->saveWidgetInformation(this);
config.saveWidgetInformation(this);
} }
#endif #endif

View File

@ -242,8 +242,7 @@ void NotifyQt::UpdateGUI()
if (rsNotify->NotifyPopupMessage(type, id, msg)) if (rsNotify->NotifyPopupMessage(type, id, msg))
{ {
RshareSettings settings; uint popupflags = Settings->getNotifyFlags();
uint popupflags = settings.getNotifyFlags();
/* id the name */ /* id the name */
std::string name = rsPeers->getPeerName(id); std::string name = rsPeers->getPeerName(id);

View File

@ -61,12 +61,7 @@ void StatusMessage::closeEvent (QCloseEvent * event)
/** Saves the changes on this page */ /** Saves the changes on this page */
void StatusMessage::save() void StatusMessage::save()
{ {
RshareSettings settings; Settings->setValueToGroup("Profile", "StatusMessage",ui.txt_StatusMessage->text());
settings.beginGroup("Profile");
settings.setValue("StatusMessage",ui.txt_StatusMessage->text());
settings.endGroup();
rsMsgs->setCustomStateString(ui.txt_StatusMessage->text().toStdString()); rsMsgs->setCustomStateString(ui.txt_StatusMessage->text().toStdString());

View File

@ -69,10 +69,9 @@ AppearancePage::save(QString &errmsg)
QString languageCode = QString languageCode =
LanguageSupport::languageCode(ui.cmboLanguage->currentText()); LanguageSupport::languageCode(ui.cmboLanguage->currentText());
RshareSettings settings; Settings->setLanguageCode(languageCode);
settings.setLanguageCode(languageCode); Settings->setInterfaceStyle(ui.cmboStyle->currentText());
settings.setInterfaceStyle(ui.cmboStyle->currentText()); Settings->setSheetName(ui.styleSheetCombo->currentText());
settings.setSheetName(ui.styleSheetCombo->currentText());
/* Set to new style */ /* Set to new style */
Rshare::setStyle(ui.cmboStyle->currentText()); Rshare::setStyle(ui.cmboStyle->currentText());
@ -85,21 +84,19 @@ AppearancePage::save(QString &errmsg)
void void
AppearancePage::load() AppearancePage::load()
{ {
RshareSettings settings; int index = ui.cmboLanguage->findData(Settings->getLanguageCode());
int index = ui.cmboLanguage->findData(settings.getLanguageCode());
ui.cmboLanguage->setCurrentIndex(index); ui.cmboLanguage->setCurrentIndex(index);
index = ui.cmboStyle->findData(Rshare::style().toLower()); index = ui.cmboStyle->findData(Rshare::style().toLower());
ui.cmboStyle->setCurrentIndex(index); ui.cmboStyle->setCurrentIndex(index);
ui.styleSheetCombo->setCurrentIndex(ui.styleSheetCombo->findText(settings.getSheetName())); ui.styleSheetCombo->setCurrentIndex(ui.styleSheetCombo->findText(Settings->getSheetName()));
/** load saved internal styleSheet **/ /** load saved internal styleSheet **/
//QFile file(":/qss/" + (settings.getSheetName().toLower()) + ".qss"); //QFile file(":/qss/" + (settings.getSheetName().toLower()) + ".qss");
/** load saved extern Stylesheets **/ /** load saved extern Stylesheets **/
QFile file(QApplication::applicationDirPath() + "/qss/" + (settings.getSheetName().toLower()) + ".qss"); QFile file(QApplication::applicationDirPath() + "/qss/" + (Settings->getSheetName().toLower()) + ".qss");
file.open(QFile::ReadOnly); file.open(QFile::ReadOnly);
QString styleSheet = QLatin1String(file.readAll()); QString styleSheet = QLatin1String(file.readAll());

View File

@ -22,13 +22,13 @@
#include "rsiface/rspeers.h" //for rsPeers variable #include "rsiface/rspeers.h" //for rsPeers variable
#include "rsiface/rsiface.h" #include "rsiface/rsiface.h"
#include "rsharesettings.h"
#include <QtGui> #include <QtGui>
#include <rshare.h> #include <rshare.h>
#include "ChatPage.h" #include "ChatPage.h"
#include "rsettings.h"
/** Constructor */ /** Constructor */
ChatPage::ChatPage(QWidget * parent, Qt::WFlags flags) ChatPage::ChatPage(QWidget * parent, Qt::WFlags flags)
: ConfigPage(parent, flags) : ConfigPage(parent, flags)
@ -52,12 +52,14 @@ ChatPage::closeEvent (QCloseEvent * event)
bool bool
ChatPage::save(QString &errmsg) ChatPage::save(QString &errmsg)
{ {
RSettings settings(QString("Chat")); Settings->beginGroup(QString("Chat"));
settings.setValue(QString::fromUtf8("Emoteicons_PrivatChat"), emotePrivatChat()); Settings->setValue(QString::fromUtf8("Emoteicons_PrivatChat"), emotePrivatChat());
settings.setValue(QString::fromUtf8("Emoteicons_GroupChat"), emoteGroupChat()); Settings->setValue(QString::fromUtf8("Emoteicons_GroupChat"), emoteGroupChat());
settings.setValue(QString::fromUtf8("GroupChat_History"), groupchatHistory()); Settings->setValue(QString::fromUtf8("GroupChat_History"), groupchatHistory());
settings.setValue(QString::fromUtf8("ChatScreenFont"), fontTempChat.toString()); Settings->setValue(QString::fromUtf8("ChatScreenFont"), fontTempChat.toString());
Settings->endGroup();
return true; return true;
} }
@ -66,13 +68,15 @@ ChatPage::save(QString &errmsg)
void void
ChatPage::load() ChatPage::load()
{ {
RSettings settings(QString("Chat")); Settings->beginGroup(QString("Chat"));
ui.checkBox_emoteprivchat->setChecked(settings.value(QString::fromUtf8("Emoteicons_PrivatChat"), true).toBool()); ui.checkBox_emoteprivchat->setChecked(Settings->value(QString::fromUtf8("Emoteicons_PrivatChat"), true).toBool());
ui.checkBox_emotegroupchat->setChecked(settings.value(QString::fromUtf8("Emoteicons_GroupChat"), true).toBool()); ui.checkBox_emotegroupchat->setChecked(Settings->value(QString::fromUtf8("Emoteicons_GroupChat"), true).toBool());
ui.checkBox_groupchathistory->setChecked(settings.value(QString::fromUtf8("GroupChat_History"), true).toBool()); ui.checkBox_groupchathistory->setChecked(Settings->value(QString::fromUtf8("GroupChat_History"), true).toBool());
fontTempChat.fromString(settings.value(QString::fromUtf8("ChatScreenFont")).toString()); fontTempChat.fromString(Settings->value(QString::fromUtf8("ChatScreenFont")).toString());
Settings->endGroup();
ui.labelChatFontPreview->setText(fontTempChat.rawName()); ui.labelChatFontPreview->setText(fontTempChat.rawName());
ui.labelChatFontPreview->setFont(fontTempChat); ui.labelChatFontPreview->setFont(fontTempChat);

View File

@ -166,12 +166,8 @@ FileAssociationsPage::save (QString &errmsg)
void void
FileAssociationsPage::load() FileAssociationsPage::load()
{ {
RshareSettings settings; // Settings->beginGroup("FileAssotiations");
// QSettings* settings = new QSettings( qApp->applicationDirPath()+"/sett.ini", QStringList keys = Settings->allKeys();
// QSettings::IniFormat);
//
// settings.beginGroup("FileAssotiations");
QStringList keys = settings.allKeys();
table->setRowCount( keys.count() ); table->setRowCount( keys.count() );
@ -179,7 +175,7 @@ FileAssociationsPage::load()
QStringList::const_iterator ki; QStringList::const_iterator ki;
for(ki=keys.constBegin(); ki!=keys.constEnd(); ki++) for(ki=keys.constBegin(); ki!=keys.constEnd(); ki++)
{ {
QString val = (settings.value(*ki, "")).toString(); QString val = (Settings->value(*ki, "")).toString();
addNewItemToTable( rowi, 0, *ki ); addNewItemToTable( rowi, 0, *ki );
addNewItemToTable( rowi, 1, val ); addNewItemToTable( rowi, 1, val );
@ -187,7 +183,6 @@ FileAssociationsPage::load()
rowi++; rowi++;
} }
//delete settings;
if (keys.count()==0) if (keys.count()==0)
{ {
removeAction->setEnabled(false); removeAction->setEnabled(false);
@ -206,8 +201,7 @@ FileAssociationsPage::remove()
QTableWidgetItem const * titem = table->item( currentRow,0); QTableWidgetItem const * titem = table->item( currentRow,0);
QString key = (titem->data(QTableWidgetItem::Type)).toString(); QString key = (titem->data(QTableWidgetItem::Type)).toString();
RshareSettings settings; Settings->remove(key);
settings.remove(key);
table->removeRow( currentRow ); table->removeRow( currentRow );
if ( table->rowCount()==0 ) if ( table->rowCount()==0 )
@ -235,8 +229,7 @@ FileAssociationsPage::addnew()
QString currCmd = afad.resultCommand() ; QString currCmd = afad.resultCommand() ;
RshareSettings settings; if ( !Settings->contains(currType) )//new item should be added only if
if ( !settings.contains(currType) )//new item should be added only if
{ // it wasn't entered before. { // it wasn't entered before.
int nridx = table->rowCount();//new row index int nridx = table->rowCount();//new row index
table->setRowCount(nridx+1); table->setRowCount(nridx+1);
@ -257,7 +250,7 @@ FileAssociationsPage::addnew()
} }
} }
settings.setValue(currType, currCmd); Settings->setValue(currType, currCmd);
removeAction->setEnabled(true); removeAction->setEnabled(true);
editAction->setEnabled(true); editAction->setEnabled(true);
@ -290,8 +283,7 @@ FileAssociationsPage::edit()
titem->setData(QTableWidgetItem::Type, currCmd); titem->setData(QTableWidgetItem::Type, currCmd);
RshareSettings settings; Settings->setValue(currType, currCmd);
settings.setValue(currType, currCmd);
} }
} }

View File

@ -55,14 +55,13 @@ GeneralPage::~GeneralPage()
bool bool
GeneralPage::save(QString &errmsg) GeneralPage::save(QString &errmsg)
{ {
RshareSettings settings; Settings->setValue(QString::fromUtf8("StartMinimized"), startMinimized());
settings.setValue(QString::fromUtf8("StartMinimized"), startMinimized());
settings.setValue(QString::fromUtf8("doQuit"), quit()); Settings->setValue(QString::fromUtf8("doQuit"), quit());
settings.setValue(QString::fromUtf8("ClosetoTray"), closetoTray()); Settings->setValue(QString::fromUtf8("ClosetoTray"), closetoTray());
settings.setRunRetroshareOnBoot( Settings->setRunRetroshareOnBoot(
ui.chkRunRetroshareAtSystemStartup->isChecked()); ui.chkRunRetroshareAtSystemStartup->isChecked());
return true; return true;
@ -72,14 +71,13 @@ GeneralPage::save(QString &errmsg)
void void
GeneralPage::load() GeneralPage::load()
{ {
RshareSettings settings; ui.chkRunRetroshareAtSystemStartup->setChecked(Settings->runRetroshareOnBoot());
ui.chkRunRetroshareAtSystemStartup->setChecked(settings.runRetroshareOnBoot());
ui.checkStartMinimized->setChecked(settings.value(QString::fromUtf8("StartMinimized"), false).toBool()); ui.checkStartMinimized->setChecked(Settings->value(QString::fromUtf8("StartMinimized"), false).toBool());
ui.checkQuit->setChecked(settings.value(QString::fromUtf8("doQuit"), false).toBool()); ui.checkQuit->setChecked(Settings->value(QString::fromUtf8("doQuit"), false).toBool());
ui.checkClosetoTray->setChecked(settings.value(QString::fromUtf8("ClosetoTray"), false).toBool()); ui.checkClosetoTray->setChecked(Settings->value(QString::fromUtf8("ClosetoTray"), false).toBool());
} }
@ -104,8 +102,7 @@ bool GeneralPage::closetoTray() const {
void void
GeneralPage::toggleShowOnStartup(bool checked) GeneralPage::toggleShowOnStartup(bool checked)
{ {
RshareSettings settings; Settings->setShowMainWindowAtStart(checked);
settings.setShowMainWindowAtStart(checked);
} }
void GeneralPage::setAutoLogin(){ void GeneralPage::setAutoLogin(){

View File

@ -108,10 +108,9 @@ NotifyPage::save(QString &errmsg)
if (ui.chat_Focus->isChecked()) if (ui.chat_Focus->isChecked())
chatflags |= RS_CHAT_FOCUS; chatflags |= RS_CHAT_FOCUS;
RshareSettings settings; Settings->setNotifyFlags(notifyflags);
settings.setNotifyFlags(notifyflags); Settings->setNewsFeedFlags(newsflags);
settings.setNewsFeedFlags(newsflags); Settings->setChatFlags(chatflags);
settings.setChatFlags(chatflags);
load(); load();
return true; return true;
@ -122,11 +121,9 @@ NotifyPage::save(QString &errmsg)
void NotifyPage::load() void NotifyPage::load()
{ {
/* extract from rsNotify the flags */ /* extract from rsNotify the flags */
RshareSettings settings; uint notifyflags = Settings->getNotifyFlags();
uint newsflags = Settings->getNewsFeedFlags();
uint notifyflags = settings.getNotifyFlags(); uint chatflags = Settings->getChatFlags();
uint newsflags = settings.getNewsFeedFlags();
uint chatflags = settings.getChatFlags();
ui.popup_Connect->setChecked(notifyflags & RS_POPUP_CONNECT); ui.popup_Connect->setChecked(notifyflags & RS_POPUP_CONNECT);
ui.popup_NewMsg->setChecked(notifyflags & RS_POPUP_MSG); ui.popup_NewMsg->setChecked(notifyflags & RS_POPUP_MSG);

View File

@ -56,25 +56,24 @@ SoundPage::~SoundPage()
bool bool
SoundPage::save(QString &errmsg) SoundPage::save(QString &errmsg)
{ {
RshareSettings settings; Settings->beginGroup("Sound");
settings.beginGroup("Sound"); Settings->beginGroup("Enable");
settings.beginGroup("Enable"); Settings->setValue("User_go_Online",ui.checkBoxSound->isChecked());
settings.setValue("User_go_Online",ui.checkBoxSound->isChecked());
//settings.setValue("User_go_Offline",ui.checkBoxSound_2->isChecked()); //settings.setValue("User_go_Offline",ui.checkBoxSound_2->isChecked());
settings.setValue("FileSend_Finished",ui.checkBoxSound_3->isChecked()); Settings->setValue("FileSend_Finished",ui.checkBoxSound_3->isChecked());
settings.setValue("FileRecive_Incoming",ui.checkBoxSound_4->isChecked()); Settings->setValue("FileRecive_Incoming",ui.checkBoxSound_4->isChecked());
settings.setValue("FileRecive_Finished",ui.checkBoxSound_5->isChecked()); Settings->setValue("FileRecive_Finished",ui.checkBoxSound_5->isChecked());
settings.setValue("NewChatMessage",ui.checkBoxSound_6->isChecked()); Settings->setValue("NewChatMessage",ui.checkBoxSound_6->isChecked());
settings.endGroup(); Settings->endGroup();
settings.beginGroup("SoundFilePath"); Settings->beginGroup("SoundFilePath");
settings.setValue("User_go_Online",ui.txt_SoundFile->text()); Settings->setValue("User_go_Online",ui.txt_SoundFile->text());
//settings.setValue("User_go_Offline",ui.txt_SoundFile2->text()); //settings.setValue("User_go_Offline",ui.txt_SoundFile2->text());
settings.setValue("FileSend_Finished",ui.txt_SoundFile3->text()); Settings->setValue("FileSend_Finished",ui.txt_SoundFile3->text());
settings.setValue("FileRecive_Incoming",ui.txt_SoundFile4->text()); Settings->setValue("FileRecive_Incoming",ui.txt_SoundFile4->text());
settings.setValue("FileRecive_Finished",ui.txt_SoundFile5->text()); Settings->setValue("FileRecive_Finished",ui.txt_SoundFile5->text());
settings.setValue("NewChatMessage",ui.txt_SoundFile6->text()); Settings->setValue("NewChatMessage",ui.txt_SoundFile6->text());
settings.endGroup(); Settings->endGroup();
settings.endGroup(); Settings->endGroup();
return true; return true;
} }
@ -85,15 +84,14 @@ SoundPage::save(QString &errmsg)
void void
SoundPage::load() SoundPage::load()
{ {
RshareSettings settings; Settings->beginGroup("Sound");
settings.beginGroup("Sound"); Settings->beginGroup("SoundFilePath");
settings.beginGroup("SoundFilePath"); ui.txt_SoundFile->setText(Settings->value("User_go_Online","").toString());
ui.txt_SoundFile->setText(settings.value("User_go_Online","").toString());
//ui.txt_SoundFile2->setText(settings.value("User_go_Offline","").toString()); //ui.txt_SoundFile2->setText(settings.value("User_go_Offline","").toString());
ui.txt_SoundFile3->setText(settings.value("FileSend_Finished","").toString()); ui.txt_SoundFile3->setText(Settings->value("FileSend_Finished","").toString());
ui.txt_SoundFile4->setText(settings.value("FileRecive_Incoming","").toString()); ui.txt_SoundFile4->setText(Settings->value("FileRecive_Incoming","").toString());
ui.txt_SoundFile5->setText(settings.value("FileRecive_Finished","").toString()); ui.txt_SoundFile5->setText(Settings->value("FileRecive_Finished","").toString());
ui.txt_SoundFile6->setText(settings.value("NewChatMessage","").toString()); ui.txt_SoundFile6->setText(Settings->value("NewChatMessage","").toString());
if(!ui.txt_SoundFile->text().isEmpty())ui.checkBoxSound->setEnabled(true); if(!ui.txt_SoundFile->text().isEmpty())ui.checkBoxSound->setEnabled(true);
//if(!ui.txt_SoundFile2->text().isEmpty())ui.checkBoxSound_2->setEnabled(true); //if(!ui.txt_SoundFile2->text().isEmpty())ui.checkBoxSound_2->setEnabled(true);
@ -102,17 +100,17 @@ SoundPage::load()
if(!ui.txt_SoundFile5->text().isEmpty())ui.checkBoxSound_5->setEnabled(true); if(!ui.txt_SoundFile5->text().isEmpty())ui.checkBoxSound_5->setEnabled(true);
if(!ui.txt_SoundFile6->text().isEmpty())ui.checkBoxSound_6->setEnabled(true); if(!ui.txt_SoundFile6->text().isEmpty())ui.checkBoxSound_6->setEnabled(true);
settings.endGroup(); Settings->endGroup();
settings.beginGroup("Enable"); Settings->beginGroup("Enable");
ui.checkBoxSound->setChecked(settings.value("User_go_Online",false).toBool()); ui.checkBoxSound->setChecked(Settings->value("User_go_Online",false).toBool());
//ui.checkBoxSound_2->setChecked(settings.value("User_go_Offline",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_3->setChecked(Settings->value("FileSend_Finished",false).toBool());
ui.checkBoxSound_4->setChecked(settings.value("FileRecive_Incoming",false).toBool()); ui.checkBoxSound_4->setChecked(Settings->value("FileRecive_Incoming",false).toBool());
ui.checkBoxSound_5->setChecked(settings.value("FileRecive_Finished",false).toBool()); ui.checkBoxSound_5->setChecked(Settings->value("FileRecive_Finished",false).toBool());
ui.checkBoxSound_6->setChecked(settings.value("NewChatMessage",false).toBool()); ui.checkBoxSound_6->setChecked(Settings->value("NewChatMessage",false).toBool());
settings.endGroup(); Settings->endGroup();
settings.endGroup(); Settings->endGroup();
} }
void SoundPage::on_cmd_openFile() void SoundPage::on_cmd_openFile()

View File

@ -64,6 +64,22 @@ RSettings::setValue(const QString &key, const QVariant &val)
QSettings::setValue(key, val); QSettings::setValue(key, val);
} }
QVariant RSettings::valueFromGroup(const QString &group, const QString &key, const QVariant &defaultVal)
{
beginGroup(group);
QVariant val = value(key, defaultVal);
endGroup();
return val;
}
void RSettings::setValueToGroup(const QString &group, const QString &key, const QVariant &val)
{
beginGroup(group);
setValue(key, val);
endGroup();
}
/** Sets the default setting for <b>key</b> to <b>val</b>. */ /** Sets the default setting for <b>key</b> to <b>val</b>. */
void void
RSettings::setDefault(const QString &key, const QVariant &val) RSettings::setDefault(const QString &key, const QVariant &val)

View File

@ -54,6 +54,10 @@ public:
/** Sets the value associated with <b>key</b> to <b>val</b>. */ /** Sets the value associated with <b>key</b> to <b>val</b>. */
virtual void setValue(const QString &key, const QVariant &val); virtual void setValue(const QString &key, const QVariant &val);
virtual QVariant valueFromGroup(const QString &group, const QString &key,
const QVariant &defaultVal = QVariant());
virtual void setValueToGroup(const QString &group, const QString &key, const QVariant &val);
protected: protected:
/** Sets the default setting for <b>key</b> to <b>val</b>. */ /** Sets the default setting for <b>key</b> to <b>val</b>. */
void setDefault(const QString &key, const QVariant &val); void setDefault(const QString &key, const QVariant &val);

View File

@ -69,8 +69,14 @@
#define DEFAULT_BWGRAPH_FILTER (BWGRAPH_SEND|BWGRAPH_REC) #define DEFAULT_BWGRAPH_FILTER (BWGRAPH_SEND|BWGRAPH_REC)
#define DEFAULT_BWGRAPH_ALWAYS_ON_TOP false #define DEFAULT_BWGRAPH_ALWAYS_ON_TOP false
RshareSettings::RshareSettings(std::string filename) : RSettings(filename) { // the one and only global settings object
initSettings(); RshareSettings *Settings = NULL;
/*static*/ void RshareSettings::Create ()
{
if (Settings == NULL) {
Settings = new RshareSettings ();
}
} }
/** Default Constructor */ /** Default Constructor */

View File

@ -48,13 +48,8 @@ class RshareSettings : public RSettings
{ {
public: public:
/** Default constructor. */ /* create settings object */
RshareSettings(); static void Create ();
/** Default constructor. */
RshareSettings(std::string filename);
void initSettings();
/** Gets the currently preferred language code for RShare. */ /** Gets the currently preferred language code for RShare. */
QString getLanguageCode(); QString getLanguageCode();
@ -119,22 +114,27 @@ public:
uint getNotifyFlags(); uint getNotifyFlags();
void setNotifyFlags(uint flags); void setNotifyFlags(uint flags);
//! Save placement, state and size information of a window.
void saveWidgetInformation(QWidget *widget);
//! Save placement, state and size information of a window. //! Load placement, state and size information of a window.
void saveWidgetInformation(QWidget *widget); void loadWidgetInformation(QWidget *widget);
//! Load placement, state and size information of a window. //! Method overload. Save window and toolbar information.
void loadWidgetInformation(QWidget *widget); void saveWidgetInformation(QMainWindow *widget, QToolBar *toolBar);
//! Method overload. Save window and toolbar information.
void saveWidgetInformation(QMainWindow *widget, QToolBar *toolBar);
//! Method overload. Restore window and toolbar information.
void loadWidgetInformation(QMainWindow *widget, QToolBar *toolBar);
//! Method overload. Restore window and toolbar information.
void loadWidgetInformation(QMainWindow *widget, QToolBar *toolBar);
protected:
/** Default constructor. */
RshareSettings();
void initSettings();
}; };
// the one and only global settings object
extern RshareSettings *Settings;
#endif #endif

View File

@ -68,15 +68,14 @@ void OnlineToaster::chatButtonSlot() {
} }
void OnlineToaster::play(){ void OnlineToaster::play(){
RshareSettings settings; Settings->beginGroup("Sound");
settings.beginGroup("Sound"); Settings->beginGroup("SoundFilePath");
settings.beginGroup("SoundFilePath"); QString OnlineSound = Settings->value("User_go_Online","").toString();
QString OnlineSound= settings.value("User_go_Online","").toString(); Settings->endGroup();
settings.endGroup(); Settings->beginGroup("Enable");
settings.beginGroup("Enable"); bool flag = Settings->value("User_go_Online",false).toBool();
bool flag= settings.value("User_go_Online",false).toBool(); Settings->endGroup();
settings.endGroup(); Settings->endGroup();
settings.endGroup();
if(!OnlineSound.isEmpty()&&flag) if(!OnlineSound.isEmpty()&&flag)
if(QSound::isAvailable()) if(QSound::isAvailable())
QSound::play(OnlineSound); QSound::play(OnlineSound);

View File

@ -61,8 +61,7 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
setWindowTitle(tr("RetroShare")); setWindowTitle(tr("RetroShare"));
RshareSettings config; Settings->loadWidgetInformation(this);
config.loadWidgetInformation(this);
// Setting icons // Setting icons
this->setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); this->setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
@ -155,8 +154,7 @@ void ApplicationWindow::createActions()
void ApplicationWindow::closeEvent(QCloseEvent *e) void ApplicationWindow::closeEvent(QCloseEvent *e)
{ {
RshareSettings config; Settings->saveWidgetInformation(this);
config.saveWidgetInformation(this);
hide(); hide();
e->ignore(); e->ignore();

View File

@ -43,9 +43,6 @@ StatisticDialog::StatisticDialog(QWidget *parent)
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
/* Create Bandwidth Graph related QObjects */
_settings = new RshareSettings();
/* Bind events to actions */ /* Bind events to actions */
createActions(); createActions();
@ -85,12 +82,6 @@ StatisticDialog::StatisticDialog(QWidget *parent)
} }
/** Default destructor */
StatisticDialog::~StatisticDialog()
{
delete _settings;
}
/** /**
Custom event handler. Checks if the event is a bandwidth update event. If it Custom event handler. Checks if the event is a bandwidth update event. If it
is, it will add the data point to the history and updates the graph.*/ is, it will add the data point to the history and updates the graph.*/
@ -182,7 +173,7 @@ StatisticDialog::loadSettings()
/* Set the line filter checkboxes accordingly */ /* Set the line filter checkboxes accordingly */
uint filter = _settings->getBWGraphFilter(); uint filter = Settings->getBWGraphFilter();
ui.chkReceiveRate->setChecked(filter & BWGRAPH_REC); ui.chkReceiveRate->setChecked(filter & BWGRAPH_REC);
ui.chkSendRate->setChecked(filter & BWGRAPH_SEND); ui.chkSendRate->setChecked(filter & BWGRAPH_SEND);
@ -215,13 +206,13 @@ StatisticDialog::saveChanges()
showSettingsFrame(false); showSettingsFrame(false);
/* Save the opacity */ /* Save the opacity */
_settings->setBWGraphOpacity(ui.sldrOpacity->value()); Settings->setBWGraphOpacity(ui.sldrOpacity->value());
/* Save the line filter values */ /* Save the line filter values */
_settings->setBWGraphFilter(BWGRAPH_REC, ui.chkReceiveRate->isChecked()); Settings->setBWGraphFilter(BWGRAPH_REC, ui.chkReceiveRate->isChecked());
_settings->setBWGraphFilter(BWGRAPH_SEND, ui.chkSendRate->isChecked()); Settings->setBWGraphFilter(BWGRAPH_SEND, ui.chkSendRate->isChecked());
/* Update the graph frame settings */ /* Update the graph frame settings */
ui.frmGraph->setShowCounters(ui.chkReceiveRate->isChecked(), ui.frmGraph->setShowCounters(ui.chkReceiveRate->isChecked(),

View File

@ -42,8 +42,7 @@ class StatisticDialog : public MainPage
public: public:
/** Default Constructor */ /** Default Constructor */
StatisticDialog(QWidget *parent = 0); StatisticDialog(QWidget *parent = 0);
/** Default Destructor */
~StatisticDialog();
protected: protected:
/** Called to deliver a bandwidth update event from RetroShare. */ /** Called to deliver a bandwidth update event from RetroShare. */
void customEvent(QEvent *event); void customEvent(QEvent *event);

View File

@ -54,6 +54,9 @@ int main(int argc, char *argv[])
RsInit::InitRsConfig(); RsInit::InitRsConfig();
bool okStart = RsInit::InitRetroShare(argc, argv); bool okStart = RsInit::InitRetroShare(argc, argv);
/* create global settings object */
RshareSettings::Create ();
/* /*
Function RsConfigMinimised is not available in SVN, so I commented it out. Function RsConfigMinimised is not available in SVN, so I commented it out.
bool startMinimised = RsConfigStartMinimised(config); bool startMinimised = RsConfigStartMinimised(config);
@ -163,9 +166,7 @@ int main(int argc, char *argv[])
{ {
/* only show window, if not startMinimized */ /* only show window, if not startMinimized */
RshareSettings _settings; if(!Settings->value(QString::fromUtf8("StartMinimized"), false).toBool())
if(!_settings.value(QString::fromUtf8("StartMinimized"), false).toBool())
{ {
w->show(); w->show();
@ -179,13 +180,11 @@ int main(int argc, char *argv[])
/* dive into the endless loop */ /* dive into the endless loop */
// return ret; // return ret;
int ti = rshare.exec(); int ti = rshare.exec();
delete w ; delete w ;
Settings->sync();
delete Settings;
return ti ; return ti ;
} }

View File

@ -96,8 +96,7 @@ Rshare::Rshare(QStringList args, int &argc, char **argv, QString dir)
/* Check if we're supposed to reset our config before proceeding. */ /* Check if we're supposed to reset our config before proceeding. */
if (_args.contains(ARG_RESET)) { if (_args.contains(ARG_RESET)) {
RshareSettings settings; Settings->reset();
settings.reset();
} }
/* Handle the -loglevel and -logfile options. */ /* Handle the -loglevel and -logfile options. */
@ -314,8 +313,7 @@ Rshare::setLanguage(QString languageCode)
{ {
/* If the language code is empty, use the previously-saved setting */ /* If the language code is empty, use the previously-saved setting */
if (languageCode.isEmpty()) { if (languageCode.isEmpty()) {
RshareSettings settings; languageCode = Settings->getLanguageCode();
languageCode = settings.getLanguageCode();
} }
/* Translate into the desired langauge */ /* Translate into the desired langauge */
if (LanguageSupport::translate(languageCode)) { if (LanguageSupport::translate(languageCode)) {
@ -334,8 +332,7 @@ Rshare::setStyle(QString styleKey)
{ {
/* If no style was specified, use the previously-saved setting */ /* If no style was specified, use the previously-saved setting */
if (styleKey.isEmpty()) { if (styleKey.isEmpty()) {
RshareSettings settings; styleKey = Settings->getInterfaceStyle();
styleKey = settings.getInterfaceStyle();
} }
/* Apply the specified GUI style */ /* Apply the specified GUI style */
if (QApplication::setStyle(styleKey)) { if (QApplication::setStyle(styleKey)) {
@ -350,8 +347,7 @@ Rshare::setSheet(QString sheet)
{ {
/* If no stylesheet was specified, use the previously-saved setting */ /* If no stylesheet was specified, use the previously-saved setting */
if (sheet.isEmpty()) { if (sheet.isEmpty()) {
RshareSettings settings; sheet = Settings->getSheetName();
sheet = settings.getSheetName();
} }
/* Apply the specified GUI stylesheet */ /* Apply the specified GUI stylesheet */
_stylesheet = sheet; _stylesheet = sheet;