homescreenapp/hsdomainmodel/inc/hsconfiguration.h
branchRCL_3
changeset 82 5f0182e07bfb
equal deleted inserted replaced
79:f00a6757af32 82:5f0182e07bfb
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef HSCONFIGURATION_H
       
    19 #define HSCONFIGURATION_H
       
    20 
       
    21 #include <QObject>
       
    22 #include <QVariant>
       
    23 #include <QEasingCurve>
       
    24 
       
    25 #include <HbFeedback>
       
    26 
       
    27 #include "hsdomainmodel_global.h"
       
    28 
       
    29 #include "hstest_global.h"
       
    30 HOMESCREEN_TEST_CLASS(TestHsDomainModel)
       
    31 
       
    32 #define HSCONFIGURATION_GET(getter) \
       
    33     HsConfiguration::instance()->getter()
       
    34 #define HSCONFIGURATION_SET(setter, value) \
       
    35     HsConfiguration::instance()->setter(value)
       
    36 
       
    37 class HSDOMAINMODEL_EXPORT HsConfiguration : public QObject
       
    38 {
       
    39     Q_OBJECT
       
    40     Q_PROPERTY(int bounceEffect READ bounceEffect WRITE setBounceEffect)
       
    41     Q_PROPERTY(int pageChangeAnimationDuration READ pageChangeAnimationDuration WRITE setPageChangeAnimationDuration)
       
    42     Q_PROPERTY(int pageChangeZoneAnimationDuration READ pageChangeZoneAnimationDuration WRITE setPageChangeZoneAnimationDuration)
       
    43     Q_PROPERTY(int pageChangeZoneReverseAnimationDuration READ pageChangeZoneReverseAnimationDuration WRITE setPageChangeZoneReverseAnimationDuration)
       
    44     Q_PROPERTY(int pageRemovedAnimationDuration READ pageRemovedAnimationDuration WRITE setPageRemovedAnimationDuration)
       
    45     Q_PROPERTY(int newPageAddedAnimationDuration READ newPageAddedAnimationDuration WRITE setNewPageAddedAnimationDuration)
       
    46     Q_PROPERTY(int widgetDragEffectDuration READ widgetDragEffectDuration WRITE setWidgetDragEffectDuration)
       
    47     Q_PROPERTY(int widgetDropEffectDuration READ widgetDropEffectDuration WRITE setWidgetDropEffectDuration)
       
    48     Q_PROPERTY(int defaultPageId READ defaultPageId WRITE setDefaultPageId)
       
    49     Q_PROPERTY(int maximumPageCount READ maximumPageCount WRITE setMaximumPageCount)
       
    50     Q_PROPERTY(bool isShortcutLabelVisible READ isShortcutLabelVisible WRITE setShortcutLabelVisible)
       
    51     Q_PROPERTY(qreal bounceFeedbackEffectDistance READ bounceFeedbackEffectDistance WRITE setBounceFeedbackEffectDistance)
       
    52     Q_PROPERTY(qreal pageChangeZoneWidth READ pageChangeZoneWidth WRITE setPageChangeZoneWidth)
       
    53     Q_PROPERTY(qreal pageIndicatorSpacing READ pageIndicatorSpacing WRITE setPageIndicatorSpacing)
       
    54     Q_PROPERTY(qreal maximumWidgetHeight READ maximumWidgetHeight WRITE setMaximumWidgetHeight)
       
    55     Q_PROPERTY(qreal maximumWidgetWidth READ maximumWidgetWidth WRITE setMaximumWidgetWidth)
       
    56     Q_PROPERTY(qreal minimumWidgetHeight READ minimumWidgetHeight WRITE setMinimumWidgetHeight)
       
    57     Q_PROPERTY(qreal minimumWidgetWidth READ minimumWidgetWidth WRITE setMinimumWidgetWidth)
       
    58     Q_PROPERTY(qreal pageChangePanDistance READ pageChangePanDistance WRITE setPageChangePanDistance)
       
    59     Q_PROPERTY(HbFeedback::InstantEffect pageChangeFeedbackEffect READ pageChangeFeedbackEffect WRITE setPageChangeFeedbackEffect)
       
    60     Q_PROPERTY(HbFeedback::InstantEffect widgetPickFeedbackEffect READ widgetPickFeedbackEffect WRITE setWidgetPickFeedbackEffect)
       
    61     Q_PROPERTY(HbFeedback::InstantEffect widgetDropFeedbackEffect READ widgetDropFeedbackEffect WRITE setWidgetDropFeedbackEffect)
       
    62     Q_PROPERTY(HbFeedback::InstantEffect widgetRepositionFeedbackEffect READ widgetRepositionFeedbackEffect WRITE setWidgetRepositionFeedbackEffect)
       
    63     Q_PROPERTY(HbFeedback::InstantEffect widgetOverTrashbinFeedbackEffect READ widgetOverTrashbinFeedbackEffect WRITE setWidgetOverTrashbinFeedbackEffect)
       
    64     Q_PROPERTY(HbFeedback::InstantEffect widgetDropToTrashbinFeedbackEffect READ widgetDropToTrashbinFeedbackEffect WRITE setWidgetDropToTrashbinFeedbackEffect)
       
    65     Q_PROPERTY(HbFeedback::InstantEffect shortcutWidgetTapFeedbackEffect READ shortcutWidgetTapFeedbackEffect WRITE setShortcutWidgetTapFeedbackEffect)
       
    66     Q_PROPERTY(HbFeedback::InstantEffect widgetMoveBlockedFeedbackEffect READ widgetMoveBlockedFeedbackEffect WRITE setWidgetMoveBlockedFeedbackEffect)
       
    67     Q_PROPERTY(HbFeedback::InstantEffect clockWidgetTapFeedbackEffect READ clockWidgetTapFeedbackEffect WRITE setClockWidgetTapFeedbackEffect)
       
    68     Q_PROPERTY(HbFeedback::InstantEffect widgetSnappingFeedbackEffect READ widgetSnappingFeedbackEffect WRITE setWidgetSnappingFeedbackEffect)
       
    69     Q_PROPERTY(bool isSnapEnabled READ isSnapEnabled WRITE setSnapEnabled)
       
    70     Q_PROPERTY(int snapTimeout READ snapTimeout WRITE setSnapTimeout)
       
    71     Q_PROPERTY(qreal snapForce READ snapForce WRITE setSnapForce)
       
    72     Q_PROPERTY(qreal snapGap READ snapGap WRITE setSnapGap)
       
    73     Q_PROPERTY(qreal pageMargin READ pageMargin WRITE setPageMargin)
       
    74     Q_PROPERTY(int snapLineFadeInDuration READ snapLineFadeInDuration WRITE setSnapLineFadeInDuration)
       
    75     Q_PROPERTY(int snapLineFadeOutDuration READ snapLineFadeOutDuration WRITE setSnapLineFadeOutDuration)
       
    76     Q_PROPERTY(bool isSnapEffectsEnabled READ isSnapEffectsEnabled WRITE setSnapEffectsEnabled)
       
    77     Q_PROPERTY(SceneType sceneType READ sceneType WRITE setSceneType)
       
    78     Q_PROPERTY(QEasingCurve::Type bounceAnimationEasingCurve READ bounceAnimationEasingCurve WRITE setBounceAnimationEasingCurve)
       
    79     Q_PROPERTY(QEasingCurve::Type pageChangeAnimationEasingCurve READ pageChangeAnimationEasingCurve WRITE setPageChangeAnimationEasingCurve)
       
    80 
       
    81     Q_ENUMS(SceneType)
       
    82 
       
    83 public:
       
    84     HsConfiguration(QObject *parent = 0);
       
    85     ~HsConfiguration();
       
    86 
       
    87     enum SceneType
       
    88     {
       
    89         PageWallpapers,
       
    90         SceneWallpaper
       
    91     };
       
    92 
       
    93 #define SETVALUE(member, name) \
       
    94     if (member != value) { \
       
    95         member = value; \
       
    96         emit propertyChanged(name); \
       
    97     }
       
    98 
       
    99     int bounceEffect() const { return mBounceEffect; }
       
   100     void setBounceEffect(int value) { SETVALUE(mBounceEffect, "bounceEffect") }
       
   101     int pageChangeAnimationDuration() const { return mPageChangeAnimationDuration; }
       
   102     void setPageChangeAnimationDuration(int value) { SETVALUE(mPageChangeAnimationDuration, "pageChangeAnimationDuration") }
       
   103     int pageChangeZoneAnimationDuration() const { return mPageChangeZoneAnimationDuration; }
       
   104     void setPageChangeZoneAnimationDuration(int value) { SETVALUE(mPageChangeZoneAnimationDuration, "pageChangeZoneAnimationDuration") }
       
   105     int pageChangeZoneReverseAnimationDuration() const { return mPageChangeZoneReverseAnimationDuration; }
       
   106     void setPageChangeZoneReverseAnimationDuration(int value) { SETVALUE(mPageChangeZoneReverseAnimationDuration, "pageChangeZoneReverseAnimationDuration") }
       
   107     int pageRemovedAnimationDuration() const { return mPageRemovedAnimationDuration; }
       
   108     void setPageRemovedAnimationDuration(int value) { SETVALUE(mPageRemovedAnimationDuration, "pageRemovedAnimationDuration") }
       
   109     int newPageAddedAnimationDuration() const { return mNewPageAddedAnimationDuration; }
       
   110     void setNewPageAddedAnimationDuration(int value) { SETVALUE(mNewPageAddedAnimationDuration, "newPageAddedAnimationDuration") }
       
   111     int widgetDragEffectDuration() const { return mWidgetDragEffectDuration; }
       
   112     void setWidgetDragEffectDuration(int value) { SETVALUE(mWidgetDragEffectDuration, "widgetDragEffectDuration") }
       
   113     int widgetDropEffectDuration() const { return mWidgetDropEffectDuration; }
       
   114     void setWidgetDropEffectDuration(int value) { SETVALUE(mWidgetDropEffectDuration, "widgetDropEffectDuration") }
       
   115     int defaultPageId() const { return mDefaultPageId; }
       
   116     void setDefaultPageId(int value) { SETVALUE(mDefaultPageId, "defaultPageId") }
       
   117     int maximumPageCount() const { return mMaximumPageCount; }
       
   118     void setMaximumPageCount(int value) { SETVALUE(mMaximumPageCount, "maximumPageCount") }
       
   119     bool isShortcutLabelVisible() const { return mIsShortcutLabelVisible; }
       
   120     void setShortcutLabelVisible(bool value) { SETVALUE(mIsShortcutLabelVisible, "isShortcutLabelVisible") }
       
   121     qreal bounceFeedbackEffectDistance() const { return mBounceFeedbackEffectDistance; }
       
   122     void setBounceFeedbackEffectDistance(qreal value) { SETVALUE(mBounceFeedbackEffectDistance, "bounceFeedbackEffectDistance") }
       
   123     qreal pageChangeZoneWidth() const { return mPageChangeZoneWidth; }
       
   124     void setPageChangeZoneWidth(qreal value) { SETVALUE(mPageChangeZoneWidth, "pageChangeZoneWidth") }
       
   125     qreal pageIndicatorSpacing() const { return mPageIndicatorSpacing; }
       
   126     void setPageIndicatorSpacing(qreal value) { SETVALUE(mPageIndicatorSpacing, "pageIndicatorSpacing") }
       
   127     qreal maximumWidgetHeight() const { return mMaximumWidgetHeight; }
       
   128     void setMaximumWidgetHeight(qreal value) { SETVALUE(mMaximumWidgetHeight, "maximumWidgetHeight") }
       
   129     qreal maximumWidgetWidth() const { return mMaximumWidgetWidth; }
       
   130     void setMaximumWidgetWidth(qreal value) { SETVALUE(mMaximumWidgetWidth, "maximumWidgetWidth") }
       
   131     qreal minimumWidgetHeight() const { return mMinimumWidgetHeight; }
       
   132     void setMinimumWidgetHeight(qreal value) { SETVALUE(mMinimumWidgetHeight, "minimumWidgetHeight") }
       
   133     qreal minimumWidgetWidth() const { return mMinimumWidgetWidth; }
       
   134     void setMinimumWidgetWidth(qreal value) { SETVALUE(mMinimumWidgetWidth, "minimumWidgetWidth") }
       
   135     qreal pageChangePanDistance() const { return mPageChangePanDistance; }
       
   136     void setPageChangePanDistance(qreal value) { SETVALUE(mPageChangePanDistance, "pageChangePanDistance") }
       
   137     HbFeedback::InstantEffect pageChangeFeedbackEffect() const { return mPageChangeFeedbackEffect; }
       
   138     void setPageChangeFeedbackEffect(HbFeedback::InstantEffect value) { SETVALUE(mPageChangeFeedbackEffect, "pageChangeFeedbackEffect") }
       
   139     HbFeedback::InstantEffect widgetPickFeedbackEffect() const { return mWidgetPickFeedbackEffect; }
       
   140     void setWidgetPickFeedbackEffect(HbFeedback::InstantEffect value) { SETVALUE(mWidgetPickFeedbackEffect, "widgetPickFeedbackEffect") }
       
   141     HbFeedback::InstantEffect widgetDropFeedbackEffect() const { return mWidgetDropFeedbackEffect; }
       
   142     void setWidgetDropFeedbackEffect(HbFeedback::InstantEffect value) { SETVALUE(mWidgetDropFeedbackEffect, "widgetDropFeedbackEffect") }
       
   143     HbFeedback::InstantEffect widgetRepositionFeedbackEffect() const { return mWidgetRepositionFeedbackEffect; }
       
   144     void setWidgetRepositionFeedbackEffect(HbFeedback::InstantEffect value) { SETVALUE(mWidgetRepositionFeedbackEffect, "widgetRepositionFeedbackEffect") }
       
   145     HbFeedback::InstantEffect widgetOverTrashbinFeedbackEffect() const { return mWidgetOverTrashbinFeedbackEffect; }
       
   146     void setWidgetOverTrashbinFeedbackEffect(HbFeedback::InstantEffect value) { SETVALUE(mWidgetOverTrashbinFeedbackEffect, "widgetOverTrashbinFeedbackEffect") }
       
   147     HbFeedback::InstantEffect widgetDropToTrashbinFeedbackEffect() const { return mWidgetDropToTrashbinFeedbackEffect; }
       
   148     void setWidgetDropToTrashbinFeedbackEffect(HbFeedback::InstantEffect value) { SETVALUE(mWidgetDropToTrashbinFeedbackEffect, "widgetDropToTrashbinFeedbackEffect") }
       
   149     HbFeedback::InstantEffect shortcutWidgetTapFeedbackEffect() const { return mShortcutWidgetTapFeedbackEffect; }
       
   150     void setShortcutWidgetTapFeedbackEffect(HbFeedback::InstantEffect value) { SETVALUE(mShortcutWidgetTapFeedbackEffect, "shortcutWidgetTapFeedbackEffect") }
       
   151     HbFeedback::InstantEffect widgetMoveBlockedFeedbackEffect() const { return mWidgetMoveBlockedFeedbackEffect; }
       
   152     void setWidgetMoveBlockedFeedbackEffect(HbFeedback::InstantEffect value) { SETVALUE(mWidgetMoveBlockedFeedbackEffect, "widgetMoveBlockedFeedbackEffect") }
       
   153     HbFeedback::InstantEffect clockWidgetTapFeedbackEffect() const { return mClockWidgetTapFeedbackEffect; }
       
   154     void setClockWidgetTapFeedbackEffect(HbFeedback::InstantEffect value) { SETVALUE(mClockWidgetTapFeedbackEffect, "clockWidgetTapFeedbackEffect") }
       
   155     HbFeedback::InstantEffect widgetSnappingFeedbackEffect() const { return mWidgetSnappingFeedbackEffect; }
       
   156     void setWidgetSnappingFeedbackEffect(HbFeedback::InstantEffect value) { SETVALUE(mWidgetSnappingFeedbackEffect, "widgetSnappingFeedbackEffect") }
       
   157     bool isSnapEnabled() const { return mIsSnapEnabled; }
       
   158     void setSnapEnabled(bool value) { SETVALUE(mIsSnapEnabled, "isSnapEnabled") }
       
   159     int snapTimeout() const { return mSnapTimeout; }
       
   160     void setSnapTimeout(int value) { SETVALUE(mSnapTimeout, "snapTimeout") }
       
   161     qreal snapForce() const { return mSnapForce; }
       
   162     void setSnapForce(qreal value) { SETVALUE(mSnapForce, "snapForce") }
       
   163     qreal snapGap() const { return mSnapGap; }
       
   164     void setSnapGap(qreal value) { SETVALUE(mSnapGap, "snapGap") }
       
   165     qreal pageMargin() const { return mPageMargin; }
       
   166     void setPageMargin(qreal value) { SETVALUE(mPageMargin, "pageMargin") }
       
   167     int snapLineFadeInDuration() const { return mSnapLineFadeInDuration; }
       
   168     void setSnapLineFadeInDuration(int value) { SETVALUE(mSnapLineFadeInDuration, "snapLineFadeInDuration") }
       
   169     int snapLineFadeOutDuration() const { return mSnapLineFadeOutDuration; }
       
   170     void setSnapLineFadeOutDuration(int value) { SETVALUE(mSnapLineFadeOutDuration, "snapLineFadeOutDuration") }
       
   171     bool isSnapEffectsEnabled() const { return mIsSnapEffectsEnabled; }
       
   172     void setSnapEffectsEnabled(bool value) { SETVALUE(mIsSnapEffectsEnabled, "isSnapEffectsEnabled") }
       
   173     SceneType sceneType() const { return mSceneType; }
       
   174     void setSceneType(SceneType value) { SETVALUE(mSceneType, "sceneType") }
       
   175     QEasingCurve::Type bounceAnimationEasingCurve() const { return mBounceAnimationEasingCurve; }
       
   176     void setBounceAnimationEasingCurve(QEasingCurve::Type value) { SETVALUE(mBounceAnimationEasingCurve, "bounceAnimationEasingCurve") }
       
   177     QEasingCurve::Type pageChangeAnimationEasingCurve() const { return mPageChangeAnimationEasingCurve; }
       
   178     void setPageChangeAnimationEasingCurve(QEasingCurve::Type value) { SETVALUE(mPageChangeAnimationEasingCurve, "pageChangeAnimationEasingCurve") }
       
   179 
       
   180 #undef SETVALUE
       
   181 
       
   182     QSizeF minimumWidgetSizeInUnits() const;
       
   183     QSizeF maximumWidgetSizeInUnits() const;
       
   184     QSizeF minimumWidgetSizeInPixels() const;
       
   185     QSizeF maximumWidgetSizeInPixels() const;
       
   186 
       
   187     bool load();
       
   188     bool importFromFile(const QString &path);
       
   189     bool exportToFile(const QString &path);
       
   190 
       
   191     static HsConfiguration *instance();
       
   192     static HsConfiguration *takeInstance();
       
   193     static void setInstance(HsConfiguration *instance);
       
   194 
       
   195 signals:
       
   196     void propertyChanged(const QString &name);
       
   197 
       
   198 private:
       
   199     Q_DISABLE_COPY(HsConfiguration)
       
   200 
       
   201 private:
       
   202     int mBounceEffect;
       
   203     int mPageChangeAnimationDuration;
       
   204     int mPageChangeZoneAnimationDuration;
       
   205     int mPageChangeZoneReverseAnimationDuration;
       
   206     int mPageRemovedAnimationDuration;
       
   207     int mNewPageAddedAnimationDuration;
       
   208     int mWidgetDragEffectDuration;
       
   209     int mWidgetDropEffectDuration;
       
   210     int mDefaultPageId;
       
   211     int mMaximumPageCount;
       
   212     bool mIsShortcutLabelVisible;
       
   213     qreal mBounceFeedbackEffectDistance;
       
   214     qreal mPageChangeZoneWidth;
       
   215     qreal mPageIndicatorSpacing;
       
   216     qreal mMaximumWidgetHeight;
       
   217     qreal mMaximumWidgetWidth;
       
   218     qreal mMinimumWidgetHeight;
       
   219     qreal mMinimumWidgetWidth;
       
   220     qreal mPageChangePanDistance;
       
   221     HbFeedback::InstantEffect mPageChangeFeedbackEffect;
       
   222     HbFeedback::InstantEffect mWidgetPickFeedbackEffect;
       
   223     HbFeedback::InstantEffect mWidgetDropFeedbackEffect;
       
   224     HbFeedback::InstantEffect mWidgetRepositionFeedbackEffect;
       
   225     HbFeedback::InstantEffect mWidgetOverTrashbinFeedbackEffect;
       
   226     HbFeedback::InstantEffect mWidgetDropToTrashbinFeedbackEffect;
       
   227     HbFeedback::InstantEffect mShortcutWidgetTapFeedbackEffect;
       
   228     HbFeedback::InstantEffect mWidgetMoveBlockedFeedbackEffect;
       
   229     HbFeedback::InstantEffect mClockWidgetTapFeedbackEffect;
       
   230     HbFeedback::InstantEffect mWidgetSnappingFeedbackEffect;
       
   231     bool mIsSnapEnabled;
       
   232     int mSnapTimeout;
       
   233     qreal mSnapForce;
       
   234     qreal mSnapGap;
       
   235     qreal mPageMargin;
       
   236     int mSnapLineFadeInDuration;
       
   237     int mSnapLineFadeOutDuration;
       
   238     bool mIsSnapEffectsEnabled;
       
   239     SceneType mSceneType;
       
   240     QEasingCurve::Type mBounceAnimationEasingCurve;
       
   241     QEasingCurve::Type mPageChangeAnimationEasingCurve;
       
   242     
       
   243     static HsConfiguration *mInstance;
       
   244 
       
   245     HOMESCREEN_TEST_FRIEND_CLASS(TestHsDomainModel)
       
   246 };
       
   247 
       
   248 #endif // HSCONFIGURATION_H