#include "kcam.h"
#include <KStandardAction>
#include <KApplication>
#include <KActionCollection>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <KLocale>
#include <KAction>

KCam::KCam(QWidget * parent)
        :KXmlGuiWindow(parent)
{



foreach (const Solid::Device &device, Solid::Device::listFromType(Solid::DeviceInterface::Video, QString()))
    {
        kDebug() << device.udi().toLatin1().constData();
        kDebug()<<"vendor:"<<device.product ();

     }




m_cam = new KCamWidget;
m_buttonShot = new KPushButton(KIcon("view-preview"),"take shot");
//m_buttonRecord = new KPushButton(KIcon("media-record"),"record");
QHBoxLayout * hLayout = new QHBoxLayout;
QVBoxLayout * vLayout = new QVBoxLayout;

hLayout->addWidget(m_buttonShot);
//hLayout->addWidget(m_buttonRecord);

vLayout->addWidget(m_cam);
vLayout->addLayout(hLayout);

QWidget * mainWidget = new QWidget;
mainWidget->setLayout(vLayout);

setCentralWidget(mainWidget);
resize(m_cam->resolution());
setupActions();


}
   void KCam::setupActions()
   {
  KStandardAction::quit(kapp, SLOT(quit()),actionCollection());
  KStandardAction::fullScreen(this, SLOT(setViewFullScreen(bool)), this, actionCollection());

  KAction* shotAction = new KAction(this);
  shotAction->setText(i18n("Take Shot"));
  shotAction->setIcon(KIcon("view-preview"));
  actionCollection()->addAction("shot", shotAction);
  connect(shotAction, SIGNAL(triggered(bool)),m_cam, SLOT(takeShoot()));
  connect(m_buttonShot,SIGNAL(clicked()),shotAction,SLOT(trigger ()));


  setupGUI();


   }
