~ubuntu-branches/ubuntu/feisty/digikam/feisty

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Achim Bohnet
  • Date: 2005-03-10 02:39:02 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050310023902-023nymfst5mg696c
Tags: 0.7.2-2
* debian/TODO: clean
* digikam manpage: better --detect-camera description

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ============================================================
 
2
 * Author: Gilles Caulier <caulier dot gilles at free.fr>
 
3
 * Date  : 2004-08-03
 
4
 * Description : setup tab for ImageEditor.
 
5
 *
 
6
 * Copyright 2004 by Gilles Caulier
 
7
 *
 
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)
 
12
 * any later version.
 
13
 *
 
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.
 
18
 *
 
19
 * ============================================================ */
 
20
 
 
21
// QT includes.
 
22
 
 
23
#include <qlayout.h>
 
24
#include <qcolor.h>
 
25
#include <qhbox.h>
 
26
#include <qvgroupbox.h>
 
27
#include <qlabel.h>
 
28
#include <qwhatsthis.h>
 
29
#include <qcheckbox.h>
 
30
 
 
31
// KDE includes.
 
32
 
 
33
#include <klocale.h>
 
34
#include <kdialog.h>
 
35
#include <kcolorbutton.h>
 
36
#include <knuminput.h>
 
37
#include <kconfig.h>
 
38
#include <kapplication.h>
 
39
#include <klistview.h>
 
40
#include <ktrader.h>
 
41
 
 
42
// Local includes.
 
43
 
 
44
#include "setupeditor.h"
 
45
 
 
46
 
 
47
SetupEditor::SetupEditor(QWidget* parent )
 
48
           : QWidget(parent)
 
49
{
 
50
   QVBoxLayout *layout = new QVBoxLayout( parent );
 
51
 
 
52
   // --------------------------------------------------------
 
53
 
 
54
   QVGroupBox *savingOptionsGroup = new QVGroupBox(i18n("Saving Images Options"),
 
55
                                                   parent);
 
56
 
 
57
   m_JPEGcompression = new KIntNumInput(75, savingOptionsGroup);
 
58
   m_JPEGcompression->setRange(1, 100, 1, true );
 
59
   m_JPEGcompression->setLabel( i18n("&JPEG quality:"), AlignLeft|AlignVCenter );
 
60
 
 
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>"));
 
67
   
 
68
   m_PNGcompression = new KIntNumInput(1, savingOptionsGroup);
 
69
   m_PNGcompression->setRange(1, 9, 1, true );
 
70
   m_PNGcompression->setLabel( i18n("&PNG compression:"), AlignLeft|AlignVCenter );
 
71
 
 
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>"));
 
79
 
 
80
   m_TIFFcompression = new QCheckBox(i18n("Compress TIFF files"),
 
81
                                     savingOptionsGroup);
 
82
   
 
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>"));
 
88
 
 
89
   layout->addWidget(savingOptionsGroup);
 
90
 
 
91
   // --------------------------------------------------------
 
92
 
 
93
   QVGroupBox *interfaceOptionsGroup = new QVGroupBox(i18n("Interface Options"),
 
94
                                                      parent);
 
95
 
 
96
   QHBox* colorBox = new QHBox(interfaceOptionsGroup);
 
97
 
 
98
   QLabel *backgroundColorlabel = new QLabel( i18n("&Background color:"),
 
99
                                             colorBox );
 
100
 
 
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 );
 
106
 
 
107
   m_hideToolBar = new QCheckBox(i18n("H&ide toolbar in fullscreen mode"),
 
108
                                 interfaceOptionsGroup);
 
109
 
 
110
   layout->addWidget(interfaceOptionsGroup);
 
111
 
 
112
   // --------------------------------------------------------
 
113
 
 
114
   QVGroupBox *imagePluginsListGroup = new QVGroupBox(i18n("Image Plugins List"),
 
115
                                                      parent);
 
116
 
 
117
   m_pluginsNumber = new QLabel(imagePluginsListGroup);
 
118
 
 
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."));
 
129
 
 
130
   layout->addWidget( imagePluginsListGroup );
 
131
 
 
132
   // --------------------------------------------------------
 
133
 
 
134
   readSettings();
 
135
   initImagePluginsList();
 
136
   updateImagePluginsList(m_availableImagePluginList, m_enableImagePluginList);
 
137
}
 
138
 
 
139
SetupEditor::~SetupEditor()
 
140
{
 
141
}
 
142
 
 
143
void SetupEditor::initImagePluginsList()
 
144
{
 
145
    KTrader::OfferList offers = KTrader::self()->query("Digikam/ImagePlugin");
 
146
    KTrader::OfferList::ConstIterator iter;
 
147
 
 
148
    for(iter = offers.begin(); iter != offers.end(); ++iter)
 
149
        {
 
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.
 
154
        }
 
155
}
 
156
 
 
157
void SetupEditor::updateImagePluginsList(QStringList lista, QStringList listl)
 
158
{
 
159
    QStringList::Iterator it = lista.begin();
 
160
    m_pluginsNumber->setText(i18n("Plugins found: %1")
 
161
                             .arg(lista.count()/3));
 
162
 
 
163
    while( it != lista.end() )
 
164
        {
 
165
        QString pluginName = *it;
 
166
        it++;
 
167
        QString libraryName = *it;
 
168
        it++;
 
169
        QString pluginComments = *it;
 
170
        QCheckListItem *item = new QCheckListItem (m_pluginList, pluginName, QCheckListItem::CheckBox);
 
171
 
 
172
        if (listl.contains(libraryName))
 
173
           item->setOn(true);
 
174
 
 
175
        if (libraryName == "digikamimageplugin_core")  // Always enable the Digikam core plugin.
 
176
           {
 
177
           item->setOn(true);
 
178
           item->setEnabled(false);
 
179
           }
 
180
 
 
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.
 
184
        it++;
 
185
        }
 
186
}
 
187
 
 
188
QStringList SetupEditor::getImagePluginsListEnable()
 
189
{
 
190
    QStringList imagePluginList;
 
191
    QCheckListItem *item = (QCheckListItem*)m_pluginList->firstChild();
 
192
 
 
193
    while( item )
 
194
        {
 
195
        if (item->isOn())
 
196
        imagePluginList.append(item->text(1));        // Get the plugin library name.
 
197
        item = (QCheckListItem*)item->nextSibling();
 
198
        }
 
199
 
 
200
    return imagePluginList;
 
201
}
 
202
 
 
203
void SetupEditor::applySettings()
 
204
{
 
205
    KConfig* config = kapp->config();
 
206
 
 
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());
 
214
    config->sync();
 
215
}
 
216
 
 
217
void SetupEditor::readSettings()
 
218
{
 
219
    KConfig* config = kapp->config();
 
220
    QColor *Black = new QColor(Qt::black);
 
221
 
 
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));
 
229
 
 
230
    delete Black;
 
231
}
 
232
 
 
233
 
 
234
#include "setupeditor.moc"