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

📄 qpeapplication.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	pal.setColor( QPalette::Disabled, QColorGroup::Foreground, QColor(val));    } else {	pal.setColor( QPalette::Disabled, QColorGroup::Foreground,	    pal.color(QPalette::Active, QColorGroup::Background).dark() );    }    setPalette( pal, TRUE );    color = config.readEntry( "AlternateBase", "#EEF5D6" );    if ( color[0] == '#' )	style().setExtendedBrush(QStyle::AlternateBase, QColor(color));    else {	QPixmap pix;#ifdef SIZE_WALLPAPER_TO_DESKTOP_SIZE  // Disabled at the moment	QSize siz = qApp->desktop()->size();	int wid = siz.width(), h = siz.height();	pix = Resource::loadImage(color).smoothScale(wid,h);#endif	pix = Resource::loadPixmap(color);	style().setExtendedBrush(QStyle::AlternateBase, QBrush(QColor("#EEF5D6"),pix));    }    // Unpublished feature for now, since current windows will be broken.    // Need to go through all windows and poke QScrollViews to updateScrollbars.    extern bool qt_left_hand_scrollbars;    int lh = config.readNumEntry( "LeftHand", 0 );    qt_left_hand_scrollbars = lh;    // Window Decoration    QString dec = config.readEntry( "Decoration", "Qtopia" );    QString decTheme = config.readEntry( "DecorationTheme", "" );    if ( dec != d->decorationName || !decTheme.isEmpty()) {	qwsSetDecoration( new QPEDecoration( dec ) );	d->decorationName = dec;	d->decorationTheme = decTheme;    }    // Font    QString ff = config.readEntry( "FontFamily", font().family() );    int fs = config.readNumEntry( "FontSize", font().pointSize() );    QFont fn(ff,fs);    // Icon size#ifndef QPE_FONT_HEIGHT_TO_ICONSIZE#define QPE_FONT_HEIGHT_TO_ICONSIZE(x) (x+1)#endif    int is = config.readNumEntry( "IconSize", -1 );    if ( is < 0 ) {	QFontMetrics fm(fn);	config.writeEntry( "IconSize", QPE_FONT_HEIGHT_TO_ICONSIZE(fm.height()) );	config.write();    }    setFont( fn, TRUE );#ifdef QTOPIA_PHONE    if ( styleName == "phonestyle" || styleName == "Qtopia" ) {	QString path = themeCfg.readEntry("WidgetConfig");	((PhoneStyle*)&style())->setTheme(!!path ? themeDir+path : path);    }#endif#endif}void QPEApplication::systemMessage( const QCString &msg, const QByteArray &data){#ifdef Q_WS_QWS    QDataStream stream( data, IO_ReadOnly );    if ( msg == "linkChanged(QString)" ) {	QString lf;	stream >> lf;	emit linkChanged( lf );    } else if ( msg == "applyStyle()" ) {	applyStyle();    } else if ( msg == "setScreenSaverInterval(int)" ) {	if ( type() == GuiServer ) {	    int time;	    stream >> time;	    setScreenSaverInterval(time);	}    } else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {	if ( type() == GuiServer ) {	    int t1,t2,t3;	    stream >> t1 >> t2 >> t3;	    setScreenSaverIntervals(t1,t2,t3);	}    } else if ( msg == "setBacklight(int)" ) {	if ( type() == GuiServer ) {	    int bright;	    stream >> bright;	    setBacklight(bright);	}    } else if ( msg == "setDefaultRotation(int)" ) {	int r;	stream >> r;	if ( type() == GuiServer )	    setDefaultRotation(r);# if QT_VERSION >= 234	int t = 0;	switch ( r ) {	    case 90:		t = 1;		break;	    case 180:		t = 2;		break;	    case 270:		t = 3;		break;	}	QWSDisplay::setTransformation( t );# endif    } else if ( msg == "shutdown()" ) {	if ( type() == GuiServer )	    shutdown();    } else if ( msg == "quit()" ) {	if ( type() != GuiServer )	    tryQuit();    } else if ( msg == "close()" ) {	if ( type() != GuiServer )	    hideOrQuit();    } else if ( msg == "forceQuit()" ) {	if ( type() != GuiServer )	    quit();    } else if ( msg == "restart()" ) {	if ( type() == GuiServer )	    restart();    } else if ( msg == "grabKeyboard(QString)" ) {	QString who;	stream >> who;	if ( who.isEmpty() )	    d->kbgrabber = 0;	else if ( who != d->appName )	    d->kbgrabber = 1;	else	    d->kbgrabber = 2;    } else if ( msg == "language(QString)" ) {	if ( type() == GuiServer ) {	    QString l;	    stream >> l;	    l += ".utf8";	    QString cl = getenv("LANG");	    if ( cl != l ) {		if ( l.isNull() )		    unsetenv( "LANG" );		else		    setenv( "LANG", l.latin1(), 1 );		restart();	    }	}    } else if ( msg == "timeChange(QString)" ) {	// doesn't make sense to do this if quicklauncher,	// and may steal call to something that needs it.	if (d->appName != "quicklauncher") {	    d->skiptimechanged++;	    QString t;	    stream >> t;	    if ( t.isNull() )		unsetenv( "TZ" );	    else		setenv( "TZ", t.latin1(), 1 );	    // emit the signal so everyone else knows...	    emit timeChanged();	}    } else if ( msg =="categoriesChanged()" ) {	emit categoriesChanged();    } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {	if ( type() == GuiServer ) {	    QDateTime when;	    QCString channel, message;	    int data;	    stream >> when >> channel >> message >> data;	    AlarmServer::addAlarm( when, channel, message, data );	}    } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {	if ( type() == GuiServer ) {	    QDateTime when;	    QCString channel, message;	    int data;	    stream >> when >> channel >> message >> data;	    AlarmServer::deleteAlarm( when, channel, message, data );	}    } else if ( msg == "clockChange(bool)" ) {	int tmp;	stream >> tmp;	emit clockChanged( tmp );    } else if ( msg == "weekChange(bool)" ) {	int tmp;	stream >> tmp;	emit weekChanged( tmp );    } else if ( msg == "setDateFormat(DateFormat)" ) {	::DateFormat tmp;	stream >> tmp;	emit dateFormatChanged( tmp );    } else if ( msg == "setVolume(int,int)" ) {	if ( type() == GuiServer ) {	    int t,v;	    stream >> t >> v;	    setVolume(t,v);	}	emit volumeChanged( qtopia_muted );    } else if ( msg == "volumeChange(bool)" ) {        stream >> qtopia_muted;	if ( type() == GuiServer ) {            {            Config cfg("Sound");            cfg.setGroup("System");            cfg.writeEntry("Muted",qtopia_muted);            }	    setVolume();        }	emit volumeChanged( qtopia_muted );    } else if ( msg == "flush()" ) {	emit flush();	// we need to tell the desktop#ifndef QT_NO_COP	QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );	e << d->appName;#endif    } else if ( msg == "reload()" ) {	// Reload anything stored in files...	applyStyle();	if ( type() == GuiServer ) {	    setVolume();	    setBacklight(-1);	}	// App-specifics...	emit reload();    } else if ( msg == "setScreenSaverMode(int)" ) {	if ( type() == GuiServer ) {	    int old = disable_suspend;	    stream >> disable_suspend;	    qwsServer->restartScreenSaverTimer();	}    } else if ( msg == "getMarkedText()" ) {	if ( type() == GuiServer ) {	    const ushort unicode = 'C'-'@';	    const int scan = Key_C;	    qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE );	    qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE );	}    } else if ( msg == "newChannel(QString)") {	QString myChannel = "QPE/Application/" + d->appName;	QString channel;	stream >> channel;	if (channel == myChannel) {	    processQCopFile();	    d->sendQCopQ();	}    } else if ( msg == "wordsChanged(QString,int)" ) {	QString dictname;	int pid;	stream >> dictname >> pid;	void qtopia_reload_words(const QString& dictname); // global.cpp	if ( pid != getpid() ) {	    qDebug("Reload words '%s' (I am %d, not %d)",		dictname.latin1(),getpid(),pid);	    qtopia_reload_words(dictname);	}    } else if ( msg == "RecoverMemory()" ) {	if (qApp->type() != GuiServer) {	    QPixmapCache::clear();	}    } #ifdef QTOPIA_PHONE    else if ( msg == "updateContextBar()" ) {	if (activeWindow() && focusWidget()) {	    ContextKeyManager::instance()->updateContextLabels();	}    }#endif#else    Q_UNUSED( msg );	    Q_UNUSED( data );	#endif}/*!  \internal*/bool QPEApplication::raiseAppropriateWindow(){    bool r=FALSE;    // 1. Raise the main widget    QWidget *top = d->qpe_main_widget;    if ( !top ) top = mainWidget();    if ( top && d->keep_running ) {	if ( top->isVisible() )	    r = TRUE;	else if (d->preloaded) {	    // We are preloaded and not visible.. pretend we just started..#ifndef QT_NO_COP	    QCopEnvelope e("QPE/System", "fastAppShowing(QString)");	    e << d->appName;#endif	}	d->show_mx(top,d->nomaximize, d->appName);	top->raise();    }    QWidget *topm = activeModalWidget();    // 2. Raise any parentless widgets (except top and topm, as they    //     are raised before and after this loop).  Order from most    //     recently raised as deepest to least recently as top, so    //     that repeated calls cycle through widgets.    QWidgetList *list = topLevelWidgets();    if ( list ) {	bool foundlast = FALSE;	QWidget* topsub = 0;	if ( d->lastraised ) {	    for (QWidget* w = list->first(); w; w = list->next()) {		if ( !w->parentWidget() && w != top && w != topm && w->isVisible() && !w->isDesktop() ) {		    if ( w == d->lastraised )			foundlast = TRUE;		    if ( foundlast ) {			w->raise();			topsub = w;		    }		}	    }	}	for (QWidget* w = list->first(); w; w = list->next()) {	    if ( !w->parentWidget() && w != top && w != topm && w->isVisible() && !w->isDesktop() ) {		if ( w == d->lastraised )		    break;		w->raise();		topsub = w;	    }	}	d->lastraised = topsub;	delete list;    }    // 3. Raise the active modal widget.    if ( topm && topm != top ) {	topm->show();	topm->raise();	// If we haven't already handled the fastAppShowing message	if (!top && d->preloaded) {#ifndef QT_NO_COP	    QCopEnvelope e("QPE/System", "fastAppShowing(QString)");	    e << d->appName;#endif           	}	r = FALSE;    }    return r;}void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data){#ifdef Q_WS_QWS    if ( msg == "quit()" ) {	tryQuit();    } else if ( msg == "quitIfInvisible()" ) {	if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )	    quit();    } else if ( msg == "close()" ) {	hideOrQuit();    } else if ( msg == "disablePreload()" ) {	d->preloaded = FALSE;	d->keep_running = TRUE;	/* so that quit will quit */    } else if ( msg == "enablePreload()" ) {	if (d->qpe_main_widget) {	    d->preloaded = TRUE;	    d->forceshow = FALSE;	}	d->keep_running = TRUE;	/* so next quit won't quit */    } else if ( msg == "raise()" ) {	d->keep_running = TRUE;	d->notbusysent = FALSE;	raiseAppropriateWindow();	// Tell the system we're still chugging along...#ifndef QT_NO_COP	QCopEnvelope e("QPE/System", "appRaised(QString)");	e << d->appName;#endif    } else if ( msg == "flush()" ) {	emit flush();	// we need to tell the desktop#ifndef QT_NO_COP	QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );	e << d->appName;#endif    } else if ( msg == "reload()" ) {	emit reload();    } else if ( msg == "setDocument(QString)" ) {	d->keep_running = TRUE;	QDataStream stream( data, IO_ReadOnly );	QString doc;	stream >> doc;	QWidget *mw = mainWidget();	if ( !mw )	    mw = d->qpe_main_widget;	if ( mw )	    Global::setDocument( mw, doc );    } else if ( msg == "timeChange(QString)" ) {	// Same as the QPE/System message	if ( d->skiptimechanged ) {	    // Was handled in pidMessage()	    // (ie. we must offer TimeMonitor service)	    --d->skiptimechanged;	} else {	    QDataStream stream( data, IO_ReadOnly );	    QString t;	    stream >> t;	    if ( t.isNull() )		unsetenv( "TZ" );	    else		setenv( "TZ", t.latin1(), 1 );	    // emit the signal so everyone else knows...	    emit timeChanged();	}    } else if ( msg == "QPEProcessQCop()") {	processQCopFile();	d->sendQCopQ();    } else {	bool p = d->keep_running;	d->keep_running = FALSE;	emit appMessage( msg, data);	if ( d->keep_running ) {	    d->notbusysent = FALSE;	    raiseAppropriateWindow();	    if ( !p ) {		// Tell the system we're still chugging along...#ifndef QT_NO_COP		QCopEnvelope e("QPE/System", "appRaised(QString)");		e << d->appName;#endif	    }	}	if ( p )	    d->keep_running = p;    }#else    Q_UNUSED( msg );	    Q_UNUSED( data );	#endif}/*!  Sets widget \a mw as the mainWidget() and shows it. For small windows,  consider passing TRUE for \a nomaximize rather than the default FALSE.  \sa showMainDocumentWidget()*/void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ){    d->show(mw,nomaximize);}/*!  Sets widget \a mw as the mainWidget() and shows it. For small windows,  consider passing TRUE for \a nomaximize rather than the default FALSE.  This calls designates the application as  a \link docwidget.html document-oriented\endlink application.  The \a mw widget \e must have this slot: setDocument(const QString&).  \sa showMainWidget()*/void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ){#ifdef Q_WS_QWS    if ( mw && argc() == 2 )	Global::setDocument( mw, QString::fromUtf8(argv()[1]) );#endif    d->show(mw,nomaximize);}/*!    If an application is started via a \

⌨️ 快捷键说明

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