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 */
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);
}

View File

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

View File

@ -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);
}

View File

@ -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