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

📄 qpeapplication.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.7平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 4 页
字号:
#ifdef Q_WS_QWS    ke->simpleData.keycode = key;#endif}#ifdef Q_WS_QWS/*!  Filters Qt event \a e to implement Qtopia-specific functionality.*/bool QPEApplication::qwsEventFilter( QWSEvent *e ){    if ( type() == GuiServer ) {	switch ( e->type ) {	    case QWSEvent::Mouse:		if ( e->asMouse()->simpleData.state && !QWidget::find(e->window()) )		    emit clientMoused();	}    }    if ( e->type == QWSEvent::Key ) {	if ( d->kbgrabber == 1 )	    return TRUE;	QWSKeyEvent *ke = (QWSKeyEvent *)e;	if ( ke->simpleData.keycode == Qt::Key_F33 ) {	    // Use special "OK" key to press "OK" on top level widgets	    QWidget *active = activeWindow();	    QWidget *popup = 0;	    if ( active && active->isPopup() ) {		popup = active;		active = active->parentWidget();	    }	    if ( active && (int)active->winId() == ke->simpleData.window &&		 !active->testWFlags( WStyle_Customize|WType_Popup|WType_Desktop )) {		if ( ke->simpleData.is_press ) {		    if ( popup )			popup->close();		    if ( active->inherits( "QDialog" ) ) {			HackDialog *d = (HackDialog *)active;			d->acceptIt();			return TRUE;		    } else if ( ((HackWidget *)active)->needsOk() ) {			QSignal s;			s.connect( active, SLOT( accept() ) );			s.activate();		    } else {			// do the same as with the select key: Map to the default action of the widget:			mapToDefaultAction( ke, Qt::Key_Return );		    }		}	    }	} else if ( ke->simpleData.keycode == Qt::Key_F30 ) {	    // Use special "select" key to do whatever default action a widget has	    mapToDefaultAction( ke, Qt::Key_Space );	} else if ( ke->simpleData.keycode == Qt::Key_Escape &&		    ke->simpleData.is_press ) {	    // Escape key closes app if focus on toplevel	    QWidget *active = activeWindow();	    if ( active && active->testWFlags( WType_TopLevel ) &&		 (int)active->winId() == ke->simpleData.window &&		 !active->testWFlags( WStyle_Dialog|WStyle_Customize|WType_Popup|WType_Desktop )) {		if ( active->inherits( "QDialog" ) ) {		    HackDialog *d = (HackDialog *)active;		    d->rejectIt();		    return TRUE;		} else if ( strcmp( argv()[0], "embeddedkonsole") != 0 ) {		    active->close();		}	    }	}#if QT_VERSION < 231	// Filter out the F4/Launcher key from apps	// ### The launcher key may not always be F4 on all devices	if ( ((QWSKeyEvent *)e)->simpleData.keycode == Qt::Key_F4 )	    return TRUE;#endif    } else if ( e->type == QWSEvent::Focus ) {	if ( !d->notbusysent ) {	    if ( qApp->type() != QApplication::GuiServer ) {#ifndef QT_NO_COP		QCopEnvelope e("QPE/System", "notBusy(QString)" );		e << d->appName;#endif	    }	    d->notbusysent=TRUE;	}	QWSFocusEvent *fe = (QWSFocusEvent*)e;	QWidget* nfw = QWidget::find(e->window());	if ( !fe->simpleData.get_focus ) {	    QWidget *active = activeWindow();	    while ( active && active->isPopup() ) {		active->close();		active = activeWindow();	    }	    if ( !nfw && d->kbgrabber == 2 ) {		ungrabKeyboard();		d->kbregrab = TRUE; // want kb back when we're active	    }	} else {	    // make sure our modal widget is ALWAYS on top	    QWidget *topm = activeModalWidget();	    if ( topm ) {		topm->raise();	    }	    if ( d->kbregrab ) {		grabKeyboard();		d->kbregrab = FALSE;	    }	}	if ( fe->simpleData.get_focus && inputMethodDict ) {	    InputMethodHint m = inputMethodHint( QWidget::find(e->window()) );	    if ( m == AlwaysOff )		Global::hideInputMethod();	    if ( m == AlwaysOn )		Global::showInputMethod();	}    }    return QApplication::qwsEventFilter( e );}#endif/*!  Destroys the QPEApplication.*/QPEApplication::~QPEApplication(){    if ( !d->notbusysent ) {	// maybe we didn't map a window - still tell the server we're not	// busy anymore.	if ( qApp->type() != QApplication::GuiServer ) {#ifndef QT_NO_COP	    QCopEnvelope e("QPE/System", "notBusy(QString)" );	    e << d->appName;#endif	}    }    ungrabKeyboard();#if defined(Q_WS_QWS) && !defined(QT_NO_COP)    // Need to delete QCopChannels early, since the display will    // be gone by the time we get to ~QObject().    delete sysChannel;    delete pidChannel;#endif    delete d;}/*!  Returns \c{$QPEDIR/}.*/QString QPEApplication::qpeDir(){#ifdef Q_WS_QWS    QString base, dir;    if (getenv( "QPEDIR" ))    	base = QString(getenv("QPEDIR")).stripWhiteSpace();    if ( !base.isNull() && (base.length() > 0 )){#ifdef Q_OS_WIN32	QString temp(base);	if (temp[(int)temp.length()-1] != QDir::separator())	    temp.append(QDir::separator());	dir = temp;#else	dir = QString( base ) + "/";#endif    }else{	dir = QString( ".." ) + QDir::separator();    }    return dir;#elif defined(QTOPIA_DESKTOP)#ifdef __GNUG__#warning "Should be able to change given a 'developing' parameter"// qtopiadesktop has a 'debug' parameter, but we can't/shouldn't get it here.#endif    QSettings settings;    settings.insertSearchPath( QSettings::Unix,	    QDir::homeDirPath() + "/.palmtopcenter/" );    settings.insertSearchPath( QSettings::Windows, "/Trolltech" );    QString key = "/palmtopcenter/qtopiadir";    bool okay;    QString dir = settings.readEntry(key, QString::null, &okay) + "/";    if (!okay || dir.isNull()) {	dir = "/opt/Qtopia/qtopiadesktop";	settings.writeEntry( key, dir);    }    return dir;#else    qWarning("Cannot determine the install path");    return QString::null;#endif // Q_WS_QWS}/*!  Returns the user's current Document directory. There is a trailing "/".*/QString QPEApplication::documentDir(){    QString r = QDir::homeDirPath();#ifdef QTOPIA_DESKTOP    r += "/.palmtopcenter/";#endif    QString base = r;    if (base.length() > 0){	return base + "/Documents/";    }    return QString( "../Documents/" );}static int deforient=-1;/*!  \internal*/int QPEApplication::defaultRotation(){    if ( deforient < 0 ) {	QString d = getenv("QWS_DISPLAY");	Config config("qpe");        config.setGroup( "Rotation" );	d = config.readEntry("Screen", d);	if ( d.contains("Rot90") ) { // No tr	    deforient = 90;	} else if ( d.contains("Rot180") ) { // No tr	    deforient = 180;	} else if ( d.contains("Rot270") ) { // No tr	    deforient = 270;	} else {	    deforient=0;	}    }    return deforient;}/*!  \internal*/void QPEApplication::setDefaultRotation(int r){    if ( qApp->type() == GuiServer ) {	deforient = r;	setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(r).latin1(), 1);	Config config("qpe");        config.setGroup( "Rotation" );	config.writeEntry( "Screen", getenv("QWS_DISPLAY") );    } else {#ifndef QT_NO_COP	QCopEnvelope("QPE/System", "setDefaultRotation(int)") << r;#endif    }}/*!  \internal*/void QPEApplication::applyStyle(){    Config config( "qpe" );    config.setGroup( "Appearance" );    // Widget style    QString style = config.readEntry( "Style", "Qtopia" );    internalSetStyle( style );    // Colors    QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) );    QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) );    QPalette pal( btncolor, bgcolor );    QString color = config.readEntry( "Highlight", "#800000" );    pal.setColor( QColorGroup::Highlight, QColor(color) );    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) );    color = config.readEntry( "Base", "#FFFFFF" );    pal.setColor( QColorGroup::Base, QColor(color) );    pal.setColor( QPalette::Disabled, QColorGroup::Text,		  pal.color(QPalette::Active, QColorGroup::Background).dark() );    setPalette( pal, TRUE );#ifdef Q_WS_QWS    // Window Decoration    QString dec = config.readEntry( "Decoration", "Qtopia" );    if ( dec != d->decorationName ) {	qwsSetDecoration( new QPEDecoration( dec ) );	d->decorationName = dec;    }#endif    // 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 );}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 == "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;	    QString cl = getenv("LANG");	    if ( cl != l ) {		if ( l.isNull() )		    unsetenv( "LANG" );		else		    setenv( "LANG", l.latin1(), 1 );		restart();	    }	}    } else if ( msg == "timeChange(QString)" ) {	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 ) {	    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;	    //qDebug("setScreenSaverMode(%d)", disable_suspend );	    if ( disable_suspend > old )		setScreenSaverInterval( -1 );	}    } 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();	}    }#endif}/*!  \internal*/bool QPEApplication::raiseAppropriateWindow(){    bool r=FALSE;    // ########## raise()ing main window should raise and set active    // ########## it and then all childen. This belongs in Qt/Embedded    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();	top->setActiveWindow();    }    QWidget *topm = activeModalWidget();    if ( topm && topm != top ) {	topm->show();	topm->raise();	topm->setActiveWindow();	// 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->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;

⌨️ 快捷键说明

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