1 /* 2 SPDX-FileCopyrightText: 1998-2008 Sebastian Trueg <trueg@k3b.org> 3 4 SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7 8 #include "k3bdatamodewidget.h" 9 #include "k3bglobals.h" 10 11 #include <KConfig> 12 #include <KLocalizedString> 13 #include <QToolTip> 14 15 static const int s_autoIndex = 0; 16 static const int s_mode1Index = 1; 17 static const int s_mode2Index = 2; 18 19 DataModeWidget(QWidget * parent)20K3b::DataModeWidget::DataModeWidget( QWidget* parent ) 21 : QComboBox( parent ) 22 { 23 insertItem( s_autoIndex, i18n("Auto") ); 24 insertItem( s_mode1Index, i18n("Mode1") ); 25 insertItem( s_mode2Index, i18n("Mode2") ); 26 27 this->setToolTip(i18n("Select the mode for the data-track") ); 28 this->setWhatsThis( i18n("<p><b>Data Mode</b>" 29 "<p>Data tracks may be written in two different modes:</p>" 30 "<p><b>Auto</b><br>" 31 "Let K3b select the best suited data mode.</p>" 32 "<p><b>Mode 1</b><br>" 33 "This is the <em>original</em> writing mode as introduced in the " 34 "<em>Yellow Book</em> standard. It is the preferred mode when writing " 35 "pure data CDs.</p>" 36 "<p><b>Mode 2</b><br>" 37 "To be exact <em>XA Mode 2 Form 1</em>, but since the " 38 "other modes are rarely used it is common to refer to it as <em>Mode 2</em>.</p>" 39 "<p><b>Be aware:</b> Do not mix different modes on one CD. " 40 "Some older drives may have problems reading mode 1 multisession CDs.") ); 41 } 42 43 ~DataModeWidget()44K3b::DataModeWidget::~DataModeWidget() 45 { 46 } 47 48 dataMode() const49int K3b::DataModeWidget::dataMode() const 50 { 51 if( currentIndex() == s_autoIndex ) 52 return K3b::DataModeAuto; 53 else if( currentIndex() == s_mode1Index ) 54 return K3b::DataMode1; 55 else 56 return K3b::DataMode2; 57 } 58 59 setDataMode(int mode)60void K3b::DataModeWidget::setDataMode( int mode ) 61 { 62 if( mode == K3b::DataMode1 ) 63 setCurrentIndex( s_mode1Index ); 64 else if( mode == K3b::DataMode2 ) 65 setCurrentIndex( s_mode2Index ); 66 else 67 setCurrentIndex( s_autoIndex ); 68 } 69 70 saveConfig(KConfigGroup c)71void K3b::DataModeWidget::saveConfig( KConfigGroup c ) 72 { 73 QString datamode; 74 if( dataMode() == K3b::DataMode1 ) 75 datamode = "mode1"; 76 else if( dataMode() == K3b::DataMode2 ) 77 datamode = "mode2"; 78 else 79 datamode = "auto"; 80 c.writeEntry( "data_track_mode", datamode ); 81 } 82 83 loadConfig(const KConfigGroup & c)84void K3b::DataModeWidget::loadConfig( const KConfigGroup& c ) 85 { 86 QString datamode = c.readEntry( "data_track_mode" ); 87 if( datamode == "mode1" ) 88 setDataMode( K3b::DataMode1 ); 89 else if( datamode == "mode2" ) 90 setDataMode( K3b::DataMode2 ); 91 else 92 setDataMode( K3b::DataModeAuto ); 93 } 94 95 96