qtmobility/plugins/multimedia/symbian/camera/s60viewfinderwidget.cpp
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
child 5 453da2cfceef
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include "s60viewfinderwidget.h"
       
    43 
       
    44 #include <QtCore/qcoreevent.h>
       
    45 #include <QtCore/qdebug.h>
       
    46 #include <QtGui/qapplication.h>
       
    47 #include <QtGui/qpainter.h>
       
    48 #include <QtGui/qevent.h>
       
    49 
       
    50 #include <QtGui/private/qwidget_p.h>
       
    51 
       
    52 #include <coemain.h>    // For CCoeEnv
       
    53 #include <coecntrl.h>
       
    54 #include <w32std.h>
       
    55 
       
    56 #include <QTimer>
       
    57 
       
    58 S60ViewFinderWidget::S60ViewFinderWidget(QWidget *parent)
       
    59     : QWidget(parent)
       
    60 {
       
    61     setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
       
    62     QPalette palette;
       
    63     palette.setColor(QPalette::Background, Qt::black);
       
    64     setPalette(palette);
       
    65 }
       
    66 
       
    67 void S60ViewFinderWidget::ViewFinderFrameReady(const QImage& image)
       
    68 {
       
    69     m_pixmapImage = QPixmap::fromImage(image);
       
    70     repaint();
       
    71 }
       
    72 
       
    73 void S60ViewFinderWidget::paintEvent(QPaintEvent *)
       
    74 {
       
    75     QPainter painter(this);   
       
    76     QPoint point(pos());
       
    77     painter.drawPixmap(point, m_pixmapImage.scaled(size(), Qt::KeepAspectRatio));
       
    78 }
       
    79 
       
    80 S60ViewFinderWidgetControl::S60ViewFinderWidgetControl(QObject *parent)
       
    81     : QVideoWidgetControl(parent)
       
    82     , m_widget(new S60ViewFinderWidget)
       
    83 {
       
    84     m_widget->installEventFilter(this);
       
    85 }
       
    86 
       
    87 S60ViewFinderWidgetControl::~S60ViewFinderWidgetControl()
       
    88 {
       
    89     delete m_widget;
       
    90 }
       
    91 
       
    92 ;bool S60ViewFinderWidgetControl::eventFilter(QObject *object, QEvent *e)
       
    93 {
       
    94 	if (e->type() == QEvent::Show) {
       
    95 		m_widget->setAttribute(Qt::WA_NoSystemBackground, true);
       
    96 
       
    97 		return true;
       
    98 	}
       
    99 	
       
   100 	if (e->type() == QEvent::Resize) {
       
   101         emit resizeVideo();
       
   102         return true;
       
   103 	}
       
   104 	
       
   105 	if (e->type() == QEvent::Paint) {
       
   106         //QTimer::singleShot(20, this, SLOT(enableUpdates()));
       
   107 	}
       
   108     
       
   109 	return QVideoWidgetControl::eventFilter(object, e);
       
   110 }
       
   111 
       
   112 void S60ViewFinderWidgetControl::enableUpdates()
       
   113 {
       
   114     emit resizeVideo();
       
   115 }
       
   116 
       
   117 void S60ViewFinderWidgetControl::setOverlay()
       
   118 {
       
   119 	// TODO:
       
   120 }
       
   121 
       
   122 void S60ViewFinderWidgetControl::updateNativeVideoSize()
       
   123 {
       
   124     // TODO:
       
   125 }
       
   126 
       
   127 
       
   128 void S60ViewFinderWidgetControl::windowExposed()
       
   129 {
       
   130     // TODO:
       
   131 }
       
   132 
       
   133 S60ViewFinderWidget *S60ViewFinderWidgetControl::videoWidget()
       
   134 {
       
   135     return m_widget;
       
   136 }
       
   137 
       
   138 QVideoWidget::AspectRatioMode S60ViewFinderWidgetControl::aspectRatioMode() const
       
   139 {
       
   140     return m_aspectRatioMode;
       
   141 }
       
   142 
       
   143 QSize S60ViewFinderWidgetControl::customAspectRatio() const
       
   144 {
       
   145     return m_customAspectRatio;
       
   146 }
       
   147 
       
   148 void S60ViewFinderWidgetControl::setAspectRatioMode(QVideoWidget::AspectRatioMode ratio)
       
   149 {
       
   150     // TODO:
       
   151 }
       
   152 
       
   153 void S60ViewFinderWidgetControl::setCustomAspectRatio(const QSize &ratio)
       
   154 {
       
   155     m_customAspectRatio = ratio;
       
   156 }
       
   157 
       
   158 bool S60ViewFinderWidgetControl::isFullScreen() const
       
   159 {
       
   160     return m_widget->isFullScreen();
       
   161 }
       
   162 
       
   163 void S60ViewFinderWidgetControl::setFullScreen(bool fullScreen)
       
   164 {
       
   165     if (fullScreen) {
       
   166         m_widget->setWindowFlags(m_widget->windowFlags() | Qt::Window | Qt::WindowStaysOnTopHint);
       
   167         m_widget->setWindowState(m_widget->windowState() | Qt::WindowFullScreen);
       
   168 
       
   169         m_widget->show();
       
   170 
       
   171         emit fullScreenChanged(fullScreen);
       
   172     } else {
       
   173         m_widget->setWindowFlags(m_widget->windowFlags() & ~(Qt::Window | Qt::WindowStaysOnTopHint));
       
   174         m_widget->setWindowState(m_widget->windowState() & ~Qt::WindowFullScreen);
       
   175 
       
   176         m_widget->show();
       
   177 
       
   178         emit fullScreenChanged(fullScreen);
       
   179     }
       
   180 }
       
   181 
       
   182 int S60ViewFinderWidgetControl::brightness() const
       
   183 {
       
   184     int brightness = 0;
       
   185 
       
   186     // TODO:
       
   187 
       
   188     return brightness / 10;
       
   189 }
       
   190 
       
   191 void S60ViewFinderWidgetControl::setBrightness(int brightness)
       
   192 {
       
   193     // TODO:
       
   194 
       
   195     emit brightnessChanged(brightness);
       
   196 }
       
   197 
       
   198 int S60ViewFinderWidgetControl::contrast() const
       
   199 {
       
   200     int contrast = 0;
       
   201 
       
   202     // TODO:
       
   203 
       
   204     return contrast / 10;
       
   205 }
       
   206 
       
   207 void S60ViewFinderWidgetControl::setContrast(int contrast)
       
   208 {
       
   209     // TODO:
       
   210 
       
   211     emit contrastChanged(contrast);
       
   212 }
       
   213 
       
   214 int S60ViewFinderWidgetControl::hue() const
       
   215 {
       
   216     int hue = 0;
       
   217 
       
   218     // TODO:
       
   219 
       
   220     return hue / 10;
       
   221 }
       
   222 
       
   223 void S60ViewFinderWidgetControl::setHue(int hue)
       
   224 {
       
   225     // TODO:
       
   226 
       
   227     emit hueChanged(hue);
       
   228 }
       
   229 
       
   230 int S60ViewFinderWidgetControl::saturation() const
       
   231 {
       
   232     int saturation = 0;
       
   233 
       
   234     // TODO:
       
   235 
       
   236     return saturation / 10;
       
   237 }
       
   238 
       
   239 void S60ViewFinderWidgetControl::setSaturation(int saturation)
       
   240 {
       
   241     // TODO:
       
   242 
       
   243     emit saturationChanged(saturation);
       
   244 }