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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
|
/*
*
* $Id: k3bprojectburndialog.cpp 630454 2007-02-05 13:06:45Z trueg $
* Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
*
* This file is part of the K3b project.
* Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
*
* 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.
* See the file "COPYING" for the exact licensing terms.
*/
#include "k3bprojectburndialog.h"
#include "k3bdoc.h"
#include "k3bburnprogressdialog.h"
#include "k3bjob.h"
#include "k3btempdirselectionwidget.h"
#include "k3bwriterselectionwidget.h"
#include "k3bstdguiitems.h"
#include "k3bwritingmodewidget.h"
#include <k3bdevice.h>
#include <k3bdevicemanager.h>
#include <k3bglobals.h>
#include <k3bcore.h>
#include <tqstring.h>
#include <tqpushbutton.h>
#include <tqtooltip.h>
#include <tqwhatsthis.h>
#include <tqlayout.h>
#include <tqvbox.h>
#include <tqcheckbox.h>
#include <tqtabwidget.h>
#include <tqgroupbox.h>
#include <tqspinbox.h>
#include <tqlabel.h>
#include <tdelocale.h>
#include <tdeconfig.h>
#include <tdemessagebox.h>
#include <kguiitem.h>
#include <kstdguiitem.h>
#include <kdebug.h>
#include <tdeglobal.h>
#include <kstandarddirs.h>
#include <tdeapplication.h>
#include <kiconloader.h>
K3bProjectBurnDialog::K3bProjectBurnDialog( K3bDoc* doc, TQWidget *parent, const char *name, bool modal, bool dvd )
: K3bInteractionDialog( parent, name, i18n("Project"), TQString(),
START_BUTTON|SAVE_BUTTON|CANCEL_BUTTON, START_BUTTON,
"default " + doc->typeString() + " settings", modal ),
m_writerSelectionWidget(0),
m_tempDirSelectionWidget(0),
m_dvd(dvd)
{
m_doc = doc;
/**
* There is at least one scenario in which this is useful: change the volume id (or rename a file)
* without explicit confirmation (by pressing enter for example). Then click the "burn" button.
* The "focus out" event which results in a rename in the listviewitem will be processed after the
* initialization of the burn dialog. Thus, the burn dialog will read the old volume id.
*/
setDelayedInitialization( true );
setButtonGui( SAVE_BUTTON,
KStdGuiItem::close() );
setButtonText( SAVE_BUTTON,
i18n("Close"),
i18n("Save Settings and close"),
i18n("Saves the settings to the project and closes the dialog.") );
setButtonGui( CANCEL_BUTTON, KStdGuiItem::cancel() );
setButtonText( CANCEL_BUTTON,
i18n("Cancel"),
i18n("Discard all changes and close"),
i18n("Discards all changes made in the dialog and closes it.") );
m_job = 0;
}
K3bProjectBurnDialog::~K3bProjectBurnDialog(){
}
void K3bProjectBurnDialog::init()
{
readSettings();
// if( !m_writerSelectionWidget->writerDevice() )
// m_checkOnlyCreateImage->setChecked(true);
}
void K3bProjectBurnDialog::slotWriterChanged()
{
slotToggleAll();
}
void K3bProjectBurnDialog::slotWritingAppChanged( int )
{
slotToggleAll();
}
void K3bProjectBurnDialog::toggleAll()
{
K3bDevice::Device* dev = m_writerSelectionWidget->writerDevice();
if( dev ) {
if( m_dvd ) {
if( (dev->type() & (K3bDevice::DVDPR|K3bDevice::DVDPRW)) &&
!(dev->type() & (K3bDevice::DVDR|K3bDevice::DVDRW)) ) {
// no simulation support for DVD+R(W) only drives
m_checkSimulate->setChecked(false);
m_checkSimulate->setEnabled(false);
}
else {
m_checkSimulate->setEnabled(true);
}
}
setButtonEnabled( START_BUTTON, true );
}
else
setButtonEnabled( START_BUTTON, false );
m_writingModeWidget->determineSupportedModesFromMedium( dev );
m_writingModeWidget->setDisabled( m_checkOnlyCreateImage->isChecked() );
m_checkSimulate->setDisabled( m_checkOnlyCreateImage->isChecked() );
m_checkCacheImage->setDisabled( m_checkOnlyCreateImage->isChecked() );
m_checkRemoveBufferFiles->setDisabled( m_checkOnlyCreateImage->isChecked() || !m_checkCacheImage->isChecked() );
if( m_checkOnlyCreateImage->isChecked() ) {
m_checkRemoveBufferFiles->setChecked(false);
setButtonEnabled( START_BUTTON, true );
}
m_tempDirSelectionWidget->setDisabled( !m_checkCacheImage->isChecked() && !m_checkOnlyCreateImage->isChecked() );
m_writerSelectionWidget->setDisabled( m_checkOnlyCreateImage->isChecked() );
m_spinCopies->setDisabled( m_checkSimulate->isChecked() || m_checkOnlyCreateImage->isChecked() );
if( !m_dvd ) {
// we only support DAO with cdrdao
if( m_writerSelectionWidget->writingApp() == K3b::CDRDAO )
m_writingModeWidget->setSupportedModes( K3b::DAO );
}
if( m_checkOnlyCreateImage->isChecked() )
setButtonText( START_BUTTON,
i18n("Start"),
i18n("Start the image creation") );
else
setButtonText( START_BUTTON, i18n("Burn"),
i18n("Start the burning process") );
}
int K3bProjectBurnDialog::execBurnDialog( bool burn )
{
if( burn && m_job == 0 ) {
setButtonShown( START_BUTTON, true );
setDefaultButton( START_BUTTON );
}
else {
setButtonShown( START_BUTTON, false );
setDefaultButton( SAVE_BUTTON );
}
return K3bInteractionDialog::exec(false);
}
void K3bProjectBurnDialog::slotSaveClicked()
{
saveSettings();
done( Saved );
}
void K3bProjectBurnDialog::slotCancelClicked()
{
done( Canceled );
}
void K3bProjectBurnDialog::slotStartClicked()
{
saveSettings();
if( m_tempDirSelectionWidget ) {
if( !doc()->onTheFly() || doc()->onlyCreateImages() ) {
//
// check if the temp dir exists
//
TQString tempDir = m_tempDirSelectionWidget->tempDirectory();
if( !TQFile::exists( tempDir ) ) {
if( KMessageBox::warningYesNo( this, i18n("Image folder '%1' does not exist. Do you want K3b to create it?").arg( tempDir ) )
== KMessageBox::Yes ) {
if( !TDEStandardDirs::makeDir( tempDir ) ) {
KMessageBox::error( this, i18n("Failed to create folder '%1'.").arg( tempDir ) );
return;
}
}
else
return;
}
//
// check if enough space in tempdir if not on-the-fly
//
if( doc()->size()/1024 > m_tempDirSelectionWidget->freeTempSpace() ) {
if( KMessageBox::warningContinueCancel( this, i18n("There seems to be not enough free space in temporary directory. "
"Write anyway?") ) == KMessageBox::Cancel )
return;
}
}
}
K3bJobProgressDialog* dlg = 0;
if( m_checkOnlyCreateImage && m_checkOnlyCreateImage->isChecked() )
dlg = new K3bJobProgressDialog( parentWidget() );
else
dlg = new K3bBurnProgressDialog( parentWidget() );
m_job = m_doc->newBurnJob( dlg );
if( m_writerSelectionWidget )
m_job->setWritingApp( m_writerSelectionWidget->writingApp() );
prepareJob( m_job );
if( !exitLoopOnHide() )
hide();
dlg->startJob(m_job);
kdDebug() << "(K3bProjectBurnDialog) job done. cleaning up." << endl;
delete m_job;
m_job = 0;
delete dlg;
done( Burn );
}
void K3bProjectBurnDialog::prepareGui()
{
TQVBoxLayout* mainLay = new TQVBoxLayout( mainWidget() );
mainLay->setAutoAdd( true );
mainLay->setMargin( 0 );
mainLay->setSpacing( KDialog::spacingHint() );
m_writerSelectionWidget = new K3bWriterSelectionWidget( mainWidget() );
m_writerSelectionWidget->setWantedMediumType( m_dvd ? K3bDevice::MEDIA_WRITABLE_DVD : K3bDevice::MEDIA_WRITABLE_CD );
m_writerSelectionWidget->setWantedMediumState( K3bDevice::STATE_EMPTY );
m_tabWidget = new TQTabWidget( mainWidget() );
TQWidget* w = new TQWidget( m_tabWidget );
m_tabWidget->addTab( w, i18n("Writing") );
TQGroupBox* groupWritingMode = new TQGroupBox( 1, Qt::Vertical, i18n("Writing Mode"), w );
groupWritingMode->setInsideMargin( marginHint() );
m_writingModeWidget = new K3bWritingModeWidget( groupWritingMode );
m_optionGroup = new TQGroupBox( 0, Qt::Vertical, i18n("Settings"), w );
m_optionGroup->layout()->setMargin(0);
m_optionGroup->layout()->setSpacing(0);
m_optionGroupLayout = new TQVBoxLayout( m_optionGroup->layout() );
m_optionGroupLayout->setMargin( KDialog::marginHint() );
m_optionGroupLayout->setSpacing( KDialog::spacingHint() );
// add the options
m_checkCacheImage = K3bStdGuiItems::createCacheImageCheckbox( m_optionGroup );
m_checkSimulate = K3bStdGuiItems::simulateCheckbox( m_optionGroup );
m_checkRemoveBufferFiles = K3bStdGuiItems::removeImagesCheckbox( m_optionGroup );
m_checkOnlyCreateImage = K3bStdGuiItems::onlyCreateImagesCheckbox( m_optionGroup );
m_optionGroupLayout->addWidget(m_checkSimulate);
m_optionGroupLayout->addWidget(m_checkCacheImage);
m_optionGroupLayout->addWidget(m_checkOnlyCreateImage);
m_optionGroupLayout->addWidget(m_checkRemoveBufferFiles);
TQGroupBox* groupCopies = new TQGroupBox( 2, Qt::Horizontal, i18n("Copies"), w );
groupCopies->setInsideSpacing( spacingHint() );
groupCopies->setInsideMargin( marginHint() );
TQLabel* pixLabel = new TQLabel( groupCopies );
pixLabel->setPixmap( SmallIcon( "cdcopy", TDEIcon::SizeMedium ) );
pixLabel->setScaledContents( false );
m_spinCopies = new TQSpinBox( 1, 999, 1, groupCopies );
// arrange it
TQGridLayout* grid = new TQGridLayout( w );
grid->setMargin( KDialog::marginHint() );
grid->setSpacing( KDialog::spacingHint() );
grid->addWidget( groupWritingMode, 0, 0 );
grid->addMultiCellWidget( m_optionGroup, 0, 2, 1, 1 );
grid->addWidget( groupCopies, 2, 0 );
// grid->addMultiCellWidget( m_tempDirSelectionWidget, 1, 3, 1, 1 );
grid->setRowStretch( 1, 1 );
grid->setColStretch( 1, 1 );
TQWidget* tempW = new TQWidget( m_tabWidget );
grid = new TQGridLayout( tempW );
grid->setMargin( KDialog::marginHint() );
grid->setSpacing( KDialog::spacingHint() );
m_tabWidget->addTab( tempW, i18n("Image") );
m_tempDirSelectionWidget = new K3bTempDirSelectionWidget( tempW );
grid->addWidget( m_tempDirSelectionWidget, 0, 0 );
m_tempDirSelectionWidget->setNeededSize( doc()->size() );
// tab order
setTabOrder( m_writerSelectionWidget, m_writingModeWidget );
setTabOrder( m_writingModeWidget, groupCopies );
setTabOrder( groupCopies, m_optionGroup );
// some default connections that should always be useful
connect( m_writerSelectionWidget, TQT_SIGNAL(writerChanged()), this, TQT_SLOT(slotWriterChanged()) );
connect( m_writerSelectionWidget, TQT_SIGNAL(writerChanged(K3bDevice::Device*)),
m_writingModeWidget, TQT_SLOT(determineSupportedModesFromMedium(K3bDevice::Device*)) );
connect( m_writerSelectionWidget, TQT_SIGNAL(writingAppChanged(int)), this, TQT_SLOT(slotWritingAppChanged(int)) );
connect( m_checkCacheImage, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotToggleAll()) );
connect( m_checkSimulate, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotToggleAll()) );
connect( m_checkOnlyCreateImage, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotToggleAll()) );
connect( m_writingModeWidget, TQT_SIGNAL(writingModeChanged(int)), this, TQT_SLOT(slotToggleAll()) );
}
void K3bProjectBurnDialog::addPage( TQWidget* page, const TQString& title )
{
m_tabWidget->addTab( page, title );
}
void K3bProjectBurnDialog::saveSettings()
{
m_doc->setDummy( m_checkSimulate->isChecked() );
m_doc->setOnTheFly( !m_checkCacheImage->isChecked() );
m_doc->setOnlyCreateImages( m_checkOnlyCreateImage->isChecked() );
m_doc->setRemoveImages( m_checkRemoveBufferFiles->isChecked() );
m_doc->setSpeed( m_writerSelectionWidget->writerSpeed() );
m_doc->setBurner( m_writerSelectionWidget->writerDevice() );
m_doc->setWritingMode( m_writingModeWidget->writingMode() );
m_doc->setWritingApp( m_writerSelectionWidget->writingApp() );
m_doc->setCopies( m_spinCopies->value() );
}
void K3bProjectBurnDialog::readSettings()
{
m_checkSimulate->setChecked( doc()->dummy() );
m_checkCacheImage->setChecked( !doc()->onTheFly() );
m_checkOnlyCreateImage->setChecked( m_doc->onlyCreateImages() );
m_checkRemoveBufferFiles->setChecked( m_doc->removeImages() );
m_writingModeWidget->setWritingMode( doc()->writingMode() );
m_writerSelectionWidget->setWriterDevice( doc()->burner() );
m_writerSelectionWidget->setSpeed( doc()->speed() );
m_writerSelectionWidget->setWritingApp( doc()->writingApp() );
m_spinCopies->setValue( m_doc->copies() );
}
void K3bProjectBurnDialog::saveUserDefaults( TDEConfigBase* c )
{
m_writingModeWidget->saveConfig( c );
c->writeEntry( "simulate", m_checkSimulate->isChecked() );
c->writeEntry( "on_the_fly", !m_checkCacheImage->isChecked() );
c->writeEntry( "remove_image", m_checkRemoveBufferFiles->isChecked() );
c->writeEntry( "only_create_image", m_checkOnlyCreateImage->isChecked() );
c->writeEntry( "copies", m_spinCopies->value() );
m_tempDirSelectionWidget->saveConfig( c );
m_writerSelectionWidget->saveConfig( c );
}
void K3bProjectBurnDialog::loadUserDefaults( TDEConfigBase* c )
{
m_writingModeWidget->loadConfig( c );
m_checkSimulate->setChecked( c->readBoolEntry( "simulate", false ) );
m_checkCacheImage->setChecked( !c->readBoolEntry( "on_the_fly", true ) );
m_checkRemoveBufferFiles->setChecked( c->readBoolEntry( "remove_image", true ) );
m_checkOnlyCreateImage->setChecked( c->readBoolEntry( "only_create_image", false ) );
m_spinCopies->setValue( c->readNumEntry( "copies", 1 ) );
m_tempDirSelectionWidget->readConfig( c );
m_writerSelectionWidget->loadConfig( c );
}
void K3bProjectBurnDialog::loadK3bDefaults()
{
m_writerSelectionWidget->loadDefaults();
m_writingModeWidget->setWritingMode( K3b::WRITING_MODE_AUTO );
m_checkSimulate->setChecked( false );
m_checkCacheImage->setChecked( false );
m_checkRemoveBufferFiles->setChecked( true );
m_checkOnlyCreateImage->setChecked( false );
m_spinCopies->setValue( 1 );
if( m_tempDirSelectionWidget->selectionMode() == K3bTempDirSelectionWidget::DIR )
m_tempDirSelectionWidget->setTempPath( K3b::defaultTempPath() );
else
m_tempDirSelectionWidget->setTempPath( K3b::defaultTempPath() + doc()->name() + ".iso" );
}
#include "k3bprojectburndialog.moc"
|