Menu

[2da4f3]: / src / options_impl.cpp  Maximize  Restore  History

Download this file

142 lines (129 with data), 5.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/**
* This file is a part of Qtpfsgui package.
* ----------------------------------------------------------------------
* Copyright (C) 2006,2007 Giuseppe Rota
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* ----------------------------------------------------------------------
*
* @author Giuseppe Rota <grota@users.sourceforge.net>
*/
#include "options_impl.h"
#include <QColorDialog>
#include <QFileDialog>
QtpfsguiOptions::QtpfsguiOptions(QWidget *p, qtpfsgui_opts *orig_opts, QSettings *s) : QDialog(p), opts(orig_opts), infnancolor(opts->naninfcolor), negcolor(opts->negcolor), settings(s) {
setupUi(this);
from_options_to_gui(); //update the gui in order to show the options
connect(negative_color_button,SIGNAL(clicked()),this,SLOT(negative_clicked()));
connect(infnan_color_button,SIGNAL(clicked()),this,SLOT(infnan_clicked()));
connect(OptionListWidget,SIGNAL(currentRowChanged(int)),stackedWidget,SLOT(setCurrentIndex(int)));
connect(okButton,SIGNAL(clicked()),this,SLOT(ok_clicked()));
connect(chooseCachePathButton,SIGNAL(clicked()),this,SLOT(updateLineEditString()));
}
void QtpfsguiOptions::negative_clicked() {
negcolor = QColorDialog::getColor(negcolor, this);
change_color_of(negative_color_button,&negcolor);
}
void QtpfsguiOptions::infnan_clicked() {
infnancolor = QColorDialog::getColor(infnancolor, this);
change_color_of(infnan_color_button,&infnancolor);
}
void QtpfsguiOptions::change_color_of(QPushButton *button, QColor *newcolor) {
if (newcolor->isValid()) {
#if QT_VERSION <= 0x040200
QPalette modified_palette(button->palette());
modified_palette.setColor(QPalette::Active,QPalette::Button,*newcolor);
button->setPalette( modified_palette );
#else
button->setStyleSheet(QString("background: rgb(%1,%2,%3)").arg(newcolor->red()).arg(newcolor->green()).arg(newcolor->blue()));
#endif
}
}
void QtpfsguiOptions::ok_clicked() {
settings->beginGroup(GROUP_DCRAW);
if (checkBox_camwb->isChecked() != opts->dcraw_options.camera_wb) {
opts->dcraw_options.camera_wb=checkBox_camwb->isChecked();
settings->setValue(KEY_CAMERAWB,checkBox_camwb->isChecked());
}
if (checkBox_autowb->isChecked() != opts->dcraw_options.auto_wb) {
opts->dcraw_options.auto_wb=checkBox_autowb->isChecked();
settings->setValue(KEY_AUTOWB,checkBox_autowb->isChecked());
}
if (checkBox_4colors->isChecked() != opts->dcraw_options.four_colors) {
opts->dcraw_options.four_colors=checkBox_4colors->isChecked();
settings->setValue(KEY_4COLORS,checkBox_4colors->isChecked());
}
if (spinBox_highlights->value() != opts->dcraw_options.highlights) {
opts->dcraw_options.highlights=spinBox_highlights->value();
settings->setValue(KEY_HIGHLIGHTS,spinBox_highlights->value());
}
if (comboBox_outcolspace->currentIndex() != opts->dcraw_options.output_color_space) {
opts->dcraw_options.output_color_space=comboBox_outcolspace->currentIndex();
settings->setValue(KEY_OUTCOLOR,comboBox_outcolspace->currentIndex());
}
if (comboBox_quality->currentIndex() != opts->dcraw_options.quality) {
opts->dcraw_options.quality=comboBox_quality->currentIndex();
settings->setValue(KEY_QUALITY,comboBox_quality->currentIndex());
}
settings->endGroup();
settings->beginGroup(GROUP_HDRVISUALIZATION);
if(negcolor.rgba() != opts->negcolor) {
opts->negcolor=negcolor.rgba();
settings->setValue(KEY_NEGCOLOR,negcolor.rgba());
}
if(infnancolor.rgba() != opts->naninfcolor) {
opts->naninfcolor=infnancolor.rgba();
settings->setValue(KEY_NANINFCOLOR,infnancolor.rgba());
}
settings->endGroup();
settings->beginGroup(GROUP_TONEMAPPING);
if (lineEditTempPath->text() != opts->tempfilespath) {
opts->tempfilespath=lineEditTempPath->text();
settings->setValue(KEY_TEMP_RESULT_PATH,lineEditTempPath->text());
}
settings->endGroup();
settings->beginGroup(GROUP_TIFF);
if (radioButtonLogLuv->isChecked() != opts->saveLogLuvTiff) {
opts->saveLogLuvTiff=radioButtonLogLuv->isChecked();
settings->setValue(KEY_SAVE_LOGLUV,radioButtonLogLuv->isChecked());
}
settings->endGroup();
accept();
}
void QtpfsguiOptions::from_options_to_gui() {
checkBox_autowb->setChecked(opts->dcraw_options.auto_wb);
checkBox_camwb->setChecked(opts->dcraw_options.camera_wb);
checkBox_4colors->setChecked(opts->dcraw_options.four_colors);
spinBox_highlights->setValue(opts->dcraw_options.highlights);
comboBox_outcolspace->setCurrentIndex(opts->dcraw_options.output_color_space);
comboBox_quality->setCurrentIndex(opts->dcraw_options.quality);
change_color_of(negative_color_button,&negcolor);
change_color_of(infnan_color_button,&infnancolor);
radioButtonLogLuv->setChecked(opts->saveLogLuvTiff);
radioButtonFloatTiff->setChecked(!opts->saveLogLuvTiff);
lineEditTempPath->setText(opts->tempfilespath);
}
QtpfsguiOptions::~QtpfsguiOptions() {
}
void QtpfsguiOptions::updateLineEditString() {
QString dir=QFileDialog::getExistingDirectory(
this,
"Choose a directory",
QDir::currentPath(),
QFileDialog::ShowDirsOnly|QFileDialog::DontResolveSymlinks);
if (!dir.isEmpty()) {
lineEditTempPath->setText(dir);
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.