• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kopete/libkopete

  • sources
  • kde-4.14
  • kdenetwork
  • kopete
  • libkopete
  • ui
avatarwebcamdialog.cpp
Go to the documentation of this file.
1 /*
2  avatarfromwebcamdialog.cpp - Dialog to get a pixmap from a webcam
3 
4  Copyright (c) 2009 by Alex Fiestas <alex@eyeos.org>
5 
6  *************************************************************************
7  * *
8  * This library is free software; you can redistribute it and/or *
9  * modify it under the terms of the GNU Lesser General Public *
10  * License as published by the Free Software Foundation; either *
11  * version 2 of the License, or (at your option) any later version. *
12  * *
13  *************************************************************************
14 */
15 
16 #include "avatarwebcamdialog.h"
17 #include "webcamwidget.h"
18 
19 // QT includes
20 #include <qtimer.h>
21 
22 // KDE includes
23 #include <kdebug.h>
24 #include <klocale.h>
25 
26 // Kopete includes
27 #ifndef VIDEOSUPPORT_DISABLED
28 #include "avdevice/videodevicepool.h"
29 #endif
30 
31 namespace Kopete
32 {
33 
34 namespace UI
35 {
36 
37 class AvatarWebcamDialog::Private
38 {
39 public:
40  Private()
41  : mainWidget(0)
42  {}
43  ~Private()
44  {
45  }
46 
47  Kopete::WebcamWidget *mainWidget;
48  QTimer *m_timer;
49 #ifndef VIDEOSUPPORT_DISABLED
50  Kopete::AV::VideoDevicePool *m_devicePool;
51 #endif
52  QPixmap lastPixmap;
53  QString selectedPath;
54  QString currentPath;
55 };
56 
57 AvatarWebcamDialog::AvatarWebcamDialog(QWidget *parent)
58  : KDialog(parent), d(new Private)
59 {
60  showButtonSeparator(true);
61  setCaption(i18n("Take a photo"));
62  setButtons(KDialog::Ok | KDialog::Cancel);
63 
64 #ifndef VIDEOSUPPORT_DISABLED
65  d->m_devicePool = Kopete::AV::VideoDevicePool::self();
66  d->m_devicePool->open();
67  // NB: this may fail if the device is already in use
68  d->m_devicePool->setImageSize(640, 480);
69  d->m_devicePool->startCapturing();
70 #endif
71 
72  d->m_timer = new QTimer( this );
73  connect( d->m_timer, SIGNAL(timeout()), this, SLOT(updateImage()));
74 
75  d->mainWidget = new Kopete::WebcamWidget(this);
76 #ifndef VIDEOSUPPORT_DISABLED
77  d->mainWidget->setMinimumSize(d->m_devicePool->width() + 5,
78  d->m_devicePool->height() + 5);
79 #endif
80  d->m_timer->start(40);
81  setMainWidget(d->mainWidget);
82 }
83 
84 void AvatarWebcamDialog::updateImage()
85 {
86  QImage image = QImage();
87 #ifndef VIDEOSUPPORT_DISABLED
88  if (EXIT_SUCCESS != d->m_devicePool->getFrame())
89  return;
90  d->m_devicePool->getImage(&image);
91 #endif
92  d->lastPixmap = QPixmap::fromImage(image.mirrored(false,false));//There is a better way of do this?
93  d->mainWidget->updatePixmap(d->lastPixmap);
94 }
95 
96 QPixmap& AvatarWebcamDialog::getLastPixmap()
97 {
98  return d->lastPixmap;
99 }
100 
101 void AvatarWebcamDialog::slotButtonClicked(int button)
102 {
103 #ifndef VIDEOSUPPORT_DISABLED
104  d->m_devicePool->close();
105 #endif
106  KDialog::slotButtonClicked(button);
107 }
108 
109 AvatarWebcamDialog::~AvatarWebcamDialog()
110 {
111  delete d;
112 }
113 
114 } // namespace UI
115 
116 } // namespace Kopete
Kopete::UI::AvatarWebcamDialog::~AvatarWebcamDialog
virtual ~AvatarWebcamDialog()
Clean-up resource of AvatarFromWebcamDialog.
Definition: avatarwebcamdialog.cpp:109
QWidget
webcamwidget.h
QPixmap::fromImage
QPixmap fromImage(const QImage &image, QFlags< Qt::ImageConversionFlag > flags)
KDialog
Kopete::UI::AvatarWebcamDialog::getLastPixmap
QPixmap & getLastPixmap()
Return the last captured pixmap.
Definition: avatarwebcamdialog.cpp:96
QTimer
avatarwebcamdialog.h
QString
QPixmap
Kopete::WebcamWidget
A simple widget to display webcam frames.
Definition: webcamwidget.h:31
QImage
Kopete::UI::Global::setMainWidget
KOPETE_EXPORT void setMainWidget(QWidget *widget)
Set the main widget to widget.
Definition: kopeteuiglobal.cpp:32
Kopete::UI::Global::mainWidget
KOPETE_EXPORT QWidget * mainWidget()
Returns the main widget - this is the widget that message boxes and KNotify stuff should use as a par...
Definition: kopeteuiglobal.cpp:37
Kopete::AV::VideoDevicePool::self
static VideoDevicePool * self()
Returns pointer to a common instance of the VideoDevicePool.
Definition: videodevicepool.cpp:57
Kopete::AV::VideoDevicePool
This class allows kopete to check for the existence, open, configure, test, set parameters, grab frames from and close a given video capture card using the Video4Linux API.
Definition: videodevicepool.h:46
videodevicepool.h
Kopete::UI::AvatarWebcamDialog::slotButtonClicked
virtual void slotButtonClicked(int button)
Definition: avatarwebcamdialog.cpp:101
QImage::mirrored
QImage mirrored(bool horizontal, bool vertical) const
Kopete::UI::AvatarWebcamDialog::AvatarWebcamDialog
AvatarWebcamDialog(QWidget *parent=0)
Create a new AvatarFromWebcamDialog.
Definition: avatarwebcamdialog.cpp:57
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/libkopete

Skip menu "kopete/libkopete"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal