00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "cupsdjobspage.h"
00021 #include "cupsdconf.h"
00022
00023 #include <QtGui/QLabel>
00024 #include <QtGui/QCheckBox>
00025 #include <QtGui/QLayout>
00026
00027 #include <klocale.h>
00028 #include <knuminput.h>
00029
00030 CupsdJobsPage::CupsdJobsPage(QWidget *parent)
00031 : CupsdPage(parent)
00032 {
00033 setPageLabel(i18n("Jobs"));
00034 setHeader(i18n("Print Jobs Settings"));
00035 setPixmap("document-print");
00036
00037 keepjobhistory_ = new QCheckBox(i18n("Preserve job history"), this);
00038 keepjobfiles_ = new QCheckBox(i18n("Preserve job files"), this);
00039 autopurgejobs_ = new QCheckBox(i18n("Auto purge jobs"), this);
00040 maxjobs_ = new KIntNumInput(this);
00041 maxjobsperprinter_ = new KIntNumInput(this);
00042 maxjobsperuser_ = new KIntNumInput(this);
00043
00044 maxjobs_->setRange(0, 1000, 1, true);
00045 maxjobs_->setSteps(1, 10);
00046 maxjobs_->setSpecialValueText(i18n("Unlimited"));
00047 maxjobsperprinter_->setRange(0, 1000, 1, true);
00048 maxjobsperprinter_->setSpecialValueText(i18n("Unlimited"));
00049 maxjobsperprinter_->setSteps(1, 10);
00050 maxjobsperuser_->setRange(0, 1000, 1, true);
00051 maxjobsperuser_->setSpecialValueText(i18n("Unlimited"));
00052 maxjobsperuser_->setSteps(1, 10);
00053
00054 QLabel *l1 = new QLabel(i18n("Max jobs:"), this);
00055 QLabel *l2 = new QLabel(i18n("Max jobs per printer:"), this);
00056 QLabel *l3 = new QLabel(i18n("Max jobs per user:"), this);
00057
00058 QGridLayout *m1 = new QGridLayout(this);
00059 m1->setMargin(10);
00060 m1->setSpacing(7);
00061 m1->setRowStretch(6, 1);
00062 m1->setColumnStretch(1, 1);
00063 m1->addWidget(keepjobhistory_, 0, 1);
00064 m1->addWidget(keepjobfiles_, 1, 1);
00065 m1->addWidget(autopurgejobs_, 2, 1);
00066 m1->addWidget(l1, 3, 0, Qt::AlignRight);
00067 m1->addWidget(l2, 4, 0, Qt::AlignRight);
00068 m1->addWidget(l3, 5, 0, Qt::AlignRight);
00069 m1->addWidget(maxjobs_, 3, 1);
00070 m1->addWidget(maxjobsperprinter_, 4, 1);
00071 m1->addWidget(maxjobsperuser_, 5, 1);
00072
00073 connect(keepjobhistory_, SIGNAL(toggled(bool)), SLOT(historyChanged(bool)));
00074 keepjobhistory_->setChecked(true);
00075 }
00076
00077 bool CupsdJobsPage::loadConfig(CupsdConf *conf, QString&)
00078 {
00079 conf_ = conf;
00080 keepjobhistory_->setChecked(conf_->keepjobhistory_);
00081 if (conf_->keepjobhistory_) {
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 conf->keepjobfiles_ = keepjobfiles_->isChecked();
00097 conf->autopurgejobs_ = autopurgejobs_->isChecked();
00098 }
00099 conf->maxjobs_ = maxjobs_->value();
00100 conf->maxjobsperprinter_ = maxjobsperprinter_->value();
00101 conf->maxjobsperuser_ = maxjobsperuser_->value();
00102
00103 return true;
00104 }
00105
00106 void CupsdJobsPage::setInfos(CupsdConf *conf)
00107 {
00108 keepjobhistory_->setWhatsThis(conf->comments_.toolTip("preservejobhistory"));
00109 keepjobfiles_->setWhatsThis(conf->comments_.toolTip("preservejobfiles"));
00110 autopurgejobs_->setWhatsThis(conf->comments_.toolTip("autopurgejobs"));
00111 maxjobs_->setWhatsThis(conf->comments_.toolTip("maxjobs"));
00112 maxjobsperprinter_->setWhatsThis(conf->comments_.toolTip("maxjobsperprinter"));
00113 maxjobsperuser_->setWhatsThis(conf->comments_.toolTip("maxjobsperuser"));
00114 }
00115
00116 void CupsdJobsPage::historyChanged(bool on)
00117 {
00118 keepjobfiles_->setEnabled(on);
00119 autopurgejobs_->setEnabled(on);
00120 }
00121
00122 #include "cupsdjobspage.moc"