From 423f6811ce24e3c1ffb3d8d176355795a4ec9055 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Wed, 21 Jul 2010 07:39:14 +0000 Subject: [PATCH] new methods for set and get the max time before idle on RshareSettings git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3308 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/MainWindow.cpp | 7 ++++--- retroshare-gui/src/gui/MainWindow.h | 1 - .../src/gui/settings/rsharesettings.cpp | 18 ++++++++++++++++++ .../src/gui/settings/rsharesettings.h | 7 +++++++ 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index ef45346a8..417a68773 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -129,7 +129,7 @@ /** Constructor */ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) - : RWindow("MainWindow", parent, flags), maxTimeBeforeIdle(30) + : RWindow("MainWindow", parent, flags) { /* Invoke the Qt Designer generated QObject setup routine */ ui.setupUi(this); @@ -876,9 +876,10 @@ void MainWindow::loadOwnStatus() void MainWindow::checkAndSetIdle(int idleTime) { - if ((idleTime >= (int) maxTimeBeforeIdle) && !isIdle) { + int maxTimeBeforeIdle = Settings->getMaxTimeBeforeIdle(); + if ((idleTime >= maxTimeBeforeIdle) && !isIdle) { setIdle(true); - } else if ((idleTime < (int) maxTimeBeforeIdle) && isIdle) { + } else if ((idleTime < maxTimeBeforeIdle) && isIdle) { setIdle(false); } diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index b2413472a..936dac53f 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -242,7 +242,6 @@ private: // idle function void setIdle(bool Idle); bool isIdle; - const unsigned long maxTimeBeforeIdle; /** Qt Designer generated object */ Ui::MainWindow ui; diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index 5c02e9517..005d68e0b 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -87,6 +87,8 @@ RshareSettings *Settings = NULL; /** Default Constructor */ RshareSettings::RshareSettings() { + m_maxTimeBeforeIdle = -1; + initSettings(); } @@ -375,3 +377,19 @@ void RshareSettings::setMsgSetToReadOnActivate (bool bValue) { setValueToGroup("MessageDialog", "SetMsgToReadOnActivate", bValue); } + +/* time before idle */ +uint RshareSettings::getMaxTimeBeforeIdle() +{ + if (m_maxTimeBeforeIdle == -1) { + m_maxTimeBeforeIdle = valueFromGroup("General", "maxTimeBeforeIdle", 30).toUInt(); + } + + return m_maxTimeBeforeIdle; +} + +void RshareSettings::setMaxTimeBeforeIdle(uint nValue) +{ + m_maxTimeBeforeIdle = nValue; + setValueToGroup("General", "maxTimeBeforeIdle", nValue); +} diff --git a/retroshare-gui/src/gui/settings/rsharesettings.h b/retroshare-gui/src/gui/settings/rsharesettings.h index c82c2e95e..4996a9bf4 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.h +++ b/retroshare-gui/src/gui/settings/rsharesettings.h @@ -133,11 +133,18 @@ public: bool getMsgSetToReadOnActivate (); void setMsgSetToReadOnActivate (bool bValue); + /* time before idle */ + uint getMaxTimeBeforeIdle(); + void setMaxTimeBeforeIdle(uint nValue); + protected: /** Default constructor. */ RshareSettings(); void initSettings(); + + /* member for fast access */ + int m_maxTimeBeforeIdle; }; // the one and only global settings object