camerauis/cameraxui/cxui/src/cxuiprecaptureview.cpp
changeset 28 3075d9b614e6
parent 19 d9aefe59d544
child 38 0f0b4c1d7744
child 43 0e652f8f1fbd
equal deleted inserted replaced
19:d9aefe59d544 28:3075d9b614e6
    27 #include <hbtransparentwindow.h>
    27 #include <hbtransparentwindow.h>
    28 #include <hbmenu.h>
    28 #include <hbmenu.h>
    29 #include <hbdialog.h>
    29 #include <hbdialog.h>
    30 #include <hbdeviceprofile.h>
    30 #include <hbdeviceprofile.h>
    31 #include <hbnotificationdialog.h>
    31 #include <hbnotificationdialog.h>
       
    32 #include <hbmessagebox.h>
    32 #include <hbaction.h>
    33 #include <hbaction.h>
    33 #include <hbstyle.h>
    34 #include <hbstyle.h>
    34 #include <hbframeitem.h>
    35 #include <hbframeitem.h>
       
    36 #include <hbwidget.h>
    35 
    37 
    36 #include "cxeengine.h"
    38 #include "cxeengine.h"
    37 #include "cxeviewfindercontrol.h"
    39 #include "cxeviewfindercontrol.h"
    38 #include "cxezoomcontrol.h"
    40 #include "cxezoomcontrol.h"
    39 #include "cxecameradevicecontrol.h"
    41 #include "cxecameradevicecontrol.h"
    55 #include "OstTraceDefinitions.h"
    57 #include "OstTraceDefinitions.h"
    56 #ifdef OST_TRACE_COMPILER_IN_USE
    58 #ifdef OST_TRACE_COMPILER_IN_USE
    57 #include "cxuiprecaptureviewTraces.h"
    59 #include "cxuiprecaptureviewTraces.h"
    58 #endif
    60 #endif
    59 #include "cxuiserviceprovider.h"
    61 #include "cxuiserviceprovider.h"
       
    62 #include "cxuizoomslider.h"
    60 
    63 
    61 
    64 
    62 // CONSTANTS
    65 // CONSTANTS
    63 const int CXUI_HIDE_CONTROLS_TIMEOUT     = 6000; // 6 seconds
    66 const int CXUI_HIDE_CONTROLS_TIMEOUT     = 6000; // 6 seconds
    64 const QString PhotosAppExe = "photos.exe";
    67 const QString PhotosAppExe = "photos.exe";
    91     mWidgetsLoaded(false),
    94     mWidgetsLoaded(false),
    92     mSettingsDialog(NULL),
    95     mSettingsDialog(NULL),
    93     mSettingsDialogList(NULL),
    96     mSettingsDialogList(NULL),
    94     mKeyHandler(NULL),
    97     mKeyHandler(NULL),
    95     mQualityIcon(NULL),
    98     mQualityIcon(NULL),
       
    99     mIndicators(NULL),
    96     mSettingsDialogHeading(NULL),
   100     mSettingsDialogHeading(NULL),
    97     mSliderSettingsDialog(NULL),
   101     mSliderSettingsDialog(NULL),
    98     mSliderSettingsDialogHeading(NULL),
   102     mSliderSettingsDialogHeading(NULL),
    99     mSettingsSlider(NULL),
   103     mSettingsSlider(NULL),
   100     mSettingsInfo(NULL)
   104     mSettingsInfo(NULL),
       
   105     mSettingsDialogOkAction(NULL),
       
   106     mSliderSettingsDialogOkAction(NULL)
   101 {
   107 {
   102     CX_DEBUG_ENTER_FUNCTION();
   108     CX_DEBUG_ENTER_FUNCTION();
   103     mDisplayHandler = new CxuiDisplayPropertyHandler();
   109     mDisplayHandler = new CxuiDisplayPropertyHandler();
   104     CX_DEBUG_EXIT_FUNCTION();
   110     CX_DEBUG_EXIT_FUNCTION();
   105 }
   111 }
   247     mControlsVisible = false;
   253     mControlsVisible = false;
   248     if (mHideControlsTimeout.isActive()) {
   254     if (mHideControlsTimeout.isActive()) {
   249         mHideControlsTimeout.stop();
   255         mHideControlsTimeout.stop();
   250     }
   256     }
   251     hideToolbar();
   257     hideToolbar();
       
   258 
       
   259     // show indicators when controls are hidden
       
   260     showIndicators();
       
   261 
   252     // give the keyboard focus back to the view
   262     // give the keyboard focus back to the view
   253     // for the view to receive key events
   263     // for the view to receive key events
   254     setFocus();
   264     setFocus();
   255 
   265 
   256     CX_DEBUG_EXIT_FUNCTION();
   266     CX_DEBUG_EXIT_FUNCTION();
   325 {
   335 {
   326     if (mZoomVisible) {
   336     if (mZoomVisible) {
   327         hideZoom();
   337         hideZoom();
   328     } else {
   338     } else {
   329         showZoom();
   339         showZoom();
       
   340     }
       
   341 }
       
   342 
       
   343 // ---------------------------------------------------------------------------
       
   344 // CxuiPrecaptureView::hideIndicators
       
   345 //
       
   346 // ---------------------------------------------------------------------------
       
   347 //
       
   348 void CxuiPrecaptureView::hideIndicators()
       
   349 {
       
   350     if (mIndicators) {
       
   351         mIndicators->hide();
       
   352     }
       
   353 }
       
   354 
       
   355 // ---------------------------------------------------------------------------
       
   356 // CxuiPrecaptureView::showIndicators
       
   357 //
       
   358 // ---------------------------------------------------------------------------
       
   359 //
       
   360 void CxuiPrecaptureView::showIndicators()
       
   361 {
       
   362     if (mIndicators) {
       
   363         mIndicators->show();
   330     }
   364     }
   331 }
   365 }
   332 
   366 
   333 // ---------------------------------------------------------------------------
   367 // ---------------------------------------------------------------------------
   334 // CxuiPrecaptureView::showControls
   368 // CxuiPrecaptureView::showControls
   346             showToolbar();
   380             showToolbar();
   347             // show zoom
   381             // show zoom
   348             showZoom();
   382             showZoom();
   349             // show titlepane
   383             // show titlepane
   350             showItems(Hb::AllItems);
   384             showItems(Hb::AllItems);
       
   385 
       
   386             // hide indicators when controls are shown
       
   387             hideIndicators();
       
   388 
   351             mHideControlsTimeout.start();
   389             mHideControlsTimeout.start();
   352             mControlsVisible = true;
   390             mControlsVisible = true;
   353         }
   391         }
   354     }
   392     }
   355 }
   393 }
   428 //
   466 //
   429 // ---------------------------------------------------------------------------
   467 // ---------------------------------------------------------------------------
   430 //
   468 //
   431 void CxuiPrecaptureView::mousePressEvent(QGraphicsSceneMouseEvent *event)
   469 void CxuiPrecaptureView::mousePressEvent(QGraphicsSceneMouseEvent *event)
   432 {
   470 {
   433     if (event->type() == QEvent::GraphicsSceneMousePress) {
   471     //! @todo temporary workaround for title bar mouse event handling bug
       
   472     if (event->type() == QEvent::GraphicsSceneMousePress && event->scenePos().y() > 70) {
   434         toggleControls();
   473         toggleControls();
   435         event->accept();
   474         event->accept();
   436     }
   475     }
   437 }
   476 }
   438 
   477 
   682 
   721 
   683     mSettingsDialogList = qobject_cast<CxuiSettingRadioButtonList *>(
   722     mSettingsDialogList = qobject_cast<CxuiSettingRadioButtonList *>(
   684                                     documentLoader->findWidget(SETTINGS_DIALOG_CONTENT_WIDGET));
   723                                     documentLoader->findWidget(SETTINGS_DIALOG_CONTENT_WIDGET));
   685     CX_ASSERT_ALWAYS(mSettingsDialogList);
   724     CX_ASSERT_ALWAYS(mSettingsDialogList);
   686 
   725 
       
   726     QObject *object = documentLoader->findObject(SETTINGS_DIALOG_OK_ACTION);
       
   727     mSettingsDialogOkAction = qobject_cast<HbAction *>(object);
       
   728     CX_DEBUG_ASSERT(mSettingsDialogOkAction);
   687 
   729 
   688     CX_DEBUG_EXIT_FUNCTION();
   730     CX_DEBUG_EXIT_FUNCTION();
   689 
   731 
   690     delete documentLoader;
   732     delete documentLoader;
   691     documentLoader = NULL;
   733     documentLoader = NULL;
   735             // Store action that starts the dialog.
   777             // Store action that starts the dialog.
   736             // Dialog passes this along with it's signals,
   778             // Dialog passes this along with it's signals,
   737             // so we can easily decide if we show grid again or not.
   779             // so we can easily decide if we show grid again or not.
   738             mSettingsDialog->setStarterAction(qobject_cast<HbAction *>(action));
   780             mSettingsDialog->setStarterAction(qobject_cast<HbAction *>(action));
   739 
   781 
   740             HbAction *okAction = mSettingsDialog->primaryAction();
   782             if (mSettingsDialogOkAction) {
   741             if (okAction) {
   783                 // disconnect ok action from dialog so that dialog won't be closed
   742                 // disconnect primary action from dialog so that dialog won't be closed
       
   743                 // automatically when action is triggered. handleSelectionAccepted
   784                 // automatically when action is triggered. handleSelectionAccepted
   744                 // is called instead
   785                 // is called instead
   745                 okAction->disconnect(mSettingsDialog);
   786                 mSettingsDialogOkAction->disconnect(mSettingsDialog);
   746                 connect(okAction, SIGNAL(triggered()), mSettingsDialogList, SLOT(handleSelectionAccepted()));
   787                 connect(mSettingsDialogOkAction, SIGNAL(triggered()), mSettingsDialogList, SLOT(handleSelectionAccepted()));
   747 
   788 
   748                 // Close the dialog when new setting value is committed
   789                 // Close the dialog when new setting value is committed
   749                 connect(mSettingsDialogList, SIGNAL(selectionCommitted()), mSettingsDialog, SLOT(close()));
   790                 connect(mSettingsDialogList, SIGNAL(selectionCommitted()), mSettingsDialog, SLOT(close()));
   750 
   791 
   751                 connect(mSettingsDialog, SIGNAL(aboutToClose()), mSettingsDialogList, SLOT(handleClose()));
   792                 connect(mSettingsDialog, SIGNAL(aboutToClose()), mSettingsDialogList, SLOT(handleClose()));
   790 
   831 
   791     mSettingsSlider = qobject_cast<CxuiSettingSlider *>(
   832     mSettingsSlider = qobject_cast<CxuiSettingSlider *>(
   792                                     documentLoader->findWidget(SETTINGS_SLIDER_DIALOG_CONTENT_WIDGET));
   833                                     documentLoader->findWidget(SETTINGS_SLIDER_DIALOG_CONTENT_WIDGET));
   793     CX_ASSERT_ALWAYS(mSettingsSlider);
   834     CX_ASSERT_ALWAYS(mSettingsSlider);
   794 
   835 
       
   836     QObject *object = documentLoader->findObject(SETTINGS_DIALOG_OK_ACTION);
       
   837     mSliderSettingsDialogOkAction = qobject_cast<HbAction *>(object);
       
   838     CX_DEBUG_ASSERT(mSliderSettingsDialogOkAction);
   795 
   839 
   796     CX_DEBUG_EXIT_FUNCTION();
   840     CX_DEBUG_EXIT_FUNCTION();
   797 
   841 
   798     delete documentLoader;
   842     delete documentLoader;
   799     documentLoader = NULL;
   843     documentLoader = NULL;
   841             // Store action that starts the dialog.
   885             // Store action that starts the dialog.
   842             // Dialog passes this along with it's signals,
   886             // Dialog passes this along with it's signals,
   843             // so we can easily decide if we show grid again or not.
   887             // so we can easily decide if we show grid again or not.
   844             mSliderSettingsDialog->setStarterAction(qobject_cast<HbAction *>(action));
   888             mSliderSettingsDialog->setStarterAction(qobject_cast<HbAction *>(action));
   845 
   889 
   846             HbAction *okAction = mSliderSettingsDialog->primaryAction();
   890             if (mSliderSettingsDialogOkAction) {
   847             if (okAction) {
   891                 // disconnect ok action from dialog so that dialog won't be closed
   848                 // disconnect primary action from dialog so that dialog won't be closed
       
   849                 // automatically when action is triggered. handleSelectionAccepted
   892                 // automatically when action is triggered. handleSelectionAccepted
   850                 // is called instead
   893                 // is called instead
   851                 okAction->disconnect(mSliderSettingsDialog);
   894                 mSliderSettingsDialogOkAction->disconnect(mSliderSettingsDialog);
   852                 connect(okAction, SIGNAL(triggered()), mSettingsSlider, SLOT(handleSelectionAccepted()));
   895                 connect(mSliderSettingsDialogOkAction, SIGNAL(triggered()), mSettingsSlider, SLOT(handleSelectionAccepted()));
   853 
   896 
   854                 // Close the dialog when new setting value is committed
   897                 // Close the dialog when new setting value is committed
   855                 connect(mSettingsSlider, SIGNAL(selectionCommitted()), mSliderSettingsDialog, SLOT(close()));
   898                 connect(mSettingsSlider, SIGNAL(selectionCommitted()), mSliderSettingsDialog, SLOT(close()));
   856 
   899 
   857                 connect(mSliderSettingsDialog, SIGNAL(aboutToClose()), mSettingsSlider, SLOT(handleClose()));
   900                 connect(mSliderSettingsDialog, SIGNAL(aboutToClose()), mSettingsSlider, SLOT(handleClose()));
   889 * Show "not supported" notification.
   932 * Show "not supported" notification.
   890 */
   933 */
   891 void CxuiPrecaptureView::launchNotSupportedNotification()
   934 void CxuiPrecaptureView::launchNotSupportedNotification()
   892 {
   935 {
   893     CX_DEBUG_ENTER_FUNCTION();
   936     CX_DEBUG_ENTER_FUNCTION();
   894 
   937     HbNotificationDialog::launchDialog("Notification", "Not supported yet");
   895     // Instantiate a popup
   938     CX_DEBUG_EXIT_FUNCTION();
   896     HbNotificationDialog note;
   939 }
   897     note.setTitle("Notification");
   940 
   898     note.setText("Not supported yet");
   941 /*!
   899     note.exec();
   942 * Show "Disk full" notification.
   900 
   943 */
       
   944 void CxuiPrecaptureView::launchDiskFullNotification()
       
   945 {
       
   946     CX_DEBUG_ENTER_FUNCTION();
       
   947     HbMessageBox::warning(hbTrId("txt_cam_info_memory_full"));
   901     CX_DEBUG_EXIT_FUNCTION();
   948     CX_DEBUG_EXIT_FUNCTION();
   902 }
   949 }
   903 
   950 
   904 /**
   951 /**
   905 * Show settings grid.
   952 * Show settings grid.
   965 
  1012 
   966 /*!
  1013 /*!
   967 * Adding zoom buttons to the slider
  1014 * Adding zoom buttons to the slider
   968 * \param slider Pointer to the slider object, where the buttons will be added
  1015 * \param slider Pointer to the slider object, where the buttons will be added
   969 */
  1016 */
   970 void CxuiPrecaptureView::addIncreaseDecreaseButtons(HbSlider* slider)
  1017 void CxuiPrecaptureView::addIncreaseDecreaseButtons(CxuiZoomSlider *slider)
   971 {
  1018 {
   972     // get current slider elements
  1019     // get current slider elements
   973     QList<HbSlider::SliderElement> elements = slider->elements();
  1020     QList<QVariant> elements = slider->sliderElements();
       
  1021 
   974     // add increase and decrease elements to the slider
  1022     // add increase and decrease elements to the slider
   975     elements << HbSlider::IncreaseElement << HbSlider::DecreaseElement;
  1023     elements << HbSlider::IncreaseElement << HbSlider::DecreaseElement;
   976     slider->setElements(elements);
  1024     slider->setSliderElements(elements);
       
  1025 
   977     // set icons for the increase and decrease element
  1026     // set icons for the increase and decrease element
   978     slider->setIcon(HbSlider::DecreaseElement , HbIcon("qtg_mono_minus"));
  1027     slider->setElementIcon(HbSlider::DecreaseElement , HbIcon("qtg_mono_minus"));
   979     slider->setIcon(HbSlider::IncreaseElement , HbIcon("qtg_mono_plus"));
  1028     slider->setElementIcon(HbSlider::IncreaseElement , HbIcon("qtg_mono_plus"));
   980 }
  1029 }
   981 
  1030 
   982 
  1031 
   983 /*!
  1032 /*!
   984 * Function can be used to create a graphics item and setting it as a background
  1033 * Function can be used to create a graphics item and setting it as a background
   988 */
  1037 */
   989 void CxuiPrecaptureView::createWidgetBackgroundGraphic(HbWidget *widget,
  1038 void CxuiPrecaptureView::createWidgetBackgroundGraphic(HbWidget *widget,
   990                                                        const QString &graphicName,
  1039                                                        const QString &graphicName,
   991                                                        HbFrameDrawer::FrameType frameType)
  1040                                                        HbFrameDrawer::FrameType frameType)
   992 {
  1041 {
   993     HbFrameDrawer *drawer = new HbFrameDrawer(graphicName, frameType);
  1042     if (widget) {
   994 
  1043         HbFrameDrawer *drawer = new HbFrameDrawer(graphicName, frameType);
   995     if (drawer && widget) {
  1044 
   996         HbFrameItem *backgroundItem = new HbFrameItem(drawer, widget);
  1045         if (drawer) {
   997         if (backgroundItem) {
  1046             HbFrameItem *backgroundItem = new HbFrameItem(drawer, widget);
   998             // set item to fill the whole widget
  1047             if (backgroundItem) {
   999             backgroundItem->setGeometry(QRectF(QPointF(0, 0), widget->size()));
  1048                 // set item to fill the whole widget
  1000             backgroundItem->setZValue(0);
  1049                 backgroundItem->setGeometry(QRectF(QPointF(0, 0), widget->size()));
  1001             widget->setBackgroundItem(backgroundItem);
  1050                 backgroundItem->setZValue(0);
       
  1051                 widget->setBackgroundItem(backgroundItem);
       
  1052             }
  1002         }
  1053         }
  1003     }
  1054     }
  1004 }
  1055 }
  1005 
  1056 
  1006 /*!
  1057 /*!
  1032     \param value Setting value
  1083     \param value Setting value
  1033     \return Returns string containing icon locigal name
  1084     \return Returns string containing icon locigal name
  1034 */
  1085 */
  1035 QString CxuiPrecaptureView::getSettingItemIcon(const QString &key, QVariant value)
  1086 QString CxuiPrecaptureView::getSettingItemIcon(const QString &key, QVariant value)
  1036 {
  1087 {
       
  1088     CX_DEBUG_ENTER_FUNCTION();
  1037     CxUiSettings::RadioButtonListParams data;
  1089     CxUiSettings::RadioButtonListParams data;
  1038     QString icon = "";
  1090     QString icon = "";
  1039     if (mSettingsInfo && mSettingsInfo->getSettingsContent(key, data)) {
  1091     if (mSettingsInfo && mSettingsInfo->getSettingsContent(key, data)) {
  1040         CxUiSettings::SettingItem setting;
  1092         CxUiSettings::SettingItem setting;
  1041         foreach (setting, data.mSettingPairList) {
  1093         foreach (setting, data.mSettingPairList) {
  1043                 icon = setting.mIcon;
  1095                 icon = setting.mIcon;
  1044                 break;
  1096                 break;
  1045             }
  1097             }
  1046         }
  1098         }
  1047     }
  1099     }
       
  1100 
       
  1101     CX_DEBUG((("Setting icon name [%s]"), icon.toAscii().constData()));
       
  1102     CX_DEBUG_EXIT_FUNCTION();
  1048     return icon;
  1103     return icon;
  1049 }
  1104 }
  1050 
  1105 
  1051 /*!
  1106 /*!
  1052     Update the quality indicator
  1107     Update the quality indicator