summaryrefslogtreecommitdiffstats
path: root/digikam/showfoto/setup/setupeditor.cpp
blob: dcb51e0f3f6304a2bc9367b4b5d90b5b75a8372e (plain)
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/* ============================================================
 *
 * This file is a part of digiKam project
 * http://www.digikam.org
 *
 * Date        : 2005-04-02
 * Description : setup showfoto tab.
 *
 * Copyright (C) 2005-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
 * Copyright (C) 2008 by Arnd Baecker <arnd dot baecker at web dot de>
 *
 * 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, 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.
 *
 * ============================================================ */

// TQt includes.

#include <tqlayout.h>
#include <tqcolor.h>
#include <tqhbox.h>
#include <tqvgroupbox.h>
#include <tqlabel.h>
#include <tqwhatsthis.h>
#include <tqcheckbox.h>
#include <tqcombobox.h>

// KDE includes.

#include <tdelocale.h>
#include <kdialog.h>
#include <kcolorbutton.h>
#include <knuminput.h>
#include <tdeconfig.h>
#include <tdeapplication.h>

// Local includes.

#include "setupeditor.h"
#include "setupeditor.moc"

namespace ShowFoto
{

class SetupEditorPriv
{
public:

    SetupEditorPriv()
    {
        backgroundColor       = 0;
        hideToolBar           = 0;
        hideThumbBar          = 0;
        horizontalThumbBar    = 0;
        showSplash            = 0;
        useTrash              = 0;
        exifRotateBox         = 0;
        exifSetOrientationBox = 0;
        overExposureColor     = 0;
        underExposureColor    = 0;
        themebackgroundColor  = 0;
        colorBox              = 0;
        sortOrderComboBox     = 0;
        sortReverse           = 0;
        useRawImportTool      = 0;
    }

    TQHBox        *colorBox;

    TQCheckBox    *sortReverse;
    TQCheckBox    *hideToolBar;
    TQCheckBox    *hideThumbBar;
    TQCheckBox    *horizontalThumbBar;
    TQCheckBox    *showSplash;
    TQCheckBox    *useTrash;
    TQCheckBox    *exifRotateBox;
    TQCheckBox    *exifSetOrientationBox;
    TQCheckBox    *themebackgroundColor;
    TQCheckBox    *useRawImportTool;

    TQComboBox    *sortOrderComboBox;

    KColorButton *backgroundColor;
    KColorButton *underExposureColor;
    KColorButton *overExposureColor;
};

SetupEditor::SetupEditor(TQWidget* parent )
           : TQWidget(parent)
{
    d = new SetupEditorPriv;
    TQVBoxLayout *layout = new TQVBoxLayout( parent, 0, KDialog::spacingHint() );

    // --------------------------------------------------------

    TQVGroupBox *interfaceOptionsGroup = new TQVGroupBox(i18n("Interface Options"), parent);

    d->themebackgroundColor = new TQCheckBox(i18n("&Use theme background color"),
                                            interfaceOptionsGroup);

    TQWhatsThis::add( d->themebackgroundColor, i18n("<p>Enable this option to use background theme "
                                              "color in image editor area") );

    d->colorBox                  = new TQHBox(interfaceOptionsGroup);
    TQLabel *backgroundColorlabel = new TQLabel( i18n("&Background color:"), d->colorBox);
    d->backgroundColor           = new KColorButton(d->colorBox);
    backgroundColorlabel->setBuddy(d->backgroundColor);
    TQWhatsThis::add( d->backgroundColor, i18n("<p>Select background color to use "
                                              "for image editor area.") );

    d->hideToolBar        = new TQCheckBox(i18n("H&ide toolbar in fullscreen mode"), interfaceOptionsGroup);
    d->hideThumbBar       = new TQCheckBox(i18n("Hide &thumbbar in fullscreen mode"), interfaceOptionsGroup);
    d->horizontalThumbBar = new TQCheckBox(i18n("Use &horizontal thumbbar (need to restart showFoto)"), interfaceOptionsGroup);
    TQWhatsThis::add( d->horizontalThumbBar, i18n("<p>If this option is enabled, the thumbnails bar will be displayed horizontally behind "
                                                 "the image area. You need to restart showFoto for this option take effect.<p>"));
    d->useTrash   = new TQCheckBox(i18n("&Deleting items should move them to trash"), interfaceOptionsGroup);
    d->showSplash = new TQCheckBox(i18n("&Show splash screen at startup"), interfaceOptionsGroup);

    d->useRawImportTool = new TQCheckBox(i18n("Use Raw Import Tool to handle Raw image"), interfaceOptionsGroup);
    TQWhatsThis::add(d->useRawImportTool, i18n("<p>Set on this option to use Raw Import "
                                              "tool before to load a Raw image, "
                                              "to customize indeep decoding settings."));

    // --------------------------------------------------------

    TQVGroupBox *exposureOptionsGroup = new TQVGroupBox(i18n("Exposure Indicators"), parent);

    TQHBox *underExpoBox         = new TQHBox(exposureOptionsGroup);
    TQLabel *underExpoColorlabel = new TQLabel( i18n("&Under-exposure color:"), underExpoBox);
    d->underExposureColor       = new KColorButton(underExpoBox);
    underExpoColorlabel->setBuddy(d->underExposureColor);
    TQWhatsThis::add( d->underExposureColor, i18n("<p>Customize color used in image editor to identify "
                                                 "under-exposed pixels.") );

    TQHBox *overExpoBox         = new TQHBox(exposureOptionsGroup);
    TQLabel *overExpoColorlabel = new TQLabel( i18n("&Over-exposure color:"), overExpoBox);
    d->overExposureColor       = new KColorButton(overExpoBox);
    overExpoColorlabel->setBuddy(d->overExposureColor);
    TQWhatsThis::add( d->overExposureColor, i18n("<p>Customize color used in image editor to identify "
                                                "over-exposed pixels.") );

    // --------------------------------------------------------

    TQVGroupBox *ExifGroupOptions = new TQVGroupBox(i18n("EXIF Actions"), parent);

    d->exifRotateBox = new TQCheckBox(ExifGroupOptions);
    d->exifRotateBox->setText(i18n("Show images/thumbs &rotated according to orientation tag"));

    d->exifSetOrientationBox = new TQCheckBox(ExifGroupOptions);
    d->exifSetOrientationBox->setText(i18n("Set orientation tag to normal after rotate/flip"));

     // --------------------------------------------------------

    TQVGroupBox *sortOptionsGroup = new TQVGroupBox(i18n("Sort order for images"), parent);

    TQHBox* sortBox       = new TQHBox(sortOptionsGroup);
    new TQLabel(i18n("Sort images by:"), sortBox);
    d->sortOrderComboBox = new TQComboBox(false, sortBox);
    d->sortOrderComboBox->insertItem(i18n("File Date"), 0);
    d->sortOrderComboBox->insertItem(i18n("File Name"), 1);
    d->sortOrderComboBox->insertItem(i18n("File size"), 2);
    TQWhatsThis::add(d->sortOrderComboBox, i18n("<p>Here, select whether newly-loaded "
                                               "images are sorted by file-date, file-name, or file-size."));

    d->sortReverse = new TQCheckBox(i18n("Reverse ordering"), sortOptionsGroup);
    TQWhatsThis::add(d->sortReverse, i18n("<p>If this option is enabled, newly-loaded "
                                         "images will be sorted in descending order."));

    // --------------------------------------------------------

    layout->addWidget(interfaceOptionsGroup);
    layout->addWidget(exposureOptionsGroup);
    layout->addWidget(ExifGroupOptions);
    layout->addWidget(sortOptionsGroup);
    layout->addStretch();

    // --------------------------------------------------------

    connect(d->themebackgroundColor, TQT_SIGNAL(toggled(bool)),
            this, TQT_SLOT(slotThemeBackgroundColor(bool)));

    readSettings();
}

SetupEditor::~SetupEditor()
{
    delete d;
}

void SetupEditor::slotThemeBackgroundColor(bool e)
{
    d->colorBox->setEnabled(!e);
}

void SetupEditor::readSettings()
{
    TDEConfig* config = kapp->config();
    TQColor Black(TQt::black);
    TQColor White(TQt::white);
    config->setGroup("ImageViewer Settings");
    d->themebackgroundColor->setChecked(config->readBoolEntry("UseThemeBackgroundColor", true));
    d->backgroundColor->setColor( config->readColorEntry("BackgroundColor", &Black ) );
    d->hideToolBar->setChecked(config->readBoolEntry("FullScreen Hide ToolBar", false));
    d->hideThumbBar->setChecked(config->readBoolEntry("FullScreenHideThumbBar", true));
    d->horizontalThumbBar->setChecked(config->readBoolEntry("HorizontalThumbbar", false));
    d->useTrash->setChecked(config->readBoolEntry("DeleteItem2Trash", false));
    d->showSplash->setChecked(config->readBoolEntry("ShowSplash", true));
    d->exifRotateBox->setChecked(config->readBoolEntry("EXIF Rotate", true));
    d->exifSetOrientationBox->setChecked(config->readBoolEntry("EXIF Set Orientation", true));
    d->underExposureColor->setColor(config->readColorEntry("UnderExposureColor", &White));
    d->overExposureColor->setColor(config->readColorEntry("OverExposureColor", &Black));
    d->sortOrderComboBox->setCurrentItem(config->readNumEntry("SortOrder", 0));
    d->sortReverse->setChecked(config->readBoolEntry("ReverseSort", false));
    d->useRawImportTool->setChecked(config->readBoolEntry("UseRawImportTool", false));
}

void SetupEditor::applySettings()
{
    TDEConfig* config = kapp->config();
    config->setGroup("ImageViewer Settings");
    config->writeEntry("UseThemeBackgroundColor", d->themebackgroundColor->isChecked());
    config->writeEntry("BackgroundColor",         d->backgroundColor->color());
    config->writeEntry("FullScreen Hide ToolBar", d->hideToolBar->isChecked());
    config->writeEntry("FullScreenHideThumbBar",  d->hideThumbBar->isChecked());
    config->writeEntry("HorizontalThumbbar",      d->horizontalThumbBar->isChecked());
    config->writeEntry("DeleteItem2Trash",        d->useTrash->isChecked());
    config->writeEntry("ShowSplash",              d->showSplash->isChecked());
    config->writeEntry("EXIF Rotate",             d->exifRotateBox->isChecked());
    config->writeEntry("EXIF Set Orientation",    d->exifSetOrientationBox->isChecked());
    config->writeEntry("UnderExposureColor",      d->underExposureColor->color());
    config->writeEntry("OverExposureColor",       d->overExposureColor->color());
    config->writeEntry("SortOrder",               d->sortOrderComboBox->currentItem());
    config->writeEntry("ReverseSort",             d->sortReverse->isChecked());
    config->writeEntry("UseRawImportTool",        d->useRawImportTool->isChecked());
    config->sync();
}

}   // namespace ShowFoto