File indexing completed on 2024-04-28 03:43:17

0001 /*
0002     SPDX-FileCopyrightText: 2017 Jasem Mutlaq <mutlaqja@ikarustech.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "dslrinfodialog.h"
0008 
0009 #include <KLocalizedString>
0010 #include "ksnotification.h"
0011 
0012 #include "Options.h"
0013 
0014 DSLRInfo::DSLRInfo(QWidget *parent, ISD::Camera *ccd) : QDialog(parent)
0015 {
0016 #ifdef Q_OS_OSX
0017     setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint);
0018 #endif
0019 
0020     setupUi(this);
0021 
0022     currentCCD = ccd;
0023 
0024     connect(buttonBox, SIGNAL(accepted()), this, SLOT(save()));
0025 
0026     DSLRIcon->setPixmap(
0027         QIcon::fromTheme("camera-photo").pixmap(48, 48));
0028 }
0029 
0030 void DSLRInfo::save()
0031 {
0032     sensorMaxWidth    = maxWidth->value();
0033     sensorMaxHeight   = maxHeight->value();
0034     sensorPixelW      = pixelX->value();
0035     sensorPixelH      = pixelY->value();
0036 
0037     if (sensorMaxWidth == 0 || sensorMaxHeight == 0 || sensorPixelW == 0 || sensorPixelH == 0)
0038     {
0039         KSNotification::error(i18n("Invalid values. Please set all values."));
0040         return;
0041     }
0042 
0043     ISD::CameraChip *primaryChip = currentCCD->getChip(ISD::CameraChip::PRIMARY_CCD);
0044     primaryChip->setImageInfo(sensorMaxWidth, sensorMaxHeight, sensorPixelW, sensorPixelH, 8);
0045     primaryChip->setFrame(0, 0, sensorMaxWidth, sensorMaxHeight);
0046 
0047     currentCCD->setConfig(SAVE_CONFIG);
0048 
0049     emit infoChanged();
0050 }