cupsdjobspage.cpp

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #include "cupsdjobspage.h"
00021 #include "cupsdconf.h"
00022 
00023 #include <qlabel.h>
00024 #include <qcheckbox.h>
00025 #include <qlayout.h>
00026 #include <qwhatsthis.h>
00027 
00028 #include <klocale.h>
00029 #include <knuminput.h>
00030 
00031 CupsdJobsPage::CupsdJobsPage(QWidget *parent, const char *name)
00032     : CupsdPage(parent, name)
00033 {
00034     setPageLabel(i18n("Jobs"));
00035     setHeader(i18n("Print Jobs Settings"));
00036     setPixmap("fileprint");
00037 
00038     keepjobhistory_ = new QCheckBox(i18n("Preserve job history"), this);
00039     keepjobfiles_ = new QCheckBox(i18n("Preserve job files"), this);
00040     autopurgejobs_ = new QCheckBox(i18n("Auto purge jobs"), this);
00041     maxjobs_ = new KIntNumInput(this);
00042     maxjobsperprinter_ = new KIntNumInput(this);
00043     maxjobsperuser_ = new KIntNumInput(this);
00044 
00045     maxjobs_->setRange(0, 1000, 1, true);
00046     maxjobs_->setSteps(1, 10);
00047     maxjobs_->setSpecialValueText(i18n("Unlimited"));
00048     maxjobsperprinter_->setRange(0, 1000, 1, true);
00049     maxjobsperprinter_->setSpecialValueText(i18n("Unlimited"));
00050     maxjobsperprinter_->setSteps(1, 10);
00051     maxjobsperuser_->setRange(0, 1000, 1, true);
00052     maxjobsperuser_->setSpecialValueText(i18n("Unlimited"));
00053     maxjobsperuser_->setSteps(1, 10);
00054 
00055     QLabel *l1 = new QLabel(i18n("Max jobs:"), this);
00056     QLabel *l2 = new QLabel(i18n("Max jobs per printer:"), this);
00057     QLabel *l3 = new QLabel(i18n("Max jobs per user:"), this);
00058 
00059     QGridLayout *m1 = new QGridLayout(this, 7, 2, 10, 7);
00060     m1->setRowStretch(6, 1);
00061     m1->setColStretch(1, 1);
00062     m1->addWidget(keepjobhistory_, 0, 1);
00063     m1->addWidget(keepjobfiles_, 1, 1);
00064     m1->addWidget(autopurgejobs_, 2, 1);
00065     m1->addWidget(l1, 3, 0, Qt::AlignRight);
00066     m1->addWidget(l2, 4, 0, Qt::AlignRight);
00067     m1->addWidget(l3, 5, 0, Qt::AlignRight);
00068     m1->addWidget(maxjobs_, 3, 1);
00069     m1->addWidget(maxjobsperprinter_, 4, 1);
00070     m1->addWidget(maxjobsperuser_, 5, 1);
00071 
00072     connect(keepjobhistory_, SIGNAL(toggled(bool)), SLOT(historyChanged(bool)));
00073     keepjobhistory_->setChecked(true);
00074 }
00075 
00076 bool CupsdJobsPage::loadConfig(CupsdConf *conf, QString&)
00077 {
00078     conf_ = conf;
00079     keepjobhistory_->setChecked(conf_->keepjobhistory_);
00080     if (conf_->keepjobhistory_)
00081     {
00082         keepjobfiles_->setChecked(conf_->keepjobfiles_);
00083         autopurgejobs_->setChecked(conf_->autopurgejobs_);
00084     }
00085     maxjobs_->setValue(conf_->maxjobs_);
00086     maxjobsperprinter_->setValue(conf_->maxjobsperprinter_);
00087     maxjobsperuser_->setValue(conf_->maxjobsperuser_);
00088 
00089     return true;
00090 }
00091 
00092 bool CupsdJobsPage::saveConfig(CupsdConf *conf, QString&)
00093 {
00094     conf->keepjobhistory_ = keepjobhistory_->isChecked();
00095     if (conf->keepjobhistory_)
00096     {
00097         conf->keepjobfiles_ = keepjobfiles_->isChecked();
00098         conf->autopurgejobs_ = autopurgejobs_->isChecked();
00099     }
00100     conf->maxjobs_ = maxjobs_->value();
00101     conf->maxjobsperprinter_ = maxjobsperprinter_->value();
00102     conf->maxjobsperuser_ = maxjobsperuser_->value();
00103 
00104     return true;
00105 }
00106 
00107 void CupsdJobsPage::setInfos(CupsdConf *conf)
00108 {
00109     QWhatsThis::add(keepjobhistory_, conf->comments_.toolTip("preservejobhistory"));
00110     QWhatsThis::add(keepjobfiles_, conf->comments_.toolTip("preservejobfiles"));
00111     QWhatsThis::add(autopurgejobs_, conf->comments_.toolTip("autopurgejobs"));
00112     QWhatsThis::add(maxjobs_, conf->comments_.toolTip("maxjobs"));
00113     QWhatsThis::add(maxjobsperprinter_, conf->comments_.toolTip("maxjobsperprinter"));
00114     QWhatsThis::add(maxjobsperuser_, conf->comments_.toolTip("maxjobsperuser"));
00115 }
00116 
00117 void CupsdJobsPage::historyChanged(bool on)
00118 {
00119     keepjobfiles_->setEnabled(on);
00120     autopurgejobs_->setEnabled(on);
00121 }
00122 
00123 #include "cupsdjobspage.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys