1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
/***************************************************************************
smb4kprintdialog - The print dialog for Smb4K
-------------------
begin : So Apr 11 2004
copyright : (C) 2004-2007 by Alexander Reinholdt
email : dustpuppy@users.berlios.de
***************************************************************************/
/***************************************************************************
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301 USA *
***************************************************************************/
// TQt includes
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqframe.h>
// KDE includes
#include <tdelocale.h>
#include <tdemessagebox.h>
#include <kurlrequester.h>
#include <knuminput.h>
#include <kdebug.h>
// application specific includes
#include "smb4kprintdialog.h"
#include "../core/smb4kprintinfo.h"
#include "../core/smb4kcore.h"
#include "../core/smb4knetworkitems.h"
Smb4KPrintDialog::Smb4KPrintDialog( Smb4KShareItem *item, TQWidget *parent, const char *name )
: KDialogBase( Plain, i18n( "Print File" ), Details|Filler|User1|Cancel, User1, parent, name, true, true ),
m_item( item ), m_ip( TQString() ) /* will collect it in an instant */
{
setWFlags( TQt::WDestructiveClose );
if ( !m_item )
{
close();
}
setButtonGuiItem( User1, KStdGuiItem::print() );
setButtonText( Details, i18n( "Options" ) );
// Get the IP address
if ( Smb4KHostItem *host = Smb4KCore::scanner()->getHost( m_item->host(), m_item->workgroup() ) )
{
m_ip = host->ip();
}
// Bild the view:
TQFrame *frame = plainPage();
TQGridLayout *layout = new TQGridLayout( frame );
layout->setSpacing( 10 );
TQGroupBox *p = new TQGroupBox( 2, Qt::Horizontal, i18n( "Printer" ), frame );
p->setInsideSpacing( 5 );
(void) new TQLabel( i18n( "Name:" ), p );
(void) new TQLabel( m_item->name()+
(!m_item->comment().stripWhiteSpace().isEmpty() ?
" ("+m_item->comment()+")" :
""), p );
// (void) new TQLabel( i18n( "Comment:" ), p );
// (void) new TQLabel( m_item->comment(), p );
(void) new TQLabel( i18n( "Host:" ), p );
(void) new TQLabel( m_item->host(), p );
(void) new TQLabel( i18n( "IP address:" ), p );
(void) new TQLabel( m_ip.stripWhiteSpace().isEmpty() ?
i18n( "Unknown" ) :
m_ip,
p );
(void) new TQLabel( i18n( "Workgroup:" ), p );
(void) new TQLabel( m_item->workgroup(), p );
TQGroupBox *f = new TQGroupBox( 2, Qt::Horizontal, i18n( "File" ), frame );
f->setInsideSpacing( 5 );
(void) new TQLabel( i18n( "File:" ), f );
KURLRequester *requester = new KURLRequester( TQString(), f, "URL" );
requester->setMode( KFile::File | KFile::LocalOnly );
TQGroupBox *s = new TQGroupBox( 2, Qt::Horizontal, i18n( "Options" ), frame );
s->setInsideSpacing( 5 );
setDetailsWidget( s );
(void) new TQLabel( i18n( "Copies:" ), s );
KIntNumInput *cp = new KIntNumInput( 1, s, 10, "Copies" );
cp->setMinValue( 1 );
layout->addWidget( p, 0, 0, 0 );
layout->addWidget( f, 1, 0, 0 );
setFixedSize( (sizeHint().width() > 350 ? sizeHint().width() : 350), sizeHint().height() );
enableButton( User1, false );
connect( requester, TQT_SIGNAL( textChanged( const TQString & ) ),
this, TQT_SLOT( slotInputValueChanged( const TQString & ) ) );
}
Smb4KPrintDialog::~ Smb4KPrintDialog()
{
// Do not delete the pointer to the Smb4KShareObject here!
}
/////////////////////////////////////////////////////////////////////////////
// TQT_SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KPrintDialog::slotUser1()
{
KURLRequester *url = static_cast<KURLRequester *>( TQT_TQWIDGET(child( "URL", "KURLRequester", true )) );
KIntNumInput *copies = static_cast<KIntNumInput *>( TQT_TQWIDGET(child( "Copies", "KIntNumInput", true )) );
if ( url && copies )
{
if ( !url->url().stripWhiteSpace().isEmpty() )
{
if ( Smb4KCore::print()->print( new Smb4KPrintInfo( m_item, m_ip, url->url().stripWhiteSpace(), copies->value() ) ) )
{
enableButton( User1, false );
connect( Smb4KCore::print(), TQT_SIGNAL( state( int ) ), this, TQT_SLOT( slotPrintStateChanged( int ) ) );
}
else
{
// FIXME: Should we report an error here?
}
}
else
{
KMessageBox::error( this, i18n( "You haven't specified a file." ) );
}
}
}
void Smb4KPrintDialog::slotCancel()
{
if ( Smb4KCore::printIsRunning() )
{
Smb4KCore::print()->abort();
}
KDialogBase::slotCancel();
}
void Smb4KPrintDialog::slotPrintStateChanged( int state )
{
switch ( state )
{
case PRINT_STOP:
{
accept();
break;
}
default:
{
break;
}
}
}
void Smb4KPrintDialog::slotInputValueChanged( const TQString &text )
{
enableButton( User1, !text.isEmpty() );
}
#include "smb4kprintdialog.moc"
|