author | zecke <zecke> | 2002-10-08 20:03:29 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-08 20:03:29 (UTC) |
commit | 9237d1adcf23ee11f16881fbeea51e0bb3ec0b2f (patch) (unidiff) | |
tree | da7ac82c0abd3948d5e18e6e8db3a9277d4922ac | |
parent | b81a4afcb4d363bf1ee50aa7b43a1f1566addc9d (diff) | |
download | opie-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
-rw-r--r-- | noncore/apps/opie-console/default.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/iolayerbase.cpp | 123 | ||||
-rw-r--r-- | noncore/apps/opie-console/iolayerbase.h | 47 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/opie-console.pro | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 11 | ||||
-rw-r--r-- | noncore/apps/opie-console/terminalwidget.cpp | 191 | ||||
-rw-r--r-- | noncore/apps/opie-console/terminalwidget.h | 46 |
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,18 +1,19 @@ | |||
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" |
5 | 6 | ||
6 | extern "C" { | 7 | extern "C" { |
7 | // FILE Transfer Stuff | 8 | // FILE Transfer Stuff |
8 | FileTransferLayer* newSZTransfer(IOLayer* lay) { | 9 | FileTransferLayer* newSZTransfer(IOLayer* lay) { |
9 | return new SzTransfer( SzTransfer::SZ, lay ); | 10 | return new SzTransfer( SzTransfer::SZ, lay ); |
10 | } | 11 | } |
11 | FileTransferLayer* newSYTransfer(IOLayer* lay) { | 12 | FileTransferLayer* newSYTransfer(IOLayer* lay) { |
12 | return new SzTransfer( SzTransfer::SY, lay ); | 13 | return new SzTransfer( SzTransfer::SY, lay ); |
13 | } | 14 | } |
14 | FileTransferLayer* newSXTransfer(IOLayer* lay) { | 15 | FileTransferLayer* newSXTransfer(IOLayer* lay) { |
15 | return new SzTransfer( SzTransfer::SX, lay ); | 16 | return new SzTransfer( SzTransfer::SX, lay ); |
16 | } | 17 | } |
17 | 18 | ||
18 | // Layer stuff | 19 | // Layer stuff |
@@ -25,34 +26,34 @@ extern "C" { | |||
25 | IOLayer* newIrDaLayer( const Profile& ) { | 26 | IOLayer* newIrDaLayer( const Profile& ) { |
26 | return 0l; | 27 | return 0l; |
27 | } | 28 | } |
28 | 29 | ||
29 | // Connection Widgets | 30 | // Connection Widgets |
30 | ProfileDialogWidget* newSerialWidget(const QString& str, QWidget* ) { | 31 | ProfileDialogWidget* newSerialWidget(const QString& str, QWidget* ) { |
31 | return 0l; | 32 | return 0l; |
32 | } | 33 | } |
33 | ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid) { | 34 | ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid) { |
34 | return newSerialWidget(str, wid); | 35 | return newSerialWidget(str, wid); |
35 | } | 36 | } |
36 | ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid) { | 37 | ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid) { |
37 | return newSerialWidget(str, wid ); | 38 | return newSerialWidget(str, wid ); |
38 | } | 39 | } |
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 | ||
45 | }; | 46 | }; |
46 | 47 | ||
47 | Default::Default( MetaFactory* fact ) { | 48 | Default::Default( MetaFactory* fact ) { |
48 | fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer ); | 49 | fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer ); |
49 | fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer ); | 50 | fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer ); |
50 | fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer ); | 51 | fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer ); |
51 | 52 | ||
52 | fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer ); | 53 | fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer ); |
53 | fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer ); | 54 | fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer ); |
54 | fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer ); | 55 | fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer ); |
55 | 56 | ||
56 | fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget ); | 57 | fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget ); |
57 | fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget ); | 58 | fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget ); |
58 | fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget ); | 59 | fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget ); |
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 | |||
10 | namespace { | ||
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 | |||
32 | IOLayerBase::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 | }; | ||
71 | IOLayerBase::~IOLayerBase() { | ||
72 | |||
73 | } | ||
74 | void 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 | } | ||
84 | void 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 | } | ||
94 | void 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 | } | ||
115 | IOLayerBase::Flow IOLayerBase::flow()const { | ||
116 | return Hardware; | ||
117 | } | ||
118 | IOLayerBase::Parity IOLayerBase::parity()const { | ||
119 | return Odd; | ||
120 | } | ||
121 | IOLayerBase::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 | |||
7 | class QLabel; | ||
8 | class QComboBox; | ||
9 | class QVBoxLayout; | ||
10 | class QButtonGroup; | ||
11 | class QRadioButton; | ||
12 | class QHBoxLayout; | ||
13 | class IOLayerBase : public QWidget { | ||
14 | Q_OBJECT | ||
15 | public: | ||
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; | ||
33 | private: | ||
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 | |||
@@ -107,32 +107,33 @@ void MainWindow::initUI() { | |||
107 | } | 107 | } |
108 | 108 | ||
109 | ProfileManager* MainWindow::manager() { | 109 | ProfileManager* MainWindow::manager() { |
110 | return m_manager; | 110 | return m_manager; |
111 | } | 111 | } |
112 | 112 | ||
113 | void MainWindow::populateProfiles() { | 113 | void MainWindow::populateProfiles() { |
114 | m_sessionsPop->clear(); | 114 | m_sessionsPop->clear(); |
115 | Profile::ValueList list = manager()->all(); | 115 | Profile::ValueList list = manager()->all(); |
116 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 116 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
117 | m_sessionsPop->insertItem( (*it).name() ); | 117 | m_sessionsPop->insertItem( (*it).name() ); |
118 | } | 118 | } |
119 | 119 | ||
120 | } | 120 | } |
121 | MainWindow::~MainWindow() { | 121 | MainWindow::~MainWindow() { |
122 | delete m_factory; | 122 | delete m_factory; |
123 | manager()->save(); | ||
123 | } | 124 | } |
124 | 125 | ||
125 | MetaFactory* MainWindow::factory() { | 126 | MetaFactory* MainWindow::factory() { |
126 | return m_factory; | 127 | return m_factory; |
127 | } | 128 | } |
128 | 129 | ||
129 | Session* MainWindow::currentSession() { | 130 | Session* MainWindow::currentSession() { |
130 | return m_curSession; | 131 | return m_curSession; |
131 | } | 132 | } |
132 | 133 | ||
133 | QList<Session> MainWindow::sessions() { | 134 | QList<Session> MainWindow::sessions() { |
134 | return m_sessions; | 135 | return m_sessions; |
135 | } | 136 | } |
136 | 137 | ||
137 | void MainWindow::slotNew() { | 138 | void MainWindow::slotNew() { |
138 | qWarning("New Connection"); | 139 | qWarning("New Connection"); |
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 | |||
@@ -83,32 +83,32 @@ ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWid | |||
83 | 83 | ||
84 | QMap<QString, configWidget>::Iterator it; | 84 | QMap<QString, configWidget>::Iterator it; |
85 | it = m_conFact.find( str ); | 85 | it = m_conFact.find( str ); |
86 | if ( it != m_conFact.end() ) { | 86 | if ( it != m_conFact.end() ) { |
87 | wid = (*(it.data() ) )(str,parent); | 87 | wid = (*(it.data() ) )(str,parent); |
88 | } | 88 | } |
89 | return wid; | 89 | return wid; |
90 | } | 90 | } |
91 | ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) { | 91 | ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) { |
92 | if (str.isEmpty() ) | 92 | if (str.isEmpty() ) |
93 | return 0l; | 93 | return 0l; |
94 | ProfileDialogWidget* wid = 0l; | 94 | ProfileDialogWidget* wid = 0l; |
95 | qWarning("new terminalPlugin %s %l", str.latin1(), parent ); | 95 | qWarning("new terminalPlugin %s %l", str.latin1(), parent ); |
96 | 96 | ||
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 | } |
102 | return wid; | 102 | return wid; |
103 | } | 103 | } |
104 | QCString MetaFactory::internal( const QString& str )const { | 104 | QCString MetaFactory::internal( const QString& str )const { |
105 | return m_strings[str]; | 105 | return m_strings[str]; |
106 | } | 106 | } |
107 | QString MetaFactory::external( const QCString& str )const { | 107 | QString MetaFactory::external( const QCString& str )const { |
108 | QMap<QString, QCString>::ConstIterator it; | 108 | QMap<QString, QCString>::ConstIterator it; |
109 | for ( it = m_strings.begin(); it != m_strings.end(); ++it ) { | 109 | for ( it = m_strings.begin(); it != m_strings.end(); ++it ) { |
110 | if ( it.data() == str ) | 110 | if ( it.data() == str ) |
111 | return it.key(); | 111 | return it.key(); |
112 | } | 112 | } |
113 | return QString::null; | 113 | return QString::null; |
114 | } | 114 | } |
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 | |||
@@ -11,47 +11,51 @@ HEADERS = io_layer.h io_serial.h \ | |||
11 | profileconfig.h \ | 11 | profileconfig.h \ |
12 | profilemanager.h \ | 12 | profilemanager.h \ |
13 | configwidget.h \ | 13 | configwidget.h \ |
14 | tabwidget.h \ | 14 | tabwidget.h \ |
15 | configdialog.h \ | 15 | configdialog.h \ |
16 | emulation_layer.h \ | 16 | emulation_layer.h \ |
17 | widget.h \ | 17 | widget.h \ |
18 | vt102emulation.h \ | 18 | vt102emulation.h \ |
19 | common.h \ | 19 | common.h \ |
20 | history.h \ | 20 | history.h \ |
21 | screen.h \ | 21 | screen.h \ |
22 | keytrans.h \ | 22 | keytrans.h \ |
23 | widget_layer.h \ | 23 | widget_layer.h \ |
24 | transferdialog.h \ | 24 | transferdialog.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 | ||
29 | SOURCES = io_layer.cpp io_serial.cpp \ | 31 | SOURCES = io_layer.cpp io_serial.cpp \ |
30 | file_layer.cpp sz_transfer.cpp \ | 32 | file_layer.cpp sz_transfer.cpp \ |
31 | main.cpp \ | 33 | main.cpp \ |
32 | metafactory.cpp \ | 34 | metafactory.cpp \ |
33 | session.cpp \ | 35 | session.cpp \ |
34 | mainwindow.cpp \ | 36 | mainwindow.cpp \ |
35 | profile.cpp \ | 37 | profile.cpp \ |
36 | profileconfig.cpp \ | 38 | profileconfig.cpp \ |
37 | profilemanager.cpp \ | 39 | profilemanager.cpp \ |
38 | tabwidget.cpp \ | 40 | tabwidget.cpp \ |
39 | configdialog.cpp \ | 41 | configdialog.cpp \ |
40 | emulation_layer.cpp \ | 42 | emulation_layer.cpp \ |
41 | widget.cpp \ | 43 | widget.cpp \ |
42 | vt102emulation.cpp \ | 44 | vt102emulation.cpp \ |
43 | history.cpp \ | 45 | history.cpp \ |
44 | screen.cpp \ | 46 | screen.cpp \ |
45 | keytrans.cpp \ | 47 | keytrans.cpp \ |
46 | widget_layer.cpp \ | 48 | widget_layer.cpp \ |
47 | transferdialog.cpp \ | 49 | transferdialog.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 | ||
52 | INTERFACES = configurebase.ui editbase.ui | 56 | INTERFACES = configurebase.ui editbase.ui |
53 | INCLUDEPATH += $(OPIEDIR)/include | 57 | INCLUDEPATH += $(OPIEDIR)/include |
54 | DEPENDPATH += $(OPIEDIR)/include | 58 | DEPENDPATH += $(OPIEDIR)/include |
55 | LIBS += -lqpe -lopie | 59 | LIBS += -lqpe -lopie |
56 | TARGET = opie-console | 60 | TARGET = opie-console |
57 | 61 | ||
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 | |||
@@ -136,55 +136,62 @@ void ProfileEditorDialog::accept() | |||
136 | { | 136 | { |
137 | QMessageBox::information(this, | 137 | QMessageBox::information(this, |
138 | QObject::tr("Invalid profile"), | 138 | QObject::tr("Invalid profile"), |
139 | QObject::tr("Please enter a profile name.")); | 139 | QObject::tr("Please enter a profile name.")); |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | // Save profile and plugin profile | 142 | // Save profile and plugin profile |
143 | //if(plugin_plugin) plugin_plugin->save(); | 143 | //if(plugin_plugin) plugin_plugin->save(); |
144 | 144 | ||
145 | // Save general values | 145 | // Save general values |
146 | m_prof.setName(profName()); | 146 | m_prof.setName(profName()); |
147 | m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); | 147 | m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); |
148 | m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); | 148 | m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); |
149 | qWarning("Term %s %s", m_fact->internal(m_termCmb->currentText() ).data(), | 149 | qWarning("Term %s %s", m_fact->internal(m_termCmb->currentText() ).data(), |
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 | } |
154 | 159 | ||
155 | 160 | ||
156 | QString ProfileEditorDialog::profName()const | 161 | QString ProfileEditorDialog::profName()const |
157 | { | 162 | { |
158 | return m_name->text(); | 163 | return m_name->text(); |
159 | } | 164 | } |
160 | 165 | ||
161 | QCString ProfileEditorDialog::profType()const | 166 | QCString ProfileEditorDialog::profType()const |
162 | { | 167 | { |
163 | /*QStringList w = m_fact->configWidgets(); | 168 | /*QStringList w = m_fact->configWidgets(); |
164 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) | 169 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) |
165 | if(device_box->currentText() == m_fact->name((*it))) return (*it); | 170 | if(device_box->currentText() == m_fact->name((*it))) return (*it); |
166 | */ | 171 | */ |
167 | return QCString(); | 172 | return QCString(); |
168 | } | 173 | } |
169 | /* | 174 | /* |
170 | * we need to switch the widget | 175 | * we need to switch the widget |
171 | */ | 176 | */ |
172 | void ProfileEditorDialog::slotConActivated( const QString& str ) { | 177 | void ProfileEditorDialog::slotConActivated( const QString& str ) { |
173 | delete m_con; | 178 | delete m_con; |
174 | m_con = m_fact->newConnectionPlugin( str, m_tabCon ); | 179 | m_con = m_fact->newConnectionPlugin( str, m_tabCon ); |
175 | 180 | ||
176 | if (m_con ) | 181 | if (m_con ) |
177 | m_layCon->addWidget( m_con ); | 182 | m_layCon->addWidget( m_con ); |
178 | } | 183 | } |
179 | /* | 184 | /* |
180 | * we need to switch the widget | 185 | * we need to switch the widget |
181 | */ | 186 | */ |
182 | void ProfileEditorDialog::slotTermActivated( const QString& str ) { | 187 | void 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 | |||
13 | namespace { | ||
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 | |||
32 | TerminalWidget::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 | } | ||
101 | TerminalWidget::~TerminalWidget() { | ||
102 | } | ||
103 | void 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 | } | ||
152 | void 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 | |||
6 | class QComboBox; | ||
7 | class QLabel; | ||
8 | class QVBoxLayout; | ||
9 | class QHBoxLayout; | ||
10 | class QButtonGroup; | ||
11 | class QRadioButton; | ||
12 | class QCheckBox; | ||
13 | class QHGroupBox; | ||
14 | |||
15 | class TerminalWidget : public ProfileDialogTerminalWidget { | ||
16 | Q_OBJECT | ||
17 | public: | ||
18 | TerminalWidget(const QString& name, QWidget* wid, | ||
19 | const char* na ) ; | ||
20 | ~TerminalWidget(); | ||
21 | |||
22 | void load( const Profile& ); | ||
23 | void save( Profile& ); | ||
24 | private: | ||
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 | ||