00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "floppy.h"
00025 #include "format.h"
00026
00027 #include <QCheckBox>
00028 #include <QLabel>
00029 #include <qcursor.h>
00030 #include <qradiobutton.h>
00031 #include <q3buttongroup.h>
00032
00033 #include <QVBoxLayout>
00034 #include <QFrame>
00035 #include <QHBoxLayout>
00036 #include <QGridLayout>
00037 #include <QKeyEvent>
00038 #include <QCloseEvent>
00039 #include <QtDBus/QtDBus>
00040 #include <kconfig.h>
00041
00042 #include <kmessagebox.h>
00043 #include <kdebug.h>
00044 #include <khelpmenu.h>
00045 #include <kpushbutton.h>
00046 #include <kmenu.h>
00047 #include <kapplication.h>
00048 #include <qprogressbar.h>
00049 #include <klocale.h>
00050 #include <kcombobox.h>
00051 #include <klineedit.h>
00052 #include <kurl.h>
00053 #include <ktoolinvocation.h>
00054 #include <kglobal.h>
00055
00056 FloppyData::FloppyData(QWidget * parent)
00057 : KDialog( parent ),
00058 formatActions(0L), m_canLowLevel(false), m_canZeroOut( false )
00059 {
00060 QWidget *widget = new QWidget(this);
00061 setMainWidget(widget);
00062 setButtons(None);
00063 formating = false;
00064
00065 blocks = 0;
00066
00067 QVBoxLayout* ml = new QVBoxLayout( widget );
00068 ml->setSpacing( 10 );
00069
00070 QHBoxLayout* h1 = new QHBoxLayout();
00071 ml->addItem( h1 );
00072
00073 QVBoxLayout* v1 = new QVBoxLayout( );
00074 h1->addItem( v1 );
00075 h1->addSpacing( 5 );
00076
00077 QGridLayout* g1 = new QGridLayout();
00078 v1->addItem( g1 );
00079
00080 deviceComboBox = new KComboBox( false, widget );
00081 label1 = new QLabel( i18n("Floppy &drive:"), widget );
00082 label1->setBuddy( deviceComboBox );
00083 g1->addWidget( label1, 0, 0, Qt::AlignLeft );
00084 g1->addWidget( deviceComboBox, 0, 1 );
00085
00086
00087 deviceComboBox->setEditable( true );
00088
00089 deviceComboBox->addItem(i18nc("Primary floppy drive", "Primary"));
00090 deviceComboBox->addItem(i18nc("Secondary floppy drive", "Secondary"));
00091
00092 const QString deviceWhatsThis = i18n("<qt>Select the floppy drive.</qt>");
00093
00094 label1->setWhatsThis( deviceWhatsThis);
00095 deviceComboBox->setWhatsThis( deviceWhatsThis);
00096
00097
00098 densityComboBox = new KComboBox( false, widget );
00099 label2 = new QLabel( i18n("&Size:"), widget);
00100 label2->setBuddy( densityComboBox );
00101 g1->addWidget( label2, 1, 0, Qt::AlignLeft );
00102 g1->addWidget( densityComboBox, 1, 1 );
00103
00104 #if defined(ANY_LINUX)
00105 densityComboBox->addItem( i18n( "Auto-Detect" ) );
00106 #endif
00107 densityComboBox->addItem(i18n("3.5\" 1.44MB"));
00108 densityComboBox->addItem(i18n("3.5\" 720KB"));
00109 densityComboBox->addItem(i18n("5.25\" 1.2MB"));
00110 densityComboBox->addItem(i18n("5.25\" 360KB"));
00111
00112 const QString densityWhatsThis =
00113 i18n("<qt>This allows you to select the "
00114 "floppy disk's size and density.</qt>");
00115
00116 label2->setWhatsThis( densityWhatsThis);
00117 densityComboBox->setWhatsThis( densityWhatsThis);
00118
00119
00120 filesystemComboBox = new KComboBox( false, widget );
00121 label3 = new QLabel( i18n("F&ile system:"), widget);
00122 label3->setBuddy( filesystemComboBox );
00123 g1->addWidget( label3, 2, 0, Qt::AlignLeft );
00124 g1->addWidget( filesystemComboBox, 2, 1 );
00125 g1->setColumnStretch(1, 1);
00126
00127 #if defined(ANY_LINUX)
00128 label3->setWhatsThis(
00129 i18nc( "Linux", "KFloppy supports three file formats under Linux: MS-DOS, Ext2, and Minix" ) );
00130 #elif defined(ANY_BSD)
00131 label3->setWhatsThis(
00132 i18nc( "BSD", "KFloppy supports three file formats under BSD: MS-DOS, UFS, and Ext2" ) );
00133 #endif
00134
00135
00136 QString userFeedBack;
00137 uint numFileSystems = 0;
00138
00139 #if defined(ANY_LINUX)
00140 filesystemComboBox->setWhatsThis(
00141 i18nc( "Linux", "KFloppy supports three file formats under Linux: MS-DOS, Ext2, and Minix" ) );
00142 if (FATFilesystem::runtimeCheck()) {
00143 filesystemComboBox->addItem(i18n("DOS"));
00144 ++numFileSystems;
00145 userFeedBack += i18nc( "Linux", "Program mkdosfs found." );
00146 }
00147 else {
00148 userFeedBack += i18nc( "Linux", "Program mkdosfs <b>not found</b>. MSDOS formatting <b>not available</b>." );
00149 }
00150 userFeedBack += "<br>";
00151 if (Ext2Filesystem::runtimeCheck()) {
00152 filesystemComboBox->addItem(i18n("ext2"));
00153 ++numFileSystems;
00154 userFeedBack += i18n( "Program mke2fs found." );
00155 }
00156 else {
00157 userFeedBack += i18n( "Program mke2fs <b>not found</b>. Ext2 formatting <b>not available</b>" );
00158 }
00159 userFeedBack += "<br>";
00160 if (MinixFilesystem::runtimeCheck()) {
00161 filesystemComboBox->addItem(i18n("Minix"));
00162 ++numFileSystems;
00163 userFeedBack += i18nc( "Linux", "Program mkfs.minix found." );
00164 }
00165 else {
00166 userFeedBack += i18nc( "Linux", "Program mkfs.minix <b>not found</b>. Minix formatting <b>not available</b>" );
00167 }
00168 #elif defined(ANY_BSD)
00169 filesystemComboBox->setWhatsThis(
00170 i18nc( "BSD", "KFloppy supports two file formats under BSD: MS-DOS and UFS" ) );
00171 if (FATFilesystem::runtimeCheck()) {
00172 filesystemComboBox->addItem(i18n("DOS"));
00173 ++numFileSystems;
00174 userFeedBack += i18nc( "BSD", "Program newfs_msdos found." );
00175 }
00176 else {
00177 userFeedBack += i18nc( "BSD", "Program newfs_msdos <b>not found</b>. MSDOS formatting <b>not available</b>." );
00178 }
00179 userFeedBack += "<br>";
00180 if (UFSFilesystem::runtimeCheck()) {
00181 filesystemComboBox->addItem(i18n("UFS"));
00182 ++numFileSystems;
00183 userFeedBack += i18nc( "BSD", "Program newfs found." );
00184 }
00185 else {
00186 userFeedBack += i18nc( "BSD", "Program newfs <b>not found</b>. UFS formatting <b>not available</b>." );
00187 }
00188 userFeedBack += "<br>";
00189 if (Ext2Filesystem::runtimeCheck()) {
00190 filesystemComboBox->addItem(i18n("ext2"));
00191 ++numFileSystems;
00192 userFeedBack += i18n( "Program mke2fs found." );
00193 }
00194 else {
00195 userFeedBack += i18n( "Program mke2fs <b>not found</b>. Ext2 formatting <b>not available</b>" );
00196 }
00197 #endif
00198
00199 v1->addSpacing( 10 );
00200
00201 buttongroup = new QGroupBox( i18n("&Formatting"), this );
00202 QVBoxLayout* buttonGroupLayout = new QVBoxLayout(buttongroup);
00203
00204 quick = new QRadioButton( i18n( "Q&uick format" ), buttongroup );
00205 buttonGroupLayout->addWidget(quick);
00206 quick->setObjectName( "RadioButton_2" );
00207 quick->setWhatsThis(
00208 i18n("<qt>Quick format is only a high-level format:"
00209 " it creates only a file system.</qt>") );
00210
00211 zerooutformat = new QRadioButton( i18n( "&Zero out and quick format"), buttongroup );
00212 buttonGroupLayout->addWidget(zerooutformat);
00213 zerooutformat->setObjectName( "RadioButton_ZeroOutFormat" );
00214 zerooutformat->setWhatsThis(
00215 i18n("<qt>This first erases the floppy by writing zeros and then it creates the file system.</qt>") );
00216
00217 fullformat = new QRadioButton( i18n( "Fu&ll format"), buttongroup );
00218 buttonGroupLayout->addWidget(fullformat);
00219 fullformat->setObjectName( "RadioButton_3" );
00220 fullformat->setWhatsThis(
00221 i18n("Full format is a low-level and high-level format. It erases everything on the disk.") );
00222
00223 v1->addWidget( buttongroup );
00224
00225
00226 userFeedBack += "<br>";
00227 m_canLowLevel = FDFormat::runtimeCheck();
00228 if (m_canLowLevel){
00229 fullformat->setChecked(true);
00230 userFeedBack += i18n( "Program fdformat found." );
00231 }
00232 else {
00233 fullformat->setDisabled(true);
00234 quick->setChecked(true);
00235 userFeedBack += i18n( "Program fdformat <b>not found</b>. Full formatting <b>disabled</b>." );
00236 }
00237 userFeedBack += "<br>";
00238 m_canZeroOut = DDZeroOut::runtimeCheck();
00239 if ( m_canZeroOut )
00240 {
00241 zerooutformat->setChecked( true );
00242 userFeedBack += i18n( "Program dd found." );
00243 }
00244 else {
00245 zerooutformat->setDisabled(true);
00246 userFeedBack += i18n( "Program dd <b>not found</b>. Zeroing-out <b>disabled</b>." );
00247 }
00248
00249 verifylabel = new QCheckBox( this );
00250 verifylabel->setObjectName( "CheckBox_Integrity" );
00251 verifylabel->setText(i18n( "&Verify integrity" ));
00252 verifylabel->setChecked(true);
00253 v1->addWidget( verifylabel, Qt::AlignLeft );
00254 verifylabel->setWhatsThis(
00255 i18n("<qt>Check this if you want the floppy disk to be checked after formatting."
00256 " Please note that the floppy will be checked twice if you have selected full formatting.</qt>") );
00257
00258 labellabel = new QCheckBox( this );
00259 labellabel->setObjectName( "Checkbox_Label" );
00260 labellabel->setText(i18n( "Volume la&bel:") );
00261 labellabel->setChecked(true);
00262 v1->addWidget( labellabel, Qt::AlignLeft );
00263 labellabel->setWhatsThis(
00264 i18n("<qt>Check this if you want a volume label for your floppy."
00265 " Please note that Minix does not support labels at all.</qt>") );
00266
00267 QHBoxLayout* h2 = new QHBoxLayout();
00268 v1->addItem( h2 );
00269 h2->addSpacing( 20 );
00270
00271 lineedit = new KLineEdit( widget );
00272
00273 lineedit->setText(i18nc( "Volume label, maximal 11 characters", "KDE Floppy" ) );
00274 lineedit->setMaxLength(11);
00275 h2->addWidget( lineedit, Qt::AlignRight );
00276 lineedit->setWhatsThis(
00277 i18n("<qt>This is for the volume label."
00278 " Due to a limitation of MS-DOS the label can only be 11 characters long."
00279 " Please note that Minix does not support labels, whatever you enter here.</qt>") );
00280
00281 connect(labellabel,SIGNAL(toggled(bool)),lineedit,SLOT(setEnabled(bool)));
00282
00283 QVBoxLayout* v3 = new QVBoxLayout();
00284 h1->addItem( v3 );
00285
00286 formatbutton = new KPushButton( widget );
00287 formatbutton->setText(i18n( "&Format") );
00288 formatbutton->setAutoRepeat( false );
00289 if (!numFileSystems)
00290 formatbutton->setDisabled(false);
00291 connect(formatbutton,SIGNAL(clicked()),this,SLOT(format()));
00292 v3->addWidget( formatbutton );
00293 formatbutton->setWhatsThis(
00294 i18n("<qt>Click here to start formatting.</qt>") );
00295
00296 v3->addStretch( 1 );
00297
00298
00299 helpMenu = new KHelpMenu(this, KGlobal::mainComponent().aboutData(), false);
00300
00301 helpbutton = new KPushButton( KStandardGuiItem::help(), widget );
00302 helpbutton->setAutoRepeat( false );
00303 helpbutton->setMenu(helpMenu->menu());
00304 v3->addWidget( helpbutton );
00305
00306 quitbutton = new KPushButton( KStandardGuiItem::quit(), widget );
00307 quitbutton->setAutoRepeat( false );
00308 connect(quitbutton,SIGNAL(clicked()),this,SLOT(quit()));
00309 v3->addWidget( quitbutton );
00310
00311 ml->addSpacing( 10 );
00312
00313 frame = new QLabel( widget );
00314 frame->setObjectName( "NewsWindow" );
00315 frame->setFrameStyle(QFrame::Panel | QFrame::Sunken);
00316 frame->setWordWrap( true );
00317 frame->setWhatsThis(
00318 i18n("<qt>This is the status window, where error messages are displayed.</qt>") );
00319
00320 QString frameText( userFeedBack );
00321 frameText.prepend( "<qt>" );
00322 frameText.append( "</qt>" );
00323 frame->setText( frameText );
00324
00325 ml->addWidget( frame );
00326
00327 progress = new QProgressBar( widget );
00328 progress->setDisabled( true );
00329 ml->addWidget( progress );
00330
00331 progress->setWhatsThis(
00332 i18n("<qt>Shows progress of the format.</qt>"));
00333
00334 readSettings();
00335 setWidgets();
00336
00337 if (!numFileSystems) {
00338 QString errorMessage;
00339 errorMessage += "<qt>";
00340 errorMessage += i18n("KFloppy cannot find any of the needed programs for creating file systems; please check your installation.<br /><br />Log:");
00341 errorMessage += "<br>";
00342 errorMessage += userFeedBack;
00343 errorMessage += "</qt>";
00344 KMessageBox::error( this, errorMessage );
00345 }
00346 }
00347
00348
00349 FloppyData::~FloppyData()
00350 {
00351 delete formatActions;
00352 }
00353
00354 void FloppyData::closeEvent(QCloseEvent*)
00355 {
00356 quit();
00357 }
00358
00359 void FloppyData::keyPressEvent(QKeyEvent *e)
00360 {
00361 switch(e->key()) {
00362 case Qt::Key_F1:
00363 KToolInvocation::invokeHelp();
00364 break;
00365 default:
00366 KDialog::keyPressEvent(e);
00367 return;
00368 }
00369 }
00370
00371 void FloppyData::show() {
00372 setCaption(i18n("KDE Floppy Formatter"));
00373 KDialog::show();
00374 }
00375
00376 bool FloppyData::findDevice()
00377 {
00378
00379
00380 drive=-1;
00381 if( deviceComboBox->currentText() == i18nc("Primary floppy drive", "Primary") )
00382 {
00383 drive=0;
00384 }
00385 else if( deviceComboBox->currentText() == i18nc("Secondary floppy drive", "Secondary") )
00386 {
00387 drive=1;
00388 }
00389
00390 blocks=-1;
00391
00392 if( densityComboBox->currentText() == i18n("3.5\" 1.44MB")){
00393 blocks = 1440;
00394 }
00395 else
00396 if( densityComboBox->currentText() == i18n("3.5\" 720KB")){
00397 blocks = 720;
00398 }
00399 else
00400 if( densityComboBox->currentText() == i18n("5.25\" 1.2MB")){
00401 blocks = 1200;
00402 }
00403 else
00404 if( densityComboBox->currentText() == i18n("5.25\" 360KB")){
00405 blocks = 360;
00406 }
00407 #if defined(ANY_LINUX)
00408 else {
00409 blocks = 0;
00410 }
00411 #endif
00412
00413 return true;
00414 }
00415
00416 bool FloppyData::setInitialDevice(const QString& dev)
00417 {
00418
00419 QString newDevice = dev;
00420
00421 KUrl url( newDevice );
00422 if( url.isValid() && ( url.protocol() == "media" || url.protocol() == "system" ) ) {
00423 QString name = url.fileName();
00424
00425 QDBusInterface mediamanager( "org.kde.kded", "/modules/mediamanager", "org.kde.MediaManager" );
00426 QDBusReply<QStringList> reply = mediamanager.call( "properties", name );
00427 if (!reply.isValid()) {
00428 kError() << "Invalid reply from mediamanager" << endl;
00429 } else {
00430 QStringList properties = reply;
00431 newDevice = properties[5];
00432 }
00433 }
00434
00435 int drive = -1;
00436 if ( newDevice.startsWith("/dev/fd0") )
00437 drive = 0;
00438 if ( newDevice.startsWith("/dev/fd1"))
00439 drive = 1;
00440
00441
00442
00443 bool ok = (drive>=0);
00444 if (ok)
00445 deviceComboBox->setCurrentIndex(drive);
00446 return ok;
00447 }
00448
00449 void FloppyData::quit(){
00450 if (formatActions) formatActions->quit();
00451 writeSettings();
00452 kapp->quit();
00453 delete this;
00454 }
00455
00456 void FloppyData::setEnabled(bool b)
00457 {
00458 if (b)
00459 unsetCursor();
00460 else
00461 setCursor(QCursor(Qt::WaitCursor));
00462 label1->setEnabled(b);
00463 deviceComboBox->setEnabled(b);
00464 label2->setEnabled(b);
00465 densityComboBox->setEnabled(b);
00466 label3->setEnabled(b);
00467 filesystemComboBox->setEnabled(b);
00468 buttongroup->setEnabled(b);
00469 quick->setEnabled(b);
00470 fullformat->setEnabled(b && m_canLowLevel);
00471 zerooutformat->setEnabled(b && m_canZeroOut);
00472 verifylabel->setEnabled(b);
00473 labellabel->setEnabled(b);
00474 lineedit->setEnabled(b && labellabel->isChecked() );
00475 helpbutton->setEnabled(b);
00476 quitbutton->setEnabled(b);
00477 formatbutton->setEnabled(b);
00478 progress->setDisabled( b );
00479 }
00480
00481 void FloppyData::reset()
00482 {
00483 DEBUGSETUP;
00484
00485 formating = false;
00486
00487 if (formatActions)
00488 {
00489 formatActions->quit();
00490 delete formatActions;
00491 formatActions = 0L;
00492 }
00493
00494 progress->setValue(0);
00495 formatbutton->setText(i18n("&Format"));
00496 setEnabled(true);
00497 }
00498
00499 void FloppyData::format(){
00500
00501 if(formating){
00502
00503 reset();
00504 return;
00505 }
00506
00507 frame->clear();
00508
00509 const QString currentComboBoxDevice ( deviceComboBox->currentText() );
00510 const bool userDevice = ( currentComboBoxDevice.startsWith ("/dev/") );
00511
00512 #ifdef ANY_BSD
00513 if ( userDevice && filesystemComboBox->currentText() != i18n("UFS"))
00514 {
00515 KMessageBox::error( this, i18nc("BSD", "Formatting with BSD on a user-given device is only possible with UFS") );
00516 return;
00517 }
00518
00519 #endif
00520 if ( userDevice && ( quick->isChecked() || zerooutformat->isChecked() ) )
00521 {
00522 if (KMessageBox::warningContinueCancel( this,
00523 i18n("<qt>Formatting will erase all data on the device:<br/><b>%1</b><br/>"
00524 "(Please check the correctness of the device name.)<br/>"
00525 "Are you sure you wish to proceed?</qt>", currentComboBoxDevice )
00526 , i18n("Proceed?") ) != KMessageBox::Continue)
00527 {
00528 return;
00529 }
00530 }
00531 else if ( userDevice )
00532 {
00533
00534 KMessageBox::error( this, i18n("Full formatting of a user-given device is not possible!") );
00535 return;
00536 }
00537 else
00538 {
00539 if (KMessageBox::warningContinueCancel( this,
00540 i18n("Formatting will erase all data on the disk.\n"
00541 "Are you sure you wish to proceed?"), i18n("Proceed?") ) !=
00542 KMessageBox::Continue)
00543 {
00544 return;
00545 }
00546 }
00547
00548
00549 setEnabled(false);
00550
00551
00552 frame->setText( QString::null );
00553
00554 if ( !userDevice )
00555 {
00556 if ( !findDevice() )
00557 {
00558 reset();
00559 return;
00560 }
00561 }
00562
00563 if (formatActions) delete formatActions;
00564 formatActions = new KFActionQueue(this);
00565
00566 connect(formatActions,SIGNAL(status(const QString &,int)),
00567 this,SLOT(formatStatus(const QString &,int)));
00568 connect(formatActions,SIGNAL(done(KFAction *,bool)),
00569 this,SLOT(reset()));
00570
00571 if ( quick->isChecked())
00572 {
00573 formating=false;
00574
00575 }
00576 else if ( zerooutformat->isChecked() )
00577 {
00578 DDZeroOut* f = new DDZeroOut( this );
00579 if ( userDevice )
00580 {
00581 f->configureDevice( currentComboBoxDevice );
00582 }
00583 else
00584 {
00585 f->configureDevice( drive, blocks );
00586 }
00587 formatActions->queue(f);
00588 }
00589 else if ( userDevice )
00590 {
00591
00592 formating=false;
00593
00594 }
00595 else
00596 {
00597 FDFormat *f = new FDFormat(this);
00598 f->configureDevice(drive,blocks);
00599 f->configure(verifylabel->isChecked());
00600 formatActions->queue(f);
00601 }
00602
00603 if ( filesystemComboBox->currentText() == i18n("DOS") )
00604 {
00605 FATFilesystem *f = new FATFilesystem(this);
00606 f->configure(verifylabel->isChecked(),
00607 labellabel->isChecked(),
00608 lineedit->text());
00609 if ( userDevice )
00610 {
00611 f->configureDevice( currentComboBoxDevice );
00612 }
00613 else
00614 {
00615 f->configureDevice(drive,blocks);
00616 }
00617 formatActions->queue(f);
00618 }
00619
00620 else if ( filesystemComboBox->currentText() == i18n("ext2") )
00621 {
00622 Ext2Filesystem *f = new Ext2Filesystem(this);
00623 f->configure(verifylabel->isChecked(),
00624 labellabel->isChecked(),
00625 lineedit->text());
00626 if ( userDevice )
00627 {
00628 f->configureDevice( currentComboBoxDevice );
00629 }
00630 else
00631 {
00632 f->configureDevice(drive,blocks);
00633 }
00634 formatActions->queue(f);
00635 }
00636
00637 #ifdef ANY_BSD
00638 else if ( filesystemComboBox->currentText() == i18n("UFS") )
00639 {
00640 FloppyAction *f = new UFSFilesystem(this);
00641 f->configureDevice(drive,blocks);
00642 formatActions->queue(f);
00643 }
00644 #endif
00645
00646 #ifdef ANY_LINUX
00647 else if ( filesystemComboBox->currentText() == i18n("Minix") )
00648 {
00649 MinixFilesystem *f = new MinixFilesystem(this);
00650 f->configure(verifylabel->isChecked(),
00651 labellabel->isChecked(),
00652 lineedit->text());
00653 if ( userDevice )
00654 {
00655 f->configureDevice( currentComboBoxDevice );
00656 }
00657 else
00658 {
00659 f->configureDevice(drive,blocks);
00660 }
00661 formatActions->queue(f);
00662 }
00663 #endif
00664
00665 formatActions->exec();
00666 }
00667
00668 void FloppyData::formatStatus(const QString &s,int p)
00669 {
00670 kDebug(2002) << "FloppyData::formatStatus: " << s << " : " << p ;
00671 if (!s.isEmpty())
00672 {
00673 const QString oldText ( frame->text() );
00674 if ( oldText.isEmpty() )
00675 {
00676 frame->setText( s );
00677 }
00678 else
00679 {
00680 frame->setText( oldText + '\n' + s );
00681 }
00682 }
00683
00684 if ((0<=p) && (p<=100))
00685 progress->setValue(p);
00686 }
00687
00688 void FloppyData::writeSettings(){
00689
00690 KConfigGroup config = KGlobal::config()->group("GeneralData");
00691
00692 densityconfig = densityComboBox->currentText().trimmed();
00693 filesystemconfig = filesystemComboBox->currentText().trimmed();
00694 driveconfig = deviceComboBox->currentText().trimmed();
00695
00696 quickformatconfig = quick->isChecked();
00697
00698 labelnameconfig = lineedit->text().trimmed();
00699
00700 labelconfig = labellabel->isChecked();
00701
00702 verifyconfig = verifylabel->isChecked();
00703
00704 config.writeEntry("CreateLabel",labelconfig);
00705 config.writeEntry("Label",labelnameconfig);
00706
00707
00708 config.writeEntry("QuickFormat",quickformatconfig);
00709 config.writeEntry("FloppyDrive",driveconfig);
00710 config.writeEntry("Density",densityconfig);
00711 config.writeEntry("Filesystem",filesystemconfig);
00712 config.writeEntry("Verify",verifyconfig);
00713 config.sync();
00714 }
00715
00716 void FloppyData::readSettings(){
00717
00718 KConfigGroup config = KGlobal::config()->group("GeneralData");
00719
00720 verifyconfig = config.readEntry("Verify", 1);
00721 labelconfig = config.readEntry("CreateLabel",1);
00722 labelnameconfig = config.readEntry( "Label", i18nc("Volume label, maximal 11 characters", "KDE Floppy") );
00723 quickformatconfig = config.readEntry("QuickFormat",0);
00724 driveconfig = config.readEntry( "FloppyDrive", i18nc("Primary floppy drive", "Primary") );
00725 #if defined(ANY_LINUX)
00726 densityconfig = config.readEntry( "Density", i18n( "Auto-Detect" ) );
00727 #else
00728 densityconfig = config.readEntry( "Density", i18n("3.5\" 1.44MB") );
00729 #endif
00730 filesystemconfig = config.readEntry( "Filesystem", i18n("DOS") );
00731 }
00732
00733 void FloppyData::setWidgets(){
00734
00735 labellabel->setChecked(labelconfig);
00736 verifylabel->setChecked(verifyconfig);
00737 quick->setChecked(quickformatconfig || !m_canLowLevel);
00738 fullformat->setChecked(!quickformatconfig && m_canLowLevel);
00739 lineedit->setText(labelnameconfig);
00740
00741 for(int i = 0 ; i < deviceComboBox->count(); i++){
00742 if ( deviceComboBox->itemText(i) == driveconfig){
00743 deviceComboBox->setCurrentIndex(i);
00744 }
00745 }
00746
00747 for(int i = 0 ; i < filesystemComboBox->count(); i++){
00748 if ( filesystemComboBox->itemText(i) == filesystemconfig){
00749 filesystemComboBox->setCurrentIndex(i);
00750 }
00751 }
00752
00753 for(int i = 0 ; i < densityComboBox->count(); i++){
00754 if ( densityComboBox->itemText(i) == densityconfig){
00755 densityComboBox->setCurrentIndex(i);
00756 }
00757 }
00758 }
00759
00760 #include "floppy.moc"