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
This commit is contained in:
thunder2 2010-07-21 07:39:14 +00:00
parent e3e4c97369
commit 423f6811ce
4 changed files with 29 additions and 4 deletions

View File

@ -129,7 +129,7 @@
/** Constructor */ /** Constructor */
MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) 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 */ /* Invoke the Qt Designer generated QObject setup routine */
ui.setupUi(this); ui.setupUi(this);
@ -876,9 +876,10 @@ void MainWindow::loadOwnStatus()
void MainWindow::checkAndSetIdle(int idleTime) void MainWindow::checkAndSetIdle(int idleTime)
{ {
if ((idleTime >= (int) maxTimeBeforeIdle) && !isIdle) { int maxTimeBeforeIdle = Settings->getMaxTimeBeforeIdle();
if ((idleTime >= maxTimeBeforeIdle) && !isIdle) {
setIdle(true); setIdle(true);
} else if ((idleTime < (int) maxTimeBeforeIdle) && isIdle) { } else if ((idleTime < maxTimeBeforeIdle) && isIdle) {
setIdle(false); setIdle(false);
} }

View File

@ -242,7 +242,6 @@ private:
// idle function // idle function
void setIdle(bool Idle); void setIdle(bool Idle);
bool isIdle; bool isIdle;
const unsigned long maxTimeBeforeIdle;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::MainWindow ui; Ui::MainWindow ui;

View File

@ -87,6 +87,8 @@ RshareSettings *Settings = NULL;
/** Default Constructor */ /** Default Constructor */
RshareSettings::RshareSettings() RshareSettings::RshareSettings()
{ {
m_maxTimeBeforeIdle = -1;
initSettings(); initSettings();
} }
@ -375,3 +377,19 @@ void RshareSettings::setMsgSetToReadOnActivate (bool bValue)
{ {
setValueToGroup("MessageDialog", "SetMsgToReadOnActivate", 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);
}

View File

@ -133,11 +133,18 @@ public:
bool getMsgSetToReadOnActivate (); bool getMsgSetToReadOnActivate ();
void setMsgSetToReadOnActivate (bool bValue); void setMsgSetToReadOnActivate (bool bValue);
/* time before idle */
uint getMaxTimeBeforeIdle();
void setMaxTimeBeforeIdle(uint nValue);
protected: protected:
/** Default constructor. */ /** Default constructor. */
RshareSettings(); RshareSettings();
void initSettings(); void initSettings();
/* member for fast access */
int m_maxTimeBeforeIdle;
}; };
// the one and only global settings object // the one and only global settings object