summaryrefslogtreecommitdiffstats
path: root/kamera/kcontrol
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit47d455dd55be855e4cc691c32f687f723d9247ee (patch)
tree52e236aaa2576bdb3840ebede26619692fed6d7d /kamera/kcontrol
downloadtdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.tar.gz
tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kamera/kcontrol')
-rw-r--r--kamera/kcontrol/Makefile.am16
-rw-r--r--kamera/kcontrol/kamera.cpp423
-rw-r--r--kamera/kcontrol/kamera.desktop193
-rw-r--r--kamera/kcontrol/kamera.h115
-rw-r--r--kamera/kcontrol/kameraconfigdialog.cpp317
-rw-r--r--kamera/kcontrol/kameraconfigdialog.h53
-rw-r--r--kamera/kcontrol/kameradevice.cpp476
-rw-r--r--kamera/kcontrol/kameradevice.h117
8 files changed, 1710 insertions, 0 deletions
diff --git a/kamera/kcontrol/Makefile.am b/kamera/kcontrol/Makefile.am
new file mode 100644
index 00000000..9fd30f46
--- /dev/null
+++ b/kamera/kcontrol/Makefile.am
@@ -0,0 +1,16 @@
+kde_module_LTLIBRARIES = kcm_kamera.la
+
+kcm_kamera_la_SOURCES = kamera.cpp kameradevice.cpp kameraconfigdialog.cpp
+
+kcm_kamera_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+kcm_kamera_la_LIBADD = $(LIB_KIO) $(GPHOTO2_LIBS)
+INCLUDES= $(all_includes) $(GPHOTO2_INCS)
+
+kcm_kamera_la_METASOURCES = AUTO
+
+noinst_HEADERS = kamera.h kameradevice.h kameraconfigdialog.h
+
+messages:
+ $(XGETTEXT) $(kcm_kamera_la_SOURCES) -o $(podir)/kcmkamera.pot
+
+xdg_apps_DATA = kamera.desktop
diff --git a/kamera/kcontrol/kamera.cpp b/kamera/kcontrol/kamera.cpp
new file mode 100644
index 00000000..0fdc416a
--- /dev/null
+++ b/kamera/kcontrol/kamera.cpp
@@ -0,0 +1,423 @@
+/*
+
+ Copyright (C) 2001 The Kompany
+ 2002-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
+ 2002-2003 Marcus Meissner <marcus@jet.franken.de>
+ 2003 Nadeem Hasan <nhasan@nadmm.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
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+#include <qlabel.h>
+#include <qlayout.h>
+
+#include <kgenericfactory.h>
+#include <ksimpleconfig.h>
+#include <kaction.h>
+#include <kiconloader.h>
+#include <kmessagebox.h>
+#include <kiconview.h>
+#include <kdialog.h>
+#include <klocale.h>
+#include <ktoolbar.h>
+#include <kpopupmenu.h>
+#include <kprotocolinfo.h>
+#include <kdebug.h>
+
+#include "kameraconfigdialog.h"
+#include "kameradevice.h"
+#include "kamera.h"
+#include "kamera.moc"
+
+typedef KGenericFactory<KKameraConfig, QWidget> KKameraConfigFactory;
+K_EXPORT_COMPONENT_FACTORY( kcm_kamera, KKameraConfigFactory( "kcmkamera" ) )
+
+// --------------- Camera control center module widget ---
+
+KKameraConfig *KKameraConfig::m_instance = NULL;
+
+KKameraConfig::KKameraConfig(QWidget *parent, const char *name, const QStringList &)
+ : KCModule(KKameraConfigFactory::instance(), parent, name)
+{
+ m_devicePopup = new KPopupMenu(this);
+ m_actions = new KActionCollection(this);
+ m_config = new KSimpleConfig(KProtocolInfo::config("camera"));
+
+ m_context = gp_context_new();
+ if (m_context) {
+
+ // Register the callback functions
+ gp_context_set_cancel_func(m_context, cbGPCancel, this);
+ gp_context_set_idle_func(m_context, cbGPIdle, this);
+
+ displayGPSuccessDialogue();
+
+ // load existing configuration
+ load();
+
+ } else {
+
+ displayGPFailureDialogue();
+ }
+
+ // store instance for frontend_prompt
+ m_instance = this;
+}
+
+KKameraConfig::~KKameraConfig()
+{
+ delete m_config;
+}
+
+void KKameraConfig::defaults()
+{
+ load( true );
+}
+
+void KKameraConfig::displayGPFailureDialogue(void)
+{
+ new QLabel(i18n("Unable to initialize the gPhoto2 libraries."), this);
+}
+
+void KKameraConfig::displayGPSuccessDialogue(void)
+{
+ // set the kcontrol module buttons
+ setButtons(Help | Apply | Cancel | Ok);
+
+ // create a layout with two vertical boxes
+ QVBoxLayout *topLayout = new QVBoxLayout(this, 0, 0);
+ topLayout->setAutoAdd(true);
+
+ m_toolbar = new KToolBar(this, "ToolBar");
+ m_toolbar->setMovingEnabled(false);
+
+ // create list of devices
+ m_deviceSel = new KIconView(this);
+
+ connect(m_deviceSel, SIGNAL(rightButtonClicked(QIconViewItem *, const QPoint &)),
+ SLOT(slot_deviceMenu(QIconViewItem *, const QPoint &)));
+ connect(m_deviceSel, SIGNAL(doubleClicked(QIconViewItem *)),
+ SLOT(slot_configureCamera()));
+ connect(m_deviceSel, SIGNAL(selectionChanged(QIconViewItem *)),
+ SLOT(slot_deviceSelected(QIconViewItem *)));
+
+ m_deviceSel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
+
+ // create actions
+ KAction *act;
+
+ act = new KAction(i18n("Add"), "camera", 0, this, SLOT(slot_addCamera()), m_actions, "camera_add");
+ act->setWhatsThis(i18n("Click this button to add a new camera."));
+ act->plug(m_toolbar);
+ m_toolbar->insertLineSeparator();
+ act = new KAction(i18n("Test"), "camera_test", 0, this, SLOT(slot_testCamera()), m_actions, "camera_test");
+ act->setWhatsThis(i18n("Click this button to remove the selected camera from the list."));
+ act->plug(m_toolbar);
+ act = new KAction(i18n("Remove"), "edittrash", 0, this, SLOT(slot_removeCamera()), m_actions, "camera_remove");
+ act->setWhatsThis(i18n("Click this button to remove the selected camera from the list."));
+ act->plug(m_toolbar);
+ act = new KAction(i18n("Configure..."), "configure", 0, this, SLOT(slot_configureCamera()), m_actions, "camera_configure");
+ act->setWhatsThis(i18n("Click this button to change the configuration of the selected camera.<br><br>The availability of this feature and the contents of the Configuration dialog depend on the camera model."));
+ act->plug(m_toolbar);
+ act = new KAction(i18n("Information"), "hwinfo", 0, this, SLOT(slot_cameraSummary()), m_actions, "camera_summary");
+ act->setWhatsThis(i18n("Click this button to view a summary of the current status of the selected camera.<br><br>The availability of this feature and the contents of the Configuration dialog depend on the camera model."));
+ act->plug(m_toolbar);
+ m_toolbar->insertLineSeparator();
+ act = new KAction(i18n("Cancel"), "stop", 0, this, SLOT(slot_cancelOperation()), m_actions, "camera_cancel");
+ act->setWhatsThis(i18n("Click this button to cancel the current camera operation."));
+ act->setEnabled(false);
+ act->plug(m_toolbar);
+}
+
+void KKameraConfig::populateDeviceListView(void)
+{
+ m_deviceSel->clear();
+ CameraDevicesMap::Iterator it;
+ for (it = m_devices.begin(); it != m_devices.end(); it++) {
+ if (it.data()) {
+ new QIconViewItem(m_deviceSel, it.key(), DesktopIcon("camera"));
+ }
+ }
+ slot_deviceSelected(m_deviceSel->currentItem());
+}
+
+void KKameraConfig::save(void)
+{
+ CameraDevicesMap::Iterator it;
+
+ for (it = m_devices.begin(); it != m_devices.end(); it++)
+ {
+ it.data()->save(m_config);
+ }
+ m_config->sync();
+}
+
+void KKameraConfig::load(void)
+{
+ load( false );
+}
+
+void KKameraConfig::load(bool useDefaults )
+{
+ m_config->setReadDefaults( useDefaults );
+ QStringList groupList = m_config->groupList();
+ QStringList::Iterator it;
+ int i, count;
+ CameraList *list;
+ CameraAbilitiesList *al;
+ GPPortInfoList *il;
+ const char *model, *value;
+ KCamera *kcamera;
+
+ for (it = groupList.begin(); it != groupList.end(); it++) {
+ if (*it != "<default>") {
+ m_config->setGroup(*it);
+ if (m_config->readEntry("Path").contains("usb:"))
+ continue;
+
+ kcamera = new KCamera(*it,m_config->readEntry("Path"));
+ connect(kcamera, SIGNAL(error(const QString &)), SLOT(slot_error(const QString &)));
+ connect(kcamera, SIGNAL(error(const QString &, const QString &)), SLOT(slot_error(const QString &, const QString &)));
+ kcamera->load(m_config);
+ m_devices[*it] = kcamera;
+ }
+ }
+ m_cancelPending = false;
+
+ gp_list_new (&list);
+
+ gp_abilities_list_new (&al);
+ gp_abilities_list_load (al, m_context);
+ gp_port_info_list_new (&il);
+ gp_port_info_list_load (il);
+ gp_abilities_list_detect (al, il, list, m_context);
+ gp_abilities_list_free (al);
+ gp_port_info_list_free (il);
+
+ count = gp_list_count (list);
+
+ QMap<QString,QString> ports, names;
+
+ for (i = 0 ; i<count ; i++) {
+ gp_list_get_name (list, i, &model);
+ gp_list_get_value (list, i, &value);
+
+ ports[value] = model;
+ if (!strcmp(value,"usb:"))
+ names[model] = value;
+ }
+ if (ports.contains("usb:") && names[ports["usb:"]]!="usb:")
+ ports.remove("usb:");
+
+ QMap<QString,QString>::iterator portit;
+
+ for (portit = ports.begin() ; portit != ports.end(); portit++) {
+ /* kdDebug() << "Adding USB camera: " << portit.data() << " at " << portit.key() << endl; */
+
+ kcamera = new KCamera(portit.data(),portit.key());
+ connect(kcamera, SIGNAL(error(const QString &)), SLOT(slot_error(const QString &)));
+ connect(kcamera, SIGNAL(error(const QString &, const QString &)), SLOT(slot_error(const QString &, const QString &)));
+ m_devices[portit.data()] = kcamera;
+ }
+ populateDeviceListView();
+
+ gp_list_free (list);
+
+ emit changed( useDefaults );
+}
+
+void KKameraConfig::beforeCameraOperation(void)
+{
+ m_cancelPending = false;
+
+ m_actions->action("camera_test")->setEnabled(false);
+ m_actions->action("camera_remove")->setEnabled(false);
+ m_actions->action("camera_configure")->setEnabled(false);
+ m_actions->action("camera_summary")->setEnabled(false);
+
+ m_actions->action("camera_cancel")->setEnabled(true);
+}
+
+void KKameraConfig::afterCameraOperation(void)
+{
+ m_actions->action("camera_cancel")->setEnabled(false);
+
+ // if we're regaining control after a Cancel...
+ if (m_cancelPending) {
+ qApp->restoreOverrideCursor();
+ m_cancelPending = false;
+ }
+
+ // if any item was selected before the operation was run
+ // it makes sense for the relevant toolbar buttons to be enabled
+ slot_deviceSelected(m_deviceSel->currentItem());
+}
+
+QString KKameraConfig::suggestName(const QString &name)
+{
+ QString new_name = name;
+ new_name.replace("/", ""); // we cannot have a slash in a URI's host
+
+ if (!m_devices.contains(new_name)) return new_name;
+
+ // try new names with a number appended until we find a free one
+ int i = 1;
+ while (i++ < 0xffff) {
+ new_name = name + " (" + QString::number(i) + ")";
+ if (!m_devices.contains(new_name)) return new_name;
+ }
+
+ return QString::null;
+}
+
+void KKameraConfig::slot_addCamera()
+{
+ KCamera *m_device = new KCamera(QString::null,QString::null);
+ connect(m_device, SIGNAL(error(const QString &)), SLOT(slot_error(const QString &)));
+ connect(m_device, SIGNAL(error(const QString &, const QString &)), SLOT(slot_error(const QString &, const QString &)));
+ KameraDeviceSelectDialog dialog(this, m_device);
+ if (dialog.exec() == QDialog::Accepted) {
+ dialog.save();
+ m_device->setName(suggestName(m_device->model()));
+ m_devices.insert(m_device->name(), m_device);
+ populateDeviceListView();
+ emit changed(true);
+ } else {
+ delete m_device;
+ }
+}
+
+void KKameraConfig::slot_removeCamera()
+{
+ QString name = m_deviceSel->currentItem()->text();
+ if (m_devices.contains(name)) {
+ KCamera *m_device = m_devices[name];
+ m_devices.remove(name);
+ delete m_device;
+ m_config->deleteGroup(name, true);
+ populateDeviceListView();
+ emit changed(true);
+ }
+}
+
+void KKameraConfig::slot_testCamera()
+{
+ beforeCameraOperation();
+
+ QString name = m_deviceSel->currentItem()->text();
+ if (m_devices.contains(name)) {
+ KCamera *m_device = m_devices[name];
+ if (m_device->test())
+ KMessageBox::information(this, i18n("Camera test was successful."));
+ }
+
+ afterCameraOperation();
+}
+
+void KKameraConfig::slot_configureCamera()
+{
+ QString name = m_deviceSel->currentItem()->text();
+ if (m_devices.contains(name)) {
+ KCamera *m_device = m_devices[name];
+ m_device->configure();
+ }
+}
+
+void KKameraConfig::slot_cameraSummary()
+{
+ QString summary;
+ QString name = m_deviceSel->currentItem()->text();
+ if (m_devices.contains(name)) {
+ KCamera *m_device = m_devices[name];
+ summary = m_device->summary();
+ if (!summary.isNull()) {
+ KMessageBox::information(this, summary);
+ }
+ }
+}
+
+void KKameraConfig::slot_cancelOperation()
+{
+ m_cancelPending = true;
+ // Prevent the user from keeping clicking Cancel
+ m_actions->action("camera_cancel")->setEnabled(false);
+ // and indicate that the click on Cancel did have some effect
+ qApp->setOverrideCursor(Qt::WaitCursor);
+}
+
+void KKameraConfig::slot_deviceMenu(QIconViewItem *item, const QPoint &point)
+{
+ if (item) {
+ m_devicePopup->clear();
+ m_actions->action("camera_test")->plug(m_devicePopup);
+ m_actions->action("camera_remove")->plug(m_devicePopup);
+ m_actions->action("camera_configure")->plug(m_devicePopup);
+ m_actions->action("camera_summary")->plug(m_devicePopup);
+ m_devicePopup->popup(point);
+ }
+}
+
+void KKameraConfig::slot_deviceSelected(QIconViewItem *item)
+{
+ m_actions->action("camera_test")->setEnabled(item);
+ m_actions->action("camera_remove")->setEnabled(item);
+ m_actions->action("camera_configure")->setEnabled(item);
+ m_actions->action("camera_summary")->setEnabled(item);
+}
+
+void KKameraConfig::cbGPIdle(GPContext * /*context*/, void * /*data*/)
+{
+ /*KKameraConfig *self( reinterpret_cast<KKameraConfig*>(data) );*/
+
+ qApp->processEvents();
+}
+
+GPContextFeedback KKameraConfig::cbGPCancel(GPContext * /*context*/, void *data)
+{
+ KKameraConfig *self( reinterpret_cast<KKameraConfig*>(data) );
+
+ // Since in practice no camera driver supports idle callbacks yet,
+ // we'll use the cancel callback as opportunity to process events
+ qApp->processEvents();
+
+ // If a cancel request is pending, ask gphoto to cancel
+ if (self->m_cancelPending)
+ return GP_CONTEXT_FEEDBACK_CANCEL;
+ else
+ return GP_CONTEXT_FEEDBACK_OK;
+}
+
+QString KKameraConfig::quickHelp() const
+{
+ return i18n("<h1>Digital Camera</h1>\n"
+ "This module allows you to configure support for your digital camera.\n"
+ "You would need to select the camera's model and the port it is connected\n"
+ "to on your computer (e.g. USB, Serial, Firewire). If your camera doesn't\n"
+ "appear in the list of <i>Supported Cameras</i>, go to the\n"
+ "<a href=\"http://www.gphoto.org\">GPhoto web site</a> for a possible update.<br><br>\n"
+ "To view and download images from the digital camera, go to address\n"
+ "<a href=\"camera:/\">camera:/</a> in Konqueror and other KDE applications.");
+}
+
+void KKameraConfig::slot_error(const QString &message)
+{
+ KMessageBox::error(this, message);
+}
+
+void KKameraConfig::slot_error(const QString &message, const QString &details)
+{
+ KMessageBox::detailedError(this, message, details);
+}
+
diff --git a/kamera/kcontrol/kamera.desktop b/kamera/kcontrol/kamera.desktop
new file mode 100644
index 00000000..0fda1401
--- /dev/null
+++ b/kamera/kcontrol/kamera.desktop
@@ -0,0 +1,193 @@
+[Desktop Entry]
+Comment=Configure Kamera
+Comment[af]=Konfigureer Kamera
+Comment[ar]=إعداد Kamera
+Comment[az]=Kameranı Quraşdır
+Comment[bg]=Настройване на цифров фотоапарат
+Comment[br]=Kefluniañ Kamera
+Comment[bs]=Podesi kameru
+Comment[ca]=Configura Kamera
+Comment[cs]=Nastavení Kamery
+Comment[cy]=Ffurfweddu Kamera
+Comment[da]=Indstil kamera
+Comment[de]=Kamera einrichten
+Comment[el]=Ρύθμιση Kamera
+Comment[eo]=Agordu fotilon
+Comment[es]=Configura Kamera
+Comment[et]=Kaamera seadistamine
+Comment[eu]=Konfiguratu Kamera
+Comment[fa]=پیکربندی Kamera
+Comment[fi]=Kameran asetukset
+Comment[fr]=Configuration de Kamera
+Comment[ga]=Cumraigh Kamera
+Comment[gl]=Configurar Kamera
+Comment[he]=שינוי הגדרות Kamera
+Comment[hi]=कॉन्फ़िगर केमरा
+Comment[hr]=Podesi Kameru
+Comment[hu]=A digitális fényképezőgépek beállításai
+Comment[id]=Konfigurasi kamera
+Comment[is]=Stilla samskiptaforrit stafrænna myndavéla (Kamera)
+Comment[it]=Configura Kamera
+Comment[ja]=カメラの設定
+Comment[kk]=Kamera баптаулары
+Comment[km]=កំណត់​រចនាសម្ព័ន្ធ Kamera
+Comment[ko]=카메라 설정
+Comment[lt]=Konfigūruoti Kamera
+Comment[mk]=Конфигурирајте ја Kamera
+Comment[ms]=Konfigurasi Kamera
+Comment[mt]=Ikkonfigura Kamera
+Comment[nb]=Tilpass Kamera
+Comment[nds]=Kamera instellen
+Comment[ne]=क्यामेरा कन्फिगर गर्नुहोस्
+Comment[nl]=Camera instellen
+Comment[nn]=Set opp Kamera
+Comment[nso]=Beakanya Kamera
+Comment[pa]=ਕੈਮਰਾ ਸੰਰਚਨਾ
+Comment[pl]=Konfiguracja Kamery
+Comment[pt]=Configuração do Kamera
+Comment[pt_BR]=Configurar Kamera
+Comment[ro]=Configurează aparatul foto digital
+Comment[ru]=Настройка камеры
+Comment[se]=Heivet govvenapperáhta
+Comment[sk]=Nastaviť program Kamera
+Comment[sl]=Nastavitve fotoaparata
+Comment[sr]=Подеси Kamera-у
+Comment[sr@Latn]=Podesi Kamera-u
+Comment[sv]=Anpassa kamera
+Comment[ta]=காமிராவை அமை
+Comment[tg]=Танзимоти камера
+Comment[th]=ปรับแต่ง Kamera
+Comment[tr]=Kamera'yı Yapılandır
+Comment[uk]=Налаштувати Kamera
+Comment[uz]=Fotoaparatni moslash
+Comment[uz@cyrillic]=Фотоапаратни мослаш
+Comment[ven]=Dzudzanya kamera
+Comment[xh]=Qwalasela Umfoti
+Comment[zh_CN]=配置 Kamera
+Comment[zh_HK]=設定 Kamera
+Comment[zh_TW]=設定照相機
+Comment[zu]=Hlanganisa ikhamera
+Keywords=gphoto,camera,digicam,webcam,kamera
+Keywords[ar]=gphoto,كاميرا,كاميرا رقمية,كاميرا ويب,kamera
+Keywords[az]=gphoto,kamera,digicam,veb kamera,Kamera,webcam
+Keywords[bg]=фото, апарат, фотоапарат, камера, цифров, цифрова, gphoto, camera, digicam, webcam, kamera
+Keywords[br]=gphoto,kamera,digicam,webcam,kamera
+Keywords[ca]=gphoto,càmera,digicam,webcam,kamera
+Keywords[cs]=gphoto,Kamera,Digitální kamera,Webová kamera,Foto
+Keywords[da]=gphoto,kamera,digicam,webcam
+Keywords[de]=gphoto,Kamera,Digicam,Webcam,Digitalkamera
+Keywords[el]=gphoto,κάμερα,digicam,webcam,kamera
+Keywords[eo]=gphoto,kamerao,fotilo,cifereca fotilo,TTT-fotilo
+Keywords[es]=gphoto,cámara,digicam,webcam,kamera
+Keywords[et]=gphoto,kaamera,digitaalkaamera,veebikaamera,kamera
+Keywords[eu]=gphoto,kamera,digicam,webcam,kamera
+Keywords[fa]=gphoto، دوربین، دوربین رقمی، دوربین وب، kamera
+Keywords[fi]=gphoto,kamera,digicam,webcam
+Keywords[fr]=gphoto,camera,digicam,webcam,kamera,caméscope,caméra,appareil photo
+Keywords[he]=gphoto,kamera,מצלמה,מצלמת רשת,מצלמה דיגיטלית, amera,digicam,webcam
+Keywords[hi]=जीफोटो,केमरा,डिजिकेम,वेबकेम,केमरा
+Keywords[hu]=gphoto,fényképezőgép,digitális fényképezőgép,webkamera,videókamera
+Keywords[is]=gphoto,myndavél,stafræn myndavél,webcam,kamera
+Keywords[it]=gphoto,fotocamera,macchina fotografica digitale,webcam,kamera
+Keywords[ja]=gphoto,カメラ,デジカム,ウェブカム,kamera
+Keywords[km]=gphoto,ម៉ាស៊ីន​ថត​រូប,digicam,ម៉ាស៊ីនថត​តាម​បណ្ដាញ,kamera
+Keywords[ko]=gphoto,camera,digicam,webcam,kamera,사진,카메라,사진기,웹캠
+Keywords[lv]=gfoto,camera,digicam,webcam,kamera
+Keywords[nb]=gphoto,kamera,digicam,webcam,webkamera
+Keywords[nds]=gphoto,Kamera,Webcam,Kamera,Nettkamera
+Keywords[ne]=जी फोटो, क्यामेरा, डिजिक्याम, वेबक्याम, कामेरा
+Keywords[nl]=gphoto,camera,digicam,webcam,kamera,foto
+Keywords[nn]=gphoto,fotoapparat,digitalt kamera,webkamera,vevkamera,kamera
+Keywords[pl]=gphoto,kamera,kamera cyfrowa,kamera sieciowa
+Keywords[pt]=gphoto,câmara,digicam,webcam,kamera
+Keywords[pt_BR]=gphoto,câmera,câmera digital,webcam,kamera
+Keywords[ro]=gphoto,aparat,foto,digicam,webcam,camera,kamera
+Keywords[ru]=gphoto,camera,digicam,webcam,kamera,камера,фото
+Keywords[sl]=gphoto,kamera,digicam,webcam,foto,fotoaparat,spletna kamera
+Keywords[sr]=gphoto,camera,digicam,webcam,kamera,камера
+Keywords[sr@Latn]=gphoto,camera,digicam,webcam,kamera,kamera
+Keywords[sv]=gphoto,kamera,digital kamera,webbkamera,kamera
+Keywords[ta]=ஜிபோட்டோ, காமிரா, டிஜிகேம்,வலைதள காமிரா, காமிரா
+Keywords[tg]=gphoto,camera,digicam,webcam,kamera,камера,фото
+Keywords[tr]=gphoto,kamera,digicam,web kamera,Kamera,webcam
+Keywords[uk]=gphoto,камера,цифрова камера,камера Тенет,kamera
+Keywords[ven]=Tshinepe tsha g,Tshaudzhia zwifanyiso,digicam,webcam,Tshaudzhiazwifanyiso
+Keywords[xh]=gphoto,umfoti,digicam,webcam,umfoti
+Keywords[zh_CN]=gphoto,camera,digicam,webcam,kamera,照相机,数码相机,摄像头
+Keywords[zh_TW]=gphoto,camera,digicam,webcam,kamera,照相機
+Keywords[zu]=gphoto,ikhamera,digicam,webcam,ikhamera
+Name=Digital Camera
+Name[af]=Digitaal Kamera
+Name[ar]=كاميرا رقمية
+Name[az]=Digital Kamera
+Name[bg]=Фотоапарат
+Name[br]=Kamera niverel
+Name[bs]=Digitalna kamera
+Name[ca]=Càmera digital
+Name[cs]=Digitální fotoaparát
+Name[cy]=Camera Digidol
+Name[da]=Digitalt kamera
+Name[de]=Digitalkamera
+Name[el]=Ψηφιακή κάμερα
+Name[eo]=Cifereca fotilo
+Name[es]=Cámara digital
+Name[et]=Digitaalkaamera
+Name[eu]=Kamera digitala
+Name[fa]=دوربین رقمی
+Name[fi]=Digitaalikamera
+Name[fr]=Appareil photo numérique
+Name[ga]=Ceamara Digiteach
+Name[gl]=Cámara dixital
+Name[he]=מצלמה דיגיטלית
+Name[hi]=डिजिटल कैमरा
+Name[hr]=Digitalna kamera
+Name[hu]=Digitális fényképezőgép
+Name[is]=Stafræn myndavél
+Name[it]=Macchina fotografica digitale
+Name[ja]=デジタルカメラ
+Name[kk]=Цифрлық камера
+Name[km]=ម៉ាស៊ីន​ថតរូប​ឌីជីថល
+Name[lt]=Skaitmeninė kamera
+Name[lv]=Digitālā Kamera
+Name[mk]=Дигитална камера
+Name[ms]=Kamera Digital
+Name[mt]=Kamera diġitali
+Name[nb]=Digitalkamera
+Name[nds]=Digitaalkamera
+Name[ne]= डिजिटल क्यामेरा
+Name[nl]=Digitale camera
+Name[nn]=Digitalkamera
+Name[nso]=Camera ya Digital
+Name[pa]=ਡਿਜ਼ੀਟਲ ਕੈਮਰਾ
+Name[pl]=Aparat cyfrowy
+Name[pt]=Máquina Fotográfica Digital
+Name[pt_BR]=Câmera Digital
+Name[ro]=Aparat foto digital
+Name[ru]=Цифровая камера
+Name[se]=Digitalalaš govvenapperáhtta
+Name[sk]=Digitálny fotoaparát
+Name[sl]=Digitalni fotoaparat
+Name[sr]=Дигитална камера
+Name[sr@Latn]=Digitalna kamera
+Name[sv]=Digitalkamera
+Name[ta]= Digital Camera
+Name[tg]=Камераи digital
+Name[th]=กล้องดิจิตอล
+Name[tr]=Sayısal Kamera
+Name[uk]=Цифровий фотоапарат
+Name[uz]=Fotoaparat
+Name[uz@cyrillic]=Фотоапарат
+Name[ven]=Tshau dzhia zwifanyiso tsha didzhithala
+Name[xh]=Ikhamera Yesuntswana
+Name[zh_CN]=数码相机
+Name[zh_HK]=數碼相機
+Name[zh_TW]=數位相機
+Name[zu]=Ikhamera ebonisa inani ngalinye
+Terminal=false
+Type=Application
+X-KDE-Library=kamera
+X-KDE-ModuleType=Library
+Icon=camera
+Exec=kcmshell kamera
+DocPath=kamera/index.html
+Categories=Qt;KDE;Settings;X-KDE-settings-hardware;
diff --git a/kamera/kcontrol/kamera.h b/kamera/kcontrol/kamera.h
new file mode 100644
index 00000000..35f93bc0
--- /dev/null
+++ b/kamera/kcontrol/kamera.h
@@ -0,0 +1,115 @@
+/*
+
+ Copyright (C) 2001 The Kompany
+ 2002-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
+ 2002-2003 Marcus Meissner <marcus@jet.franken.de>
+ 2003 Nadeem Hasan <nhasan@nadmm.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
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+#ifndef __kamera_h__
+#define __kamera_h__
+
+#include <kcmodule.h>
+#include <gphoto2.h>
+
+class QWidget;
+class QRadioButton;
+class QPushButton;
+class QComboBox;
+class QVButtonGroup;
+class QLineEdit;
+class QWidgetStack;
+class QCheckBox;
+class QIconViewItem;
+
+class KCamera;
+class KameraDeviceSelectDialog;
+class KSimpleConfig;
+class KIconView;
+class KActionCollection;
+class KToolBar;
+class KPopupMenu;
+
+class KKameraConfig : public KCModule
+{
+ Q_OBJECT
+ friend class KameraDeviceSelectDialog;
+
+public:
+ KKameraConfig(QWidget *parent, const char *name, const QStringList &);
+ virtual ~KKameraConfig();
+
+ // KCModule interface methods
+ void load();
+ void load(bool useDefaults);
+ void save();
+ void defaults();
+ int buttons();
+ QString quickHelp() const;
+
+protected:
+ QString suggestName(const QString &name);
+
+protected slots:
+ void slot_deviceMenu(QIconViewItem *item, const QPoint &point);
+ void slot_deviceSelected(QIconViewItem *item);
+ void slot_addCamera();
+ void slot_removeCamera();
+ void slot_configureCamera();
+ void slot_cameraSummary();
+ void slot_testCamera();
+ void slot_cancelOperation();
+ void slot_error(const QString &message);
+ void slot_error(const QString &message, const QString &details);
+
+private:
+ void displayGPFailureDialogue(void);
+ void displayGPSuccessDialogue(void);
+ void displayCameraAbilities(const CameraAbilities &abilities);
+ void populateDeviceListView(void);
+ void beforeCameraOperation(void);
+ void afterCameraOperation(void);
+
+ // gphoto callbacks
+ static void cbGPIdle(GPContext *context, void *data);
+ static GPContextFeedback cbGPCancel(GPContext *context, void *data);
+
+private:
+ typedef QMap<QString, KCamera *> CameraDevicesMap;
+
+ KSimpleConfig *m_config;
+ CameraDevicesMap m_devices;
+ bool m_cancelPending;
+
+ // gphoto members
+ GPContext *m_context;
+
+ // widgets for the cameras listview
+ KIconView *m_deviceSel;
+ KActionCollection *m_actions;
+ QPushButton *m_addCamera, *m_removeCamera, *m_testCamera, *m_configureCamera;
+ KToolBar *m_toolbar;
+ KPopupMenu *m_devicePopup;
+
+ // true if libgphoto2 was initialised successfully in
+ // the constructor
+ bool m_gpInitialised;
+
+ static KKameraConfig *m_instance;
+};
+
+#endif
diff --git a/kamera/kcontrol/kameraconfigdialog.cpp b/kamera/kcontrol/kameraconfigdialog.cpp
new file mode 100644
index 00000000..5af0b33d
--- /dev/null
+++ b/kamera/kcontrol/kameraconfigdialog.cpp
@@ -0,0 +1,317 @@
+/*
+
+ Copyright (C) 2001 The Kompany
+ 2002-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
+ 2002-2003 Marcus Meissner <marcus@jet.franken.de>
+ 2003 Nadeem Hasan <nhasan@nadmm.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
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+#include <qlayout.h>
+#include <qgrid.h>
+#include <qlabel.h>
+#include <qvgroupbox.h>
+#include <qcheckbox.h>
+#include <qradiobutton.h>
+#include <qlineedit.h>
+#include <qcombobox.h>
+#include <qslider.h>
+#include <qvbuttongroup.h>
+#include <qhbuttongroup.h>
+#include <qvbox.h>
+#include <qtabwidget.h>
+#include <qwhatsthis.h>
+
+#include <klocale.h>
+
+#include "kameraconfigdialog.h"
+#include "kameraconfigdialog.moc"
+
+KameraConfigDialog::KameraConfigDialog(Camera */*camera*/,
+ CameraWidget *widget,
+ QWidget *parent,
+ const char *name) :
+KDialogBase(parent, name, true, QString::null, Ok|Cancel, Ok ),
+m_widgetRoot(widget)
+{
+ QFrame *main = makeMainWidget();
+ QVBoxLayout *topLayout = new QVBoxLayout(main, 0, spacingHint());
+ topLayout->setAutoAdd(true);
+
+ m_tabWidget = 0;
+
+ appendWidget(main, widget);
+}
+
+void KameraConfigDialog::appendWidget(QWidget *parent, CameraWidget *widget)
+{
+ QWidget *newParent = parent;
+
+ CameraWidgetType widget_type;
+ const char *widget_name;
+ const char *widget_info;
+ const char *widget_label;
+ float widget_value_float;
+ int widget_value_int;
+ const char *widget_value_string;
+ gp_widget_get_type(widget, &widget_type);
+ gp_widget_get_label(widget, &widget_label);
+ gp_widget_get_info(widget, &widget_info);
+ gp_widget_get_name(widget, &widget_name);
+
+ QString whats_this = QString::fromLocal8Bit(widget_info); // gphoto2 doesn't seem to have any standard for i18n
+
+ // Add this widget to parent
+ switch(widget_type) {
+ case GP_WIDGET_WINDOW:
+ {
+ setCaption(widget_label);
+
+ break;
+ }
+ case GP_WIDGET_SECTION:
+ {
+ if (!m_tabWidget)
+ m_tabWidget = new QTabWidget(parent);
+ QWidget *tab = new QWidget(m_tabWidget);
+ // widgets are to be aligned vertically in the tab
+ QVBoxLayout *tabLayout = new QVBoxLayout(tab, marginHint(),
+ spacingHint());
+ m_tabWidget->insertTab(tab, widget_label);
+ QVBox *tabContainer = new QVBox(tab);
+ tabContainer->setSpacing(spacingHint());
+ tabLayout->addWidget(tabContainer);
+ newParent = tabContainer;
+
+ tabLayout->addStretch();
+
+ break;
+ }
+ case GP_WIDGET_TEXT:
+ {
+ gp_widget_get_value(widget, &widget_value_string);
+
+ QGrid *grid = new QGrid(2, Horizontal, parent);
+ grid->setSpacing(spacingHint());
+ new QLabel(QString::fromLocal8Bit( widget_label )+":", grid);
+ QLineEdit *lineEdit = new QLineEdit(widget_value_string, grid);
+ m_wmap.insert(widget, lineEdit);
+
+ if (!whats_this.isEmpty())
+ QWhatsThis::add(grid, whats_this);
+
+ break;
+ }
+ case GP_WIDGET_RANGE:
+ {
+ float widget_low;
+ float widget_high;
+ float widget_increment;
+ gp_widget_get_range(widget, &widget_low, &widget_high, &widget_increment);
+ gp_widget_get_value(widget, &widget_value_float);
+
+ QGroupBox *groupBox = new QVGroupBox(widget_label, parent);
+ QSlider *slider = new QSlider(
+ ( int )widget_low,
+ ( int )widget_high,
+ ( int )widget_increment,
+ ( int )widget_value_float,
+ QSlider::Horizontal,
+ groupBox );
+ m_wmap.insert(widget, slider);
+
+ if (!whats_this.isEmpty())
+ QWhatsThis::add(groupBox, whats_this);
+
+ break;
+ }
+ case GP_WIDGET_TOGGLE:
+ {
+ gp_widget_get_value(widget, &widget_value_int);
+
+ QCheckBox *checkBox = new QCheckBox(widget_label, parent);
+ checkBox->setChecked(widget_value_int);
+ m_wmap.insert(widget, checkBox);
+
+ if (!whats_this.isEmpty())
+ QWhatsThis::add(checkBox, whats_this);
+
+ break;
+ }
+ case GP_WIDGET_RADIO:
+ {
+ gp_widget_get_value(widget, &widget_value_string);
+
+ int count = gp_widget_count_choices(widget);
+
+ // for less than 5 options, align them horizontally
+ QButtonGroup *buttonGroup;
+ if (count > 4)
+ buttonGroup = new QVButtonGroup(widget_label, parent);
+ else
+ buttonGroup = new QHButtonGroup(widget_label, parent);
+
+ for(int i = 0; i < count; ++i) {
+ const char *widget_choice;
+ gp_widget_get_choice(widget, i, &widget_choice);
+
+ new QRadioButton(widget_choice, buttonGroup);
+ if(!strcmp(widget_value_string, widget_choice))
+ buttonGroup->setButton(i);
+ }
+ m_wmap.insert(widget, buttonGroup);
+
+ if (!whats_this.isEmpty())
+ QWhatsThis::add(buttonGroup, whats_this);
+
+ break;
+ }
+ case GP_WIDGET_MENU:
+ {
+ gp_widget_get_value(widget, &widget_value_string);
+
+ QComboBox *comboBox = new QComboBox(FALSE, parent);
+ comboBox->clear();
+ for(int i = 0; i < gp_widget_count_choices(widget); ++i) {
+ const char *widget_choice;
+ gp_widget_get_choice(widget, i, &widget_choice);
+
+ comboBox->insertItem(widget_choice);
+ if(!strcmp(widget_value_string, widget_choice))
+ comboBox->setCurrentItem(i);
+ }
+ m_wmap.insert(widget, comboBox);
+
+ if (!whats_this.isEmpty())
+ QWhatsThis::add(comboBox, whats_this);
+
+ break;
+ }
+ case GP_WIDGET_BUTTON:
+ {
+ // TODO
+ // I can't see a way of implementing this. Since there is
+ // no way of telling which button sent you a signal, we
+ // can't map to the appropriate widget->callback
+ new QLabel(i18n("Button (not supported by KControl)"), parent);
+
+ break;
+ }
+ case GP_WIDGET_DATE:
+ {
+ // TODO
+ new QLabel(i18n("Date (not supported by KControl)"), parent);
+
+ break;
+ }
+ default:
+ return;
+ }
+
+ // Append all this widgets children
+ for(int i = 0; i < gp_widget_count_children(widget); ++i) {
+ CameraWidget *widget_child;
+ gp_widget_get_child(widget, i, &widget_child);
+ appendWidget(newParent, widget_child);
+ }
+
+ // Things that must be done after all children were added
+/*
+ switch (widget_type) {
+ case GP_WIDGET_SECTION:
+ {
+ tabLayout->addItem( new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding) );
+ break;
+ }
+ }
+*/
+}
+
+void KameraConfigDialog::updateWidgetValue(CameraWidget *widget)
+{
+ CameraWidgetType widget_type;
+ gp_widget_get_type(widget, &widget_type);
+
+ switch(widget_type) {
+ case GP_WIDGET_WINDOW:
+ // nothing to do
+ break;
+ case GP_WIDGET_SECTION:
+ // nothing to do
+ break;
+ case GP_WIDGET_TEXT:
+ {
+ QLineEdit *lineEdit = static_cast<QLineEdit *>(m_wmap[widget]);
+ gp_widget_set_value(widget, (void *)lineEdit->text().local8Bit().data());
+
+ break;
+ }
+ case GP_WIDGET_RANGE:
+ {
+ QSlider *slider = static_cast<QSlider *>(m_wmap[widget]);
+ float value_float = slider->value();
+ gp_widget_set_value(widget, (void *)&value_float);
+
+ break;
+ }
+ case GP_WIDGET_TOGGLE:
+ {
+ QCheckBox *checkBox = static_cast<QCheckBox *>(m_wmap[widget]);
+ int value_int = checkBox->isChecked() ? 1 : 0;
+ gp_widget_set_value(widget, (void *)&value_int);
+
+ break;
+ }
+ case GP_WIDGET_RADIO:
+ {
+ QButtonGroup *buttonGroup = static_cast<QVButtonGroup *>(m_wmap[widget]);
+ gp_widget_set_value(widget, (void *)buttonGroup->selected()->text().local8Bit().data());
+
+ break;
+ }
+ case GP_WIDGET_MENU:
+ {
+ QComboBox *comboBox = static_cast<QComboBox *>(m_wmap[widget]);
+ gp_widget_set_value(widget, (void *)comboBox->currentText().local8Bit().data());
+
+ break;
+ }
+ case GP_WIDGET_BUTTON:
+ // nothing to do
+ break;
+ case GP_WIDGET_DATE:
+ {
+ // not implemented
+ break;
+ }
+ }
+
+ // Copy child widget values
+ for(int i = 0; i < gp_widget_count_children(widget); ++i) {
+ CameraWidget *widget_child;
+ gp_widget_get_child(widget, i, &widget_child);
+ updateWidgetValue(widget_child);
+ }
+}
+
+void KameraConfigDialog::slotOk()
+{
+ // Copy Qt widget values into CameraWidget hierarchy
+ updateWidgetValue(m_widgetRoot);
+
+ // 'ok' dialog
+ accept();
+}
diff --git a/kamera/kcontrol/kameraconfigdialog.h b/kamera/kcontrol/kameraconfigdialog.h
new file mode 100644
index 00000000..73b2a012
--- /dev/null
+++ b/kamera/kcontrol/kameraconfigdialog.h
@@ -0,0 +1,53 @@
+/*
+
+ Copyright (C) 2001 The Kompany
+ 2002-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
+ 2002-2003 Marcus Meissner <marcus@jet.franken.de>
+ 2003 Nadeem Hasan <nhasan@nadmm.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
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+#ifndef __kameraconfigdialog_h__
+#define __kameraconfigdialog_h__
+
+#include <qmap.h>
+#include <kdialogbase.h>
+#include <qtabwidget.h>
+
+extern "C" {
+ #include <gphoto2.h>
+}
+
+class KameraConfigDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ KameraConfigDialog(Camera *camera, CameraWidget *widget,
+ QWidget *parent = 0, const char *name = 0);
+
+private slots:
+ void slotOk();
+
+private:
+ void appendWidget(QWidget *parent, CameraWidget *widget);
+ void updateWidgetValue(CameraWidget *widget);
+
+ QMap<CameraWidget *, QWidget *> m_wmap;
+ CameraWidget *m_widgetRoot;
+ QTabWidget *m_tabWidget;
+};
+
+#endif
diff --git a/kamera/kcontrol/kameradevice.cpp b/kamera/kcontrol/kameradevice.cpp
new file mode 100644
index 00000000..010bf694
--- /dev/null
+++ b/kamera/kcontrol/kameradevice.cpp
@@ -0,0 +1,476 @@
+/*
+
+ Copyright (C) 2001 The Kompany
+ 2002-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
+ 2002-2003 Marcus Meissner <marcus@jet.franken.de>
+ 2003 Nadeem Hasan <nhasan@nadmm.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
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+#include <qlayout.h>
+#include <qwidgetstack.h>
+#include <qvbuttongroup.h>
+#include <qvgroupbox.h>
+#include <qcombobox.h>
+#include <qlineedit.h>
+#include <qradiobutton.h>
+#include <qwhatsthis.h>
+#include <qlabel.h>
+#include <qgrid.h>
+
+#include <klocale.h>
+#include <kconfig.h>
+#include <klistview.h>
+#include <kmessagebox.h>
+#include <kdebug.h>
+
+extern "C" {
+ #include <gphoto2.h>
+}
+
+#include "kamera.h"
+#include "kameraconfigdialog.h"
+#include "kameradevice.moc"
+
+// Define some parts of the old API
+#define GP_PROMPT_OK 0
+#define GP_PROMPT_CANCEL -1
+
+static const int INDEX_NONE= 0;
+static const int INDEX_SERIAL = 1;
+static const int INDEX_USB= 3;
+static GPContext *glob_context = 0;
+
+KCamera::KCamera(const QString &name, const QString &path)
+{
+ m_name = name;
+ m_model = name;
+ m_path = path;
+ m_camera = NULL;
+}
+
+KCamera::~KCamera()
+{
+ if(m_camera)
+ gp_camera_free(m_camera);
+ if(m_abilitylist)
+ gp_abilities_list_free(m_abilitylist);
+}
+
+bool KCamera::initInformation()
+{
+ if (!m_model)
+ return false;
+
+ if(gp_abilities_list_new(&m_abilitylist) != GP_OK) {
+ emit error(i18n("Could not allocate memory for abilities list."));
+ return false;
+ }
+ if(gp_abilities_list_load(m_abilitylist, glob_context) != GP_OK) {
+ emit error(i18n("Could not load ability list."));
+ return false;
+ }
+ int index = gp_abilities_list_lookup_model(m_abilitylist, m_model.local8Bit().data());
+ if(index < 0) {
+ emit error(i18n("Description of abilities for camera %1 is not available."
+ " Configuration options may be incorrect.").arg(m_model));
+ return false;
+ }
+ gp_abilities_list_get_abilities(m_abilitylist, index, &m_abilities);
+ return true;
+}
+
+bool KCamera::initCamera()
+{
+ if (m_camera)
+ return m_camera;
+ else {
+ int result;
+
+ initInformation();
+
+ if (!m_model || !m_path)
+ return false;
+
+ result = gp_camera_new(&m_camera);
+ if (result != GP_OK) {
+ // m_camera is not initialized, so we cannot get result as string
+ emit error(i18n("Could not access driver. Check your gPhoto2 installation."));
+ return false;
+ }
+
+ // set the camera's model
+ GPPortInfo info;
+ GPPortInfoList *il;
+ gp_port_info_list_new(&il);
+ gp_port_info_list_load(il);
+ gp_port_info_list_get_info(il, gp_port_info_list_lookup_path(il, m_path.local8Bit().data()), &info);
+ gp_port_info_list_free(il);
+ gp_camera_set_abilities(m_camera, m_abilities);
+ gp_camera_set_port_info(m_camera, info);
+
+ // this might take some time (esp. for non-existant camera) - better be done asynchronously
+ result = gp_camera_init(m_camera, glob_context);
+ if (result != GP_OK) {
+ gp_camera_free(m_camera);
+ m_camera = NULL;
+ emit error(
+ i18n("Unable to initialize camera. Check your port settings and camera connectivity and try again."),
+ gp_result_as_string(result));
+ return false;
+ }
+
+ return m_camera;
+ }
+}
+
+Camera* KCamera::camera()
+{
+ initCamera();
+ return m_camera;
+}
+
+QString KCamera::summary()
+{
+ int result;
+ CameraText summary;
+
+ initCamera();
+
+ result = gp_camera_get_summary(m_camera, &summary, glob_context);
+ if (result != GP_OK)
+ return i18n("No camera summary information is available.\n");
+ return QString(summary.text);
+}
+
+bool KCamera::configure()
+{
+ CameraWidget *window;
+ int result;
+
+ initCamera();
+
+ result = gp_camera_get_config(m_camera, &window, glob_context);
+ if (result != GP_OK) {
+ emit error(i18n("Camera configuration failed."), gp_result_as_string(result));
+ return false;
+ }
+
+ KameraConfigDialog kcd(m_camera, window);
+ result = kcd.exec() ? GP_PROMPT_OK : GP_PROMPT_CANCEL;
+
+ if (result == GP_PROMPT_OK) {
+ result = gp_camera_set_config(m_camera, window, glob_context);
+ if (result != GP_OK) {
+ emit error(i18n("Camera configuration failed."), gp_result_as_string(result));
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool KCamera::test()
+{
+ // TODO: Make testing non-blocking (maybe via KIO?)
+ // Currently, a failed serial test times out at about 30 sec.
+ return camera() != 0;
+}
+
+void KCamera::load(KConfig *config)
+{
+ config->setGroup(m_name);
+ if (m_model.isNull())
+ m_model = config->readEntry("Model");
+ if (m_path.isNull())
+ m_path = config->readEntry("Path");
+ invalidateCamera();
+}
+
+void KCamera::save(KConfig *config)
+{
+ config->setGroup(m_name);
+ config->writeEntry("Model", m_model);
+ config->writeEntry("Path", m_path);
+}
+
+QString KCamera::portName()
+{
+ QString port = m_path.left(m_path.find(":")).lower();
+ if (port == "serial") return i18n("Serial");
+ if (port == "usb") return i18n("USB");
+ return i18n("Unknown port");
+}
+
+void KCamera::setName(const QString &name)
+{
+ m_name = name;
+}
+
+void KCamera::setModel(const QString &model)
+{
+ m_model = model;
+ invalidateCamera();
+ initInformation();
+}
+
+void KCamera::setPath(const QString &path)
+{
+ m_path = path;
+ invalidateCamera();
+}
+
+void KCamera::invalidateCamera()
+{
+ if (m_camera) {
+ gp_camera_free(m_camera);
+ m_camera = NULL;
+ }
+}
+
+bool KCamera::isTestable() const
+{
+ return true;
+}
+
+bool KCamera::isConfigurable()
+{
+ initInformation();
+ return m_abilities.operations & GP_OPERATION_CONFIG;
+}
+
+QStringList KCamera::supportedPorts()
+{
+ initInformation();
+ QStringList ports;
+ if (m_abilities.port & GP_PORT_SERIAL)
+ ports.append("serial");
+ if (m_abilities.port & GP_PORT_USB)
+ ports.append("usb");
+ return ports;
+}
+
+CameraAbilities KCamera::abilities()
+{
+ return m_abilities;
+}
+
+// ---------- KameraSelectCamera ------------
+
+KameraDeviceSelectDialog::KameraDeviceSelectDialog(QWidget *parent, KCamera *device)
+ : KDialogBase(parent, "kkameradeviceselect", true, i18n("Select Camera Device"), Ok | Cancel, Ok, true)
+{
+ m_device = device;
+ connect(m_device, SIGNAL(error(const QString &)),
+ SLOT(slot_error(const QString &)));
+ connect(m_device, SIGNAL(error(const QString &, const QString &)),
+ SLOT(slot_error(const QString &, const QString &)));
+
+ QWidget *page = new QWidget( this );
+ setMainWidget(page);
+
+ // a layout with vertical boxes
+ QHBoxLayout *topLayout = new QHBoxLayout(page, 0, KDialog::spacingHint());
+
+ // the models list
+ m_modelSel = new KListView(page);
+ topLayout->addWidget( m_modelSel );
+ m_modelSel->addColumn(i18n("Supported Cameras"));
+ m_modelSel->setColumnWidthMode(0, QListView::Maximum);
+ connect(m_modelSel, SIGNAL(selectionChanged(QListViewItem *)),
+ SLOT(slot_setModel(QListViewItem *)));
+ // make sure listview only as wide as it needs to be
+ m_modelSel->setSizePolicy(QSizePolicy(QSizePolicy::Maximum,
+ QSizePolicy::Preferred));
+
+ QVBoxLayout *rightLayout = new QVBoxLayout(0L, 0, KDialog::spacingHint());
+ topLayout->addLayout( rightLayout );
+
+ m_portSelectGroup = new QVButtonGroup(i18n("Port"), page);
+ rightLayout->addWidget(m_portSelectGroup);
+ m_portSettingsGroup = new QVGroupBox(i18n("Port Settings"), page);
+ rightLayout->addWidget(m_portSettingsGroup);
+
+ // Create port type selection radiobuttons.
+ m_serialRB = new QRadioButton(i18n("Serial"), m_portSelectGroup);
+ m_portSelectGroup->insert(m_serialRB, INDEX_SERIAL);
+ QWhatsThis::add(m_serialRB, i18n("If this option is checked, the camera would have to be connected one of the serial ports (known as COM in Microsoft Windows) in your computer."));
+ m_USBRB = new QRadioButton(i18n("USB"), m_portSelectGroup);
+ m_portSelectGroup->insert(m_USBRB, INDEX_USB);
+ QWhatsThis::add(m_USBRB, i18n("If this option is checked, the camera would have to be connected to one of the USB slots in your computer or USB hub."));
+ // Create port settings widget stack
+ m_settingsStack = new QWidgetStack(m_portSettingsGroup);
+ connect(m_portSelectGroup, SIGNAL(clicked(int)),
+ m_settingsStack, SLOT(raiseWidget(int)));
+
+ // none tab
+ m_settingsStack->addWidget(new QLabel(i18n("No port type selected."),
+ m_settingsStack), INDEX_NONE);
+
+ // serial tab
+ QGrid *grid = new QGrid(2, m_settingsStack);
+ grid->setSpacing(KDialog::spacingHint());
+ new QLabel(i18n("Port:"), grid);
+ m_serialPortCombo = new QComboBox(TRUE, grid);
+ QWhatsThis::add(m_serialPortCombo, i18n("Here you should choose the serial port you connect the camera to."));
+ m_settingsStack->addWidget(grid, INDEX_SERIAL);
+
+ grid = new QGrid(2, m_settingsStack);
+ grid->setSpacing(KDialog::spacingHint());
+ new QLabel(i18n("Port"), grid);
+
+ m_settingsStack->addWidget(new
+ QLabel(i18n("No further configuration is required for USB."),
+ m_settingsStack), INDEX_USB);
+
+ // query gphoto2 for existing serial ports
+ GPPortInfoList *list;
+ GPPortInfo info;
+ int gphoto_ports=0;
+ gp_port_info_list_new(&list);
+ if(gp_port_info_list_load(list) >= 0) {
+ gphoto_ports = gp_port_info_list_count(list);
+ }
+ for (int i = 0; i < gphoto_ports; i++) {
+ if (gp_port_info_list_get_info(list, i, &info) >= 0) {
+ if (strncmp(info.path, "serial:", 7) == 0)
+ m_serialPortCombo->insertItem(QString::fromLatin1(info.path).mid(7));
+ }
+ }
+ gp_port_info_list_free(list);
+
+ // add a spacer
+ rightLayout->addStretch();
+
+ populateCameraListView();
+ load();
+
+ enableButtonOK(false );
+ m_portSelectGroup->setEnabled( false );
+ m_portSettingsGroup->setEnabled( false );
+}
+
+bool KameraDeviceSelectDialog::populateCameraListView()
+{
+ gp_abilities_list_new (&m_device->m_abilitylist);
+ gp_abilities_list_load(m_device->m_abilitylist, glob_context);
+ int numCams = gp_abilities_list_count(m_device->m_abilitylist);
+ CameraAbilities a;
+
+ if(numCams < 0) {
+ // XXX libgphoto2 failed to get te camera list
+ return false;
+ } else {
+ for(int x = 0; x < numCams; ++x) {
+ if(gp_abilities_list_get_abilities(m_device->m_abilitylist, x, &a) == GP_OK) {
+ new QListViewItem(m_modelSel, a.model);
+ }
+ }
+ return true;
+ }
+}
+
+void KameraDeviceSelectDialog::save()
+{
+ m_device->setModel(m_modelSel->currentItem()->text(0));
+
+ if (m_portSelectGroup->selected()) {
+ QString type = m_portSelectGroup->selected()->text();
+
+ if(type == i18n("Serial"))
+ m_device->setPath("serial:" + m_serialPortCombo->currentText());
+ else if(type == i18n("USB"))
+ m_device->setPath("usb:");
+ } else {
+ // This camera has no port type (e.g. "Directory Browse" camera).
+ // Do nothing.
+ }
+}
+
+void KameraDeviceSelectDialog::load()
+{
+ QString path = m_device->path();
+ QString port = path.left(path.find(":")).lower();
+
+ if (port == "serial") setPortType(INDEX_SERIAL);
+ if (port == "usb") setPortType(INDEX_USB);
+
+ QListViewItem *modelItem = m_modelSel->firstChild();
+ if( modelItem)
+ {
+ do {
+ if (modelItem->text(0) == m_device->model()) {
+ m_modelSel->setSelected(modelItem, true);
+ m_modelSel->ensureItemVisible(modelItem);
+ }
+ } while ( ( modelItem = modelItem->nextSibling() ) );
+ }
+}
+
+void KameraDeviceSelectDialog::slot_setModel(QListViewItem *item)
+{
+ enableButtonOK(true);
+ m_portSelectGroup->setEnabled(true);
+ m_portSettingsGroup->setEnabled(true);
+
+ QString model = item->text(0);
+
+ CameraAbilities abilities;
+ int index = gp_abilities_list_lookup_model(m_device->m_abilitylist, model.local8Bit().data());
+ if(index < 0) {
+ slot_error(i18n("Description of abilities for camera %1 is not available."
+ " Configuration options may be incorrect.").arg(model));
+ }
+ int result = gp_abilities_list_get_abilities(m_device->m_abilitylist, index, &abilities);
+ if (result == GP_OK) {
+ // enable radiobuttons for supported port types
+ m_serialRB->setEnabled(abilities.port & GP_PORT_SERIAL);
+ m_USBRB->setEnabled(abilities.port & GP_PORT_USB);
+
+ // turn off any selected port
+ QButton *selected = m_portSelectGroup->selected();
+ if(selected != NULL)
+ selected->toggle();
+
+ // if there's only one available port type, make sure it's selected
+ if (abilities.port == GP_PORT_SERIAL)
+ setPortType(INDEX_SERIAL);
+ if (abilities.port == GP_PORT_USB)
+ setPortType(INDEX_USB);
+ } else {
+ slot_error(i18n("Description of abilities for camera %1 is not available."
+ " Configuration options may be incorrect.").arg(model));
+ }
+}
+
+void KameraDeviceSelectDialog::setPortType(int type)
+{
+ // Enable the correct button
+ m_portSelectGroup->setButton(type);
+
+ // Bring the right tab to the front
+ m_settingsStack->raiseWidget(type);
+}
+
+void KameraDeviceSelectDialog::slot_error(const QString &message)
+{
+ KMessageBox::error(this, message);
+}
+
+void KameraDeviceSelectDialog::slot_error(const QString &message, const QString &details)
+{
+ KMessageBox::detailedError(this, message, details);
+}
diff --git a/kamera/kcontrol/kameradevice.h b/kamera/kcontrol/kameradevice.h
new file mode 100644
index 00000000..aae24e02
--- /dev/null
+++ b/kamera/kcontrol/kameradevice.h
@@ -0,0 +1,117 @@
+/*
+
+ Copyright (C) 2001 The Kompany
+ 2002-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
+ 2002-2003 Marcus Meissner <marcus@jet.franken.de>
+ 2003 Nadeem Hasan <nhasan@nadmm.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
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+#ifndef __kameradevice_h__
+#define __kameradevice_h__
+
+#include <qmap.h>
+#include <kdialogbase.h>
+#include <config.h>
+
+class KConfig;
+class QString;
+class KListView;
+class QWidgetStack;
+class QVButtonGroup;
+class QVGroupBox;
+class QComboBox;
+class QLineEdit;
+class QRadioButton;
+
+class KCamera : public QObject {
+ friend class KameraDeviceSelectDialog;
+ Q_OBJECT
+public:
+ KCamera(const QString &name, const QString &path);
+ ~KCamera();
+ void invalidateCamera();
+ bool configure();
+ void load(KConfig *m_config);
+ void save(KConfig *m_config);
+ bool test();
+ QStringList supportedPorts();
+
+ Camera* camera();
+ QString name() const { return m_name ; }
+ QString model() const { return m_model; }
+ QString path() const { return m_path; }
+ QString portName();
+
+ QString summary();
+ CameraAbilities abilities();
+
+ void setName(const QString &name);
+ void setModel(const QString &model);
+ void setPath(const QString &path);
+
+ bool isTestable() const;
+ bool isConfigurable();
+
+signals:
+ void error(const QString &message);
+ void error(const QString &message, const QString &details);
+
+protected:
+ bool initInformation();
+ bool initCamera();
+// void doConfigureCamera(Camera *camera, CameraWidget *widgets);
+// int frontend_prompt(Camera *camera, CameraWidget *widgets);
+
+ Camera *m_camera;
+// KConfig *m_config;
+ QString m_name; // the camera's real name
+ QString m_model;
+ QString m_path;
+ CameraAbilities m_abilities;
+ CameraAbilitiesList *m_abilitylist;
+};
+
+class KameraDeviceSelectDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ KameraDeviceSelectDialog(QWidget *parent, KCamera *device);
+ void save();
+ void load();
+protected slots:
+ void slot_setModel(QListViewItem *item);
+ void slot_error(const QString &message);
+ void slot_error(const QString &message, const QString &details);
+protected:
+ KCamera *m_device;
+
+ bool populateCameraListView(void);
+ void setPortType(int type);
+
+ // port settings widgets
+ KListView *m_modelSel;
+ QLineEdit *m_nameEdit;
+ QWidgetStack *m_settingsStack;
+ QVButtonGroup *m_portSelectGroup;
+ QVGroupBox *m_portSettingsGroup;
+ QComboBox *m_serialPortCombo;
+ // port selection radio buttons
+ QRadioButton *m_serialRB;
+ QRadioButton *m_USBRB;
+};
+
+#endif