⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glade2ui.cpp

📁 Linux下的基于X11的图形开发环境。
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		  QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed) );    emitProperty( QString("pixmap"), imageName, QString("pixmap") );    emitClosing( QString("widget") );}void Glade2Ui::emitGnomeAbout( QString copyright, QString authors,			       QString comments ){    QString prog = yyProgramName;    if ( prog.isEmpty() )	prog = QString( "Gnomovision 1.69" );    if ( copyright.isEmpty() )	copyright = QString( "(C) 2001 Jasmin Blanchette" );    if ( authors.isEmpty() )	authors = QString( "Jasmin Blanchette <jasmin@troll.no>" );    if ( comments.isEmpty() )	comments = QString( "Gnomovision is the official GNU application." );    emitOpening( QString("hbox") );    emitSpacer( QString("Horizontal") );    emitOpeningWidget( QString("QLayoutWidget") );    emitOpening( QString("vbox") );    emitProperty( QString("spacing"), 17 );    /*      Emit the application name.    */    emitOpeningWidget( QString("QLabel") );    emitFontProperty( QString("font"), 24, TRUE );    emitProperty( QString("text"), prog );    emitProperty( QString("alignment"), QString("AlignAuto|AlignCenter"),		  QString("set") );    emitClosing( QString("widget") );    /*      Emit the copyright notice.    */    emitOpeningWidget( QString("QLabel") );    emitFontProperty( QString("font"), 12, TRUE );    emitProperty( QString("text"), copyright );    emitClosing( QString("widget") );    /*      Emit the authors' names.    */    emitOpeningWidget( QString("QLayoutWidget") );    emitOpening( QString("hbox") );    emitOpeningWidget( QString("QLabel") );    emitFontProperty( QString("font"), 12, TRUE );    emitProperty( QString("text"), QString("Authors:") );    emitProperty( QString("alignment"), QString("AlignAuto|AlignTop"),		  QString("set") );    emitClosing( QString("widget") );    emitOpeningWidget( QString("QLabel") );    emitFontProperty( QString("font"), 12, FALSE );    emitProperty( QString("text"), authors );    emitProperty( QString("alignment"), QString("AlignAuto|AlignTop"),		  QString("set") );    emitClosing( QString("widget") );    emitSpacer( QString("Horizontal") );    emitClosing( QString("hbox") );    emitClosing( QString("widget") );    /*      Emit the comments.    */    emitOpeningWidget( QString("QLabel") );    emitFontProperty( QString("font"), 10, FALSE );    emitProperty( QString("text"), comments );    emitProperty( QString("alignment"), QString("AlignAuto|AlignTop"),		  QString("set") );    emitClosing( QString("widget") );    /*      Emit the spacer and the OK button.    */    emitSpacer( QString("Vertical") );    emitOpeningWidget( QString("QLayoutWidget") );    emitOpening( QString("hbox") );    emitSpacer( QString("Horizontal") );    emitPushButton( QString("&OK"), QString("okButton") );    emitSpacer( QString("Horizontal") );    emitClosing( QString("hbox") );    emitClosing( QString("widget") );    emitClosing( QString("vbox") );    emitClosing( QString("widget") );    emitSpacer( QString("Horizontal") );    emitClosing( QString("hbox") );}/*  GnomeApps are emitted in two passes, because some information goes  into the <widget> section, whereas other information goes into the  <toolbars> section.*/void Glade2Ui::emitGnomeAppChildWidgetsPass1(	const QValueList<QDomElement>& childWidgets ){    QValueList<QDomElement>::ConstIterator c = childWidgets.begin();    while ( c != childWidgets.end() ) {	QValueList<QDomElement> grandchildWidgets;	QString childName;	QDomNode n = (*c).firstChild();	while ( !n.isNull() ) {	    QString tagName = n.toElement().tagName();	    if ( tagName == QString("child_name") ) {		childName = getTextValue( n );	    } else if ( tagName == QString("widget") ) {		grandchildWidgets.push_back( n.toElement() );	    }	    n = n.nextSibling();	}	if ( childName == QString("GnomeDock:contents") ) {	    emitWidget( *c, FALSE );	} else {	    emitGnomeAppChildWidgetsPass1( grandchildWidgets );	}	++c;    }}void Glade2Ui::doPass2( const QValueList<QDomElement>& childWidgets,			QValueList<QDomElement> *menuBar,			QValueList<QValueList<QDomElement> > *toolBars ){    QValueList<QDomElement>::ConstIterator c = childWidgets.begin();    while ( c != childWidgets.end() ) {	QValueList<QDomElement> grandchildWidgets;	QString childName;	QString gtkClass;	QDomNode n = (*c).firstChild();	while ( !n.isNull() ) {	    QString tagName = n.toElement().tagName();	    if ( tagName == QString("child_name") ) {		childName = getTextValue( n );	    } else if ( tagName == QString("class") ) {		gtkClass = getTextValue( n );	    } else if ( tagName == QString("widget") ) {		grandchildWidgets.push_back( n.toElement() );	    }	    n = n.nextSibling();	}	if ( gtkClass == QString("GtkMenuBar") ) {	    *menuBar = grandchildWidgets;	} else if ( gtkClass == QString("GtkToolbar") ) {	    toolBars->push_back( grandchildWidgets );	} else if ( childName != QString("GnomeDock:contents") ) {	    doPass2( grandchildWidgets, menuBar, toolBars );	}	++c;    }}void Glade2Ui::emitGnomeAppChildWidgetsPass2(	const QValueList<QDomElement>& childWidgets ){    QValueList<QDomElement> menuBar;    QValueList<QValueList<QDomElement> > toolBars;    doPass2( childWidgets, &menuBar, &toolBars );    emitGtkMenuBarChildWidgets( menuBar );    if ( !toolBars.isEmpty() ) {	emitOpening( QString("toolbars") );	while ( !toolBars.isEmpty() ) {	    emitGtkToolbarChildWidgets( toolBars.first() );	    toolBars.remove( toolBars.begin() );	}	emitClosing( QString("toolbars") );    }}void Glade2Ui::emitGtkButtonChildWidgets( QValueList<QDomElement> childWidgets ){    QValueList<QDomElement>::ConstIterator c = childWidgets.begin();    while ( c != childWidgets.end() ) {	QString label;	QDomNode n = (*c).firstChild();	while ( !n.isNull() ) {	    QString tagName = n.toElement().tagName();	    if ( tagName == QString("label") ) {		label = getTextValue( n );	    } else if ( tagName == QString("widget") ) {		childWidgets.push_back( n.toElement() );	    }	    n = n.nextSibling();	}	if ( !label.isEmpty() ) {	    emitProperty( QString("text"), accelerate(label) );	    break;	}	++c;    }}void Glade2Ui::emitGtkComboChildWidgets(	const QValueList<QDomElement>& childWidgets, const QStringList& items ){    QString text;    // there should be exactly one child, of type GtkEntry    if ( childWidgets.count() == 1 ) {	QDomNode n = childWidgets.first().firstChild();	while ( !n.isNull() ) {	    QString tagName = n.toElement().tagName();	    if ( tagName == QString("name") ) {		// grep 'elsewhere'		emitProperty( QString("name"),			      fixedName(getTextValue(n).latin1()) );	    } else if ( tagName == QString("text") ) {		text = getTextValue( n );	    }	    n = n.nextSibling();	}    }    int n = 0;    QStringList::ConstIterator s = items.begin();    while ( s != items.end() ) {	if ( !text.isEmpty() && *s == text )	    emitProperty( QString("currentItem"), n );	n++;	++s;    }}void Glade2Ui::emitGtkNotebookChildWidgets(	const QValueList<QDomElement>& childWidgets ){    QStringList tabNames;    QStringList tabLabels;    for ( int i = 0; i < (int) childWidgets.count(); i++ ) {	tabNames.push_back( QString("tab%1").arg(i + 1) );	tabLabels.push_back( QString("Tab %1").arg(i + 1) );    }    QValueList<QDomElement>::ConstIterator c;    c = childWidgets.begin();    QStringList::Iterator nam = tabNames.begin();    QStringList::Iterator lab = tabLabels.begin();    while ( c != childWidgets.end() ) {	QString childName;	QString name;	QString label;	QDomNode n = (*c).firstChild();	while ( !n.isNull() ) {	    QString tagName = n.toElement().tagName();	    if ( tagName == QString("child_name") ) {		childName = getTextValue( n );	    } else if ( tagName == QString("name") ) {		name = getTextValue( n );	    } else if ( tagName == QString("label") ) {		label = getTextValue( n );	    }	    n = n.nextSibling();	}	if ( childName == QString("Notebook:tab") ) {	    if ( !name.isEmpty() )		*nam = name;	    if ( !label.isEmpty() )		*lab = label;	    ++nam;	    ++lab;	}	++c;    }    c = childWidgets.begin();    while ( c != childWidgets.end() ) {	QString childName;	QString name;	QString label;	QDomNode n = (*c).firstChild();	while ( !n.isNull() ) {	    QString tagName = n.toElement().tagName();	    if ( tagName == QString("child_name") )		childName = getTextValue( n );	    n = n.nextSibling();	}	if ( childName != QString("Notebook:tab") ) {	    emitOpeningWidget( QString("QWidget") );	    emitProperty( QString("name"), tabNames.first().latin1() );	    tabNames.remove( tabNames.begin() );	    emitAttribute( QString("title"), accelerate(tabLabels.first()) );	    tabLabels.remove( tabLabels.begin() );	    emitWidget( *c, FALSE );	    emitClosing( QString("widget") );	}	++c;    }}void Glade2Ui::emitQListViewColumns( const QDomElement& qlistview ){    QDomNode n = qlistview.firstChild();    while ( !n.isNull() ) {	QString tagName = n.toElement().tagName();	if ( tagName == QString("widget") ) {	    QDomNode child = n.firstChild();	    while ( !child.isNull() ) {		QString tagName = child.toElement().tagName();		if ( tagName == QString("label") ) {		    emitOpening( QString("column") );		    emitProperty( QString("text"),				  decelerate(getTextValue(child)) );		    emitClosing( QString("column") );		}		child = child.nextSibling();	    }	} else if ( tagName == QString("class") ) {	    QString gtkClass = getTextValue( n );	    if ( gtkClass.endsWith(QString("Tree")) )		emitProperty( QString("rootIsDecorated"), QVariant(TRUE, 0) );	} else if ( tagName == QString("selection_mode") ) {	    emitProperty( QString("selectionMode"),			  gtk2qtSelectionMode(getTextValue(n)) );	}	n = n.nextSibling();    }}void Glade2Ui::emitGtkScrolledWindowChildWidgets(	const QValueList<QDomElement>& childWidgets, const QString& qtClass ){    if ( childWidgets.count() == 1 ) {	if ( qtClass == QString("QIconView") ||	     qtClass == QString("QListBox") ||	     qtClass == QString("QListView") ) {	    QDomNode n = childWidgets.first().firstChild();	    while ( !n.isNull() ) {		QString tagName = n.toElement().tagName();		if ( tagName == QString("selection_mode") ) {		    emitProperty( QString("selectionMode"),				  gtk2qtSelectionMode(getTextValue(n)) );		}		n = n.nextSibling();	    }	}	if ( qtClass == QString("QListView") ) {	    emitQListViewColumns( childWidgets.first() );	} else if ( qtClass == QString("QTextEdit") ||		    qtClass == QString("QTextView") ) {	    QDomNode n = childWidgets.first().firstChild();	    while ( !n.isNull() ) {		QString tagName = n.toElement().tagName();		if ( tagName == QString("text") )		    emitProperty( QString("text"), getTextValue(n) );		n = n.nextSibling();	    }	}    }}void Glade2Ui::emitGnomeDruidPage( const QDomElement& druidPage ){    QValueList<QDomElement> childWidgets;    QString gtkClass;    QString logoImage;    QString name;    QString text;    QString title;    QString watermarkImage;    emitOpeningWidget( QString("QWidget") );    QDomNode n = druidPage.firstChild();    while ( !n.isNull() ) {	QString tagName = n.toElement().tagName();	if ( tagName == QString("class") ) {	    gtkClass = getTextValue( n );	} else if ( tagName == QString("logo_image") ) {	    logoImage = getTextValue( n );	} else if ( tagName == QString("name") ) {	    name = getTextValue( n );	} else if ( tagName == QString("text") ) {	    text = getTextValue( n );	} else if ( tagName == QString("title") ) {	    title = getTextValue( n );	} else if ( tagName == QString("watermark_image") ) {	    watermarkImage = getTextValue( n );	} else if ( tagName == QString("widget") ) {	    childWidgets.push_back( n.toElement() );	}	n = n.nextSibling();    }    if ( !name.isEmpty() )	emitProperty( QString("name"), fixedName(name).latin1() );    if ( title.isEmpty() )	title = QString( "Page" );    emitAttribute( QString("title"), title );    /*      We're striving to get the logoImage and/or the watermarkImage at      the right places with a grid layout.    */    int leftAttach = 0;    int rightAttach = 0;    int topAttach = 0;    int bottomAttach = 0;    int numImages = 0;    if ( !logoImage.isEmpty() ) {	topAttach = 1;	numImages++;    }    if ( !watermarkImage.isEmpty() ) {	leftAttach = 1;	numImages++;    }    rightAttach = leftAttach + numImages;    bottomAttach = topAttach + numImages;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -