1 /*
2
3 Copyright (C) 2001 The Kompany
4 2002-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
5 2002-2003 Marcus Meissner <marcus@jet.franken.de>
6 2003 Nadeem Hasan <nhasan@nadmm.com>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
22 */
23 #ifndef __kamera_h__
24 #define __kamera_h__
25
26 #include <KCModule>
27 #include <gphoto2.h>
28 #include <KPluginFactory>
29 #include <QLoggingCategory>
30
31 class QWidget;
32 class QPushButton;
33 class QListView;
34 class QStandardItemModel;
35 class QModelIndex;
36 class QMenu;
37
38 class KCamera;
39 class KameraDeviceSelectDialog;
40 class KConfig;
41 class KActionCollection;
42 class KToolBar;
43
Q_DECLARE_LOGGING_CATEGORY(KAMERA_KCONTROL)44 Q_DECLARE_LOGGING_CATEGORY(KAMERA_KCONTROL)
45
46 class KKameraConfig : public KCModule
47 {
48 Q_OBJECT
49 friend class KameraDeviceSelectDialog;
50
51 public:
52 explicit KKameraConfig(QWidget *parent, const QVariantList &);
53 ~KKameraConfig() override;
54
55 // KCModule interface methods
56 void load() override;
57 void save() override;
58 void defaults() override;
59 int buttons();
60 QString quickHelp() const override;
61
62 protected:
63 QString suggestName(const QString &name);
64
65 protected Q_SLOTS:
66 void slot_deviceMenu(const QPoint &point);
67 void slot_deviceSelected(const QModelIndex &index);
68 void slot_addCamera();
69 void slot_removeCamera();
70 void slot_configureCamera();
71 void slot_cameraSummary();
72 void slot_testCamera();
73 void slot_cancelOperation();
74 void slot_error(const QString &message);
75 void slot_error(const QString &message, const QString &details);
76
77 private:
78 void displayGPFailureDialogue();
79 void displayGPSuccessDialogue();
80 void displayCameraAbilities(const CameraAbilities &abilities);
81 void populateDeviceListView();
82 void beforeCameraOperation();
83 void afterCameraOperation();
84
85 // gphoto callbacks
86 static void cbGPIdle(GPContext *context, void *data);
87 static GPContextFeedback cbGPCancel(GPContext *context, void *data);
88
89 private:
90 typedef QMap<QString, KCamera *> CameraDevicesMap;
91
92 KConfig *m_config;
93 CameraDevicesMap m_devices;
94 bool m_cancelPending;
95
96 // gphoto members
97 GPContext *m_context;
98
99 // widgets for the cameras listview
100 QListView *m_deviceSel;
101 QStandardItemModel *m_deviceModel;
102 KActionCollection *m_actions;
103 QPushButton *m_addCamera, *m_removeCamera, *m_testCamera, *m_configureCamera;
104 KToolBar *m_toolbar;
105 QMenu *m_devicePopup;
106
107 // true if libgphoto2 was initialised successfully in
108 // the constructor
109 bool m_gpInitialised;
110 };
111
112 #endif
113