void MainWidget::readSettings( ) { m_htmlWidget->readSettings( ); KConfig* config = kapp->config( ); config->setGroup( "General" ); m_stylesheetURLs = config->readListEntry( "stylesheetURLs" ); m_useLocalManPage = config->readBoolEntry( "useLocalManPage", false ); m_wrapText = config->readBoolEntry( "wrapText", false ); QValueList<int> splitterSizes = config->readIntListEntry( "splitterSizes" ); setSizes( splitterSizes ); QStringList scanNames = config->readListEntry( "scanNames" ); if( !scanNames.count( )) scanNames.append( "default" ); QString visibleScanName = config->readEntry( "visibleScan", QString::null ); ScanWidget* visibleScanWidget = NULL; for( QStringList::Iterator it = scanNames.begin( ); it != scanNames.end(); ++it ) { ScanWidget* scanWidget = createScan( *it, false, QString::null ); if( visibleScanName == scanWidget->scanName( )) visibleScanWidget = scanWidget; } if( visibleScanWidget == NULL ) { visibleScanWidget = m_scanStack->firstScanWidget( ); if( visibleScanWidget == NULL ) { KMessageBox::error( this, i18n( "Internal error - no ScanWidget to display!" ), i18n( "Internal error" )); kapp->quit( ); } } m_scanStack->raiseWidget( visibleScanWidget ); }
bool ScanDialog::setup() { if( ! m_device ) { good_scan_connect = false; return(false); } // The scan device is now closed on closing the scan dialog. That means // that more work to open it needs to be done in the setup slot like opening // the selector if necessary etc. if( m_scanParams ) { /* if m_scanParams exist it means, that the dialog is already open */ return true; } m_scanParams = new ScanParams( splitter ); connect( m_previewer->getImageCanvas(), SIGNAL( newRect(QRect)), m_scanParams, SLOT(slCustomScanSize(QRect))); connect( m_previewer->getImageCanvas(), SIGNAL( noRect()), m_scanParams, SLOT(slMaximalScanSize())); connect( m_scanParams, SIGNAL( scanResolutionChanged( int, int )), m_previewer, SLOT( slNewScanResolutions( int, int ))); /* continue to attach a real scanner */ /* first, get the list of available devices from libkscan */ QStringList scannerNames; QStrList backends = m_device->getDevices();; QStrListIterator it( backends ); while ( it.current() ) { scannerNames.append( m_device->getScannerName( it.current() )); ++it; } /* ..if there are devices.. */ QCString configDevice; good_scan_connect = true; if( scannerNames.count() > 0 ) { /* allow the user to select one */ DeviceSelector ds( this, backends, scannerNames ); configDevice = ds.getDeviceFromConfig( ); if( configDevice.isEmpty() || configDevice.isNull() ) { kdDebug(29000) << "configDevice is not valid - starting selector!" << configDevice << endl; if ( ds.exec() == QDialog::Accepted ) { configDevice = ds.getSelectedDevice(); } } /* If a device was selected, */ if( ! configDevice.isNull() ) { /* ..open it (init sane with that) */ m_device->openDevice( configDevice ); /* ..and connect to the gui (create the gui) */ if ( !m_scanParams->connectDevice( m_device ) ) { kdDebug(29000) << "ERR: Could not connect scan device" << endl; good_scan_connect = false; } } } if( configDevice.isNull() || configDevice.isEmpty() ) { /* No scanner found, open with information */ m_scanParams->connectDevice( 0L ); good_scan_connect = false; /* Making the previewer gray */ /* disabling is much better than hiding for 'advertising' ;) */ } /* Move the scan params to the left, for backward compatibility. * However, having it on the right looks a bit better IMHO */ if( splitter && m_scanParams ) splitter->moveToFirst( m_scanParams ); if( good_scan_connect ) { m_previewer->setEnabled( true ); m_previewer->setPreviewImage( m_device->loadPreviewImage() ); m_previewer->connectScanner( m_device ); } /* set initial sizes */ setInitialSize( configDialogSize( GROUP_STARTUP )); KConfig *kfg = KGlobal::config(); if( kfg ) { QRect r = KGlobalSettings::desktopGeometry(this); kfg->setGroup( GROUP_STARTUP ); /* Since this is a vertical splitter, only the width is important */ QString key = QString::fromLatin1( SCANDIA_SPLITTER_SIZES ).arg( r.width()); kdDebug(29000) << "Read Splitter-Sizes " << key << endl; splitter->setSizes( kfg->readIntListEntry( key )); } return true; }