Diffstat (limited to 'noncore/apps/opie-console/terminalwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/terminalwidget.cpp | 70 |
1 files changed, 43 insertions, 27 deletions
diff --git a/noncore/apps/opie-console/terminalwidget.cpp b/noncore/apps/opie-console/terminalwidget.cpp index 087476b..3e3b8a6 100644 --- a/noncore/apps/opie-console/terminalwidget.cpp +++ b/noncore/apps/opie-console/terminalwidget.cpp | |||
@@ -1,26 +1,28 @@ | |||
1 | #include "terminalwidget.h" | 1 | #include "terminalwidget.h" |
2 | 2 | ||
3 | /* OPIE */ | 3 | /* OPIE */ |
4 | #include <opie2/odebug.h> | 4 | #include <opie2/odebug.h> |
5 | |||
5 | using namespace Opie::Core; | 6 | using namespace Opie::Core; |
6 | 7 | ||
7 | /* QT */ | 8 | /* QT */ |
8 | #include <qlabel.h> | 9 | #include <qlabel.h> |
9 | #include <qcheckbox.h> | 10 | #include <qcheckbox.h> |
10 | #include <qcombobox.h> | 11 | #include <qcombobox.h> |
11 | #include <qradiobutton.h> | 12 | #include <qradiobutton.h> |
12 | #include <qhgroupbox.h> | 13 | #include <qhgroupbox.h> |
13 | #include <qhbuttongroup.h> | 14 | #include <qhbuttongroup.h> |
14 | #include <qlayout.h> | 15 | #include <qlayout.h> |
16 | #include <qhbox.h> | ||
15 | 17 | ||
16 | namespace { | 18 | namespace { |
17 | enum TermIds { | 19 | enum TermIds { |
18 | id_term_vt100 = 0, | 20 | id_term_vt100 = 0, |
19 | id_term_vt102, | 21 | id_term_vt102, |
20 | id_term_linux, | 22 | id_term_linux, |
21 | id_term_xterm | 23 | id_term_xterm |
22 | }; | 24 | }; |
23 | 25 | ||
24 | enum ColourIds { | 26 | enum ColourIds { |
25 | id_term_black, | 27 | id_term_black, |
26 | id_term_white, | 28 | id_term_white, |
@@ -35,55 +37,59 @@ namespace { | |||
35 | }; | 37 | }; |
36 | }; | 38 | }; |
37 | 39 | ||
38 | TerminalWidget::TerminalWidget( const QString& name, QWidget* parent, | 40 | TerminalWidget::TerminalWidget( const QString& name, QWidget* parent, |
39 | const char* na ) | 41 | const char* na ) |
40 | : ProfileDialogTerminalWidget( name, parent, na ) { | 42 | : ProfileDialogTerminalWidget( name, parent, na ) { |
41 | 43 | ||
42 | m_terminal = new QLabel(tr("Terminal Type"), this ); | 44 | m_terminal = new QLabel(tr("Terminal Type"), this ); |
43 | m_terminalBox = new QComboBox(this); | 45 | m_terminalBox = new QComboBox(this); |
44 | m_colorLabel = new QLabel(tr("Color scheme"), this); | 46 | m_colorLabel = new QLabel(tr("Color scheme"), this); |
45 | m_colorCmb = new QComboBox(this ); | 47 | m_colorCmb = new QComboBox(this ); |
46 | 48 | ||
47 | m_groupSize = new QHButtonGroup(tr("Font size"), this ); | 49 | // m_groupSize = new QHButtonGroup(tr("Font size"), this ); |
48 | m_sizeSmall = new QRadioButton(tr("small"), m_groupSize ); | 50 | m_groupSize = new QHBox( this ); |
49 | m_sizeMedium = new QRadioButton(tr("medium"), m_groupSize ); | 51 | m_fontSelector = new Opie::Ui::OFontSelector( false, m_groupSize ); |
50 | m_sizeLarge = new QRadioButton(tr("large"), m_groupSize ); | 52 | |
53 | // m_sizeSmall = new QRadioButton(tr("small"), m_groupSize ); | ||
54 | // m_sizeMedium = new QRadioButton(tr("medium"), m_groupSize ); | ||
55 | // m_sizeLarge = new QRadioButton(tr("large"), m_groupSize ); | ||
51 | 56 | ||
52 | m_groupConv = new QHGroupBox( tr("Line-break conversions"), this ); | 57 | m_groupConv = new QHGroupBox( tr("Line-break conversions"), this ); |
53 | m_convInbound = new QCheckBox( tr("Inbound"), m_groupConv ); | 58 | m_convInbound = new QCheckBox( tr("Inbound"), m_groupConv ); |
54 | m_convOutbound = new QCheckBox( tr("Outbound"), m_groupConv ); | 59 | m_convOutbound = new QCheckBox( tr("Outbound"), m_groupConv ); |
55 | 60 | ||
61 | |||
56 | m_groupOptions = new QHGroupBox( tr("Options"), this ); | 62 | m_groupOptions = new QHGroupBox( tr("Options"), this ); |
57 | m_optionEcho = new QCheckBox( tr("Local echo"), m_groupOptions ); | 63 | m_optionEcho = new QCheckBox( tr("Local echo"), m_groupOptions ); |
58 | m_optionWrap = new QCheckBox( tr("Line wrap"), m_groupOptions ); | 64 | m_optionWrap = new QCheckBox( tr("Line wrap"), m_groupOptions ); |
59 | 65 | ||
60 | m_lroot = new QVBoxLayout( this ); | 66 | m_lroot = new QVBoxLayout( this ); |
61 | m_typeBox = new QVBoxLayout( m_lroot ); | 67 | m_typeBox = new QVBoxLayout( m_lroot ); |
62 | m_colorBox = new QVBoxLayout( m_lroot ); | 68 | m_colorBox = new QVBoxLayout( m_lroot ); |
63 | 69 | ||
64 | // Layout | 70 | // Layout |
65 | m_typeBox->add( m_terminal ); | 71 | m_typeBox->add( m_terminal ); |
66 | m_typeBox->add( m_terminalBox ); | 72 | m_typeBox->add( m_terminalBox ); |
67 | m_lroot->add( m_groupSize ); | 73 | m_lroot->add( m_groupSize ); |
68 | 74 | ||
69 | m_colorBox->add( m_colorLabel ); | 75 | m_colorBox->add( m_colorLabel ); |
70 | m_colorBox->add( m_colorCmb ); | 76 | m_colorBox->add( m_colorCmb ); |
71 | 77 | ||
72 | m_lroot->add( m_groupConv ); | 78 | m_lroot->add( m_groupConv ); |
73 | m_lroot->add( m_groupOptions ); | 79 | m_lroot->add( m_groupOptions ); |
74 | m_lroot->addStretch( 0 ); | 80 | m_lroot->addStretch( 0 ); |
75 | 81 | ||
76 | // Fill in some options | 82 | // Fill in some options |
77 | owarn << "Options for terminal box" << oendl; | 83 | owarn << "Options for terminal box" << oendl; |
78 | m_terminalBox->insertItem( tr("VT 100"), 0 ); // /*, id_term_vt100*/ ); | 84 | m_terminalBox->insertItem( tr("VT 100"), 0 ); // /*, id_term_vt100*/ ); |
79 | m_terminalBox->insertItem( tr("VT 102"), 1 ); // /* , id_term_vt102 */); | 85 | m_terminalBox->insertItem( tr("VT 102"), 1 ); // /* , id_term_vt102 */); |
80 | m_terminalBox->insertItem( tr("Linux Console"), 2 ); //, id_term_linux ); | 86 | m_terminalBox->insertItem( tr("Linux Console"), 2 ); //, id_term_linux ); |
81 | m_terminalBox->insertItem( tr("X-Terminal"), 3 ); //, id_term_xterm ); | 87 | m_terminalBox->insertItem( tr("X-Terminal"), 3 ); //, id_term_xterm ); |
82 | //m_terminalBox->insertItem( tr("ANSI"), id_term_ansi ); | 88 | //m_terminalBox->insertItem( tr("ANSI"), id_term_ansi ); |
83 | 89 | ||
84 | m_colorCmb->insertItem( tr("black on white"), id_term_black ); | 90 | m_colorCmb->insertItem( tr("black on white"), id_term_black ); |
85 | m_colorCmb->insertItem( tr("white on black"), id_term_white ); | 91 | m_colorCmb->insertItem( tr("white on black"), id_term_white ); |
86 | m_colorCmb->insertItem( tr("green on black"), id_term_green ); | 92 | m_colorCmb->insertItem( tr("green on black"), id_term_green ); |
87 | m_colorCmb->insertItem( tr("orange on black"), id_term_orange ); | 93 | m_colorCmb->insertItem( tr("orange on black"), id_term_orange ); |
88 | 94 | ||
89 | // signals + slots | 95 | // signals + slots |
@@ -101,25 +107,25 @@ TerminalWidget::TerminalWidget( const QString& name, QWidget* parent, | |||
101 | this, SLOT(slotTermWrap(bool) ) ); | 107 | this, SLOT(slotTermWrap(bool) ) ); |
102 | connect(m_convInbound, SIGNAL(toggled(bool) ), | 108 | connect(m_convInbound, SIGNAL(toggled(bool) ), |
103 | this, SLOT(slotTermInbound(bool) ) ); | 109 | this, SLOT(slotTermInbound(bool) ) ); |
104 | connect(m_convOutbound, SIGNAL(toggled(bool) ), | 110 | connect(m_convOutbound, SIGNAL(toggled(bool) ), |
105 | this, SLOT(slotTermOutbound(bool) ) ); | 111 | this, SLOT(slotTermOutbound(bool) ) ); |
106 | */ | 112 | */ |
107 | } | 113 | } |
108 | TerminalWidget::~TerminalWidget() { | 114 | TerminalWidget::~TerminalWidget() { |
109 | } | 115 | } |
110 | void TerminalWidget::load( const Profile& prof ) { | 116 | void TerminalWidget::load( const Profile& prof ) { |
111 | int term = prof.readNumEntry("Terminal"); | 117 | int term = prof.readNumEntry("Terminal"); |
112 | int color = prof.readNumEntry("Color"); | 118 | int color = prof.readNumEntry("Color"); |
113 | int fontsize = prof.readNumEntry("Font"); | 119 | // int fontsize = prof.readNumEntry("Font"); |
114 | int opt_echo = prof.readNumEntry("Echo"); | 120 | int opt_echo = prof.readNumEntry("Echo"); |
115 | int opt_wrap = prof.readNumEntry("Wrap"); | 121 | int opt_wrap = prof.readNumEntry("Wrap"); |
116 | int opt_inbound = prof.readNumEntry("Inbound"); | 122 | int opt_inbound = prof.readNumEntry("Inbound"); |
117 | int opt_outbound = prof.readNumEntry("Outbound"); | 123 | int opt_outbound = prof.readNumEntry("Outbound"); |
118 | 124 | ||
119 | switch( term ) { | 125 | switch( term ) { |
120 | case Profile::VT100: | 126 | case Profile::VT100: |
121 | m_terminalBox->setCurrentItem(id_term_vt100 ); | 127 | m_terminalBox->setCurrentItem(id_term_vt100 ); |
122 | break; | 128 | break; |
123 | case Profile::VT102: | 129 | case Profile::VT102: |
124 | m_terminalBox->setCurrentItem(id_term_vt102 ); | 130 | m_terminalBox->setCurrentItem(id_term_vt102 ); |
125 | break; | 131 | break; |
@@ -142,38 +148,41 @@ void TerminalWidget::load( const Profile& prof ) { | |||
142 | m_colorCmb->setCurrentItem(id_term_white ); | 148 | m_colorCmb->setCurrentItem(id_term_white ); |
143 | break; | 149 | break; |
144 | case Profile::Green: | 150 | case Profile::Green: |
145 | m_colorCmb->setCurrentItem(id_term_green ); | 151 | m_colorCmb->setCurrentItem(id_term_green ); |
146 | break; | 152 | break; |
147 | case Profile::Orange: | 153 | case Profile::Orange: |
148 | m_colorCmb->setCurrentItem(id_term_orange ); | 154 | m_colorCmb->setCurrentItem(id_term_orange ); |
149 | break; | 155 | break; |
150 | default: | 156 | default: |
151 | break; | 157 | break; |
152 | }; | 158 | }; |
153 | 159 | ||
154 | switch( fontsize ) { | 160 | |
155 | case Profile::Micro: | 161 | m_fontSelector->setSelectedFont( prof.readEntry( "Font"), prof.readEntry( "FontStyle"), prof.readNumEntry( "FontSize" ), prof.readEntry( "FontCharset") ); |
156 | m_sizeSmall->setChecked(true ); | 162 | |
157 | break; | 163 | // switch( fontsize ) { |
158 | case Profile::Small: | 164 | // case Profile::Micro: |
159 | m_sizeMedium->setChecked(true ); | 165 | // m_sizeSmall->setChecked(true ); |
160 | break; | 166 | // break; |
161 | case Profile::Medium: | 167 | // case Profile::Small: |
162 | m_sizeLarge->setChecked( true ); | 168 | // m_sizeMedium->setChecked(true ); |
163 | break; | 169 | // break; |
164 | default: | 170 | // case Profile::Medium: |
165 | m_sizeMedium->setChecked(true ); | 171 | // m_sizeLarge->setChecked( true ); |
166 | break; | 172 | // break; |
167 | }; | 173 | // default: |
174 | // m_sizeMedium->setChecked(true ); | ||
175 | // break; | ||
176 | // }; | ||
168 | 177 | ||
169 | if (opt_echo) m_optionEcho->setChecked( true ); | 178 | if (opt_echo) m_optionEcho->setChecked( true ); |
170 | if (opt_wrap) m_optionWrap->setChecked( true ); | 179 | if (opt_wrap) m_optionWrap->setChecked( true ); |
171 | if (opt_inbound) m_convInbound->setChecked( true ); | 180 | if (opt_inbound) m_convInbound->setChecked( true ); |
172 | if (opt_outbound) m_convOutbound->setChecked( true ); | 181 | if (opt_outbound) m_convOutbound->setChecked( true ); |
173 | 182 | ||
174 | } | 183 | } |
175 | void TerminalWidget::save( Profile& profile ) { | 184 | void TerminalWidget::save( Profile& profile ) { |
176 | switch(m_terminalBox->currentItem() ) { | 185 | switch(m_terminalBox->currentItem() ) { |
177 | case id_term_vt100: | 186 | case id_term_vt100: |
178 | profile.writeEntry("Terminal", Profile::VT100 ); | 187 | profile.writeEntry("Terminal", Profile::VT100 ); |
179 | break; | 188 | break; |
@@ -202,25 +211,32 @@ void TerminalWidget::save( Profile& profile ) { | |||
202 | profile.writeEntry("Color", Profile::White ); | 211 | profile.writeEntry("Color", Profile::White ); |
203 | break; | 212 | break; |
204 | case id_term_green: | 213 | case id_term_green: |
205 | profile.writeEntry("Color", Profile::Green ); | 214 | profile.writeEntry("Color", Profile::Green ); |
206 | break; | 215 | break; |
207 | case id_term_orange: | 216 | case id_term_orange: |
208 | profile.writeEntry("Color", Profile::Orange ); | 217 | profile.writeEntry("Color", Profile::Orange ); |
209 | break; | 218 | break; |
210 | default: | 219 | default: |
211 | break; | 220 | break; |
212 | }; | 221 | }; |
213 | 222 | ||
214 | if (m_sizeSmall->isChecked() ) { | 223 | |
215 | profile.writeEntry("Font", Profile::Micro ); | 224 | profile.writeEntry( "FontSize", m_fontSelector->fontSize() ); |
216 | }else if (m_sizeMedium->isChecked() ) { | 225 | profile.writeEntry( "FontStyle", m_fontSelector->fontStyle() ); |
217 | profile.writeEntry("Font", Profile::Small ); | 226 | profile.writeEntry( "FontCharset", m_fontSelector->fontCharSet() ); |
218 | }else { | 227 | profile.writeEntry( "Font", m_fontSelector->fontFamily() ); |
219 | profile.writeEntry("Font", Profile::Medium ); | 228 | |
220 | } | 229 | |
230 | // if (m_sizeSmall->isChecked() ) { | ||
231 | // profile.writeEntry("Font", Profile::Micro ); | ||
232 | // }else if (m_sizeMedium->isChecked() ) { | ||
233 | // profile.writeEntry("Font", Profile::Small ); | ||
234 | // }else { | ||
235 | // profile.writeEntry("Font", Profile::Medium ); | ||
236 | // } | ||
221 | 237 | ||
222 | profile.writeEntry("Echo", m_optionEcho->isChecked() ); | 238 | profile.writeEntry("Echo", m_optionEcho->isChecked() ); |
223 | profile.writeEntry("Wrap", m_optionWrap->isChecked() ); | 239 | profile.writeEntry("Wrap", m_optionWrap->isChecked() ); |
224 | profile.writeEntry("Inbound", m_convInbound->isChecked() ); | 240 | profile.writeEntry("Inbound", m_convInbound->isChecked() ); |
225 | profile.writeEntry("Outbound",m_convOutbound->isChecked() ); | 241 | profile.writeEntry("Outbound",m_convOutbound->isChecked() ); |
226 | } | 242 | } |