21 #include "kmwizardpage.h"
22 #include "kmprinter.h"
23 #include "kmfactory.h"
24 #include "kmuimanager.h"
26 #include <kpushbutton.h>
28 #include <tqwidgetstack.h>
29 #include <tdemessagebox.h>
31 #include <tdelocale.h>
33 #include <kseparator.h>
34 #include <tdeapplication.h>
35 #include <kstdguiitem.h>
37 #include "kmwinfopage.h"
38 #include "kmwpassword.h"
39 #include "kmwbackend.h"
40 #include "kmwsocket.h"
41 #include "kmwdriver.h"
42 #include "kmwdriverselect.h"
43 #include "kmwdrivertest.h"
51 #include "sidepixmap.h"
53 KMWizard::KMWizard(TQWidget *parent,
const char *name)
54 : TQDialog(parent,name,true)
56 m_start = KMWizard::Start;
57 m_end = KMWizard::End;
59 m_printer =
new KMPrinter();
61 m_pagepool.setAutoDelete(
false);
63 m_stack =
new TQWidgetStack(
this);
64 m_next =
new KPushButton(i18n(
"&Next >"),
this);
65 m_next->setDefault(
true);
66 m_prev =
new KPushButton(i18n(
"< &Back"),
this);
67 TQPushButton *m_cancel =
new KPushButton(KStdGuiItem::cancel(),
this);
68 m_title =
new TQLabel(
this);
69 TQFont f(m_title->font());
72 KSeparator* sep =
new KSeparator( KSeparator::HLine,
this);
73 sep->setFixedHeight(5);
74 KSeparator* sep2 =
new KSeparator( KSeparator::HLine,
this);
75 TQPushButton *m_help =
new KPushButton(KStdGuiItem::help(),
this);
77 connect(m_cancel,TQ_SIGNAL(clicked()),TQ_SLOT(reject()));
78 connect(m_next,TQ_SIGNAL(clicked()),TQ_SLOT(slotNext()));
79 connect(m_prev,TQ_SIGNAL(clicked()),TQ_SLOT(slotPrev()));
80 connect(m_help, TQ_SIGNAL(clicked()), TQ_SLOT(slotHelp()));
82 m_side =
new SidePixmap(
this);
83 if (!m_side->isValid())
90 TQVBoxLayout *main0_ =
new TQVBoxLayout(
this, 10, 10);
91 TQVBoxLayout *main_ =
new TQVBoxLayout(0, 0, 0);
92 TQHBoxLayout *main1_ =
new TQHBoxLayout(0, 0, 10);
93 TQHBoxLayout *btn_ =
new TQHBoxLayout(0, 0, 10);
94 main0_->addLayout(main1_);
96 main1_->addWidget(m_side);
97 main1_->addLayout(main_);
98 main_->addWidget(m_title);
99 main_->addWidget(sep);
100 main_->addSpacing(10);
101 main_->addWidget(m_stack,1);
102 main0_->addWidget(sep2);
103 main0_->addLayout(btn_);
104 btn_->addWidget(m_help);
106 btn_->addWidget(m_prev);
107 btn_->addWidget(m_next);
108 btn_->addWidget(m_cancel);
111 addPage(
new KMWInfoPage(
this));
112 m_backend =
new KMWBackend(
this);
114 addPage(
new KMWPassword(
this));
115 addPage(
new KMWSocket(
this));
116 addPage(
new KMWDriver(
this));
117 addPage(
new KMWDriverSelect(
this));
118 addPage(
new KMWDriverTest(
this));
119 addPage(
new KMWName(
this));
120 addPage(
new KMWEnd(
this));
121 addPage(
new KMWClass(
this));
122 addPage(
new KMWLpd(
this));
123 addPage(
new KMWFile(
this));
124 addPage(
new KMWSmb(
this));
125 addPage(
new KMWLocal(
this));
128 KMFactory::self()->uiManager()->setupWizard(
this);
130 setCurrentPage(m_start,
false);
131 setCaption(i18n(
"Add Printer Wizard"));
135 KMWizard::~KMWizard()
140 void KMWizard::addPage(KMWizardPage *page)
142 m_stack->addWidget(page,page->id());
143 m_pagepool.insert(page->id(),page);
146 void KMWizard::setPrinter(KMPrinter *p)
151 KMWizardPage *page = (KMWizardPage*)m_stack->visibleWidget();
153 page->initPrinter(m_printer);
157 void KMWizard::configure(
int start,
int end,
bool inclusive)
161 m_inclusive = inclusive;
165 m_backend->enableBackend(KMWizard::Class,(m_start == KMWizard::Start));
166 setCaption((m_start == KMWizard::Start ? i18n(
"Add Printer Wizard") : i18n(
"Modify Printer")));
170 if (start == KMWizard::Start && end == KMWizard::End)
176 setCurrentPage(m_start,
false);
179 void KMWizard::setNextPage(
int page,
int next)
181 KMWizardPage *p = m_pagepool.find(page);
183 p->setNextPage(next);
186 void KMWizard::setCurrentPage(
int ID,
bool back)
188 KMWizardPage *page = m_pagepool.find(ID);
191 KMessageBox::error(
this,i18n(
"Unable to find the requested page."),i18n(
"Add Printer Wizard"));
196 if (!back) m_pagestack.push(ID);
199 m_stack->raiseWidget(page);
200 m_title->setText(page->title());
201 if (!back || page->needsInitOnBack()) page->initPrinter(m_printer);
204 if (ID == m_start) m_prev->setEnabled(
false);
205 else m_prev->setEnabled(
true);
206 if ((m_inclusive && ID == m_end) || (!m_inclusive && page->nextPage() == m_end))
207 m_next->setText(i18n(
"&Finish"));
209 m_next->setText(i18n(
"&Next >"));
212 void KMWizard::slotPrev()
216 int ID = m_pagestack.top();
217 setCurrentPage(ID,
true);
220 void KMWizard::slotNext()
222 KMWizardPage *page = (KMWizardPage*)m_stack->visibleWidget();
226 if (!page->isValid(msg))
229 KMessageBox::error(
this,msg.prepend(
"<qt>").append(
"</qt>"),page->title());
233 page->updatePrinter(m_printer);
234 if (m_next->text() == i18n(
"&Finish"))
238 int ID = page->nextPage();
239 setCurrentPage(ID,
false);
245 void KMWizard::slotHelp()
247 kapp->invokeHelp(TQString::null,
"tdeprint");
250 void KMWizard::enableWizard()
252 m_next->setEnabled(
true );
253 m_prev->setEnabled( m_pagestack.top() != m_start );
256 void KMWizard::disableWizard()
258 m_next->setEnabled(
false );
259 m_prev->setEnabled(
false );
262 #include "kmwizard.moc"