-rw-r--r-- | noncore/apps/opie-console/default.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/iolayerbase.cpp | 34 | ||||
-rw-r--r-- | noncore/apps/opie-console/iolayerbase.h | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/opie-console.pro | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/profilemanager.cpp | 9 | ||||
-rw-r--r-- | noncore/apps/opie-console/serialconfigwidget.cpp | 135 | ||||
-rw-r--r-- | noncore/apps/opie-console/serialconfigwidget.h | 27 |
9 files changed, 212 insertions, 13 deletions
diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp index 4ab4695..d9a0557 100644 --- a/noncore/apps/opie-console/default.cpp +++ b/noncore/apps/opie-console/default.cpp @@ -2,2 +2,3 @@ #include "sz_transfer.h" +#include "serialconfigwidget.h" #include "terminalwidget.h" @@ -30,4 +31,4 @@ extern "C" { // Connection Widgets - ProfileDialogWidget* newSerialWidget(const QString& str, QWidget* ) { - return 0l; + ProfileDialogWidget* newSerialWidget(const QString& str, QWidget* wid) { + return new SerialConfigWidget(str, wid ); } diff --git a/noncore/apps/opie-console/iolayerbase.cpp b/noncore/apps/opie-console/iolayerbase.cpp index 1e164fe..99b6cc1 100644 --- a/noncore/apps/opie-console/iolayerbase.cpp +++ b/noncore/apps/opie-console/iolayerbase.cpp @@ -37,3 +37,3 @@ IOLayerBase::IOLayerBase( QWidget* par, const char* name ) - m_groupFlow = new QButtonGroup(tr("Flow control") ); + m_groupFlow = new QButtonGroup(tr("Flow control"),this ); m_flowHw = new QRadioButton(tr("Hardware"), m_groupFlow ); @@ -115,9 +115,35 @@ void IOLayerBase::setSpeed( Speed sp ) { IOLayerBase::Flow IOLayerBase::flow()const { - return Hardware; + if (m_flowHw->isChecked() ) { + qWarning("Hardware flow"); + return Hardware; + }else { + qWarning("Software"); + return Software; + } } IOLayerBase::Parity IOLayerBase::parity()const { - return Odd; + if (m_parityOdd->isChecked() ) + return Odd; + else + return Even; + } IOLayerBase::Speed IOLayerBase::speed()const{ - return Baud_9600; + switch( m_speedBox->currentItem() ) { + case id_baud_115200: + return Baud_115200; + break; + case id_baud_57600: + return Baud_57600; + break; + case id_baud_38400: + return Baud_38400; + break; + case id_baud_19200: + return Baud_19200; + break; + case id_baud_9600: + return Baud_9600; + break; + } } diff --git a/noncore/apps/opie-console/iolayerbase.h b/noncore/apps/opie-console/iolayerbase.h index 7ef3f4d..151a04b 100644 --- a/noncore/apps/opie-console/iolayerbase.h +++ b/noncore/apps/opie-console/iolayerbase.h @@ -15,4 +15,4 @@ class IOLayerBase : public QWidget { public: - enum Flow { Software, Hardware }; - enum Parity{ Odd, Even }; + enum Flow { Hardware, Software }; + enum Parity{ Odd =2 , Even =1 }; enum Speed{ Baud_115200, diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index a414bdb..3531478 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -167,2 +167,3 @@ void MainWindow::slotConfigure() { if ( QDialog::Accepted == ret ) { + qWarning("conf %d", conf.list().count() ); manager()->setProfiles( conf.list() ); diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro index 9e25e8f..ea6d759 100644 --- a/noncore/apps/opie-console/opie-console.pro +++ b/noncore/apps/opie-console/opie-console.pro @@ -28,3 +28,4 @@ HEADERS = io_layer.h io_serial.h \ terminalwidget.h \ - iolayerbase.h + iolayerbase.h \ + serialconfigwidget.h @@ -53,3 +54,4 @@ SOURCES = io_layer.cpp io_serial.cpp \ terminalwidget.cpp \ - iolayerbase.cpp + iolayerbase.cpp \ + serialconfigwidget.cpp diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index c5c6248..faf9c39 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp @@ -180,4 +180,6 @@ void ProfileEditorDialog::slotConActivated( const QString& str ) { - if (m_con ) + if (m_con ) { + m_con->load(m_prof ); m_layCon->addWidget( m_con ); + } } diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp index 6ad08b5..e66ebcc 100644 --- a/noncore/apps/opie-console/profilemanager.cpp +++ b/noncore/apps/opie-console/profilemanager.cpp @@ -1 +1,5 @@ +#include <stdio.h> +#include <stdlib.h> + +#include <qfile.h> @@ -32,2 +36,3 @@ void ProfileManager::load() { prof.setTerminalName( conf.readEntry("term").utf8() ); + qWarning(" %s %s", conf.readEntry("iolayer").latin1(), prof.ioLayerName().data() ); prof.setBackground( conf.readNumEntry("back") ); @@ -62,4 +67,4 @@ Session* ProfileManager::fromProfile( const Profile& prof) { void ProfileManager::save( ) { + QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); ProfileConfig conf("opie-console-profiles"); - conf.clearAll(); Profile::ValueList::Iterator it; @@ -68,3 +73,3 @@ void ProfileManager::save( ) { conf.writeEntry( "name", (*it).name() ); - conf.writeEntry( "ioplayer", QString::fromUtf8( (*it).ioLayerName() ) ); + conf.writeEntry( "iolayer", QString::fromUtf8( (*it).ioLayerName() ) ); conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) ); diff --git a/noncore/apps/opie-console/serialconfigwidget.cpp b/noncore/apps/opie-console/serialconfigwidget.cpp new file mode 100644 index 0000000..a427302 --- a/dev/null +++ b/noncore/apps/opie-console/serialconfigwidget.cpp @@ -0,0 +1,135 @@ +#include <qlabel.h> +#include <qlayout.h> +#include <qcombobox.h> + +#include "iolayerbase.h" +#include "serialconfigwidget.h" + +namespace { + void setCurrent( const QString& str, QComboBox* bo ) { + uint b = bo->count(); + for (uint i = 0; i < bo->count(); i++ ) { + if ( bo->text(i) == str ) { + bo->setCurrentItem( i ); + return; + } + } + bo->insertItem( str ); + bo->setCurrentItem( b ); + } + + +} + +SerialConfigWidget::SerialConfigWidget( const QString& name, + QWidget* parent, + const char* na ) + : ProfileDialogConnectionWidget( name, parent, na ) { + + m_lay = new QVBoxLayout(this ); + m_device = new QLabel(tr("Device"), this ); + m_deviceCmb = new QComboBox(this ); + m_deviceCmb->setEditable( TRUE ); + + m_base = new IOLayerBase(this, "base"); + + m_lay->addWidget( m_device ); + m_lay->addWidget( m_deviceCmb ); + m_lay->addWidget( m_base ); + + m_deviceCmb->insertItem( "/dev/ttyS0" ); + m_deviceCmb->insertItem( "/dev/ttyS1" ); + m_deviceCmb->insertItem( "/dev/ttySA0"); + m_deviceCmb->insertItem( "/dev/ttySA1"); + +} +SerialConfigWidget::~SerialConfigWidget() { + +} +void SerialConfigWidget::load( const Profile& prof ) { + int rad_flow = prof.readNumEntry("Flow"); + int rad_parity = prof.readNumEntry("Parity"); + int speed = prof.readNumEntry("Speed"); + + if (rad_flow == 0) + m_base->setFlow( IOLayerBase::Hardware ); + else + m_base->setFlow( IOLayerBase::Software ); + + if (rad_parity == 1) + m_base->setParity( IOLayerBase::Even ); + else + m_base->setParity( IOLayerBase::Odd ); + + switch( speed ) { + case 115200: + m_base->setSpeed(IOLayerBase::Baud_115200 ); + break; + case 57600: + m_base->setSpeed( IOLayerBase::Baud_57600 ); + break; + case 38400: + m_base->setSpeed(IOLayerBase::Baud_38400 ); + break; + case 19200: + m_base->setSpeed( IOLayerBase::Baud_19200 ); + break; + case 9600: + default: + m_base->setSpeed(IOLayerBase::Baud_9600 ); + break; + } + + if ( prof.readEntry("Device").isEmpty() ) return; + setCurrent( prof.readEntry("Device"), m_deviceCmb ); + +} +/* + * save speed, + * flow, + * parity + */ +void SerialConfigWidget::save( Profile& prof ) { + int flow, parity, speed; + prof.writeEntry("Device", m_deviceCmb->currentText() ); + + switch( m_base->flow() ) { + case IOLayerBase::Software: + flow = 1; + break; + case IOLayerBase::Hardware: + flow = 0; + break; + } + + switch( m_base->parity() ) { + case IOLayerBase::Odd: + parity = 2; + break; + case IOLayerBase::Even: + parity = 1; + break; + } + + switch( m_base->speed() ) { + case IOLayerBase::Baud_115200: + speed = 115200; + break; + case IOLayerBase::Baud_57600: + speed = 57600; + break; + case IOLayerBase::Baud_38400: + speed = 38400; + break; + case IOLayerBase::Baud_19200: + speed = 19200; + break; + case IOLayerBase::Baud_9600: + speed = 9600; + break; + } + + prof.writeEntry("Flow", flow); + prof.writeEntry("Parity", parity); + prof.writeEntry("Speed", speed); +} diff --git a/noncore/apps/opie-console/serialconfigwidget.h b/noncore/apps/opie-console/serialconfigwidget.h new file mode 100644 index 0000000..8b5c8aa --- a/dev/null +++ b/noncore/apps/opie-console/serialconfigwidget.h @@ -0,0 +1,27 @@ +#ifndef OPIE_SERIAL_CONFIG_WIDGET_H +#define OPIE_SERIAL_CONFIG_WIDGET_H + +#include "profiledialogwidget.h" + +class QVBoxLayout; +class QLabel; +class QComboBox; +class IOLayerBase; +class SerialConfigWidget : public ProfileDialogConnectionWidget { + Q_OBJECT +public: + SerialConfigWidget( const QString& name, QWidget* parent, const char* name = 0l ); + ~SerialConfigWidget(); + + void load( const Profile& ); + void save( Profile& ); +private: + QVBoxLayout* m_lay; + QLabel* m_device; + QComboBox* m_deviceCmb; + IOLayerBase* m_base; + +}; + + +#endif |