📄 launcher.cpp.bak
字号:
"<h2>The beauty of it</h2>\n" "\n" "Qt/Embedded features some great additional functionality compared\n" "to X11. You will be stunned by the beauty of anti-aliased text and alpha\n" "blended pixmaps. These new features could add an additional touch of class to a\n" "user interface. Forget about embedded graphics which looks more like old\n" "alphanumeric terminals. Qt/Embedded can utilize hardware graphics acceleration\n" "and it is well suited for multimedia and web applications. Let Qt/Embedded\n" "impress you and your customers.\n", "\n" "<h2>Getting there faster</h2>\n" "\n" "Qt is one of the most popular GUI toolkits in the world.\n" "Programmers like the compact code,the powerful API,the ease of use, and the\n" "excellent support. It is easy to find existing developer skills with Qt and a\n" "lot of quality Qt based code has already been written. Qt/Embedded allows you\n" "and your programmers to move seamlessly into the exciting field of embedded\n" "systems. Your Qt experts don't need to be retrained. Our customers tell us that\n" "even programmers without Qt experience get up to speed sooner with Qt than with\n" "other toolkits.\n", "\n" "<h2>We support you</h2>\n" "\n" "Embedded devices have other requirements than conventional\n" "computers. The Qt/Embedded team at Trolltech is dedicated to support you with\n" "new features and widgets. We can offer training, partnerships and first class\n" "support. It is straightforward to port Qt/Embedded to new hardware. We can\n" "offer you a port to your special device or the embedded operating system of\n" "your choice. We look forward to working closely with you to help you succeed.\n", 0 }; QString t=infotext[i]; info->setText( "<blockquote>" +t+ "</blockquote>" ); i++; if (!infotext[i]) i=0; } void quit3() { qApp->exit(3); } void run(const char* cmd) { QString c = cmd; // c += " 2>/dev/null >/dev/null"; c += " &"; system(c.latin1()); } void execute() { run(sender()->name()); } void executeOther(int i) { run(other_command[i].file); } void setAntiAliasedText(bool on) { if ( on ) { unsetenv("QWS_NO_SMOOTH_FONTS"); } else { setenv("QWS_NO_SMOOTH_FONTS","1",1); } } void setAcceleration(bool on) { if ( on ) { unsetenv("QWS_NOACCEL"); } else { setenv("QWS_NOACCEL","1",1); } } void setRotation( int r ) {#if !defined(QT_NO_QWS_TRANSFORMED) switch ( r ) { case 0: unsetenv( "QWS_DISPLAY" ); break; case 1: setenv( "QWS_DISPLAY", "Transformed:Rot90:0", 1 ); break; case 2: setenv( "QWS_DISPLAY", "Transformed:Rot180:0", 1 ); break; case 3: setenv( "QWS_DISPLAY", "Transformed:Rot270:0", 1 ); break; }#endif }private: QLabel* info;};#include "launcher.moc"#ifdef _WS_QWS_#include <qmap.h>#include <qfile.h>#include <qtextstream.h>class SimpleIM : public QWSServer::KeyboardFilter{public: SimpleIM( const QString &fn ); bool filter(int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat);private: int backspaces( const QString &s ); bool active; unsigned int maxlen; QMap<QString,QString> map; QString soFar;};SimpleIM::SimpleIM( const QString &fn ){ active = FALSE; maxlen = 0; QFile f( fn ); if ( f.open(IO_ReadOnly) ) { QTextStream t( &f ); // use a text stream QString s; while ( !t.eof() ) { // until end of file... s = t.readLine(); // line of text excluding '\n' int p = s.find( '\t' ); if ( p >= -1 ) { QString s1 = s.left( p ); QString s2 = s.mid( p+1 ); map[s1] = s2; maxlen = QMAX( maxlen, s1.length() ); } } f.close(); } qDebug( "maxlen = %d", maxlen );}static void sendKey( int unicode, int keycode ){ QWSServer::sendKeyEvent( unicode, keycode, 0, TRUE, FALSE ); QWSServer::sendKeyEvent( unicode, keycode, 0, FALSE, FALSE );}static void sendString( const QString &s ){ for ( int i = 0; i < int(s.length()); i++ ) sendKey( s[i].unicode(), 0 );}/* How many backspaces do I need to send in order to remove \a str?*/int SimpleIM::backspaces( const QString &str ){ int r = 0; QString s = str; while ( !s.isEmpty() ) { qDebug( "testing %s", s.latin1() ); int n = s.length(); while ( n > 0 ) { QString sub = s.right( n ); if ( map.contains( sub ) ) { r += map[sub].length(); break; } n--; } if ( n == 0 ) { n = 1; r++; } s = s.left(s.length()-n); } return r;}/* Watch all keypresses. Toggle active mode when shift+space is seen. In active mode: Put each key pressed into the buffer soFar. When the contents of soFar match an entry in map, send backspace keypresses to remove the source characters and then send the mapped string. This is just a simple example. Production code would have to handle key releases as well. */bool SimpleIM::filter(int unicode, int keycode, int modifiers, bool isPress, bool /*autoRepeat*/ ){ if ( modifiers == Qt::ShiftButton && keycode == Qt::Key_Space ) { if ( !isPress ) { active = !active; } return TRUE; //filter } if ( active && !(modifiers&~Qt::ShiftButton) ) { if ( isPress && keycode != Qt::Key_Shift ) { soFar = soFar + QChar( unicode ); soFar = soFar.right( maxlen ); int n = soFar.length(); while ( n > 0 ) { QString candidate = soFar.right( n ); if ( map.contains( candidate ) ) { int bc = backspaces( candidate.left(n-1) ); for ( int i = 0; i < bc; i++ ) sendKey( 0, Qt::Key_Backspace); sendString( map[candidate] ); soFar=soFar.right(n); return TRUE; //filter } n--; } } return FALSE; //don't filter } soFar = ""; return FALSE; //don't filter}#endifvoid silent(QtMsgType, const char *){}int main(int argc, char** argv){ QApplication app(argc,argv, QApplication::GuiServer); qInstallMsgHandler(silent); app.setFont(QFont("smoothtimes",22));#ifdef _WS_QWS_ if ( QString(argv[1]) == "-im" && argv[2] ) { SimpleIM* im = new SimpleIM( argv[2] ); QWSServer::setKeyboardFilter( im ); }/* // Custom 40 grey palette QRgb cols[40]; for ( int i = 0; i < 40; i++ ) { int c = i*256/40; cols[i] = qRgb( c, c, c ); } app.qwsSetCustomColors( cols, 0, 40 );*/#endif Launcher l; app.setMainWidget(&l); l.showMaximized(); return app.exec();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -