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

📄 kdevdlg2ui.cpp

📁 Linux下的基于X11的图形开发环境。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/************************************************************************** Copyright (C) 2000 Trolltech AS.  All rights reserved.**** This file is part of Qt Designer.**** This file may be distributed and/or modified under the terms of the** GNU General Public License version 2 as published by the Free Software** Foundation and appearing in the file LICENSE.GPL included in the** packaging of this file.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.**** See http://www.trolltech.com/gpl/ for GPL licensing information.**** Contact info@trolltech.com if any conditions of this licensing are** not clear to you.************************************************************************/#include "kdevdlg2ui.h"#include <qdir.h>#include <qstring.h>#include <qptrstack.h>/// some little helpers ///void KDEVDLG2UI::wi(){    for ( int i = 0; i < indentation; i++ )	*out << "    ";}void KDEVDLG2UI::indent(){    indentation++;}void KDEVDLG2UI::undent(){    indentation--;}void KDEVDLG2UI::writeClass( const QString& name ){    wi(); *out << "<class>" << name << "</class>" << endl;}void KDEVDLG2UI::writeWidgetStart( const QString& qclass ){    wi(); *out << "<widget class=\"" << qclass << "\">" << endl;}void KDEVDLG2UI::writeWidgetEnd(){    wi(); *out << "</widget>" << endl;}void KDEVDLG2UI::writeCString( const QString& name, const QString& value ){    wi(); *out << "<property>" << endl; indent();    wi(); *out << "<name>" << name << "</name>" << endl;    wi(); *out << "<cstring>" << value << "</cstring>" << endl; undent();    wi(); *out << "</property>" << endl;}void KDEVDLG2UI::writeString( const QString& name, const QString& value ){    wi(); *out << "<property>" << endl; indent();    wi(); *out << "<name>" << name << "</name>" << endl;    wi(); *out << "<string>" << value << "</string>" << endl; undent();    wi(); *out << "</property>" << endl;}void KDEVDLG2UI::writeRect( const QString& name, int x, int y, int w, int h ){    wi(); *out << "<property>" << endl; indent();    wi(); *out << "<name>" << name << "</name>" << endl;    wi(); *out << "<rect>" << endl; indent();    wi(); *out << "<x>" << x << "</x>" << endl;    wi(); *out << "<y>" << y << "</y>" << endl;    wi(); *out << "<width>" << w << "</width>" << endl;    wi(); *out << "<height>" << h << "</height>" << endl; undent();    wi(); *out << "</rect>" << endl; undent();    wi(); *out << "</property>" << endl;}void KDEVDLG2UI::writeFont( const QString& family, int pointsize ){    wi(); *out << "<property>" << endl; indent();    wi(); *out << "<name>font</name>" << endl;    wi(); *out << "<font>" << endl; indent();    wi(); *out << "<family>" << family << "</family>" << endl;    wi(); *out << "<pointsize>" << pointsize << "</pointsize>" << endl; undent();    wi(); *out << "</font>" << endl; undent();    wi(); *out << "</property>" << endl;}void KDEVDLG2UI::writeBool( const QString& name, bool value ){    wi(); *out << "<property>" << endl; indent();    wi(); *out << "<name>" << name << "</name>" << endl;    wi(); *out << "<bool>" << (value ? "true" : "false") << "</bool>" << endl; undent();    wi(); *out << "</property>" << endl;}void KDEVDLG2UI::writeNumber( const QString& name, int value ){    wi(); *out << "<property>" << endl; indent();    wi(); *out << "<name>" << name << "</name>" << endl;    wi(); *out << "<number>" << value << "</number>" << endl; undent();    wi(); *out << "</property>" << endl;}void KDEVDLG2UI::writeEnum( const QString& name, const QString& value ){    wi(); *out << "<property>" << endl; indent();    wi(); *out << "<name>" << name << "</name>" << endl;    wi(); *out << "<enum>" << value << "</enum>" << endl; undent();    wi(); *out << "</property>" << endl;}void KDEVDLG2UI::writeSet( const QString& name, const QString& value ){    wi(); *out << "<property>" << endl; indent();    wi(); *out << "<name>" << name << "</name>" << endl;    wi(); *out << "<set>" << value << "</set>" << endl; undent();    wi(); *out << "</property>" << endl;}void KDEVDLG2UI::writeItem( const QString& name, const QString& value ){    wi(); *out << "<item>" << endl; indent();    writeString( name, value ); undent();    wi(); *out << "</item>" << endl;}void KDEVDLG2UI::writeColumn( const QString& name, const QString& value ){    wi(); *out << "<column>" << endl; indent();    writeString( name, value ); undent();    wi(); *out << "</column>" << endl;}void KDEVDLG2UI::writeColor( const QString& name, const QString& value ){    int color = value.toInt();    int r = color & 0x00ff0000 >> 16;    int g = color & 0x0000ff00 >> 8;    int b = color & 0x000000ff;        wi(); *out << "<property>" << endl; indent(); //###FIX    wi(); *out << "<name>" << name << "</name>" << endl;    wi(); *out << "<color>" << endl; indent();    wi(); *out << "<red>" << r << "</red>" << endl;    wi(); *out << "<green>" << g << "</green>" << endl;    wi(); *out << "<blue>" << b << "</blue>" << endl; undent();    wi(); *out << "</color>" << endl;    wi(); *out << "</property>" << endl;}void KDEVDLG2UI::writeStyles( const QStringList styles, bool isFrame ){    if ( isFrame ) {	bool defineFrame = FALSE;	QString shadow = "NoFrame";	QString shape = "StyledPanel";	int width = 2;	if ( styles.contains( "WS_EX_STATICEDGE" ) ) {	    shadow = "Plain";	    width = 1;	    defineFrame = TRUE;	}	if ( styles.contains( "WS_EX_CLIENTEDGE" ) ) {	    shadow = "Sunken";	    defineFrame = TRUE;	}	if ( styles.contains( "WS_EX_DLGMODALFRAME" ) ) {	    shadow = "Raised";	    defineFrame = TRUE;	}	if ( !styles.contains( "WS_BORDER" ) ) {	    shape = "NoFrame";	    defineFrame = TRUE;	}	if ( defineFrame ) {	    writeEnum( "frameShape", "StyledPanel" );	    writeEnum( "frameShadow", shadow );	    writeNumber( "lineWidth", width );	}    }    if ( styles.contains("WS_DISABLED") )	writeBool("enabled", FALSE );    if ( styles.contains("WS_EX_ACCEPTFILES") )	writeBool("acceptDrops", TRUE );    if ( styles.contains("WS_EX_TRANSPARENT") )	writeBool("autoMask", TRUE );    if ( !styles.contains("WS_TABSTOP") )	writeEnum("focusPolicy", "NoFocus");}/*!  Constructs a KDEVDLG2UI object*/KDEVDLG2UI::KDEVDLG2UI( QTextStream* input, const QString& name ){    className = name;    writeToFile = TRUE;    in = input;    indentation = 0;    out = 0;}/*!  Destructs the KDEVDLG2UI object*/KDEVDLG2UI::~KDEVDLG2UI(){}/*!  Parses the input stream and writes the output to files.*/bool KDEVDLG2UI::parse(){    QFile fileOut;    QString buffer;	    if ( writeToFile ) {	QString outputFile = QString( className ) + ".ui";	fileOut.setName( outputFile );	if (!fileOut.open( IO_WriteOnly ) )	    qFatal( "kdevdlg2ui: Could not open output file '%s'", outputFile.latin1() );	out = new QTextStream( &fileOut );	targetFiles.append( outputFile );    } else {	out = new QTextStream( &buffer, IO_WriteOnly );    }        writeDialog( className );    delete out;    out = 0;    return TRUE;}/*!

⌨️ 快捷键说明

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