File indexing completed on 2024-05-05 04:51:36
0001 /* 0002 SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 #include "k3badvancedoptiontab.h" 0006 #include "k3bmsfedit.h" 0007 #include "k3bcore.h" 0008 #include "k3bstdguiitems.h" 0009 #include "k3bglobalsettings.h" 0010 0011 #include <KConfig> 0012 #include <KConfigGroup> 0013 #include <KSharedConfig> 0014 #include <KLineEdit> 0015 #include <KLocalizedString> 0016 0017 #include <QValidator> 0018 #include <QCheckBox> 0019 #include <QComboBox> 0020 #include <QGroupBox> 0021 #include <QLabel> 0022 #include <QLayout> 0023 #include <QRadioButton> 0024 #include <QSpinBox> 0025 #include <QTabWidget> 0026 #include <QToolTip> 0027 0028 0029 K3b::AdvancedOptionTab::AdvancedOptionTab( QWidget* parent ) 0030 : QWidget( parent ) 0031 { 0032 setupGui(); 0033 } 0034 0035 0036 K3b::AdvancedOptionTab::~AdvancedOptionTab() 0037 { 0038 } 0039 0040 0041 void K3b::AdvancedOptionTab::setupGui() 0042 { 0043 QGridLayout* groupAdvancedLayout = new QGridLayout( this ); 0044 groupAdvancedLayout->setAlignment( Qt::AlignTop ); 0045 groupAdvancedLayout->setContentsMargins( 0, 0, 0, 0 ); 0046 0047 0048 QGroupBox* groupWritingApp = new QGroupBox( i18n("Burning"), this ); 0049 QGridLayout* bufferLayout = new QGridLayout( groupWritingApp ); 0050 0051 m_checkBurnfree = K3b::StdGuiItems::burnproofCheckbox( groupWritingApp ); 0052 m_checkOverburn = new QCheckBox( i18n("Allow &overburning"), groupWritingApp ); 0053 m_checkForceUnsafeOperations = new QCheckBox( i18n("&Force unsafe operations"), groupWritingApp ); 0054 m_checkManualWritingBufferSize = new QCheckBox( i18n("&Manual writing buffer size") + ':', groupWritingApp ); 0055 m_editWritingBufferSize = new QSpinBox( groupWritingApp ); 0056 m_editWritingBufferSize->setRange( 1, 100 ); 0057 m_editWritingBufferSize->setValue( 4 ); 0058 m_editWritingBufferSize->setSuffix( ' ' + i18n("MB") ); 0059 m_checkShowForceGuiElements = new QCheckBox( i18n("Show &advanced GUI elements"), groupWritingApp ); 0060 bufferLayout->addWidget( m_checkBurnfree, 0, 0, 1, 3 ); 0061 bufferLayout->addWidget( m_checkOverburn, 1, 0, 1, 2 ); 0062 bufferLayout->addWidget( m_checkForceUnsafeOperations, 2, 0, 1, 3 ); 0063 bufferLayout->addWidget( m_checkManualWritingBufferSize, 3, 0 ); 0064 bufferLayout->addWidget( m_editWritingBufferSize, 3, 1 ); 0065 bufferLayout->addWidget( m_checkShowForceGuiElements, 4, 0, 1, 3 ); 0066 bufferLayout->setColumnStretch( 2, 1 ); 0067 0068 QGroupBox* groupMisc = new QGroupBox( i18n("Miscellaneous"), this ); 0069 QVBoxLayout* groupMiscLayout = new QVBoxLayout( groupMisc ); 0070 m_checkEject = new QCheckBox( i18n("Do not &eject medium after write process"), groupMisc ); 0071 groupMiscLayout->addWidget( m_checkEject ); 0072 m_checkAutoErasingRewritable = new QCheckBox( i18n("Automatically erase CD-RWs and DVD-RWs"), groupMisc ); 0073 groupMiscLayout->addWidget( m_checkAutoErasingRewritable ); 0074 0075 groupAdvancedLayout->addWidget( groupWritingApp, 0, 0 ); 0076 groupAdvancedLayout->addWidget( groupMisc, 1, 0 ); 0077 groupAdvancedLayout->setRowStretch( 2, 1 ); 0078 0079 0080 connect( m_checkManualWritingBufferSize, SIGNAL(toggled(bool)), 0081 m_editWritingBufferSize, SLOT(setEnabled(bool)) ); 0082 connect( m_checkManualWritingBufferSize, SIGNAL(toggled(bool)), 0083 this, SLOT(slotSetDefaultBufferSizes(bool)) ); 0084 0085 0086 m_editWritingBufferSize->setDisabled( true ); 0087 // ----------------------------------------------------------------------- 0088 0089 0090 m_checkOverburn->setToolTip( i18n("Allow burning more than the official media capacities") ); 0091 m_checkShowForceGuiElements->setToolTip( i18n("Show advanced GUI elements like allowing to choose between cdrecord and cdrdao") ); 0092 m_checkAutoErasingRewritable->setToolTip( i18n("Automatically erase CD-RWs and DVD-RWs without asking") ); 0093 m_checkEject->setToolTip( i18n("Do not eject the burn medium after a completed burn process") ); 0094 m_checkForceUnsafeOperations->setToolTip( i18n("Force K3b to continue some operations otherwise deemed as unsafe") ); 0095 0096 m_checkShowForceGuiElements->setWhatsThis( i18n("<p>If this option is checked additional GUI " 0097 "elements which allow one to influence the behavior of K3b are shown. " 0098 "This includes the manual selection of the used burning tool. " 0099 "(Choose between cdrecord and cdrdao when writing a CD or between " 0100 "cdrecord and growisofs when writing a DVD/BD.)" 0101 "<p><b>Be aware that K3b does not support all possible tools " 0102 "in all project types and actions.</b>") ); 0103 0104 m_checkOverburn->setWhatsThis( i18n("<p>Each medium has an official maximum capacity which is stored in a read-only " 0105 "area of the medium and is guaranteed by the vendor. However, this official " 0106 "maximum is not always the actual maximum. Many media have an " 0107 "actual total capacity that is slightly larger than the official amount." 0108 "<p>If this option is checked K3b will disable a safety check that prevents " 0109 "burning beyond the official capacity." 0110 "<p><b>Caution:</b> Enabling this option can cause failures in the end of the " 0111 "burning process if K3b attempts to write beyond the official capacity. It " 0112 "makes sense to first determine the actual maximum capacity of the media brand " 0113 "with a simulated burn.") ); 0114 0115 m_checkAutoErasingRewritable->setWhatsThis( i18n("<p>If this option is checked K3b will automatically " 0116 "erase CD-RWs and format DVD-RWs if one is found instead " 0117 "of an empty media before writing.") ); 0118 0119 m_checkManualWritingBufferSize->setWhatsThis( i18n("<p>K3b uses a software buffer during the burning process to " 0120 "avoid gaps in the data stream due to high system load. The default " 0121 "sizes used are %1 MB for CD and %2 MB for DVD burning." 0122 "<p>If this option is checked the value specified will be used for both " 0123 "CD and DVD burning.", 4, 32) ); 0124 0125 m_checkEject->setWhatsThis( i18n("<p>If this option is checked K3b will not eject the medium once the burn process " 0126 "finishes. This can be helpful in case one leaves the computer after starting the " 0127 "burning and does not want the tray to be open all the time." 0128 "<p>However, on Linux systems a freshly burned medium has to be reloaded. Otherwise " 0129 "the system will not detect the changes and still treat it as an empty medium.") ); 0130 0131 m_checkForceUnsafeOperations->setWhatsThis( i18n("<p>If this option is checked K3b will continue in some situations " 0132 "which would otherwise be deemed as unsafe." 0133 "<p>This setting for example disables the check for medium speed " 0134 "verification. Thus, one can force K3b to burn a high speed medium on " 0135 "a low speed writer." 0136 "<p><b>Caution:</b> Enabling this option may result in damaged media.") ); 0137 } 0138 0139 0140 void K3b::AdvancedOptionTab::readSettings() 0141 { 0142 KConfigGroup c( KSharedConfig::openConfig(), QStringLiteral("General Options") ); 0143 0144 m_checkAutoErasingRewritable->setChecked( c.readEntry( "auto rewritable erasing", false ) ); 0145 m_checkShowForceGuiElements->setChecked( c.readEntry( "Show advanced GUI", false ) ); 0146 0147 m_checkBurnfree->setChecked( k3bcore->globalSettings()->burnfree() ); 0148 m_checkEject->setChecked( !k3bcore->globalSettings()->ejectMedia() ); 0149 m_checkOverburn->setChecked( k3bcore->globalSettings()->overburn() ); 0150 m_checkForceUnsafeOperations->setChecked( k3bcore->globalSettings()->force() ); 0151 m_checkManualWritingBufferSize->setChecked( k3bcore->globalSettings()->useManualBufferSize() ); 0152 if( k3bcore->globalSettings()->useManualBufferSize() ) 0153 m_editWritingBufferSize->setValue( k3bcore->globalSettings()->bufferSize() ); 0154 } 0155 0156 0157 void K3b::AdvancedOptionTab::saveSettings() 0158 { 0159 KConfigGroup c( KSharedConfig::openConfig(), QStringLiteral("General Options") ); 0160 0161 c.writeEntry( "auto rewritable erasing", m_checkAutoErasingRewritable->isChecked() ); 0162 c.writeEntry( "Show advanced GUI", m_checkShowForceGuiElements->isChecked() ); 0163 0164 k3bcore->globalSettings()->setEjectMedia( !m_checkEject->isChecked() ); 0165 k3bcore->globalSettings()->setOverburn( m_checkOverburn->isChecked() ); 0166 k3bcore->globalSettings()->setBurnfree( m_checkBurnfree->isChecked() ); 0167 k3bcore->globalSettings()->setUseManualBufferSize( m_checkManualWritingBufferSize->isChecked() ); 0168 k3bcore->globalSettings()->setBufferSize( m_editWritingBufferSize->value() ); 0169 k3bcore->globalSettings()->setForce( m_checkForceUnsafeOperations->isChecked() ); 0170 } 0171 0172 0173 void K3b::AdvancedOptionTab::slotSetDefaultBufferSizes( bool b ) 0174 { 0175 if( !b ) { 0176 m_editWritingBufferSize->setValue( 4 ); 0177 } 0178 } 0179 0180 #include "moc_k3badvancedoptiontab.cpp"