/* * KdmThemer. The main theming interface */ KdmThemer::KdmThemer( const QString &_filename, const QString &mode, const QMap<QString, bool> &showTypes, QWidget *w ) : QObject() , m_currentMode( mode ) , m_showTypes( showTypes ) , rootItem( 0 ) , m_geometryOutdated( true ) , m_geometryInvalid( true ) , m_widget( 0 ) { // read the XML file and create DOM tree QString filename = _filename; if (!::access( QFile::encodeName( filename + "/KdmGreeterTheme.desktop" ), R_OK )) { KConfig _cfg( filename + "/KdmGreeterTheme.desktop", KConfig::SimpleConfig ); KConfigGroup cfg( &_cfg, "KdmGreeterTheme" ); filename += '/' + cfg.readEntry( "Greeter" ); } QFile opmlFile( filename ); if (!opmlFile.open( QIODevice::ReadOnly )) { FDialog::box( w, errorbox, i18n( "Cannot open theme file %1" , filename) ); return; } QDomDocument domTree; if (!domTree.setContent( &opmlFile )) { FDialog::box( w, errorbox, i18n( "Cannot parse theme file %1" , filename) ); return; } // generate all the items defined in the theme const QDomElement &theme = domTree.documentElement(); // Get its tag, and check it's correct ("greeter") if (theme.tagName() != "greeter") { FDialog::box( w, errorbox, i18n( "%1 does not seem to be a correct theme file" , filename) ); return; } // Set the root (screen) item rootItem = new KdmRect( this, theme ); basedir = QFileInfo( filename ).absolutePath(); generateItems( rootItem, theme ); rootItem->updateVisible(); /* *TODO* // Animation timer QTimer *time = new QTimer( this ); time->start( 500 ); connect( time, SIGNAL(timeout()), SLOT(update()) ) */ }
OutlineTree::OutlineTree( const QString fileName, QWidget *parent, const char *name ) : QListView( parent, name ) { // div. configuration of the list view addColumn( "Outlines" ); setSorting( -1 ); setRootIsDecorated( TRUE ); // read the XML file and create DOM tree QFile opmlFile( fileName ); if ( !opmlFile.open( IO_ReadOnly ) ) { QMessageBox::critical( 0, tr( "Critical Error" ), tr( "Cannot open file %1" ).arg( fileName ) ); return; } if ( !domTree.setContent( &opmlFile ) ) { QMessageBox::critical( 0, tr( "Critical Error" ), tr( "Parsing error for file %1" ).arg( fileName ) ); opmlFile.close(); return; } opmlFile.close(); // get the header information from the DOM QDomElement root = domTree.documentElement(); QDomNode node; node = root.firstChild(); while ( !node.isNull() ) { if ( node.isElement() && node.nodeName() == "head" ) { QDomElement header = node.toElement(); getHeaderInformation( header ); break; } node = node.nextSibling(); } // create the tree view out of the DOM node = root.firstChild(); while ( !node.isNull() ) { if ( node.isElement() && node.nodeName() == "body" ) { QDomElement body = node.toElement(); buildTree( 0, body ); break; } node = node.nextSibling(); } }