summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-08 20:03:29 (UTC)
committer zecke <zecke>2002-10-08 20:03:29 (UTC)
commit9237d1adcf23ee11f16881fbeea51e0bb3ec0b2f (patch) (side-by-side diff)
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) (show 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 @@
#include "io_serial.h"
#include "sz_transfer.h"
+#include "terminalwidget.h"
#include "default.h"
@@ -39,6 +40,6 @@ extern "C" {
// Terminal Widget(s)
- ProfileDialogWidget* newTerminalWidget(const QString&, QWidget* ) {
- return 0l;
+ ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) {
+ return new TerminalWidget(na, wid,0 );
}
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 @@
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qcombobox.h>
+#include <qbuttongroup.h>
+#include <qhbuttongroup.h>
+#include <qradiobutton.h>
+
+#include "iolayerbase.h"
+
+namespace {
+ enum ParityIds {
+ id_parity_odd,
+ id_parity_even
+ };
+
+ enum FlowIds {
+ id_flow_hw,
+ id_flow_sw
+ };
+
+ enum SpeedIds {
+ id_baud_115200,
+ id_baud_57600,
+ id_baud_38400,
+ id_baud_19200,
+ id_baud_9600
+ };
+
+}
+
+
+IOLayerBase::IOLayerBase( QWidget* par, const char* name )
+ : QWidget( par, name )
+{
+ m_speedLabel = new QLabel(tr("Speed"), this );
+ m_speedBox = new QComboBox(this );
+
+ m_groupFlow = new QButtonGroup(tr("Flow control") );
+ m_flowHw = new QRadioButton(tr("Hardware"), m_groupFlow );
+ m_flowSw = new QRadioButton(tr("Software"), m_groupFlow );
+
+ m_groupParity = new QButtonGroup(tr("Parity"), this );
+ m_parityOdd = new QRadioButton(tr("Odd"), m_groupParity );
+ m_parityEven = new QRadioButton(tr("Even"), m_groupParity );
+
+ m_lroot = new QVBoxLayout(this );
+ m_lroot->add(m_speedLabel );
+ m_lroot->add(m_speedBox );
+ m_lroot->setStretchFactor(m_speedLabel, 1);
+ m_lroot->setStretchFactor(m_speedBox, 1 );
+
+ m_hbox = new QHBoxLayout(m_groupFlow, 2 );
+ m_hbox->add(m_flowHw );
+ m_hbox->add(m_flowSw );
+ m_lroot->add(m_groupFlow );
+ m_lroot->setStretchFactor(m_groupFlow, 2 );
+
+ m_hboxPar = new QHBoxLayout( m_groupParity, 2 );
+ m_hboxPar->add(m_parityOdd );
+ m_hboxPar->add(m_parityEven );
+ m_lroot->add(m_groupParity );
+ m_lroot->setStretchFactor(m_groupParity, 2 );
+
+ // profiles
+ m_speedBox->insertItem(tr("115200 baud"), id_baud_115200 );
+ m_speedBox->insertItem(tr("57600 baud"), id_baud_57600 );
+ m_speedBox->insertItem(tr("38400 baud"), id_baud_38400 );
+ m_speedBox->insertItem(tr("19200 baud"), id_baud_19200 );
+ m_speedBox->insertItem(tr("9600 baud"), id_baud_9600 );
+};
+IOLayerBase::~IOLayerBase() {
+
+}
+void IOLayerBase::setFlow( Flow flo ) {
+ switch ( flo ) {
+ case Software:
+ m_flowSw->setChecked( true );
+ break;
+ case Hardware:
+ m_flowHw->setChecked( true );
+ break;
+ }
+}
+void IOLayerBase::setParity( Parity par ) {
+ switch( par ) {
+ case Odd:
+ m_parityOdd->setChecked( true );
+ break;
+ case Even:
+ m_parityEven->setChecked( true );
+ break;
+ }
+}
+void IOLayerBase::setSpeed( Speed sp ) {
+ int index;
+ switch( sp ) {
+ case Baud_115200:
+ index = id_baud_115200;
+ break;
+ case Baud_57600:
+ index = id_baud_57600;
+ break;
+ case Baud_38400:
+ index = id_baud_38400;
+ break;
+ case Baud_19200:
+ index = id_baud_19200;
+ break;
+ case Baud_9600:
+ index = id_baud_9600;
+ break;
+ }
+ m_speedBox->setCurrentItem(index );
+}
+IOLayerBase::Flow IOLayerBase::flow()const {
+ return Hardware;
+}
+IOLayerBase::Parity IOLayerBase::parity()const {
+ return Odd;
+}
+IOLayerBase::Speed IOLayerBase::speed()const{
+ return Baud_9600;
+}
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 @@
+#ifndef OPIE_IO_LAYER_BASE_H
+#define OPIE_IO_LAYER_BASE_H
+
+
+#include <qwidget.h>
+
+class QLabel;
+class QComboBox;
+class QVBoxLayout;
+class QButtonGroup;
+class QRadioButton;
+class QHBoxLayout;
+class IOLayerBase : public QWidget {
+ Q_OBJECT
+public:
+ enum Flow { Software, Hardware };
+ enum Parity{ Odd, Even };
+ enum Speed{ Baud_115200,
+ Baud_57600,
+ Baud_38400,
+ Baud_19200,
+ Baud_9600 };
+ IOLayerBase( QWidget* base, const char* name = 0l);
+ ~IOLayerBase();
+
+ void setFlow( Flow flo );
+ void setParity( Parity par );
+ void setSpeed( Speed speed );
+
+ Flow flow()const;
+ Parity parity()const;
+ Speed speed()const;
+private:
+ QVBoxLayout* m_lroot;
+ QLabel* m_speedLabel;
+ QComboBox* m_speedBox;
+ QButtonGroup* m_groupFlow;
+ QRadioButton *m_flowHw, *m_flowSw;
+
+ QButtonGroup* m_groupParity;
+ QRadioButton *m_parityOdd, *m_parityEven;
+ QHBoxLayout* m_hbox;
+ QHBoxLayout* m_hboxPar;
+};
+
+
+#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() {
MainWindow::~MainWindow() {
delete m_factory;
+ manager()->save();
}
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
QMap<QString, configWidget>::Iterator it;
it = m_termFact.find( str );
- if ( it != m_conFact.end() ) {
+ if ( it != m_termFact.end() ) {
wid = (*(it.data() ) )(str,parent);
}
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 \
profiledialogwidget.h \
profileeditordialog.h \
- default.h
+ default.h \
+ terminalwidget.h \
+ iolayerbase.h
SOURCES = io_layer.cpp io_serial.cpp \
@@ -48,5 +50,7 @@ SOURCES = io_layer.cpp io_serial.cpp \
profiledialogwidget.cpp \
profileeditordialog.cpp \
- default.cpp
+ default.cpp \
+ terminalwidget.cpp \
+ iolayerbase.cpp
INTERFACES = 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()
m_termCmb->currentText().latin1() );
+ if (m_con )
+ m_con->save( m_prof );
+ if (m_term )
+ m_term->save( m_prof );
+
QDialog::accept();
}
@@ -182,9 +187,11 @@ void ProfileEditorDialog::slotConActivated( const QString& str ) {
void ProfileEditorDialog::slotTermActivated( const QString& str ) {
delete m_term;
- m_term = m_fact->newTerminalPlugin( str, 0l );
+ m_term = m_fact->newTerminalPlugin( str, m_tabTerm );
qWarning("past");
- if (m_term)
+ if (m_term) {
+ m_term->load(m_prof );
m_layTerm->addWidget( m_term );
}
+}
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 @@
+#include <qbuttongroup.h>
+#include <qlabel.h>
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qradiobutton.h>
+#include <qgroupbox.h>
+#include <qvbox.h>
+#include <qhgroupbox.h>
+#include <qlayout.h>
+
+#include "terminalwidget.h"
+
+namespace {
+ enum TermIds {
+ id_term_vt100,
+ id_term_vt220,
+ id_term_ansi
+ };
+
+ enum ColourIds {
+ id_term_black,
+ id_term_white
+ };
+
+ enum FontIds {
+ id_size_small,
+ id_size_medium,
+ id_size_large
+ };
+};
+
+TerminalWidget::TerminalWidget( const QString& name, QWidget* parent,
+ const char* na )
+ : ProfileDialogTerminalWidget( name, parent, na ) {
+
+ m_terminal = new QLabel(tr("Terminal Type"), this );
+ m_terminalBox = new QComboBox(this);
+ m_colorLabel = new QLabel(tr("Color scheme"), this);
+ m_colorCmb = new QComboBox(this );
+
+ m_groupSize = new QButtonGroup(tr("Font size"), this );
+ m_sizeSmall = new QRadioButton(tr("small"), m_groupSize );
+ m_sizeMedium = new QRadioButton(tr("medium"), m_groupSize );
+ m_sizeLarge = new QRadioButton(tr("large"), m_groupSize );
+
+ m_groupConv = new QHGroupBox(tr("Line-break conversions"), this );
+ m_convInbound = new QCheckBox(tr("Inbound"), m_groupConv );
+ m_convOutbound = new QCheckBox(tr("Outbound"), m_groupConv );
+
+ m_groupOptions = new QHGroupBox( tr("Options"), this );
+ m_optionEcho = new QCheckBox(tr("Local echo"), m_groupOptions );
+ m_optionWrap = new QCheckBox(tr("Line wrap"), m_groupOptions );
+
+ m_lroot = new QVBoxLayout(this, 2 );
+ m_typeBox = new QVBoxLayout( m_lroot );
+ m_hbox = new QHBoxLayout( m_groupSize, 2 );
+ m_colorBox = new QVBoxLayout( m_lroot );
+
+ // Layout
+ m_typeBox->add(m_terminal );
+ m_typeBox->add(m_terminalBox );
+
+ m_hbox->add(m_sizeSmall );
+ m_hbox->add(m_sizeMedium );
+ m_hbox->add(m_sizeLarge );
+ m_lroot->add(m_groupSize );
+
+ m_colorBox->add( m_colorLabel );
+ m_colorBox->add( m_colorCmb );
+
+ m_lroot->add(m_groupConv );
+ m_lroot->add(m_groupOptions );
+
+ // Fill in some options
+ m_terminalBox->insertItem( tr("VT 100"), id_term_vt100 );
+ m_terminalBox->insertItem( tr("VT 220"), id_term_vt220 );
+ m_terminalBox->insertItem( tr("ANSI"), id_term_ansi );
+
+ m_colorCmb->insertItem( tr("black on white"), id_term_black );
+ m_colorCmb->insertItem( tr("white on black"), id_term_white );
+
+ // signals + slots
+ /*
+ connect(m_terminalBox, SIGNAL(activated(int) ),
+ this, SLOT(slotTermTerm(int) ) );
+ connect(m_colorBox, SIGNAL(activated(int) ),
+ tis, SLOT(slotTermColor(int) ) );
+ connect(m_groupSize, SIGNAL(activated(int) ),
+ this, SLOT(slotTermFont(int) ) );
+
+ connect(m_optionEcho, SIGNAL(toggled(bool) ),
+ this, SLOT(slotTermEcho(bool) ) );
+ connect(m_optionWrap, SIGNAL(toggled(bool) ),
+ this, SLOT(slotTermWrap(bool) ) );
+ connect(m_convInbound, SIGNAL(toggled(bool) ),
+ this, SLOT(slotTermInbound(bool) ) );
+ connect(m_convOutbound, SIGNAL(toggled(bool) ),
+ this, SLOT(slotTermOutbound(bool) ) );
+*/
+}
+TerminalWidget::~TerminalWidget() {
+}
+void TerminalWidget::load( const Profile& prof ) {
+ int term = prof.readNumEntry("Terminal");
+ int color = prof.readNumEntry("Color");
+ int fontsize = prof.readNumEntry("Font");
+ int opt_echo = prof.readNumEntry("Echo");
+ int opt_wrap = prof.readNumEntry("Wrap");
+ int opt_inbound = prof.readNumEntry("Inbound");
+ int opt_outbound = prof.readNumEntry("Outbound");
+
+ switch( term ) {
+ case Profile::VT102:
+ m_terminalBox->setCurrentItem(id_term_vt100 );
+ break;
+ default:
+ break;
+ };
+
+ switch( color ) {
+ case Profile::Black:
+ m_colorCmb->setCurrentItem(id_term_black );
+ break;
+ case Profile::White:
+ m_colorCmb->setCurrentItem(id_term_white );
+ break;
+ default:
+ break;
+ };
+
+ switch( fontsize ) {
+ case Profile::Micro:
+ m_sizeSmall->setChecked(true );
+ break;
+ case Profile::Small:
+ m_sizeMedium->setChecked(true );
+ break;
+ case Profile::Medium:
+ m_sizeLarge->setChecked( true );
+ break;
+ m_sizeSmall->setChecked(true);
+ default:
+ break;
+ };
+
+ if (opt_echo) m_optionEcho->setChecked( true );
+ if (opt_wrap) m_optionWrap->setChecked( true );
+ if (opt_inbound) m_convInbound->setChecked( true );
+ if (opt_outbound) m_convOutbound->setChecked( true );
+
+}
+void TerminalWidget::save( Profile& profile ) {
+ switch(m_terminalBox->currentItem() ) {
+ case id_term_vt100:
+ profile.writeEntry("Terminal", Profile::VT102 );
+ break;
+ case id_term_vt220:
+ profile.writeEntry("Terminal", Profile::VT102 );
+ break;
+ case id_term_ansi:
+ profile.writeEntry("Terminal", Profile::VT102 );
+ break;
+ default:
+ break;
+ };
+
+ // color
+ switch(m_colorCmb->currentItem() ) {
+ case id_term_black:
+ profile.writeEntry("Color", Profile::Black );
+ break;
+ case id_term_white:
+ profile.writeEntry("Color", Profile::White );
+ break;
+ default:
+ break;
+ };
+
+ if (m_sizeSmall->isChecked() ) {
+ profile.writeEntry("Font", Profile::Micro );
+ }else if (m_sizeMedium->isChecked() ) {
+ profile.writeEntry("Font", Profile::Small );
+ }else {
+ profile.writeEntry("Font", Profile::Medium );
+ }
+
+ profile.writeEntry("Echo", m_optionEcho->isChecked() );
+ profile.writeEntry("Wrap", m_optionWrap->isChecked() );
+ profile.writeEntry("Inbound", m_convInbound->isChecked() );
+ profile.writeEntry("Outbound",m_convOutbound->isChecked() );
+}
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 @@
+#ifndef OPIE_TERMINAL_WIDGET_H
+#define OPIE_TERMINAL_WIDGET_H
+
+#include "profiledialogwidget.h"
+
+class QComboBox;
+class QLabel;
+class QVBoxLayout;
+class QHBoxLayout;
+class QButtonGroup;
+class QRadioButton;
+class QCheckBox;
+class QHGroupBox;
+
+class TerminalWidget : public ProfileDialogTerminalWidget {
+ Q_OBJECT
+public:
+ TerminalWidget(const QString& name, QWidget* wid,
+ const char* na ) ;
+ ~TerminalWidget();
+
+ void load( const Profile& );
+ void save( Profile& );
+private:
+ QVBoxLayout* m_lroot, *m_typeBox, *m_colorBox;
+
+ QHBoxLayout* m_hbox;
+
+ QLabel* m_terminal, *m_colorLabel;
+
+ QComboBox* m_terminalBox, *m_colorCmb;
+
+ QButtonGroup* m_groupSize;
+
+ QRadioButton* m_sizeSmall, *m_sizeMedium,
+ *m_sizeLarge;
+
+ QHGroupBox *m_groupConv, *m_groupOptions;
+
+ QCheckBox *m_convInbound,
+ *m_convOutbound, *m_optionEcho,
+ *m_optionWrap;
+
+};
+
+#endif