-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index 48218e6..9f34d2c 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp | |||
@@ -1,131 +1,131 @@ | |||
1 | #include <qwidget.h> | 1 | #include <qwidget.h> |
2 | 2 | ||
3 | #include "TEWidget.h" | 3 | #include "TEWidget.h" |
4 | #include "TEmuVt102.h" | 4 | #include "TEmuVt102.h" |
5 | 5 | ||
6 | #include "profile.h" | 6 | #include "profile.h" |
7 | #include "emulation_handler.h" | 7 | #include "emulation_handler.h" |
8 | 8 | ||
9 | 9 | ||
10 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) | 10 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) |
11 | : QObject(0, name ) | 11 | : QObject(0, name ) |
12 | { | 12 | { |
13 | m_teWid = new TEWidget( parent, "TerminalMain"); | 13 | m_teWid = new TEWidget( parent, "TerminalMain"); |
14 | m_teWid->setMinimumSize(150, 70 ); | 14 | m_teWid->setMinimumSize(150, 70 ); |
15 | parent->resize( m_teWid->calcSize(80, 24 ) ); | 15 | parent->resize( m_teWid->calcSize(80, 24 ) ); |
16 | m_teEmu = new TEmuVt102(m_teWid ); | 16 | m_teEmu = new TEmuVt102(m_teWid ); |
17 | 17 | ||
18 | connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), | 18 | connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), |
19 | this, SIGNAL(changeSize(int, int) ) ); | 19 | this, SIGNAL(changeSize(int, int) ) ); |
20 | connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), | 20 | connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), |
21 | this, SLOT(recvEmulation(const char*, int) ) ); | 21 | this, SLOT(recvEmulation(const char*, int) ) ); |
22 | m_teEmu->setConnect( true ); | 22 | m_teEmu->setConnect( true ); |
23 | m_teEmu->setHistory( TRUE ); | 23 | m_teEmu->setHistory( TRUE ); |
24 | load( prof ); | 24 | load( prof ); |
25 | 25 | ||
26 | 26 | ||
27 | 27 | ||
28 | } | 28 | } |
29 | EmulationHandler::~EmulationHandler() { | 29 | EmulationHandler::~EmulationHandler() { |
30 | delete m_teEmu; | 30 | delete m_teEmu; |
31 | delete m_teWid; | 31 | delete m_teWid; |
32 | } | 32 | } |
33 | void EmulationHandler::load( const Profile& prof) { | 33 | void EmulationHandler::load( const Profile& prof) { |
34 | m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); | 34 | m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); |
35 | int num = prof.readNumEntry("Color"); | 35 | int num = prof.readNumEntry("Color"); |
36 | setColor( foreColor(num), backColor(num) ); | 36 | setColor( foreColor(num), backColor(num) ); |
37 | m_teWid->setBackgroundColor(backColor(num) ); | 37 | m_teWid->setBackgroundColor(backColor(num) ); |
38 | } | 38 | } |
39 | void EmulationHandler::recv( const QByteArray& ar) { | 39 | void EmulationHandler::recv( const QByteArray& ar) { |
40 | qWarning("received in EmulationHandler!"); | 40 | qWarning("received in EmulationHandler!"); |
41 | m_teEmu->onRcvBlock(ar.data(), ar.count() ); | 41 | m_teEmu->onRcvBlock(ar.data(), ar.count() ); |
42 | } | 42 | } |
43 | void EmulationHandler::recvEmulation(const char* src, int len ) { | 43 | void EmulationHandler::recvEmulation(const char* src, int len ) { |
44 | qWarning("received from te "); | 44 | qWarning("received from te "); |
45 | QByteArray ar(len); | 45 | QByteArray ar(len); |
46 | 46 | ||
47 | memcpy(ar.data(), src, sizeof(char) * len ); | 47 | memcpy(ar.data(), src, sizeof(char) * len ); |
48 | 48 | ||
49 | emit send(ar); | 49 | emit send(ar); |
50 | } | 50 | } |
51 | QWidget* EmulationHandler::widget() { | 51 | QWidget* EmulationHandler::widget() { |
52 | return m_teWid; | 52 | return m_teWid; |
53 | } | 53 | } |
54 | /* | 54 | /* |
55 | * allocate a new table of colors | 55 | * allocate a new table of colors |
56 | */ | 56 | */ |
57 | void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { | 57 | void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { |
58 | ColorEntry table[TABLE_COLORS]; | 58 | ColorEntry table[TABLE_COLORS]; |
59 | const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); | 59 | const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); |
60 | 60 | ||
61 | for (int i = 0; i < TABLE_COLORS; i++ ) { | 61 | for (int i = 0; i < TABLE_COLORS; i++ ) { |
62 | if ( i == 0 || i == 10 ) { | 62 | if ( i == 0 || i == 10 ) { |
63 | table[i].color = fore; | 63 | table[i].color = fore; |
64 | }else if ( i == 1 || i == 11 ) { | 64 | }else if ( i == 1 || i == 11 ) { |
65 | table[i].color = back; | 65 | table[i].color = back; |
66 | table[i].transparent = 0; | 66 | table[i].transparent = 0; |
67 | }else { | 67 | }else { |
68 | table[i].color = defaultCt[i].color; | 68 | table[i].color = defaultCt[i].color; |
69 | } | 69 | } |
70 | } | 70 | } |
71 | // m_teWid->setColorTable(table ); | 71 | m_teWid->setColorTable(table ); |
72 | m_teWid->update(); | 72 | m_teWid->update(); |
73 | } | 73 | } |
74 | QFont EmulationHandler::font( int id ) { | 74 | QFont EmulationHandler::font( int id ) { |
75 | QString name; | 75 | QString name; |
76 | int size = 0; | 76 | int size = 0; |
77 | switch(id ) { | 77 | switch(id ) { |
78 | default: // fall through | 78 | default: // fall through |
79 | case 0: | 79 | case 0: |
80 | name = QString::fromLatin1("Micro"); | 80 | name = QString::fromLatin1("Micro"); |
81 | size = 4; | 81 | size = 4; |
82 | break; | 82 | break; |
83 | case 1: | 83 | case 1: |
84 | name = QString::fromLatin1("Fixed"); | 84 | name = QString::fromLatin1("Fixed"); |
85 | size = 7; | 85 | size = 7; |
86 | break; | 86 | break; |
87 | case 2: | 87 | case 2: |
88 | name = QString::fromLatin1("Fixed"); | 88 | name = QString::fromLatin1("Fixed"); |
89 | size = 12; | 89 | size = 12; |
90 | break; | 90 | break; |
91 | } | 91 | } |
92 | QFont font(name, size, QFont::Normal ); | 92 | QFont font(name, size, QFont::Normal ); |
93 | font.setFixedPitch(TRUE ); | 93 | font.setFixedPitch(TRUE ); |
94 | return font; | 94 | return font; |
95 | } | 95 | } |
96 | QColor EmulationHandler::foreColor(int col) { | 96 | QColor EmulationHandler::foreColor(int col) { |
97 | QColor co; | 97 | QColor co; |
98 | /* we need to switch it */ | 98 | /* we need to switch it */ |
99 | switch( col ) { | 99 | switch( col ) { |
100 | default: | 100 | default: |
101 | case Profile::White: | 101 | case Profile::White: |
102 | qWarning("Foreground black"); | 102 | qWarning("Foreground black"); |
103 | /* color is black */ | 103 | /* color is black */ |
104 | co = Qt::black; | 104 | co = Qt::white; |
105 | break; | 105 | break; |
106 | case Profile::Black: | 106 | case Profile::Black: |
107 | qWarning("Foreground white"); | 107 | qWarning("Foreground white"); |
108 | co = Qt::white; | 108 | co = Qt::black; |
109 | break; | 109 | break; |
110 | } | 110 | } |
111 | 111 | ||
112 | return co; | 112 | return co; |
113 | } | 113 | } |
114 | QColor EmulationHandler::backColor(int col ) { | 114 | QColor EmulationHandler::backColor(int col ) { |
115 | QColor co; | 115 | QColor co; |
116 | /* we need to switch it */ | 116 | /* we need to switch it */ |
117 | switch( col ) { | 117 | switch( col ) { |
118 | default: | 118 | default: |
119 | case Profile::White: | 119 | case Profile::White: |
120 | qWarning("Background white"); | 120 | qWarning("Background white"); |
121 | /* color is white */ | 121 | /* color is white */ |
122 | co = Qt::white; | 122 | co = Qt::black; |
123 | break; | 123 | break; |
124 | case Profile::Black: | 124 | case Profile::Black: |
125 | qWarning("Background black"); | 125 | qWarning("Background black"); |
126 | co = Qt::black; | 126 | co = Qt::white; |
127 | break; | 127 | break; |
128 | } | 128 | } |
129 | 129 | ||
130 | return co; | 130 | return co; |
131 | } | 131 | } |