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

tdeprint

  • tdeprint
  • management
kmwbackend.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 "kmwbackend.h"
21 #include "kmwizard.h"
22 #include "kmprinter.h"
23 
24 #include <tqlayout.h>
25 #include <tqregexp.h>
26 #include <tqbuttongroup.h>
27 #include <tqradiobutton.h>
28 #include <tqwhatsthis.h>
29 
30 #include <kcursor.h>
31 #include <tdelocale.h>
32 #include <kseparator.h>
33 #include <kdialog.h>
34 #include <kdebug.h>
35 
36 class TDERadioButton : public TQRadioButton
37 {
38 public:
39  TDERadioButton(const TQString& txt, TQWidget *parent = 0, const char *name = 0);
40 };
41 
42 TDERadioButton::TDERadioButton(const TQString& txt, TQWidget *parent, const char *name)
43 : TQRadioButton(txt,parent,name)
44 {
45  setCursor(KCursor::handCursor());
46 }
47 
48 //********************************************************************************************************
49 
50 KMWBackend::KMWBackend(TQWidget *parent, const char *name)
51 : KMWizardPage(parent,name)
52 {
53  m_ID = KMWizard::Backend;
54  m_title = i18n("Backend Selection");
55 
56  m_buttons = new TQButtonGroup(this);
57  m_buttons->hide();
58 
59  m_layout = new TQVBoxLayout(this, 0, KDialog::spacingHint());
60  m_layout->addStretch(1);
61  m_count = 0;
62 }
63 
64 bool KMWBackend::isValid(TQString& msg)
65 {
66  if (!m_buttons->selected())
67  {
68  msg = i18n("You must select a backend.");
69  return false;
70  }
71  return true;
72 }
73 
74 void KMWBackend::initPrinter(KMPrinter *p)
75 {
76  TQString s = p->option("kde-backend");
77  int ID(-1);
78 
79  if (!s.isEmpty())
80  ID = s.toInt();
81  else
82  {
83  s = p->deviceProtocol();
84  // extract protocol
85  if (s == "parallel" || s == "serial" || s == "usb") ID = KMWizard::Local;
86  else if (s == "smb") ID = KMWizard::SMB;
87  else if (s == "ipp" || s == "http") ID = KMWizard::IPP;
88  else if (s == "lpd") ID = KMWizard::LPD;
89  else if (s == "socket") ID = KMWizard::TCP;
90  else if (s == "file") ID = KMWizard::File;
91  else if (p->members().count() > 0) ID = KMWizard::Class;
92  }
93 
94  if (m_buttons->find(ID))
95  m_buttons->setButton(ID);
96 }
97 
98 void KMWBackend::updatePrinter(KMPrinter *p)
99 {
100  int ID = m_buttons->id(m_buttons->selected());
101  if (ID == KMWizard::Class) p->setType(KMPrinter::Class);
102  else p->setType(KMPrinter::Printer);
103  p->setOption("kde-backend",TQString::number(ID));
104  TQString s = m_buttons->selected()->text();
105  s.replace(TQRegExp("&(?=\\w)"), TQString::fromLatin1(""));
106  p->setOption("kde-backend-description",s);
107  setNextPage((m_map.contains(ID) ? m_map[ID] : KMWizard::Error));
108 }
109 
110 void KMWBackend::addBackend( int ID, bool on, int nextpage )
111 {
112  switch ( ID )
113  {
114  case KMWizard::Local:
115  addBackend( ID, i18n("&Local printer (parallel, serial, USB)"), on,
116  i18n( "<qt><p>Locally-connected printer</p>"
117  "<p>Use this for a printer connected "
118  "to the computer via a parallel, serial or USB port.</p></qt>" ),
119  nextpage );
120  break;
121  case KMWizard::SMB:
122  addBackend( ID, i18n("&SMB shared printer (Windows)"), on,
123  i18n( "<qt><p>Shared Windows printer</p>"
124  "<p>Use this for a printer installed "
125  "on a Windows server and shared on the network using the SMB "
126  "protocol (samba).</p></qt>" ),
127  nextpage );
128  break;
129  case KMWizard::LPD:
130  addBackend( ID, i18n("&Remote LPD queue"), on,
131  i18n( "<qt><p>Print queue on a remote LPD server</p>"
132  "<p>Use this for a print queue "
133  "existing on a remote machine running a LPD print server.</p></qt>" ),
134  nextpage );
135  break;
136  case KMWizard::TCP:
137  addBackend( ID, i18n("Ne&twork printer (TCP)"), on,
138  i18n( "<qt><p>Network TCP printer</p>"
139  "<p>Use this for a network-enabled printer "
140  "using TCP (usually on port 9100) as communication protocol. Most "
141  "network printers can use this mode.</p></qt>" ),
142  nextpage );
143  break;
144  case -1:
145  addBackend( ID, TQString::null, on, TQString::null, nextpage );
146  break;
147  default:
148  kdError( 500 ) << "Non standard wizard page ID: " << ID << endl;
149  }
150 }
151 
152 void KMWBackend::addBackend(int ID, const TQString& txt, bool on, const TQString& whatsThis, int nextpage)
153 {
154  if (ID == -1)
155  {
156  KSeparator* sep = new KSeparator( KSeparator::HLine, this);
157  m_layout->insertWidget(m_count, sep);
158  }
159  else
160  {
161  TDERadioButton *btn = new TDERadioButton(txt, this);
162  btn->setEnabled(on);
163  if ( !whatsThis.isEmpty() )
164  TQWhatsThis::add( btn, whatsThis );
165  m_buttons->insert(btn, ID);
166  m_map[ID] = (nextpage == -1 ? ID : nextpage); // use nextpage if specified, default to ID
167  m_layout->insertWidget(m_count, btn);
168  }
169  m_count++;
170 }
171 
172 void KMWBackend::enableBackend(int ID, bool on)
173 {
174  TQButton *btn = static_cast<TQButton*>(m_buttons->find(ID));
175  if (btn)
176  btn->setEnabled(on);
177 }

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.1
This website is maintained by Timothy Pearson.