controlpanelplugins/themeplugin/src/cpthemepreview.cpp
changeset 17 4a9568303383
parent 14 23411a3be0db
child 24 f5dfdd5e4a1b
equal deleted inserted replaced
15:cc79acdc26cb 17:4a9568303383
    16  */
    16  */
    17 
    17 
    18 #include <QString>
    18 #include <QString>
    19 #include <QGraphicsPixmapItem>
    19 #include <QGraphicsPixmapItem>
    20 #include <QGraphicsLinearLayout>
    20 #include <QGraphicsLinearLayout>
    21 #include <QDebug>
    21 
    22 #include <hbaction.h>
    22 #include <hbaction.h>
    23 #include <hbtoolbar.h>
    23 #include <hbtoolbar.h>
    24 #include <hbicon.h>
    24 #include <hbicon.h>
    25 #include <hbaction.h>
    25 #include <hbaction.h>
    26 #include <hblabel.h>
    26 #include <hblabel.h>
    50     QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical);
    50     QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical);
    51 
    51 
    52     
    52     
    53     //setup the heading.
    53     //setup the heading.
    54     //TODO: translation of string  hbTrId("txt_cp_title_preview_1")
    54     //TODO: translation of string  hbTrId("txt_cp_title_preview_1")
    55     
       
    56     QString themeHeading = tr("Preview: ") + mTheme.name;
    55     QString themeHeading = tr("Preview: ") + mTheme.name;
    57     HbLabel* label = new HbLabel(themeHeading, this);
    56     HbLabel* label = new HbLabel(themeHeading, this);
    58     label->setFontSpec(HbFontSpec(HbFontSpec::Primary));
    57     label->setFontSpec(HbFontSpec(HbFontSpec::Primary));
    59    
    58    
    60     label->setPreferredHeight(5.0);
       
    61     layout->addItem(label);
    59     layout->addItem(label);
    62     
    60     
    63     layout->setAlignment(layout->itemAt(0), Qt::AlignTop);
    61     layout->setAlignment(layout->itemAt(0), Qt::AlignTop);
    64     
    62     
    65     //Create the toolbar and "Select" and "Cancel" actions.
    63     //Create the toolbar and "Select" and "Cancel" actions.
    88     }
    86     }
    89     else {
    87     else {
    90         mPreviewIcon = new HbIconItem(mTheme.portraitPreviewIcon, this);
    88         mPreviewIcon = new HbIconItem(mTheme.portraitPreviewIcon, this);
    91     }
    89     }
    92     layout->addItem(mPreviewIcon);
    90     layout->addItem(mPreviewIcon);
    93     layout->setAlignment(layout->itemAt(0), Qt::AlignTop);
    91  
    94     
       
    95     setToolBar(mToolBar);
    92     setToolBar(mToolBar);
    96     setLayout(layout);
    93     setLayout(layout);
    97 
    94 
    98     //Setup the Back button action and set softkey. Back button 
    95     //Setup the Back button action and set softkey. Back button 
    99     //takes the user to the theme list view.
    96     //takes the user to the theme list view.
   100     mSoftKeyBackAction = new HbAction(Hb::BackNaviAction, this);
    97     mSoftKeyBackAction = new HbAction(Hb::BackNaviAction, this);
   101     QObject::connect(mSoftKeyBackAction, SIGNAL(triggered()), 
    98     QObject::connect(mSoftKeyBackAction, SIGNAL(triggered()), 
   102             this, SIGNAL(aboutToClose()) );
    99             this, SIGNAL(aboutToClose()) );
   103 
   100 
   104     this->setNavigationAction(mSoftKeyBackAction);
   101     setNavigationAction(mSoftKeyBackAction);
   105 }
   102 }
   106 
   103 
   107 /*!
   104 /*!
   108     destructor.
   105     destructor.
   109 */
   106 */
   150 void CpThemePreview::previewOrientationChanged(Qt::Orientation orientation)
   147 void CpThemePreview::previewOrientationChanged(Qt::Orientation orientation)
   151 {
   148 {
   152    
   149    
   153     QGraphicsLinearLayout* previewLayout = dynamic_cast<QGraphicsLinearLayout*>(layout());
   150     QGraphicsLinearLayout* previewLayout = dynamic_cast<QGraphicsLinearLayout*>(layout());
   154    
   151    
   155     if(mPreviewIcon == dynamic_cast<HbIconItem*>(previewLayout->itemAt(1)) ) {
   152     if(mPreviewIcon && mPreviewIcon == dynamic_cast<HbIconItem*>(previewLayout->itemAt(1)) ) {
   156         previewLayout->removeAt(1);
   153         previewLayout->removeAt(1);
   157         delete mPreviewIcon;
       
   158         mPreviewIcon = 0;
       
   159         
   154         
   160         if(orientation == Qt::Horizontal) {
   155         if(orientation == Qt::Horizontal) {
   161             mPreviewIcon = new HbIconItem(mTheme.landscapePreviewIcon, this);
   156             mPreviewIcon->setIcon(mTheme.landscapePreviewIcon);
   162         }
   157         }
   163         else {
   158         else {
   164             mPreviewIcon = new HbIconItem(mTheme.portraitPreviewIcon, this);
   159             mPreviewIcon->setIcon(mTheme.portraitPreviewIcon);
   165         }
   160         }
   166         
   161         
   167         previewLayout->addItem(mPreviewIcon);
   162         previewLayout->addItem(mPreviewIcon);
   168     }
   163     }
   169     
   164