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

📄 appearance.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	    qDebug("Write simple config theme select %s %s", item->filename().latin1(), item->text().latin1());	    config.writeEntry( "Style", s );	    config.writeEntry( "Theme", "");	    config.writeEntry( "DecorationTheme", "");	}    }#else    PluginItem *item = (PluginItem *)styleList->item( styleList->currentItem() );    if ( item ) {	s = item->filename().isEmpty() ? item->text() : item->filename();	config.writeEntry( "Style", s );    }#endif    item = (PluginItem *)decorationList->item( decorationList->currentItem() );    if ( item ) {	s = item->filename().isEmpty() ? item->text() : item->filename();	config.writeEntry( "Decoration", s );    }    s = colorListIDs[colorList->currentItem()];    config.writeEntry( "Scheme", s );    Config scheme( QPEApplication::qpeDir() + "etc/colors/" + s + ".scheme",        Config::File );    if (scheme.isValid()){	scheme.setGroup("Colors");	QString color = scheme.readEntry( "Background", "#EEEEEE" );	config.writeEntry( "Background", color );	color = scheme.readEntry( "Foreground", "#000000" );	config.writeEntry( "Foreground", color );	color = scheme.readEntry( "Button", "#F0F0F0" );	config.writeEntry( "Button", color );	color = scheme.readEntry( "Highlight", "#8BAF31" );	config.writeEntry( "Highlight", color );	color = scheme.readEntry( "HighlightedText", "#FFFFFF" );	config.writeEntry( "HighlightedText", color );	color = scheme.readEntry( "Text", "#000000" );	config.writeEntry( "Text", color );	color = scheme.readEntry( "ButtonText", "#000000" );	config.writeEntry( "ButtonText", color );	color = scheme.readEntry( "Base", "#FFFFFF" );	config.writeEntry( "Base", color );	color = scheme.readEntry( "AlternateBase", "#CBEF71" );	config.writeEntry( "AlternateBase", color );	color = scheme.readEntry( "Text_disabled", "" );	config.writeEntry("Text_disabled", color);	color = scheme.readEntry( "Foreground_disabled", "" );	config.writeEntry("Foreground_disabled", color);	color = scheme.readEntry( "Shadow", "" );	config.writeEntry("Shadow", color);    } else {	QString themeConfigName(QPEApplication::qpeDir() + "etc/themes/" + s+ ".conf");	Config themeConfig(themeConfigName, Config::File);	if (themeConfig.isValid()){	    themeConfig.setGroup( "Theme" ); 	    if (themeConfig.hasKey( "Name" ) && themeConfig.hasKey( "Style" ) && themeConfig.hasKey( "WidgetsConfig")) {		QString themeXMLFile = themeConfig.readEntry( "WidgetsConfig");		WidgetThemeParser parser;		if (parser.parse(QPEApplication::qpeDir() + "etc/themes/" + themeXMLFile)){		    QPalette pal = parser.palette();		    config.writeEntry("Button", pal.color(QPalette::Normal, QColorGroup::Button).name());		    config.writeEntry("Background", pal.color(QPalette::Normal, QColorGroup::Background).name());		    config.writeEntry("Foreground", pal.color(QPalette::Normal, QColorGroup::Foreground).name());		    config.writeEntry("Highlight", pal.color(QPalette::Normal, QColorGroup::Highlight).name());		    config.writeEntry("HighlightedText", pal.color(QPalette::Normal, QColorGroup::HighlightedText).name());		    config.writeEntry("Text", pal.color(QPalette::Normal, QColorGroup::Text).name());		    config.writeEntry("ButtonText", pal.color(QPalette::Normal, QColorGroup::ButtonText).name());		    config.writeEntry("Base", pal.color(QPalette::Normal, QColorGroup::Base).name());		    config.writeEntry("Text_disabled", "");		    config.writeEntry("Foreground_disabled", "");		    config.writeEntry("Shadow", "");		}		    }else{		qWarning("Theme config %s is invalid", themeConfigName.local8Bit().data());	    }	}else{	    qWarning("Unable to read config file %s", themeConfigName.local8Bit().data());	}    }#ifndef QTOPIA_PHONE    QFont font(fontList->currentText(), fontSize->currentText().toInt());    config.writeEntry( "FontFamily", fontList->currentText() );    config.writeEntry( "FontSize", fontSize->currentText().toInt() );#else    FontMap::Font f = fontMap.current();    QFont font(f.family,f.size);    fontMap.write(config);    config.writeEntry("BackgroundImage", bgImgName);#endif#ifndef QPE_FONT_HEIGHT_TO_ICONSIZE#define QPE_FONT_HEIGHT_TO_ICONSIZE(x) (x+1)#endif    QFontMetrics fm(font);    config.writeEntry( "IconSize", QPE_FONT_HEIGHT_TO_ICONSIZE(fm.height()) );    config.write(); // need to flush the config info first    Global::applyStyle();    QDialog::accept();}void AppearanceSettings::done(int r){     QDialog::done(r);    close();}bool AppearanceSettings::eventFilter(QObject *#ifdef QTOPIA_PHONEo, QEvent *e#else,QEvent *#endif){#ifdef QTOPIA_PHONE    if (o == previewLabel && e->type() == QEvent::Show) {	bgTimer->start(0, TRUE);    }#endif    return FALSE;}void AppearanceSettings::resizeEvent( QResizeEvent *e ){#ifndef QTOPIA_PHONE    int dheight = QApplication::desktop()->height();    int dwidth = QApplication::desktop()->width();    static bool wide = FALSE;    bool isWide = ( dheight < 300 && dheight < dwidth );    if ( isWide != wide ) {	wide = isWide;	delete layout();	QBoxLayout *l;	if ( wide )	    l = new QHBoxLayout( this );	else	    l = new QVBoxLayout( this );	l->setMargin( 4 );	l->setSpacing( 6 );	l->addWidget( tabWidget );	delete sample;	sample = new SampleWindow( this );	l->addWidget( sample );	sample->show();    }#endif    AppearanceSettingsBase::resizeEvent( e );}void AppearanceSettings::colorSelected( int id ){#ifndef QTOPIA_PHONE    QPalette pal = readColorScheme(id);    sample->setPalette( pal );#else    Q_UNUSED(id);#endif}#define setPaletteEntry(pal, cfg, role, defaultVal) \    setPalEntry(pal, cfg, #role, QColorGroup::role, defaultVal)static void setPalEntry( QPalette &pal, const Config &config, const QString &entry,				QColorGroup::ColorRole role, const QString &defaultVal ){    QString value = config.readEntry( entry, defaultVal );    if ( value[0] == '#' )	pal.setColor( role, QColor(value) );    else	pal.setBrush( role, QBrush(QColor(defaultVal), Resource::loadPixmap(value)) );}QPalette AppearanceSettings::readColorScheme(int id){    Config config( QPEApplication::qpeDir() + "etc/colors/" + colorListIDs[id] + ".scheme",        Config::File );    config.setGroup( "Colors" );    QPalette tempPal;    setPaletteEntry( tempPal, config, Button, "#F0F0F0" );    setPaletteEntry( tempPal, config, Background, "#EEEEEE" );    QPalette pal( tempPal.normal().button(), tempPal.normal().background() );    setPaletteEntry( pal, config, Button, "#F0F0F0" );    setPaletteEntry( pal, config, Background, "#EEEEEE" );    setPaletteEntry( pal, config, Base, "#FFFFFF" );    setPaletteEntry( pal, config, Highlight, "#8BAF31" );    setPaletteEntry( pal, config, Foreground, "#000000" );    QString color = config.readEntry( "HighlightedText", "#FFFFFF" );    pal.setColor( QColorGroup::HighlightedText, QColor(color) );    color = config.readEntry( "Text", "#000000" );    pal.setColor( QColorGroup::Text, QColor(color) );    color = config.readEntry( "ButtonText", "#000000" );    pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor(color) );    pal.setColor( QPalette::Disabled, QColorGroup::Text,		  pal.color(QPalette::Active, QColorGroup::Background).dark() );    return pal;}void AppearanceSettings::styleSelected( int idx ){#ifndef QTOPIA_PHONE    QString style("Qtopia");    PluginItem *item = (PluginItem *)styleList->item( idx );    if ( item )	style = item->filename().isEmpty() ? item->text() : item->filename();    StyleInterface *oldIface = styleiface;    QStyle *newStyle = 0;    styleiface = 0;    if ( style == "Windows" ) { // No tr	newStyle = new QWindowsStyle;    } else if ( style == "QPE" || style == "Qtopia" ) {	newStyle = new QPEStyle;    } else {	StyleInterface *iface = 0;	if ( styleLoader->queryInterface( style, IID_Style, (QUnknownInterface**)&iface ) == QS_OK && iface ) {	    newStyle = iface->style();	    styleiface = iface;	}    }    if (!newStyle)	newStyle = new QPEStyle;    sample->setUpdatesEnabled( FALSE );    QPixmapCache::clear();    setStyle( sample, newStyle );    QTimer::singleShot( 0, this, SLOT(fixSampleGeometry()) );    if ( oldIface )	styleLoader->releaseInterface( oldIface );#else    Q_UNUSED(idx);#endif}void AppearanceSettings::themeSelected( int idx ){#ifdef QTOPIA_PHONE    QString theme("Qtopia");    PluginItem *item = (PluginItem *)themeList->item( idx );    if ( item )	theme = item->themeFilename().isEmpty() ? item->text() : item->themeFilename();    QString readStyleName, configFileName;    // Check if a themed style was selected.    QString themeDataPath( QPEApplication::qpeDir() + "etc/themes/" );    QDir dir;    bool validTheme, skipTheme;    qDebug( "Find the themed definition" );    if ( item && !item->text().isEmpty() && dir.exists( themeDataPath ) ){	dir.setPath( themeDataPath );	dir.setNameFilter( "*.conf" ); // No tr	for (int index = 0; index < (int)dir.count(); index++){	    QString configFileName(themeDataPath + dir[index]);	    Config themeConfig(configFileName, Config::File );	    validTheme = TRUE;	    skipTheme = FALSE;	    qDebug( "Reading config %s", configFileName.local8Bit().data() );	    themeConfig.setGroup( "Theme" ); // no Tr	    if ( themeConfig.isValid() ){		if ( themeConfig.hasKey( "Name" ) && themeConfig.hasKey( "Style" ) ){	// No tr 		    readStyleName = themeConfig.readEntry( "Name" );		    if ( readStyleName == item->text() ){ 			qDebug( "Adopting theme %s", item->text().local8Bit().data());			theme = item->themeFilename();			break;		    }else{			skipTheme = TRUE;			qDebug( "Skipping themed style %s when looking for %s", 				readStyleName.local8Bit().data(), item->text().local8Bit().data() );		    }		}else{		    validTheme = FALSE;		}	    }	    if (!validTheme && !skipTheme)		qDebug("Ignoring invalid theme file %s", configFileName.local8Bit().data()); 	}    }#else    Q_UNUSED(idx);#endif}void AppearanceSettings::decorationSelected( int idx ){#ifndef QTOPIA_PHONE    if ( wdIsPlugin ) {	wdLoader->releaseInterface( wdiface );    } else {	delete wdiface;    }    wdiface = 0;    wdIsPlugin = FALSE;    QString dec("Qtopia");    PluginItem *item = (PluginItem *)decorationList->item( idx );    if ( item )	dec = item->filename().isEmpty() ? item->text() : item->filename();    if ( dec != "Qtopia" ) {	if ( wdLoader->queryInterface( dec, IID_WindowDecoration, (QUnknownInterface**)&wdiface ) == QS_OK && wdiface )	    wdIsPlugin = TRUE;    }    if ( !wdiface )	wdiface = new DefaultWindowDecoration;    sample->setDecoration( wdiface );    sample->repaint();#else    Q_UNUSED(idx);#endif}void AppearanceSettings::fontSelected( const QString &name )

⌨️ 快捷键说明

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