00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00028 #include <qlayout.h>
00029 #include <qlabel.h>
00030 #include <qframe.h>
00031 #include <kcolorbutton.h>
00032 #include <kpushbutton.h>
00033 #include <klocale.h>
00034 #include <kiconloader.h>
00035 #include <kglobal.h>
00036 #include <knuminput.h>
00037 #include <kurlrequester.h>
00038 #include <qslider.h>
00039 #include <qbuttongroup.h>
00040 #include <klistbox.h>
00041 #include <qcheckbox.h>
00042 #include <klineedit.h>
00043 #include <kfontrequester.h>
00044 #include <kcolorcombo.h>
00045 #include <kcombobox.h>
00046 #include <kurl.h>
00047 #include <kmimetype.h>
00048 #include <kmessagebox.h>
00049
00050 #include "configuration.h"
00051 #include "configdialog.h"
00052 #include "prefcaption.h"
00053 #include "prefcapture.h"
00054 #include "preffile.h"
00055 #include "prefftp.h"
00056 #include "prefwww.h"
00057
00058 ConfigDialog::ConfigDialog(QWidget *parent, const char *name, WFlags f)
00059 : KDialogBase(IconList, i18n("Preferences"), Default|Ok|Apply|Cancel, Ok, parent, name, f)
00060 {
00061 setIcon(KGlobal::iconLoader()->loadIcon("configure",KIcon::Small,0,false) );
00062
00063
00064 QFrame *frame = addPage(i18n("Capture"), i18n("Capture options"),
00065 KGlobal::iconLoader()->loadIcon("ksnapshot",KIcon::Panel,0,false) );
00066 QVBoxLayout *frameLayout = new QVBoxLayout( frame, 0, 0 );
00067 m_prefCapture = new PrefCapture(frame);
00068 frameLayout->addWidget(m_prefCapture);
00069
00070
00071 frame = addPage(i18n("File"), i18n("File settings"),
00072 KGlobal::iconLoader()->loadIcon("edit",KIcon::Panel,0,false) );
00073 frameLayout = new QVBoxLayout( frame, 0, 0 );
00074 m_prefFile = new PrefFile(frame);
00075 frameLayout->addWidget(m_prefFile);
00076
00077
00078 frame = addPage(i18n("FTP"), i18n("FTP settings"),
00079 KGlobal::iconLoader()->loadIcon("network",KIcon::Panel,0,false) );
00080 frameLayout = new QVBoxLayout( frame, 0, 0 );
00081 m_prefFTP = new PrefFTP(frame);
00082 frameLayout->addWidget(m_prefFTP);
00083
00084
00085 frame = addPage(i18n("WWW"), i18n("WWW settings"),
00086 KGlobal::iconLoader()->loadIcon("kppp",KIcon::Panel,0,false) );
00087 frameLayout = new QVBoxLayout( frame, 0, 0 );
00088 m_prefWWW = new PrefWWW(frame);
00089 frameLayout->addWidget(m_prefWWW);
00090
00091
00092 frame = addPage(i18n("Caption"), i18n("Caption settings"),
00093 KGlobal::iconLoader()->loadIcon("fonts",KIcon::Panel,0,false) );
00094 frameLayout = new QVBoxLayout( frame, 0, 0 );
00095 m_prefCaption = new PrefCaption(frame);
00096 frameLayout->addWidget(m_prefCaption);
00097
00098
00099 connect(m_prefCapture->m_inputDelay, SIGNAL(valueChanged(int)), this, SLOT(enableApply()));
00100 connect(m_prefCapture->m_grpRadio, SIGNAL(clicked(int)), this, SLOT(enableApply()));
00101 connect(m_prefCapture->m_sldQuality, SIGNAL(valueChanged(int)), this, SLOT(enableApply()));
00102 connect(m_prefCapture->m_inputMain, SIGNAL(valueChanged(int)), this, SLOT(enableApply()));
00103 connect(m_prefCapture->m_inputThumb, SIGNAL(valueChanged(int)), this, SLOT(enableApply()));
00104 connect(m_prefCapture->m_cmbMode, SIGNAL(activated(int)), this, SLOT(enableApply()));
00105 connect(m_prefCapture->m_chkIncWD, SIGNAL(toggled(bool)), this, SLOT(enableApply()));
00106
00107 connect(m_prefFile->m_urlMain, SIGNAL(textChanged(const QString&)), this, SLOT(enableApply()));
00108 connect(m_prefFile->m_urlThumb, SIGNAL(textChanged(const QString&)), this, SLOT(enableApply()));
00109 connect(m_prefFile->m_urlOffline, SIGNAL(textChanged(const QString&)), this, SLOT(enableApply()));
00110 connect(m_prefFile->m_urlSystem, SIGNAL(textChanged(const QString&)), this, SLOT(enableApply()));
00111
00112 connect(m_prefFTP->m_chkUseFTP, SIGNAL(toggled(bool)), this, SLOT(enableApply()));
00113 connect(m_prefFTP->m_spinPort, SIGNAL(valueChanged(int)), this, SLOT(enableApply()));
00114 connect(m_prefFTP->m_editHost, SIGNAL(textChanged(const QString&)), this, SLOT(enableApply()));
00115 connect(m_prefFTP->m_editUser, SIGNAL(textChanged(const QString&)), this, SLOT(enableApply()));
00116 connect(m_prefFTP->m_editPass, SIGNAL(textChanged(const QString&)), this, SLOT(enableApply()));
00117 connect(m_prefFTP->m_editPath, SIGNAL(textChanged(const QString&)), this, SLOT(enableApply()));
00118
00119 connect(m_prefWWW->m_chkWWW, SIGNAL(toggled(bool)), this, SLOT(enableApply()));
00120 connect(m_prefWWW->m_spinPort, SIGNAL(valueChanged(int)), this, SLOT(enableApply()));
00121 connect(m_prefWWW, SIGNAL(itemRemoved()), this, SLOT(enableApply()));
00122 connect(m_prefWWW, SIGNAL(itemsAdded()), this, SLOT(enableApply()));
00123
00124 connect(m_prefCaption->m_chkCaption, SIGNAL(toggled(bool)), this, SLOT(enableApply()));
00125 connect(m_prefCaption->m_editText, SIGNAL(textChanged(const QString&)), this, SLOT(enableApply()));
00126 connect(m_prefCaption->m_fontRequest, SIGNAL(fontSelected(const QFont&)), this, SLOT(enableApply()));
00127 connect(m_prefCaption->m_cmbColor, SIGNAL(activated(int)), this, SLOT(enableApply()));
00128 connect(m_prefCaption->m_cmbPos, SIGNAL(activated(int)), this, SLOT(enableApply()));
00129 connect(m_prefCaption->m_chkCustom, SIGNAL(toggled(bool)), this, SLOT(enableApply()));
00130 connect(m_prefCaption->m_inputX, SIGNAL(valueChanged(int)), this, SLOT(enableApply()));
00131 connect(m_prefCaption->m_inputY, SIGNAL(valueChanged(int)), this, SLOT(enableApply()));
00132
00133
00134 alignFlags[Configuration::PosTopLeft] = Qt::AlignLeft | Qt::AlignTop;
00135 alignFlags[Configuration::PosTopRight] = Qt::AlignRight | Qt::AlignTop;
00136 alignFlags[Configuration::PosTopCenter] = Qt::AlignHCenter | Qt::AlignTop;
00137 alignFlags[Configuration::PosLeftCenter] = Qt::AlignLeft | Qt::AlignVCenter;
00138 alignFlags[Configuration::PosCenter] = Qt::AlignCenter;
00139 alignFlags[Configuration::PosRightCenter] = Qt::AlignRight | Qt::AlignVCenter;
00140 alignFlags[Configuration::PosBottomLeft] = Qt::AlignLeft | Qt::AlignBottom;
00141 alignFlags[Configuration::PosBottomCenter] = Qt::AlignHCenter | Qt::AlignBottom;
00142 alignFlags[Configuration::PosBottomRight] = Qt::AlignRight | Qt::AlignBottom;
00143 }
00144
00145
00146 ConfigDialog::~ConfigDialog()
00147 {
00148 }
00149
00150 void ConfigDialog::updateDialog()
00151 {
00152
00153 m_prefCapture->m_inputDelay->setValue(Config().Capture.CaptureDelay / 1000);
00154 m_prefCapture->m_grpRadio->setButton(Config().Capture.ScaleMode);
00155 m_prefCapture->m_sldQuality->setValue(Config().Capture.PictureQuality);
00156 m_prefCapture->m_inputMain->setValue(Config().Capture.ScaleMain);
00157 m_prefCapture->m_inputThumb->setValue(Config().Capture.ScaleThumb);
00158 m_prefCapture->scaleModeChanged(Config().Capture.ScaleMode);
00159 m_prefCapture->m_cmbMode->setCurrentItem(Configuration::FullScreen);
00160 m_prefCapture->m_cmbMode->setCurrentItem(Configuration::WindowUnderCursor);
00161 m_prefCapture->m_cmbMode->setCurrentItem(Config().Capture.CaptureMode);
00162 m_prefCapture->m_chkIncWD->setChecked(Config().Capture.IncludeWD);
00163
00164
00165 m_prefFile->m_urlMain->setURL(Config().File.PathMain);
00166 if(Config().Ftp.UseThumb) m_prefFile->m_urlThumb->setURL(Config().File.PathThumb);
00167 if(Config().Ftp.UseOffline) m_prefFile->m_urlOffline->setURL(Config().File.PathOffline);
00168 if(Config().Log.UseLog) m_prefFile->m_urlSystem->setURL(Config().Log.Path);
00169
00170
00171 m_prefFTP->m_chkUseFTP->setChecked(true);
00172 m_prefFTP->m_chkUseFTP->setChecked(false);
00173 m_prefFTP->m_chkUseFTP->setChecked(Config().Ftp.UseFtp);
00174 m_prefFTP->m_spinPort->setValue(Config().Ftp.Port);
00175 m_prefFTP->m_editHost->setText(Config().Ftp.Host);
00176 m_prefFTP->m_editUser->setText(Config().Ftp.User);
00177 m_prefFTP->m_editPass->setText(Config().Ftp.Password);
00178 m_prefFTP->m_editPath->setText(Config().Ftp.TransferPath);
00179
00180
00181 m_prefWWW->m_chkWWW->setChecked(true);
00182 m_prefWWW->m_chkWWW->setChecked(false);
00183 m_prefWWW->m_chkWWW->setChecked(Config().WWW.UseWWW);
00184 if(Config().WWW.UseWWW)
00185 {
00186 m_prefWWW->m_spinPort->setValue(Config().WWW.Port);
00187
00188 m_prefWWW->m_listFiles->clear();
00189 for ( QStringList::Iterator it = Config().WWW.Files.begin(); it != Config().WWW.Files.end(); ++it )
00190 {
00191 KURL url;
00192 url.setPath(*it);
00193 m_prefWWW->m_listFiles->insertItem(KMimeType::pixmapForURL(url, 0, KIcon::Small), *it);
00194 }
00195
00196
00197 }
00198
00199
00200 m_prefCaption->m_chkCaption->setChecked(true);
00201 m_prefCaption->m_chkCaption->setChecked(false);
00202 m_prefCaption->m_chkCaption->setChecked(Config().Caption.UseCaption);
00203 m_prefCaption->m_editText->setText(Config().Caption.Text);
00204 m_prefCaption->m_fontRequest->setFont(Config().Caption.Font);
00205 m_prefCaption->m_cmbColor->setColor(Config().Caption.Color);
00206
00207
00208 int i;
00209 for(i = 0; i < 9; i++)
00210 {
00211 if(alignFlags[i] == Config().Caption.Position) break;
00212 }
00213 m_prefCaption->m_cmbPos->setCurrentItem(i);
00214
00215 bool customPosition = Config().Caption.CustomPos;
00216 m_prefCaption->m_chkCustom->setChecked(customPosition);
00217 m_prefCaption->m_grpCustom->setEnabled(customPosition);
00218 if(customPosition)
00219 {
00220 m_prefCaption->m_inputX->setValue(Config().Caption.PositionX);
00221 m_prefCaption->m_inputY->setValue(Config().Caption.PositionY);
00222 }
00223
00224 enableButtonApply(false);
00225 }
00226
00227 void ConfigDialog::updateConfiguration()
00228 {
00229
00230 Config().Capture.CaptureMode = m_prefCapture->m_cmbMode->currentItem();
00231 Config().Capture.CaptureDelay = m_prefCapture->m_inputDelay->value() * 1000;
00232 Config().Capture.ScaleMode = m_prefCapture->m_grpRadio->selectedId();
00233 Config().Capture.PictureQuality = m_prefCapture->m_sldQuality->value();
00234 Config().Capture.ScaleMain = m_prefCapture->m_inputMain->value();
00235 Config().Capture.ScaleThumb = m_prefCapture->m_inputThumb->value();
00236 Config().Capture.IncludeWD = m_prefCapture->m_chkIncWD->isChecked();
00237
00238
00239 Config().File.PathMain = m_prefFile->m_urlMain->url();
00240
00241 Config().File.PathThumb = m_prefFile->m_urlThumb->url();
00242 if((Config().File.PathThumb).isEmpty())
00243 Config().Ftp.UseThumb = false;
00244 else
00245 Config().Ftp.UseThumb = true;
00246
00247 Config().File.PathOffline = m_prefFile->m_urlOffline->url();
00248 if((Config().File.PathOffline).isEmpty())
00249 Config().Ftp.UseOffline = false;
00250 else
00251 Config().Ftp.UseOffline = true;
00252
00253 Config().Log.Path = m_prefFile->m_urlSystem->url();
00254 if((Config().Log.Path).isEmpty())
00255 Config().Log.UseLog = false;
00256 else
00257 Config().Log.UseLog = true;
00258
00259
00260 Config().Ftp.UseFtp = m_prefFTP->m_chkUseFTP->isChecked();
00261 if(Config().Ftp.UseFtp)
00262 {
00263 Config().Ftp.Port = m_prefFTP->m_spinPort->value();
00264 Config().Ftp.Host = m_prefFTP->m_editHost->text();
00265 Config().Ftp.User = m_prefFTP->m_editUser->text();
00266 Config().Ftp.Password = m_prefFTP->m_editPass->text();
00267 Config().Ftp.TransferPath = m_prefFTP->m_editPath->text();
00268 }
00269
00270 Config().WWW.UseWWW = m_prefWWW->m_chkWWW->isChecked();
00271 Config().WWW.Files.clear();
00272 if(Config().WWW.UseWWW)
00273 {
00274 Config().WWW.Port = m_prefWWW->m_spinPort->value();
00275 for(uint i = 0; i < m_prefWWW->m_listFiles->count(); i++)
00276 {
00277 QListBoxItem* lbi = m_prefWWW->m_listFiles->item(i);
00278 Config().WWW.Files.append(lbi->text());
00279 }
00280 }
00281
00282 Config().Caption.UseCaption = false;
00283 if(m_prefCaption->m_chkCaption->isChecked())
00284 {
00285 Config().Caption.UseCaption = true;
00286 Config().Caption.Text = m_prefCaption->m_editText->text();
00287 Config().Caption.Font = m_prefCaption->m_fontRequest->font();
00288 Config().Caption.Color = m_prefCaption->m_cmbColor->color();
00289 Config().Caption.Position = alignFlags[m_prefCaption->m_cmbPos->currentItem()];
00290
00291 Config().Caption.CustomPos = false;
00292 if(m_prefCaption->m_chkCustom->isChecked())
00293 {
00294 Config().Caption.CustomPos = true;
00295 Config().Caption.PositionX = m_prefCaption->m_inputX->value();
00296 Config().Caption.PositionY = m_prefCaption->m_inputY->value();
00297 }
00298 }
00299
00300 enableButtonApply(false);
00301
00302 }
00303
00304 void ConfigDialog::slotDefault()
00305 {
00306 if(KMessageBox::warningContinueCancel(this, i18n("This will set the default options "
00307 "in ALL pages of the preferences dialog! Continue?"), i18n("Set default options?"),
00308 i18n("Set defaults"))==KMessageBox::Continue)
00309 {
00310
00311 m_prefCapture->m_inputDelay->setValue(Config().Default.Capture.CaptureDelay / 1000);
00312 m_prefCapture->m_grpRadio->setButton(Config().Default.Capture.ScaleMode);
00313 m_prefCapture->m_sldQuality->setValue(Config().Default.Capture.PictureQuality);
00314 m_prefCapture->m_inputMain->setValue(Config().Default.Capture.ScaleMain);
00315 m_prefCapture->m_inputThumb->setValue(Config().Default.Capture.ScaleThumb);
00316 m_prefCapture->scaleModeChanged(Config().Default.Capture.ScaleMode);
00317 m_prefCapture->m_cmbMode->setCurrentItem(Configuration::FullScreen);
00318 m_prefCapture->m_cmbMode->setCurrentItem(Configuration::WindowUnderCursor);
00319 m_prefCapture->m_cmbMode->setCurrentItem(Config().Default.Capture.CaptureMode);
00320 m_prefCapture->m_chkIncWD->setChecked(Config().Default.Capture.IncludeWD);
00321
00322
00323 m_prefFile->m_urlMain->setURL(Config().Default.File.PathMain);
00324 m_prefFile->m_urlThumb->setURL(Config().Default.File.PathThumb);
00325 m_prefFile->m_urlOffline->setURL(Config().Default.File.PathOffline);
00326 m_prefFile->m_urlSystem->setURL(Config().Default.Log.Path);
00327
00328
00329 m_prefFTP->m_chkUseFTP->setChecked(true);
00330 m_prefFTP->m_chkUseFTP->setChecked(false);
00331 m_prefFTP->m_chkUseFTP->setChecked(Config().Default.Ftp.UseFtp);
00332 m_prefFTP->m_spinPort->setValue(Config().Default.Ftp.Port);
00333 m_prefFTP->m_editHost->setText(Config().Default.Ftp.Host);
00334 m_prefFTP->m_editUser->setText(Config().Default.Ftp.User);
00335 m_prefFTP->m_editPass->setText(Config().Default.Ftp.Password);
00336 m_prefFTP->m_editPath->setText(Config().Default.Ftp.TransferPath);
00337
00338
00339
00340 m_prefWWW->m_chkWWW->setChecked(true);
00341 m_prefWWW->m_chkWWW->setChecked(false);
00342 m_prefWWW->m_chkWWW->setChecked(Config().Default.WWW.UseWWW);
00343 m_prefWWW->m_spinPort->setValue(Config().Default.WWW.Port);
00344
00345 m_prefWWW->m_listFiles->clear();
00346
00347
00348
00349
00350
00351
00352
00353
00354 m_prefCaption->m_chkCaption->setChecked(true);
00355 m_prefCaption->m_chkCaption->setChecked(false);
00356 m_prefCaption->m_chkCaption->setChecked(Config().Default.Caption.UseCaption);
00357 m_prefCaption->m_editText->setText(Config().Default.Caption.Text);
00358 m_prefCaption->m_fontRequest->setFont(Config().Default.Caption.Font);
00359 m_prefCaption->m_cmbColor->setColor(Config().Default.Caption.Color);
00360
00361
00362 int i;
00363 for(i = 0; i < 9; i++)
00364 {
00365 if(alignFlags[i] == Config().Default.Caption.Position) break;
00366 }
00367 m_prefCaption->m_cmbPos->setCurrentItem(i);
00368
00369 bool customPosition = Config().Default.Caption.CustomPos;
00370 m_prefCaption->m_chkCustom->setChecked(customPosition);
00371 m_prefCaption->m_grpCustom->setEnabled(customPosition);
00372 m_prefCaption->m_inputX->setValue(Config().Default.Caption.PositionX);
00373 m_prefCaption->m_inputY->setValue(Config().Default.Caption.PositionY);
00374 }
00375
00376 enableApply();
00377 }
00378
00379 void ConfigDialog::slotApply()
00380 {
00381 updateConfiguration();
00382 emit settingsChanged();
00383 enableButtonApply(false);
00384 }
00385
00386 void ConfigDialog::enableApply()
00387 {
00388 enableButtonApply(true);
00389 }
00390
00391