mirror of
https://bitbucket.org/smil3y/kde-playground.git
synced 2025-02-23 10:22:50 +00:00
kamera: format and indent
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
d2acc3e3ea
commit
1994b3ee00
6 changed files with 903 additions and 891 deletions
|
@ -50,25 +50,22 @@ K_EXPORT_PLUGIN(KKameraConfigFactory("kcmkamera"))
|
|||
// --------------- Camera control center module widget ---
|
||||
|
||||
KKameraConfig::KKameraConfig(QWidget *parent, const QVariantList &)
|
||||
: KCModule(KKameraConfigFactory::componentData(), parent/*, name*/)
|
||||
: KCModule(KKameraConfigFactory::componentData(), parent/*, name*/)
|
||||
{
|
||||
m_devicePopup = new KMenu(this);
|
||||
m_actions = new KActionCollection(this);
|
||||
m_config = new KConfig(KProtocolInfo::config("camera"), KConfig::SimpleConfig);
|
||||
m_devicePopup = new KMenu(this);
|
||||
m_actions = new KActionCollection(this);
|
||||
m_config = new KConfig(KProtocolInfo::config("camera"), KConfig::SimpleConfig);
|
||||
|
||||
m_context = gp_context_new();
|
||||
if (m_context) {
|
||||
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);
|
||||
|
||||
// Register the callback functions
|
||||
gp_context_set_cancel_func(m_context, cbGPCancel, this);
|
||||
gp_context_set_idle_func(m_context, cbGPIdle, this);
|
||||
|
||||
displayGPSuccessDialogue();
|
||||
|
||||
} else {
|
||||
|
||||
displayGPFailureDialogue();
|
||||
}
|
||||
displayGPSuccessDialogue();
|
||||
} else {
|
||||
displayGPFailureDialogue();
|
||||
}
|
||||
}
|
||||
|
||||
KKameraConfig::~KKameraConfig()
|
||||
|
@ -82,366 +79,373 @@ void KKameraConfig::defaults()
|
|||
|
||||
void KKameraConfig::displayGPFailureDialogue(void)
|
||||
{
|
||||
QVBoxLayout *topLayout = new QVBoxLayout(this);
|
||||
topLayout->setSpacing(0);
|
||||
topLayout->setMargin(0);
|
||||
QLabel *label = new QLabel(i18n("Unable to initialize the gPhoto2 libraries."), this);
|
||||
topLayout->addWidget(label);
|
||||
QVBoxLayout *topLayout = new QVBoxLayout(this);
|
||||
topLayout->setSpacing(0);
|
||||
topLayout->setMargin(0);
|
||||
QLabel *label = new QLabel(i18n("Unable to initialize the gPhoto2 libraries."), this);
|
||||
topLayout->addWidget(label);
|
||||
}
|
||||
|
||||
void KKameraConfig::displayGPSuccessDialogue(void)
|
||||
{
|
||||
// set the kcontrol module buttons
|
||||
setButtons(Help | Apply );
|
||||
// set the kcontrol module buttons
|
||||
setButtons(Help | Apply );
|
||||
|
||||
// create a layout with two vertical boxes
|
||||
QVBoxLayout *topLayout = new QVBoxLayout(this);
|
||||
topLayout->setSpacing(0);
|
||||
topLayout->setMargin(0);
|
||||
// create a layout with two vertical boxes
|
||||
QVBoxLayout *topLayout = new QVBoxLayout(this);
|
||||
topLayout->setSpacing(0);
|
||||
topLayout->setMargin(0);
|
||||
|
||||
m_toolbar = new KToolBar(this, "ToolBar");
|
||||
topLayout->addWidget(m_toolbar);
|
||||
m_toolbar->setMovable(false);
|
||||
m_toolbar = new KToolBar(this, "ToolBar");
|
||||
topLayout->addWidget(m_toolbar);
|
||||
m_toolbar->setMovable(false);
|
||||
|
||||
// create list of devices
|
||||
m_deviceSel = new QListView(this);
|
||||
topLayout->addWidget(m_deviceSel);
|
||||
// create list of devices
|
||||
m_deviceSel = new QListView(this);
|
||||
topLayout->addWidget(m_deviceSel);
|
||||
|
||||
m_deviceModel = new QStandardItemModel(this);
|
||||
m_deviceSel->setModel(m_deviceModel);
|
||||
m_deviceModel = new QStandardItemModel(this);
|
||||
m_deviceSel->setModel(m_deviceModel);
|
||||
|
||||
connect(m_deviceSel, SIGNAL(customContextMenuRequested(const QPoint &)),
|
||||
SLOT(slot_deviceMenu(const QPoint &)));
|
||||
connect(m_deviceSel, SIGNAL(doubleClicked(const QModelIndex &)),
|
||||
SLOT(slot_configureCamera()));
|
||||
connect(m_deviceSel, SIGNAL(activated(const QModelIndex &)),
|
||||
SLOT(slot_deviceSelected(const QModelIndex &)));
|
||||
connect(m_deviceSel, SIGNAL(customContextMenuRequested(const QPoint &)),
|
||||
SLOT(slot_deviceMenu(const QPoint &)));
|
||||
connect(m_deviceSel, SIGNAL(doubleClicked(const QModelIndex &)),
|
||||
SLOT(slot_configureCamera()));
|
||||
connect(m_deviceSel, SIGNAL(activated(const QModelIndex &)),
|
||||
SLOT(slot_deviceSelected(const QModelIndex &)));
|
||||
|
||||
m_deviceSel->setViewMode(QListView::IconMode);
|
||||
m_deviceSel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||
m_deviceSel->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
m_deviceSel->setViewMode(QListView::IconMode);
|
||||
m_deviceSel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||
m_deviceSel->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
// create actions
|
||||
QAction *act;
|
||||
// create actions
|
||||
QAction *act;
|
||||
|
||||
act = m_actions->addAction("camera_add");
|
||||
act->setIcon(KIcon("camera-photo"));
|
||||
act->setText(i18n("Add"));
|
||||
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_addCamera()));
|
||||
act->setWhatsThis(i18n("Click this button to add a new camera."));
|
||||
m_toolbar->addAction(act);
|
||||
m_toolbar->addSeparator();
|
||||
act = m_actions->addAction("camera_test");
|
||||
act->setIcon(KIcon("dialog-ok"));
|
||||
act->setText(i18n("Test"));
|
||||
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_testCamera()));
|
||||
act->setWhatsThis(i18n("Click this button to test the connection to the selected camera."));
|
||||
m_toolbar->addAction(act);
|
||||
act = m_actions->addAction("camera_remove");
|
||||
act->setIcon(KIcon("user-trash"));
|
||||
act->setText(i18n("Remove"));
|
||||
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_removeCamera()));
|
||||
act->setWhatsThis(i18n("Click this button to remove the selected camera from the list."));
|
||||
m_toolbar->addAction(act);
|
||||
act = m_actions->addAction("camera_configure");
|
||||
act->setIcon(KIcon("configure"));
|
||||
act->setText(i18n("Configure..."));
|
||||
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_configureCamera()));
|
||||
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."));
|
||||
m_toolbar->addAction(act);
|
||||
act = m_actions->addAction("camera_summary");
|
||||
act->setIcon(KIcon("hwinfo"));
|
||||
act->setText(i18n("Information"));
|
||||
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_cameraSummary()));
|
||||
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 Information dialog depend on the camera model."));
|
||||
m_toolbar->addAction(act);
|
||||
m_toolbar->addSeparator();
|
||||
act = m_actions->addAction("camera_cancel");
|
||||
act->setIcon(KIcon("process-stop"));
|
||||
act->setText(i18n("Cancel"));
|
||||
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_cancelOperation()));
|
||||
act->setWhatsThis(i18n("Click this button to cancel the current camera operation."));
|
||||
act->setEnabled(false);
|
||||
m_toolbar->addAction(act);
|
||||
act = m_actions->addAction("camera_add");
|
||||
act->setIcon(KIcon("camera-photo"));
|
||||
act->setText(i18n("Add"));
|
||||
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_addCamera()));
|
||||
act->setWhatsThis(i18n("Click this button to add a new camera."));
|
||||
m_toolbar->addAction(act);
|
||||
m_toolbar->addSeparator();
|
||||
act = m_actions->addAction("camera_test");
|
||||
act->setIcon(KIcon("dialog-ok"));
|
||||
act->setText(i18n("Test"));
|
||||
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_testCamera()));
|
||||
act->setWhatsThis(i18n("Click this button to test the connection to the selected camera."));
|
||||
m_toolbar->addAction(act);
|
||||
act = m_actions->addAction("camera_remove");
|
||||
act->setIcon(KIcon("user-trash"));
|
||||
act->setText(i18n("Remove"));
|
||||
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_removeCamera()));
|
||||
act->setWhatsThis(i18n("Click this button to remove the selected camera from the list."));
|
||||
m_toolbar->addAction(act);
|
||||
act = m_actions->addAction("camera_configure");
|
||||
act->setIcon(KIcon("configure"));
|
||||
act->setText(i18n("Configure..."));
|
||||
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_configureCamera()));
|
||||
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."));
|
||||
m_toolbar->addAction(act);
|
||||
act = m_actions->addAction("camera_summary");
|
||||
act->setIcon(KIcon("hwinfo"));
|
||||
act->setText(i18n("Information"));
|
||||
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_cameraSummary()));
|
||||
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 Information dialog depend on the camera model."));
|
||||
m_toolbar->addAction(act);
|
||||
m_toolbar->addSeparator();
|
||||
act = m_actions->addAction("camera_cancel");
|
||||
act->setIcon(KIcon("process-stop"));
|
||||
act->setText(i18n("Cancel"));
|
||||
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_cancelOperation()));
|
||||
act->setWhatsThis(i18n("Click this button to cancel the current camera operation."));
|
||||
act->setEnabled(false);
|
||||
m_toolbar->addAction(act);
|
||||
|
||||
load();
|
||||
load();
|
||||
}
|
||||
|
||||
void KKameraConfig::populateDeviceListView(void)
|
||||
{
|
||||
m_deviceModel->clear();
|
||||
CameraDevicesMap::ConstIterator it;
|
||||
for (it = m_devices.constBegin(); it != m_devices.constEnd(); ++it) {
|
||||
if (it.value()) {
|
||||
QStandardItem *deviceItem = new QStandardItem;
|
||||
deviceItem->setEditable(false);
|
||||
deviceItem->setText(it.key());
|
||||
deviceItem->setIcon(KIcon("camera-photo"));
|
||||
m_deviceModel->appendRow(deviceItem);
|
||||
}
|
||||
}
|
||||
slot_deviceSelected(m_deviceSel->currentIndex());
|
||||
m_deviceModel->clear();
|
||||
CameraDevicesMap::ConstIterator it;
|
||||
for (it = m_devices.constBegin(); it != m_devices.constEnd(); ++it) {
|
||||
if (it.value()) {
|
||||
QStandardItem *deviceItem = new QStandardItem;
|
||||
deviceItem->setEditable(false);
|
||||
deviceItem->setText(it.key());
|
||||
deviceItem->setIcon(KIcon("camera-photo"));
|
||||
m_deviceModel->appendRow(deviceItem);
|
||||
}
|
||||
}
|
||||
slot_deviceSelected(m_deviceSel->currentIndex());
|
||||
}
|
||||
|
||||
void KKameraConfig::save(void)
|
||||
{
|
||||
CameraDevicesMap::Iterator it;
|
||||
CameraDevicesMap::Iterator it;
|
||||
|
||||
for (it = m_devices.begin(); it != m_devices.end(); it++)
|
||||
{
|
||||
it.value()->save(m_config);
|
||||
}
|
||||
m_config->sync();
|
||||
for (it = m_devices.begin(); it != m_devices.end(); it++) {
|
||||
it.value()->save(m_config);
|
||||
}
|
||||
m_config->sync();
|
||||
}
|
||||
|
||||
void KKameraConfig::load(void)
|
||||
{
|
||||
QStringList groupList = m_config->groupList();
|
||||
QStringList::Iterator it;
|
||||
int i, count;
|
||||
CameraList *list;
|
||||
CameraAbilitiesList *al;
|
||||
GPPortInfoList *il;
|
||||
const char *model, *value;
|
||||
KCamera *kcamera;
|
||||
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>") {
|
||||
KConfigGroup cg(m_config, *it);
|
||||
if (cg.readEntry("Path").contains("usb:"))
|
||||
continue;
|
||||
for (it = groupList.begin(); it != groupList.end(); it++) {
|
||||
if (*it != "<default>") {
|
||||
KConfigGroup cg(m_config, *it);
|
||||
if (cg.readEntry("Path").contains("usb:")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
kcamera = new KCamera(*it, cg.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;
|
||||
kcamera = new KCamera(*it, cg.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_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);
|
||||
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);
|
||||
count = gp_list_count(list);
|
||||
|
||||
QMap<QString,QString> ports, names;
|
||||
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);
|
||||
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:");
|
||||
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;
|
||||
QMap<QString,QString>::iterator portit;
|
||||
|
||||
for (portit = ports.begin() ; portit != ports.end(); portit++) {
|
||||
/* kDebug() << "Adding USB camera: " << portit.data() << " at " << portit.key(); */
|
||||
for (portit = ports.begin() ; portit != ports.end(); portit++) {
|
||||
/* kDebug() << "Adding USB camera: " << portit.data() << " at " << portit.key(); */
|
||||
|
||||
kcamera = new KCamera(portit.value(), 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.value()] = kcamera;
|
||||
}
|
||||
populateDeviceListView();
|
||||
kcamera = new KCamera(portit.value(), 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.value()] = kcamera;
|
||||
}
|
||||
populateDeviceListView();
|
||||
|
||||
gp_list_free (list);
|
||||
gp_list_free(list);
|
||||
}
|
||||
|
||||
void KKameraConfig::beforeCameraOperation(void)
|
||||
{
|
||||
m_cancelPending = false;
|
||||
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_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);
|
||||
m_actions->action("camera_cancel")->setEnabled(true);
|
||||
}
|
||||
|
||||
void KKameraConfig::afterCameraOperation(void)
|
||||
{
|
||||
m_actions->action("camera_cancel")->setEnabled(false);
|
||||
m_actions->action("camera_cancel")->setEnabled(false);
|
||||
|
||||
// if we're regaining control after a Cancel...
|
||||
if (m_cancelPending) {
|
||||
qApp->restoreOverrideCursor();
|
||||
m_cancelPending = 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->currentIndex());
|
||||
// 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->currentIndex());
|
||||
}
|
||||
|
||||
QString KKameraConfig::suggestName(const QString &name)
|
||||
{
|
||||
QString new_name = name;
|
||||
new_name.remove('/'); // we cannot have a slash in a URI's host
|
||||
QString new_name = name;
|
||||
new_name.remove('/'); // we cannot have a slash in a URI's host
|
||||
|
||||
if (!m_devices.contains(new_name)) return new_name;
|
||||
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;
|
||||
}
|
||||
// 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();
|
||||
return QString();
|
||||
}
|
||||
|
||||
void KKameraConfig::slot_addCamera()
|
||||
{
|
||||
KCamera *m_device = new KCamera(QString(), QString()); //krazy:exclusion=nullstrassign for old broken gcc
|
||||
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;
|
||||
}
|
||||
KCamera *m_device = new KCamera(QString(), QString());
|
||||
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()
|
||||
{
|
||||
const QString name = m_deviceSel->currentIndex().data(Qt::DisplayRole).toString();
|
||||
if (m_devices.contains(name)) {
|
||||
KCamera *m_device = m_devices.value(name);
|
||||
m_devices.remove(name);
|
||||
delete m_device;
|
||||
m_config->deleteGroup(name);
|
||||
populateDeviceListView();
|
||||
emit changed(true);
|
||||
}
|
||||
const QString name = m_deviceSel->currentIndex().data(Qt::DisplayRole).toString();
|
||||
if (m_devices.contains(name)) {
|
||||
KCamera *m_device = m_devices.value(name);
|
||||
m_devices.remove(name);
|
||||
delete m_device;
|
||||
m_config->deleteGroup(name);
|
||||
populateDeviceListView();
|
||||
emit changed(true);
|
||||
}
|
||||
}
|
||||
|
||||
void KKameraConfig::slot_testCamera()
|
||||
{
|
||||
beforeCameraOperation();
|
||||
beforeCameraOperation();
|
||||
|
||||
const QString name = m_deviceSel->currentIndex().data(Qt::DisplayRole).toString();
|
||||
if (m_devices.contains(name)) {
|
||||
KCamera *m_device = m_devices.value(name);
|
||||
if (m_device->test())
|
||||
KMessageBox::information(this, i18n("Camera test was successful."));
|
||||
}
|
||||
const QString name = m_deviceSel->currentIndex().data(Qt::DisplayRole).toString();
|
||||
if (m_devices.contains(name)) {
|
||||
KCamera *m_device = m_devices.value(name);
|
||||
if (m_device->test()) {
|
||||
KMessageBox::information(this, i18n("Camera test was successful."));
|
||||
}
|
||||
}
|
||||
|
||||
afterCameraOperation();
|
||||
afterCameraOperation();
|
||||
}
|
||||
|
||||
void KKameraConfig::slot_configureCamera()
|
||||
{
|
||||
const QString name = m_deviceSel->currentIndex().data(Qt::DisplayRole).toString();
|
||||
if (m_devices.contains(name)) {
|
||||
KCamera *m_device = m_devices[name];
|
||||
m_device->configure();
|
||||
}
|
||||
const QString name = m_deviceSel->currentIndex().data(Qt::DisplayRole).toString();
|
||||
if (m_devices.contains(name)) {
|
||||
KCamera *m_device = m_devices[name];
|
||||
m_device->configure();
|
||||
}
|
||||
}
|
||||
|
||||
void KKameraConfig::slot_cameraSummary()
|
||||
{
|
||||
const QString name = m_deviceSel->currentIndex().data(Qt::DisplayRole).toString();
|
||||
if (m_devices.contains(name)) {
|
||||
KCamera *m_device = m_devices[name];
|
||||
QString summary = m_device->summary();
|
||||
if (!summary.isNull()) {
|
||||
KMessageBox::information(this, summary);
|
||||
}
|
||||
}
|
||||
const QString name = m_deviceSel->currentIndex().data(Qt::DisplayRole).toString();
|
||||
if (m_devices.contains(name)) {
|
||||
KCamera *m_device = m_devices[name];
|
||||
QString 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);
|
||||
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(const QPoint &point)
|
||||
{
|
||||
QModelIndex index = m_deviceSel->indexAt(point);
|
||||
if (index.isValid()) {
|
||||
m_devicePopup->clear();
|
||||
m_devicePopup->addAction(m_actions->action("camera_test"));
|
||||
m_devicePopup->addAction(m_actions->action("camera_remove"));
|
||||
m_devicePopup->addAction(m_actions->action("camera_configure"));
|
||||
m_devicePopup->addAction(m_actions->action("camera_summary"));
|
||||
m_devicePopup->exec(m_deviceSel->viewport()->mapToGlobal(point));
|
||||
}
|
||||
QModelIndex index = m_deviceSel->indexAt(point);
|
||||
if (index.isValid()) {
|
||||
m_devicePopup->clear();
|
||||
m_devicePopup->addAction(m_actions->action("camera_test"));
|
||||
m_devicePopup->addAction(m_actions->action("camera_remove"));
|
||||
m_devicePopup->addAction(m_actions->action("camera_configure"));
|
||||
m_devicePopup->addAction(m_actions->action("camera_summary"));
|
||||
m_devicePopup->exec(m_deviceSel->viewport()->mapToGlobal(point));
|
||||
}
|
||||
}
|
||||
|
||||
void KKameraConfig::slot_deviceSelected(const QModelIndex &index)
|
||||
{
|
||||
bool isValid = index.isValid();
|
||||
m_actions->action("camera_test")->setEnabled(isValid);
|
||||
m_actions->action("camera_remove")->setEnabled(isValid);
|
||||
m_actions->action("camera_configure")->setEnabled(isValid);
|
||||
m_actions->action("camera_summary")->setEnabled(isValid);
|
||||
bool isValid = index.isValid();
|
||||
m_actions->action("camera_test")->setEnabled(isValid);
|
||||
m_actions->action("camera_remove")->setEnabled(isValid);
|
||||
m_actions->action("camera_configure")->setEnabled(isValid);
|
||||
m_actions->action("camera_summary")->setEnabled(isValid);
|
||||
}
|
||||
|
||||
void KKameraConfig::cbGPIdle(GPContext * /*context*/, void * /*data*/)
|
||||
{
|
||||
/*KKameraConfig *self( reinterpret_cast<KKameraConfig*>(data) );*/
|
||||
/*KKameraConfig *self( reinterpret_cast<KKameraConfig*>(data) );*/
|
||||
|
||||
qApp->processEvents();
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
GPContextFeedback KKameraConfig::cbGPCancel(GPContext * /*context*/, void *data)
|
||||
{
|
||||
KKameraConfig *self( reinterpret_cast<KKameraConfig*>(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();
|
||||
// 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;
|
||||
// If a cancel request is pending, ask gphoto to cancel
|
||||
if (self->m_cancelPending) {
|
||||
return GP_CONTEXT_FEEDBACK_CANCEL;
|
||||
}
|
||||
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 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 does not\n"
|
||||
"appear on 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 the address\n"
|
||||
"<a href=\"camera:/\">camera:/</a> in Konqueror and other KDE applications.");
|
||||
return i18n("<h1>Digital Camera</h1>\n"
|
||||
"This module allows you to configure support for your digital camera.\n"
|
||||
"You 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 does not\n"
|
||||
"appear on 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 the address\n"
|
||||
"<a href=\"camera:/\">camera:/</a> in Konqueror and other KDE applications.");
|
||||
}
|
||||
|
||||
void KKameraConfig::slot_error(const QString &message)
|
||||
{
|
||||
KMessageBox::error(this, message);
|
||||
KMessageBox::error(this, message);
|
||||
}
|
||||
|
||||
void KKameraConfig::slot_error(const QString &message, const QString &details)
|
||||
{
|
||||
KMessageBox::detailedError(this, message, details);
|
||||
KMessageBox::detailedError(this, message, details);
|
||||
}
|
||||
|
||||
#include "moc_kamera.cpp"
|
||||
|
|
|
@ -42,68 +42,68 @@ class KMenu;
|
|||
|
||||
class KKameraConfig : public KCModule
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class KameraDeviceSelectDialog;
|
||||
Q_OBJECT
|
||||
friend class KameraDeviceSelectDialog;
|
||||
|
||||
public:
|
||||
KKameraConfig(QWidget *parent, const QVariantList &);
|
||||
virtual ~KKameraConfig();
|
||||
KKameraConfig(QWidget *parent, const QVariantList &);
|
||||
virtual ~KKameraConfig();
|
||||
|
||||
// KCModule interface methods
|
||||
void load();
|
||||
void save();
|
||||
void defaults();
|
||||
int buttons();
|
||||
QString quickHelp() const;
|
||||
// KCModule interface methods
|
||||
void load();
|
||||
void save();
|
||||
void defaults();
|
||||
int buttons();
|
||||
QString quickHelp() const;
|
||||
|
||||
protected:
|
||||
QString suggestName(const QString &name);
|
||||
QString suggestName(const QString &name);
|
||||
|
||||
protected slots:
|
||||
void slot_deviceMenu(const QPoint &point);
|
||||
void slot_deviceSelected(const QModelIndex &index);
|
||||
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);
|
||||
void slot_deviceMenu(const QPoint &point);
|
||||
void slot_deviceSelected(const QModelIndex &index);
|
||||
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);
|
||||
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;
|
||||
|
||||
KConfig *m_config;
|
||||
CameraDevicesMap m_devices;
|
||||
bool m_cancelPending;
|
||||
typedef QMap<QString, KCamera *> CameraDevicesMap;
|
||||
|
||||
KConfig *m_config;
|
||||
CameraDevicesMap m_devices;
|
||||
bool m_cancelPending;
|
||||
|
||||
// gphoto members
|
||||
GPContext *m_context;
|
||||
// gphoto members
|
||||
GPContext *m_context;
|
||||
|
||||
// widgets for the cameras listview
|
||||
QListView *m_deviceSel;
|
||||
QStandardItemModel *m_deviceModel;
|
||||
KActionCollection *m_actions;
|
||||
QPushButton *m_addCamera, *m_removeCamera, *m_testCamera, *m_configureCamera;
|
||||
KToolBar *m_toolbar;
|
||||
KMenu *m_devicePopup;
|
||||
// widgets for the cameras listview
|
||||
QListView *m_deviceSel;
|
||||
QStandardItemModel *m_deviceModel;
|
||||
KActionCollection *m_actions;
|
||||
QPushButton *m_addCamera, *m_removeCamera, *m_testCamera, *m_configureCamera;
|
||||
KToolBar *m_toolbar;
|
||||
KMenu *m_devicePopup;
|
||||
|
||||
// true if libgphoto2 was initialised successfully in
|
||||
// the constructor
|
||||
bool m_gpInitialised;
|
||||
// true if libgphoto2 was initialised successfully in
|
||||
// the constructor
|
||||
bool m_gpInitialised;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -42,9 +42,7 @@
|
|||
#include "kameraconfigdialog.h"
|
||||
#include "moc_kameraconfigdialog.cpp"
|
||||
|
||||
KameraConfigDialog::KameraConfigDialog(Camera */*camera*/,
|
||||
CameraWidget *widget,
|
||||
QWidget *parent) :
|
||||
KameraConfigDialog::KameraConfigDialog(Camera */*camera*/, CameraWidget *widget, QWidget *parent) :
|
||||
KDialog(parent),
|
||||
m_widgetRoot(widget)
|
||||
{
|
||||
|
@ -65,269 +63,265 @@ KameraConfigDialog::KameraConfigDialog(Camera */*camera*/,
|
|||
|
||||
void KameraConfigDialog::appendWidget(QWidget *parent, CameraWidget *widget)
|
||||
{
|
||||
QWidget *newParent = parent;
|
||||
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 = NULL;
|
||||
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);
|
||||
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 = NULL;
|
||||
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
|
||||
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(QString::fromLocal8Bit(widget_label));
|
||||
// Add this widget to parent
|
||||
switch(widget_type) {
|
||||
case GP_WIDGET_WINDOW: {
|
||||
setCaption(QString::fromLocal8Bit(widget_label));
|
||||
break;
|
||||
}
|
||||
case GP_WIDGET_SECTION: {
|
||||
if (!m_tabWidget) {
|
||||
m_tabWidget = new QTabWidget(parent);
|
||||
parent->layout()->addWidget(m_tabWidget);
|
||||
}
|
||||
QWidget *tab = new QWidget(m_tabWidget);
|
||||
// widgets are to be aligned vertically in the tab
|
||||
QVBoxLayout *tabLayout = new QVBoxLayout(tab);
|
||||
m_tabWidget->addTab(tab, QString::fromLocal8Bit(widget_label));
|
||||
KVBox *tabContainer = new KVBox(tab);
|
||||
tabLayout->addWidget(tabContainer);
|
||||
newParent = tabContainer;
|
||||
|
||||
break;
|
||||
}
|
||||
case GP_WIDGET_SECTION:
|
||||
{
|
||||
if (!m_tabWidget) {
|
||||
m_tabWidget = new QTabWidget(parent);
|
||||
parent->layout()->addWidget(m_tabWidget);
|
||||
}
|
||||
QWidget *tab = new QWidget(m_tabWidget);
|
||||
// widgets are to be aligned vertically in the tab
|
||||
QVBoxLayout *tabLayout = new QVBoxLayout(tab);
|
||||
m_tabWidget->addTab(tab, QString::fromLocal8Bit(widget_label));
|
||||
KVBox *tabContainer = new KVBox(tab);
|
||||
tabLayout->addWidget(tabContainer);
|
||||
newParent = tabContainer;
|
||||
tabLayout->addStretch();
|
||||
|
||||
tabLayout->addStretch();
|
||||
break;
|
||||
}
|
||||
case GP_WIDGET_TEXT: {
|
||||
gp_widget_get_value(widget, &widget_value_string);
|
||||
|
||||
break;
|
||||
}
|
||||
case GP_WIDGET_TEXT:
|
||||
{
|
||||
gp_widget_get_value(widget, &widget_value_string);
|
||||
QWidget *grid = new QWidget(parent);
|
||||
QGridLayout *gridLayout = new QGridLayout(grid);
|
||||
grid->setLayout(gridLayout);
|
||||
parent->layout()->addWidget(grid);
|
||||
QLabel *label = new QLabel(QString::fromLocal8Bit( widget_label )+':', grid);
|
||||
QLineEdit *lineEdit = new QLineEdit(widget_value_string, grid);
|
||||
|
||||
QWidget *grid = new QWidget(parent);
|
||||
QGridLayout *gridLayout = new QGridLayout(grid);
|
||||
grid->setLayout(gridLayout);
|
||||
parent->layout()->addWidget(grid);
|
||||
QLabel *label = new QLabel(QString::fromLocal8Bit( widget_label )+':', grid);
|
||||
QLineEdit *lineEdit = new QLineEdit(widget_value_string, grid);
|
||||
gridLayout->addWidget(label, 0, 0, Qt::AlignLeft);
|
||||
gridLayout->addWidget(label, 0, 1, Qt::AlignRight);
|
||||
m_wmap.insert(widget, lineEdit);
|
||||
|
||||
gridLayout->addWidget(label, 0, 0, Qt::AlignLeft);
|
||||
gridLayout->addWidget(label, 0, 1, Qt::AlignRight);
|
||||
m_wmap.insert(widget, lineEdit);
|
||||
if (!whats_this.isEmpty()) {
|
||||
grid->setWhatsThis( whats_this);
|
||||
}
|
||||
|
||||
if (!whats_this.isEmpty())
|
||||
grid->setWhatsThis( 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);
|
||||
|
||||
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);
|
||||
Q3GroupBox *groupBox = new Q3GroupBox(1, Qt::Horizontal,QString::fromLocal8Bit(widget_label), parent);
|
||||
parent->layout()->addWidget(groupBox);
|
||||
QSlider *slider = new QSlider(Qt::Horizontal, groupBox);
|
||||
slider->setMinimum((int)widget_low);
|
||||
slider->setMaximum((int)widget_high);
|
||||
slider->setPageStep((int)widget_increment);
|
||||
slider->setValue((int)widget_value_float);
|
||||
m_wmap.insert(widget, slider);
|
||||
|
||||
Q3GroupBox *groupBox = new Q3GroupBox(1, Qt::Horizontal,QString::fromLocal8Bit(widget_label), parent);
|
||||
parent->layout()->addWidget(groupBox);
|
||||
QSlider *slider = new QSlider(Qt::Horizontal, groupBox);
|
||||
slider->setMinimum((int)widget_low);
|
||||
slider->setMaximum((int)widget_high);
|
||||
slider->setPageStep((int)widget_increment);
|
||||
slider->setValue((int)widget_value_float);
|
||||
m_wmap.insert(widget, slider);
|
||||
if (!whats_this.isEmpty()) {
|
||||
groupBox->setWhatsThis( whats_this);
|
||||
}
|
||||
|
||||
if (!whats_this.isEmpty())
|
||||
groupBox->setWhatsThis( whats_this);
|
||||
break;
|
||||
}
|
||||
case GP_WIDGET_TOGGLE: {
|
||||
gp_widget_get_value(widget, &widget_value_int);
|
||||
|
||||
break;
|
||||
}
|
||||
case GP_WIDGET_TOGGLE:
|
||||
{
|
||||
gp_widget_get_value(widget, &widget_value_int);
|
||||
QCheckBox *checkBox = new QCheckBox(QString::fromLocal8Bit(widget_label), parent);
|
||||
parent->layout()->addWidget(checkBox);
|
||||
checkBox->setChecked(widget_value_int);
|
||||
m_wmap.insert(widget, checkBox);
|
||||
|
||||
QCheckBox *checkBox = new QCheckBox(QString::fromLocal8Bit(widget_label), parent);
|
||||
parent->layout()->addWidget(checkBox);
|
||||
checkBox->setChecked(widget_value_int);
|
||||
m_wmap.insert(widget, checkBox);
|
||||
if (!whats_this.isEmpty()) {
|
||||
checkBox->setWhatsThis( whats_this);
|
||||
}
|
||||
|
||||
if (!whats_this.isEmpty())
|
||||
checkBox->setWhatsThis( whats_this);
|
||||
break;
|
||||
}
|
||||
case GP_WIDGET_RADIO:
|
||||
{
|
||||
gp_widget_get_value(widget, &widget_value_string);
|
||||
|
||||
break;
|
||||
}
|
||||
case GP_WIDGET_RADIO:
|
||||
{
|
||||
gp_widget_get_value(widget, &widget_value_string);
|
||||
int count = gp_widget_count_choices(widget);
|
||||
|
||||
int count = gp_widget_count_choices(widget);
|
||||
// for less than 5 options, align them horizontally
|
||||
Q3ButtonGroup *buttonGroup;
|
||||
if (count > 4) {
|
||||
buttonGroup = new Q3VButtonGroup(QString::fromLocal8Bit(widget_label), parent);
|
||||
} else {
|
||||
buttonGroup = new Q3HButtonGroup(QString::fromLocal8Bit(widget_label), parent);
|
||||
}
|
||||
parent->layout()->addWidget(buttonGroup);
|
||||
|
||||
// for less than 5 options, align them horizontally
|
||||
Q3ButtonGroup *buttonGroup;
|
||||
if (count > 4)
|
||||
buttonGroup = new Q3VButtonGroup(QString::fromLocal8Bit(widget_label), parent);
|
||||
else
|
||||
buttonGroup = new Q3HButtonGroup(QString::fromLocal8Bit(widget_label), parent);
|
||||
parent->layout()->addWidget(buttonGroup);
|
||||
for(int i = 0; i < count; ++i) {
|
||||
const char *widget_choice;
|
||||
gp_widget_get_choice(widget, i, &widget_choice);
|
||||
|
||||
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 (widget_value_string && !strcmp(widget_value_string, widget_choice)) {
|
||||
buttonGroup->setButton(i);
|
||||
}
|
||||
}
|
||||
m_wmap.insert(widget, buttonGroup);
|
||||
|
||||
new QRadioButton(widget_choice, buttonGroup);
|
||||
if(widget_value_string && !strcmp(widget_value_string, widget_choice))
|
||||
buttonGroup->setButton(i);
|
||||
}
|
||||
m_wmap.insert(widget, buttonGroup);
|
||||
if (!whats_this.isEmpty()) {
|
||||
buttonGroup->setWhatsThis(whats_this);
|
||||
}
|
||||
|
||||
if (!whats_this.isEmpty())
|
||||
buttonGroup->setWhatsThis( whats_this);
|
||||
break;
|
||||
}
|
||||
case GP_WIDGET_MENU: {
|
||||
gp_widget_get_value(widget, &widget_value_string);
|
||||
|
||||
break;
|
||||
}
|
||||
case GP_WIDGET_MENU:
|
||||
{
|
||||
gp_widget_get_value(widget, &widget_value_string);
|
||||
QComboBox *comboBox = new QComboBox(parent);
|
||||
parent->layout()->addWidget(comboBox);
|
||||
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);
|
||||
|
||||
QComboBox *comboBox = new QComboBox(parent);
|
||||
parent->layout()->addWidget(comboBox);
|
||||
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->addItem(widget_choice);
|
||||
if (widget_value_string && !strcmp(widget_value_string, widget_choice)) {
|
||||
comboBox->setCurrentIndex(i);
|
||||
}
|
||||
}
|
||||
m_wmap.insert(widget, comboBox);
|
||||
|
||||
comboBox->addItem(widget_choice);
|
||||
if(widget_value_string && !strcmp(widget_value_string, widget_choice))
|
||||
comboBox->setCurrentIndex(i);
|
||||
}
|
||||
m_wmap.insert(widget, comboBox);
|
||||
if (!whats_this.isEmpty()) {
|
||||
comboBox->setWhatsThis( whats_this);
|
||||
}
|
||||
|
||||
if (!whats_this.isEmpty())
|
||||
comboBox->setWhatsThis( 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
|
||||
QLabel *label = new QLabel(i18n("Button (not supported by KControl)"), parent);
|
||||
parent->layout()->addWidget(label);
|
||||
|
||||
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
|
||||
QLabel *label = new QLabel(i18n("Button (not supported by KControl)"), parent);
|
||||
parent->layout()->addWidget(label);
|
||||
break;
|
||||
}
|
||||
case GP_WIDGET_DATE: {
|
||||
// TODO
|
||||
QLabel * label = new QLabel(i18n("Date (not supported by KControl)"), parent);
|
||||
parent->layout()->addWidget(label);
|
||||
|
||||
break;
|
||||
}
|
||||
case GP_WIDGET_DATE:
|
||||
{
|
||||
// TODO
|
||||
QLabel * label = new QLabel(i18n("Date (not supported by KControl)"), parent);
|
||||
parent->layout()->addWidget(label);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// 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
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
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);
|
||||
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().toLocal8Bit().data());
|
||||
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().toLocal8Bit().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_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_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:
|
||||
{
|
||||
Q3ButtonGroup *buttonGroup = static_cast<Q3VButtonGroup *>(m_wmap[widget]);
|
||||
gp_widget_set_value(widget, (void *)buttonGroup->selected()->text().toLocal8Bit().data());
|
||||
break;
|
||||
}
|
||||
case GP_WIDGET_RADIO: {
|
||||
Q3ButtonGroup *buttonGroup = static_cast<Q3VButtonGroup *>(m_wmap[widget]);
|
||||
gp_widget_set_value(widget, (void *)buttonGroup->selected()->text().toLocal8Bit().data());
|
||||
|
||||
break;
|
||||
}
|
||||
case GP_WIDGET_MENU:
|
||||
{
|
||||
QComboBox *comboBox = static_cast<QComboBox *>(m_wmap[widget]);
|
||||
gp_widget_set_value(widget, (void *)comboBox->currentText().toLocal8Bit().data());
|
||||
break;
|
||||
}
|
||||
case GP_WIDGET_MENU: {
|
||||
QComboBox *comboBox = static_cast<QComboBox *>(m_wmap[widget]);
|
||||
gp_widget_set_value(widget, (void *)comboBox->currentText().toLocal8Bit().data());
|
||||
|
||||
break;
|
||||
}
|
||||
case GP_WIDGET_BUTTON:
|
||||
// nothing to do
|
||||
break;
|
||||
case GP_WIDGET_DATE:
|
||||
{
|
||||
// not implemented
|
||||
break;
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
// 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);
|
||||
// Copy Qt widget values into CameraWidget hierarchy
|
||||
updateWidgetValue(m_widgetRoot);
|
||||
|
||||
// 'ok' dialog
|
||||
accept();
|
||||
// 'ok' dialog
|
||||
accept();
|
||||
}
|
||||
|
|
|
@ -28,26 +28,25 @@
|
|||
#include <qtabwidget.h>
|
||||
|
||||
extern "C" {
|
||||
#include <gphoto2.h>
|
||||
#include <gphoto2.h>
|
||||
}
|
||||
|
||||
class KameraConfigDialog : public KDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
KameraConfigDialog(Camera *camera, CameraWidget *widget,
|
||||
QWidget *parent = 0);
|
||||
KameraConfigDialog(Camera *camera, CameraWidget *widget, QWidget *parent = 0);
|
||||
|
||||
private slots:
|
||||
void slotOk();
|
||||
void slotOk();
|
||||
|
||||
private:
|
||||
void appendWidget(QWidget *parent, CameraWidget *widget);
|
||||
void updateWidgetValue(CameraWidget *widget);
|
||||
|
||||
QMap<CameraWidget *, QWidget *> m_wmap;
|
||||
CameraWidget *m_widgetRoot;
|
||||
QTabWidget *m_tabWidget;
|
||||
void appendWidget(QWidget *parent, CameraWidget *widget);
|
||||
void updateWidgetValue(CameraWidget *widget);
|
||||
|
||||
QMap<CameraWidget *, QWidget *> m_wmap;
|
||||
CameraWidget *m_widgetRoot;
|
||||
QTabWidget *m_tabWidget;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -56,412 +56,424 @@ 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;
|
||||
m_abilitylist = NULL;
|
||||
m_name = name;
|
||||
m_model = name;
|
||||
m_path = path;
|
||||
m_camera = NULL;
|
||||
m_abilitylist = NULL;
|
||||
}
|
||||
|
||||
KCamera::~KCamera()
|
||||
{
|
||||
if(m_camera)
|
||||
gp_camera_free(m_camera);
|
||||
if(m_abilitylist)
|
||||
gp_abilities_list_free(m_abilitylist);
|
||||
if (m_camera) {
|
||||
gp_camera_free(m_camera);
|
||||
}
|
||||
if (m_abilitylist) {
|
||||
gp_abilities_list_free(m_abilitylist);
|
||||
}
|
||||
}
|
||||
|
||||
bool KCamera::initInformation()
|
||||
{
|
||||
if (m_model.isNull())
|
||||
return false;
|
||||
if (m_model.isNull())
|
||||
return false;
|
||||
|
||||
if(gp_abilities_list_new(&m_abilitylist) != GP_OK) {
|
||||
emit error(i18n("Could not allocate memory for the 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.toLocal8Bit().data());
|
||||
if(index < 0) {
|
||||
emit error(i18n("Description of abilities for camera %1 is not available."
|
||||
" Configuration options may be incorrect.", m_model));
|
||||
return false;
|
||||
}
|
||||
gp_abilities_list_get_abilities(m_abilitylist, index, &m_abilities);
|
||||
return true;
|
||||
if (gp_abilities_list_new(&m_abilitylist) != GP_OK) {
|
||||
emit error(i18n("Could not allocate memory for the 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.toLocal8Bit().data());
|
||||
if (index < 0) {
|
||||
emit error(i18n("Description of abilities for camera %1 is not available."
|
||||
" Configuration options may be incorrect.", 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;
|
||||
if (m_camera) {
|
||||
return m_camera;
|
||||
} else {
|
||||
int result;
|
||||
|
||||
initInformation();
|
||||
initInformation();
|
||||
|
||||
if (m_model.isNull() || m_path.isNull())
|
||||
return false;
|
||||
if (m_model.isNull() || m_path.isNull()) {
|
||||
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;
|
||||
}
|
||||
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.toLocal8Bit().data()), &info);
|
||||
gp_camera_set_abilities(m_camera, m_abilities);
|
||||
gp_camera_set_port_info(m_camera, info);
|
||||
gp_port_info_list_free(il);
|
||||
// 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.toLocal8Bit().data()), &info);
|
||||
gp_camera_set_abilities(m_camera, m_abilities);
|
||||
gp_camera_set_port_info(m_camera, info);
|
||||
gp_port_info_list_free(il);
|
||||
|
||||
// this might take some time (esp. for non-existent 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."),
|
||||
QString::fromLocal8Bit(gp_result_as_string(result)));
|
||||
return false;
|
||||
}
|
||||
// this might take some time (esp. for non-existent 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."),
|
||||
QString::fromLocal8Bit(gp_result_as_string(result)));
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_camera;
|
||||
}
|
||||
return m_camera;
|
||||
}
|
||||
}
|
||||
|
||||
Camera* KCamera::camera()
|
||||
{
|
||||
initCamera();
|
||||
return m_camera;
|
||||
initCamera();
|
||||
return m_camera;
|
||||
}
|
||||
|
||||
QString KCamera::summary()
|
||||
{
|
||||
int result;
|
||||
CameraText summary;
|
||||
int result;
|
||||
CameraText summary;
|
||||
|
||||
initCamera();
|
||||
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::fromLocal8Bit(summary.text);
|
||||
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::fromLocal8Bit(summary.text);
|
||||
}
|
||||
|
||||
bool KCamera::configure()
|
||||
{
|
||||
CameraWidget *window;
|
||||
int result;
|
||||
CameraWidget *window;
|
||||
int result;
|
||||
|
||||
initCamera();
|
||||
initCamera();
|
||||
|
||||
result = gp_camera_get_config(m_camera, &window, glob_context);
|
||||
if (result != GP_OK) {
|
||||
emit error(i18n("Camera configuration failed."), QString::fromLocal8Bit(gp_result_as_string(result)));
|
||||
return false;
|
||||
}
|
||||
result = gp_camera_get_config(m_camera, &window, glob_context);
|
||||
if (result != GP_OK) {
|
||||
emit error(i18n("Camera configuration failed."), QString::fromLocal8Bit(gp_result_as_string(result)));
|
||||
return false;
|
||||
}
|
||||
|
||||
KameraConfigDialog kcd(m_camera, window);
|
||||
result = kcd.exec() ? GP_PROMPT_OK : GP_PROMPT_CANCEL;
|
||||
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."), QString::fromLocal8Bit(gp_result_as_string(result)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
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."), QString::fromLocal8Bit(gp_result_as_string(result)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
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;
|
||||
// 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)
|
||||
{
|
||||
KConfigGroup group = config->group(m_name);
|
||||
if (m_model.isNull())
|
||||
m_model = group.readEntry("Model");
|
||||
if (m_path.isNull())
|
||||
m_path = group.readEntry("Path");
|
||||
invalidateCamera();
|
||||
KConfigGroup group = config->group(m_name);
|
||||
if (m_model.isNull()) {
|
||||
m_model = group.readEntry("Model");
|
||||
}
|
||||
if (m_path.isNull()) {
|
||||
m_path = group.readEntry("Path");
|
||||
}
|
||||
invalidateCamera();
|
||||
}
|
||||
|
||||
void KCamera::save(KConfig *config)
|
||||
{
|
||||
KConfigGroup group = config->group(m_name);
|
||||
group.writeEntry("Model", m_model);
|
||||
group.writeEntry("Path", m_path);
|
||||
KConfigGroup group = config->group(m_name);
|
||||
group.writeEntry("Model", m_model);
|
||||
group.writeEntry("Path", m_path);
|
||||
}
|
||||
|
||||
QString KCamera::portName()
|
||||
{
|
||||
QString port = m_path.left(m_path.indexOf(":")).toLower();
|
||||
if (port == "serial") return i18n("Serial");
|
||||
if (port == "usb") return i18n("USB");
|
||||
return i18n("Unknown port");
|
||||
QString port = m_path.left(m_path.indexOf(":")).toLower();
|
||||
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;
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
void KCamera::setModel(const QString &model)
|
||||
{
|
||||
m_model = model;
|
||||
invalidateCamera();
|
||||
initInformation();
|
||||
m_model = model;
|
||||
invalidateCamera();
|
||||
initInformation();
|
||||
}
|
||||
|
||||
void KCamera::setPath(const QString &path)
|
||||
{
|
||||
m_path = path;
|
||||
invalidateCamera();
|
||||
m_path = path;
|
||||
invalidateCamera();
|
||||
}
|
||||
|
||||
void KCamera::invalidateCamera()
|
||||
{
|
||||
if (m_camera) {
|
||||
gp_camera_free(m_camera);
|
||||
m_camera = NULL;
|
||||
}
|
||||
if (m_camera) {
|
||||
gp_camera_free(m_camera);
|
||||
m_camera = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool KCamera::isTestable() const
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool KCamera::isConfigurable()
|
||||
{
|
||||
initInformation();
|
||||
return m_abilities.operations & GP_OPERATION_CONFIG;
|
||||
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;
|
||||
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;
|
||||
return m_abilities;
|
||||
}
|
||||
|
||||
// ---------- KameraSelectCamera ------------
|
||||
|
||||
KameraDeviceSelectDialog::KameraDeviceSelectDialog(QWidget *parent, KCamera *device)
|
||||
: KDialog(parent)
|
||||
: KDialog(parent)
|
||||
{
|
||||
setCaption( i18n("Select Camera Device") );
|
||||
setButtons( Ok | Cancel );
|
||||
setDefaultButton( Ok );
|
||||
setModal( true );
|
||||
showButtonSeparator( 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 &)));
|
||||
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);
|
||||
QWidget *page = new QWidget( this );
|
||||
setMainWidget(page);
|
||||
|
||||
// a layout with vertical boxes
|
||||
QHBoxLayout *topLayout = new QHBoxLayout(page);
|
||||
topLayout->setSpacing(KDialog::spacingHint());
|
||||
topLayout->setMargin(0);
|
||||
// a layout with vertical boxes
|
||||
QHBoxLayout *topLayout = new QHBoxLayout(page);
|
||||
topLayout->setSpacing(KDialog::spacingHint());
|
||||
topLayout->setMargin(0);
|
||||
|
||||
// the models list
|
||||
m_modelSel = new QListView(page);
|
||||
m_model = new QStandardItemModel(this);
|
||||
m_model->setColumnCount(1);
|
||||
m_model->setHeaderData(0, Qt::Horizontal, i18nc("@title:column", "Supported Cameras"));
|
||||
m_modelSel->setModel(m_model);
|
||||
// the models list
|
||||
m_modelSel = new QListView(page);
|
||||
m_model = new QStandardItemModel(this);
|
||||
m_model->setColumnCount(1);
|
||||
m_model->setHeaderData(0, Qt::Horizontal, i18nc("@title:column", "Supported Cameras"));
|
||||
m_modelSel->setModel(m_model);
|
||||
|
||||
topLayout->addWidget( m_modelSel );
|
||||
connect(m_modelSel, SIGNAL(activated(const QModelIndex &)),
|
||||
SLOT(slot_setModel(const QModelIndex &)));
|
||||
// make sure listview only as wide as it needs to be
|
||||
m_modelSel->setSizePolicy(QSizePolicy(QSizePolicy::Maximum,
|
||||
QSizePolicy::Preferred));
|
||||
topLayout->addWidget( m_modelSel );
|
||||
connect(m_modelSel, SIGNAL(activated(const QModelIndex &)),
|
||||
SLOT(slot_setModel(const QModelIndex &)));
|
||||
// make sure listview only as wide as it needs to be
|
||||
m_modelSel->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred));
|
||||
|
||||
QVBoxLayout *rightLayout = new QVBoxLayout();
|
||||
rightLayout->setSpacing(KDialog::spacingHint());
|
||||
rightLayout->setMargin(0);
|
||||
topLayout->addLayout( rightLayout );
|
||||
QVBoxLayout *rightLayout = new QVBoxLayout();
|
||||
rightLayout->setSpacing(KDialog::spacingHint());
|
||||
rightLayout->setMargin(0);
|
||||
topLayout->addLayout( rightLayout );
|
||||
|
||||
m_portSelectGroup = new QGroupBox(i18n("Port"), page);
|
||||
QVBoxLayout *vertLayout = new QVBoxLayout;
|
||||
m_portSelectGroup->setLayout( vertLayout );
|
||||
rightLayout->addWidget(m_portSelectGroup);
|
||||
m_portSettingsGroup = new QGroupBox(i18n("Port Settings"), page);
|
||||
QVBoxLayout *lay = new QVBoxLayout;
|
||||
m_portSettingsGroup->setLayout( lay );
|
||||
rightLayout->addWidget(m_portSettingsGroup);
|
||||
// Create port type selection radiobuttons.
|
||||
m_serialRB = new QRadioButton(i18n("Serial"));
|
||||
vertLayout->addWidget(m_serialRB );
|
||||
m_serialRB->setWhatsThis( i18n("If this option is checked, the camera has to be connected to one of the computer's serial ports (known as COM ports in Microsoft Windows.)"));
|
||||
m_USBRB = new QRadioButton(i18n("USB"));
|
||||
vertLayout->addWidget(m_USBRB );
|
||||
m_USBRB->setWhatsThis( i18n("If this option is checked, the camera has to be connected to one of the computer's USB ports, or to a USB hub."));
|
||||
// Create port settings widget stack
|
||||
m_settingsStack = new QStackedWidget;
|
||||
QWidget *grid2 = new QWidget(m_settingsStack);
|
||||
QGridLayout *gridLayout2 = new QGridLayout(grid2);
|
||||
m_portSelectGroup = new QGroupBox(i18n("Port"), page);
|
||||
QVBoxLayout *vertLayout = new QVBoxLayout;
|
||||
m_portSelectGroup->setLayout( vertLayout );
|
||||
rightLayout->addWidget(m_portSelectGroup);
|
||||
m_portSettingsGroup = new QGroupBox(i18n("Port Settings"), page);
|
||||
QVBoxLayout *lay = new QVBoxLayout;
|
||||
m_portSettingsGroup->setLayout( lay );
|
||||
rightLayout->addWidget(m_portSettingsGroup);
|
||||
// Create port type selection radiobuttons.
|
||||
m_serialRB = new QRadioButton(i18n("Serial"));
|
||||
vertLayout->addWidget(m_serialRB );
|
||||
m_serialRB->setWhatsThis( i18n("If this option is checked, the camera has to be connected to one of the computer's serial ports (known as COM ports in Microsoft Windows.)"));
|
||||
m_USBRB = new QRadioButton(i18n("USB"));
|
||||
vertLayout->addWidget(m_USBRB );
|
||||
m_USBRB->setWhatsThis( i18n("If this option is checked, the camera has to be connected to one of the computer's USB ports, or to a USB hub."));
|
||||
// Create port settings widget stack
|
||||
m_settingsStack = new QStackedWidget;
|
||||
QWidget *grid2 = new QWidget(m_settingsStack);
|
||||
QGridLayout *gridLayout2 = new QGridLayout(grid2);
|
||||
gridLayout2->setSpacing(KDialog::spacingHint());
|
||||
grid2->setLayout(gridLayout2);
|
||||
grid2->setLayout(gridLayout2);
|
||||
QLabel *label2 = new QLabel(i18n("Port"), grid2);
|
||||
gridLayout2->addWidget(label2, 0, 0, Qt::AlignLeft);
|
||||
gridLayout2->addWidget(label2, 0, 0, Qt::AlignLeft);
|
||||
|
||||
lay->addWidget(grid2);
|
||||
lay->addWidget( m_settingsStack );
|
||||
connect(m_serialRB, SIGNAL( toggled(bool) ),
|
||||
this, SLOT( changeCurrentIndex() ) );
|
||||
connect(m_USBRB, SIGNAL( toggled(bool) ),
|
||||
this, SLOT( changeCurrentIndex() ) );
|
||||
// none tab
|
||||
m_settingsStack->insertWidget(INDEX_NONE, new QLabel(i18n("No port type selected."),
|
||||
m_settingsStack));
|
||||
connect(m_serialRB, SIGNAL( toggled(bool) ),
|
||||
this, SLOT( changeCurrentIndex() ) );
|
||||
connect(m_USBRB, SIGNAL( toggled(bool) ),
|
||||
this, SLOT( changeCurrentIndex() ) );
|
||||
// none tab
|
||||
m_settingsStack->insertWidget(INDEX_NONE, new QLabel(i18n("No port type selected."), m_settingsStack));
|
||||
|
||||
// serial tab
|
||||
QWidget *grid = new QWidget(m_settingsStack);
|
||||
QGridLayout *gridLayout = new QGridLayout(grid);
|
||||
gridLayout->setSpacing(KDialog::spacingHint());
|
||||
grid->setLayout(gridLayout);
|
||||
// serial tab
|
||||
QWidget *grid = new QWidget(m_settingsStack);
|
||||
QGridLayout *gridLayout = new QGridLayout(grid);
|
||||
gridLayout->setSpacing(KDialog::spacingHint());
|
||||
grid->setLayout(gridLayout);
|
||||
|
||||
QLabel *label = new QLabel(i18n("Port:"), grid);
|
||||
m_serialPortCombo = new QComboBox(grid);
|
||||
m_serialPortCombo->setEditable(true);
|
||||
m_serialPortCombo->setWhatsThis( i18n("Specify here the serial port to which you connect the camera."));
|
||||
QLabel *label = new QLabel(i18n("Port:"), grid);
|
||||
m_serialPortCombo = new QComboBox(grid);
|
||||
m_serialPortCombo->setEditable(true);
|
||||
m_serialPortCombo->setWhatsThis( i18n("Specify here the serial port to which you connect the camera."));
|
||||
|
||||
gridLayout->addWidget(label, 1, 0, Qt::AlignLeft);
|
||||
gridLayout->addWidget(m_serialPortCombo, 1, 1, Qt::AlignRight);
|
||||
m_settingsStack->insertWidget(INDEX_SERIAL, grid);
|
||||
gridLayout->addWidget(label, 1, 0, Qt::AlignLeft);
|
||||
gridLayout->addWidget(m_serialPortCombo, 1, 1, Qt::AlignRight);
|
||||
m_settingsStack->insertWidget(INDEX_SERIAL, grid);
|
||||
|
||||
m_settingsStack->insertWidget(INDEX_USB, new
|
||||
QLabel(i18n("No further configuration is required for USB cameras."),
|
||||
m_settingsStack));
|
||||
m_settingsStack->insertWidget(INDEX_USB, new
|
||||
QLabel(i18n("No further configuration is required for USB cameras."),
|
||||
m_settingsStack));
|
||||
|
||||
// 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) {
|
||||
// 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) {
|
||||
#ifdef HAVE_GPHOTO2_5
|
||||
char *xpath;
|
||||
gp_port_info_get_path (info, &xpath);
|
||||
if (strncmp(xpath, "serial:", 7) == 0)
|
||||
m_serialPortCombo->addItem(QString::fromLocal8Bit(xpath).mid(7));
|
||||
char *xpath;
|
||||
gp_port_info_get_path (info, &xpath);
|
||||
if (strncmp(xpath, "serial:", 7) == 0) {
|
||||
m_serialPortCombo->addItem(QString::fromLocal8Bit(xpath).mid(7));
|
||||
}
|
||||
#else
|
||||
if (strncmp(info.path, "serial:", 7) == 0)
|
||||
m_serialPortCombo->addItem(QString::fromLocal8Bit(info.path).mid(7));
|
||||
if (strncmp(info.path, "serial:", 7) == 0) {
|
||||
m_serialPortCombo->addItem(QString::fromLocal8Bit(info.path).mid(7));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
gp_port_info_list_free(list);
|
||||
}
|
||||
}
|
||||
gp_port_info_list_free(list);
|
||||
|
||||
// add a spacer
|
||||
rightLayout->addStretch();
|
||||
// add a spacer
|
||||
rightLayout->addStretch();
|
||||
|
||||
populateCameraListView();
|
||||
load();
|
||||
populateCameraListView();
|
||||
load();
|
||||
|
||||
enableButtonOk(false );
|
||||
m_portSelectGroup->setEnabled( false );
|
||||
m_portSettingsGroup->setEnabled( false );
|
||||
enableButtonOk(false);
|
||||
m_portSelectGroup->setEnabled(false);
|
||||
m_portSettingsGroup->setEnabled(false);
|
||||
}
|
||||
|
||||
void KameraDeviceSelectDialog::changeCurrentIndex()
|
||||
{
|
||||
QRadioButton *send = dynamic_cast<QRadioButton*>( sender() );
|
||||
if ( send )
|
||||
{
|
||||
if ( send == m_serialRB )
|
||||
{
|
||||
m_settingsStack->setCurrentIndex( INDEX_SERIAL );
|
||||
}
|
||||
else if ( send == m_USBRB )
|
||||
{
|
||||
|
||||
m_settingsStack->setCurrentIndex( INDEX_USB );
|
||||
QRadioButton *send = dynamic_cast<QRadioButton*>(sender());
|
||||
if (send) {
|
||||
if (send == m_serialRB) {
|
||||
m_settingsStack->setCurrentIndex(INDEX_SERIAL);
|
||||
} else if (send == m_USBRB) {
|
||||
m_settingsStack->setCurrentIndex(INDEX_USB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
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) {
|
||||
QStandardItem *cameraItem = new QStandardItem;
|
||||
cameraItem->setEditable(false);
|
||||
cameraItem->setText(a.model);
|
||||
m_model->appendRow(cameraItem);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
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) {
|
||||
QStandardItem *cameraItem = new QStandardItem;
|
||||
cameraItem->setEditable(false);
|
||||
cameraItem->setText(a.model);
|
||||
m_model->appendRow(cameraItem);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void KameraDeviceSelectDialog::save()
|
||||
{
|
||||
m_device->setModel(m_modelSel->currentIndex().data(Qt::DisplayRole).toString());
|
||||
m_device->setModel(m_modelSel->currentIndex().data(Qt::DisplayRole).toString());
|
||||
|
||||
if (m_serialRB->isChecked())
|
||||
m_device->setPath("serial:" + m_serialPortCombo->currentText());
|
||||
else if ( m_USBRB->isChecked() )
|
||||
m_device->setPath("usb:");
|
||||
if (m_serialRB->isChecked()) {
|
||||
m_device->setPath("serial:" + m_serialPortCombo->currentText());
|
||||
} else if (m_USBRB->isChecked() ) {
|
||||
m_device->setPath("usb:");
|
||||
}
|
||||
}
|
||||
|
||||
void KameraDeviceSelectDialog::load()
|
||||
{
|
||||
QString path = m_device->path();
|
||||
QString port = path.left(path.indexOf(':')).toLower();
|
||||
QString path = m_device->path();
|
||||
QString port = path.left(path.indexOf(':')).toLower();
|
||||
|
||||
if (port == "serial") setPortType(INDEX_SERIAL);
|
||||
if (port == "usb") setPortType(INDEX_USB);
|
||||
if (port == "serial") {
|
||||
setPortType(INDEX_SERIAL);
|
||||
}
|
||||
if (port == "usb") {
|
||||
setPortType(INDEX_USB);
|
||||
}
|
||||
|
||||
QList<QStandardItem *> items = m_model->findItems(m_device->model());
|
||||
foreach (QStandardItem *item, items) {
|
||||
const QModelIndex index = m_model->indexFromItem(item);
|
||||
m_modelSel->selectionModel()->select(index, QItemSelectionModel::Select);
|
||||
}
|
||||
QList<QStandardItem *> items = m_model->findItems(m_device->model());
|
||||
foreach (QStandardItem *item, items) {
|
||||
const QModelIndex index = m_model->indexFromItem(item);
|
||||
m_modelSel->selectionModel()->select(index, QItemSelectionModel::Select);
|
||||
}
|
||||
}
|
||||
|
||||
void KameraDeviceSelectDialog::slot_setModel(const QModelIndex &modelIndex)
|
||||
|
@ -472,35 +484,38 @@ void KameraDeviceSelectDialog::slot_setModel(const QModelIndex &modelIndex)
|
|||
|
||||
QString model = modelIndex.data(Qt::DisplayRole).toString();
|
||||
|
||||
CameraAbilities abilities;
|
||||
int index = gp_abilities_list_lookup_model(m_device->m_abilitylist, model.toLocal8Bit().data());
|
||||
if(index < 0) {
|
||||
slot_error(i18n("Description of abilities for camera %1 is not available."
|
||||
" Configuration options may be incorrect.", 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);
|
||||
// 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.", model));
|
||||
}
|
||||
CameraAbilities abilities;
|
||||
int index = gp_abilities_list_lookup_model(m_device->m_abilitylist, model.toLocal8Bit().data());
|
||||
if(index < 0) {
|
||||
slot_error(i18n("Description of abilities for camera %1 is not available."
|
||||
" Configuration options may be incorrect.", 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);
|
||||
// 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.", model));
|
||||
}
|
||||
}
|
||||
|
||||
void KameraDeviceSelectDialog::setPortType(int type)
|
||||
{
|
||||
// Enable the correct button
|
||||
if ( type == INDEX_USB )
|
||||
m_USBRB->setChecked( true );
|
||||
else if ( type == INDEX_SERIAL )
|
||||
m_serialRB->setChecked( true );
|
||||
// Enable the correct button
|
||||
if (type == INDEX_USB) {
|
||||
m_USBRB->setChecked(true);
|
||||
} else if (type == INDEX_SERIAL) {
|
||||
m_serialRB->setChecked(true);
|
||||
}
|
||||
|
||||
// Bring the right tab to the front
|
||||
m_settingsStack->setCurrentIndex(type);
|
||||
|
@ -508,10 +523,10 @@ void KameraDeviceSelectDialog::setPortType(int type)
|
|||
|
||||
void KameraDeviceSelectDialog::slot_error(const QString &message)
|
||||
{
|
||||
KMessageBox::error(this, message);
|
||||
KMessageBox::error(this, message);
|
||||
}
|
||||
|
||||
void KameraDeviceSelectDialog::slot_error(const QString &message, const QString &details)
|
||||
{
|
||||
KMessageBox::detailedError(this, message, details);
|
||||
KMessageBox::detailedError(this, message, details);
|
||||
}
|
||||
|
|
|
@ -38,82 +38,82 @@ class KConfig;
|
|||
#include <QModelIndex>
|
||||
|
||||
class KCamera : public QObject {
|
||||
friend class KameraDeviceSelectDialog;
|
||||
Q_OBJECT
|
||||
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();
|
||||
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();
|
||||
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();
|
||||
QString summary();
|
||||
CameraAbilities abilities();
|
||||
|
||||
void setName(const QString &name);
|
||||
void setModel(const QString &model);
|
||||
void setPath(const QString &path);
|
||||
void setName(const QString &name);
|
||||
void setModel(const QString &model);
|
||||
void setPath(const QString &path);
|
||||
|
||||
bool isTestable() const;
|
||||
bool isConfigurable();
|
||||
bool isTestable() const;
|
||||
bool isConfigurable();
|
||||
|
||||
signals:
|
||||
void error(const QString &message);
|
||||
void error(const QString &message, const QString &details);
|
||||
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);
|
||||
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;
|
||||
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 KDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
KameraDeviceSelectDialog(QWidget *parent, KCamera *device);
|
||||
void save();
|
||||
void load();
|
||||
KameraDeviceSelectDialog(QWidget *parent, KCamera *device);
|
||||
void save();
|
||||
void load();
|
||||
protected slots:
|
||||
void slot_setModel(const QModelIndex &index);
|
||||
void slot_error(const QString &message);
|
||||
void slot_error(const QString &message, const QString &details);
|
||||
void changeCurrentIndex();
|
||||
void slot_setModel(const QModelIndex &index);
|
||||
void slot_error(const QString &message);
|
||||
void slot_error(const QString &message, const QString &details);
|
||||
void changeCurrentIndex();
|
||||
protected:
|
||||
KCamera *m_device;
|
||||
KCamera *m_device;
|
||||
|
||||
bool populateCameraListView(void);
|
||||
void setPortType(int type);
|
||||
bool populateCameraListView(void);
|
||||
void setPortType(int type);
|
||||
|
||||
// port settings widgets
|
||||
QListView *m_modelSel;
|
||||
QStandardItemModel *m_model;
|
||||
QLineEdit *m_nameEdit;
|
||||
QStackedWidget *m_settingsStack;
|
||||
QGroupBox *m_portSelectGroup;
|
||||
QGroupBox *m_portSettingsGroup;
|
||||
QComboBox *m_serialPortCombo;
|
||||
// port selection radio buttons
|
||||
QRadioButton *m_serialRB;
|
||||
QRadioButton *m_USBRB;
|
||||
// port settings widgets
|
||||
QListView *m_modelSel;
|
||||
QStandardItemModel *m_model;
|
||||
QLineEdit *m_nameEdit;
|
||||
QStackedWidget *m_settingsStack;
|
||||
QGroupBox *m_portSelectGroup;
|
||||
QGroupBox *m_portSettingsGroup;
|
||||
QComboBox *m_serialPortCombo;
|
||||
// port selection radio buttons
|
||||
QRadioButton *m_serialRB;
|
||||
QRadioButton *m_USBRB;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue