44
46
#include <kfiledialog.h>
46
48
#include <kmessagebox.h>
47
#include <klineeditdlg.h>
49
#include <kurlrequester.h>
49
51
// // Local includes.
51
53
#include "albumsettings.h"
52
54
#include "setupgeneral.h"
55
#include "setupgeneral.moc"
60
class SetupGeneralPriv
67
iconTreeThumbSize = 0;
68
iconTreeThumbLabel = 0;
72
iconShowModDateBox = 0;
73
iconShowResolutionBox = 0;
74
iconShowCommentsBox = 0;
76
iconShowRatingBox = 0;
77
rightClickActionComboBox = 0;
78
previewLoadFullImageSize = 0;
79
showFolderTreeViewItemsCount = 0;
82
QLabel *iconTreeThumbLabel;
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;
95
QComboBox *iconTreeThumbSize;
96
QComboBox *rightClickActionComboBox;
98
KURLRequester *albumPathEdit;
100
KDialogBase *mainDialog;
55
103
SetupGeneral::SetupGeneral(QWidget* parent, KDialogBase* dialog )
59
QVBoxLayout *layout = new QVBoxLayout( parent, 0, KDialog::spacingHint() );
61
// --------------------------------------------------------
63
QHGroupBox *albumPathBox = new QHGroupBox(parent);
64
albumPathBox->setTitle(i18n("Album &Library Path"));
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."));
71
QPushButton *changePathButton = new QPushButton(i18n("&Change..."),
73
connect(changePathButton, SIGNAL(clicked()),
74
this, SLOT(slotChangeAlbumPath()));
75
connect( albumPathEdit, SIGNAL(textChanged(const QString&)),
76
this, SLOT(slotPathEdited(const QString&)) );
78
layout->addWidget(albumPathBox);
80
// --------------------------------------------------------
82
QVGroupBox *tipSettingBox = new QVGroupBox(parent);
83
tipSettingBox->setTitle(i18n("Tooltips Settings"));
85
showToolTipsBox_ = new QCheckBox(tipSettingBox);
86
showToolTipsBox_->setText(i18n("Show toolti&ps for items"));
88
layout->addWidget(tipSettingBox);
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());
97
iconShowNameBox_ = new QCheckBox(iconTextGroup);
98
iconShowNameBox_->setText(i18n("Show file &name"));
99
tagSettingsLayout->addWidget(iconShowNameBox_, 0, 0);
101
iconShowTagsBox_ = new QCheckBox(iconTextGroup);
102
iconShowTagsBox_->setText(i18n("Show file &tags"));
103
tagSettingsLayout->addWidget(iconShowTagsBox_, 1, 0);
105
iconShowSizeBox_ = new QCheckBox(iconTextGroup);
106
iconShowSizeBox_->setText(i18n("Show file si&ze"));
107
tagSettingsLayout->addWidget(iconShowSizeBox_, 2, 0);
109
iconShowDateBox_ = new QCheckBox(iconTextGroup);
110
iconShowDateBox_->setText(i18n("Show file &modification date"));
111
tagSettingsLayout->addWidget(iconShowDateBox_, 3, 0);
113
iconShowCommentsBox_ = new QCheckBox(iconTextGroup);
114
iconShowCommentsBox_->setText(i18n("Show &digiKam comments"));
115
tagSettingsLayout->addWidget(iconShowCommentsBox_, 4, 0);
117
iconShowRatingBox_ = new QCheckBox(iconTextGroup);
118
iconShowRatingBox_->setText(i18n("Show file rating"));
119
tagSettingsLayout->addWidget(iconShowRatingBox_, 5,0);
121
iconShowResolutionBox_ = new QCheckBox(iconTextGroup);
122
iconShowResolutionBox_->setText(i18n("Show ima&ge dimensions (warning: slow)"));
123
tagSettingsLayout->addWidget(iconShowResolutionBox_, 6, 0);
125
layout->addWidget(iconTextGroup);
127
// --------------------------------------------------------
129
layout->addStretch();
106
d = new SetupGeneralPriv;
107
d->mainDialog = dialog;
108
QVBoxLayout *layout = new QVBoxLayout( parent, 0, KDialog::spacingHint() );
110
// --------------------------------------------------------
112
QHGroupBox *albumPathBox = new QHGroupBox(parent);
113
albumPathBox->setTitle(i18n("Album &Library Path"));
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."));
122
connect(d->albumPathEdit, SIGNAL(urlSelected(const QString &)),
123
this, SLOT(slotChangeAlbumPath(const QString &)));
125
connect(d->albumPathEdit, SIGNAL(textChanged(const QString&)),
126
this, SLOT(slotPathEdited(const QString&)) );
128
layout->addWidget(albumPathBox);
130
// --------------------------------------------------------
132
QVGroupBox *iconTextGroup = new QVGroupBox(i18n("Thumbnail Information"), parent);
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."));
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."));
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."));
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."));
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."));
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."));
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."));
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."));
164
layout->addWidget(iconTextGroup);
166
// --------------------------------------------------------
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());
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 "
183
ifaceSettingsLayout->addMultiCellWidget(d->iconTreeThumbLabel, 0, 0, 0, 0);
184
ifaceSettingsLayout->addMultiCellWidget(d->iconTreeThumbSize, 0, 0, 1, 1);
186
d->showFolderTreeViewItemsCount = new QCheckBox(i18n("Show count of items in all tree-view"), interfaceOptionsGroup);
187
ifaceSettingsLayout->addMultiCellWidget(d->showFolderTreeViewItemsCount, 1, 1, 0, 4);
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);
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);
205
layout->addWidget(interfaceOptionsGroup);
207
// --------------------------------------------------------
209
layout->addStretch();
135
215
SetupGeneral::~SetupGeneral()
139
220
void SetupGeneral::applySettings()
141
222
AlbumSettings* settings = AlbumSettings::instance();
143
223
if (!settings) return;
145
settings->setAlbumLibraryPath(albumPathEdit->text());
147
settings->setShowToolTips(showToolTipsBox_->isChecked());
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());
225
settings->setAlbumLibraryPath(d->albumPathEdit->url());
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());
237
settings->setItemRightClickAction((AlbumSettings::ItemRightClickAction)
238
d->rightClickActionComboBox->currentItem());
240
settings->setPreviewLoadFullImageSize(d->previewLoadFullImageSize->isChecked());
241
settings->setShowFolderTreeViewItemsCount(d->showFolderTreeViewItemsCount->isChecked());
157
242
settings->saveSettings();
164
249
if (!settings) return;
166
albumPathEdit->setText(settings->getAlbumLibraryPath());
168
showToolTipsBox_->setChecked(settings->getShowToolTips());
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());
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);
260
d->iconTreeThumbSize->setCurrentItem(3);
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());
271
d->rightClickActionComboBox->setCurrentItem((int)settings->getItemRightClickAction());
273
d->previewLoadFullImageSize->setChecked(settings->getPreviewLoadFullImageSize());
274
d->showFolderTreeViewItemsCount->setChecked(settings->getShowFolderTreeViewItemsCount());
179
void SetupGeneral::slotChangeAlbumPath()
277
void SetupGeneral::slotChangeAlbumPath(const QString &result)
182
KFileDialog::getExistingDirectory(
183
albumPathEdit->text(),
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))
281
KMessageBox::sorry(0, i18n("Sorry you can't use your home directory as album library."));
191
285
QFileInfo targetPath(result);
192
if (!result.isEmpty() && !targetPath.isWritable()) {
287
if (!result.isEmpty() && !targetPath.isWritable())
193
289
KMessageBox::information(0, i18n("No write access for this path.\n"
194
"Warning: the comments and tag features will not work."));
198
if (!result.isEmpty()) {
199
albumPathEdit->setText(result);
290
"Warning: the caption and tag features will not work."));
203
294
void SetupGeneral::slotPathEdited(const QString& newPath)
205
if (newPath.isEmpty()) {
206
mainDialog_->enableButtonOK(false);
296
if (newPath.isEmpty())
298
d->mainDialog->enableButtonOK(false);
210
if (!newPath.startsWith("/")) {
211
albumPathEdit->setText(QDir::homeDirPath()+"/"+newPath);
302
if (!newPath.startsWith("/"))
304
d->albumPathEdit->setURL(QDir::homeDirPath() + '/' + newPath);
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());
220
#include "setupgeneral.moc"
312
} // namespace Digikam