20 #include "kpschedulepage.h"
24 #include <tqcombobox.h>
26 #include <tqdatetimeedit.h>
27 #include <tqdatetime.h>
28 #include <tqlineedit.h>
29 #include <tqwhatsthis.h>
30 #include <tdelocale.h>
31 #include <kseparator.h>
32 #include <knuminput.h>
36 KPSchedulePage::KPSchedulePage(TQWidget *parent,
const char *name)
40 TQString whatsThisBillingInfo = i18n(
" <qt> <p><b>Print Job Billing and Accounting</b></p> "
41 " <p>Insert a meaningful string here to associate"
42 " the current print job with a certain account. This"
43 " string will appear in the CUPS \"page_log\" to help"
44 " with the print accounting in your organization. (Leave"
45 " it empty if you do not need it.)"
46 " <p> It is useful for people"
47 " who print on behalf of different \"customers\", like"
48 " print service bureaux, letter shops, press and prepress"
49 " companies, or secretaries who serve different bosses, etc.</p>"
52 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
53 " with the CUPS commandline job option parameter:</em> "
55 " -o job-billing=... # example: \"Marketing_Department\" or \"Joe_Doe\" "
60 TQString whatsThisScheduledPrinting = i18n(
" <qt> <p><b>Scheduled Printing</b></p> "
61 " <p>Scheduled printing lets you control the time"
62 " of the actual printout, while you can still send away your"
63 " job <b>now</b> and have it out of your way."
64 " <p> Especially useful"
65 " is the \"Never (hold indefinitely)\" option. It allows you"
66 " to park your job until a time when you (or a printer administrator)"
67 " decides to manually release it."
68 " <p> This is often required in"
69 " enterprise environments, where you normally are not"
70 " allowed to directly and immediately access the huge production"
71 " printers in your <em>Central Repro Department</em>. However it"
72 " is okay to send jobs to the queue which is under the control of the"
73 " operators (who, after all, need to make sure that the 10,000"
74 " sheets of pink paper which is required by the Marketing"
75 " Department for a particular job are available and loaded"
76 " into the paper trays).</p>"
79 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
80 " with the CUPS commandline job option parameter:</em> "
82 " -o job-hold-until=... # example: \"indefinite\" or \"no-hold\" "
87 TQString whatsThisPageLabel = i18n(
" <qt> <p><b>Page Labels</b></p> "
88 " <p>Page Labels are printed by CUPS at the top and bottom"
89 " of each page. They appear on the pages surrounded by a little"
91 " <p>They contain any string you type into the line edit field.</p>"
94 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
95 " with the CUPS commandline job option parameter:</em> "
97 " -o page-label=\"...\" # example: \"Company Confidential\" "
102 TQString whatsThisJobPriority = i18n(
" <qt> <p><b>Job Priority</b></p> "
103 " <p>Usually CUPS prints all jobs per queue according to"
104 " the \"FIFO\" principle: <em>First In, First Out</em>."
106 " job priority option allows you to re-order the queue according"
108 " <p> It works in both directions: you can increase"
109 " as well as decrease priorities. (Usually you can only control"
110 " your <b>own</b> jobs)."
111 " <p> Since the default job priority is \"50\", any job sent"
112 " with, for example, \"49\" will be printed only after all those"
113 " others have finished. Conversely, a"
114 " \"51\" or higher priority job will go right to the top of"
115 " a populated queue (if no other, higher prioritized one is present).</p>"
118 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
119 " with the CUPS commandline job option parameter:</em> "
121 " -o job-priority=... # example: \"10\" or \"66\" or \"99\" "
126 setTitle(i18n(
"Advanced Options"));
127 setOnlyRealPrinters(
true);
131 struct tm *ts = gmtime(&ct);
132 m_gmtdiff = ts->tm_hour;
134 m_gmtdiff -= ts->tm_hour;
136 m_time =
new TQComboBox(
this);
137 m_time->insertItem(i18n(
"Immediately"));
138 m_time->insertItem(i18n(
"Never (hold indefinitely)"));
139 m_time->insertItem(i18n(
"Daytime (6 am - 6 pm)"));
140 m_time->insertItem(i18n(
"Evening (6 pm - 6 am)"));
141 m_time->insertItem(i18n(
"Night (6 pm - 6 am)"));
142 m_time->insertItem(i18n(
"Weekend"));
143 m_time->insertItem(i18n(
"Second Shift (4 pm - 12 am)"));
144 m_time->insertItem(i18n(
"Third Shift (12 am - 8 am)"));
145 m_time->insertItem(i18n(
"Specified Time"));
146 TQWhatsThis::add(m_time, whatsThisScheduledPrinting);
147 m_tedit =
new TQTimeEdit(
this);
148 m_tedit->setAutoAdvance(
true);
149 m_tedit->setTime(TQTime::currentTime());
150 m_tedit->setEnabled(
false);
151 TQWhatsThis::add(m_tedit, whatsThisScheduledPrinting);
152 m_billing =
new TQLineEdit(
this);
153 TQWhatsThis::add(m_billing, whatsThisBillingInfo);
154 m_pagelabel =
new TQLineEdit(
this);
155 TQWhatsThis::add(m_pagelabel, whatsThisPageLabel);
156 m_priority =
new KIntNumInput(50,
this);
157 TQWhatsThis::add(m_priority, whatsThisJobPriority);
158 m_priority->setRange(1, 100, 10,
true);
160 TQLabel *lab =
new TQLabel(i18n(
"&Scheduled printing:"),
this);
161 lab->setBuddy(m_time);
162 TQWhatsThis::add(lab, whatsThisScheduledPrinting);
163 TQLabel *lab1 =
new TQLabel(i18n(
"&Billing information:"),
this);
164 TQWhatsThis::add(lab1, whatsThisBillingInfo);
165 lab1->setBuddy(m_billing);
166 TQLabel *lab2 =
new TQLabel(i18n(
"T&op/Bottom page label:"),
this);
167 TQWhatsThis::add(lab2, whatsThisPageLabel);
168 lab2->setBuddy(m_pagelabel);
169 m_priority->setLabel(i18n(
"&Job priority:"), TQt::AlignVCenter|TQt::AlignLeft);
170 TQWhatsThis::add(m_priority, whatsThisJobPriority);
172 KSeparator *sep0 =
new KSeparator(
this);
173 sep0->setFixedHeight(10);
175 TQGridLayout *l0 =
new TQGridLayout(
this, 6, 2, 0, 7);
176 l0->addWidget(lab, 0, 0);
177 TQHBoxLayout *l1 =
new TQHBoxLayout(0, 0, 5);
178 l0->addLayout(l1, 0, 1);
179 l1->addWidget(m_time);
180 l1->addWidget(m_tedit);
181 l0->addWidget(lab1, 1, 0);
182 l0->addWidget(lab2, 2, 0);
183 l0->addWidget(m_billing, 1, 1);
184 l0->addWidget(m_pagelabel, 2, 1);
185 l0->addMultiCellWidget(sep0, 3, 3, 0, 1);
186 l0->addMultiCellWidget(m_priority, 4, 4, 0, 1);
187 l0->setRowStretch(5, 1);
189 connect(m_time, TQ_SIGNAL(activated(
int)), TQ_SLOT(slotTimeChanged()));
192 KPSchedulePage::~KPSchedulePage()
196 bool KPSchedulePage::isValid(TQString& msg)
198 if (m_time->currentItem() == 8 && !m_tedit->time().isValid())
200 msg = i18n(
"The time specified is not valid.");
206 void KPSchedulePage::setOptions(
const TQMap<TQString,TQString>& opts)
208 TQString t = opts[
"job-hold-until"];
213 if (t ==
"no-hold") item = 0;
214 else if (t ==
"indefinite") item = 1;
215 else if (t ==
"day-time") item = 2;
216 else if (t ==
"evening") item = 3;
217 else if (t ==
"night") item = 4;
218 else if (t ==
"weekend") item = 5;
219 else if (t ==
"second-shift") item = 6;
220 else if (t ==
"third-shift") item = 7;
223 TQTime qt = TQTime::fromString(t);
224 m_tedit->setTime(qt.addSecs(-3600 * m_gmtdiff));
230 m_time->setCurrentItem(item);
234 TQRegExp re(
"^\"|\"$");
235 t = opts[
"job-billing"].stripWhiteSpace();
237 m_billing->setText(t);
238 t = opts[
"page-label"].stripWhiteSpace();
240 m_pagelabel->setText(t);
241 int val = opts[
"job-priority"].toInt();
243 m_priority->setValue(val);
246 void KPSchedulePage::getOptions(TQMap<TQString,TQString>& opts,
bool incldef)
248 if (incldef || m_time->currentItem() != 0)
251 switch (m_time->currentItem())
253 case 0: t =
"no-hold";
break;
254 case 1: t =
"indefinite";
break;
255 case 2: t =
"day-time";
break;
256 case 3: t =
"evening";
break;
257 case 4: t =
"night";
break;
258 case 5: t =
"weekend";
break;
259 case 6: t =
"second-shift";
break;
260 case 7: t =
"third-shift";
break;
262 t = m_tedit->time().addSecs(3600 * m_gmtdiff).toString();
265 opts[
"job-hold-until"] = t;
267 if (incldef || !m_billing->text().isEmpty())
268 opts[
"job-billing"] =
"\"" + m_billing->text() +
"\"";
269 if (incldef || !m_pagelabel->text().isEmpty())
270 opts[
"page-label"] =
"\"" + m_pagelabel->text() +
"\"";
271 if (incldef || m_priority->value() != 50)
272 opts[
"job-priority"] = TQString::number(m_priority->value());
275 void KPSchedulePage::slotTimeChanged()
277 m_tedit->setEnabled(m_time->currentItem() == 8);
278 if (m_time->currentItem() == 8)
282 #include "kpschedulepage.moc"
This class is intended to be used as base class for customized print dialog page.