~ubuntu-branches/ubuntu/intrepid/digikam/intrepid

« back to all changes in this revision

Viewing changes to digikam/utilities/setup/setupgeneral.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2008-07-17 20:25:39 UTC
  • mfrom: (1.3.2 upstream) (37 hardy)
  • mto: This revision was merged to the branch mainline in revision 39.
  • Revision ID: james.westby@ubuntu.com-20080717202539-1bw3w3nrsso7yj4z
* New upstream release
  - digiKam 0.9.4 Release Plan (KDE3) ~ 13 July 08 (Closes: #490144)
* DEB_CONFIGURE_EXTRA_FLAGS := --without-included-sqlite3
* Debhelper compatibility level V7
* Install pixmaps in debian/*.install
* Add debian/digikam.lintian-overrides

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* ============================================================
2
 
 * Author: Renchi Raju <renchi@pooh.tam.uiuc.edu>
3
 
 *         Gilles Caulier <caulier dot gilles at free.fr>
4
 
 * Date  : 2003-02-01
5
 
 * Description :
6
 
 *
7
 
 * Copyright 2003-2004 by Renchi Raju
 
2
 *
 
3
 * This file is a part of digiKam project
 
4
 * http://www.digikam.org
 
5
 * 
 
6
 * Date        : 2003-02-01
 
7
 * Description : general configuration setup tab
 
8
 *
 
9
 * Copyright (C) 2003-2004 by Renchi Raju <renchi@pooh.tam.uiuc.edu>
 
10
 * Copyright (C) 2005-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
8
11
 *
9
12
 * This program is free software; you can redistribute it
10
13
 * and/or modify it under the terms of the GNU General
30
33
#include <qradiobutton.h>
31
34
#include <qcheckbox.h>
32
35
#include <qlabel.h>
33
 
#include <qlineedit.h>
34
 
#include <qpushbutton.h>
35
36
#include <qdir.h>
36
37
#include <qlistbox.h>
37
38
#include <qwhatsthis.h>
 
39
#include <qtooltip.h>
38
40
#include <qfileinfo.h>
39
41
 
40
42
// KDE includes.
44
46
#include <kfiledialog.h>
45
47
#include <kurl.h>
46
48
#include <kmessagebox.h>
47
 
#include <klineeditdlg.h>
 
49
#include <kurlrequester.h>
48
50
 
49
51
// // Local includes.
50
52
 
51
53
#include "albumsettings.h"
52
54
#include "setupgeneral.h"
53
 
 
 
55
#include "setupgeneral.moc"
 
56
 
 
57
namespace Digikam
 
58
{
 
59
 
 
60
class SetupGeneralPriv
 
61
{
 
62
public:
 
63
 
 
64
    SetupGeneralPriv()
 
65
    {
 
66
        albumPathEdit                = 0;
 
67
        iconTreeThumbSize            = 0;
 
68
        iconTreeThumbLabel           = 0;
 
69
        iconShowNameBox              = 0;
 
70
        iconShowSizeBox              = 0;
 
71
        iconShowDateBox              = 0;
 
72
        iconShowModDateBox           = 0;
 
73
        iconShowResolutionBox        = 0;
 
74
        iconShowCommentsBox          = 0;
 
75
        iconShowTagsBox              = 0;
 
76
        iconShowRatingBox            = 0;
 
77
        rightClickActionComboBox     = 0;
 
78
        previewLoadFullImageSize     = 0;
 
79
        showFolderTreeViewItemsCount = 0;
 
80
    }
 
81
 
 
82
    QLabel        *iconTreeThumbLabel;
 
83
 
 
84
    QCheckBox     *iconShowNameBox;
 
85
    QCheckBox     *iconShowSizeBox;
 
86
    QCheckBox     *iconShowDateBox;
 
87
    QCheckBox     *iconShowModDateBox;
 
88
    QCheckBox     *iconShowResolutionBox;
 
89
    QCheckBox     *iconShowCommentsBox;
 
90
    QCheckBox     *iconShowTagsBox;
 
91
    QCheckBox     *iconShowRatingBox;
 
92
    QCheckBox     *previewLoadFullImageSize;
 
93
    QCheckBox     *showFolderTreeViewItemsCount;
 
94
 
 
95
    QComboBox     *iconTreeThumbSize;
 
96
    QComboBox     *rightClickActionComboBox;
 
97
 
 
98
    KURLRequester *albumPathEdit;
 
99
 
 
100
    KDialogBase   *mainDialog;
 
101
};
54
102
 
55
103
SetupGeneral::SetupGeneral(QWidget* parent, KDialogBase* dialog )
56
104
            : QWidget(parent)
57
105
{
58
 
   mainDialog_ = dialog;
59
 
   QVBoxLayout *layout = new QVBoxLayout( parent, 0, KDialog::spacingHint() );
60
 
 
61
 
   // --------------------------------------------------------
62
 
 
63
 
   QHGroupBox *albumPathBox = new QHGroupBox(parent);
64
 
   albumPathBox->setTitle(i18n("Album &Library Path"));
65
 
 
66
 
   albumPathEdit = new QLineEdit(albumPathBox);
67
 
   QWhatsThis::add( albumPathEdit, i18n("<p>Here you can set the main path to the digiKam album "
68
 
                                        "library in your computer.\n"
69
 
                                        "Write access is required for this path."));
70
 
 
71
 
   QPushButton *changePathButton = new QPushButton(i18n("&Change..."),
72
 
                                                   albumPathBox);
73
 
   connect(changePathButton, SIGNAL(clicked()),
74
 
           this, SLOT(slotChangeAlbumPath()));
75
 
   connect( albumPathEdit, SIGNAL(textChanged(const QString&)),
76
 
             this, SLOT(slotPathEdited(const QString&)) );
77
 
 
78
 
   layout->addWidget(albumPathBox);
79
 
 
80
 
   // --------------------------------------------------------
81
 
 
82
 
   QVGroupBox *tipSettingBox = new QVGroupBox(parent);
83
 
   tipSettingBox->setTitle(i18n("Tooltips Settings"));
84
 
 
85
 
   showToolTipsBox_ = new QCheckBox(tipSettingBox);
86
 
   showToolTipsBox_->setText(i18n("Show toolti&ps for items"));
87
 
 
88
 
   layout->addWidget(tipSettingBox);
89
 
 
90
 
   // --------------------------------------------------------
91
 
   QVGroupBox *iconTextGroup = new QVGroupBox(i18n("Thumbnails"), parent);
92
 
   iconTextGroup->setColumnLayout(0, Qt::Vertical );
93
 
   iconTextGroup->layout()->setMargin(KDialog::marginHint());
94
 
   QGridLayout* tagSettingsLayout = new QGridLayout(iconTextGroup->layout(), 3, 8,
95
 
                                                    KDialog::spacingHint());
96
 
 
97
 
   iconShowNameBox_ = new QCheckBox(iconTextGroup);
98
 
   iconShowNameBox_->setText(i18n("Show file &name"));
99
 
   tagSettingsLayout->addWidget(iconShowNameBox_, 0, 0);
100
 
 
101
 
   iconShowTagsBox_ = new QCheckBox(iconTextGroup);
102
 
   iconShowTagsBox_->setText(i18n("Show file &tags"));
103
 
   tagSettingsLayout->addWidget(iconShowTagsBox_, 1, 0);
104
 
 
105
 
   iconShowSizeBox_ = new QCheckBox(iconTextGroup);
106
 
   iconShowSizeBox_->setText(i18n("Show file si&ze"));
107
 
   tagSettingsLayout->addWidget(iconShowSizeBox_, 2, 0);
108
 
 
109
 
   iconShowDateBox_ = new QCheckBox(iconTextGroup);
110
 
   iconShowDateBox_->setText(i18n("Show file &modification date"));
111
 
   tagSettingsLayout->addWidget(iconShowDateBox_, 3, 0);
112
 
 
113
 
   iconShowCommentsBox_ = new QCheckBox(iconTextGroup);
114
 
   iconShowCommentsBox_->setText(i18n("Show &digiKam comments"));
115
 
   tagSettingsLayout->addWidget(iconShowCommentsBox_, 4, 0);
116
 
 
117
 
   iconShowRatingBox_ = new QCheckBox(iconTextGroup);
118
 
   iconShowRatingBox_->setText(i18n("Show file rating"));
119
 
   tagSettingsLayout->addWidget(iconShowRatingBox_, 5,0);
120
 
 
121
 
   iconShowResolutionBox_ = new QCheckBox(iconTextGroup);
122
 
   iconShowResolutionBox_->setText(i18n("Show ima&ge dimensions (warning: slow)"));
123
 
   tagSettingsLayout->addWidget(iconShowResolutionBox_, 6, 0);
124
 
 
125
 
   layout->addWidget(iconTextGroup);
126
 
 
127
 
   // --------------------------------------------------------
128
 
 
129
 
   layout->addStretch();
130
 
 
131
 
   readSettings();
132
 
   adjustSize();
 
106
    d = new SetupGeneralPriv;
 
107
    d->mainDialog       = dialog;
 
108
    QVBoxLayout *layout = new QVBoxLayout( parent, 0, KDialog::spacingHint() );
 
109
 
 
110
    // --------------------------------------------------------
 
111
 
 
112
    QHGroupBox *albumPathBox = new QHGroupBox(parent);
 
113
    albumPathBox->setTitle(i18n("Album &Library Path"));
 
114
 
 
115
    d->albumPathEdit = new KURLRequester(albumPathBox);
 
116
    d->albumPathEdit->setMode(KFile::Directory | KFile::LocalOnly | KFile::ExistingOnly);    
 
117
    QToolTip::add( d->albumPathEdit, i18n("<p>Here you can set the main path to the digiKam album "
 
118
                                          "library in your computer."
 
119
                                          "<p>Write access is required for this path and do not use a "
 
120
                                          "remote path here, like an NFS mounted file system."));
 
121
 
 
122
    connect(d->albumPathEdit, SIGNAL(urlSelected(const QString &)),
 
123
            this, SLOT(slotChangeAlbumPath(const QString &)));
 
124
 
 
125
    connect(d->albumPathEdit, SIGNAL(textChanged(const QString&)),
 
126
            this, SLOT(slotPathEdited(const QString&)) );
 
127
 
 
128
    layout->addWidget(albumPathBox);
 
129
 
 
130
    // --------------------------------------------------------
 
131
 
 
132
    QVGroupBox *iconTextGroup = new QVGroupBox(i18n("Thumbnail Information"), parent);
 
133
      
 
134
    d->iconShowNameBox = new QCheckBox(i18n("Show file &name"), iconTextGroup);
 
135
    QWhatsThis::add( d->iconShowNameBox, i18n("<p>Set this option to show the file name below the image thumbnail."));
 
136
 
 
137
    d->iconShowSizeBox = new QCheckBox(i18n("Show file si&ze"), iconTextGroup);
 
138
    QWhatsThis::add( d->iconShowSizeBox, i18n("<p>Set this option to show the file size below the image thumbnail."));
 
139
 
 
140
    d->iconShowDateBox = new QCheckBox(i18n("Show camera creation &date"), iconTextGroup);
 
141
    QWhatsThis::add( d->iconShowDateBox, i18n("<p>Set this option to show the camera creation date "
 
142
                                              "below the image thumbnail."));
 
143
 
 
144
    d->iconShowModDateBox = new QCheckBox(i18n("Show file &modification date"), iconTextGroup);
 
145
    QWhatsThis::add( d->iconShowModDateBox, i18n("<p>Set this option to show the file modification date "
 
146
                                                 "below the image thumbnail."));
 
147
 
 
148
    d->iconShowCommentsBox = new QCheckBox(i18n("Show digiKam &captions"), iconTextGroup);
 
149
    QWhatsThis::add( d->iconShowCommentsBox, i18n("<p>Set this option to show the digiKam captions "
 
150
                                                  "below the image thumbnail."));
 
151
 
 
152
    d->iconShowTagsBox = new QCheckBox(i18n("Show digiKam &tags"), iconTextGroup);
 
153
    QWhatsThis::add( d->iconShowTagsBox, i18n("<p>Set this option to show the digiKam tags "
 
154
                                              "below the image thumbnail."));
 
155
 
 
156
    d->iconShowRatingBox = new QCheckBox(i18n("Show digiKam &rating"), iconTextGroup);
 
157
    QWhatsThis::add( d->iconShowRatingBox, i18n("<p>Set this option to show the digiKam rating "
 
158
                                                "below the image thumbnail."));
 
159
 
 
160
    d->iconShowResolutionBox = new QCheckBox(i18n("Show ima&ge dimensions (warning: slow)"), iconTextGroup);
 
161
    QWhatsThis::add( d->iconShowResolutionBox, i18n("<p>Set this option to show the image size in pixels "
 
162
                                                    "below the image thumbnail."));
 
163
 
 
164
    layout->addWidget(iconTextGroup);
 
165
 
 
166
    // --------------------------------------------------------
 
167
 
 
168
    QVGroupBox *interfaceOptionsGroup = new QVGroupBox(i18n("Interface Options"), parent);
 
169
    interfaceOptionsGroup->setColumnLayout(0, Qt::Vertical );
 
170
    interfaceOptionsGroup->layout()->setMargin(KDialog::marginHint());
 
171
    QGridLayout* ifaceSettingsLayout = new QGridLayout(interfaceOptionsGroup->layout(), 3, 4, KDialog::spacingHint());
 
172
 
 
173
    d->iconTreeThumbLabel = new QLabel(i18n("Sidebar thumbnail size:"), interfaceOptionsGroup);
 
174
    d->iconTreeThumbSize = new QComboBox(false, interfaceOptionsGroup);
 
175
    d->iconTreeThumbSize->insertItem("16");
 
176
    d->iconTreeThumbSize->insertItem("22");
 
177
    d->iconTreeThumbSize->insertItem("32");
 
178
    d->iconTreeThumbSize->insertItem("48");
 
179
    QToolTip::add( d->iconTreeThumbSize, i18n("<p>Set this option to configure the size "
 
180
                                              "in pixels of the thumbnails in digiKam's sidebars. "
 
181
                                              "This option will take effect when you restart "
 
182
                                              "digiKam."));
 
183
    ifaceSettingsLayout->addMultiCellWidget(d->iconTreeThumbLabel, 0, 0, 0, 0);
 
184
    ifaceSettingsLayout->addMultiCellWidget(d->iconTreeThumbSize, 0, 0, 1, 1);
 
185
 
 
186
    d->showFolderTreeViewItemsCount = new QCheckBox(i18n("Show count of items in all tree-view"), interfaceOptionsGroup);
 
187
    ifaceSettingsLayout->addMultiCellWidget(d->showFolderTreeViewItemsCount, 1, 1, 0, 4);
 
188
 
 
189
 
 
190
    QLabel *rightClickLabel     = new QLabel(i18n("Thumbnail click action:"), interfaceOptionsGroup);
 
191
    d->rightClickActionComboBox = new QComboBox(false, interfaceOptionsGroup);
 
192
    d->rightClickActionComboBox->insertItem(i18n("Show embedded preview"), AlbumSettings::ShowPreview);
 
193
    d->rightClickActionComboBox->insertItem(i18n("Start image editor"), AlbumSettings::StartEditor);
 
194
    QToolTip::add( d->rightClickActionComboBox, i18n("<p>Here, choose what should happen when you "
 
195
                                                     "click on a thumbnail."));
 
196
    ifaceSettingsLayout->addMultiCellWidget(rightClickLabel, 2 ,2, 0, 0);
 
197
    ifaceSettingsLayout->addMultiCellWidget(d->rightClickActionComboBox, 2, 2, 1, 4);
 
198
 
 
199
    d->previewLoadFullImageSize = new QCheckBox(i18n("Embedded preview loads full image size"), interfaceOptionsGroup);
 
200
    QWhatsThis::add( d->previewLoadFullImageSize, i18n("<p>Set this option to load the full image size "
 
201
                     "with an embedded preview, instead a reduced one. Because this option will take more time "
 
202
                     "to load images, use it only if you have a fast computer."));
 
203
    ifaceSettingsLayout->addMultiCellWidget(d->previewLoadFullImageSize, 3, 3, 0, 4);
 
204
 
 
205
    layout->addWidget(interfaceOptionsGroup);
 
206
 
 
207
    // --------------------------------------------------------
 
208
 
 
209
    layout->addStretch();
 
210
 
 
211
    readSettings();
 
212
    adjustSize();
133
213
}
134
214
 
135
215
SetupGeneral::~SetupGeneral()
136
216
{
 
217
    delete d;
137
218
}
138
219
 
139
220
void SetupGeneral::applySettings()
140
221
{
141
222
    AlbumSettings* settings = AlbumSettings::instance();
142
 
 
143
223
    if (!settings) return;
144
224
 
145
 
    settings->setAlbumLibraryPath(albumPathEdit->text());
146
 
 
147
 
    settings->setShowToolTips(showToolTipsBox_->isChecked());
148
 
 
149
 
    settings->setIconShowName(iconShowNameBox_->isChecked());
150
 
    settings->setIconShowTags(iconShowTagsBox_->isChecked());
151
 
    settings->setIconShowSize(iconShowSizeBox_->isChecked());
152
 
    settings->setIconShowDate(iconShowDateBox_->isChecked());
153
 
    settings->setIconShowResolution(iconShowResolutionBox_->isChecked());
154
 
    settings->setIconShowComments(iconShowCommentsBox_->isChecked());
155
 
    settings->setIconShowRating(iconShowRatingBox_->isChecked());
156
 
 
 
225
    settings->setAlbumLibraryPath(d->albumPathEdit->url());
 
226
 
 
227
    settings->setDefaultTreeIconSize(d->iconTreeThumbSize->currentText().toInt());
 
228
    settings->setIconShowName(d->iconShowNameBox->isChecked());
 
229
    settings->setIconShowTags(d->iconShowTagsBox->isChecked());
 
230
    settings->setIconShowSize(d->iconShowSizeBox->isChecked());
 
231
    settings->setIconShowDate(d->iconShowDateBox->isChecked());
 
232
    settings->setIconShowModDate(d->iconShowModDateBox->isChecked());
 
233
    settings->setIconShowResolution(d->iconShowResolutionBox->isChecked());
 
234
    settings->setIconShowComments(d->iconShowCommentsBox->isChecked());
 
235
    settings->setIconShowRating(d->iconShowRatingBox->isChecked());
 
236
 
 
237
    settings->setItemRightClickAction((AlbumSettings::ItemRightClickAction)
 
238
                                      d->rightClickActionComboBox->currentItem());
 
239
 
 
240
    settings->setPreviewLoadFullImageSize(d->previewLoadFullImageSize->isChecked());
 
241
    settings->setShowFolderTreeViewItemsCount(d->showFolderTreeViewItemsCount->isChecked());
157
242
    settings->saveSettings();
158
243
}
159
244
 
163
248
 
164
249
    if (!settings) return;
165
250
 
166
 
    albumPathEdit->setText(settings->getAlbumLibraryPath());
167
 
 
168
 
    showToolTipsBox_->setChecked(settings->getShowToolTips());
169
 
 
170
 
    iconShowNameBox_->setChecked(settings->getIconShowName());
171
 
    iconShowTagsBox_->setChecked(settings->getIconShowTags());
172
 
    iconShowSizeBox_->setChecked(settings->getIconShowSize());
173
 
    iconShowDateBox_->setChecked(settings->getIconShowDate());
174
 
    iconShowResolutionBox_->setChecked(settings->getIconShowResolution());
175
 
    iconShowCommentsBox_->setChecked(settings->getIconShowComments());
176
 
    iconShowRatingBox_->setChecked(settings->getIconShowRating());
 
251
    d->albumPathEdit->setURL(settings->getAlbumLibraryPath());
 
252
 
 
253
    if (settings->getDefaultTreeIconSize() == 16)
 
254
        d->iconTreeThumbSize->setCurrentItem(0);
 
255
    else if (settings->getDefaultTreeIconSize() == 22)
 
256
        d->iconTreeThumbSize->setCurrentItem(1);
 
257
    else if (settings->getDefaultTreeIconSize() == 32)
 
258
        d->iconTreeThumbSize->setCurrentItem(2);
 
259
    else 
 
260
        d->iconTreeThumbSize->setCurrentItem(3);
 
261
    
 
262
    d->iconShowNameBox->setChecked(settings->getIconShowName());
 
263
    d->iconShowTagsBox->setChecked(settings->getIconShowTags());
 
264
    d->iconShowSizeBox->setChecked(settings->getIconShowSize());
 
265
    d->iconShowDateBox->setChecked(settings->getIconShowDate());
 
266
    d->iconShowModDateBox->setChecked(settings->getIconShowModDate());
 
267
    d->iconShowResolutionBox->setChecked(settings->getIconShowResolution());
 
268
    d->iconShowCommentsBox->setChecked(settings->getIconShowComments());
 
269
    d->iconShowRatingBox->setChecked(settings->getIconShowRating());
 
270
 
 
271
    d->rightClickActionComboBox->setCurrentItem((int)settings->getItemRightClickAction());
 
272
 
 
273
    d->previewLoadFullImageSize->setChecked(settings->getPreviewLoadFullImageSize());
 
274
    d->showFolderTreeViewItemsCount->setChecked(settings->getShowFolderTreeViewItemsCount());
177
275
}
178
276
 
179
 
void SetupGeneral::slotChangeAlbumPath()
 
277
void SetupGeneral::slotChangeAlbumPath(const QString &result)
180
278
{
181
 
    QString  result =
182
 
        KFileDialog::getExistingDirectory(
183
 
            albumPathEdit->text(),
184
 
            this);
185
 
 
186
 
    if (KURL(result).equals(KURL(QDir::homeDirPath()), true)) {
187
 
        KMessageBox::sorry(0, i18n("Sorry; cannot use home directory as albums library."));
 
279
    if (KURL(result).equals(KURL(QDir::homeDirPath()), true)) 
 
280
    {
 
281
        KMessageBox::sorry(0, i18n("Sorry you can't use your home directory as album library."));
188
282
        return;
189
283
    }
190
284
 
191
285
    QFileInfo targetPath(result);
192
 
    if (!result.isEmpty() && !targetPath.isWritable()) {
 
286
 
 
287
    if (!result.isEmpty() && !targetPath.isWritable()) 
 
288
    {
193
289
        KMessageBox::information(0, i18n("No write access for this path.\n"
194
 
                                         "Warning: the comments and tag features will not work."));
195
 
        return;
196
 
    }
197
 
 
198
 
    if (!result.isEmpty()) {
199
 
        albumPathEdit->setText(result);
 
290
                                         "Warning: the caption and tag features will not work."));
200
291
    }
201
292
}
202
293
 
203
294
void SetupGeneral::slotPathEdited(const QString& newPath)
204
295
{
205
 
    if (newPath.isEmpty()) {
206
 
       mainDialog_->enableButtonOK(false);
 
296
    if (newPath.isEmpty()) 
 
297
    {
 
298
       d->mainDialog->enableButtonOK(false);
207
299
       return;
208
300
    }
209
301
 
210
 
    if (!newPath.startsWith("/")) {
211
 
        albumPathEdit->setText(QDir::homeDirPath()+"/"+newPath);
 
302
    if (!newPath.startsWith("/")) 
 
303
    {
 
304
        d->albumPathEdit->setURL(QDir::homeDirPath() + '/' + newPath);
212
305
    }
213
306
 
214
307
    QFileInfo targetPath(newPath);
215
308
    QDir dir(newPath);
216
 
    mainDialog_->enableButtonOK(dir.exists() &&
217
 
                                dir != QDir(QDir::homeDirPath ()));
 
309
    d->mainDialog->enableButtonOK(dir.exists() && dir.path() != QDir::homeDirPath());
218
310
}
219
311
 
220
 
#include "setupgeneral.moc"
 
312
}  // namespace Digikam
 
313