File indexing completed on 2023-09-24 04:29:50

0001 /*
0002     SPDX-FileCopyrightText: 2001 The Kompany
0003     SPDX-FileCopyrightText: 2002-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
0004     SPDX-FileCopyrightText: 2002-2003 Marcus Meissner <marcus@jet.franken.de>
0005     SPDX-FileCopyrightText: 2003 Nadeem Hasan <nhasan@nadmm.com>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef __kameradevice_h__
0011 #define __kameradevice_h__
0012 
0013 #include "kamera.h"
0014 
0015 #include <QDialog>
0016 class QWidget;
0017 class QDialogButtonBox;
0018 
0019 class KConfig;
0020 class QString;
0021 class QListView;
0022 class QStackedWidget;
0023 class QComboBox;
0024 class QLineEdit;
0025 class QRadioButton;
0026 class QGroupBox;
0027 class QStandardItemModel;
0028 class QModelIndex;
0029 
0030 class KCamera : public QObject
0031 {
0032     friend class KameraDeviceSelectDialog;
0033     Q_OBJECT
0034 public:
0035     explicit KCamera(const QString &name, const QString &path);
0036     ~KCamera() override;
0037     void invalidateCamera();
0038     bool configure();
0039     void load(KConfig *m_config);
0040     void save(KConfig *m_config);
0041     bool test();
0042     QStringList supportedPorts();
0043 
0044     Camera *camera();
0045     QString name() const
0046     {
0047         return m_name;
0048     }
0049     QString model() const
0050     {
0051         return m_model;
0052     }
0053     QString path() const
0054     {
0055         return m_path;
0056     }
0057     QString portName();
0058 
0059     QString summary();
0060     CameraAbilities abilities() const;
0061 
0062     void setName(const QString &name);
0063     void setModel(const QString &model);
0064     void setPath(const QString &path);
0065 
0066     bool isTestable() const;
0067     bool isConfigurable();
0068 
0069 Q_SIGNALS:
0070     void error(const QString &message);
0071     void error(const QString &message, const QString &details);
0072 
0073 protected:
0074     bool initInformation();
0075     bool initCamera();
0076 
0077     Camera *m_camera;
0078     QString m_name; // the camera's real name
0079     QString m_model;
0080     QString m_path;
0081     CameraAbilities m_abilities;
0082     CameraAbilitiesList *m_abilitylist;
0083 };
0084 
0085 class KameraDeviceSelectDialog : public QDialog
0086 {
0087     Q_OBJECT
0088 public:
0089     KameraDeviceSelectDialog(QWidget *parent, KCamera *device);
0090     void save();
0091     void load();
0092 protected Q_SLOTS:
0093     void slot_setModel(const QModelIndex &index);
0094     void slot_error(const QString &message);
0095     void slot_error(const QString &message, const QString &details);
0096     void changeCurrentIndex();
0097 
0098 protected:
0099     KCamera *m_device;
0100 
0101     bool populateCameraListView();
0102     void setPortType(int type);
0103 
0104     // port settings widgets
0105     QListView *m_modelSel;
0106     QStandardItemModel *m_model;
0107     QLineEdit *m_nameEdit;
0108     QStackedWidget *m_settingsStack;
0109     QGroupBox *m_portSelectGroup;
0110     QGroupBox *m_portSettingsGroup;
0111     QComboBox *m_serialPortCombo;
0112     QDialogButtonBox *m_OkCancelButtonBox;
0113     // port selection radio buttons
0114     QRadioButton *m_serialRB;
0115     QRadioButton *m_USBRB;
0116 };
0117 
0118 #endif