screensaver/snsrplugins/snsrbigclockscreensaverplugin/src/snsrdigitalclockcontainer.cpp
changeset 98 e6f74eb7f69f
parent 97 66b5fe3c07fd
equal deleted inserted replaced
97:66b5fe3c07fd 98:e6f74eb7f69f
    21 #include <QTime>
    21 #include <QTime>
    22 #include <QGraphicsLinearLayout>
    22 #include <QGraphicsLinearLayout>
    23 
    23 
    24 #include <HbExtendedLocale>
    24 #include <HbExtendedLocale>
    25 #include <HbMainWindow>
    25 #include <HbMainWindow>
       
    26 #include <HbPushButton>
    26 
    27 
    27 #include "snsrswipewidget.h"
       
    28 #include "snsrindicatorwidget.h"
    28 #include "snsrindicatorwidget.h"
    29 #include "snsrlabel.h"
    29 #include "snsrlabel.h"
    30 
    30 
    31 /*!
    31 /*!
    32     \class SnsrDigitalClockContainer
    32     \class SnsrDigitalClockContainer
    33     \ingroup group_snsrbigclockscreensaverplugin
    33     \ingroup group_snsrbigclockscreensaverplugin
    34     \brief Container used for preparing layout for digital clock.
    34     \brief Container used for preparing layout for digital clock.
    35  */
    35  */
    36 
    36 
    37 const char *gDigitalLayoutDocml = ":/xml/snsrbigclockscreensaverdigital.docml";
    37 const char *gDigitalLayoutDocml = ":/xml/snsrbigclockscreensaverdigital.docml";
    38 const char *gSwipeDigitalLayoutDocml = ":/xml/snsrbigclockscreensaverdigitalswipe.docml";
    38 const char *gUnlockDigitalLayoutDocml = ":/xml/snsrbigclockscreensaverdigitalunlockbutton.docml";
    39 
    39 
    40 extern const char *gPortraitSectionName;
    40 extern const char *gPortraitSectionName;
    41 extern const char *gLandscapeSectionName;
    41 extern const char *gLandscapeSectionName;
    42 
    42 
    43 extern const char *gMainViewName;
    43 extern const char *gMainViewName;
    51 // This is same as r_qtn_time_usual_with_zero defined in
    51 // This is same as r_qtn_time_usual_with_zero defined in
    52 // hbi18ndef.h expect am/pm place holders are removed.
    52 // hbi18ndef.h expect am/pm place holders are removed.
    53 const char *gTimeFormatStr = "%:0%J%:1%T%:3";
    53 const char *gTimeFormatStr = "%:0%J%:1%T%:3";
    54 
    54 
    55 extern const char *gIndicatorWidgetName;
    55 extern const char *gIndicatorWidgetName;
    56 extern const char *gSwipeWidgetName;
    56 extern const char *gUnlockButtonName;
    57 
    57 
    58 
    58 
    59 /*!
    59 /*!
    60     Constructs a new SnsrDigitalClockContainer.
    60     Constructs a new SnsrDigitalClockContainer.
    61  */
    61  */
    62 SnsrDigitalClockContainer::SnsrDigitalClockContainer() :
    62 SnsrDigitalClockContainer::SnsrDigitalClockContainer() :
    63     SnsrBigClockContainer(),
    63     SnsrBigClockContainer(),
    64     mTimeLabel(0),
    64     mTimeLabel(0),
    65     mAmPmLabel(0),
    65     mAmPmLabel(0),
    66     mDateLabel(0),
    66     mDateLabel(0),
    67     mSwipeWidget(0)
    67     mUnlockButton(0)
    68 {
    68 {
    69     SCREENSAVER_TEST_FUNC_ENTRY("SnsrDigitalClockContainer::SnsrDigitalClockContainer")
    69     SCREENSAVER_TEST_FUNC_ENTRY("SnsrDigitalClockContainer::SnsrDigitalClockContainer")
    70     SCREENSAVER_TEST_FUNC_EXIT("SnsrDigitalClockContainer::SnsrDigitalClockContainer")
    70     SCREENSAVER_TEST_FUNC_EXIT("SnsrDigitalClockContainer::SnsrDigitalClockContainer")
    71 }
    71 }
    72 
    72 
   108     
   108     
   109     // date
   109     // date
   110     mDateLabel->setPlainText(
   110     mDateLabel->setPlainText(
   111         locale.format(QDate::currentDate(), gDateFormatStr)
   111         locale.format(QDate::currentDate(), gDateFormatStr)
   112         );
   112         );
   113     
       
   114     if (mSwipeWidget) {
       
   115         mSwipeWidget->setCurrentOrientation(mCurrentOrientation);
       
   116     }
       
   117 
   113 
   118     SCREENSAVER_TEST_FUNC_EXIT("SnsrDigitalClockContainer::update")
   114     SCREENSAVER_TEST_FUNC_EXIT("SnsrDigitalClockContainer::update")
   119 }
   115 }
   120 
   116 
   121 /*!
   117 /*!
   129 /*!
   125 /*!
   130     @copydoc SnsrBigClockContainer::loadWidgets()
   126     @copydoc SnsrBigClockContainer::loadWidgets()
   131  */
   127  */
   132 void SnsrDigitalClockContainer::loadWidgets()
   128 void SnsrDigitalClockContainer::loadWidgets()
   133 {
   129 {
   134     //if swipe is used we load the docml file containing it
   130     //if unlockbutton is used we load the docml file containing it
   135     if ( swipeToUnlockSupported() ) {
   131     if ( unlockButtonSupported() ) {
   136         loadWidgets(gSwipeDigitalLayoutDocml);
   132         loadWidgets(gUnlockDigitalLayoutDocml);
   137         Q_ASSERT_X( mSwipeWidget, gSwipeDigitalLayoutDocml, "Swipe widget not found in DocML file.");
   133         Q_ASSERT_X( mUnlockButton, gUnlockDigitalLayoutDocml, "Unlock button not found in DocML file.");
   138         connect( mSwipeWidget, SIGNAL(swipeDownDetected()), SIGNAL(unlockRequested()) );
   134         mUnlockButton->setText("Unlock");
       
   135         connect( mUnlockButton, SIGNAL(clicked()), SIGNAL(unlockRequested()) );
   139     }
   136     }
   140     else {
   137     else {
   141         loadWidgets(gDigitalLayoutDocml);
   138         loadWidgets(gDigitalLayoutDocml);
   142     }
   139     }
   143 }
   140 }
   153     mMainView = 0;
   150     mMainView = 0;
   154     mDateLabel = 0;
   151     mDateLabel = 0;
   155     mTimeLabel = 0;
   152     mTimeLabel = 0;
   156     mAmPmLabel = 0;
   153     mAmPmLabel = 0;
   157     mIndicatorWidget = 0;
   154     mIndicatorWidget = 0;
   158     mSwipeWidget = 0;
   155     mUnlockButton = 0;
   159     // load widgets from docml
   156     // load widgets from docml
   160     qDebug() << docmlName;
   157     qDebug() << docmlName;
   161     mDocumentObjects = mDocumentLoader.load(docmlName, &ok);
   158     mDocumentObjects = mDocumentLoader.load(docmlName, &ok);
   162     Q_ASSERT_X(ok, docmlName, "Invalid DocML file.");
   159     Q_ASSERT_X(ok, docmlName, "Invalid DocML file.");
   163     if (ok) {
   160     if (ok) {
   168                 mDocumentLoader.findWidget(gTimeLabelName));
   165                 mDocumentLoader.findWidget(gTimeLabelName));
   169         mAmPmLabel = qobject_cast<SnsrLabel *>(
   166         mAmPmLabel = qobject_cast<SnsrLabel *>(
   170                 mDocumentLoader.findWidget(gAmPmLabelName));
   167                 mDocumentLoader.findWidget(gAmPmLabelName));
   171         mIndicatorWidget = qobject_cast<SnsrIndicatorWidget *>(
   168         mIndicatorWidget = qobject_cast<SnsrIndicatorWidget *>(
   172                 mDocumentLoader.findWidget(gIndicatorWidgetName));
   169                 mDocumentLoader.findWidget(gIndicatorWidgetName));
   173         mSwipeWidget = qobject_cast<SnsrSwipeWidget *>(
   170         mUnlockButton = qobject_cast<HbPushButton *>(
   174             mDocumentLoader.findWidget(gSwipeWidgetName));
   171             mDocumentLoader.findWidget(gUnlockButtonName));
   175         
   172         
   176         Q_ASSERT_X(
   173         Q_ASSERT_X(
   177             mMainView && mDateLabel && mTimeLabel && mAmPmLabel &&
   174             mMainView && mDateLabel && mTimeLabel && mAmPmLabel &&
   178             mIndicatorWidget,
   175             mIndicatorWidget,
   179             docmlName, "Objects not found in DocML file."
   176             docmlName, "Objects not found in DocML file."