1 /* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2006-07-09
7 * Description : item tool tip configuration setup tab
8 *
9 * Copyright (C) 2006-2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
10 * Copyright (C) 2013-2014 by Mohamed_Anwer <m_dot_anwer at gmx dot com>
11 *
12 * This program is free software; you can redistribute it
13 * and/or modify it under the terms of the GNU General
14 * Public License as published by the Free Software Foundation;
15 * either version 2, or (at your option)
16 * any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * ============================================================ */
24
25 #include "showfotosetuptooltip.h"
26
27 // Qt includes
28
29 #include <QCheckBox>
30 #include <QGroupBox>
31 #include <QVBoxLayout>
32 #include <QApplication>
33 #include <QStyle>
34
35 // KDE includes
36
37 #include <klocalizedstring.h>
38
39 // Local includes
40
41 #include "dfontselect.h"
42 #include "showfotosettings.h"
43
44 using namespace Digikam;
45
46 namespace ShowFoto
47 {
48
49 class Q_DECL_HIDDEN ShowfotoSetupToolTip::Private
50 {
51 public:
52
Private()53 explicit Private()
54 : showFileDateBox (nullptr),
55 showFileNameBox (nullptr),
56 showFileSizeBox (nullptr),
57 showImageDimBox (nullptr),
58 showImageTypeBox (nullptr),
59 showPhotoDateBox (nullptr),
60 showPhotoExpoBox (nullptr),
61 showPhotoFlashBox(nullptr),
62 showPhotoFocalBox(nullptr),
63 showPhotoMakeBox (nullptr),
64 showPhotoLensBox (nullptr),
65 showPhotoModeBox (nullptr),
66 showPhotoWbBox (nullptr),
67 showToolTipsBox (nullptr),
68 fileSettingBox (nullptr),
69 photoSettingBox (nullptr),
70 fontSelect (nullptr),
71 settings (nullptr)
72 {
73 }
74
75 QCheckBox* showFileDateBox;
76 QCheckBox* showFileNameBox;
77 QCheckBox* showFileSizeBox;
78 QCheckBox* showImageDimBox;
79 QCheckBox* showImageTypeBox;
80 QCheckBox* showPhotoDateBox;
81 QCheckBox* showPhotoExpoBox;
82 QCheckBox* showPhotoFlashBox;
83 QCheckBox* showPhotoFocalBox;
84 QCheckBox* showPhotoMakeBox;
85 QCheckBox* showPhotoLensBox;
86 QCheckBox* showPhotoModeBox;
87 QCheckBox* showPhotoWbBox;
88 QCheckBox* showToolTipsBox;
89
90 QGroupBox* fileSettingBox;
91 QGroupBox* photoSettingBox;
92
93 DFontSelect* fontSelect;
94 ShowfotoSettings* settings;
95 };
96
97 // --------------------------------------------------------
98
ShowfotoSetupToolTip(QWidget * const parent)99 ShowfotoSetupToolTip::ShowfotoSetupToolTip(QWidget* const parent)
100 : QScrollArea(parent),
101 d (new Private)
102 {
103 QWidget* const panel = new QWidget(viewport());
104 setWidget(panel);
105 setWidgetResizable(true);
106
107 const int spacing = QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing);
108
109 QVBoxLayout* const layout = new QVBoxLayout(panel);
110 d->showToolTipsBox = new QCheckBox(i18n("Show Items' Toolti&ps With Thumbbar and Folder-View"), panel);
111 d->showToolTipsBox->setWhatsThis(i18n("Set this option to display the image information when "
112 "the mouse hovers over a thumbbar or folder-view item."));
113
114 d->fontSelect = new DFontSelect(i18n("Font:"), panel);
115 d->fontSelect->setToolTip(i18n("Select here the font used to display text in tooltips."));
116
117 // --------------------------------------------------------
118
119 d->fileSettingBox = new QGroupBox(i18n("File/Image Information"), panel);
120 QVBoxLayout* const gLayout1 = new QVBoxLayout(d->fileSettingBox);
121
122 d->showFileNameBox = new QCheckBox(i18n("Show file name"), d->fileSettingBox);
123 d->showFileNameBox->setWhatsThis( i18n("Set this option to display the image file name."));
124
125 d->showFileDateBox = new QCheckBox(i18n("Show file date"), d->fileSettingBox);
126 d->showFileDateBox->setWhatsThis( i18n("Set this option to display the image file date."));
127
128 d->showFileSizeBox = new QCheckBox(i18n("Show file size"), d->fileSettingBox);
129 d->showFileSizeBox->setWhatsThis( i18n("Set this option to display the image file size."));
130
131 d->showImageTypeBox = new QCheckBox(i18n("Show image type"), d->fileSettingBox);
132 d->showImageTypeBox->setWhatsThis( i18n("Set this option to display the image type."));
133
134 d->showImageDimBox = new QCheckBox(i18n("Show image dimensions"), d->fileSettingBox);
135 d->showImageDimBox->setWhatsThis( i18n("Set this option to display the image dimensions in pixels."));
136
137 gLayout1->addWidget(d->showFileNameBox);
138 gLayout1->addWidget(d->showFileDateBox);
139 gLayout1->addWidget(d->showFileSizeBox);
140 gLayout1->addWidget(d->showImageTypeBox);
141 gLayout1->addWidget(d->showImageDimBox);
142 gLayout1->setContentsMargins(spacing, spacing, spacing, spacing);
143 gLayout1->setSpacing(0);
144
145 // --------------------------------------------------------
146
147 d->photoSettingBox = new QGroupBox(i18n("Photograph Information"), panel);
148 QVBoxLayout* gLayout2 = new QVBoxLayout(d->photoSettingBox);
149
150 d->showPhotoMakeBox = new QCheckBox(i18n("Show camera make and model"), d->photoSettingBox);
151 d->showPhotoMakeBox->setWhatsThis( i18n("Set this option to display the make and model of the "
152 "camera with which the image has been taken."));
153
154 d->showPhotoLensBox = new QCheckBox(i18n("Camera lens model"), d->photoSettingBox);
155 d->showPhotoLensBox->setWhatsThis(i18n("Set this option to display the lens model with "
156 "which the image was taken."));
157
158 d->showPhotoDateBox = new QCheckBox(i18n("Show camera date"), d->photoSettingBox);
159 d->showPhotoDateBox->setWhatsThis( i18n("Set this option to display the date when the image was taken."));
160
161 d->showPhotoFocalBox = new QCheckBox(i18n("Show camera aperture and focal length"), d->photoSettingBox);
162 d->showPhotoFocalBox->setWhatsThis( i18n("Set this option to display the camera aperture and focal settings "
163 "used to take the image."));
164
165 d->showPhotoExpoBox = new QCheckBox(i18n("Show camera exposure and sensitivity"), d->photoSettingBox);
166 d->showPhotoExpoBox->setWhatsThis( i18n("Set this option to display the camera exposure and sensitivity "
167 "used to take the image."));
168
169 d->showPhotoModeBox = new QCheckBox(i18n("Show camera mode and program"), d->photoSettingBox);
170 d->showPhotoModeBox->setWhatsThis( i18n("Set this option to display the camera mode and program "
171 "used to take the image."));
172
173 d->showPhotoFlashBox = new QCheckBox(i18n("Show camera flash settings"), d->photoSettingBox);
174 d->showPhotoFlashBox->setWhatsThis( i18n("Set this option to display the camera flash settings "
175 "used to take the image."));
176
177 d->showPhotoWbBox = new QCheckBox(i18n("Show camera white balance settings"), d->photoSettingBox);
178 d->showPhotoWbBox->setWhatsThis( i18n("Set this option to display the camera white balance settings "
179 "used to take the image."));
180
181 gLayout2->addWidget(d->showPhotoMakeBox);
182 gLayout2->addWidget(d->showPhotoLensBox);
183 gLayout2->addWidget(d->showPhotoDateBox);
184 gLayout2->addWidget(d->showPhotoFocalBox);
185 gLayout2->addWidget(d->showPhotoExpoBox);
186 gLayout2->addWidget(d->showPhotoModeBox);
187 gLayout2->addWidget(d->showPhotoFlashBox);
188 gLayout2->addWidget(d->showPhotoWbBox);
189 gLayout2->setContentsMargins(spacing, spacing, spacing, spacing);
190 gLayout2->setSpacing(0);
191
192 layout->addWidget(d->showToolTipsBox);
193 layout->addWidget(d->fontSelect);
194 layout->addWidget(d->fileSettingBox);
195 layout->addWidget(d->photoSettingBox);
196 layout->addStretch();
197 layout->setContentsMargins(spacing, spacing, spacing, spacing);
198 layout->setSpacing(spacing);
199
200 // --------------------------------------------------------
201
202 connect(d->showToolTipsBox, SIGNAL(toggled(bool)),
203 d->fileSettingBox, SLOT(setEnabled(bool)));
204
205 connect(d->showToolTipsBox, SIGNAL(toggled(bool)),
206 d->photoSettingBox, SLOT(setEnabled(bool)));
207
208 connect(d->showToolTipsBox, SIGNAL(toggled(bool)),
209 d->fontSelect, SLOT(setEnabled(bool)));
210
211 // --------------------------------------------------------
212
213 readSettings();
214 adjustSize();
215 }
216
~ShowfotoSetupToolTip()217 ShowfotoSetupToolTip::~ShowfotoSetupToolTip()
218 {
219 delete d;
220 }
221
readSettings()222 void ShowfotoSetupToolTip::readSettings()
223 {
224 d->settings = ShowfotoSettings::instance();
225
226 d->showToolTipsBox->setChecked(d->settings->getShowToolTip());
227 d->fontSelect->setFont(d->settings->getToolTipFont());
228
229 d->showFileNameBox->setChecked(d->settings->getShowFileName());
230 d->showFileDateBox->setChecked(d->settings->getShowFileDate());
231 d->showFileSizeBox->setChecked(d->settings->getShowFileSize());
232 d->showImageTypeBox->setChecked(d->settings->getShowFileType());
233 d->showImageDimBox->setChecked(d->settings->getShowFileDim());
234
235 d->showPhotoMakeBox->setChecked(d->settings->getShowPhotoMake());
236 d->showPhotoLensBox->setChecked(d->settings->getShowPhotoLens());
237 d->showPhotoDateBox->setChecked(d->settings->getShowPhotoDate());
238 d->showPhotoFocalBox->setChecked(d->settings->getShowPhotoFocal());
239 d->showPhotoExpoBox->setChecked(d->settings->getShowPhotoExpo());
240 d->showPhotoModeBox->setChecked(d->settings->getShowPhotoMode());
241 d->showPhotoFlashBox->setChecked(d->settings->getShowPhotoFlash());
242 d->showPhotoWbBox->setChecked(d->settings->getShowPhotoWB());
243
244 d->fileSettingBox->setEnabled(d->settings->getShowToolTip());
245 d->photoSettingBox->setEnabled(d->settings->getShowToolTip());
246 }
247
applySettings()248 void ShowfotoSetupToolTip::applySettings()
249 {
250 d->settings->setShowToolTip(d->showToolTipsBox->isChecked());
251 d->settings->setToolTipFont(d->fontSelect->font());
252
253 d->settings->setShowFileName(d->showFileNameBox->isChecked());
254 d->settings->setShowFileDate(d->showFileDateBox->isChecked());
255 d->settings->setShowFileSize(d->showFileSizeBox->isChecked());
256 d->settings->setShowFileType(d->showImageTypeBox->isChecked());
257 d->settings->setShowFileDim(d->showImageDimBox->isChecked());
258
259 d->settings->setShowPhotoMake(d->showPhotoMakeBox->isChecked());
260 d->settings->setShowPhotoLens(d->showPhotoLensBox->isChecked());
261 d->settings->setShowPhotoDate(d->showPhotoDateBox->isChecked());
262 d->settings->setShowPhotoFocal(d->showPhotoFocalBox->isChecked());
263 d->settings->setShowPhotoExpo(d->showPhotoExpoBox->isChecked());
264 d->settings->setShowPhotoMode(d->showPhotoModeBox->isChecked());
265 d->settings->setShowPhotoFlash(d->showPhotoFlashBox->isChecked());
266 d->settings->setShowPhotoWB(d->showPhotoWbBox->isChecked());
267
268 d->settings->syncConfig();
269 }
270
271 } // namespace ShowFoto
272