File indexing completed on 2024-05-05 04:51:48

0001 /*
0002     SPDX-FileCopyrightText: 2003-2004 Christian Kvasny <chris@k3b.org>
0003     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #include "k3bvcdburndialog.h"
0009 #include "k3bvcddoc.h"
0010 #include "k3bvcdoptions.h"
0011 #include "k3bdevice.h"
0012 #include "k3bcore.h"
0013 #include "k3bwriterselectionwidget.h"
0014 #include "k3btempdirselectionwidget.h"
0015 #include "k3bstdguiitems.h"
0016 #include "k3bglobals.h"
0017 #include "k3bwritingmodewidget.h"
0018 #include "k3bexternalbinmanager.h"
0019 #include "k3bvalidators.h"
0020 
0021 #include <KConfig>
0022 #include <KLocalizedString>
0023 #include <KIO/Global>
0024 #include <KMessageBox>
0025 
0026 #include <QDir>
0027 #include <QFileInfo>
0028 #include <QStandardPaths>
0029 #include <QTextStream>
0030 #include <QButtonGroup>
0031 #include <QCheckBox>
0032 #include <QFrame>
0033 #include <QGroupBox>
0034 #include <QGridLayout>
0035 #include <QLabel>
0036 #include <QLayout>
0037 #include <QLineEdit>
0038 #include <QRadioButton>
0039 #include <QSpinBox>
0040 #include <QTextEdit>
0041 #include <QToolButton>
0042 #include <QToolTip>
0043 
0044 K3b::VcdBurnDialog::VcdBurnDialog( K3b::VcdDoc* _doc, QWidget *parent )
0045     : K3b::ProjectBurnDialog( _doc, parent )
0046 {
0047     m_vcdDoc = _doc;
0048 
0049     prepareGui();
0050 
0051     QString vcdType;
0052     switch (m_vcdDoc->vcdType()) {
0053     case K3b::VcdDoc::VCD11:
0054         vcdType = i18n("Video CD (Version 1.1)");
0055         break;
0056     case K3b::VcdDoc::VCD20:
0057         vcdType = i18n("Video CD (Version 2.0)");
0058         break;
0059     case K3b::VcdDoc::SVCD10:
0060         vcdType = i18n("Super Video CD");
0061         break;
0062     case K3b::VcdDoc::HQVCD:
0063         vcdType = i18n("High-Quality Video CD");
0064         break;
0065     default:
0066         vcdType = i18n("Video CD");
0067     }
0068 
0069     setTitle( vcdType, i18np( "1 MPEG (%2)", "%1 MPEGs (%2)",
0070                               m_vcdDoc->tracks() ->count() , KIO::convertSize( m_vcdDoc->size() ) ) );
0071 
0072     const K3b::ExternalBin* cdrecordBin = k3bcore->externalBinManager() ->binObject( "cdrecord" );
0073     if ( cdrecordBin && cdrecordBin->hasFeature( "cuefile" ) )
0074         m_writerSelectionWidget->setSupportedWritingApps( K3b::WritingAppCdrdao | K3b::WritingAppCdrecord );
0075     else
0076         m_writerSelectionWidget->setSupportedWritingApps( K3b::WritingAppCdrdao );
0077 
0078     m_checkCacheImage->hide();
0079 
0080     QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
0081     m_optionGroupLayout->addItem( spacer );
0082 
0083     setupVideoCdTab();
0084     setupLabelTab();
0085     setupAdvancedTab();
0086 
0087     connect( m_spinVolumeCount, SIGNAL(valueChanged(int)), this, SLOT(slotSpinVolumeCount()) );
0088     connect( m_buttonGroupVcdFormat, SIGNAL(buttonClicked(int)), this, SLOT(slotVcdTypeClicked(int)) );
0089     connect( m_checkCdiSupport, SIGNAL(toggled(bool)), this, SLOT(slotCdiSupportChecked(bool)) );
0090     connect( m_checkAutoDetect, SIGNAL(toggled(bool)), this, SLOT(slotAutoDetect(bool)) );
0091     connect( m_checkGaps, SIGNAL(toggled(bool)), this, SLOT(slotGapsChecked(bool)) );
0092 
0093     // ToolTips
0094     // -------------------------------------------------------------------------
0095     m_radioVcd11->setToolTip( i18n( "Select Video CD type %1", QString("(VCD 1.1)") ) );
0096     m_radioVcd20->setToolTip( i18n( "Select Video CD type %1" , QString("(VCD 2.0)" )) );
0097     m_radioSvcd10->setToolTip( i18n( "Select Video CD type %1" , QString("(SVCD 1.0)" )) );
0098     m_radioHqVcd10->setToolTip( i18n( "Select Video CD type %1" , QString("(HQ-VCD 1.0)" )) );
0099     m_checkAutoDetect->setToolTip( i18n( "Automatic video type recognition." ) );
0100     m_checkNonCompliant->setToolTip( i18n( "Non-compliant compatibility mode for broken devices" ) );
0101     m_checkVCD30interpretation->setToolTip( i18n( "Chinese VCD3.0 track interpretation" ) );
0102     m_check2336->setToolTip( i18n( "Use 2336 byte sectors for output" ) );
0103 
0104     m_editVolumeId->setToolTip( i18n( "Specify ISO volume label for Video CD" ) );
0105     m_editAlbumId->setToolTip( i18n( "Specify album id for Video CD set" ) );
0106     m_spinVolumeNumber->setToolTip( i18n( "Specify album set sequence number ( <= volume-count )" ) );
0107     m_spinVolumeCount->setToolTip( i18n( "Specify number of volumes in album set" ) );
0108     m_checkCdiSupport->setToolTip( i18n( "Enable CD-i Application Support for Video CD Type 1.1 & 2.0" ) );
0109     m_editCdiCfg->setToolTip( i18n( "Configuration parameters (only for VCD 2.0)" ) );
0110 
0111     m_checkPbc->setToolTip( i18n( "Playback control, PBC, is available for Video CD 2.0 and Super Video CD 1.0 disc formats." ) );
0112     m_checkSegmentFolder->setToolTip( i18n( "Add always an empty `/SEGMENT' folder" ) );
0113     m_checkRelaxedAps->setToolTip( i18n( "This controls whether APS constraints are strict or relaxed. " ) );
0114     m_checkUpdateScanOffsets->setToolTip( i18n( "This controls whether to update the scan data information contained in the MPEG-2 video streams." ) );
0115     m_labelRestriction->setToolTip( i18n( "This element allows one to set viewing restrictions which may be interpreted by the playing device." ) );
0116 
0117     m_checkGaps->setToolTip( i18n( "This option allows customization of Gaps and Margins." ) );
0118     m_labelPreGapLeadout->setToolTip( i18n( "Used to set the number of empty sectors added before the lead-out area begins." ) );
0119     m_labelPreGapTrack->setToolTip( i18n( "Used to set the track pre-gap for all tracks in sectors globally." ) );
0120     m_labelFrontMarginTrack->setToolTip( i18n( "Sets the front margin for sequence items." ) );
0121     m_labelRearMarginTrack->setToolTip( i18n( "Sets the rear margin for sequence items." ) );
0122 
0123     // What's This info
0124     // -------------------------------------------------------------------------
0125     m_radioVcd11->setWhatsThis( i18n( "<p>This is the most basic <b>Video CD</b> specification dating back to 1993, which has the following characteristics:"
0126                                       "<ul><li>One mode2 mixed form ISO 9660 track containing file pointers to the information areas.</li>"
0127                                       "<li>Up to 98 multiplex-ed MPEG-1 audio/video streams or CD-DA audio tracks.</li>"
0128                                       "<li>Up to 500 MPEG sequence entry points used as chapter divisions.</li></ul>"
0129                                       "<p>The Video CD specification requires the multiplex-ed MPEG-1 stream to have a CBR of less than 174300 bytes (1394400 bits) per second in order to accommodate single speed CD-ROM drives.<br>"
0130                                       "The specification allows for the following two resolutions:"
0131                                       "<ul><li>352 x 240 @ 29.97 Hz (NTSC SIF).</li>"
0132                                       "<li>352 x 240 @ 23.976 Hz (FILM SIF).</li></ul>"
0133                                       "<p>The CBR MPEG-1, layer II audio stream is fixed at 224 kbps with 1 stereo or 2 mono channels."
0134                                       "<p><b>It is recommended to keep the video bit-rate under 1151929.1 bps.</b>" ) );
0135 
0136     m_radioVcd20->setWhatsThis( i18n( "<p>About two years after the Video CD 1.1 specification came out, an improved <b>Video CD 2.0</b> standard was published in 1995."
0137                                       "<p>This one added the following items to the features already available in the Video CD 1.1 specification:"
0138                                       "<ul><li>Support for MPEG segment play items (<b>\"SPI\"</b>), consisting of still pictures, motion pictures and/or audio (only) streams was added.</li>"
0139                                       "<li>Note Segment Items::.</li>"
0140                                       "<li>Support for interactive playback control (<b>\"PBC\"</b>) was added.</li>"
0141                                       "<li>Support for playing related access by providing a scan point index file was added. (<b>\"/EXT/SCANDATA.DAT\"</b>)</li>"
0142                                       "<li>Support for closed captions.</li>"
0143                                       "<li>Support for mixing NTSC and PAL content.</li></ul>"
0144                                       "<p>By adding PAL support to the Video CD 1.1 specification, the following resolutions became available:"
0145                                       "<ul><li>352 x 240 @ 29.97 Hz (NTSC SIF).</li>"
0146                                       "<li>352 x 240 @ 23.976 Hz (FILM SIF).</li>"
0147                                       "<li>352 x 288 @ 25 Hz (PAL SIF).</li></ul>"
0148                                       "<p>For segment play items the following audio encodings became available:"
0149                                       "<ul><li>Joint stereo, stereo or dual channel audio streams at 128, 192, 224 or 384 kbit/sec bit-rate.</li>"
0150                                       "<li>Mono audio streams at 64, 96 or 192 kbit/sec bit-rate.</li></ul>"
0151                                       "<p>Also the possibility to have audio only streams and still pictures was provided."
0152                                       "<p><b>The bit-rate of multiplex-ed streams should be kept under 174300 bytes/sec (except for single still picture items) in order to accommodate single speed drives.</b>" ) );
0153 
0154     m_radioSvcd10->setWhatsThis( i18n( "<p>With the upcoming of the DVD-V media, a new VCD standard had to be published in order to be able to keep up with technology, so the Super Video CD specification was called into life 1999."
0155                                        "<p>In the midst of 2000 a full subset of this <b>Super Video CD</b> specification was published as <b>IEC-62107</b>."
0156                                        "<p>As the most notable change over Video CD 2.0 is a switch from MPEG-1 CBR to MPEG-2 VBR encoding for the video stream was performed."
0157                                        "<p>The following new features--building upon the Video CD 2.0 specification--are:"
0158                                        "<ul><li>Use of MPEG-2 encoding instead of MPEG-1 for the video stream.</li>"
0159                                        "<li>Allowed VBR encoding of MPEG-1 audio stream.</li>"
0160                                        "<li>Higher resolutions (see below) for video stream resolution.</li>"
0161                                        "<li>Up to 4 overlay graphics and text (<b>\"OGT\"</b>) sub-channels for user switchable subtitle displaying in addition to the already existing closed caption facility.</li>"
0162                                        "<li>Command lists for controlling the SVCD virtual machine.</li></ul>"
0163                                        "<p>For the <b>Super Video CD</b>, only the following two resolutions are supported for motion video and (low resolution) still pictures:"
0164                                        "<ul><li>480 x 480 @ 29.97 Hz (NTSC 2/3 D-2).</li>"
0165                                        "<li>480 x 576 @ 25 Hz (PAL 2/3 D-2).</li></ul>" ) );
0166 
0167     m_radioHqVcd10->setWhatsThis( i18n( "<p>This is actually just a minor variation defined in IEC-62107 on the Super Video CD 1.0 format for compatibility with current products in the market."
0168                                         "<p>It differs from the Super Video CD 1.0 format in the following items:"
0169                                         "<ul><li>The system profile tag field in <b>/SVCD/INFO.SVD</b> is set to <b>1</b> instead of <b>0</b>.</li>"
0170                                         "<li>The system identification field value in <b>/SVCD/INFO.SVD</b> is set to <b>HQ-VCD</b> instead of <b>SUPERVCD</b>.</li>"
0171                                         "<li><b>/EXT/SCANDATA.DAT</b> is mandatory instead of being optional.</li>"
0172                                         "<li><b>/SVCD/SEARCH.DAT</b> is optional instead of being mandatory.</li></ul>" ) );
0173 
0174     m_checkAutoDetect->setWhatsThis( i18n( "<p>If Autodetect is:</p>"
0175                                            "<ul><li>ON then K3b will set the correct Video CD type.</li>"
0176                                            "<li>OFF then the correct Video CD type needs to be set by the user.</li></ul>"
0177                                            "<p>If you are not sure about the correct Video CD type, it is best to turn Autodetect ON.</p>"
0178                                            "<p>If you want to force the Video CD type, you must turn Autodetect OFF. This is useful for some standalone DVD players without SVCD support.</p>" ) );
0179 
0180     m_checkNonCompliant->setWhatsThis( i18n( "<ul><li>Rename <b>\"/MPEG2\"</b> folder on SVCDs to (non-compliant) \"/MPEGAV\".</li>"
0181                                              "<li>Enables the use of the (deprecated) signature <b>\"ENTRYSVD\"</b> instead of <b>\"ENTRYVCD\"</b> for the file <b>\"/SVCD/ENTRY.SVD\"</b>.</li></ul>" ) );
0182     m_checkVCD30interpretation->setWhatsThis( i18n( "<ul><li>Enables the use of the (deprecated) Chinese <b>\"/SVCD/TRACKS.SVD\"</b> format which differs from the format defined in the <b>IEC-62107</b> specification.</li></ul>"
0183                                                     "<p><b>The differences are most exposed on SVCDs containing more than one video track.</b>" ) );
0184 
0185     m_check2336->setWhatsThis( i18n( "<p>though most devices will have problems with such an out-of-specification media."
0186                                      "<p><b>You may want use this option for images longer than 80 minutes</b>" ) );
0187 
0188     m_checkCdiSupport->setWhatsThis( i18n( "<p>To allow the play of Video-CDs on a CD-i player, the Video-CD standard requires that a CD-i application program must be present."
0189                                            "<p>This program is designed to:"
0190                                            "<ul><li>provide full play back control as defined in the PSD of the standard</li>"
0191                                            "<li>be extremely simple to use and easy-to-learn for the end-user</li></ul>"
0192                                            "<p>The program runs on CD-i players equipped with the CDRTOS 1.1(.1) operating system and a Digital Video extension cartridge." ) );
0193 
0194     m_editCdiCfg->setWhatsThis( i18n( "<p>Configuration parameters only available for Video CD 2.0"
0195                                       "<p>The engine works perfectly well when used as-is."
0196                                       "<p>You have the option to configure the VCD application."
0197                                       "<p>You can adapt the color and/or the shape of the cursor and lots more." ) );
0198 
0199 
0200     m_checkPbc->setWhatsThis( i18n( "<p>Playback control, PBC, is available for Video CD 2.0 and Super Video CD 1.0 disc formats."
0201                                     "<p>PBC allows control of the playback of play items and the possibility of interaction with the user through the remote control or some other input device available." ) );
0202 
0203     m_checkSegmentFolder->setWhatsThis( i18n( "<p>Here you can specify that the folder <b>SEGMENT</b> should always be present."
0204                                               "<p>Some DVD players need the folder to give a faultless rendition." ) );
0205 
0206     m_checkRelaxedAps->setWhatsThis( i18n( "<p>An Access Point Sector, APS, is an MPEG video sector on the VCD/SVCD which is suitable to be jumped to directly."
0207                                            "<p>APS are required for entry points and scantables. APS have to fulfill the requirement to precede every I-frame by a GOP header which shall be preceded by a sequence header in its turn."
0208                                            "<p>The start codes of these 3 items are required to be contained all in the same MPEG pack/sector, thus forming a so-called access point sector."
0209                                            "<p>This requirement can be relaxed by enabling the relaxed aps option, i.e. every sector containing an I-frame will be regarded as an APS."
0210                                            "<p><b>Warning:</b> The sequence header is needed for a playing device to figure out display parameters, such as display resolution and frame rate, relaxing the aps requirement may lead to non-working entry points." ) );
0211 
0212     m_checkUpdateScanOffsets->setWhatsThis( i18n( "<p>According to the specification, it is mandatory for Super Video CDs to encode scan information data into user data blocks in the picture layer of all intra coded picture."
0213                                                   "<p>It can be used by playing devices for implementing fast forward & fast reverse scanning."
0214                                                   "<p>The already existing scan information data can be updated by enabling the update scan offsets option." ) );
0215 
0216     m_labelRestriction->setWhatsThis( i18n( "<p>Viewing Restriction may be interpreted by the playing device."
0217                                             "<p>The allowed range goes from 0 to 3."
0218                                             "<ul><li>0 = unrestricted, free to view for all</li>"
0219                                             "<li>3 = restricted, content not suitable for ages under 18</li></ul>"
0220                                             "<p>Actually, the exact meaning is not defined and is player dependent."
0221                                             "<p><b>Most players ignore that value.<b>" ) );
0222 
0223     m_checkGaps->setWhatsThis( i18n( "<p>This option allows customization of Gaps and Margins." ) );
0224     m_labelPreGapLeadout->setWhatsThis( i18n( "<p>This option allows one to set the number of empty sectors added before the lead-out area begins, i.e. the number of post-gap sectors."
0225                                               "<p>The ECMA-130 specification requires the last data track before the lead-out to carry a post-gap of at least 150 sectors, which is used as default for this parameter."
0226                                               "<p>Some operating systems may encounter I/O errors due to read-ahead issues when reading the last MPEG track if this parameter is set too low."
0227                                               "<p>Allowed value content: [0..300]. Default: 150." ) );
0228 
0229     m_labelPreGapTrack->setWhatsThis( i18n( "<p>Used to set the track pre-gap for all tracks in sectors globally."
0230                                             "<p>The specification requires the pre-gaps to be at least 150 sectors long."
0231                                             "<p>Allowed value content: [0..300]. Default: 150." ) );
0232 
0233     m_labelFrontMarginTrack->setWhatsThis( i18n( "Margins are used to compensate for inaccurate sector-addressing issues on CD-ROM media. Interestingly, they have been abandoned for Super Video CDs."
0234                                                  "<p>For Video CD 1.0/1.1/2.0 this margin should be at least 15 sectors long."
0235                                                  "<p>Allowed value content: [0..150]. Default: 30 for Video CD 1.0/1.1/2.0, otherwise (i.e. Super Video CD 1.0 and HQ-VCD 1.0) 0." ) );
0236 
0237     m_labelRearMarginTrack->setWhatsThis( i18n( "<p>Margins are used to compensate for inaccurate sector-addressing issues on CD-ROM media. Interestingly, they have been abandoned for Super Video CDs."
0238                                                 "<p>For Video CD 1.0/1.1/2.0 this margin should be at least 15 sectors long."
0239                                                 "<p>Allowed value content: [0..150]. Default: 45 for Video CD 1.0/1.1/2.0, otherwise 0." ) );
0240 
0241 }
0242 
0243 
0244 K3b::VcdBurnDialog::~VcdBurnDialog()
0245 {}
0246 
0247 void K3b::VcdBurnDialog::setupAdvancedTab()
0248 {
0249     QWidget * w = new QWidget( this );
0250 
0251     // ---------------------------------------------------- generic group ----
0252     m_groupGeneric = new QGroupBox( i18n( "Generic" ), w );
0253 
0254     m_checkPbc = new QCheckBox( i18n( "Playback Control (PBC)" ), m_groupGeneric );
0255     m_checkSegmentFolder = new QCheckBox( i18n( "SEGMENT Folder must always be present" ), m_groupGeneric );
0256     m_checkRelaxedAps = new QCheckBox( i18n( "Relaxed aps" ), m_groupGeneric );
0257     m_checkUpdateScanOffsets = new QCheckBox( i18n( "Update scan offsets" ), m_groupGeneric );
0258     m_checkUpdateScanOffsets->setEnabled( false );
0259     QVBoxLayout* groupGenericLayout = new QVBoxLayout( m_groupGeneric );
0260     groupGenericLayout->addWidget( m_checkPbc );
0261     groupGenericLayout->addWidget( m_checkSegmentFolder );
0262     groupGenericLayout->addWidget( m_checkRelaxedAps );
0263     groupGenericLayout->addWidget( m_checkUpdateScanOffsets );
0264 
0265     // -------------------------------------------- gaps & margins group ----
0266     m_groupGaps = new QGroupBox( i18n( "Gaps" ), w );
0267 
0268     QGridLayout* groupGapsLayout = new QGridLayout( m_groupGaps );
0269     groupGapsLayout->setAlignment( Qt::AlignTop );
0270 
0271     m_checkGaps = new QCheckBox( i18n( "Customize gaps and margins" ), m_groupGaps );
0272 
0273     m_labelPreGapLeadout = new QLabel( i18n( "Leadout pre gap (0..300):" ), m_groupGaps );
0274     m_spinPreGapLeadout = new QSpinBox( m_groupGaps );
0275     m_spinPreGapLeadout->setMinimum( 0 );
0276     m_spinPreGapLeadout->setMaximum( 300 );
0277 
0278     m_labelPreGapTrack = new QLabel( i18n( "Track pre gap (0..300):" ), m_groupGaps );
0279     m_spinPreGapTrack = new QSpinBox( m_groupGaps );
0280     m_spinPreGapTrack->setMinimum( 0 );
0281     m_spinPreGapTrack->setMaximum( 300 );
0282 
0283     m_labelFrontMarginTrack = new QLabel( i18n( "Track front margin (0..150):" ), m_groupGaps );
0284     m_spinFrontMarginTrack = new QSpinBox( m_groupGaps );
0285     m_spinFrontMarginTrack->setMinimum( 0 );
0286     m_spinFrontMarginTrack->setMaximum( 150 );
0287     m_spinFrontMarginTrackSVCD = new QSpinBox( m_groupGaps );
0288     m_spinFrontMarginTrackSVCD->setMinimum( 0 );
0289     m_spinFrontMarginTrackSVCD->setMaximum( 150 );
0290     m_spinFrontMarginTrackSVCD->setHidden( true );
0291 
0292     m_labelRearMarginTrack = new QLabel( i18n( "Track rear margin (0..150):" ), m_groupGaps );
0293     m_spinRearMarginTrack = new QSpinBox( m_groupGaps );
0294     m_spinRearMarginTrack->setMinimum( 0 );
0295     m_spinRearMarginTrack->setMaximum( 150 );
0296     m_spinRearMarginTrackSVCD = new QSpinBox( m_groupGaps );
0297     m_spinRearMarginTrackSVCD->setMinimum( 0 );
0298     m_spinRearMarginTrackSVCD->setMaximum( 150 );
0299     m_spinRearMarginTrackSVCD->setHidden( true );
0300 
0301     groupGapsLayout->addWidget( m_checkGaps, 1, 0, 1, 5 );
0302     groupGapsLayout->addWidget( m_labelPreGapLeadout, 2, 0 );
0303     groupGapsLayout->addWidget( m_spinPreGapLeadout, 2, 1 );
0304     groupGapsLayout->addWidget( m_labelPreGapTrack, 2, 3 );
0305     groupGapsLayout->addWidget( m_spinPreGapTrack, 2, 4 );
0306 
0307     groupGapsLayout->addWidget( m_labelFrontMarginTrack, 3, 0 );
0308     groupGapsLayout->addWidget( m_spinFrontMarginTrack, 3, 1 );
0309     groupGapsLayout->addWidget( m_spinFrontMarginTrackSVCD, 3, 1 );
0310     groupGapsLayout->addWidget( m_labelRearMarginTrack, 3, 3 );
0311     groupGapsLayout->addWidget( m_spinRearMarginTrack, 3, 4 );
0312     groupGapsLayout->addWidget( m_spinRearMarginTrackSVCD, 3, 4 );
0313 
0314     groupGapsLayout->setRowStretch( 4, 0 );
0315 
0316     groupGapsLayout->addWidget( m_checkGaps, 1, 0, 1, 5 );
0317     groupGapsLayout->addWidget( m_labelPreGapLeadout, 2, 0 );
0318     groupGapsLayout->addWidget( m_spinPreGapLeadout, 2, 1 );
0319     groupGapsLayout->addWidget( m_labelPreGapTrack, 2, 3 );
0320     groupGapsLayout->addWidget( m_spinPreGapTrack, 2, 4 );
0321 
0322     groupGapsLayout->addWidget( m_labelFrontMarginTrack, 3, 0 );
0323     groupGapsLayout->addWidget( m_spinFrontMarginTrack, 3, 1 );
0324     groupGapsLayout->addWidget( m_spinFrontMarginTrackSVCD, 3, 1 );
0325     groupGapsLayout->addWidget( m_labelRearMarginTrack, 3, 3 );
0326     groupGapsLayout->addWidget( m_spinRearMarginTrack, 3, 4 );
0327     groupGapsLayout->addWidget( m_spinRearMarginTrackSVCD, 3, 4 );
0328 
0329     groupGapsLayout->setRowStretch( 4, 0 );
0330     groupGapsLayout->addWidget( m_checkGaps, 1, 0, 1, 5 );
0331     groupGapsLayout->addWidget( m_labelPreGapLeadout, 2, 0 );
0332     groupGapsLayout->addWidget( m_spinPreGapLeadout, 2, 1 );
0333     groupGapsLayout->addWidget( m_labelPreGapTrack, 2, 3 );
0334     groupGapsLayout->addWidget( m_spinPreGapTrack, 2, 4 );
0335 
0336     groupGapsLayout->addWidget( m_labelFrontMarginTrack, 3, 0 );
0337     groupGapsLayout->addWidget( m_spinFrontMarginTrack, 3, 1 );
0338     groupGapsLayout->addWidget( m_spinFrontMarginTrackSVCD, 3, 1 );
0339     groupGapsLayout->addWidget( m_labelRearMarginTrack, 3, 3 );
0340     groupGapsLayout->addWidget( m_spinRearMarginTrack, 3, 4 );
0341     groupGapsLayout->addWidget( m_spinRearMarginTrackSVCD, 3, 4 );
0342 
0343     groupGapsLayout->setRowStretch( 4, 0 );
0344     groupGapsLayout->addWidget( m_checkGaps, 1, 0, 1, 5 );
0345     groupGapsLayout->addWidget( m_labelPreGapLeadout, 2, 0 );
0346     groupGapsLayout->addWidget( m_spinPreGapLeadout, 2, 1 );
0347     groupGapsLayout->addWidget( m_labelPreGapTrack, 2, 3 );
0348     groupGapsLayout->addWidget( m_spinPreGapTrack, 2, 4 );
0349 
0350     groupGapsLayout->addWidget( m_labelFrontMarginTrack, 3, 0 );
0351     groupGapsLayout->addWidget( m_spinFrontMarginTrack, 3, 1 );
0352     groupGapsLayout->addWidget( m_spinFrontMarginTrackSVCD, 3, 1 );
0353     groupGapsLayout->addWidget( m_labelRearMarginTrack, 3, 3 );
0354     groupGapsLayout->addWidget( m_spinRearMarginTrack, 3, 4 );
0355     groupGapsLayout->addWidget( m_spinRearMarginTrackSVCD, 3, 4 );
0356 
0357     groupGapsLayout->setRowStretch( 4, 0 );
0358 
0359     // ------------------------------------------------------- misc group ----
0360     m_groupMisc = new QGroupBox( i18n( "Misc" ), w );
0361 
0362     QGridLayout* groupMiscLayout = new QGridLayout( m_groupMisc );
0363     groupMiscLayout->setAlignment( Qt::AlignTop );
0364 
0365     m_labelRestriction = new QLabel( i18n( "Restriction category (0..3):" ), m_groupMisc );
0366     m_spinRestriction = new QSpinBox( m_groupMisc );
0367     m_spinRestriction->setMinimum( 0 );
0368     m_spinRestriction->setMaximum( 3 );
0369 
0370     groupMiscLayout->addWidget( m_labelRestriction, 1, 0 );
0371     groupMiscLayout->addWidget( m_spinRestriction, 1, 1, 1, 4 );
0372     groupMiscLayout->setRowStretch( 2, 0 );
0373 
0374     // ----------------------------------------------------------------------
0375     QGridLayout* grid = new QGridLayout( w );
0376     grid->addWidget( m_groupGeneric, 0, 0 );
0377     grid->addWidget( m_groupGaps, 1, 0 );
0378     grid->addWidget( m_groupMisc, 2, 0 );
0379 
0380     addPage( w, i18n( "Advanced" ) );
0381 }
0382 
0383 void K3b::VcdBurnDialog::setupVideoCdTab()
0384 {
0385     QWidget * w = new QWidget( this );
0386 
0387     // ---------------------------------------------------- Format group ----
0388     m_groupVcdFormat = new QGroupBox( i18n( "Type" ), w );
0389     m_radioVcd11 = new QRadioButton( i18n( "Video CD 1.1" ), m_groupVcdFormat );
0390     m_radioVcd20 = new QRadioButton( i18n( "Video CD 2.0" ), m_groupVcdFormat );
0391     m_radioSvcd10 = new QRadioButton( i18n( "Super Video CD" ), m_groupVcdFormat );
0392     m_radioHqVcd10 = new QRadioButton( i18n( "HQ Video CD" ), m_groupVcdFormat );
0393     m_buttonGroupVcdFormat = new QButtonGroup( m_groupVcdFormat );
0394     m_buttonGroupVcdFormat->setExclusive( true );
0395     m_buttonGroupVcdFormat->addButton( m_radioVcd11, K3b::VcdDoc::VCD11);
0396     m_buttonGroupVcdFormat->addButton( m_radioVcd20, K3b::VcdDoc::VCD20 );
0397     m_buttonGroupVcdFormat->addButton( m_radioSvcd10, K3b::VcdDoc::SVCD10);
0398     m_buttonGroupVcdFormat->addButton( m_radioHqVcd10,K3b::VcdDoc::HQVCD  );
0399 
0400     QVBoxLayout* groupVcdFormatLayout = new QVBoxLayout( m_groupVcdFormat );
0401     groupVcdFormatLayout->addWidget( m_radioVcd11 );
0402     groupVcdFormatLayout->addWidget( m_radioVcd20 );
0403     groupVcdFormatLayout->addWidget( m_radioSvcd10 );
0404     groupVcdFormatLayout->addWidget( m_radioHqVcd10 );
0405 
0406 
0407     // ---------------------------------------------------- Options group ---
0408 
0409     m_groupOptions = new QGroupBox( i18n( "Settings" ), w );
0410     m_checkAutoDetect = new QCheckBox( i18n( "Autodetect Video CD type" ), m_groupOptions );
0411     m_checkNonCompliant = new QCheckBox( i18n( "Enable broken SVCD mode" ), m_groupOptions );
0412     // Only available on SVCD Type
0413     m_checkNonCompliant->setEnabled( false );
0414     m_checkNonCompliant->setChecked( false );
0415     m_checkVCD30interpretation = new QCheckBox( i18n( "Enable %1 track interpretation" , QString("VCD 3.0") ), m_groupOptions );
0416     // Only available on SVCD Type
0417     m_checkVCD30interpretation->setEnabled( false );
0418     m_checkVCD30interpretation->setChecked( false );
0419     m_check2336 = new QCheckBox( i18n( "Use 2336 byte sectors" ), m_groupOptions );
0420     m_checkCdiSupport = new QCheckBox( i18n( "Enable CD-i support" ), m_groupOptions );
0421     QVBoxLayout* groupOptionsLayout = new QVBoxLayout( m_groupOptions );
0422     groupOptionsLayout->addWidget( m_checkAutoDetect );
0423     groupOptionsLayout->addWidget( m_checkNonCompliant );
0424     groupOptionsLayout->addWidget( m_checkVCD30interpretation );
0425     groupOptionsLayout->addWidget( m_check2336 );
0426     groupOptionsLayout->addWidget( m_checkCdiSupport );
0427 
0428     // ------------------------------------------------- CD-i Application ---
0429     m_groupCdi = new QGroupBox( i18n( "Video CD on CD-i" ), w );
0430     m_editCdiCfg = new QTextEdit( m_groupCdi );
0431     m_editCdiCfg->setFrameShape( QFrame::NoFrame );
0432     QVBoxLayout* groupCdiLayout = new QVBoxLayout( m_groupCdi );
0433     groupCdiLayout->addWidget( m_editCdiCfg );
0434 
0435     // ----------------------------------------------------------------------
0436     QGridLayout* grid = new QGridLayout( w );
0437     grid->addWidget( m_groupVcdFormat, 0, 0, 2, 1 );
0438     grid->addWidget( m_groupOptions, 0, 1 );
0439     grid->addWidget( m_groupCdi, 1, 1 );
0440 
0441     addPage( w, i18n( "Settings" ) );
0442 }
0443 
0444 void K3b::VcdBurnDialog::setupLabelTab()
0445 {
0446     QWidget * w = new QWidget( this );
0447 
0448     // ----------------------------------------------------------------------
0449     // noEdit
0450     QLabel* labelSystemId = new QLabel( i18n( "System:" ), w );
0451     QLabel* labelApplicationId = new QLabel( i18n( "Application:" ), w );
0452     QLabel* labelInfoSystemId = new QLabel( vcdDoc() ->vcdOptions() ->systemId(), w );
0453     QLabel* labelInfoApplicationId = new QLabel( vcdDoc() ->vcdOptions() ->applicationId(), w );
0454 
0455     labelInfoSystemId->setFrameShape( QLabel::StyledPanel );
0456     labelInfoSystemId->setFrameShadow( QLabel::Sunken );
0457 
0458     labelInfoApplicationId->setFrameShape( QLabel::StyledPanel );
0459     labelInfoApplicationId->setFrameShadow( QLabel::Sunken );
0460     labelInfoApplicationId->setToolTip( i18n( "ISO application identifier for Video CD" ) );
0461 
0462     // ----------------------------------------------------------------------
0463 
0464     QLabel* labelVolumeId = new QLabel( i18n( "&Volume name:" ), w );
0465     QLabel* labelAlbumId = new QLabel( i18n( "Volume &set name:" ), w );
0466     QLabel* labelVolumeCount = new QLabel( i18n( "Volume set s&ize:" ), w );
0467     QLabel* labelVolumeNumber = new QLabel( i18n( "Volume set &number:" ), w );
0468     QLabel* labelPublisher = new QLabel( i18n( "&Publisher:" ), w );
0469 
0470 
0471     m_editVolumeId = new QLineEdit( w );
0472     m_editAlbumId = new QLineEdit( w );
0473     m_spinVolumeNumber = new QSpinBox( w );
0474     m_spinVolumeCount = new QSpinBox( w );
0475     m_editPublisher = new QLineEdit( w );
0476 
0477     // only ISO646 d-Characters
0478     m_editVolumeId->setValidator( K3b::Validators::iso646Validator( K3b::Validators::Iso646_d, true, m_editVolumeId ) );
0479     m_editAlbumId->setValidator( K3b::Validators::iso646Validator( K3b::Validators::Iso646_d, true, m_editVolumeId ) );
0480 
0481     m_editVolumeId->setMaxLength( 32 );
0482     m_editAlbumId->setMaxLength( 16 );
0483     // only ISO646 a-Characters
0484     m_editPublisher->setValidator( K3b::Validators::iso646Validator( K3b::Validators::Iso646_a, true, m_editVolumeId ) );
0485     m_editPublisher->setMaxLength( 128 );
0486 
0487     m_spinVolumeNumber->setMinimum( 1 );
0488     m_spinVolumeNumber->setMaximum( 1 );
0489     m_spinVolumeCount->setMinimum( 1 );
0490 
0491     QFrame* line = new QFrame( w );
0492     line->setFrameShape( QFrame::HLine );
0493     line->setFrameShadow( QFrame::Sunken );
0494     line->setFrameShape( QFrame::HLine );
0495 
0496 
0497     // ----------------------------------------------------------------------
0498     QGridLayout* grid = new QGridLayout( w );
0499 
0500     grid->addWidget( labelVolumeId, 1, 0 );
0501     grid->addWidget( m_editVolumeId, 1, 1, 1, 3 );
0502     grid->addWidget( labelAlbumId, 2, 0 );
0503     grid->addWidget( m_editAlbumId, 2, 1, 1, 3 );
0504 
0505     grid->addWidget( labelVolumeCount, 3, 0 );
0506     grid->addWidget( m_spinVolumeCount, 3, 1 );
0507     grid->addWidget( labelVolumeNumber, 3, 2 );
0508     grid->addWidget( m_spinVolumeNumber, 3, 3 );
0509 
0510     grid->addWidget( labelPublisher, 4, 0 );
0511     grid->addWidget( m_editPublisher, 4, 1, 1, 3 );
0512 
0513     grid->addWidget( line, 5, 0, 1, 4 );
0514 
0515     grid->addWidget( labelSystemId, 6, 0 );
0516     grid->addWidget( labelInfoSystemId, 6, 1, 1, 3 );
0517     grid->addWidget( labelApplicationId, 7, 0 );
0518     grid->addWidget( labelInfoApplicationId, 7, 1, 1, 3 );
0519 
0520     //  grid->addRowSpacing( 5, 15 );
0521     grid->setRowStretch( 8, 1 );
0522 
0523     // buddies
0524     labelVolumeId->setBuddy( m_editVolumeId );
0525     labelPublisher->setBuddy( m_editPublisher );
0526     labelAlbumId->setBuddy( m_editAlbumId );
0527 
0528     labelVolumeCount->setBuddy( m_spinVolumeCount );
0529     labelVolumeNumber->setBuddy( m_spinVolumeNumber );
0530 
0531     // tab order
0532     setTabOrder( m_editVolumeId, m_editAlbumId );
0533     setTabOrder( m_editAlbumId, m_spinVolumeCount );
0534     setTabOrder( m_spinVolumeCount, m_spinVolumeNumber );
0535     setTabOrder( m_spinVolumeNumber, m_editPublisher );
0536 
0537     addPage( w, i18n( "Volume Descriptor" ) );
0538 }
0539 
0540 
0541 void K3b::VcdBurnDialog::slotStartClicked()
0542 {
0543 
0544     if ( QFile::exists( vcdDoc() ->vcdImage() ) ) {
0545         if ( KMessageBox::warningContinueCancel( this,
0546                                                  i18n( "Do you want to overwrite %1?" , vcdDoc() ->vcdImage() ),
0547                                                  i18n( "File Exists" ), KStandardGuiItem::overwrite() )
0548             != KMessageBox::Continue )
0549             return;
0550     }
0551 
0552     K3b::ProjectBurnDialog::slotStartClicked();
0553 }
0554 
0555 
0556 void K3b::VcdBurnDialog::saveSettingsToProject()
0557 {
0558     K3b::ProjectBurnDialog::saveSettingsToProject();
0559 
0560     // set VolumeID if empty
0561     setVolumeID();
0562 
0563     doc() ->setTempDir( m_tempDirSelectionWidget->tempPath() );
0564     doc() ->setOnTheFly( false );
0565 
0566     // save image file & path (.bin)
0567     vcdDoc() ->setVcdImage( m_tempDirSelectionWidget->tempPath() + '/' + m_editVolumeId->text() + ".bin" );
0568 
0569     vcdDoc() ->setVcdType( m_radioVcd11->group()->id( m_radioVcd11->group()->checkedButton() ) );
0570 
0571     vcdDoc() ->vcdOptions() ->setVolumeId( m_editVolumeId->text() );
0572     vcdDoc() ->vcdOptions() ->setPublisher( m_editPublisher->text() );
0573     vcdDoc() ->vcdOptions() ->setAlbumId( m_editAlbumId->text() );
0574 
0575     vcdDoc() ->vcdOptions() ->setAutoDetect( m_checkAutoDetect->isChecked() );
0576     vcdDoc() ->vcdOptions() ->setNonCompliantMode( m_checkNonCompliant->isChecked() );
0577     vcdDoc() ->vcdOptions() ->setVCD30interpretation( m_checkVCD30interpretation->isChecked() );
0578     vcdDoc() ->vcdOptions() ->setSector2336( m_check2336->isChecked() );
0579 
0580     vcdDoc() ->vcdOptions() ->setCdiSupport( m_checkCdiSupport->isChecked() );
0581     //    vcdDoc() ->setOnlyCreateImages( m_checkOnlyCreateImage->isChecked() );
0582 
0583     vcdDoc() ->vcdOptions() ->setVolumeNumber( m_spinVolumeNumber->value() );
0584     vcdDoc() ->vcdOptions() ->setVolumeCount( m_spinVolumeCount->value() );
0585 
0586     vcdDoc() ->vcdOptions() ->setPbcEnabled( m_checkPbc->isChecked() );
0587     if ( m_checkPbc->isChecked() )
0588         vcdDoc() -> setPbcTracks();
0589 
0590     vcdDoc() ->vcdOptions() ->setSegmentFolder( m_checkSegmentFolder->isChecked() );
0591     vcdDoc() ->vcdOptions() ->setRelaxedAps( m_checkRelaxedAps->isChecked() );
0592     vcdDoc() ->vcdOptions() ->setUpdateScanOffsets( m_checkUpdateScanOffsets->isChecked() );
0593     vcdDoc() ->vcdOptions() ->setRestriction( m_spinRestriction->value() );
0594 
0595     vcdDoc() ->vcdOptions() ->setUseGaps( m_checkGaps->isChecked() );
0596     vcdDoc() ->vcdOptions() ->setPreGapLeadout( m_spinPreGapLeadout->value() );
0597     vcdDoc() ->vcdOptions() ->setPreGapTrack( m_spinPreGapTrack->value() );
0598     vcdDoc() ->vcdOptions() ->setFrontMarginTrack( m_spinFrontMarginTrack->value() );
0599     vcdDoc() ->vcdOptions() ->setRearMarginTrack( m_spinRearMarginTrack->value() );
0600     vcdDoc() ->vcdOptions() ->setFrontMarginTrackSVCD( m_spinFrontMarginTrackSVCD->value() );
0601     vcdDoc() ->vcdOptions() ->setRearMarginTrackSVCD( m_spinRearMarginTrackSVCD->value() );
0602 
0603     if ( m_editCdiCfg->document()->isModified() )
0604         saveCdiConfig();
0605 }
0606 
0607 
0608 void K3b::VcdBurnDialog::readSettingsFromProject()
0609 {
0610     K3b::ProjectBurnDialog::readSettingsFromProject();
0611 
0612     m_checkNonCompliant->setEnabled( false );
0613     m_checkVCD30interpretation->setEnabled( false );
0614 
0615     // read vcdType
0616     switch ( ( ( K3b::VcdDoc* ) doc() ) ->vcdType() ) {
0617     case K3b::VcdDoc::VCD11:
0618         m_radioVcd11->setChecked( true );
0619         break;
0620     case K3b::VcdDoc::VCD20:
0621         m_radioVcd20->setChecked( true );
0622         break;
0623     case K3b::VcdDoc::SVCD10:
0624         m_radioSvcd10->setChecked( true );
0625         m_checkNonCompliant->setEnabled( true );
0626         m_checkVCD30interpretation->setEnabled( true );
0627         break;
0628     case K3b::VcdDoc::HQVCD:
0629         m_radioHqVcd10->setChecked( true );
0630         break;
0631     default:
0632         m_radioVcd20->setChecked( true );
0633         break;
0634     }
0635 
0636     m_spinVolumeCount->setValue( vcdDoc() ->vcdOptions() ->volumeCount() );
0637     m_spinVolumeNumber->setMaximum( vcdDoc() ->vcdOptions() ->volumeCount() );
0638     m_spinVolumeNumber->setValue( vcdDoc() ->vcdOptions() ->volumeNumber() );
0639 
0640     m_checkAutoDetect->setChecked( vcdDoc() ->vcdOptions() ->AutoDetect() );
0641     m_groupVcdFormat->setDisabled( vcdDoc() ->vcdOptions() ->AutoDetect() );
0642 
0643     m_check2336->setChecked( vcdDoc() ->vcdOptions() ->Sector2336() );
0644 
0645     m_checkCdiSupport->setEnabled( false );
0646     m_checkCdiSupport->setChecked( false );
0647     m_groupCdi->setEnabled( false );
0648 
0649     if ( m_radioSvcd10->isChecked() ) {
0650         m_checkNonCompliant->setChecked( vcdDoc() ->vcdOptions() ->NonCompliantMode() );
0651         m_checkUpdateScanOffsets->setEnabled( true );
0652         m_checkVCD30interpretation->setChecked( vcdDoc() ->vcdOptions() ->VCD30interpretation() );
0653     } else if ( m_radioHqVcd10->isChecked() ) {
0654         // NonCompliant only for SVCD
0655         m_checkNonCompliant->setChecked( false );
0656         m_checkNonCompliant->setEnabled( false );
0657         m_checkUpdateScanOffsets->setEnabled( false );
0658         m_checkVCD30interpretation->setChecked( false );
0659         m_checkVCD30interpretation->setEnabled( false );
0660     } else {
0661         // NonCompliant only for SVCD
0662         m_checkNonCompliant->setChecked( false );
0663         m_checkNonCompliant->setEnabled( false );
0664         m_checkVCD30interpretation->setChecked( false );
0665         m_checkUpdateScanOffsets->setEnabled( false );
0666         m_checkVCD30interpretation->setEnabled( false );
0667         // CD-I only for VCD and CD-i application was found :)
0668         if ( vcdDoc() ->vcdOptions() ->checkCdiFiles() ) {
0669             m_checkCdiSupport->setEnabled( true );
0670             m_checkCdiSupport->setChecked( vcdDoc() ->vcdOptions() ->CdiSupport() );
0671         }
0672     }
0673 
0674     // set VolumeID if empty
0675     setVolumeID();
0676     // m_editVolumeId->setText( vcdDoc() ->vcdOptions() ->volumeId() );
0677     m_editPublisher->setText( vcdDoc() ->vcdOptions() ->publisher() );
0678     m_editAlbumId->setText( vcdDoc() ->vcdOptions() ->albumId() );
0679 
0680     m_checkPbc->setChecked( vcdDoc() ->vcdOptions() ->PbcEnabled() );
0681     m_checkSegmentFolder->setChecked( vcdDoc() ->vcdOptions() ->SegmentFolder() );
0682     m_checkRelaxedAps->setChecked( vcdDoc() ->vcdOptions() ->RelaxedAps() );
0683     m_checkUpdateScanOffsets->setChecked( vcdDoc() ->vcdOptions() ->UpdateScanOffsets() );
0684     m_spinRestriction->setValue( vcdDoc() ->vcdOptions() ->Restriction() );
0685 
0686     m_checkGaps->setChecked( vcdDoc() ->vcdOptions() ->UseGaps() );
0687     slotGapsChecked( m_checkGaps->isChecked() ) ;
0688     m_spinPreGapLeadout->setValue( vcdDoc() ->vcdOptions() ->PreGapLeadout() );
0689     m_spinPreGapTrack->setValue( vcdDoc() ->vcdOptions() ->PreGapTrack() );
0690     m_spinFrontMarginTrack->setValue( vcdDoc() ->vcdOptions() ->FrontMarginTrack() );
0691     m_spinRearMarginTrack->setValue( vcdDoc() ->vcdOptions() ->RearMarginTrack() );
0692     m_spinFrontMarginTrackSVCD->setValue( vcdDoc() ->vcdOptions() ->FrontMarginTrackSVCD() );
0693     m_spinRearMarginTrackSVCD->setValue( vcdDoc() ->vcdOptions() ->RearMarginTrackSVCD() );
0694 
0695     if ( !doc() ->tempDir().isEmpty() )
0696         m_tempDirSelectionWidget->setTempPath( doc() ->tempDir() );
0697 
0698     loadCdiConfig();
0699 }
0700 
0701 void K3b::VcdBurnDialog::loadSettings( const KConfigGroup& c )
0702 {
0703     K3b::ProjectBurnDialog::loadSettings( c );
0704 
0705     K3b::VcdOptions o = K3b::VcdOptions::load( c );
0706 
0707     m_checkAutoDetect->setChecked( o.AutoDetect() );
0708     m_check2336->setChecked( o.Sector2336() );
0709 
0710     m_checkCdiSupport->setChecked( false );
0711     m_checkCdiSupport->setEnabled( false );
0712     m_groupCdi->setEnabled( false );
0713 
0714     if ( m_radioSvcd10->isChecked() ) {
0715         m_checkNonCompliant->setChecked( o.NonCompliantMode() );
0716         m_checkVCD30interpretation->setChecked( o.VCD30interpretation() );
0717     } else {
0718         m_checkNonCompliant->setChecked( false );
0719         m_checkNonCompliant->setEnabled( false );
0720         m_checkVCD30interpretation->setChecked( false );
0721         m_checkVCD30interpretation->setEnabled( false );
0722         if ( vcdDoc() ->vcdOptions() ->checkCdiFiles() ) {
0723             m_checkCdiSupport->setEnabled( true );
0724             m_checkCdiSupport->setChecked( o.CdiSupport() );
0725         }
0726     }
0727 
0728     m_spinVolumeCount->setValue( o.volumeCount() );
0729     m_spinVolumeNumber->setMaximum( o.volumeCount() );
0730     m_spinVolumeNumber->setValue( o.volumeNumber() );
0731 
0732     m_editVolumeId->setText( o.volumeId() );
0733     m_editPublisher->setText( o.publisher() );
0734     m_editAlbumId->setText( o.albumId() );
0735     m_checkPbc->setChecked( o.PbcEnabled() );
0736     m_checkSegmentFolder->setChecked( o.SegmentFolder() );
0737     m_checkRelaxedAps->setChecked( o.RelaxedAps() );
0738     m_checkUpdateScanOffsets->setChecked( o.UpdateScanOffsets() );
0739     m_spinRestriction->setValue( o.Restriction() );
0740 
0741     m_checkGaps->setChecked( o.UseGaps() );
0742     m_spinPreGapLeadout->setValue( o.PreGapLeadout() );
0743     m_spinPreGapTrack->setValue( o.PreGapTrack() );
0744     m_spinFrontMarginTrack->setValue( o.FrontMarginTrack() );
0745     m_spinRearMarginTrack->setValue( o.RearMarginTrack() );
0746     m_spinFrontMarginTrackSVCD->setValue( o.FrontMarginTrackSVCD() );
0747     m_spinRearMarginTrackSVCD->setValue( o.RearMarginTrackSVCD() );
0748 
0749     loadCdiConfig();
0750 }
0751 
0752 
0753 void K3b::VcdBurnDialog::saveSettings( KConfigGroup c )
0754 {
0755     K3b::ProjectBurnDialog::saveSettings( c );
0756 
0757     K3b::VcdOptions o;
0758 
0759     o.setVolumeId( m_editVolumeId->text() );
0760     o.setPublisher( m_editPublisher->text() );
0761     o.setAlbumId( m_editAlbumId->text() );
0762     o.setAutoDetect( m_checkAutoDetect->isChecked() );
0763     o.setNonCompliantMode( m_checkNonCompliant->isChecked() );
0764     o.setVCD30interpretation( m_checkVCD30interpretation->isChecked() );
0765     o.setSector2336( m_check2336->isChecked() );
0766     o.setVolumeCount( m_spinVolumeCount->value() );
0767     o.setVolumeNumber( m_spinVolumeNumber->value() );
0768     o.setCdiSupport( m_checkCdiSupport->isChecked() );
0769     o.setPbcEnabled( m_checkPbc->isChecked() );
0770     o.setSegmentFolder( m_checkSegmentFolder->isChecked() );
0771     o.setRelaxedAps( m_checkRelaxedAps->isChecked() );
0772     o.setUpdateScanOffsets( m_checkUpdateScanOffsets->isChecked() );
0773     o.setRestriction( m_spinRestriction->value() );
0774     o.setUseGaps( m_checkGaps->isChecked() );
0775     o.setPreGapLeadout( m_spinPreGapLeadout->value() );
0776     o.setPreGapTrack( m_spinPreGapTrack->value() );
0777     o.setFrontMarginTrack( m_spinFrontMarginTrack->value() );
0778     o.setRearMarginTrack( m_spinRearMarginTrack->value() );
0779     o.setFrontMarginTrackSVCD( m_spinFrontMarginTrackSVCD->value() );
0780     o.setRearMarginTrackSVCD( m_spinRearMarginTrackSVCD->value() );
0781 
0782     o.save( c );
0783 
0784     saveCdiConfig();
0785 }
0786 
0787 void K3b::VcdBurnDialog::saveCdiConfig()
0788 {
0789     QString dirPath = QStandardPaths::writableLocation( QStandardPaths::AppDataLocation ) + "/cdi";
0790     QDir().mkpath( dirPath );
0791 
0792     QString filename = dirPath +  "/cdi_vcd.cfg";
0793     if ( QFile::exists( filename ) )
0794         QFile::remove
0795             ( filename );
0796 
0797     QFile cdi( filename );
0798     if ( cdi.open( QIODevice::WriteOnly ) ) {
0799         QTextStream s( &cdi );
0800         s << m_editCdiCfg->toPlainText();
0801         m_editCdiCfg->document()->setModified( false );
0802     }
0803 }
0804 
0805 void K3b::VcdBurnDialog::loadCdiConfig()
0806 {
0807     QString filename = QStandardPaths::writableLocation( QStandardPaths::AppDataLocation ) + "/cdi/cdi_vcd.cfg";
0808     if ( QFile::exists( filename ) ) {
0809         QFile cdi( filename );
0810         if ( cdi.open( QIODevice::ReadOnly ) ) {
0811             QTextStream s( &cdi );
0812             m_editCdiCfg->setPlainText( s.readAll() );
0813             m_editCdiCfg->document()->setModified( false );
0814             m_groupCdi->setEnabled( m_checkCdiSupport->isChecked() );
0815         }
0816         else {
0817             loadDefaultCdiConfig();
0818         }
0819     }
0820     else {
0821         loadDefaultCdiConfig();
0822     }
0823 }
0824 
0825 void K3b::VcdBurnDialog::loadDefaultCdiConfig()
0826 {
0827     QString filename = QStandardPaths::locate( QStandardPaths::GenericDataLocation, "k3b/cdi/cdi_vcd.cfg" );
0828     if ( QFile::exists( filename ) ) {
0829         QFile cdi( filename );
0830         if ( cdi.open( QIODevice::ReadOnly ) ) {
0831             QTextStream s( &cdi );
0832             m_editCdiCfg->setPlainText( s.readAll() );
0833             m_editCdiCfg->document()->setModified( false );
0834             m_groupCdi->setEnabled( m_checkCdiSupport->isChecked() );
0835         }
0836         else {
0837             m_checkCdiSupport->setChecked( false );
0838             m_checkCdiSupport->setEnabled( false );
0839         }
0840     }
0841 }
0842 
0843 void K3b::VcdBurnDialog::setVolumeID()
0844 {
0845     if ( m_editVolumeId->text().length() < 1 ) {
0846         if ( m_radioSvcd10->isChecked() )
0847             m_editVolumeId->setText( "SUPER_VIDEOCD" );
0848         else if ( m_radioHqVcd10->isChecked() )
0849             m_editVolumeId->setText( "HQ_VIDEOCD" );
0850         else
0851             m_editVolumeId->setText( "VIDEOCD" );
0852     }
0853 }
0854 
0855 void K3b::VcdBurnDialog::slotSpinVolumeCount()
0856 {
0857     m_spinVolumeNumber->setMaximum( m_spinVolumeCount->value() );
0858 }
0859 
0860 void K3b::VcdBurnDialog::slotVcdTypeClicked( K3b::VcdOptions::MPEGVersion i )
0861 {
0862 
0863     switch ( i ) {
0864     case K3b::VcdOptions::VCD11:
0865         // vcd 1.1 no support for version 3.x.
0866         // v4 work also for vcd 1.1 but without CD-i menus.
0867         // Do anybody use vcd 1.1 with cd-i????
0868         m_checkCdiSupport->setEnabled( vcdDoc() ->vcdOptions() ->checkCdiFiles() );
0869         m_checkCdiSupport->setChecked( false );
0870 
0871         m_checkNonCompliant->setEnabled( false );
0872         m_checkNonCompliant->setChecked( false );
0873         m_checkVCD30interpretation->setEnabled( false );
0874         m_checkVCD30interpretation->setChecked( false );
0875         m_checkUpdateScanOffsets->setEnabled( false );
0876         m_checkUpdateScanOffsets->setChecked( false );
0877         break;
0878     case K3b::VcdOptions::VCD20:
0879         //vcd 2.0
0880         m_checkCdiSupport->setEnabled( vcdDoc() ->vcdOptions() ->checkCdiFiles() );
0881         m_groupCdi->setEnabled( m_checkCdiSupport->isChecked() );
0882 
0883         m_checkNonCompliant->setEnabled( false );
0884         m_checkNonCompliant->setChecked( false );
0885         m_checkVCD30interpretation->setEnabled( false );
0886         m_checkVCD30interpretation->setChecked( false );
0887         m_checkUpdateScanOffsets->setEnabled( false );
0888         m_checkUpdateScanOffsets->setChecked( false );
0889         break;
0890     case K3b::VcdOptions::SVCD10:
0891         //svcd 1.0
0892         m_checkCdiSupport->setEnabled( false );
0893         m_checkCdiSupport->setChecked( false );
0894         m_groupCdi->setEnabled( false );
0895 
0896         m_checkNonCompliant->setEnabled( true );
0897         m_checkVCD30interpretation->setEnabled( true );
0898         m_checkUpdateScanOffsets->setEnabled( true );
0899         break;
0900     case K3b::VcdOptions::HQVCD10:
0901         //hqvcd 1.0
0902         m_checkCdiSupport->setEnabled( false );
0903         m_checkCdiSupport->setChecked( false );
0904         m_groupCdi->setEnabled( false );
0905 
0906         m_checkNonCompliant->setEnabled( false );
0907         m_checkNonCompliant->setChecked( false );
0908         m_checkVCD30interpretation->setEnabled( false );
0909         m_checkVCD30interpretation->setChecked( false );
0910         m_checkUpdateScanOffsets->setEnabled( true );
0911         break;
0912     }
0913 
0914     MarginChecked( m_checkGaps->isChecked() );
0915 
0916 }
0917 
0918 void K3b::VcdBurnDialog::slotGapsChecked( bool b )
0919 {
0920     m_labelPreGapLeadout->setEnabled( b );
0921     m_spinPreGapLeadout->setEnabled( b );
0922     m_labelPreGapTrack->setEnabled( b );
0923     m_spinPreGapTrack->setEnabled( b );
0924     MarginChecked( b );
0925 }
0926 
0927 void K3b::VcdBurnDialog::MarginChecked( bool b )
0928 {
0929     if ( m_radioSvcd10->isChecked() || m_radioHqVcd10->isChecked() ) {
0930         m_spinFrontMarginTrack->setHidden( true );
0931         m_spinFrontMarginTrackSVCD->setHidden( false );
0932         m_spinRearMarginTrack->setHidden( true );
0933         m_spinRearMarginTrackSVCD->setHidden( false );
0934     } else {
0935         m_spinFrontMarginTrack->setHidden( false );
0936         m_spinFrontMarginTrackSVCD->setHidden( true );
0937         m_spinRearMarginTrack->setHidden( false );
0938         m_spinRearMarginTrackSVCD->setHidden( true );
0939     }
0940 
0941     m_labelFrontMarginTrack->setEnabled( b );
0942     m_spinFrontMarginTrack->setEnabled( b );
0943     m_spinFrontMarginTrackSVCD->setEnabled( b );
0944 
0945     m_labelRearMarginTrack->setEnabled( b );
0946     m_spinRearMarginTrack->setEnabled( b );
0947     m_spinRearMarginTrackSVCD->setEnabled( b );
0948 
0949 }
0950 
0951 void K3b::VcdBurnDialog::slotCdiSupportChecked( bool b )
0952 {
0953     m_groupCdi->setEnabled( b );
0954 }
0955 
0956 void K3b::VcdBurnDialog::slotAutoDetect( bool b )
0957 {
0958     if ( b ) {
0959         switch( vcdDoc() ->vcdOptions() ->mpegVersion() ) {
0960         case K3b::VcdOptions::VCD11:
0961             m_radioVcd11->setChecked( true );
0962             break;
0963         case K3b::VcdOptions::VCD20:
0964             m_radioVcd20->setChecked( true );
0965             break;
0966         case K3b::VcdOptions::SVCD10:
0967             m_radioSvcd10->setChecked( true );
0968             break;
0969         case K3b::VcdOptions::HQVCD10:
0970             m_radioHqVcd10->setChecked( true );
0971             break;
0972         }
0973 
0974         slotVcdTypeClicked( vcdDoc() ->vcdOptions() ->mpegVersion() );
0975     }
0976 
0977     m_groupVcdFormat->setDisabled( b );
0978 
0979 }
0980 
0981 void K3b::VcdBurnDialog::toggleAll()
0982 {
0983     K3b::ProjectBurnDialog::toggleAll();
0984 
0985     m_writingModeWidget->setSupportedModes( K3b::WritingModeSao );
0986     m_checkRemoveBufferFiles->setDisabled( m_checkOnlyCreateImage->isChecked() );
0987 }
0988 
0989 #include "moc_k3bvcdburndialog.cpp"