File indexing completed on 2024-04-21 04:19:14

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 __kamera_h__
0011 #define __kamera_h__
0012 
0013 #include "kcoreaddons_version.h"
0014 #include <KCModule>
0015 #include <KPluginFactory>
0016 #include <gphoto2.h>
0017 
0018 class QWidget;
0019 class QPushButton;
0020 class QListView;
0021 class QStandardItemModel;
0022 class QModelIndex;
0023 class QMenu;
0024 
0025 class KCamera;
0026 class KameraDeviceSelectDialog;
0027 class KConfig;
0028 class KActionCollection;
0029 class KToolBar;
0030 
0031 class KKameraConfig : public KCModule
0032 {
0033     Q_OBJECT
0034     friend class KameraDeviceSelectDialog;
0035 
0036 public:
0037     explicit KKameraConfig(QObject *parent, const KPluginMetaData &md);
0038     ~KKameraConfig() override;
0039 
0040     // KCModule interface methods
0041     void load() override;
0042     void save() override;
0043     void defaults() override;
0044     int buttons();
0045 
0046 protected:
0047     QString suggestName(const QString &name);
0048 
0049 protected Q_SLOTS:
0050     void slot_deviceMenu(const QPoint &point);
0051     void slot_deviceSelected(const QModelIndex &index);
0052     void slot_addCamera();
0053     void slot_removeCamera();
0054     void slot_configureCamera();
0055     void slot_cameraSummary();
0056     void slot_testCamera();
0057     void slot_cancelOperation();
0058     void slot_error(const QString &message);
0059     void slot_error(const QString &message, const QString &details);
0060 
0061 private:
0062     void displayGPFailureDialogue();
0063     void displayGPSuccessDialogue();
0064     void populateDeviceListView();
0065     void beforeCameraOperation();
0066     void afterCameraOperation();
0067     // gphoto callbacks
0068     static void cbGPIdle(GPContext *context, void *data);
0069     static GPContextFeedback cbGPCancel(GPContext *context, void *data);
0070 
0071 private:
0072     using CameraDevicesMap = QMap<QString, KCamera *>;
0073 
0074     KConfig *m_config;
0075     CameraDevicesMap m_devices;
0076     bool m_cancelPending;
0077 
0078     // gphoto members
0079     GPContext *m_context;
0080 
0081     // widgets for the cameras listview
0082     QListView *m_deviceSel;
0083     QStandardItemModel *m_deviceModel;
0084     KActionCollection *m_actions;
0085     QPushButton *m_addCamera, *m_removeCamera, *m_testCamera, *m_configureCamera;
0086     KToolBar *m_toolbar;
0087     QMenu *m_devicePopup;
0088 
0089     // true if libgphoto2 was initialised successfully in
0090     // the constructor
0091     bool m_gpInitialised;
0092 };
0093 
0094 #endif