• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

  • tdeprint
  • cups
kpschedulepage.cpp
1/*
2 * This file is part of the KDE libraries
3 * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License version 2 as published by the Free Software Foundation.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 **/
19
20#include "kpschedulepage.h"
21
22#include <tqlabel.h>
23#include <tqlayout.h>
24#include <tqcombobox.h>
25#include <tqregexp.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>
33
34#include <time.h>
35
36KPSchedulePage::KPSchedulePage(TQWidget *parent, const char *name)
37: KPrintDialogPage(parent, name)
38{
39 //WhatsThis strings.... (added by pfeifle@kde.org)
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>"
50 " <br> "
51 " <hr> "
52 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
53 " with the CUPS commandline job option parameter:</em> "
54 " <pre>"
55 " -o job-billing=... # example: \"Marketing_Department\" or \"Joe_Doe\" "
56 " </pre>"
57 " </p> "
58 " </qt>" );
59
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>"
77 " <br> "
78 " <hr> "
79 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
80 " with the CUPS commandline job option parameter:</em> "
81 " <pre>"
82 " -o job-hold-until=... # example: \"indefinite\" or \"no-hold\" "
83 " </pre>"
84 " </p> "
85 " </qt>" );
86
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"
90 " frame box."
91 " <p>They contain any string you type into the line edit field.</p>"
92 " <br> "
93 " <hr> "
94 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
95 " with the CUPS commandline job option parameter:</em> "
96 " <pre>"
97 " -o page-label=\"...\" # example: \"Company Confidential\" "
98 " </pre>"
99 " </p> "
100 " </qt>" );
101
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>."
105 " <p> The"
106 " job priority option allows you to re-order the queue according"
107 " to your needs."
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>"
116 " <br> "
117 " <hr> "
118 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
119 " with the CUPS commandline job option parameter:</em> "
120 " <pre>"
121 " -o job-priority=... # example: \"10\" or \"66\" or \"99\" "
122 " </pre>"
123 " </p> "
124 " </qt>" );
125
126 setTitle(i18n("Advanced Options"));
127 setOnlyRealPrinters(true);
128
129 // compute difference in hours between GMT and local time
130 time_t ct = time(0);
131 struct tm *ts = gmtime(&ct);
132 m_gmtdiff = ts->tm_hour;
133 ts = localtime(&ct);
134 m_gmtdiff -= ts->tm_hour;
135
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);
159
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);
171
172 KSeparator *sep0 = new KSeparator(this);
173 sep0->setFixedHeight(10);
174
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);
188
189 connect(m_time, TQ_SIGNAL(activated(int)), TQ_SLOT(slotTimeChanged()));
190}
191
192KPSchedulePage::~KPSchedulePage()
193{
194}
195
196bool KPSchedulePage::isValid(TQString& msg)
197{
198 if (m_time->currentItem() == 8 && !m_tedit->time().isValid())
199 {
200 msg = i18n("The time specified is not valid.");
201 return false;
202 }
203 return true;
204}
205
206void KPSchedulePage::setOptions(const TQMap<TQString,TQString>& opts)
207{
208 TQString t = opts["job-hold-until"];
209 if (!t.isEmpty())
210 {
211 int item(-1);
212
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;
221 else
222 {
223 TQTime qt = TQTime::fromString(t);
224 m_tedit->setTime(qt.addSecs(-3600 * m_gmtdiff));
225 item = 8;
226 }
227
228 if (item != -1)
229 {
230 m_time->setCurrentItem(item);
231 slotTimeChanged();
232 }
233 }
234 TQRegExp re("^\"|\"$");
235 t = opts["job-billing"].stripWhiteSpace();
236 t.replace(re, "");
237 m_billing->setText(t);
238 t = opts["page-label"].stripWhiteSpace();
239 t.replace(re, "");
240 m_pagelabel->setText(t);
241 int val = opts["job-priority"].toInt();
242 if (val != 0)
243 m_priority->setValue(val);
244}
245
246void KPSchedulePage::getOptions(TQMap<TQString,TQString>& opts, bool incldef)
247{
248 if (incldef || m_time->currentItem() != 0)
249 {
250 TQString t;
251 switch (m_time->currentItem())
252 {
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;
261 case 8:
262 t = m_tedit->time().addSecs(3600 * m_gmtdiff).toString();
263 break;
264 }
265 opts["job-hold-until"] = t;
266 }
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());
273}
274
275void KPSchedulePage::slotTimeChanged()
276{
277 m_tedit->setEnabled(m_time->currentItem() == 8);
278 if (m_time->currentItem() == 8)
279 m_tedit->setFocus();
280}
281
282#include "kpschedulepage.moc"
KPrintDialogPage
This class is intended to be used as base class for customized print dialog page.
Definition: kprintdialogpage.h:91

tdeprint

Skip menu "tdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.9.4
This website is maintained by Timothy Pearson.