summaryrefslogtreecommitdiff
path: root/noncore/apps
authorzecke <zecke>2002-10-08 23:13:17 (UTC)
committer zecke <zecke>2002-10-08 23:13:17 (UTC)
commit8c353ec8b86ee8f82cc25172fb69dd5fee65e848 (patch) (unidiff)
treea4549bcba962689edb9c40efcb23114cae5fcda2 /noncore/apps
parentca0c224318a50c6618691fb30f39aa1d9b0b8a4f (diff)
downloadopie-8c353ec8b86ee8f82cc25172fb69dd5fee65e848.zip
opie-8c353ec8b86ee8f82cc25172fb69dd5fee65e848.tar.gz
opie-8c353ec8b86ee8f82cc25172fb69dd5fee65e848.tar.bz2
default I dunno
IOLayerBase the return values for speed()/parity()/flow() added MainWindow debug code :( opie-console.pro addition of serialconfigwidget.* ProfileManager fix removing of Profiles quite rude way of doing it Configure stuff is done and roughly tested The migration is done! TO WAZLAF: you might want to adjust Parity stuff for your needs!
Diffstat (limited to 'noncore/apps') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/default.cpp5
-rw-r--r--noncore/apps/opie-console/iolayerbase.cpp34
-rw-r--r--noncore/apps/opie-console/iolayerbase.h4
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp1
-rw-r--r--noncore/apps/opie-console/opie-console.pro6
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp4
-rw-r--r--noncore/apps/opie-console/profilemanager.cpp9
-rw-r--r--noncore/apps/opie-console/serialconfigwidget.cpp135
-rw-r--r--noncore/apps/opie-console/serialconfigwidget.h27
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
@@ -1,5 +1,6 @@
1#include "io_serial.h" 1#include "io_serial.h"
2#include "sz_transfer.h" 2#include "sz_transfer.h"
3#include "serialconfigwidget.h"
3#include "terminalwidget.h" 4#include "terminalwidget.h"
4 5
5#include "default.h" 6#include "default.h"
@@ -28,8 +29,8 @@ extern "C" {
28 } 29 }
29 30
30 // Connection Widgets 31 // Connection Widgets
31 ProfileDialogWidget* newSerialWidget(const QString& str, QWidget* ) { 32 ProfileDialogWidget* newSerialWidget(const QString& str, QWidget* wid) {
32 return 0l; 33 return new SerialConfigWidget(str, wid );
33 } 34 }
34 ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid) { 35 ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid) {
35 return newSerialWidget(str, wid); 36 return newSerialWidget(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
@@ -35,7 +35,7 @@ IOLayerBase::IOLayerBase( QWidget* par, const char* name )
35 m_speedLabel = new QLabel(tr("Speed"), this ); 35 m_speedLabel = new QLabel(tr("Speed"), this );
36 m_speedBox = new QComboBox(this ); 36 m_speedBox = new QComboBox(this );
37 37
38 m_groupFlow = new QButtonGroup(tr("Flow control") ); 38 m_groupFlow = new QButtonGroup(tr("Flow control"),this );
39 m_flowHw = new QRadioButton(tr("Hardware"), m_groupFlow ); 39 m_flowHw = new QRadioButton(tr("Hardware"), m_groupFlow );
40 m_flowSw = new QRadioButton(tr("Software"), m_groupFlow ); 40 m_flowSw = new QRadioButton(tr("Software"), m_groupFlow );
41 41
@@ -113,11 +113,37 @@ void IOLayerBase::setSpeed( Speed sp ) {
113 m_speedBox->setCurrentItem(index ); 113 m_speedBox->setCurrentItem(index );
114} 114}
115IOLayerBase::Flow IOLayerBase::flow()const { 115IOLayerBase::Flow IOLayerBase::flow()const {
116 return Hardware; 116 if (m_flowHw->isChecked() ) {
117 qWarning("Hardware flow");
118 return Hardware;
119 }else {
120 qWarning("Software");
121 return Software;
122 }
117} 123}
118IOLayerBase::Parity IOLayerBase::parity()const { 124IOLayerBase::Parity IOLayerBase::parity()const {
119 return Odd; 125 if (m_parityOdd->isChecked() )
126 return Odd;
127 else
128 return Even;
129
120} 130}
121IOLayerBase::Speed IOLayerBase::speed()const{ 131IOLayerBase::Speed IOLayerBase::speed()const{
122 return Baud_9600; 132 switch( m_speedBox->currentItem() ) {
133 case id_baud_115200:
134 return Baud_115200;
135 break;
136 case id_baud_57600:
137 return Baud_57600;
138 break;
139 case id_baud_38400:
140 return Baud_38400;
141 break;
142 case id_baud_19200:
143 return Baud_19200;
144 break;
145 case id_baud_9600:
146 return Baud_9600;
147 break;
148 }
123} 149}
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
@@ -13,8 +13,8 @@ class QHBoxLayout;
13class IOLayerBase : public QWidget { 13class IOLayerBase : public QWidget {
14 Q_OBJECT 14 Q_OBJECT
15public: 15public:
16 enum Flow { Software, Hardware }; 16 enum Flow { Hardware, Software };
17 enum Parity{ Odd, Even }; 17 enum Parity{ Odd =2 , Even =1 };
18 enum Speed{ Baud_115200, 18 enum Speed{ Baud_115200,
19 Baud_57600, 19 Baud_57600,
20 Baud_38400, 20 Baud_38400,
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
@@ -165,6 +165,7 @@ void MainWindow::slotConfigure() {
165 int ret = conf.exec(); 165 int ret = conf.exec();
166 166
167 if ( QDialog::Accepted == ret ) { 167 if ( QDialog::Accepted == ret ) {
168 qWarning("conf %d", conf.list().count() );
168 manager()->setProfiles( conf.list() ); 169 manager()->setProfiles( conf.list() );
169 populateProfiles(); 170 populateProfiles();
170 } 171 }
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
@@ -26,7 +26,8 @@ HEADERS = io_layer.h io_serial.h \
26 profileeditordialog.h \ 26 profileeditordialog.h \
27 default.h \ 27 default.h \
28 terminalwidget.h \ 28 terminalwidget.h \
29 iolayerbase.h 29 iolayerbase.h \
30 serialconfigwidget.h
30 31
31SOURCES = io_layer.cpp io_serial.cpp \ 32SOURCES = io_layer.cpp io_serial.cpp \
32 file_layer.cpp sz_transfer.cpp \ 33 file_layer.cpp sz_transfer.cpp \
@@ -51,7 +52,8 @@ SOURCES = io_layer.cpp io_serial.cpp \
51 profileeditordialog.cpp \ 52 profileeditordialog.cpp \
52 default.cpp \ 53 default.cpp \
53 terminalwidget.cpp \ 54 terminalwidget.cpp \
54 iolayerbase.cpp 55 iolayerbase.cpp \
56 serialconfigwidget.cpp
55 57
56INTERFACES = configurebase.ui editbase.ui 58INTERFACES = configurebase.ui editbase.ui
57INCLUDEPATH += $(OPIEDIR)/include 59INCLUDEPATH += $(OPIEDIR)/include
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
@@ -178,8 +178,10 @@ void ProfileEditorDialog::slotConActivated( const QString& str ) {
178 delete m_con; 178 delete m_con;
179 m_con = m_fact->newConnectionPlugin( str, m_tabCon ); 179 m_con = m_fact->newConnectionPlugin( str, m_tabCon );
180 180
181 if (m_con ) 181 if (m_con ) {
182 m_con->load(m_prof );
182 m_layCon->addWidget( m_con ); 183 m_layCon->addWidget( m_con );
184 }
183} 185}
184/* 186/*
185 * we need to switch the widget 187 * we need to switch the widget
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,3 +1,7 @@
1#include <stdio.h>
2#include <stdlib.h>
3
4#include <qfile.h>
1 5
2#include <qpe/config.h> 6#include <qpe/config.h>
3 7
@@ -30,6 +34,7 @@ void ProfileManager::load() {
30 prof.setName( conf.readEntry("name") ); 34 prof.setName( conf.readEntry("name") );
31 prof.setIOLayer( conf.readEntry("iolayer").utf8() ); 35 prof.setIOLayer( conf.readEntry("iolayer").utf8() );
32 prof.setTerminalName( conf.readEntry("term").utf8() ); 36 prof.setTerminalName( conf.readEntry("term").utf8() );
37 qWarning(" %s %s", conf.readEntry("iolayer").latin1(), prof.ioLayerName().data() );
33 prof.setBackground( conf.readNumEntry("back") ); 38 prof.setBackground( conf.readNumEntry("back") );
34 prof.setForeground( conf.readNumEntry("fore") ); 39 prof.setForeground( conf.readNumEntry("fore") );
35 prof.setTerminal( conf.readNumEntry("terminal") ); 40 prof.setTerminal( conf.readNumEntry("terminal") );
@@ -60,13 +65,13 @@ Session* ProfileManager::fromProfile( const Profile& prof) {
60 return session; 65 return session;
61} 66}
62void ProfileManager::save( ) { 67void ProfileManager::save( ) {
68 QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) );
63 ProfileConfig conf("opie-console-profiles"); 69 ProfileConfig conf("opie-console-profiles");
64 conf.clearAll();
65 Profile::ValueList::Iterator it; 70 Profile::ValueList::Iterator it;
66 for (it = m_list.begin(); it != m_list.end(); ++it ) { 71 for (it = m_list.begin(); it != m_list.end(); ++it ) {
67 conf.setGroup( (*it).name() ); 72 conf.setGroup( (*it).name() );
68 conf.writeEntry( "name", (*it).name() ); 73 conf.writeEntry( "name", (*it).name() );
69 conf.writeEntry( "ioplayer", QString::fromUtf8( (*it).ioLayerName() ) ); 74 conf.writeEntry( "iolayer", QString::fromUtf8( (*it).ioLayerName() ) );
70 conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) ); 75 conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) );
71 conf.writeEntry( "back", (*it).background() ); 76 conf.writeEntry( "back", (*it).background() );
72 conf.writeEntry( "fore", (*it).foreground() ); 77 conf.writeEntry( "fore", (*it).foreground() );
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 @@
1#include <qlabel.h>
2#include <qlayout.h>
3#include <qcombobox.h>
4
5#include "iolayerbase.h"
6#include "serialconfigwidget.h"
7
8namespace {
9 void setCurrent( const QString& str, QComboBox* bo ) {
10 uint b = bo->count();
11 for (uint i = 0; i < bo->count(); i++ ) {
12 if ( bo->text(i) == str ) {
13 bo->setCurrentItem( i );
14 return;
15 }
16 }
17 bo->insertItem( str );
18 bo->setCurrentItem( b );
19 }
20
21
22}
23
24SerialConfigWidget::SerialConfigWidget( const QString& name,
25 QWidget* parent,
26 const char* na )
27 : ProfileDialogConnectionWidget( name, parent, na ) {
28
29 m_lay = new QVBoxLayout(this );
30 m_device = new QLabel(tr("Device"), this );
31 m_deviceCmb = new QComboBox(this );
32 m_deviceCmb->setEditable( TRUE );
33
34 m_base = new IOLayerBase(this, "base");
35
36 m_lay->addWidget( m_device );
37 m_lay->addWidget( m_deviceCmb );
38 m_lay->addWidget( m_base );
39
40 m_deviceCmb->insertItem( "/dev/ttyS0" );
41 m_deviceCmb->insertItem( "/dev/ttyS1" );
42 m_deviceCmb->insertItem( "/dev/ttySA0");
43 m_deviceCmb->insertItem( "/dev/ttySA1");
44
45}
46SerialConfigWidget::~SerialConfigWidget() {
47
48}
49void SerialConfigWidget::load( const Profile& prof ) {
50 int rad_flow = prof.readNumEntry("Flow");
51 int rad_parity = prof.readNumEntry("Parity");
52 int speed = prof.readNumEntry("Speed");
53
54 if (rad_flow == 0)
55 m_base->setFlow( IOLayerBase::Hardware );
56 else
57 m_base->setFlow( IOLayerBase::Software );
58
59 if (rad_parity == 1)
60 m_base->setParity( IOLayerBase::Even );
61 else
62 m_base->setParity( IOLayerBase::Odd );
63
64 switch( speed ) {
65 case 115200:
66 m_base->setSpeed(IOLayerBase::Baud_115200 );
67 break;
68 case 57600:
69 m_base->setSpeed( IOLayerBase::Baud_57600 );
70 break;
71 case 38400:
72 m_base->setSpeed(IOLayerBase::Baud_38400 );
73 break;
74 case 19200:
75 m_base->setSpeed( IOLayerBase::Baud_19200 );
76 break;
77 case 9600:
78 default:
79 m_base->setSpeed(IOLayerBase::Baud_9600 );
80 break;
81 }
82
83 if ( prof.readEntry("Device").isEmpty() ) return;
84 setCurrent( prof.readEntry("Device"), m_deviceCmb );
85
86}
87/*
88 * save speed,
89 * flow,
90 * parity
91 */
92void SerialConfigWidget::save( Profile& prof ) {
93 int flow, parity, speed;
94 prof.writeEntry("Device", m_deviceCmb->currentText() );
95
96 switch( m_base->flow() ) {
97 case IOLayerBase::Software:
98 flow = 1;
99 break;
100 case IOLayerBase::Hardware:
101 flow = 0;
102 break;
103 }
104
105 switch( m_base->parity() ) {
106 case IOLayerBase::Odd:
107 parity = 2;
108 break;
109 case IOLayerBase::Even:
110 parity = 1;
111 break;
112 }
113
114 switch( m_base->speed() ) {
115 case IOLayerBase::Baud_115200:
116 speed = 115200;
117 break;
118 case IOLayerBase::Baud_57600:
119 speed = 57600;
120 break;
121 case IOLayerBase::Baud_38400:
122 speed = 38400;
123 break;
124 case IOLayerBase::Baud_19200:
125 speed = 19200;
126 break;
127 case IOLayerBase::Baud_9600:
128 speed = 9600;
129 break;
130 }
131
132 prof.writeEntry("Flow", flow);
133 prof.writeEntry("Parity", parity);
134 prof.writeEntry("Speed", speed);
135}
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 @@
1#ifndef OPIE_SERIAL_CONFIG_WIDGET_H
2#define OPIE_SERIAL_CONFIG_WIDGET_H
3
4#include "profiledialogwidget.h"
5
6class QVBoxLayout;
7class QLabel;
8class QComboBox;
9class IOLayerBase;
10class SerialConfigWidget : public ProfileDialogConnectionWidget {
11 Q_OBJECT
12public:
13 SerialConfigWidget( const QString& name, QWidget* parent, const char* name = 0l );
14 ~SerialConfigWidget();
15
16 void load( const Profile& );
17 void save( Profile& );
18private:
19 QVBoxLayout* m_lay;
20 QLabel* m_device;
21 QComboBox* m_deviceCmb;
22 IOLayerBase* m_base;
23
24};
25
26
27#endif