File indexing completed on 2022-09-27 13:41:20

0001 /*
0002 
0003     Copyright (C) 2001 The Kompany
0004           2002-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
0005           2002-2003 Marcus Meissner <marcus@jet.franken.de>
0006           2003      Nadeem Hasan <nhasan@nadmm.com>
0007 
0008     This program is free software; you can redistribute it and/or modify
0009     it under the terms of the GNU General Public License as published by
0010     the Free Software Foundation; either version 2 of the License, or
0011     (at your option) any later version.
0012 
0013     This program is distributed in the hope that it will be useful,
0014     but WITHOUT ANY WARRANTY; without even the implied warranty of
0015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0016     GNU General Public License for more details.
0017 
0018     You should have received a copy of the GNU General Public License
0019     along with this program; if not, write to the Free Software
0020     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0021 
0022 */
0023 #ifndef __kameradevice_h__
0024 #define __kameradevice_h__
0025 
0026 #include "kamera.h"
0027 
0028 #include <QDialog>
0029 class QWidget;
0030 class QDialogButtonBox;
0031 
0032 class KConfig;
0033 class QString;
0034 class QListView;
0035 class QStackedWidget;
0036 class QComboBox;
0037 class QLineEdit;
0038 class QRadioButton;
0039 class QGroupBox;
0040 class QStandardItemModel;
0041 class QModelIndex;
0042 
0043 class KCamera : public QObject {
0044     friend class KameraDeviceSelectDialog;
0045     Q_OBJECT
0046 public:
0047     explicit KCamera(const QString &name, const QString &path);
0048     ~KCamera() override;
0049     void invalidateCamera();
0050     bool configure();
0051     void load(KConfig *m_config);
0052     void save(KConfig *m_config);
0053     bool test();
0054     QStringList supportedPorts();
0055 
0056     Camera* camera();
0057     QString name() const { return m_name ; }
0058     QString model() const { return m_model; }
0059     QString path() const { return m_path; }
0060     QString portName();
0061 
0062     QString summary();
0063     CameraAbilities abilities() const;
0064 
0065     void setName(const QString &name);
0066     void setModel(const QString &model);
0067     void setPath(const QString &path);
0068 
0069     bool isTestable() const;
0070     bool isConfigurable();
0071 
0072 Q_SIGNALS:
0073     void error(const QString &message);
0074     void error(const QString &message, const QString &details);
0075 
0076 protected:
0077     bool initInformation();
0078     bool initCamera();
0079 
0080     Camera *m_camera;
0081     QString m_name; // the camera's real name
0082     QString m_model;
0083     QString m_path;
0084     CameraAbilities m_abilities;
0085     CameraAbilitiesList *m_abilitylist;
0086 };
0087 
0088 class KameraDeviceSelectDialog : public QDialog
0089 {
0090     Q_OBJECT
0091 public:
0092     KameraDeviceSelectDialog(QWidget *parent, KCamera *device);
0093     void save();
0094     void load();
0095 protected Q_SLOTS:
0096     void slot_setModel(const QModelIndex &index);
0097     void slot_error(const QString &message);
0098     void slot_error(const QString &message, const QString &details);
0099     void changeCurrentIndex();
0100 protected:
0101     KCamera *m_device;
0102 
0103     bool populateCameraListView();
0104     void setPortType(int type);
0105 
0106     // port settings widgets
0107     QListView *m_modelSel;
0108     QStandardItemModel *m_model;
0109     QLineEdit *m_nameEdit;
0110     QStackedWidget *m_settingsStack;
0111     QGroupBox *m_portSelectGroup;
0112     QGroupBox *m_portSettingsGroup;
0113     QComboBox *m_serialPortCombo;
0114     QDialogButtonBox *m_OkCancelButtonBox;
0115     // port selection radio buttons
0116     QRadioButton *m_serialRB;
0117     QRadioButton *m_USBRB;
0118 };
0119 
0120 #endif