summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/terminalwidget.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/terminalwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/terminalwidget.cpp191
1 files changed, 191 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/terminalwidget.cpp b/noncore/apps/opie-console/terminalwidget.cpp
new file mode 100644
index 0000000..80627c4
--- a/dev/null
+++ b/noncore/apps/opie-console/terminalwidget.cpp
@@ -0,0 +1,191 @@
1#include <qbuttongroup.h>
2#include <qlabel.h>
3#include <qcheckbox.h>
4#include <qcombobox.h>
5#include <qradiobutton.h>
6#include <qgroupbox.h>
7#include <qvbox.h>
8#include <qhgroupbox.h>
9#include <qlayout.h>
10
11#include "terminalwidget.h"
12
13namespace {
14 enum TermIds {
15 id_term_vt100,
16 id_term_vt220,
17 id_term_ansi
18 };
19
20 enum ColourIds {
21 id_term_black,
22 id_term_white
23 };
24
25 enum FontIds {
26 id_size_small,
27 id_size_medium,
28 id_size_large
29 };
30};
31
32TerminalWidget::TerminalWidget( const QString& name, QWidget* parent,
33 const char* na )
34 : ProfileDialogTerminalWidget( name, parent, na ) {
35
36 m_terminal = new QLabel(tr("Terminal Type"), this );
37 m_terminalBox = new QComboBox(this);
38 m_colorLabel = new QLabel(tr("Color scheme"), this);
39 m_colorCmb = new QComboBox(this );
40
41 m_groupSize = new QButtonGroup(tr("Font size"), this );
42 m_sizeSmall = new QRadioButton(tr("small"), m_groupSize );
43 m_sizeMedium = new QRadioButton(tr("medium"), m_groupSize );
44 m_sizeLarge = new QRadioButton(tr("large"), m_groupSize );
45
46 m_groupConv = new QHGroupBox(tr("Line-break conversions"), this );
47 m_convInbound = new QCheckBox(tr("Inbound"), m_groupConv );
48 m_convOutbound = new QCheckBox(tr("Outbound"), m_groupConv );
49
50 m_groupOptions = new QHGroupBox( tr("Options"), this );
51 m_optionEcho = new QCheckBox(tr("Local echo"), m_groupOptions );
52 m_optionWrap = new QCheckBox(tr("Line wrap"), m_groupOptions );
53
54 m_lroot = new QVBoxLayout(this, 2 );
55 m_typeBox = new QVBoxLayout( m_lroot );
56 m_hbox = new QHBoxLayout( m_groupSize, 2 );
57 m_colorBox = new QVBoxLayout( m_lroot );
58
59 // Layout
60 m_typeBox->add(m_terminal );
61 m_typeBox->add(m_terminalBox );
62
63 m_hbox->add(m_sizeSmall );
64 m_hbox->add(m_sizeMedium );
65 m_hbox->add(m_sizeLarge );
66 m_lroot->add(m_groupSize );
67
68 m_colorBox->add( m_colorLabel );
69 m_colorBox->add( m_colorCmb );
70
71 m_lroot->add(m_groupConv );
72 m_lroot->add(m_groupOptions );
73
74 // Fill in some options
75 m_terminalBox->insertItem( tr("VT 100"), id_term_vt100 );
76 m_terminalBox->insertItem( tr("VT 220"), id_term_vt220 );
77 m_terminalBox->insertItem( tr("ANSI"), id_term_ansi );
78
79 m_colorCmb->insertItem( tr("black on white"), id_term_black );
80 m_colorCmb->insertItem( tr("white on black"), id_term_white );
81
82 // signals + slots
83 /*
84 connect(m_terminalBox, SIGNAL(activated(int) ),
85 this, SLOT(slotTermTerm(int) ) );
86 connect(m_colorBox, SIGNAL(activated(int) ),
87 tis, SLOT(slotTermColor(int) ) );
88 connect(m_groupSize, SIGNAL(activated(int) ),
89 this, SLOT(slotTermFont(int) ) );
90
91 connect(m_optionEcho, SIGNAL(toggled(bool) ),
92 this, SLOT(slotTermEcho(bool) ) );
93 connect(m_optionWrap, SIGNAL(toggled(bool) ),
94 this, SLOT(slotTermWrap(bool) ) );
95 connect(m_convInbound, SIGNAL(toggled(bool) ),
96 this, SLOT(slotTermInbound(bool) ) );
97 connect(m_convOutbound, SIGNAL(toggled(bool) ),
98 this, SLOT(slotTermOutbound(bool) ) );
99*/
100}
101TerminalWidget::~TerminalWidget() {
102}
103void TerminalWidget::load( const Profile& prof ) {
104 int term = prof.readNumEntry("Terminal");
105 int color = prof.readNumEntry("Color");
106 int fontsize = prof.readNumEntry("Font");
107 int opt_echo = prof.readNumEntry("Echo");
108 int opt_wrap = prof.readNumEntry("Wrap");
109 int opt_inbound = prof.readNumEntry("Inbound");
110 int opt_outbound = prof.readNumEntry("Outbound");
111
112 switch( term ) {
113 case Profile::VT102:
114 m_terminalBox->setCurrentItem(id_term_vt100 );
115 break;
116 default:
117 break;
118 };
119
120 switch( color ) {
121 case Profile::Black:
122 m_colorCmb->setCurrentItem(id_term_black );
123 break;
124 case Profile::White:
125 m_colorCmb->setCurrentItem(id_term_white );
126 break;
127 default:
128 break;
129 };
130
131 switch( fontsize ) {
132 case Profile::Micro:
133 m_sizeSmall->setChecked(true );
134 break;
135 case Profile::Small:
136 m_sizeMedium->setChecked(true );
137 break;
138 case Profile::Medium:
139 m_sizeLarge->setChecked( true );
140 break;
141 m_sizeSmall->setChecked(true);
142 default:
143 break;
144 };
145
146 if (opt_echo) m_optionEcho->setChecked( true );
147 if (opt_wrap) m_optionWrap->setChecked( true );
148 if (opt_inbound) m_convInbound->setChecked( true );
149 if (opt_outbound) m_convOutbound->setChecked( true );
150
151}
152void TerminalWidget::save( Profile& profile ) {
153 switch(m_terminalBox->currentItem() ) {
154 case id_term_vt100:
155 profile.writeEntry("Terminal", Profile::VT102 );
156 break;
157 case id_term_vt220:
158 profile.writeEntry("Terminal", Profile::VT102 );
159 break;
160 case id_term_ansi:
161 profile.writeEntry("Terminal", Profile::VT102 );
162 break;
163 default:
164 break;
165 };
166
167 // color
168 switch(m_colorCmb->currentItem() ) {
169 case id_term_black:
170 profile.writeEntry("Color", Profile::Black );
171 break;
172 case id_term_white:
173 profile.writeEntry("Color", Profile::White );
174 break;
175 default:
176 break;
177 };
178
179 if (m_sizeSmall->isChecked() ) {
180 profile.writeEntry("Font", Profile::Micro );
181 }else if (m_sizeMedium->isChecked() ) {
182 profile.writeEntry("Font", Profile::Small );
183 }else {
184 profile.writeEntry("Font", Profile::Medium );
185 }
186
187 profile.writeEntry("Echo", m_optionEcho->isChecked() );
188 profile.writeEntry("Wrap", m_optionWrap->isChecked() );
189 profile.writeEntry("Inbound", m_convInbound->isChecked() );
190 profile.writeEntry("Outbound",m_convOutbound->isChecked() );
191}