1
/* ============================================================
2
* Author: Gilles Caulier <caulier dot gilles at free.fr>
4
* Description : setup tab for ImageEditor.
6
* Copyright 2004 by Gilles Caulier
8
* This program is free software; you can redistribute it
9
* and/or modify it under the terms of the GNU General
10
* Public License as published by the Free Software Foundation;
11
* either version 2, or (at your option)
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* ============================================================ */
26
#include <qvgroupbox.h>
28
#include <qwhatsthis.h>
29
#include <qcheckbox.h>
35
#include <kcolorbutton.h>
36
#include <knuminput.h>
38
#include <kapplication.h>
39
#include <klistview.h>
44
#include "setupeditor.h"
47
SetupEditor::SetupEditor(QWidget* parent )
50
QVBoxLayout *layout = new QVBoxLayout( parent );
52
// --------------------------------------------------------
54
QVGroupBox *savingOptionsGroup = new QVGroupBox(i18n("Saving Images Options"),
57
m_JPEGcompression = new KIntNumInput(75, savingOptionsGroup);
58
m_JPEGcompression->setRange(1, 100, 1, true );
59
m_JPEGcompression->setLabel( i18n("&JPEG quality:"), AlignLeft|AlignVCenter );
61
QWhatsThis::add( m_JPEGcompression, i18n("<p>The quality value for JPEG images:<p>"
62
"<b>1</b>: low quality (high compression and small file size)<p>"
63
"<b>50</b>: medium quality<p>"
64
"<b>75</b>: good quality (default)<p>"
65
"<b>100</b>: high quality (no compression and large file size)<p>"
66
"<b>Note: JPEG is not a lossless image compression format.</b>"));
68
m_PNGcompression = new KIntNumInput(1, savingOptionsGroup);
69
m_PNGcompression->setRange(1, 9, 1, true );
70
m_PNGcompression->setLabel( i18n("&PNG compression:"), AlignLeft|AlignVCenter );
72
QWhatsThis::add( m_PNGcompression, i18n("<p>The compression value for PNG images:<p>"
73
"<b>1</b>: low compression (large file size but "
74
"short compression duration - default)<p>"
75
"<b>5</b>: medium compression<p>"
76
"<b>9</b>: high compression (small file size but "
77
"long compression duration)<p>"
78
"<b>Note: PNG is always a lossless image compression format.</b>"));
80
m_TIFFcompression = new QCheckBox(i18n("Compress TIFF files"),
83
QWhatsThis::add( m_TIFFcompression, i18n("<p>Toggle compression for TIFF images.<p>"
84
"If you enable this option, you can reduce "
85
"the final file size of the TIFF image.</p>"
86
"<p>A lossless compression format (Adobe Deflate) "
87
"is used to save the file.<p>"));
89
layout->addWidget(savingOptionsGroup);
91
// --------------------------------------------------------
93
QVGroupBox *interfaceOptionsGroup = new QVGroupBox(i18n("Interface Options"),
96
QHBox* colorBox = new QHBox(interfaceOptionsGroup);
98
QLabel *backgroundColorlabel = new QLabel( i18n("&Background color:"),
101
m_backgroundColor = new KColorButton(colorBox);
102
backgroundColorlabel->setBuddy(m_backgroundColor);
103
QWhatsThis::add( m_backgroundColor, i18n("<p>Select here the background color to use "
104
"for image editor area.") );
105
backgroundColorlabel->setBuddy( m_backgroundColor );
107
m_hideToolBar = new QCheckBox(i18n("H&ide toolbar in fullscreen mode"),
108
interfaceOptionsGroup);
110
layout->addWidget(interfaceOptionsGroup);
112
// --------------------------------------------------------
114
QVGroupBox *imagePluginsListGroup = new QVGroupBox(i18n("Image Plugins List"),
117
m_pluginsNumber = new QLabel(imagePluginsListGroup);
119
m_pluginList = new KListView( imagePluginsListGroup, "pluginList" );
120
m_pluginList->addColumn( i18n( "Name" ) );
121
m_pluginList->addColumn( "Library Name", 0 ); // Hidden column with the internal plugin library name.
122
m_pluginList->addColumn( i18n( "Description" ) );
123
m_pluginList->setResizeMode( QListView::LastColumn );
124
m_pluginList->setAllColumnsShowFocus( true );
125
QWhatsThis::add( m_pluginList, i18n("<p>You can set here the list of plugins "
126
"which must be enabled/disabled for the future "
127
"digiKam image editor instances."
128
"<p>Note: the core image plugin cannot be disabled."));
130
layout->addWidget( imagePluginsListGroup );
132
// --------------------------------------------------------
135
initImagePluginsList();
136
updateImagePluginsList(m_availableImagePluginList, m_enableImagePluginList);
139
SetupEditor::~SetupEditor()
143
void SetupEditor::initImagePluginsList()
145
KTrader::OfferList offers = KTrader::self()->query("Digikam/ImagePlugin");
146
KTrader::OfferList::ConstIterator iter;
148
for(iter = offers.begin(); iter != offers.end(); ++iter)
150
KService::Ptr service = *iter;
151
m_availableImagePluginList.append(service->name()); // Plugin name translated.
152
m_availableImagePluginList.append(service->library()); // Plugin system library name.
153
m_availableImagePluginList.append(service->comment()); // Plugin comments translated.
157
void SetupEditor::updateImagePluginsList(QStringList lista, QStringList listl)
159
QStringList::Iterator it = lista.begin();
160
m_pluginsNumber->setText(i18n("Plugins found: %1")
161
.arg(lista.count()/3));
163
while( it != lista.end() )
165
QString pluginName = *it;
167
QString libraryName = *it;
169
QString pluginComments = *it;
170
QCheckListItem *item = new QCheckListItem (m_pluginList, pluginName, QCheckListItem::CheckBox);
172
if (listl.contains(libraryName))
175
if (libraryName == "digikamimageplugin_core") // Always enable the Digikam core plugin.
178
item->setEnabled(false);
181
item->setText(0, pluginName); // Added plugin name.
182
item->setText(1, libraryName); // Added library plugin name.
183
item->setText(2, pluginComments); // Added plugin comments.
188
QStringList SetupEditor::getImagePluginsListEnable()
190
QStringList imagePluginList;
191
QCheckListItem *item = (QCheckListItem*)m_pluginList->firstChild();
196
imagePluginList.append(item->text(1)); // Get the plugin library name.
197
item = (QCheckListItem*)item->nextSibling();
200
return imagePluginList;
203
void SetupEditor::applySettings()
205
KConfig* config = kapp->config();
207
config->setGroup("ImageViewer Settings");
208
config->writeEntry("BackgroundColor", m_backgroundColor->color());
209
config->writeEntry("JPEGCompression", m_JPEGcompression->value());
210
config->writeEntry("PNGCompression", m_PNGcompression->value());
211
config->writeEntry("TIFFCompression", m_TIFFcompression->isChecked());
212
config->writeEntry("ImagePlugins List", getImagePluginsListEnable());
213
config->writeEntry("FullScreen Hide ToolBar", m_hideToolBar->isChecked());
217
void SetupEditor::readSettings()
219
KConfig* config = kapp->config();
220
QColor *Black = new QColor(Qt::black);
222
config->setGroup("ImageViewer Settings");
223
m_backgroundColor->setColor( config->readColorEntry("BackgroundColor", Black ) );
224
m_JPEGcompression->setValue( config->readNumEntry("JPEGCompression", 75) );
225
m_PNGcompression->setValue( config->readNumEntry("PNGCompression", 9) );
226
m_TIFFcompression->setChecked(config->readBoolEntry("TIFFCompression", false));
227
m_enableImagePluginList = config->readListEntry("ImagePlugins List");
228
m_hideToolBar->setChecked(config->readBoolEntry("FullScreen Hide ToolBar", false));
234
#include "setupeditor.moc"