summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-08 20:03:29 (UTC)
committer zecke <zecke>2002-10-08 20:03:29 (UTC)
commit9237d1adcf23ee11f16881fbeea51e0bb3ec0b2f (patch) (unidiff)
treeda7ac82c0abd3948d5e18e6e8db3a9277d4922ac
parentb81a4afcb4d363bf1ee50aa7b43a1f1566addc9d (diff)
downloadopie-9237d1adcf23ee11f16881fbeea51e0bb3ec0b2f.zip
opie-9237d1adcf23ee11f16881fbeea51e0bb3ec0b2f.tar.gz
opie-9237d1adcf23ee11f16881fbeea51e0bb3ec0b2f.tar.bz2
Default added the TerminalEmulation Widget
MainWindow: do save the profiles on deconstruction MetaFactory Brown Paper bag bug fixed. take care of the right name in terminalWidget.... opie-console.pro add the widgets IOLayerBase a basic widget for speed, parity and flow control settings Terminal Widget a the ported TerminalConfiguration dialog
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/default.cpp5
-rw-r--r--noncore/apps/opie-console/iolayerbase.cpp123
-rw-r--r--noncore/apps/opie-console/iolayerbase.h47
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp1
-rw-r--r--noncore/apps/opie-console/metafactory.cpp2
-rw-r--r--noncore/apps/opie-console/opie-console.pro8
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp11
-rw-r--r--noncore/apps/opie-console/terminalwidget.cpp191
-rw-r--r--noncore/apps/opie-console/terminalwidget.h46
9 files changed, 427 insertions, 7 deletions
diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp
index 78495d2..4ab4695 100644
--- a/noncore/apps/opie-console/default.cpp
+++ b/noncore/apps/opie-console/default.cpp
@@ -1,4 +1,5 @@
1#include "io_serial.h" 1#include "io_serial.h"
2#include "sz_transfer.h" 2#include "sz_transfer.h"
3#include "terminalwidget.h"
3 4
4#include "default.h" 5#include "default.h"
@@ -39,6 +40,6 @@ extern "C" {
39 40
40 // Terminal Widget(s) 41 // Terminal Widget(s)
41 ProfileDialogWidget* newTerminalWidget(const QString&, QWidget* ) { 42 ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) {
42 return 0l; 43 return new TerminalWidget(na, wid,0 );
43 } 44 }
44 45
diff --git a/noncore/apps/opie-console/iolayerbase.cpp b/noncore/apps/opie-console/iolayerbase.cpp
new file mode 100644
index 0000000..1e164fe
--- a/dev/null
+++ b/noncore/apps/opie-console/iolayerbase.cpp
@@ -0,0 +1,123 @@
1#include <qlabel.h>
2#include <qlayout.h>
3#include <qcombobox.h>
4#include <qbuttongroup.h>
5#include <qhbuttongroup.h>
6#include <qradiobutton.h>
7
8#include "iolayerbase.h"
9
10namespace {
11 enum ParityIds {
12 id_parity_odd,
13 id_parity_even
14 };
15
16 enum FlowIds {
17 id_flow_hw,
18 id_flow_sw
19 };
20
21 enum SpeedIds {
22 id_baud_115200,
23 id_baud_57600,
24 id_baud_38400,
25 id_baud_19200,
26 id_baud_9600
27 };
28
29}
30
31
32IOLayerBase::IOLayerBase( QWidget* par, const char* name )
33 : QWidget( par, name )
34{
35 m_speedLabel = new QLabel(tr("Speed"), this );
36 m_speedBox = new QComboBox(this );
37
38 m_groupFlow = new QButtonGroup(tr("Flow control") );
39 m_flowHw = new QRadioButton(tr("Hardware"), m_groupFlow );
40 m_flowSw = new QRadioButton(tr("Software"), m_groupFlow );
41
42 m_groupParity = new QButtonGroup(tr("Parity"), this );
43 m_parityOdd = new QRadioButton(tr("Odd"), m_groupParity );
44 m_parityEven = new QRadioButton(tr("Even"), m_groupParity );
45
46 m_lroot = new QVBoxLayout(this );
47 m_lroot->add(m_speedLabel );
48 m_lroot->add(m_speedBox );
49 m_lroot->setStretchFactor(m_speedLabel, 1);
50 m_lroot->setStretchFactor(m_speedBox, 1 );
51
52 m_hbox = new QHBoxLayout(m_groupFlow, 2 );
53 m_hbox->add(m_flowHw );
54 m_hbox->add(m_flowSw );
55 m_lroot->add(m_groupFlow );
56 m_lroot->setStretchFactor(m_groupFlow, 2 );
57
58 m_hboxPar = new QHBoxLayout( m_groupParity, 2 );
59 m_hboxPar->add(m_parityOdd );
60 m_hboxPar->add(m_parityEven );
61 m_lroot->add(m_groupParity );
62 m_lroot->setStretchFactor(m_groupParity, 2 );
63
64 // profiles
65 m_speedBox->insertItem(tr("115200 baud"), id_baud_115200 );
66 m_speedBox->insertItem(tr("57600 baud"), id_baud_57600 );
67 m_speedBox->insertItem(tr("38400 baud"), id_baud_38400 );
68 m_speedBox->insertItem(tr("19200 baud"), id_baud_19200 );
69 m_speedBox->insertItem(tr("9600 baud"), id_baud_9600 );
70};
71IOLayerBase::~IOLayerBase() {
72
73}
74void IOLayerBase::setFlow( Flow flo ) {
75 switch ( flo ) {
76 case Software:
77 m_flowSw->setChecked( true );
78 break;
79 case Hardware:
80 m_flowHw->setChecked( true );
81 break;
82 }
83}
84void IOLayerBase::setParity( Parity par ) {
85 switch( par ) {
86 case Odd:
87 m_parityOdd->setChecked( true );
88 break;
89 case Even:
90 m_parityEven->setChecked( true );
91 break;
92 }
93}
94void IOLayerBase::setSpeed( Speed sp ) {
95 int index;
96 switch( sp ) {
97 case Baud_115200:
98 index = id_baud_115200;
99 break;
100 case Baud_57600:
101 index = id_baud_57600;
102 break;
103 case Baud_38400:
104 index = id_baud_38400;
105 break;
106 case Baud_19200:
107 index = id_baud_19200;
108 break;
109 case Baud_9600:
110 index = id_baud_9600;
111 break;
112 }
113 m_speedBox->setCurrentItem(index );
114}
115IOLayerBase::Flow IOLayerBase::flow()const {
116 return Hardware;
117}
118IOLayerBase::Parity IOLayerBase::parity()const {
119 return Odd;
120}
121IOLayerBase::Speed IOLayerBase::speed()const{
122 return Baud_9600;
123}
diff --git a/noncore/apps/opie-console/iolayerbase.h b/noncore/apps/opie-console/iolayerbase.h
new file mode 100644
index 0000000..7ef3f4d
--- a/dev/null
+++ b/noncore/apps/opie-console/iolayerbase.h
@@ -0,0 +1,47 @@
1#ifndef OPIE_IO_LAYER_BASE_H
2#define OPIE_IO_LAYER_BASE_H
3
4
5#include <qwidget.h>
6
7class QLabel;
8class QComboBox;
9class QVBoxLayout;
10class QButtonGroup;
11class QRadioButton;
12class QHBoxLayout;
13class IOLayerBase : public QWidget {
14 Q_OBJECT
15public:
16 enum Flow { Software, Hardware };
17 enum Parity{ Odd, Even };
18 enum Speed{ Baud_115200,
19 Baud_57600,
20 Baud_38400,
21 Baud_19200,
22 Baud_9600 };
23 IOLayerBase( QWidget* base, const char* name = 0l);
24 ~IOLayerBase();
25
26 void setFlow( Flow flo );
27 void setParity( Parity par );
28 void setSpeed( Speed speed );
29
30 Flow flow()const;
31 Parity parity()const;
32 Speed speed()const;
33private:
34 QVBoxLayout* m_lroot;
35 QLabel* m_speedLabel;
36 QComboBox* m_speedBox;
37 QButtonGroup* m_groupFlow;
38 QRadioButton *m_flowHw, *m_flowSw;
39
40 QButtonGroup* m_groupParity;
41 QRadioButton *m_parityOdd, *m_parityEven;
42 QHBoxLayout* m_hbox;
43 QHBoxLayout* m_hboxPar;
44};
45
46
47#endif
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 647a331..a414bdb 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -121,4 +121,5 @@ void MainWindow::populateProfiles() {
121MainWindow::~MainWindow() { 121MainWindow::~MainWindow() {
122 delete m_factory; 122 delete m_factory;
123 manager()->save();
123} 124}
124 125
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp
index 077b418..4501ec2 100644
--- a/noncore/apps/opie-console/metafactory.cpp
+++ b/noncore/apps/opie-console/metafactory.cpp
@@ -97,5 +97,5 @@ ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget
97 QMap<QString, configWidget>::Iterator it; 97 QMap<QString, configWidget>::Iterator it;
98 it = m_termFact.find( str ); 98 it = m_termFact.find( str );
99 if ( it != m_conFact.end() ) { 99 if ( it != m_termFact.end() ) {
100 wid = (*(it.data() ) )(str,parent); 100 wid = (*(it.data() ) )(str,parent);
101 } 101 }
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro
index 984072a..9e25e8f 100644
--- a/noncore/apps/opie-console/opie-console.pro
+++ b/noncore/apps/opie-console/opie-console.pro
@@ -25,5 +25,7 @@ HEADERS = io_layer.h io_serial.h \
25 profiledialogwidget.h \ 25 profiledialogwidget.h \
26 profileeditordialog.h \ 26 profileeditordialog.h \
27 default.h 27 default.h \
28 terminalwidget.h \
29 iolayerbase.h
28 30
29SOURCES = io_layer.cpp io_serial.cpp \ 31SOURCES = io_layer.cpp io_serial.cpp \
@@ -48,5 +50,7 @@ SOURCES = io_layer.cpp io_serial.cpp \
48 profiledialogwidget.cpp \ 50 profiledialogwidget.cpp \
49 profileeditordialog.cpp \ 51 profileeditordialog.cpp \
50 default.cpp 52 default.cpp \
53 terminalwidget.cpp \
54 iolayerbase.cpp
51 55
52INTERFACES = configurebase.ui editbase.ui 56INTERFACES = configurebase.ui editbase.ui
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index 061b1c2..c5c6248 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -150,4 +150,9 @@ void ProfileEditorDialog::accept()
150 m_termCmb->currentText().latin1() ); 150 m_termCmb->currentText().latin1() );
151 151
152 if (m_con )
153 m_con->save( m_prof );
154 if (m_term )
155 m_term->save( m_prof );
156
152 QDialog::accept(); 157 QDialog::accept();
153} 158}
@@ -182,9 +187,11 @@ void ProfileEditorDialog::slotConActivated( const QString& str ) {
182void ProfileEditorDialog::slotTermActivated( const QString& str ) { 187void ProfileEditorDialog::slotTermActivated( const QString& str ) {
183 delete m_term; 188 delete m_term;
184 m_term = m_fact->newTerminalPlugin( str, 0l ); 189 m_term = m_fact->newTerminalPlugin( str, m_tabTerm );
185 qWarning("past"); 190 qWarning("past");
186 191
187 if (m_term) 192 if (m_term) {
193 m_term->load(m_prof );
188 m_layTerm->addWidget( m_term ); 194 m_layTerm->addWidget( m_term );
195 }
189} 196}
190 197
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}
diff --git a/noncore/apps/opie-console/terminalwidget.h b/noncore/apps/opie-console/terminalwidget.h
new file mode 100644
index 0000000..c6c2be2
--- a/dev/null
+++ b/noncore/apps/opie-console/terminalwidget.h
@@ -0,0 +1,46 @@
1#ifndef OPIE_TERMINAL_WIDGET_H
2#define OPIE_TERMINAL_WIDGET_H
3
4#include "profiledialogwidget.h"
5
6class QComboBox;
7class QLabel;
8class QVBoxLayout;
9class QHBoxLayout;
10class QButtonGroup;
11class QRadioButton;
12class QCheckBox;
13class QHGroupBox;
14
15class TerminalWidget : public ProfileDialogTerminalWidget {
16 Q_OBJECT
17public:
18 TerminalWidget(const QString& name, QWidget* wid,
19 const char* na ) ;
20 ~TerminalWidget();
21
22 void load( const Profile& );
23 void save( Profile& );
24private:
25 QVBoxLayout* m_lroot, *m_typeBox, *m_colorBox;
26
27 QHBoxLayout* m_hbox;
28
29 QLabel* m_terminal, *m_colorLabel;
30
31 QComboBox* m_terminalBox, *m_colorCmb;
32
33 QButtonGroup* m_groupSize;
34
35 QRadioButton* m_sizeSmall, *m_sizeMedium,
36 *m_sizeLarge;
37
38 QHGroupBox *m_groupConv, *m_groupOptions;
39
40 QCheckBox *m_convInbound,
41 *m_convOutbound, *m_optionEcho,
42 *m_optionWrap;
43
44};
45
46#endif