File indexing completed on 2024-04-14 04:45:10

0001 /*
0002     SPDX-FileCopyrightText: 1998-2008 Sebastian Trueg <trueg@k3b.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 
0008 #include "k3bdatamodewidget.h"
0009 #include "k3bglobals.h"
0010 
0011 #include <KConfig>
0012 #include <KLocalizedString>
0013 #include <QToolTip>
0014 
0015 static const int s_autoIndex = 0;
0016 static const int s_mode1Index = 1;
0017 static const int s_mode2Index = 2;
0018 
0019 
0020 K3b::DataModeWidget::DataModeWidget( QWidget* parent )
0021     : QComboBox( parent )
0022 {
0023     insertItem( s_autoIndex, i18n("Auto") );
0024     insertItem( s_mode1Index, i18n("Mode1") );
0025     insertItem( s_mode2Index, i18n("Mode2") );
0026 
0027     this->setToolTip(i18n("Select the mode for the data-track") );
0028     this->setWhatsThis( i18n("<p><b>Data Mode</b>"
0029                              "<p>Data tracks may be written in two different modes:</p>"
0030                              "<p><b>Auto</b><br>"
0031                              "Let K3b select the best suited data mode.</p>"
0032                              "<p><b>Mode 1</b><br>"
0033                              "This is the <em>original</em> writing mode as introduced in the "
0034                              "<em>Yellow Book</em> standard. It is the preferred mode when writing "
0035                              "pure data CDs.</p>"
0036                              "<p><b>Mode 2</b><br>"
0037                              "To be exact <em>XA Mode 2 Form 1</em>, but since the "
0038                              "other modes are rarely used it is common to refer to it as <em>Mode 2</em>.</p>"
0039                              "<p><b>Be aware:</b> Do not mix different modes on one CD. "
0040                              "Some older drives may have problems reading mode 1 multisession CDs.") );
0041 }
0042 
0043 
0044 K3b::DataModeWidget::~DataModeWidget()
0045 {
0046 }
0047 
0048 
0049 int K3b::DataModeWidget::dataMode() const
0050 {
0051     if( currentIndex() == s_autoIndex )
0052         return K3b::DataModeAuto;
0053     else if( currentIndex() == s_mode1Index )
0054         return K3b::DataMode1;
0055     else
0056         return K3b::DataMode2;
0057 }
0058 
0059 
0060 void K3b::DataModeWidget::setDataMode( int mode )
0061 {
0062     if( mode == K3b::DataMode1 )
0063         setCurrentIndex( s_mode1Index );
0064     else if( mode == K3b::DataMode2 )
0065         setCurrentIndex( s_mode2Index );
0066     else
0067         setCurrentIndex( s_autoIndex );
0068 }
0069 
0070 
0071 void K3b::DataModeWidget::saveConfig( KConfigGroup c )
0072 {
0073     QString datamode;
0074     if( dataMode() == K3b::DataMode1 )
0075         datamode = "mode1";
0076     else if( dataMode() == K3b::DataMode2 )
0077         datamode = "mode2";
0078     else
0079         datamode = "auto";
0080     c.writeEntry( "data_track_mode", datamode );
0081 }
0082 
0083 
0084 void K3b::DataModeWidget::loadConfig( const KConfigGroup& c )
0085 {
0086     QString datamode = c.readEntry( "data_track_mode" );
0087     if( datamode == "mode1" )
0088         setDataMode( K3b::DataMode1 );
0089     else if( datamode == "mode2" )
0090         setDataMode( K3b::DataMode2 );
0091     else
0092         setDataMode( K3b::DataModeAuto );
0093 }
0094 
0095 #include "moc_k3bdatamodewidget.cpp"