00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 #include "cupsdserverdirpage.h"
00021 
00022 #include "qdirlineedit.h"
00023 #include <klocale.h>
00024 #include <qlayout.h>
00025 #include <qlabel.h>
00026 #include <qcombobox.h>
00027 #include <qgroupbox.h>
00028 #include <qwhatsthis.h>
00029 
00030 #include "cupsdconf.h"
00031 #include "cupsdoption.h"
00032 
00033 CupsdServerDirPage::CupsdServerDirPage(QWidget *parent, const char *name)
00034     : CupsdPage(parent, name)
00035 {
00036     path_.append(i18n("Server"));
00037     path_.append(i18n("Directories"));
00038     header_ = i18n("Server Directories Configuration");
00039 
00040     for (int i=0;i<6;i++)
00041         opt_[i] = new CupsdOption(this);
00042 
00043     serverbin_ = new QDirLineEdit(opt_[0]);
00044     serverroot_ = new QDirLineEdit(opt_[1]);
00045     datadir_ = new QDirLineEdit(opt_[2]);
00046     tempdir_ = new QDirLineEdit(opt_[3]);
00047     requestroot_ = new QDirLineEdit(opt_[4]);
00048     fontpath_ = new QDirLineEdit(opt_[5]);
00049 
00050     QLabel  *l1 = new QLabel(i18n("Executables:"), this);
00051     QLabel  *l2 = new QLabel(i18n("Configuration:"), this);
00052     QLabel  *l3 = new QLabel(i18n("Data:"), this);
00053     QLabel  *l4 = new QLabel(i18n("Temporary files:"), this);
00054     QLabel  *l5 = new QLabel(i18n("Temporary requests:"), this);
00055     QLabel  *l6 = new QLabel(i18n("Font path:"), this);
00056 
00057     QGridLayout *main_ = new QGridLayout(this, 10, 2, 10, 10);
00058     main_->addWidget(deflabel_, 0, 1, Qt::AlignRight|Qt::AlignVCenter);
00059     main_->addWidget(opt_[0], 1, 1);
00060     main_->addWidget(opt_[1], 2, 1);
00061     main_->addWidget(opt_[2], 3, 1);
00062     main_->addWidget(opt_[3], 5, 1);
00063     main_->addWidget(opt_[4], 6, 1);
00064     main_->addWidget(opt_[5], 8, 1);
00065     main_->addWidget(l1, 1, 0);
00066     main_->addWidget(l2, 2, 0);
00067     main_->addWidget(l3, 3, 0);
00068     main_->addWidget(l4, 5, 0);
00069     main_->addWidget(l5, 6, 0);
00070     main_->addWidget(l6, 8, 0);
00071     main_->setRowStretch(9, 1);
00072     main_->addRowSpacing(4, 20);
00073     main_->addRowSpacing(7, 20);
00074 
00075 }
00076 
00077 CupsdServerDirPage::~CupsdServerDirPage()
00078 {
00079 }
00080 
00081 bool CupsdServerDirPage::loadConfig(CupsdConf *conf, QString&)
00082 {
00083     conf_ = conf;
00084     if (!conf->serverbin_.isNull())
00085     {
00086         opt_[0]->setDefault(false);
00087         serverbin_->setText(conf->serverbin_);
00088     }
00089     if (!conf->serverroot_.isNull())
00090     {
00091         opt_[1]->setDefault(false);
00092         serverroot_->setText(conf->serverroot_);
00093     }
00094     if (!conf->datadir_.isNull())
00095     {
00096         opt_[2]->setDefault(false);
00097         datadir_->setText(conf->datadir_);
00098     }
00099     if (!conf->tempdir_.isNull())
00100     {
00101         opt_[3]->setDefault(false);
00102         tempdir_->setText(conf->tempdir_);
00103     }
00104     if (!conf->requestroot_.isNull())
00105     {
00106         opt_[4]->setDefault(false);
00107         requestroot_->setText(conf->requestroot_);
00108     }
00109     if (!conf->fontpath_.isNull())
00110     {
00111         opt_[5]->setDefault(false);
00112         fontpath_->setText(conf->fontpath_);
00113     }
00114     return true;
00115 }
00116 
00117 bool CupsdServerDirPage::saveConfig(CupsdConf *conf, QString&)
00118 {
00119     if (!opt_[0]->isDefault() && !serverbin_->text().isNull()) conf->serverbin_ = serverbin_->text();
00120     if (!opt_[1]->isDefault() && !serverroot_->text().isNull()) conf->serverroot_ = serverroot_->text();
00121     if (!opt_[2]->isDefault() && !datadir_->text().isNull()) conf->datadir_ = datadir_->text();
00122     if (!opt_[3]->isDefault() && !tempdir_->text().isNull()) conf->tempdir_ = tempdir_->text();
00123     if (!opt_[4]->isDefault() && !requestroot_->text().isNull()) conf->requestroot_ = requestroot_->text();
00124     if (!opt_[5]->isDefault() && !fontpath_->text().isNull()) conf->fontpath_ = fontpath_->text();
00125     return true;
00126 }
00127 
00128 void CupsdServerDirPage::setDefaults()
00129 {
00130     serverbin_->setText("/usr/lib/cups");
00131     serverroot_->setText("/etc/cups");
00132     datadir_->setText("/usr/share/cups/data");
00133     tempdir_->setText("/var/spool/cups/tmp");
00134     requestroot_->setText("/var/spool/cups");
00135     fontpath_->setText("/usr/share/cups/fonts");
00136 }
00137 
00138 void CupsdServerDirPage::setInfos(CupsdConf *conf)
00139 {
00140         QWhatsThis::add(serverbin_, conf->comments_.toolTip(SERVERBIN_COMM));
00141         QWhatsThis::add(serverroot_, conf->comments_.toolTip(SERVERROOT_COMM));
00142         QWhatsThis::add(datadir_, conf->comments_.toolTip(DATADIR_COMM));
00143         QWhatsThis::add(tempdir_, conf->comments_.toolTip(TEMPDIR_COMM));
00144         QWhatsThis::add(requestroot_, conf->comments_.toolTip(REQUESTROOT_COMM));
00145         QWhatsThis::add(fontpath_, conf->comments_.toolTip(FONTPATH_COMM));
00146 }