desktop/kdebase/feature_user-image-from-webcam.patch-disabled

2675 lines
80 KiB
Plaintext

diff -Naur kdebase-4.4.2.orig/apps/kdepasswd/kcm/chfacedlg.cpp kdebase-4.4.2/apps/kdepasswd/kcm/chfacedlg.cpp
--- kdebase-4.4.2.orig/apps/kdepasswd/kcm/chfacedlg.cpp 2009-02-26 10:11:49.000000000 +0100
+++ kdebase-4.4.2/apps/kdepasswd/kcm/chfacedlg.cpp 2010-04-27 10:56:59.563534198 +0200
@@ -1,6 +1,7 @@
/**
- * Copyright 2003 Braden MacDonald <bradenm_k@shaw.ca>
- * Copyright 2003 Ravikiran Rajagopal <ravi@ee.eng.ohio-state.edu>
+ * Copyright 2003 Braden MacDonald <bradenm_k@shaw.ca>
+ * Copyright 2003 Ravikiran Rajagopal <ravi@ee.eng.ohio-state.edu>
+ * Copyright 2010 Felipe Ortiz <f.ortiz.c@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,151 +23,170 @@
/**
* @file UserInfo's Dialog for changing your face.
- * @author Braden MacDonald
+ * @author Braden MacDonald - Felipe Ortiz
*/
-#include "chfacedlg.h"
-
-#include <QtGui/QLayout>
-#include <QtGui/QLabel>
-#include <QtGui/QPixmap>
-#include <QtGui/QImage>
-#include <QtGui/QPushButton>
#include <QtCore/QDir>
+#include <QtCore/QFile>
#include <QtGui/QCheckBox>
+#include <kmessagebox.h>
+#include <konq_operations.h>
+#include <kurl.h>
#include <klocale.h>
#include <kfiledialog.h>
#include <kimagefilepreview.h>
#include <kimageio.h>
-#include <kmessagebox.h>
-#include <konq_operations.h>
-#include <kurl.h>
-#include "settings.h" // KConfigXT
+#include "chfacedlg.h"
+#include "settings.h"
+#include "webcamui.h"
+#include "webcam.h"
+ChFaceDlg::ChFaceDlg(const QString &picsDir, QWidget *parent) : KDialog(parent, Qt::Dialog)
+{
+ setupUi(mainWidget());
+ dir = picsDir;
-/**
- * TODO: It would be nice if the widget were in a .ui
- */
-ChFaceDlg::ChFaceDlg(const QString& picsdir, QWidget *parent)
- : KDialog( parent )
+ connect(lwImages, SIGNAL(clicked(const QModelIndex &)), this, SLOT(activateButtons()));
+
+ connect(lwImages, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(accept()));
+ connect(pbFromFile, SIGNAL(clicked()), this, SLOT(slotGetImageFromFile()));
+ connect(pbDelete, SIGNAL(clicked()), this, SLOT(slotDelImage()));
+ connect(pbFromCam, SIGNAL(clicked()), this, SLOT(slotShowCamDlg()));
+ connect(this, SIGNAL(okClicked()), this, SLOT(accept()));
+
+// WebCam numCam(50, this);
+// QMap<int, QString> devices = numCam.getCamList();
+
+
+ scanImages();
+ resize(420, 500);
+ enableButtonOk(false);
+ pbDelete->setEnabled(false);
+ pbFromCam->setEnabled(!WebCam::getCamList().isEmpty());
+}
+
+void ChFaceDlg::scanImages()
+{
+ if (lwImages->count()) {
+ lwImages->clear();
+ }
+
+ QDir imageDir(dir);
+
+ if (!dir.isEmpty() && imageDir.exists()) {
+ const QStringList imgList = imageDir.entryList(QDir::Files);
+ for (QStringList::const_iterator i = imgList.constBegin(); i != imgList.constEnd(); ++i) {
+ new QListWidgetItem(QIcon(dir + *i), (*i).section('.', 0, 0), lwImages);
+ }
+ }
+
+ imageDir.setPath(KCFGUserAccount::userFaceDir());
+
+ if (imageDir.exists()) {
+ const QStringList imgList = imageDir.entryList(QDir::Files);
+
+ for (QStringList::const_iterator i = imgList.constBegin(); i != imgList.constEnd(); ++i) {
+
+ new QListWidgetItem(QIcon(KCFGUserAccount::userFaceDir() + *i),
+ '/' + (*i) == KCFGUserAccount::customFaceFile() ?
+ i18n("(Custom)") : (*i).section('.' ,0 ,0 ), lwImages );
+ }
+ }
+}
+
+QPixmap ChFaceDlg::getFaceImage() const
+{
+ if(lwImages->currentItem()){
+ return lwImages->currentItem()->icon().pixmap(64);
+ }
+ return QPixmap();
+}
+
+void ChFaceDlg::activateButtons()
{
- setCaption( i18n("Change your Face") );
- setButtons( Ok|Cancel );
- setDefaultButton( Ok );
- showButtonSeparator( true );
-
- QWidget *faceDlg = new QWidget;
- ui.setupUi(faceDlg);
-
- setMainWidget(faceDlg);
-
- connect( ui.m_FacesWidget, SIGNAL( currentItemChanged( QListWidgetItem *, QListWidgetItem * ) ), SLOT( slotFaceWidgetSelectionChanged( QListWidgetItem * ) ) );
-
- connect( ui.m_FacesWidget, SIGNAL( doubleClicked( const QModelIndex & ) ), SLOT(accept()) );
- connect( this, SIGNAL(okClicked()), this, SLOT(accept()));
-
- connect( ui.browseBtn, SIGNAL( clicked() ), SLOT( slotGetCustomImage() ) );
-
-#if 0
- QPushButton *acquireBtn = new QPushButton( i18n("&Acquire Image..."), page );
- acquireBtn->setEnabled( false );
- morePics->addWidget( acquireBtn );
-#endif
-
- // Filling the icon view
- QDir facesDir( picsdir );
- if ( facesDir.exists() )
- {
- const QStringList picslist = facesDir.entryList( QDir::Files );
- for ( QStringList::const_iterator it = picslist.constBegin(); it != picslist.constEnd(); ++it )
- new QListWidgetItem( QIcon( picsdir + *it ), (*it).section('.',0,0), ui.m_FacesWidget );
- }
- facesDir.setPath( KCFGUserAccount::userFaceDir() );
- if ( facesDir.exists() )
- {
- const QStringList picslist = facesDir.entryList( QDir::Files );
- for ( QStringList::const_iterator it = picslist.constBegin(); it != picslist.constEnd(); ++it )
- new QListWidgetItem( QIcon( KCFGUserAccount::userFaceDir() + *it ),
- '/'+(*it) == KCFGUserAccount::customFaceFile() ?
- i18n("(Custom)") : (*it).section('.',0,0),
- ui.m_FacesWidget );
- }
-
-
- enableButtonOk( false );
- //connect( this, SIGNAL( okClicked() ), SLOT( slotSaveCustomImage() ) );
-
- resize( 420, 400 );
-}
-
-void ChFaceDlg::addCustomPixmap( const QString &imPath, bool saveCopy )
-{
- QImage pix( imPath );
- // TODO: save pix to TMPDIR/userinfo-tmp,
- // then scale and copy *that* to ~/.faces
-
- if (pix.isNull())
- {
- KMessageBox::sorry( this, i18n("There was an error loading the image.") );
- return;
- }
- if ( (pix.width() > KCFGUserAccount::faceSize())
- || (pix.height() > KCFGUserAccount::faceSize()) )
- pix = pix.scaled( KCFGUserAccount::faceSize(), KCFGUserAccount::faceSize(), Qt::KeepAspectRatio );// Should be no bigger than certain size.
-
- if ( saveCopy )
- {
- // If we should save a copy:
- QDir userfaces( KCFGUserAccount::userFaceDir() );
- if ( !userfaces.exists( ) )
- userfaces.mkdir( userfaces.absolutePath() );
-
- pix.save( userfaces.absolutePath() + "/.userinfo-tmp" , "PNG" );
- KonqOperations::copy( this, KonqOperations::COPY, KUrl::List( KUrl( userfaces.absolutePath() + "/.userinfo-tmp" ) ), KUrl( userfaces.absolutePath() + '/' + QFileInfo(imPath).fileName().section('.',0,0) ) );
-#if 0
- if ( !pix.save( userfaces.absolutePath() + '/' + imPath , "PNG" ) )
- KMessageBox::sorry(this, i18n("There was an error saving the image:\n%1", userfaces.absolutePath() ) );
-#endif
- }
-
- QListWidgetItem* newface = new QListWidgetItem( QIcon(QPixmap::fromImage(pix)), QFileInfo(imPath).fileName().section('.',0,0), ui.m_FacesWidget );
- ui.m_FacesWidget->scrollToItem( newface );
- ui.m_FacesWidget->setCurrentItem( newface );
-}
-
-void ChFaceDlg::slotGetCustomImage( )
-{
- QCheckBox* checkWidget = new QCheckBox( i18n("&Save copy in custom faces folder for future use"), 0 );
-
- KFileDialog dlg( QDir::homePath(), KImageIO::pattern( KImageIO::Reading ),
- this, checkWidget);
-
- dlg.setOperationMode( KFileDialog::Opening );
- dlg.setCaption( i18n("Choose Image") );
- dlg.setMode( KFile::File | KFile::LocalOnly );
-
- KImageFilePreview *ip = new KImageFilePreview( &dlg );
- dlg.setPreviewWidget( ip );
- if (dlg.exec() == QDialog::Accepted)
- addCustomPixmap( dlg.selectedFile(), checkWidget->isChecked() );
-}
-
-#if 0
-void ChFaceDlg::slotSaveCustomImage()
-{
- if ( m_FacesWidget->currentItem()->key() == USER_CUSTOM_KEY)
- {
- QDir userfaces( QDir::homePath() + USER_FACES_DIR );
- if ( !userfaces.exists( ) )
- userfaces.mkdir( userfaces.absolutePath() );
-
- if ( !m_FacesWidget->currentItem()->pixmap()->save( userfaces.absolutePath() + USER_CUSTOM_FILE , "PNG" ) )
- KMessageBox::sorry(this, i18n("There was an error saving the image:\n%1", userfaces.absolutePath() ) );
- }
+ enableButtonOk(true);
+ pbDelete->setEnabled(true);
}
-#endif
+void ChFaceDlg::slotGetImageFromFile()
+{
+// I think that this feature is not necesary now, because I add a delete button
+// Up to date all image are stored.
+// QCheckBox *chkSaveImg = new QCheckBox(i18n("&Save copy in custom faces folder for future use"), 0);
+
+ KFileDialog openDlg(QDir::homePath(),
+ KImageIO::pattern(KImageIO::Reading), this);
+
+ openDlg.setOperationMode(KFileDialog::Opening);
+ openDlg.setCaption(i18n("Choose Image"));
+ openDlg.setMode(KFile::File | KFile::LocalOnly);
+
+ KImageFilePreview *imgPreview = new KImageFilePreview(&openDlg);
+ openDlg.setPreviewWidget(imgPreview);
+ if (openDlg.exec() == QDialog::Accepted){
+
+ const QImage pix(openDlg.selectedFile());
+ if (pix.isNull()) {
+ KMessageBox::sorry(this, i18n("There was an error loading the image."));
+ return;
+ } else {
+ addCustomPixmap(pix, QFileInfo(openDlg.selectedFile()).fileName().section('.', 0, 0));
+ }
+ }
+}
+
+void ChFaceDlg::slotDelImage()
+{
+ QString path = KCFGUserAccount::userFaceDir() + lwImages->currentItem()->text();
+
+ if (QFile::exists(path)) {
+
+ int rsp = KMessageBox::warningYesNo(this, i18n("Do you really want to delete this image?"),
+ i18n("Delete image"));
+ if (rsp == KMessageBox::Yes) {
+ KonqOperations::del(this, KonqOperations::TRASH, KUrl(path));
+
+ delete lwImages->takeItem(lwImages->currentRow());
+ }
+ } else {
+ KMessageBox::sorry(this,
+ i18n("You don't have appropriate permissions to delete this image"));
+ }
+}
+
+void ChFaceDlg::slotShowCamDlg()
+{
+ WebCamUi *wui = new WebCamUi(this);
+ if (wui->exec() == QDialog::Accepted && wui->isPhotoTaken()) {
+ addCustomPixmap(wui->getImage(), wui->getImgName());
+ }
+ delete wui;
+}
+
+void ChFaceDlg::addCustomPixmap(const QImage &pix, const QString &name)
+{
+ QImage scaledPix;
+
+ if ((pix.width() > KCFGUserAccount::faceSize()) || (pix.height() > KCFGUserAccount::faceSize())) {
+ // Should be no bigger than certain size.
+ scaledPix = pix.scaled(KCFGUserAccount::faceSize(),
+ KCFGUserAccount::faceSize(),
+ Qt::KeepAspectRatio);
+ }
+
+ QDir userFaces(KCFGUserAccount::userFaceDir());
+ if (!userFaces.exists()) {
+ userFaces.mkdir(userFaces.absolutePath());
+ }
+
+ scaledPix.save(userFaces.absolutePath() + "/" + name , "PNG");
+
+ QListWidgetItem *newFace = new QListWidgetItem(QIcon(QPixmap::fromImage(scaledPix)),
+ name, lwImages);
+ lwImages->scrollToItem(newFace);
+ lwImages->setCurrentItem(newFace);
+}
#include "chfacedlg.moc"
diff -Naur kdebase-4.4.2.orig/apps/kdepasswd/kcm/chfacedlg.h kdebase-4.4.2/apps/kdepasswd/kcm/chfacedlg.h
--- kdebase-4.4.2.orig/apps/kdepasswd/kcm/chfacedlg.h 2008-01-05 00:53:59.000000000 +0100
+++ kdebase-4.4.2/apps/kdepasswd/kcm/chfacedlg.h 2010-04-27 10:56:59.559368142 +0200
@@ -1,6 +1,7 @@
/**
* Copyright 2003 Braden MacDonald <bradenm_k@shaw.ca>
* Copyright 2003 Ravikiran Rajagopal <ravi@ee.eng.ohio-state.edu>
+ * Copyright 2010 Felipe Ortiz C. <f.ortiz.c@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,50 +23,39 @@
/**
* @file UserInfo-chface: Dialog for choosing a new face for your user.
- * @author Braden MacDonald
+ * @author Braden MacDonald - Felipe Ortiz
*/
#ifndef CHFACEDLG_H
#define CHFACEDLG_H
-#include <QtCore/QObject>
#include <QtGui/QPixmap>
+#include <QtCore/QSize>
#include <KDialog>
#include "ui_faceDlg.h"
-enum FacePerm { adminOnly = 1, adminFirst = 2, userFirst = 3, userOnly = 4};
-
-class ChFaceDlg : public KDialog
+class ChFaceDlg : public KDialog, private Ui::faceDlg
{
- Q_OBJECT
-public:
-
-
- explicit ChFaceDlg(const QString& picsdirs,
- QWidget *parent=0);
-
+ Q_OBJECT
- QPixmap getFaceImage() const
- {
- if(ui.m_FacesWidget->currentItem())
- return ui.m_FacesWidget->currentItem()->icon().pixmap(64);
- else
- return QPixmap();
- }
+public:
+ explicit ChFaceDlg(const QString &picsDir, QWidget *parent = 0);
+ QPixmap getFaceImage() const;
private Q_SLOTS:
- void slotFaceWidgetSelectionChanged( QListWidgetItem *item )
- { enableButton( Ok, !item->icon().isNull() ); }
-
- void slotGetCustomImage();
- //void slotSaveCustomImage();
+ void activateButtons();
+ void slotGetImageFromFile();
+ void slotDelImage();
+ void slotShowCamDlg();
private:
- void addCustomPixmap( const QString &imPath, bool saveCopy );
+ void addCustomPixmap(const QImage &pix, const QString &name);
+ void scanImages();
- Ui::faceDlg ui;
-};
+ QSize getSize();
+ QString dir;
-#endif // CHFACEDLG_H
+};
+#endif
diff -Naur kdebase-4.4.2.orig/apps/kdepasswd/kcm/CMakeLists.txt kdebase-4.4.2/apps/kdepasswd/kcm/CMakeLists.txt
--- kdebase-4.4.2.orig/apps/kdepasswd/kcm/CMakeLists.txt 2009-05-14 19:26:16.000000000 +0200
+++ kdebase-4.4.2/apps/kdepasswd/kcm/CMakeLists.txt 2010-04-27 10:56:59.559368142 +0200
@@ -1,19 +1,26 @@
+find_package(KDE4 REQUIRED)
+find_package(OpenCV REQUIRED)
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR} ${OPENCV_INCLUDE_DIR} ${QT_INCLUDES} ${KDE4_INCLUDES})
add_subdirectory(pics)
set(kcm_useraccount_PART_SRCS
chfnprocess.cpp
main.cpp
- chfacedlg.cpp)
+ chfacedlg.cpp
+ webcam.cpp
+ webcamui.cpp)
kde4_add_ui_files(kcm_useraccount_PART_SRCS
main_widget.ui
- faceDlg.ui)
+ faceDlg.ui
+ webcamui.ui)
kde4_add_kcfg_files(kcm_useraccount_PART_SRCS settings.kcfgc pass.kcfgc)
kde4_add_plugin(kcm_useraccount ${kcm_useraccount_PART_SRCS})
-target_link_libraries(kcm_useraccount konq ${KDE4_KIO_LIBS} ${KDE4_KDESU_LIBS})
+target_link_libraries(kcm_useraccount konq ${KDE4_KDEUI_LIBS} ${KDE4_SOLID_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KDESU_LIBS} ${OpenCV_LIBS})
install(TARGETS kcm_useraccount DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES kcm_useraccount.desktop DESTINATION ${SERVICES_INSTALL_DIR})
diff -Naur kdebase-4.4.2.orig/apps/kdepasswd/kcm/faceDlg.ui kdebase-4.4.2/apps/kdepasswd/kcm/faceDlg.ui
--- kdebase-4.4.2.orig/apps/kdepasswd/kcm/faceDlg.ui 2008-01-05 00:53:59.000000000 +0100
+++ kdebase-4.4.2/apps/kdepasswd/kcm/faceDlg.ui 2010-04-27 10:56:59.563534198 +0200
@@ -1,74 +1,142 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
<class>faceDlg</class>
- <widget class="QWidget" name="faceDlg" >
- <property name="geometry" >
+ <widget class="QWidget" name="faceDlg">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>400</width>
- <height>306</height>
+ <width>455</width>
+ <height>528</height>
</rect>
</property>
- <property name="minimumSize" >
- <size>
- <width>400</width>
- <height>199</height>
- </size>
+ <property name="windowTitle">
+ <string>Select a new image</string>
</property>
- <layout class="QGridLayout" >
- <item row="0" column="0" >
- <layout class="QVBoxLayout" >
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
- <widget class="QLabel" name="header" >
- <property name="text" >
- <string>Select a new face:</string>
+ <widget class="QLabel" name="LbTitle">
+ <property name="text">
+ <string>Select a new image:</string>
</property>
</widget>
</item>
<item>
- <widget class="QListWidget" name="m_FacesWidget" >
- <property name="iconSize" >
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
<size>
- <width>64</width>
- <height>64</height>
+ <width>40</width>
+ <height>20</height>
</size>
</property>
- <property name="resizeMode" >
- <enum>QListView::Adjust</enum>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <widget class="KListWidget" name="lwImages">
+ <property name="showDropIndicator" stdset="0">
+ <bool>true</bool>
+ </property>
+ <property name="dragDropMode">
+ <enum>QAbstractItemView::DragDrop</enum>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>64</width>
+ <height>64</height>
+ </size>
+ </property>
+ <property name="movement">
+ <enum>QListView::Free</enum>
+ </property>
+ <property name="flow">
+ <enum>QListView::LeftToRight</enum>
+ </property>
+ <property name="isWrapping" stdset="0">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>QListView::Adjust</enum>
+ </property>
+ <property name="viewMode">
+ <enum>QListView::IconMode</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
</property>
- <property name="viewMode" >
- <enum>QListView::IconMode</enum>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
</property>
- </widget>
+ </spacer>
</item>
<item>
- <layout class="QHBoxLayout" >
- <item>
- <widget class="QPushButton" name="browseBtn" >
- <property name="text" >
- <string>Custom Image...</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ <widget class="KPushButton" name="pbDelete">
+ <property name="text">
+ <string>&amp;Delete</string>
+ </property>
+ </widget>
</item>
</layout>
</item>
+ <item row="3" column="0">
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Add new image</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="KPushButton" name="pbFromFile">
+ <property name="text">
+ <string>From File</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="KPushButton" name="pbFromCam">
+ <property name="text">
+ <string>From Webcam</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="Line" name="line">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>KListWidget</class>
+ <extends>QListWidget</extends>
+ <header>klistwidget.h</header>
+ </customwidget>
+ <customwidget>
+ <class>KPushButton</class>
+ <extends>QPushButton</extends>
+ <header>kpushbutton.h</header>
+ </customwidget>
+ </customwidgets>
<resources/>
<connections/>
</ui>
diff -Naur kdebase-4.4.2.orig/apps/kdepasswd/kcm/kcm.patch kdebase-4.4.2/apps/kdepasswd/kcm/kcm.patch
--- kdebase-4.4.2.orig/apps/kdepasswd/kcm/kcm.patch 1970-01-01 01:00:00.000000000 +0100
+++ kdebase-4.4.2/apps/kdepasswd/kcm/kcm.patch 2010-04-27 10:11:45.000000000 +0200
@@ -0,0 +1,1537 @@
+Index: CMakeLists.txt
+===================================================================
+--- CMakeLists.txt (revision 1105532)
++++ CMakeLists.txt (working copy)
+@@ -1,19 +1,26 @@
++find_package(KDE4 REQUIRED)
++find_package(OpenCV REQUIRED)
++
++include_directories(${CMAKE_CURRENT_BINARY_DIR} ${OPENCV_INCLUDE_DIR} ${QT_INCLUDES} ${KDE4_INCLUDES})
+ add_subdirectory(pics)
+
+ set(kcm_useraccount_PART_SRCS
+ chfnprocess.cpp
+ main.cpp
+- chfacedlg.cpp)
++ chfacedlg.cpp
++ webcam.cpp
++ webcamui.cpp)
+
+ kde4_add_ui_files(kcm_useraccount_PART_SRCS
+ main_widget.ui
+- faceDlg.ui)
++ faceDlg.ui
++ webcamui.ui)
+
+ kde4_add_kcfg_files(kcm_useraccount_PART_SRCS settings.kcfgc pass.kcfgc)
+
+ kde4_add_plugin(kcm_useraccount ${kcm_useraccount_PART_SRCS})
+
+-target_link_libraries(kcm_useraccount konq ${KDE4_KIO_LIBS} ${KDE4_KDESU_LIBS})
++target_link_libraries(kcm_useraccount konq ${KDE4_KDEUI_LIBS} ${KDE4_SOLID_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KDESU_LIBS} ${OpenCV_LIBS})
+
+ install(TARGETS kcm_useraccount DESTINATION ${PLUGIN_INSTALL_DIR})
+ install(FILES kcm_useraccount.desktop DESTINATION ${SERVICES_INSTALL_DIR})
+Index: chfacedlg.h
+===================================================================
+--- chfacedlg.h (revision 1105532)
++++ chfacedlg.h (working copy)
+@@ -1,6 +1,7 @@
+ /**
+ * Copyright 2003 Braden MacDonald <bradenm_k@shaw.ca>
+ * Copyright 2003 Ravikiran Rajagopal <ravi@ee.eng.ohio-state.edu>
++ * Copyright 2010 Felipe Ortiz C. <f.ortiz.c@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+@@ -22,50 +23,39 @@
+
+ /**
+ * @file UserInfo-chface: Dialog for choosing a new face for your user.
+- * @author Braden MacDonald
++ * @author Braden MacDonald - Felipe Ortiz
+ */
+
+ #ifndef CHFACEDLG_H
+ #define CHFACEDLG_H
+
+-#include <QtCore/QObject>
+ #include <QtGui/QPixmap>
++#include <QtCore/QSize>
+
+ #include <KDialog>
+
+ #include "ui_faceDlg.h"
+
+-enum FacePerm { adminOnly = 1, adminFirst = 2, userFirst = 3, userOnly = 4};
+-
+-class ChFaceDlg : public KDialog
++class ChFaceDlg : public KDialog, private Ui::faceDlg
+ {
+- Q_OBJECT
+-public:
+-
+-
+- explicit ChFaceDlg(const QString& picsdirs,
+- QWidget *parent=0);
+-
++ Q_OBJECT
+
+- QPixmap getFaceImage() const
+- {
+- if(ui.m_FacesWidget->currentItem())
+- return ui.m_FacesWidget->currentItem()->icon().pixmap(64);
+- else
+- return QPixmap();
+- }
++public:
++ explicit ChFaceDlg(const QString &picsDir, QWidget *parent = 0);
++ QPixmap getFaceImage() const;
+
+ private Q_SLOTS:
+- void slotFaceWidgetSelectionChanged( QListWidgetItem *item )
+- { enableButton( Ok, !item->icon().isNull() ); }
+-
+- void slotGetCustomImage();
+- //void slotSaveCustomImage();
++ void activateButtons();
++ void slotGetImageFromFile();
++ void slotDelImage();
++ void slotShowCamDlg();
+
+ private:
+- void addCustomPixmap( const QString &imPath, bool saveCopy );
++ void addCustomPixmap(const QImage &pix, const QString &name);
++ void scanImages();
+
+- Ui::faceDlg ui;
+-};
++ QSize getSize();
++ QString dir;
+
+-#endif // CHFACEDLG_H
++};
++#endif
+Index: chfacedlg.cpp
+===================================================================
+--- chfacedlg.cpp (revision 1105532)
++++ chfacedlg.cpp (working copy)
+@@ -1,6 +1,7 @@
+ /**
+- * Copyright 2003 Braden MacDonald <bradenm_k@shaw.ca>
+- * Copyright 2003 Ravikiran Rajagopal <ravi@ee.eng.ohio-state.edu>
++ * Copyright 2003 Braden MacDonald <bradenm_k@shaw.ca>
++ * Copyright 2003 Ravikiran Rajagopal <ravi@ee.eng.ohio-state.edu>
++ * Copyright 2010 Felipe Ortiz <f.ortiz.c@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+@@ -22,151 +23,170 @@
+
+ /**
+ * @file UserInfo's Dialog for changing your face.
+- * @author Braden MacDonald
++ * @author Braden MacDonald - Felipe Ortiz
+ */
+
+-#include "chfacedlg.h"
+-
+-#include <QtGui/QLayout>
+-#include <QtGui/QLabel>
+-#include <QtGui/QPixmap>
+-#include <QtGui/QImage>
+-#include <QtGui/QPushButton>
+ #include <QtCore/QDir>
++#include <QtCore/QFile>
+ #include <QtGui/QCheckBox>
+
++#include <kmessagebox.h>
++#include <konq_operations.h>
++#include <kurl.h>
+ #include <klocale.h>
+ #include <kfiledialog.h>
+ #include <kimagefilepreview.h>
+ #include <kimageio.h>
+-#include <kmessagebox.h>
+-#include <konq_operations.h>
+-#include <kurl.h>
+
+-#include "settings.h" // KConfigXT
++#include "chfacedlg.h"
++#include "settings.h"
++#include "webcamui.h"
++#include "webcam.h"
+
++ChFaceDlg::ChFaceDlg(const QString &picsDir, QWidget *parent) : KDialog(parent, Qt::Dialog)
++{
++ setupUi(mainWidget());
+
++ dir = picsDir;
+
+-/**
+- * TODO: It would be nice if the widget were in a .ui
+- */
+-ChFaceDlg::ChFaceDlg(const QString& picsdir, QWidget *parent)
+- : KDialog( parent )
++ connect(lwImages, SIGNAL(clicked(const QModelIndex &)), this, SLOT(activateButtons()));
++
++ connect(lwImages, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(accept()));
++ connect(pbFromFile, SIGNAL(clicked()), this, SLOT(slotGetImageFromFile()));
++ connect(pbDelete, SIGNAL(clicked()), this, SLOT(slotDelImage()));
++ connect(pbFromCam, SIGNAL(clicked()), this, SLOT(slotShowCamDlg()));
++ connect(this, SIGNAL(okClicked()), this, SLOT(accept()));
++
++// WebCam numCam(50, this);
++// QMap<int, QString> devices = numCam.getCamList();
++
++
++ scanImages();
++ resize(420, 500);
++ enableButtonOk(false);
++ pbDelete->setEnabled(false);
++ pbFromCam->setEnabled(!WebCam::getCamList().isEmpty());
++}
++
++void ChFaceDlg::scanImages()
++{
++ if (lwImages->count()) {
++ lwImages->clear();
++ }
++
++ QDir imageDir(dir);
++
++ if (!dir.isEmpty() && imageDir.exists()) {
++ const QStringList imgList = imageDir.entryList(QDir::Files);
++ for (QStringList::const_iterator i = imgList.constBegin(); i != imgList.constEnd(); ++i) {
++ new QListWidgetItem(QIcon(dir + *i), (*i).section('.', 0, 0), lwImages);
++ }
++ }
++
++ imageDir.setPath(KCFGUserAccount::userFaceDir());
++
++ if (imageDir.exists()) {
++ const QStringList imgList = imageDir.entryList(QDir::Files);
++
++ for (QStringList::const_iterator i = imgList.constBegin(); i != imgList.constEnd(); ++i) {
++
++ new QListWidgetItem(QIcon(KCFGUserAccount::userFaceDir() + *i),
++ '/' + (*i) == KCFGUserAccount::customFaceFile() ?
++ i18n("(Custom)") : (*i).section('.' ,0 ,0 ), lwImages );
++ }
++ }
++}
++
++QPixmap ChFaceDlg::getFaceImage() const
++{
++ if(lwImages->currentItem()){
++ return lwImages->currentItem()->icon().pixmap(64);
++ }
++ return QPixmap();
++}
++
++void ChFaceDlg::activateButtons()
+ {
+- setCaption( i18n("Change your Face") );
+- setButtons( Ok|Cancel );
+- setDefaultButton( Ok );
+- showButtonSeparator( true );
+-
+- QWidget *faceDlg = new QWidget;
+- ui.setupUi(faceDlg);
+-
+- setMainWidget(faceDlg);
+-
+- connect( ui.m_FacesWidget, SIGNAL( currentItemChanged( QListWidgetItem *, QListWidgetItem * ) ), SLOT( slotFaceWidgetSelectionChanged( QListWidgetItem * ) ) );
+-
+- connect( ui.m_FacesWidget, SIGNAL( doubleClicked( const QModelIndex & ) ), SLOT(accept()) );
+- connect( this, SIGNAL(okClicked()), this, SLOT(accept()));
+-
+- connect( ui.browseBtn, SIGNAL( clicked() ), SLOT( slotGetCustomImage() ) );
+-
+-#if 0
+- QPushButton *acquireBtn = new QPushButton( i18n("&Acquire Image..."), page );
+- acquireBtn->setEnabled( false );
+- morePics->addWidget( acquireBtn );
+-#endif
+-
+- // Filling the icon view
+- QDir facesDir( picsdir );
+- if ( facesDir.exists() )
+- {
+- const QStringList picslist = facesDir.entryList( QDir::Files );
+- for ( QStringList::const_iterator it = picslist.constBegin(); it != picslist.constEnd(); ++it )
+- new QListWidgetItem( QIcon( picsdir + *it ), (*it).section('.',0,0), ui.m_FacesWidget );
+- }
+- facesDir.setPath( KCFGUserAccount::userFaceDir() );
+- if ( facesDir.exists() )
+- {
+- const QStringList picslist = facesDir.entryList( QDir::Files );
+- for ( QStringList::const_iterator it = picslist.constBegin(); it != picslist.constEnd(); ++it )
+- new QListWidgetItem( QIcon( KCFGUserAccount::userFaceDir() + *it ),
+- '/'+(*it) == KCFGUserAccount::customFaceFile() ?
+- i18n("(Custom)") : (*it).section('.',0,0),
+- ui.m_FacesWidget );
+- }
+-
+-
+- enableButtonOk( false );
+- //connect( this, SIGNAL( okClicked() ), SLOT( slotSaveCustomImage() ) );
+-
+- resize( 420, 400 );
+-}
+-
+-void ChFaceDlg::addCustomPixmap( const QString &imPath, bool saveCopy )
+-{
+- QImage pix( imPath );
+- // TODO: save pix to TMPDIR/userinfo-tmp,
+- // then scale and copy *that* to ~/.faces
+-
+- if (pix.isNull())
+- {
+- KMessageBox::sorry( this, i18n("There was an error loading the image.") );
+- return;
+- }
+- if ( (pix.width() > KCFGUserAccount::faceSize())
+- || (pix.height() > KCFGUserAccount::faceSize()) )
+- pix = pix.scaled( KCFGUserAccount::faceSize(), KCFGUserAccount::faceSize(), Qt::KeepAspectRatio );// Should be no bigger than certain size.
+-
+- if ( saveCopy )
+- {
+- // If we should save a copy:
+- QDir userfaces( KCFGUserAccount::userFaceDir() );
+- if ( !userfaces.exists( ) )
+- userfaces.mkdir( userfaces.absolutePath() );
+-
+- pix.save( userfaces.absolutePath() + "/.userinfo-tmp" , "PNG" );
+- KonqOperations::copy( this, KonqOperations::COPY, KUrl::List( KUrl( userfaces.absolutePath() + "/.userinfo-tmp" ) ), KUrl( userfaces.absolutePath() + '/' + QFileInfo(imPath).fileName().section('.',0,0) ) );
+-#if 0
+- if ( !pix.save( userfaces.absolutePath() + '/' + imPath , "PNG" ) )
+- KMessageBox::sorry(this, i18n("There was an error saving the image:\n%1", userfaces.absolutePath() ) );
+-#endif
+- }
+-
+- QListWidgetItem* newface = new QListWidgetItem( QIcon(QPixmap::fromImage(pix)), QFileInfo(imPath).fileName().section('.',0,0), ui.m_FacesWidget );
+- ui.m_FacesWidget->scrollToItem( newface );
+- ui.m_FacesWidget->setCurrentItem( newface );
+-}
+-
+-void ChFaceDlg::slotGetCustomImage( )
+-{
+- QCheckBox* checkWidget = new QCheckBox( i18n("&Save copy in custom faces folder for future use"), 0 );
+-
+- KFileDialog dlg( QDir::homePath(), KImageIO::pattern( KImageIO::Reading ),
+- this, checkWidget);
+-
+- dlg.setOperationMode( KFileDialog::Opening );
+- dlg.setCaption( i18n("Choose Image") );
+- dlg.setMode( KFile::File | KFile::LocalOnly );
+-
+- KImageFilePreview *ip = new KImageFilePreview( &dlg );
+- dlg.setPreviewWidget( ip );
+- if (dlg.exec() == QDialog::Accepted)
+- addCustomPixmap( dlg.selectedFile(), checkWidget->isChecked() );
+-}
+-
+-#if 0
+-void ChFaceDlg::slotSaveCustomImage()
+-{
+- if ( m_FacesWidget->currentItem()->key() == USER_CUSTOM_KEY)
+- {
+- QDir userfaces( QDir::homePath() + USER_FACES_DIR );
+- if ( !userfaces.exists( ) )
+- userfaces.mkdir( userfaces.absolutePath() );
+-
+- if ( !m_FacesWidget->currentItem()->pixmap()->save( userfaces.absolutePath() + USER_CUSTOM_FILE , "PNG" ) )
+- KMessageBox::sorry(this, i18n("There was an error saving the image:\n%1", userfaces.absolutePath() ) );
+- }
++ enableButtonOk(true);
++ pbDelete->setEnabled(true);
+ }
+-#endif
+
++void ChFaceDlg::slotGetImageFromFile()
++{
++// I think that this feature is not necesary now, because I add a delete button
++// Up to date all image are stored.
++// QCheckBox *chkSaveImg = new QCheckBox(i18n("&Save copy in custom faces folder for future use"), 0);
++
++ KFileDialog openDlg(QDir::homePath(),
++ KImageIO::pattern(KImageIO::Reading), this);
++
++ openDlg.setOperationMode(KFileDialog::Opening);
++ openDlg.setCaption(i18n("Choose Image"));
++ openDlg.setMode(KFile::File | KFile::LocalOnly);
++
++ KImageFilePreview *imgPreview = new KImageFilePreview(&openDlg);
++ openDlg.setPreviewWidget(imgPreview);
++ if (openDlg.exec() == QDialog::Accepted){
++
++ const QImage pix(openDlg.selectedFile());
++ if (pix.isNull()) {
++ KMessageBox::sorry(this, i18n("There was an error loading the image."));
++ return;
++ } else {
++ addCustomPixmap(pix, QFileInfo(openDlg.selectedFile()).fileName().section('.', 0, 0));
++ }
++ }
++}
++
++void ChFaceDlg::slotDelImage()
++{
++ QString path = KCFGUserAccount::userFaceDir() + lwImages->currentItem()->text();
++
++ if (QFile::exists(path)) {
++
++ int rsp = KMessageBox::warningYesNo(this, i18n("Do you really want to delete this image?"),
++ i18n("Delete image"));
++ if (rsp == KMessageBox::Yes) {
++ KonqOperations::del(this, KonqOperations::TRASH, KUrl(path));
++
++ delete lwImages->takeItem(lwImages->currentRow());
++ }
++ } else {
++ KMessageBox::sorry(this,
++ i18n("You don't have appropriate permissions to delete this image"));
++ }
++}
++
++void ChFaceDlg::slotShowCamDlg()
++{
++ WebCamUi *wui = new WebCamUi(this);
++ if (wui->exec() == QDialog::Accepted && wui->isPhotoTaken()) {
++ addCustomPixmap(wui->getImage(), wui->getImgName());
++ }
++ delete wui;
++}
++
++void ChFaceDlg::addCustomPixmap(const QImage &pix, const QString &name)
++{
++ QImage scaledPix;
++
++ if ((pix.width() > KCFGUserAccount::faceSize()) || (pix.height() > KCFGUserAccount::faceSize())) {
++ // Should be no bigger than certain size.
++ scaledPix = pix.scaled(KCFGUserAccount::faceSize(),
++ KCFGUserAccount::faceSize(),
++ Qt::KeepAspectRatio);
++ }
++
++ QDir userFaces(KCFGUserAccount::userFaceDir());
++ if (!userFaces.exists()) {
++ userFaces.mkdir(userFaces.absolutePath());
++ }
++
++ scaledPix.save(userFaces.absolutePath() + "/" + name , "PNG");
++
++ QListWidgetItem *newFace = new QListWidgetItem(QIcon(QPixmap::fromImage(scaledPix)),
++ name, lwImages);
++ lwImages->scrollToItem(newFace);
++ lwImages->setCurrentItem(newFace);
++}
+ #include "chfacedlg.moc"
+Index: faceDlg.ui
+===================================================================
+--- faceDlg.ui (revision 1105532)
++++ faceDlg.ui (working copy)
+@@ -1,74 +1,142 @@
+-<ui version="4.0" >
++<?xml version="1.0" encoding="UTF-8"?>
++<ui version="4.0">
+ <class>faceDlg</class>
+- <widget class="QWidget" name="faceDlg" >
+- <property name="geometry" >
++ <widget class="QWidget" name="faceDlg">
++ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+- <width>400</width>
+- <height>306</height>
++ <width>455</width>
++ <height>528</height>
+ </rect>
+ </property>
+- <property name="minimumSize" >
+- <size>
+- <width>400</width>
+- <height>199</height>
+- </size>
++ <property name="windowTitle">
++ <string>Select a new image</string>
+ </property>
+- <layout class="QGridLayout" >
+- <item row="0" column="0" >
+- <layout class="QVBoxLayout" >
++ <layout class="QGridLayout" name="gridLayout_2">
++ <item row="0" column="0">
++ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+- <widget class="QLabel" name="header" >
+- <property name="text" >
+- <string>Select a new face:</string>
++ <widget class="QLabel" name="LbTitle">
++ <property name="text">
++ <string>Select a new image:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+- <widget class="QListWidget" name="m_FacesWidget" >
+- <property name="iconSize" >
++ <spacer name="horizontalSpacer_3">
++ <property name="orientation">
++ <enum>Qt::Horizontal</enum>
++ </property>
++ <property name="sizeHint" stdset="0">
+ <size>
+- <width>64</width>
+- <height>64</height>
++ <width>40</width>
++ <height>20</height>
+ </size>
+ </property>
+- <property name="resizeMode" >
+- <enum>QListView::Adjust</enum>
++ </spacer>
++ </item>
++ </layout>
++ </item>
++ <item row="1" column="0">
++ <widget class="KListWidget" name="lwImages">
++ <property name="showDropIndicator" stdset="0">
++ <bool>true</bool>
++ </property>
++ <property name="dragDropMode">
++ <enum>QAbstractItemView::DragDrop</enum>
++ </property>
++ <property name="iconSize">
++ <size>
++ <width>64</width>
++ <height>64</height>
++ </size>
++ </property>
++ <property name="movement">
++ <enum>QListView::Free</enum>
++ </property>
++ <property name="flow">
++ <enum>QListView::LeftToRight</enum>
++ </property>
++ <property name="isWrapping" stdset="0">
++ <bool>true</bool>
++ </property>
++ <property name="resizeMode">
++ <enum>QListView::Adjust</enum>
++ </property>
++ <property name="viewMode">
++ <enum>QListView::IconMode</enum>
++ </property>
++ </widget>
++ </item>
++ <item row="2" column="0">
++ <layout class="QHBoxLayout" name="horizontalLayout">
++ <item>
++ <spacer name="horizontalSpacer">
++ <property name="orientation">
++ <enum>Qt::Horizontal</enum>
+ </property>
+- <property name="viewMode" >
+- <enum>QListView::IconMode</enum>
++ <property name="sizeHint" stdset="0">
++ <size>
++ <width>40</width>
++ <height>20</height>
++ </size>
+ </property>
+- </widget>
++ </spacer>
+ </item>
+ <item>
+- <layout class="QHBoxLayout" >
+- <item>
+- <widget class="QPushButton" name="browseBtn" >
+- <property name="text" >
+- <string>Custom Image...</string>
+- </property>
+- </widget>
+- </item>
+- <item>
+- <spacer>
+- <property name="orientation" >
+- <enum>Qt::Horizontal</enum>
+- </property>
+- <property name="sizeHint" >
+- <size>
+- <width>40</width>
+- <height>20</height>
+- </size>
+- </property>
+- </spacer>
+- </item>
+- </layout>
++ <widget class="KPushButton" name="pbDelete">
++ <property name="text">
++ <string>&amp;Delete</string>
++ </property>
++ </widget>
+ </item>
+ </layout>
+ </item>
++ <item row="3" column="0">
++ <widget class="QGroupBox" name="groupBox">
++ <property name="title">
++ <string>Add new image</string>
++ </property>
++ <layout class="QGridLayout" name="gridLayout">
++ <item row="0" column="0">
++ <widget class="KPushButton" name="pbFromFile">
++ <property name="text">
++ <string>From File</string>
++ </property>
++ </widget>
++ </item>
++ <item row="0" column="1">
++ <widget class="KPushButton" name="pbFromCam">
++ <property name="text">
++ <string>From Webcam</string>
++ </property>
++ </widget>
++ </item>
++ </layout>
++ </widget>
++ </item>
++ <item row="4" column="0">
++ <widget class="Line" name="line">
++ <property name="orientation">
++ <enum>Qt::Horizontal</enum>
++ </property>
++ </widget>
++ </item>
+ </layout>
+ </widget>
++ <customwidgets>
++ <customwidget>
++ <class>KListWidget</class>
++ <extends>QListWidget</extends>
++ <header>klistwidget.h</header>
++ </customwidget>
++ <customwidget>
++ <class>KPushButton</class>
++ <extends>QPushButton</extends>
++ <header>kpushbutton.h</header>
++ </customwidget>
++ </customwidgets>
+ <resources/>
+ <connections/>
+ </ui>
+Index: main.h
+===================================================================
+--- main.h (revision 1105532)
++++ main.h (working copy)
+@@ -1,6 +1,7 @@
+
+ /**
+ * Copyright (C) 2004 Frans Englich <frans.englich@telia.com>
++ * Copyrigth (C) 2010 Felipe Ortiz <f.ortiz.c@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+@@ -31,6 +32,8 @@ class QEvent;
+ class QObject;
+ class KUrl;
+
++enum FacePerm { adminOnly = 1, adminFirst = 2, userFirst = 3, userOnly = 4};
++
+ class MainWidget : public QWidget, public Ui::MainWidget
+ {
+ public:
+@@ -52,10 +55,10 @@ public:
+ ~KCMUserAccount();
+
+ /**
+- * The user data is loaded from chfn(/etc/password) and then
++ * The user data is loaded from chfn(/etc/password) and then
+ * written back as well as to KDE's own(KEmailSettings).
+- * The user won't notice this(assuming they change the KDE settings via
+- * this KCM) and will make KDE play nice with enviroments which uses
++ * The user won't notice this(assuming they change the KDE settings via
++ * this KCM) and will make KDE play nice with enviroments which uses
+ * /etc/password.
+ */
+ void load();
+Index: main_widget.ui
+===================================================================
+--- main_widget.ui (revision 1105532)
++++ main_widget.ui (working copy)
+@@ -1,9 +1,8 @@
+-<?xml version="1.0" encoding="UTF-8"?>
+-<ui version="4.0">
+- <author>Frans Englich &lt;frans.englich@telia.com&gt;</author>
++<ui version="4.0" >
++ <author>Frans Englich &lt;frans.englich@telia.com></author>
+ <class>MainWidget</class>
+- <widget class="QWidget" name="MainWidget">
+- <property name="geometry">
++ <widget class="QWidget" name="MainWidget" >
++ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+@@ -11,92 +10,89 @@
+ <height>557</height>
+ </rect>
+ </property>
+- <layout class="QVBoxLayout" name="verticalLayout">
+- <property name="margin">
++ <layout class="QVBoxLayout" name="verticalLayout" >
++ <property name="margin" >
+ <number>0</number>
+ </property>
+ <item>
+- <layout class="QHBoxLayout">
++ <layout class="QHBoxLayout" >
+ <item>
+- <widget class="KPushButton" name="btnChangeFace">
+- <property name="sizePolicy">
+- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
++ <widget class="KPushButton" name="btnChangeFace" >
++ <property name="sizePolicy" >
++ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+- <property name="minimumSize">
++ <property name="minimumSize" >
+ <size>
+ <width>74</width>
+ <height>74</height>
+ </size>
+ </property>
+- <property name="maximumSize">
++ <property name="maximumSize" >
+ <size>
+ <width>74</width>
+ <height>74</height>
+ </size>
+ </property>
+- <property name="acceptDrops">
++ <property name="acceptDrops" >
+ <bool>true</bool>
+ </property>
+- <property name="toolTip">
+- <string>Change your image</string>
+- </property>
+- <property name="text">
++ <property name="text" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+- <layout class="QVBoxLayout">
+- <property name="margin">
++ <layout class="QVBoxLayout" >
++ <property name="margin" >
+ <number>0</number>
+ </property>
+ <item>
+- <widget class="QLabel" name="lblUsername">
+- <property name="text">
++ <widget class="QLabel" name="lblUsername" >
++ <property name="text" >
+ <string/>
+ </property>
+- <property name="alignment">
++ <property name="alignment" >
+ <set>Qt::AlignVCenter</set>
+ </property>
+- <property name="wordWrap">
++ <property name="wordWrap" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+- <widget class="QLabel" name="lblClickButtonInfo">
+- <property name="text">
+- <string>&lt;i&gt;Click to change your image&lt;/i&gt;</string>
++ <widget class="QLabel" name="lblClickButtonInfo" >
++ <property name="text" >
++ <string>&lt;i>Click to change your image&lt;/i></string>
+ </property>
+- <property name="alignment">
++ <property name="alignment" >
+ <set>Qt::AlignVCenter</set>
+ </property>
+- <property name="wordWrap">
++ <property name="wordWrap" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+- <layout class="QHBoxLayout" name="horizontalLayout">
++ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+- <widget class="KPushButton" name="btnChangePassword">
+- <property name="text">
++ <widget class="KPushButton" name="btnChangePassword" >
++ <property name="text" >
+ <string>Change Password...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer>
+- <property name="orientation">
++ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+- <property name="sizeType">
++ <property name="sizeType" >
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+- <property name="sizeHint" stdset="0">
++ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>158</width>
+ <height>18</height>
+@@ -111,122 +107,122 @@
+ </layout>
+ </item>
+ <item>
+- <widget class="QGroupBox" name="grpUserInformation">
+- <property name="title">
++ <widget class="QGroupBox" name="grpUserInformation" >
++ <property name="title" >
+ <string>User Information</string>
+ </property>
+- <layout class="QGridLayout">
+- <item row="0" column="0">
+- <widget class="QLabel" name="lblRealName">
+- <property name="text">
++ <layout class="QGridLayout" >
++ <item row="0" column="0" >
++ <widget class="QLabel" name="lblRealName" >
++ <property name="text" >
+ <string>&amp;Name:</string>
+ </property>
+- <property name="alignment">
++ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+- <property name="wordWrap">
++ <property name="wordWrap" >
+ <bool>false</bool>
+ </property>
+- <property name="buddy">
++ <property name="buddy" >
+ <cstring>leRealname</cstring>
+ </property>
+ </widget>
+ </item>
+- <item row="0" column="1">
+- <widget class="KLineEdit" name="leRealname">
+- <property name="showClearButton" stdset="0">
++ <item row="0" column="1" >
++ <widget class="KLineEdit" name="leRealname" >
++ <property name="showClearButton" stdset="0" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+- <item row="1" column="0">
+- <widget class="QLabel" name="lblOrganisation">
+- <property name="text">
++ <item row="1" column="0" >
++ <widget class="QLabel" name="lblOrganisation" >
++ <property name="text" >
+ <string>&amp;Organization:</string>
+ </property>
+- <property name="alignment">
++ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+- <property name="wordWrap">
++ <property name="wordWrap" >
+ <bool>false</bool>
+ </property>
+- <property name="buddy">
++ <property name="buddy" >
+ <cstring>leOrganization</cstring>
+ </property>
+ </widget>
+ </item>
+- <item row="1" column="1">
+- <widget class="KLineEdit" name="leOrganization">
+- <property name="showClearButton" stdset="0">
++ <item row="1" column="1" >
++ <widget class="KLineEdit" name="leOrganization" >
++ <property name="showClearButton" stdset="0" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+- <item row="2" column="0">
+- <widget class="QLabel" name="lblEmail">
+- <property name="text">
++ <item row="2" column="0" >
++ <widget class="QLabel" name="lblEmail" >
++ <property name="text" >
+ <string>&amp;Email address:</string>
+ </property>
+- <property name="alignment">
++ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+- <property name="wordWrap">
++ <property name="wordWrap" >
+ <bool>false</bool>
+ </property>
+- <property name="buddy">
++ <property name="buddy" >
+ <cstring>leEmail</cstring>
+ </property>
+ </widget>
+ </item>
+- <item row="2" column="1">
+- <widget class="KLineEdit" name="leEmail">
+- <property name="showClearButton" stdset="0">
++ <item row="2" column="1" >
++ <widget class="KLineEdit" name="leEmail" >
++ <property name="showClearButton" stdset="0" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+- <item row="3" column="0">
+- <widget class="QLabel" name="textLabel3">
+- <property name="text">
++ <item row="3" column="0" >
++ <widget class="QLabel" name="textLabel3" >
++ <property name="text" >
+ <string>&amp;SMTP server:</string>
+ </property>
+- <property name="alignment">
++ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+- <property name="wordWrap">
++ <property name="wordWrap" >
+ <bool>false</bool>
+ </property>
+- <property name="buddy">
++ <property name="buddy" >
+ <cstring>leSMTP</cstring>
+ </property>
+ </widget>
+ </item>
+- <item row="3" column="1">
+- <widget class="KLineEdit" name="leSMTP">
+- <property name="showClearButton" stdset="0">
++ <item row="3" column="1" >
++ <widget class="KLineEdit" name="leSMTP" >
++ <property name="showClearButton" stdset="0" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+- <item row="4" column="0">
+- <widget class="QLabel" name="lblUIDTell">
+- <property name="text">
++ <item row="4" column="0" >
++ <widget class="QLabel" name="lblUIDTell" >
++ <property name="text" >
+ <string>User ID:</string>
+ </property>
+- <property name="alignment">
++ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+- <property name="wordWrap">
++ <property name="wordWrap" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+- <item row="4" column="1">
+- <widget class="QLabel" name="lblUID">
+- <property name="text">
++ <item row="4" column="1" >
++ <widget class="QLabel" name="lblUID" >
++ <property name="text" >
+ <string/>
+ </property>
+- <property name="wordWrap">
++ <property name="wordWrap" >
+ <bool>false</bool>
+ </property>
+ </widget>
+@@ -235,28 +231,28 @@
+ </widget>
+ </item>
+ <item>
+- <widget class="KButtonGroup" name="kcfg_EchoMode">
+- <property name="title">
++ <widget class="KButtonGroup" name="kcfg_EchoMode" >
++ <property name="title" >
+ <string>At Password Prompt</string>
+ </property>
+- <layout class="QVBoxLayout" name="verticalLayout_2">
++ <layout class="QVBoxLayout" name="verticalLayout_2" >
+ <item>
+- <widget class="QRadioButton" name="rdbOneStar">
+- <property name="text">
++ <widget class="QRadioButton" name="rdbOneStar" >
++ <property name="text" >
+ <string>Show one bullet for each letter</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+- <widget class="QRadioButton" name="rdbThreeStars">
+- <property name="text">
++ <widget class="QRadioButton" name="rdbThreeStars" >
++ <property name="text" >
+ <string>Show three bullets for each letter</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+- <widget class="QRadioButton" name="rdbShowPassword">
+- <property name="text">
++ <widget class="QRadioButton" name="rdbShowPassword" >
++ <property name="text" >
+ <string>Show nothing</string>
+ </property>
+ </widget>
+@@ -266,13 +262,13 @@
+ </item>
+ <item>
+ <spacer>
+- <property name="orientation">
++ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+- <property name="sizeType">
++ <property name="sizeType" >
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+- <property name="sizeHint" stdset="0">
++ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>20</width>
+ <height>16</height>
+@@ -282,7 +278,7 @@
+ </item>
+ </layout>
+ </widget>
+- <customwidgets>
++ <customwidgets>
+ <customwidget>
+ <class>KButtonGroup</class>
+ <extends>QGroupBox</extends>
+@@ -290,15 +286,15 @@
+ <container>1</container>
+ </customwidget>
+ <customwidget>
+- <class>KPushButton</class>
+- <extends>QPushButton</extends>
+- <header>kpushbutton.h</header>
+- </customwidget>
+- <customwidget>
+ <class>KLineEdit</class>
+ <extends>QLineEdit</extends>
+ <header>klineedit.h</header>
+ </customwidget>
++ <customwidget>
++ <class>KPushButton</class>
++ <extends>QPushButton</extends>
++ <header>kpushbutton.h</header>
++ </customwidget>
+ </customwidgets>
+ <tabstops>
+ <tabstop>btnChangeFace</tabstop>
+Index: webcam.h
+===================================================================
+--- webcam.h (revision 0)
++++ webcam.h (revision 0)
+@@ -0,0 +1,74 @@
++/**
++ * Copyright 2010 Felipe Ortiz <f.ortiz.c@gmail.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ *
++ *
++ * Please see the README
++ *
++ */
++
++/**
++ * @file Webcam interface based on OpenCV
++ * @author Felipe Ortiz
++ */
++
++#ifndef WEBCAM_H
++#define WEBCAM_H
++
++#include <QtCore/QObject>
++#include <QtGui/QImage>
++#include <QtCore/QTimer>
++#include <QtCore/QMap>
++
++#include <solid/device.h>
++#include <solid/video.h>
++
++#include <cv.h>
++#include <highgui.h>
++
++class WebCam : public QObject
++{
++ Q_OBJECT
++
++public:
++ explicit WebCam(int interval = 50, QObject *parent = 0);
++ ~WebCam();
++
++ void setDevice(const int id);
++ void setInterval(const int interval);
++ bool isStopped() const;
++
++ static QMap<int, QString> getCamList();
++
++
++Q_SIGNALS:
++ void newFrame(QImage img);
++
++public Q_SLOTS:
++ void stop();
++ void start();
++ void sendNewFrame();
++
++private:
++ QImage prepareFrame(IplImage *frame);
++
++ QTimer *timer;
++ CvCapture *cam;
++ int intervalTime;
++ int camId;
++ bool stopped;
++
++};
++#endif
+Index: webcam.cpp
+===================================================================
+--- webcam.cpp (revision 0)
++++ webcam.cpp (revision 0)
+@@ -0,0 +1,140 @@
++/**
++ * Copyright 2010 Felipe Ortiz <f.ortiz.c@gmail.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ *
++ *
++ * Please see the README
++ *
++ */
++
++/**
++ * @file Webcam interface based on OpenCV
++ * @author Felipe Ortiz
++ */
++
++#include <klocale.h>
++#include <kmessagebox.h>
++
++#include "webcam.h"
++
++WebCam::WebCam(int interval, QObject *parent) : QObject(parent)
++{
++ intervalTime = interval;
++ stopped = true;
++
++ timer = new QTimer(this);
++ connect(timer, SIGNAL(timeout()), this, SLOT(sendNewFrame()));
++}
++
++WebCam::~WebCam()
++{
++ if(!isStopped()){
++ stop();
++ }
++}
++
++void WebCam::setDevice(const int id)
++{
++ camId = id;
++}
++
++void WebCam::setInterval(const int interval)
++{
++ intervalTime = interval;
++
++ if (!isStopped()) {
++ timer->stop();
++ timer->start(interval);
++ }
++}
++
++bool WebCam::isStopped() const
++{
++ return stopped;
++}
++
++QMap<int, QString> WebCam::getCamList()
++{
++ QMap<int, QString> camList;
++ QList<Solid::Device> devices = Solid::Device::listFromType(Solid::DeviceInterface::Video,
++ QString());
++ foreach (const Solid::Device &dev, devices) {
++ QStringList protocols = dev.as<Solid::Video>()->supportedProtocols();
++
++ if (protocols.contains("video4linux")) {
++ QStringList drivers = dev.as<Solid::Video>()->supportedDrivers("video4linux");
++
++ if (drivers.contains("video4linux")) {
++ QString path = dev.as <Solid::Video>()->driverHandle("video4linux").toString();
++
++ bool ok;
++ int devNumber = path.mid(10).toInt(&ok, 10);
++ if (ok) {
++ camList.insert(devNumber, dev.product());
++ }
++ }
++ }
++ }
++
++ return camList;
++}
++
++void WebCam::stop()
++{
++ if (!isStopped()) {
++ timer->stop();
++
++ if (cam) {
++ cvReleaseCapture(&cam);
++ }
++ stopped = true;
++ }
++}
++
++void WebCam::start()
++{
++ if (isStopped()) {
++ cam = cvCreateCameraCapture(camId);
++
++ if (cam) {
++ timer->start(intervalTime);
++ stopped = false;
++ } else {
++ KMessageBox::sorry(0, i18n("Error while initializing the camera"));
++ }
++ }
++}
++
++QImage WebCam::prepareFrame(IplImage *frame)
++{
++ cvCvtColor(frame, frame, CV_BGR2RGB);
++ cvFlip(frame, frame, 1);
++
++ QImage image((uchar *)frame->imageData,
++ frame->width,
++ frame->height,
++ QImage::Format_RGB888);
++
++// preview = image;
++ return image;
++}
++
++void WebCam::sendNewFrame()
++{
++ IplImage *frame = cvQueryFrame(cam);
++
++ emit newFrame(prepareFrame(frame));
++}
++#include "webcam.moc"
+Index: webcamui.h
+===================================================================
+--- webcamui.h (revision 0)
++++ webcamui.h (revision 0)
+@@ -0,0 +1,60 @@
++/**
++ * Copyright 2010 Felipe Ortiz <f.ortiz.c@gmail.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ *
++ *
++ * Please see the README
++ *
++ */
++
++/**
++ * @file GUI for get picture from a webcam
++ * @author Felipe Ortiz
++ */
++
++#ifndef WEBCAMUI_H
++#define WEBCAMUI_H
++
++#include <kdialog.h>
++
++#include "webcam.h"
++#include "ui_webcamui.h"
++
++class WebCamUi : public KDialog, private Ui::WebCamUi
++{
++ Q_OBJECT
++
++public:
++ explicit WebCamUi(QWidget *parent = 0);
++
++ bool isPhotoTaken() const;
++ QImage getImage() const;
++ QString getImgName() const;
++
++private:
++ void setCboCamera();
++
++private Q_SLOTS:
++ void switchCamera(int index);
++ void showImage(QImage image);
++ void saveImage();
++
++private:
++ QString fname;
++ QImage pix;
++ bool photo;
++ WebCam *cam;
++};
++#endif
+Index: webcamui.cpp
+===================================================================
+--- webcamui.cpp (revision 0)
++++ webcamui.cpp (revision 0)
+@@ -0,0 +1,103 @@
++/**
++ * Copyright 2010 Felipe Ortiz <f.ortiz.c@gmail.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ *
++ *
++ * Please see the README
++ *
++ */
++
++/**
++ * @file GUI for get picture from a webcam
++ * @author Felipe Ortiz
++ */
++
++#include <QtGui/QInputDialog>
++#include <kmessagebox.h>
++
++#include "settings.h"
++#include "webcamui.h"
++
++WebCamUi::WebCamUi(QWidget *parent) : KDialog(parent, Qt::Dialog)
++{
++ photo = false;
++ setupUi(mainWidget());
++ cam = new WebCam(50, this);
++
++ setCboCamera();
++ connect(cboDevice, SIGNAL(activated(int)), this, SLOT(switchCamera(int)));
++ connect(cam, SIGNAL(newFrame(QImage)), this, SLOT(showImage(QImage)));
++ connect(this, SIGNAL(okClicked()), this, SLOT(saveImage()));
++
++ switchCamera(cboDevice->currentIndex());
++}
++
++bool WebCamUi::isPhotoTaken() const
++{
++ return photo;
++}
++
++void WebCamUi::setCboCamera()
++{
++ QMap<int, QString> devices = WebCam::getCamList();
++ QMap<int, QString>::const_iterator i;
++
++ for (i = devices.constBegin(); i != devices.constEnd(); ++i) {
++ cboDevice->addItem(i.value(), i.key());
++ }
++}
++
++void WebCamUi::switchCamera(int index)
++{
++ if (!cam->isStopped()) {
++ cam->stop();
++ }
++ cam->setDevice(cboDevice->itemData(index).toInt());
++ cam->start();
++}
++
++void WebCamUi::showImage(QImage image)
++{
++ QSize size(lbVideo->width(), lbVideo->height());
++
++ lbVideo->setPixmap(QPixmap::fromImage(image.scaled(size, Qt::IgnoreAspectRatio)));
++}
++
++QImage WebCamUi::getImage() const
++{
++ return pix;
++}
++
++QString WebCamUi::getImgName() const
++{
++ return fname;
++}
++
++void WebCamUi::saveImage()
++{
++
++ cam->stop();
++ fname = QInputDialog::getText(this, i18n("New Image"),
++ i18n("Image name:"),
++ QLineEdit::Normal,
++ QString(), &photo);
++
++ if (photo && !fname.isEmpty()) {
++ pix = lbVideo->pixmap()->toImage();
++ }
++}
++
++
++#include "webcamui.moc"
+Index: webcamui.ui
+===================================================================
+--- webcamui.ui (revision 0)
++++ webcamui.ui (revision 0)
+@@ -0,0 +1,82 @@
++<?xml version="1.0" encoding="UTF-8"?>
++<ui version="4.0">
++ <class>WebCamUi</class>
++ <widget class="QWidget" name="WebCamUi">
++ <property name="geometry">
++ <rect>
++ <x>0</x>
++ <y>0</y>
++ <width>539</width>
++ <height>546</height>
++ </rect>
++ </property>
++ <property name="windowTitle">
++ <string>Take a Photo</string>
++ </property>
++ <layout class="QVBoxLayout" name="verticalLayout_2">
++ <item>
++ <layout class="QVBoxLayout" name="verticalLayout">
++ <item>
++ <layout class="QHBoxLayout" name="horizontalLayout">
++ <item>
++ <widget class="QLabel" name="label">
++ <property name="text">
++ <string>Select Device:</string>
++ </property>
++ </widget>
++ </item>
++ <item>
++ <widget class="KComboBox" name="cboDevice"/>
++ </item>
++ <item>
++ <spacer name="horizontalSpacer_2">
++ <property name="orientation">
++ <enum>Qt::Horizontal</enum>
++ </property>
++ <property name="sizeHint" stdset="0">
++ <size>
++ <width>40</width>
++ <height>20</height>
++ </size>
++ </property>
++ </spacer>
++ </item>
++ </layout>
++ </item>
++ </layout>
++ </item>
++ <item>
++ <widget class="QLabel" name="lbVideo">
++ <property name="minimumSize">
++ <size>
++ <width>503</width>
++ <height>420</height>
++ </size>
++ </property>
++ <property name="frameShape">
++ <enum>QFrame::StyledPanel</enum>
++ </property>
++ <property name="text">
++ <string/>
++ </property>
++ </widget>
++ </item>
++ <item>
++ <widget class="Line" name="line_2">
++ <property name="orientation">
++ <enum>Qt::Horizontal</enum>
++ </property>
++ </widget>
++ </item>
++ </layout>
++ </widget>
++ <customwidgets>
++ <customwidget>
++ <class>KComboBox</class>
++ <extends>QComboBox</extends>
++ <header>kcombobox.h</header>
++ </customwidget>
++ </customwidgets>
++ <resources/>
++ <connections/>
++</ui>
diff -Naur kdebase-4.4.2.orig/apps/kdepasswd/kcm/main.h kdebase-4.4.2/apps/kdepasswd/kcm/main.h
--- kdebase-4.4.2.orig/apps/kdepasswd/kcm/main.h 2008-01-05 00:53:59.000000000 +0100
+++ kdebase-4.4.2/apps/kdepasswd/kcm/main.h 2010-04-27 10:56:59.563534198 +0200
@@ -1,6 +1,7 @@
/**
* Copyright (C) 2004 Frans Englich <frans.englich@telia.com>
+ * Copyrigth (C) 2010 Felipe Ortiz <f.ortiz.c@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -31,6 +32,8 @@
class QObject;
class KUrl;
+enum FacePerm { adminOnly = 1, adminFirst = 2, userFirst = 3, userOnly = 4};
+
class MainWidget : public QWidget, public Ui::MainWidget
{
public:
@@ -52,10 +55,10 @@
~KCMUserAccount();
/**
- * The user data is loaded from chfn(/etc/password) and then
+ * The user data is loaded from chfn(/etc/password) and then
* written back as well as to KDE's own(KEmailSettings).
- * The user won't notice this(assuming they change the KDE settings via
- * this KCM) and will make KDE play nice with enviroments which uses
+ * The user won't notice this(assuming they change the KDE settings via
+ * this KCM) and will make KDE play nice with enviroments which uses
* /etc/password.
*/
void load();
diff -Naur kdebase-4.4.2.orig/apps/kdepasswd/kcm/webcam.cpp kdebase-4.4.2/apps/kdepasswd/kcm/webcam.cpp
--- kdebase-4.4.2.orig/apps/kdepasswd/kcm/webcam.cpp 1970-01-01 01:00:00.000000000 +0100
+++ kdebase-4.4.2/apps/kdepasswd/kcm/webcam.cpp 2010-04-27 10:57:07.830200025 +0200
@@ -0,0 +1,140 @@
+/**
+ * Copyright 2010 Felipe Ortiz <f.ortiz.c@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ *
+ *
+ * Please see the README
+ *
+ */
+
+/**
+ * @file Webcam interface based on OpenCV
+ * @author Felipe Ortiz
+ */
+
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "webcam.h"
+
+WebCam::WebCam(int interval, QObject *parent) : QObject(parent)
+{
+ intervalTime = interval;
+ stopped = true;
+
+ timer = new QTimer(this);
+ connect(timer, SIGNAL(timeout()), this, SLOT(sendNewFrame()));
+}
+
+WebCam::~WebCam()
+{
+ if(!isStopped()){
+ stop();
+ }
+}
+
+void WebCam::setDevice(const int id)
+{
+ camId = id;
+}
+
+void WebCam::setInterval(const int interval)
+{
+ intervalTime = interval;
+
+ if (!isStopped()) {
+ timer->stop();
+ timer->start(interval);
+ }
+}
+
+bool WebCam::isStopped() const
+{
+ return stopped;
+}
+
+QMap<int, QString> WebCam::getCamList()
+{
+ QMap<int, QString> camList;
+ QList<Solid::Device> devices = Solid::Device::listFromType(Solid::DeviceInterface::Video,
+ QString());
+ foreach (const Solid::Device &dev, devices) {
+ QStringList protocols = dev.as<Solid::Video>()->supportedProtocols();
+
+ if (protocols.contains("video4linux")) {
+ QStringList drivers = dev.as<Solid::Video>()->supportedDrivers("video4linux");
+
+ if (drivers.contains("video4linux")) {
+ QString path = dev.as <Solid::Video>()->driverHandle("video4linux").toString();
+
+ bool ok;
+ int devNumber = path.mid(10).toInt(&ok, 10);
+ if (ok) {
+ camList.insert(devNumber, dev.product());
+ }
+ }
+ }
+ }
+
+ return camList;
+}
+
+void WebCam::stop()
+{
+ if (!isStopped()) {
+ timer->stop();
+
+ if (cam) {
+ cvReleaseCapture(&cam);
+ }
+ stopped = true;
+ }
+}
+
+void WebCam::start()
+{
+ if (isStopped()) {
+ cam = cvCreateCameraCapture(camId);
+
+ if (cam) {
+ timer->start(intervalTime);
+ stopped = false;
+ } else {
+ KMessageBox::sorry(0, i18n("Error while initializing the camera"));
+ }
+ }
+}
+
+QImage WebCam::prepareFrame(IplImage *frame)
+{
+ cvCvtColor(frame, frame, CV_BGR2RGB);
+ cvFlip(frame, frame, 1);
+
+ QImage image((uchar *)frame->imageData,
+ frame->width,
+ frame->height,
+ QImage::Format_RGB888);
+
+// preview = image;
+ return image;
+}
+
+void WebCam::sendNewFrame()
+{
+ IplImage *frame = cvQueryFrame(cam);
+
+ emit newFrame(prepareFrame(frame));
+}
+#include "webcam.moc"
diff -Naur kdebase-4.4.2.orig/apps/kdepasswd/kcm/webcam.h kdebase-4.4.2/apps/kdepasswd/kcm/webcam.h
--- kdebase-4.4.2.orig/apps/kdepasswd/kcm/webcam.h 1970-01-01 01:00:00.000000000 +0100
+++ kdebase-4.4.2/apps/kdepasswd/kcm/webcam.h 2010-04-27 10:57:07.830200025 +0200
@@ -0,0 +1,74 @@
+/**
+ * Copyright 2010 Felipe Ortiz <f.ortiz.c@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ *
+ *
+ * Please see the README
+ *
+ */
+
+/**
+ * @file Webcam interface based on OpenCV
+ * @author Felipe Ortiz
+ */
+
+#ifndef WEBCAM_H
+#define WEBCAM_H
+
+#include <QtCore/QObject>
+#include <QtGui/QImage>
+#include <QtCore/QTimer>
+#include <QtCore/QMap>
+
+#include <solid/device.h>
+#include <solid/video.h>
+
+#include <cv.h>
+#include <highgui.h>
+
+class WebCam : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit WebCam(int interval = 50, QObject *parent = 0);
+ ~WebCam();
+
+ void setDevice(const int id);
+ void setInterval(const int interval);
+ bool isStopped() const;
+
+ static QMap<int, QString> getCamList();
+
+
+Q_SIGNALS:
+ void newFrame(QImage img);
+
+public Q_SLOTS:
+ void stop();
+ void start();
+ void sendNewFrame();
+
+private:
+ QImage prepareFrame(IplImage *frame);
+
+ QTimer *timer;
+ CvCapture *cam;
+ int intervalTime;
+ int camId;
+ bool stopped;
+
+};
+#endif
diff -Naur kdebase-4.4.2.orig/apps/kdepasswd/kcm/webcamui.cpp kdebase-4.4.2/apps/kdepasswd/kcm/webcamui.cpp
--- kdebase-4.4.2.orig/apps/kdepasswd/kcm/webcamui.cpp 1970-01-01 01:00:00.000000000 +0100
+++ kdebase-4.4.2/apps/kdepasswd/kcm/webcamui.cpp 2010-04-27 10:57:07.832697836 +0200
@@ -0,0 +1,103 @@
+/**
+ * Copyright 2010 Felipe Ortiz <f.ortiz.c@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ *
+ *
+ * Please see the README
+ *
+ */
+
+/**
+ * @file GUI for get picture from a webcam
+ * @author Felipe Ortiz
+ */
+
+#include <QtGui/QInputDialog>
+#include <kmessagebox.h>
+
+#include "settings.h"
+#include "webcamui.h"
+
+WebCamUi::WebCamUi(QWidget *parent) : KDialog(parent, Qt::Dialog)
+{
+ photo = false;
+ setupUi(mainWidget());
+ cam = new WebCam(50, this);
+
+ setCboCamera();
+ connect(cboDevice, SIGNAL(activated(int)), this, SLOT(switchCamera(int)));
+ connect(cam, SIGNAL(newFrame(QImage)), this, SLOT(showImage(QImage)));
+ connect(this, SIGNAL(okClicked()), this, SLOT(saveImage()));
+
+ switchCamera(cboDevice->currentIndex());
+}
+
+bool WebCamUi::isPhotoTaken() const
+{
+ return photo;
+}
+
+void WebCamUi::setCboCamera()
+{
+ QMap<int, QString> devices = WebCam::getCamList();
+ QMap<int, QString>::const_iterator i;
+
+ for (i = devices.constBegin(); i != devices.constEnd(); ++i) {
+ cboDevice->addItem(i.value(), i.key());
+ }
+}
+
+void WebCamUi::switchCamera(int index)
+{
+ if (!cam->isStopped()) {
+ cam->stop();
+ }
+ cam->setDevice(cboDevice->itemData(index).toInt());
+ cam->start();
+}
+
+void WebCamUi::showImage(QImage image)
+{
+ QSize size(lbVideo->width(), lbVideo->height());
+
+ lbVideo->setPixmap(QPixmap::fromImage(image.scaled(size, Qt::IgnoreAspectRatio)));
+}
+
+QImage WebCamUi::getImage() const
+{
+ return pix;
+}
+
+QString WebCamUi::getImgName() const
+{
+ return fname;
+}
+
+void WebCamUi::saveImage()
+{
+
+ cam->stop();
+ fname = QInputDialog::getText(this, i18n("New Image"),
+ i18n("Image name:"),
+ QLineEdit::Normal,
+ QString(), &photo);
+
+ if (photo && !fname.isEmpty()) {
+ pix = lbVideo->pixmap()->toImage();
+ }
+}
+
+
+#include "webcamui.moc"
diff -Naur kdebase-4.4.2.orig/apps/kdepasswd/kcm/webcamui.h kdebase-4.4.2/apps/kdepasswd/kcm/webcamui.h
--- kdebase-4.4.2.orig/apps/kdepasswd/kcm/webcamui.h 1970-01-01 01:00:00.000000000 +0100
+++ kdebase-4.4.2/apps/kdepasswd/kcm/webcamui.h 2010-04-27 10:57:07.832697836 +0200
@@ -0,0 +1,60 @@
+/**
+ * Copyright 2010 Felipe Ortiz <f.ortiz.c@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ *
+ *
+ * Please see the README
+ *
+ */
+
+/**
+ * @file GUI for get picture from a webcam
+ * @author Felipe Ortiz
+ */
+
+#ifndef WEBCAMUI_H
+#define WEBCAMUI_H
+
+#include <kdialog.h>
+
+#include "webcam.h"
+#include "ui_webcamui.h"
+
+class WebCamUi : public KDialog, private Ui::WebCamUi
+{
+ Q_OBJECT
+
+public:
+ explicit WebCamUi(QWidget *parent = 0);
+
+ bool isPhotoTaken() const;
+ QImage getImage() const;
+ QString getImgName() const;
+
+private:
+ void setCboCamera();
+
+private Q_SLOTS:
+ void switchCamera(int index);
+ void showImage(QImage image);
+ void saveImage();
+
+private:
+ QString fname;
+ QImage pix;
+ bool photo;
+ WebCam *cam;
+};
+#endif
diff -Naur kdebase-4.4.2.orig/apps/kdepasswd/kcm/webcamui.ui kdebase-4.4.2/apps/kdepasswd/kcm/webcamui.ui
--- kdebase-4.4.2.orig/apps/kdepasswd/kcm/webcamui.ui 1970-01-01 01:00:00.000000000 +0100
+++ kdebase-4.4.2/apps/kdepasswd/kcm/webcamui.ui 2010-04-27 10:57:07.832697836 +0200
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>WebCamUi</class>
+ <widget class="QWidget" name="WebCamUi">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>539</width>
+ <height>546</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Take a Photo</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Select Device:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="KComboBox" name="cboDevice"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="lbVideo">
+ <property name="minimumSize">
+ <size>
+ <width>503</width>
+ <height>420</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="Line" name="line_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>KComboBox</class>
+ <extends>QComboBox</extends>
+ <header>kcombobox.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>