screensaver/snsrplugins/snsrbigclockscreensaverplugin/src/snsrbigclockscreensaver.cpp
author hgs
Wed, 20 Oct 2010 15:25:39 +0300
changeset 101 ba1b7e218624
parent 98 e6f74eb7f69f
permissions -rw-r--r--
201042
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
97
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
     1
/*
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
     3
* All rights reserved.
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
     8
*
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
     9
* Initial Contributors:
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    11
*
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    12
* Contributors:
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    13
*
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    14
* Description: Big clock Screensaver.
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    15
*
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    16
*/
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    17
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    18
#include "snsrbigclockscreensaver.h"
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    19
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    20
#ifdef Q_OS_SYMBIAN
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    21
#include <XQSettingsManager> 
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    22
#include <screensaverdomaincrkeys.h>
98
hgs
parents: 97
diff changeset
    23
#include <clockdomaincrkeys.h>
97
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    24
#endif // Q_OS_SYMBIAN
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    25
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    26
#include <QDebug>
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    27
#include <QTime>
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    28
#include <QTimer>
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    29
#include <HbInstance>
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    30
#include <HbMainWindow>
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    31
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    32
#include "snsranalogclockcontainer.h"
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    33
#include "snsrdigitalclockcontainer.h"
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    34
#include "snsroledanalogclockcontainer.h"
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    35
#include "snsroleddigitalclockcontainer.h"
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    36
#include "snsrblankcontainer.h"
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    37
#include "snsrindicatormodel.h"
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    38
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    39
/*!
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    40
    \class SnsrBigClockScreensaver
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    41
    \ingroup group_snsrbigclockscreensaverplugin
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    42
    \brief Screensaver with big digital clock.
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    43
 */
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    44
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    45
/*!
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    46
    Constructs a new SnsrBigClockScreensaver.
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    47
 */
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    48
SnsrBigClockScreensaver::SnsrBigClockScreensaver() :
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    49
    mMainWindow(0),
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    50
    mCurrentContainer(0),
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    51
    mIndicatorModel(0)
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    52
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    53
    mMainWindow = HbInstance::instance()->allMainWindows().at(0);
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    54
    // for nice looking clock hand transformations
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    55
    mMainWindow->setRenderHint(QPainter::SmoothPixmapTransform);
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    56
    
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    57
    // This model holds indicator status information and must exist as
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    58
    // long as screensaver does.
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    59
    mIndicatorModel = new SnsrIndicatorModel(this);
98
hgs
parents: 97
diff changeset
    60
    
hgs
parents: 97
diff changeset
    61
    // connect timer for time updates
hgs
parents: 97
diff changeset
    62
    connect( &mTimer, SIGNAL(timeout()), SLOT(updateTime()) );
97
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    63
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    64
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    65
/*!
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    66
    Destructs the class.
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    67
 */
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    68
SnsrBigClockScreensaver::~SnsrBigClockScreensaver()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    69
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    70
    // TODO: unlock orientation once the locking mechanism is available and used
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    71
    // mCurrentContainer, mIndicatorModel - deleted by the parent
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    72
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    73
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    74
/*!
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    75
    @copydoc Screensaver::onInitialize()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    76
*/
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    77
bool SnsrBigClockScreensaver::onInitialize()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    78
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    79
    qDebug() << "SnsrBigClockScreensaver::onInitialize()";
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    80
    return true;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    81
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    82
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    83
/*!
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    84
    @copydoc Screensaver::onForeground()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    85
 */
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    86
bool SnsrBigClockScreensaver::onForeground()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    87
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    88
    SCREENSAVER_TEST_FUNC_ENTRY("SnsrBigClockScreensaver::onForeground")
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    89
    qDebug() << "SnsrBigClockScreensaver::onForeground()";
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    90
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    91
    removeCurrentContainer();
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    92
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    93
    SnsrBigClockContainer* newContainer( 0 );
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    94
    if (clockFormat() == ClockFormatAnalog) {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    95
        newContainer = new SnsrAnalogClockContainer();
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    96
    }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    97
    else {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    98
        newContainer = new SnsrDigitalClockContainer();
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
    99
    }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   100
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   101
    setCurrentContainer( newContainer );
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   102
    
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   103
    SCREENSAVER_TEST_FUNC_EXIT("SnsrBigClockScreensaver::onForeground")
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   104
    return true;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   105
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   106
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   107
/*!
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   108
    @copydoc Screensaver::onPartialForeground()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   109
 */
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   110
bool SnsrBigClockScreensaver::onPartialForeground()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   111
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   112
    SCREENSAVER_TEST_FUNC_ENTRY("SnsrBigClockScreensaver::onPartialForeground")
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   113
    qDebug() << "SnsrBigClockScreensaver::onPartialForeground()";
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   114
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   115
    removeCurrentContainer();
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   116
    
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   117
    SnsrBigClockContainer* newContainer( 0 );
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   118
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   119
#ifdef Q_OS_SYMBIAN  
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   120
    // Check ScreensaverStatus from repository
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   121
    XQSettingsManager::Error error;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   122
    XQCentralRepositorySettingsKey settingsKey(
98
hgs
parents: 97
diff changeset
   123
            KCRUidValueScreensaverSettings, KScreensaverStatus ); 
97
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   124
    XQSettingsManager setManager;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   125
    int screensaverOn = setManager.readItemValue(settingsKey, XQSettingsManager::TypeInt).toInt();
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   126
    error = setManager.error();
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   127
    if (error != XQSettingsManager::NoError) {
98
hgs
parents: 97
diff changeset
   128
        qDebug("Error reading screensaver status from XQSettingsManager.. error = %d", error);
97
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   129
    }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   130
#else
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   131
    int screensaverOn = 1;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   132
#endif // Q_OS_SYMBIAN
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   133
    
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   134
    if (screensaverOn) {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   135
        if (clockFormat() == ClockFormatAnalog) {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   136
            newContainer = new SnsrOledAnalogClockContainer();
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   137
        }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   138
        else {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   139
            newContainer = new SnsrOledDigitalClockContainer();
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   140
        }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   141
    }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   142
    else {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   143
        newContainer = new SnsrBlankContainer();
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   144
    }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   145
    
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   146
    setCurrentContainer( newContainer );
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   147
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   148
    SCREENSAVER_TEST_FUNC_EXIT("SnsrBigClockScreensaver::onPartialForeground")
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   149
    return true;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   150
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   151
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   152
/*!
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   153
    @copydoc Screensaver::onBackground()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   154
 */
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   155
bool SnsrBigClockScreensaver::onBackground()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   156
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   157
    SCREENSAVER_TEST_FUNC_ENTRY("SnsrBigClockScreensaver::onBackground")
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   158
    qDebug() << "SnsrBigClockScreensaver::onBackground()";
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   159
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   160
    removeCurrentContainer();
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   161
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   162
    SCREENSAVER_TEST_FUNC_EXIT("SnsrBigClockScreensaver::onBackground")
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   163
    return true;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   164
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   165
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   166
/*!
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   167
    @copydoc Screensaver::onPowerSave()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   168
 */
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   169
bool SnsrBigClockScreensaver::onPowerSave()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   170
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   171
    SCREENSAVER_TEST_FUNC_ENTRY("SnsrBigClockScreensaver::onPowerSave")
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   172
    qDebug() << "SnsrBigClockScreensaver::onPowerSave()";
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   173
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   174
    SCREENSAVER_TEST_FUNC_EXIT("SnsrBigClockScreensaver::onPowerSave")
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   175
    return false;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   176
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   177
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   178
/*!
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   179
    @copydoc Screensaver::onClose()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   180
 */
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   181
bool SnsrBigClockScreensaver::onClose()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   182
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   183
    SCREENSAVER_TEST_FUNC_ENTRY("SnsrBigClockScreensaver::onClose")
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   184
    qDebug() << "SnsrBigClockScreensaver::onClose()";
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   185
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   186
    bool ret(false);
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   187
    if (onBackground()) {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   188
        delete mCurrentContainer;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   189
        mCurrentContainer = 0;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   190
        ret = true;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   191
    }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   192
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   193
    SCREENSAVER_TEST_FUNC_EXIT("SnsrBigClockScreensaver::onClose")
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   194
    return ret;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   195
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   196
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   197
/*!
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   198
    @copydoc Screensaver::onHandleActiveIndicators
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   199
 */
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   200
void SnsrBigClockScreensaver::onHandleActiveIndicators(
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   201
        const QList<HbIndicatorInterface*> &activeIndicators)
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   202
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   203
    mIndicatorModel->handleActiveIndicators(activeIndicators);
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   204
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   205
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   206
/*!
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   207
    @copydoc Screensaver::onHandleActivatedIndicator
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   208
 */
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   209
void SnsrBigClockScreensaver::onHandleActivatedIndicator(
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   210
        HbIndicatorInterface *activatedIndicator)
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   211
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   212
    mIndicatorModel->handleActivatedIndicator(activatedIndicator);
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   213
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   214
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   215
/*!
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   216
    @copydoc Screensaver::onHandleDeactivatedIndicator
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   217
 */
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   218
void SnsrBigClockScreensaver::onHandleDeactivatedIndicator(
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   219
        HbIndicatorInterface *deactivatedIndicator)
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   220
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   221
    mIndicatorModel->handleDeactivatedIndicator(deactivatedIndicator);
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   222
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   223
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   224
/*!
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   225
    @copydoc Screensaver::currentPowerMode
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   226
 */
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   227
Screensaver::ScreenPowerMode SnsrBigClockScreensaver::currentPowerMode()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   228
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   229
    Screensaver::ScreenPowerMode mode( Screensaver::ScreenModeFullPower );
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   230
    if ( mCurrentContainer ) {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   231
        mode = mCurrentContainer->displayPowerMode();
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   232
    }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   233
    else {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   234
        qWarning() << "No current container when current power mode queried.";
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   235
    }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   236
    return mode;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   237
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   238
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   239
/*!
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   240
    @copydoc Screensaver::getActiveScreenRows
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   241
 */
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   242
void SnsrBigClockScreensaver::getActiveScreenRows(int *firstActiveRow, int *lastActiveRow)
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   243
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   244
    if ( mCurrentContainer ) {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   245
        mCurrentContainer->getActiveScreenRows( firstActiveRow, lastActiveRow );
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   246
    }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   247
    else {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   248
        qWarning() << "No current container when active rows queried.";
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   249
    }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   250
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   251
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   252
/*!
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   253
    @copydoc Screensaver::updateLayout
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   254
 */
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   255
void SnsrBigClockScreensaver::updateLayout()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   256
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   257
    if ( mCurrentContainer ) {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   258
        if ( mCurrentContainer->isOrientationLocked() ) {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   259
            // TODO: There is currently no way for device dialog to lock the display orientation.
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   260
            // Orbit team has a backlog item about "global orientation lock" which could be
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   261
            // used here when it is available.
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   262
        }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   263
        else {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   264
            // TODO: There is currently no way for device dialog to lock the display orientation.
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   265
            // Orbit team has a backlog item about "global orientation lock" which could be
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   266
            // used here when it is available.
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   267
        }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   268
        mCurrentContainer->changeLayout( mMainWindow->orientation() );
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   269
    }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   270
    else {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   271
        qWarning() << "No current container when updateLayout called.";
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   272
    }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   273
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   274
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   275
/*!
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   276
    Update clock time when timer is triggered
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   277
 */
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   278
void SnsrBigClockScreensaver::updateTime()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   279
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   280
    if ( mCurrentContainer ) {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   281
        mCurrentContainer->update();
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   282
        
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   283
        // Move the active area of display device if current container uses the power save mode.
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   284
        if ( mCurrentContainer->displayPowerMode() == Screensaver::ScreenModeLowPower ) {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   285
            emit activeAreaMoved();
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   286
        }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   287
        
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   288
        // Ensure correct update interval is used. First timed update may be done
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   289
        // with timeout differing from the normal update rate.
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   290
        int updateInterval = mCurrentContainer->updateIntervalInMilliseconds();
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   291
        if ( updateInterval > 0 ) {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   292
            mTimer.setInterval( updateInterval );
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   293
        }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   294
    }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   295
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   296
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   297
/*!
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   298
    Determines the curent clock format settings.
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   299
    \retval ClockFormat.
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   300
 */
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   301
SnsrBigClockScreensaver::ClockFormat SnsrBigClockScreensaver::clockFormat()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   302
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   303
#ifdef Q_OS_SYMBIAN
98
hgs
parents: 97
diff changeset
   304
    XQSettingsManager::Error error;
hgs
parents: 97
diff changeset
   305
    XQCentralRepositorySettingsKey settingsKey(
hgs
parents: 97
diff changeset
   306
        KCRUidClockApp, KClockType ); 
hgs
parents: 97
diff changeset
   307
    XQSettingsManager setManager;
hgs
parents: 97
diff changeset
   308
    int useDigital = setManager.readItemValue(settingsKey, XQSettingsManager::TypeInt).toInt();
hgs
parents: 97
diff changeset
   309
    error = setManager.error();
hgs
parents: 97
diff changeset
   310
    if (error != XQSettingsManager::NoError) {
hgs
parents: 97
diff changeset
   311
        qDebug("Error reading clock format from XQSettingsManager.. error = %d", error);
97
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   312
    }
98
hgs
parents: 97
diff changeset
   313
    return ( useDigital ? ClockFormatDigital : ClockFormatAnalog );
97
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   314
#else
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   315
    // windows build - change the format every 30 seconds for testing purposes
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   316
    if (QTime::currentTime().second() < 30) {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   317
        return ClockFormatAnalog;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   318
    } else {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   319
        return ClockFormatDigital;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   320
    }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   321
#endif // Q_OS_SYMBIAN
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   322
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   323
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   324
void SnsrBigClockScreensaver::removeCurrentContainer()
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   325
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   326
    if ( mCurrentContainer ) {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   327
        if (mTimer.timerId()!= -1) {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   328
            mTimer.stop();
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   329
        }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   330
        emit viewChanged(0);
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   331
        
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   332
        delete mCurrentContainer;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   333
        mCurrentContainer = 0;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   334
    }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   335
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   336
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   337
void SnsrBigClockScreensaver::setCurrentContainer( SnsrBigClockContainer* newContainer )
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   338
{
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   339
    mCurrentContainer = newContainer;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   340
    mCurrentContainer->setParent(this);
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   341
    connect( mCurrentContainer, SIGNAL(unlockRequested()), SIGNAL(unlockRequested()) );
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   342
    
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   343
    mCurrentContainer->setIndicatorModel(*mIndicatorModel);
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   344
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   345
    int updateInterval = mCurrentContainer->updateIntervalInMilliseconds(); 
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   346
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   347
    // In case the container needs an update seldomly (at maximum once per minute),
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   348
    // align these updates with the even minutes by doing the first update on the
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   349
    // next even minute.
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   350
    const int minute = 60*1000;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   351
    if ( updateInterval >= minute ) {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   352
        updateInterval = minute - QTime::currentTime().second()*1000;
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   353
    }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   354
    // container can use negative updateInteval value to indicate that no recurring
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   355
    // updates are needed
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   356
    if ( updateInterval > 0 ) {
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   357
        mTimer.start(updateInterval);
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   358
    }
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   359
    
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   360
    emit viewChanged(mCurrentContainer);
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   361
}
66b5fe3c07fd 201039_01
hgs
parents:
diff changeset
   362