~ubuntu-branches/ubuntu/karmic/digikam/karmic-backports

1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
1
/* ============================================================
2
 *
3
 * This file is a part of digiKam project
4
 * http://www.digikam.org
5
 *
6
 * Date        : 2003-02-01
7
 * Description : album view configuration setup tab
8
 *
9
 * Copyright (C) 2003-2004 by Renchi Raju <renchi@pooh.tam.uiuc.edu>
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
10
 * Copyright (C) 2005-2009 by Gilles Caulier <caulier dot gilles at gmail dot com>
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
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 "setupalbumview.moc"
26
1.2.21 by Alessandro Ghersi
Import upstream version 1.0.0~beta1
27
// Qt includes
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
28
29
#include <QButtonGroup>
30
#include <QCheckBox>
31
#include <QGridLayout>
32
#include <QGroupBox>
33
#include <QLabel>
34
#include <QRadioButton>
35
#include <QVBoxLayout>
36
1.2.21 by Alessandro Ghersi
Import upstream version 1.0.0~beta1
37
// KDE includes
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
38
1.5.4 by Mark Purcell
Import upstream version 1.0.0~beta6
39
#include <kapplication.h>
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
40
#include <kcombobox.h>
41
#include <kdialog.h>
42
#include <klocale.h>
43
1.2.21 by Alessandro Ghersi
Import upstream version 1.0.0~beta1
44
// Local includes
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
45
46
#include "albumsettings.h"
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
47
#include "dfontselect.h"
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
48
49
namespace Digikam
50
{
51
52
class SetupAlbumViewPriv
53
{
54
public:
55
56
    SetupAlbumViewPriv()
57
    {
58
        iconTreeThumbSize            = 0;
59
        iconTreeThumbLabel           = 0;
60
        iconShowNameBox              = 0;
61
        iconShowSizeBox              = 0;
62
        iconShowDateBox              = 0;
63
        iconShowModDateBox           = 0;
64
        iconShowResolutionBox        = 0;
65
        iconShowCommentsBox          = 0;
66
        iconShowTagsBox              = 0;
67
        iconShowRatingBox            = 0;
1.5.3 by Fathi Boudra
Import upstream version 1.0.0~beta5
68
        iconShowOverlaysBox          = 0;
1.5.4 by Mark Purcell
Import upstream version 1.0.0~beta6
69
        leftClickActionComboBox      = 0;
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
70
        previewLoadFullImageSize     = 0;
71
        showFolderTreeViewItemsCount = 0;
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
72
        treeViewFontSelect           = 0;
73
        iconViewFontSelect           = 0;
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
74
    }
75
1.5.4 by Mark Purcell
Import upstream version 1.0.0~beta6
76
    QLabel*      iconTreeThumbLabel;
77
78
    QCheckBox*   iconShowNameBox;
79
    QCheckBox*   iconShowSizeBox;
80
    QCheckBox*   iconShowDateBox;
81
    QCheckBox*   iconShowModDateBox;
82
    QCheckBox*   iconShowResolutionBox;
83
    QCheckBox*   iconShowCommentsBox;
84
    QCheckBox*   iconShowTagsBox;
85
    QCheckBox*   iconShowRatingBox;
86
    QCheckBox*   iconShowOverlaysBox;
87
    QCheckBox*   previewLoadFullImageSize;
88
    QCheckBox*   showFolderTreeViewItemsCount;
89
90
    KComboBox*   iconTreeThumbSize;
91
    KComboBox*   leftClickActionComboBox;
92
93
    DFontSelect* iconViewFontSelect;
94
    DFontSelect* treeViewFontSelect;
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
95
};
96
97
SetupAlbumView::SetupAlbumView(QWidget* parent)
1.2.19 by Luka Renko
Import upstream version 0.10.0~rc2
98
              : QScrollArea(parent), d(new SetupAlbumViewPriv)
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
99
{
1.2.19 by Luka Renko
Import upstream version 0.10.0~rc2
100
    QWidget *panel = new QWidget(viewport());
101
    setWidget(panel);
102
    setWidgetResizable(true);
103
104
    QVBoxLayout *layout = new QVBoxLayout(panel);
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
105
106
    // --------------------------------------------------------
107
1.2.19 by Luka Renko
Import upstream version 0.10.0~rc2
108
    QGroupBox *iconViewGroup = new QGroupBox(i18n("Icon-View Options"), panel);
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
109
    QGridLayout *grid        = new QGridLayout(iconViewGroup);
110
1.2.21 by Alessandro Ghersi
Import upstream version 1.0.0~beta1
111
    d->iconShowNameBox       = new QCheckBox(i18n("Show file&name"), iconViewGroup);
112
    d->iconShowNameBox->setWhatsThis(i18n("Set this option to show the filename below the image thumbnail."));
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
113
114
    d->iconShowSizeBox       = new QCheckBox(i18n("Show file si&ze"), iconViewGroup);
115
    d->iconShowSizeBox->setWhatsThis(i18n("Set this option to show the file size below the image thumbnail."));
116
117
    d->iconShowDateBox       = new QCheckBox(i18n("Show camera creation &date"), iconViewGroup);
118
    d->iconShowDateBox->setWhatsThis(i18n("Set this option to show the camera creation date "
119
                                          "below the image thumbnail."));
120
121
    d->iconShowModDateBox    = new QCheckBox(i18n("Show file &modification date"), iconViewGroup);
122
    d->iconShowModDateBox->setWhatsThis(i18n("Set this option to show the file modification date "
123
                                             "below the image thumbnail."));
124
125
    d->iconShowResolutionBox = new QCheckBox(i18n("Show ima&ge dimensions"), iconViewGroup);
126
    d->iconShowResolutionBox->setWhatsThis(i18n("Set this option to show the image size in pixels "
127
                                                "below the image thumbnail."));
128
129
    d->iconShowCommentsBox   = new QCheckBox(i18n("Show digiKam &captions"), iconViewGroup);
130
    d->iconShowCommentsBox->setWhatsThis(i18n("Set this option to show the digiKam captions "
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
131
                                              "below the image thumbnail."));
132
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
133
    d->iconShowTagsBox       = new QCheckBox(i18n("Show digiKam &tags"), iconViewGroup);
134
    d->iconShowTagsBox->setWhatsThis(i18n("Set this option to show the digiKam tags "
135
                                          "below the image thumbnail."));
136
137
    d->iconShowRatingBox     = new QCheckBox(i18n("Show digiKam &rating"), iconViewGroup);
138
    d->iconShowRatingBox->setWhatsThis(i18n("Set this option to show the digiKam rating "
139
                                            "below the image thumbnail."));
140
1.5.3 by Fathi Boudra
Import upstream version 1.0.0~beta5
141
    d->iconShowOverlaysBox   = new QCheckBox(i18n("Show rotation overlay buttons"), iconViewGroup);
142
    d->iconShowOverlaysBox->setWhatsThis(i18n("Set this option to show overlay buttons on "
143
                                              "the image thumbnail for image rotation."));
144
1.5.4 by Mark Purcell
Import upstream version 1.0.0~beta6
145
    QLabel *leftClickLabel     = new QLabel(i18n("Thumbnail click action:"), iconViewGroup);
146
    d->leftClickActionComboBox = new KComboBox(iconViewGroup);
147
    d->leftClickActionComboBox->addItem(i18n("Show embedded preview"), AlbumSettings::ShowPreview);
148
    d->leftClickActionComboBox->addItem(i18n("Start image editor"), AlbumSettings::StartEditor);
149
    d->leftClickActionComboBox->setToolTip(i18n("Choose what should happen when you click on a thumbnail."));
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
150
1.2.21 by Alessandro Ghersi
Import upstream version 1.0.0~beta1
151
    d->iconViewFontSelect = new DFontSelect(i18n("Icon View font:"), panel);
152
    d->iconViewFontSelect->setToolTip(i18n("Select here the font used to display text in Icon Views."));
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
153
154
    grid->addWidget(d->iconShowNameBox,          0, 0, 1, 1);
155
    grid->addWidget(d->iconShowSizeBox,          1, 0, 1, 1);
156
    grid->addWidget(d->iconShowDateBox,          2, 0, 1, 1);
157
    grid->addWidget(d->iconShowModDateBox,       3, 0, 1, 1);
158
    grid->addWidget(d->iconShowResolutionBox,    4, 0, 1, 1);
159
    grid->addWidget(d->iconShowCommentsBox,      0, 1, 1, 1);
160
    grid->addWidget(d->iconShowTagsBox,          1, 1, 1, 1);
161
    grid->addWidget(d->iconShowRatingBox,        2, 1, 1, 1);
1.5.3 by Fathi Boudra
Import upstream version 1.0.0~beta5
162
    grid->addWidget(d->iconShowOverlaysBox,      3, 1, 1, 1);
1.5.4 by Mark Purcell
Import upstream version 1.0.0~beta6
163
    grid->addWidget(leftClickLabel,              5, 0, 1, 1);
164
    grid->addWidget(d->leftClickActionComboBox,  5, 1, 1, 1);
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
165
    grid->addWidget(d->iconViewFontSelect,       6, 0, 1, 2);
166
    grid->setSpacing(KDialog::spacingHint());
167
    grid->setMargin(KDialog::spacingHint());
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
168
169
    // --------------------------------------------------------
170
1.2.21 by Alessandro Ghersi
Import upstream version 1.0.0~beta1
171
    QGroupBox *folderViewGroup = new QGroupBox(i18n("Folder View Options"), panel);
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
172
    QGridLayout* grid2         = new QGridLayout(folderViewGroup);
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
173
1.2.21 by Alessandro Ghersi
Import upstream version 1.0.0~beta1
174
    d->iconTreeThumbLabel      = new QLabel(i18n("Tree View thumbnail size:"), folderViewGroup);
1.2.19 by Luka Renko
Import upstream version 0.10.0~rc2
175
    d->iconTreeThumbSize       = new KComboBox(folderViewGroup);
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
176
    d->iconTreeThumbSize->addItem(QString("16"));
177
    d->iconTreeThumbSize->addItem(QString("22"));
178
    d->iconTreeThumbSize->addItem(QString("32"));
179
    d->iconTreeThumbSize->addItem(QString("48"));
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
180
    d->iconTreeThumbSize->setToolTip(i18n("Set this option to configure the size in pixels of "
1.2.21 by Alessandro Ghersi
Import upstream version 1.0.0~beta1
181
                                          "the Tree View thumbnails in digiKam's sidebars."));
182
183
    d->treeViewFontSelect = new DFontSelect(i18n("Tree View font:"), folderViewGroup);
184
    d->treeViewFontSelect->setToolTip(i18n("Select here the font used to display text in Tree Views."));
185
186
    d->showFolderTreeViewItemsCount = new QCheckBox(i18n("Show a count of items in Tree Views"), folderViewGroup);
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
187
188
    grid2->addWidget(d->iconTreeThumbLabel,           0, 0, 1, 1);
189
    grid2->addWidget(d->iconTreeThumbSize,            0, 1, 1, 1);
190
    grid2->addWidget(d->treeViewFontSelect,           1, 0, 1, 2);
191
    grid2->addWidget(d->showFolderTreeViewItemsCount, 2, 0, 1, 2);
192
    grid2->setMargin(KDialog::spacingHint());
193
    grid2->setSpacing(KDialog::spacingHint());
194
195
    // --------------------------------------------------------
196
1.2.19 by Luka Renko
Import upstream version 0.10.0~rc2
197
    QGroupBox *interfaceOptionsGroup = new QGroupBox(i18n("Misc Options"), panel);
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
198
    QGridLayout* grid3               = new QGridLayout(interfaceOptionsGroup);
199
1.2.21 by Alessandro Ghersi
Import upstream version 1.0.0~beta1
200
    d->previewLoadFullImageSize      = new QCheckBox(i18n("Embedded preview loads full-sized images."), interfaceOptionsGroup);
201
    d->previewLoadFullImageSize->setWhatsThis(i18n("Set this option to load images at their full size "
202
                                                   "for preview, rather than at a reduced size. This loads more "
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
203
                                                   "data and will be slow on older computers."));
204
205
    grid3->setMargin(KDialog::spacingHint());
206
    grid3->setSpacing(KDialog::spacingHint());
1.2.19 by Luka Renko
Import upstream version 0.10.0~rc2
207
    grid3->addWidget(d->previewLoadFullImageSize, 0, 0, 1, 2);
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
208
209
    // --------------------------------------------------------
210
211
    layout->setMargin(0);
212
    layout->setSpacing(KDialog::spacingHint());
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
213
    layout->addWidget(iconViewGroup);
214
    layout->addWidget(folderViewGroup);
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
215
    layout->addWidget(interfaceOptionsGroup);
216
    layout->addStretch();
217
218
    // --------------------------------------------------------
219
220
    readSettings();
221
    adjustSize();
1.5.4 by Mark Purcell
Import upstream version 1.0.0~beta6
222
223
    // --------------------------------------------------------
224
225
    setAutoFillBackground(false);
226
    viewport()->setAutoFillBackground(false);
227
    panel->setAutoFillBackground(false);
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
228
}
229
230
SetupAlbumView::~SetupAlbumView()
231
{
232
    delete d;
233
}
234
235
void SetupAlbumView::applySettings()
236
{
237
    AlbumSettings* settings = AlbumSettings::instance();
238
    if (!settings) return;
239
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
240
    settings->setTreeViewIconSize(d->iconTreeThumbSize->currentText().toInt());
241
    settings->setTreeViewFont(d->treeViewFontSelect->font());
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
242
    settings->setIconShowName(d->iconShowNameBox->isChecked());
243
    settings->setIconShowTags(d->iconShowTagsBox->isChecked());
244
    settings->setIconShowSize(d->iconShowSizeBox->isChecked());
245
    settings->setIconShowDate(d->iconShowDateBox->isChecked());
246
    settings->setIconShowModDate(d->iconShowModDateBox->isChecked());
247
    settings->setIconShowResolution(d->iconShowResolutionBox->isChecked());
248
    settings->setIconShowComments(d->iconShowCommentsBox->isChecked());
249
    settings->setIconShowRating(d->iconShowRatingBox->isChecked());
1.5.3 by Fathi Boudra
Import upstream version 1.0.0~beta5
250
    settings->setIconShowOverlays(d->iconShowOverlaysBox->isChecked());
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
251
    settings->setIconViewFont(d->iconViewFontSelect->font());
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
252
1.5.4 by Mark Purcell
Import upstream version 1.0.0~beta6
253
    settings->setItemLeftClickAction((AlbumSettings::ItemLeftClickAction)
254
                                     d->leftClickActionComboBox->currentIndex());
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
255
256
    settings->setPreviewLoadFullImageSize(d->previewLoadFullImageSize->isChecked());
257
    settings->setShowFolderTreeViewItemsCount(d->showFolderTreeViewItemsCount->isChecked());
258
    settings->saveSettings();
259
}
260
261
void SetupAlbumView::readSettings()
262
{
263
    AlbumSettings* settings = AlbumSettings::instance();
264
    if (!settings) return;
265
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
266
    if (settings->getTreeViewIconSize() == 16)
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
267
        d->iconTreeThumbSize->setCurrentIndex(0);
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
268
    else if (settings->getTreeViewIconSize() == 22)
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
269
        d->iconTreeThumbSize->setCurrentIndex(1);
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
270
    else if (settings->getTreeViewIconSize() == 32)
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
271
        d->iconTreeThumbSize->setCurrentIndex(2);
272
    else
273
        d->iconTreeThumbSize->setCurrentIndex(3);
274
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
275
    d->treeViewFontSelect->setFont(settings->getTreeViewFont());
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
276
    d->iconShowNameBox->setChecked(settings->getIconShowName());
277
    d->iconShowTagsBox->setChecked(settings->getIconShowTags());
278
    d->iconShowSizeBox->setChecked(settings->getIconShowSize());
279
    d->iconShowDateBox->setChecked(settings->getIconShowDate());
280
    d->iconShowModDateBox->setChecked(settings->getIconShowModDate());
281
    d->iconShowResolutionBox->setChecked(settings->getIconShowResolution());
282
    d->iconShowCommentsBox->setChecked(settings->getIconShowComments());
283
    d->iconShowRatingBox->setChecked(settings->getIconShowRating());
1.5.3 by Fathi Boudra
Import upstream version 1.0.0~beta5
284
    d->iconShowOverlaysBox->setChecked(settings->getIconShowOverlays());
1.2.17 by Luka Renko
Import upstream version 0.10.0~beta8
285
    d->iconViewFontSelect->setFont(settings->getIconViewFont());
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
286
1.5.4 by Mark Purcell
Import upstream version 1.0.0~beta6
287
    d->leftClickActionComboBox->setCurrentIndex((int)settings->getItemLeftClickAction());
1.2.16 by Jonathan Riddell
Import upstream version 0.10.0~beta7
288
289
    d->previewLoadFullImageSize->setChecked(settings->getPreviewLoadFullImageSize());
290
    d->showFolderTreeViewItemsCount->setChecked(settings->getShowFolderTreeViewItemsCount());
291
}
292
293
}  // namespace Digikam