Eneboo - Documentación para desarrolladores
src/qsa/tools/designer/editor/preferences.ui.h
Ir a la documentación de este archivo.
00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qt Designer.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00012 ** licenses may use this file in accordance with the Qt Commercial License
00013 ** Agreement provided with the Software.
00014 **
00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 **
00018 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00019 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00020 **   information about Qt Commercial License Agreements.
00021 **
00022 ** Contact info@trolltech.com if any conditions of this licensing are
00023 ** not clear to you.
00024 **
00025 **********************************************************************/
00026 
00027 void PreferencesBase::init()
00028 {
00029     QFontDatabase fdb;
00030     comboFamily->insertStringList( fdb.families() );
00031     listElements->setCurrentItem( listElements->firstItem() );
00032     currentElement = "";
00033 }
00034 
00035 void PreferencesBase::destroy()
00036 {
00037 
00038 }
00039 
00040 void PreferencesBase::colorClicked()
00041 {
00042     QColor c = QColorDialog::getColor( currentStyle.color, this, "editor_getcolor_dlg" );
00043     if ( c.isValid() ) {
00044         currentStyle.color = c;
00045         setColorPixmap( c );
00046     }
00047 }
00048 
00049 void PreferencesBase::reInit()
00050 {
00051     styles = Config::readStyles( path );
00052     currentElement = "";
00053     elementChanged( tr( QString::fromLatin1("Comment") ) );
00054     for ( int i = 0; i < comboFamily->count(); ++i ) {
00055         if ( listElements->text( i ) == tr( QString::fromLatin1("Comment") ) ) {
00056             listElements->setCurrentItem( i );
00057             break;
00058         }
00059     }
00060     checkWordWrap->setChecked( Config::wordWrap( path ) );
00061     checkCompletion->setChecked( Config::completion( path ) );
00062     checkParenMatching->setChecked( Config::parenMatching( path ) );
00063     spinTabSize->setValue( Config::indentTabSize( path ) );
00064     spinIndentSize->setValue( Config::indentIndentSize( path ) );
00065     checkKeepTabs->setChecked( Config::indentKeepTabs( path ) );
00066     checkAutoIndent->setChecked( Config::indentAutoIndent( path ) );
00067 }
00068 
00069 void PreferencesBase::save()
00070 {
00071     if ( !currentElement.isEmpty() ) {
00072         styles.remove( currentElement );
00073         styles.insert( currentElement, currentStyle );
00074         currentElement = "";
00075     }
00076 
00077     QSettings settings;
00078     Config::saveStyles( styles, path );
00079     Config::setWordWrap( checkWordWrap->isChecked(), path );
00080     Config::setCompletion( checkCompletion->isChecked(), path );
00081     Config::setParenMatching( checkParenMatching->isChecked(), path );
00082     Config::setIndentTabSize( spinTabSize->value(), path );
00083     Config::setIndentIndentSize( spinIndentSize->value(), path );
00084     Config::setIndentKeepTabs( checkKeepTabs->isChecked(), path );
00085     Config::setIndentAutoIndent( checkAutoIndent->isChecked(), path );
00086 }
00087 
00088 void PreferencesBase::updatePreview()
00089 {
00090     editPreview->setFont( currentStyle.font );
00091     QPalette pal = editPreview->palette();
00092     pal.setColor( QPalette::Active, QColorGroup::Text, currentStyle.color );
00093     pal.setColor( QPalette::Active, QColorGroup::Foreground, currentStyle.color );
00094     editPreview->setPalette( pal );
00095 }
00096 
00097 void PreferencesBase::boldChanged( bool b )
00098 {
00099     currentStyle.font.setBold( b );
00100     updatePreview();
00101 }
00102 
00103 void PreferencesBase::elementChanged( const QString &element )
00104 {
00105     if ( !currentElement.isEmpty() ) {
00106         styles.remove( currentElement );
00107         styles.insert( currentElement, currentStyle );
00108         currentElement = "";
00109     }
00110     QMap<QString, ConfigStyle>::Iterator it = styles.find( element );
00111     if ( it == styles.end() )
00112         return;
00113     ConfigStyle s = *it;
00114     currentStyle = s;
00115     comboFamily->lineEdit()->setText( s.font.family() );
00116     spinSize->setValue( s.font.pointSize() );
00117     checkBold->setChecked( s.font.bold() );
00118     checkItalic->setChecked( s.font.italic() );
00119     checkUnderline->setChecked( s.font.underline() );
00120     setColorPixmap( s.color );
00121     currentElement = element;
00122     updatePreview();
00123 }
00124 
00125 void PreferencesBase::familyChanged( const QString &f )
00126 {
00127     QString oldFamily = currentStyle.font.family();
00128     currentStyle.font.setFamily( f );
00129     if ( currentElement == tr( QString::fromLatin1("Standard") ) ) {
00130         for ( QMap<QString, ConfigStyle>::Iterator it = styles.begin(); it != styles.end(); ++it ) {
00131             if ( (*it).font.family() == oldFamily )
00132                 (*it).font.setFamily( f );
00133         }
00134     }
00135     updatePreview();
00136 }
00137 
00138 void PreferencesBase::italicChanged( bool b )
00139 {
00140     currentStyle.font.setItalic( b );
00141     updatePreview();
00142 }
00143 
00144 void PreferencesBase::setColorPixmap( const QColor &c )
00145 {
00146     QPixmap pm( 20, 20 );
00147     pm.fill( c );
00148     buttonColor->setPixmap( pm );
00149     updatePreview();
00150 }
00151 
00152 void PreferencesBase::setPath( const QString &p )
00153 {
00154     path = p;
00155 }
00156 
00157 void PreferencesBase::sizeChanged( int s )
00158 {
00159     int oldSize = currentStyle.font.pointSize();
00160     currentStyle.font.setPointSize( s );
00161     if ( currentElement == tr( QString::fromLatin1("Standard") ) ) {
00162         for ( QMap<QString, ConfigStyle>::Iterator it = styles.begin(); it != styles.end(); ++it ) {
00163             if ( (*it).font.pointSize() == oldSize )
00164                 (*it).font.setPointSize( s );
00165         }
00166     }
00167     updatePreview();
00168 }
00169 
00170 void PreferencesBase::underlineChanged( bool b )
00171 {
00172     currentStyle.font.setUnderline( b );
00173     updatePreview();
00174 }
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'