src/hbinput/inputwidgets/hbinputcharpreviewpane.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
    25 // Qt includes
    25 // Qt includes
    26 #include <QGraphicsLinearLayout>
    26 #include <QGraphicsLinearLayout>
    27 #include <QSignalMapper>
    27 #include <QSignalMapper>
    28 #include <QPainter>
    28 #include <QPainter>
    29 #include <QSizePolicy>
    29 #include <QSizePolicy>
    30 
       
    31 #if QT_VERSION >= 0x040600
       
    32 #include <QGraphicsDropShadowEffect>
    30 #include <QGraphicsDropShadowEffect>
    33 #endif
       
    34 
    31 
    35 #include <hbeffect.h>
    32 #include <hbeffect.h>
    36 #include <hbinputsettingproxy.h>
    33 #include <hbinputsettingproxy.h>
    37 #include <hbmainwindow.h>
    34 #include <hbmainwindow.h>
    38 #include <hbcolorscheme.h>
    35 #include <hbcolorscheme.h>
    49 
    46 
    50 const int HbPreviewZoomDelta = 7;
    47 const int HbPreviewZoomDelta = 7;
    51 const qreal HbPreviewBoundaryDelta = 1.5;
    48 const qreal HbPreviewBoundaryDelta = 1.5;
    52 const qreal HbBoundaryLabelWidthFactor = 0.75;
    49 const qreal HbBoundaryLabelWidthFactor = 0.75;
    53 const qreal HbLabelwidthFactor = 0.50;
    50 const qreal HbLabelwidthFactor = 0.50;
       
    51 
    54 /// @cond
    52 /// @cond
    55 
    53 
    56 /*
    54 /*
    57 Character preview widget for Accented characters.
    55 Character preview widget for Accented characters.
    58 Implements character preview for characters mapped in the preview Pane.
    56 Implements character preview for characters mapped in the preview Pane.
    64     Constructor.
    62     Constructor.
    65     @param parent of the widget.
    63     @param parent of the widget.
    66     */
    64     */
    67     HbAccentedCharPreviewPane(QGraphicsItem *parent = 0)
    65     HbAccentedCharPreviewPane(QGraphicsItem *parent = 0)
    68         :HbWidget(parent),
    66         :HbWidget(parent),
    69         mFramePrim(0),
       
    70         mTextItem(0)
    67         mTextItem(0)
    71     {
    68     {
    72         mFramePrim = static_cast<HbFrameItem*>(style()->createPrimitive(HbStyle::P_Popup_background, this));
    69         HbFrameItem *n = new HbFrameItem(parent);
       
    70         n->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
    71         n->frameDrawer().setFrameGraphicsName("qtg_fr_character_preview");
       
    72 
       
    73 
       
    74         setBackgroundItem( n );
    73         mTextItem = static_cast<HbTextItem*>(style()->createPrimitive(HbStyle::P_Label_text, this));
    75         mTextItem = static_cast<HbTextItem*>(style()->createPrimitive(HbStyle::P_Label_text, this));
    74     }
    76     }
    75     /*!
    77     /*!
    76     update the text and frame primitives
    78     update the text and frame primitives
    77     */
    79     */
    78     void updatePrimitives()
    80     void updatePrimitives()
    79     {
    81     {
    80         if (mFramePrim) {
    82         HbWidget::updatePrimitives();
    81             mFramePrim->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
    83         if (mTextItem) {
    82             mFramePrim->frameDrawer().setFrameGraphicsName("qtg_fr_character_preview");
       
    83             mTextItem->setFontSpec(HbFontSpec(HbFontSpec::Primary));
    84             mTextItem->setFontSpec(HbFontSpec(HbFontSpec::Primary));
    84             mTextItem->setAlignment(Qt::AlignCenter);
    85             mTextItem->setAlignment(Qt::AlignCenter);
    85         }
    86         }
    86     }
    87     }
    87     /*!
    88     /*!
    88     Destroys the object.
    89     Destroys the object.
    89     */
    90     */
    90     ~HbAccentedCharPreviewPane() {
    91     ~HbAccentedCharPreviewPane() {
    91     }
    92     }
       
    93 
    92 public:
    94 public:
    93     HbFrameItem* mFramePrim;
       
    94     HbTextItem* mTextItem;
    95     HbTextItem* mTextItem;
    95 };
    96 };
    96 
    97 
    97 class HbCharPreviewPanePrivate: public HbDialogPrivate
    98 class HbCharPreviewPanePrivate: public HbDialogPrivate
    98 {
    99 {
   111     void _q_hidePreviewPanePopup();
   112     void _q_hidePreviewPanePopup();
   112 public:
   113 public:
   113     QStringList mCharacterList;
   114     QStringList mCharacterList;
   114     QSignalMapper *mReleaseMapper;
   115     QSignalMapper *mReleaseMapper;
   115     QGraphicsLinearLayout* mCandLayout;
   116     QGraphicsLinearLayout* mCandLayout;
   116     HbFrameItem* mFramePrim;
       
   117     QSizeF mItemSize;
   117     QSizeF mItemSize;
   118     HbAccentedCharPreviewPane* mAccentedPreviewPane;
   118     HbAccentedCharPreviewPane* mAccentedPreviewPane;
   119 };
   119 };
   120 
   120 
   121 void HbCharPreviewPanePrivate::init()
   121 void HbCharPreviewPanePrivate::init()
   122 {
   122 {
   123     Q_Q(HbCharPreviewPane);
   123     Q_Q(HbCharPreviewPane);
   124     mFramePrim = static_cast<HbFrameItem*>(q->primitive(HbStyle::P_Popup_background));
   124 
   125 
   125     HbFrameItem *n = new HbFrameItem( q );
   126     if (!mFramePrim) {
   126     n->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
   127         mFramePrim = static_cast<HbFrameItem*>(q->style()->createPrimitive(HbStyle::P_Popup_background, q));
   127     n->frameDrawer().setFrameGraphicsName("qtg_fr_character_preview");
   128     }
   128 
       
   129     q->setBackgroundItem( n );
   129 }
   130 }
   130 
   131 
   131 HbCharPreviewPanePrivate::HbCharPreviewPanePrivate()
   132 HbCharPreviewPanePrivate::HbCharPreviewPanePrivate()
   132     : mReleaseMapper(0),
   133     : mReleaseMapper(0),
   133     mCandLayout(0),
   134     mCandLayout(0)
   134     mFramePrim(0)
       
   135 {
   135 {
   136     mAccentedPreviewPane = new HbAccentedCharPreviewPane();
   136     mAccentedPreviewPane = new HbAccentedCharPreviewPane();
   137 }
   137 }
   138 
   138 
   139 HbCharPreviewPanePrivate::~HbCharPreviewPanePrivate()
   139 HbCharPreviewPanePrivate::~HbCharPreviewPanePrivate()
   185 
   185 
   186     mCandLayout->setContentsMargins(mItemSize.width() / 4, 0, mItemSize.width() / 4, 0);
   186     mCandLayout->setContentsMargins(mItemSize.width() / 4, 0, mItemSize.width() / 4, 0);
   187     mCandLayout->updateGeometry();
   187     mCandLayout->updateGeometry();
   188     q->adjustSize();
   188     q->adjustSize();
   189 }
   189 }
       
   190 
   190 /*!
   191 /*!
   191 Sets the character for preview and shows in it's Pane.
   192 Sets the character for preview and shows in it's Pane.
   192 @param character The character for preview.
   193 @param character The character for preview.
   193 @param itemSceneBoundingRect of the QGraphicsItem.
   194 @param itemSceneBoundingRect of the QGraphicsItem.
   194 */
   195 */
   254 
   255 
   255 /*!
   256 /*!
   256 @proto
   257 @proto
   257 @hbinput
   258 @hbinput
   258 \class HbCharPreviewPane
   259 \class HbCharPreviewPane
       
   260 \deprecated class HbCharPreviewPane
   259 \brief Character preview widget for virtual keyboards.
   261 \brief Character preview widget for virtual keyboards.
   260 
   262 
   261 
   263 
   262 Implements character preview for virtual keyboards. Shows a list of clickable
   264 Implements character preview for virtual keyboards. Shows a list of clickable
   263 characters and maps the clicks to owning keyboard's charFromPreviewSelected slot.
   265 characters and maps the clicks to owning keyboard's charFromPreviewSelected slot.
   266 on the lebel of preview pane we display preview of the accented character on the preview pane.
   268 on the lebel of preview pane we display preview of the accented character on the preview pane.
   267 
   269 
   268 \sa HbInputVkbWidget
   270 \sa HbInputVkbWidget
   269 \sa HbPreviewLabel
   271 \sa HbPreviewLabel
   270 */
   272 */
       
   273 
   271 /*!
   274 /*!
   272 Constructor.
   275 \deprecated HbCharPreviewPane::HbCharPreviewPane(QGraphicsItem*)
   273 @param parent of the widget.
   276     is deprecated.
   274 */
   277 */
   275 HbCharPreviewPane::HbCharPreviewPane(QGraphicsItem* parent)
   278 HbCharPreviewPane::HbCharPreviewPane(QGraphicsItem* parent)
   276     : HbDialog(*new HbCharPreviewPanePrivate, parent)
   279     : HbDialog(*new HbCharPreviewPanePrivate, parent)
   277 {
   280 {
   278     Q_D(HbCharPreviewPane);
   281     Q_D(HbCharPreviewPane);
   317     HbEffect::disable(this);
   320     HbEffect::disable(this);
   318 #endif // HB_EFFECTS
   321 #endif // HB_EFFECTS
   319 }
   322 }
   320 
   323 
   321 /*!
   324 /*!
   322 Destroys the object.
   325 \deprecated HbCharPreviewPane::~HbCharPreviewPane()
       
   326     is deprecated.
   323 */
   327 */
   324 HbCharPreviewPane::~HbCharPreviewPane()
   328 HbCharPreviewPane::~HbCharPreviewPane()
   325 {
   329 {
   326 }
   330 }
   327 
   331 
   328 /*!
   332 /*!
   329 Sets the list of characters for preview.
   333 \deprecated HbCharPreviewPane::showCharacters(const QStringList&, const QRectF &)
   330 @param characterList The character preview list.
   334     is deprecated.
   331 @param itemSceneBoundingRect of the QGraphicsItem.
       
   332 */
   335 */
   333 void HbCharPreviewPane::showCharacters(const QStringList& characterList, const QRectF &itemSceneBoundingRect)
   336 void HbCharPreviewPane::showCharacters(const QStringList& characterList, const QRectF &itemSceneBoundingRect)
   334 {
   337 {
   335     Q_D(HbCharPreviewPane);
   338     Q_D(HbCharPreviewPane);
   336     // let's validate.
   339     // let's validate.
   390     // preview pane. since popup closes on mouse release event. To aviod this situation we
   393     // preview pane. since popup closes on mouse release event. To aviod this situation we
   391     // need to reset mousePressLocation. Since this behaviour is very specific to preview pane
   394     // need to reset mousePressLocation. Since this behaviour is very specific to preview pane
   392     // we need to fix it here.
   395     // we need to fix it here.
   393     d->mousePressLocation = HbPopupPrivate::None;
   396     d->mousePressLocation = HbPopupPrivate::None;
   394 
   397 
       
   398 	// set the background as a panel if the foreground is a panel to provide focus handling
       
   399 	if ((flags() & QGraphicsItem::ItemIsPanel) && isModal()) {
       
   400 		d->backgroundItem->setFlag(QGraphicsItem::ItemIsPanel);
       
   401 	}
   395     // show it!
   402     // show it!
   396     show();
   403     show();
   397 }
   404 }
   398 
   405 
   399 void HbCharPreviewPane::updatePrimitives()
       
   400 {
       
   401     Q_D(HbCharPreviewPane);
       
   402     d->mFramePrim->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
   403     d->mFramePrim->frameDrawer().setFrameGraphicsName("qtg_fr_character_preview");
       
   404     d->mFramePrim->setGeometry(boundingRect());
       
   405 }
       
   406 
       
   407 #include "moc_hbinputcharpreviewpane.cpp"
   406 #include "moc_hbinputcharpreviewpane.cpp"
   408 // End Of File
   407 // End Of File
       
   408