22 #include "kmprinter.h"
25 #include <tqlineedit.h>
26 #include <tdelocale.h>
27 #include <tdemessagebox.h>
30 KMWName::KMWName(TQWidget *parent,
const char *name)
31 : KMWInfoBase(3,parent,name)
33 m_ID = KMWizard::Name;
34 m_title = i18n(
"General Information");
35 m_nextpage = KMWizard::End;
37 setInfo(i18n(
"<p>Enter the information concerning your printer or class. <b>Name</b> is mandatory, "
38 "<b>Location</b> and <b>Description</b> are not (they may even not be used on some systems).</p>"));
39 setLabel(0,i18n(
"Name:"));
40 setLabel(1,i18n(
"Location:"));
41 setLabel(2,i18n(
"Description:"));
44 bool KMWName::isValid(TQString& msg)
46 if (text(0).isEmpty())
48 msg = i18n(
"You must supply at least a name.");
51 else if (text(0).find(TQRegExp(
"\\s")) != -1)
53 TQString conv = text(0);
54 conv.replace(TQRegExp(
"\\s"),
"");
55 int result = KMessageBox::warningYesNoCancel(
this,
56 i18n(
"It is usually not a good idea to include spaces "
57 "in printer name: it may prevent your printer from "
58 "working correctly. The wizard can strip all spaces "
59 "from the string you entered, resulting in %1; "
60 "what do you want to do?").arg(conv),
62 i18n(
"Strip"), i18n(
"Keep"));
65 case KMessageBox::Yes:
76 void KMWName::initPrinter(KMPrinter *p)
78 setText(0,p->printerName());
79 setText(1,p->location());
80 setText(2,p->description());
81 if (text(2).isEmpty())
82 if (p->option(
"kde-driver") ==
"raw")
83 setText(2,i18n(
"Raw printer"));
85 setText(2,p->manufacturer() +
" " + p->model());
90 void KMWName::updatePrinter(KMPrinter *p)
92 p->setPrinterName(text(0));
94 p->setLocation(text(1));
95 p->setDescription(text(2));