author | josef <josef> | 2002-10-06 11:38:51 (UTC) |
---|---|---|
committer | josef <josef> | 2002-10-06 11:38:51 (UTC) |
commit | 0b7136e077b0ec2767722c38ee0939b53a95fe6a (patch) (unidiff) | |
tree | 74fe158d876abbcdbeb17fbe0bc217a4df09eac9 | |
parent | a8a476782082bd340690308673983bc7e3238db5 (diff) | |
download | opie-0b7136e077b0ec2767722c38ee0939b53a95fe6a.zip opie-0b7136e077b0ec2767722c38ee0939b53a95fe6a.tar.gz opie-0b7136e077b0ec2767722c38ee0939b53a95fe6a.tar.bz2 |
- restructure menu to use metafactory
- this is work in progress
-rw-r--r-- | noncore/apps/opie-console/metafactory.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.h | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 131 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.h | 5 |
4 files changed, 95 insertions, 52 deletions
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp index 754f34c..04f1cbe 100644 --- a/noncore/apps/opie-console/metafactory.cpp +++ b/noncore/apps/opie-console/metafactory.cpp | |||
@@ -7,7 +7,9 @@ MetaFactory::~MetaFactory() { | |||
7 | 7 | ||
8 | } | 8 | } |
9 | void MetaFactory::addConfigWidgetFactory( const QString& str, | 9 | void MetaFactory::addConfigWidgetFactory( const QString& str, |
10 | const QString& name, | ||
10 | configWidget wid) { | 11 | configWidget wid) { |
12 | m_namemap.insert ( str, name ); | ||
11 | m_confFact.insert( str, wid ); | 13 | m_confFact.insert( str, wid ); |
12 | } | 14 | } |
13 | void MetaFactory::addIOLayerFactory( const QString& str, | 15 | void MetaFactory::addIOLayerFactory( const QString& str, |
@@ -56,3 +58,8 @@ IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { | |||
56 | 58 | ||
57 | return lay; | 59 | return lay; |
58 | } | 60 | } |
61 | |||
62 | QString MetaFactory::name( const QString& str ) { | ||
63 | return m_namemap[str]; | ||
64 | } | ||
65 | |||
diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h index bdd2ad2..7fa53c6 100644 --- a/noncore/apps/opie-console/metafactory.h +++ b/noncore/apps/opie-console/metafactory.h | |||
@@ -25,6 +25,7 @@ public: | |||
25 | ~MetaFactory(); | 25 | ~MetaFactory(); |
26 | 26 | ||
27 | void addConfigWidgetFactory( const QString&, | 27 | void addConfigWidgetFactory( const QString&, |
28 | const QString&, | ||
28 | configWidget ); | 29 | configWidget ); |
29 | void addIOLayerFactory(const QString&, | 30 | void addIOLayerFactory(const QString&, |
30 | iolayer ); | 31 | iolayer ); |
@@ -35,10 +36,13 @@ public: | |||
35 | QStringList fileTransferLayers()const; | 36 | QStringList fileTransferLayers()const; |
36 | IOLayer* newIOLayer( const QString&,const Profile& ); | 37 | IOLayer* newIOLayer( const QString&,const Profile& ); |
37 | 38 | ||
39 | QString name( const QString& ); | ||
40 | |||
38 | private: | 41 | private: |
39 | QMap<QString, configWidget> m_confFact; | 42 | QMap<QString, configWidget> m_confFact; |
40 | QMap<QString, iolayer> m_layerFact; | 43 | QMap<QString, iolayer> m_layerFact; |
41 | QMap<QString, filelayer> m_fileFact; | 44 | QMap<QString, filelayer> m_fileFact; |
45 | QMap<QString, QString> m_namemap; | ||
42 | }; | 46 | }; |
43 | 47 | ||
44 | 48 | ||
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index 849439d..859abdd 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp | |||
@@ -8,6 +8,42 @@ | |||
8 | #include "qcombobox.h" | 8 | #include "qcombobox.h" |
9 | #include "qcheckbox.h" | 9 | #include "qcheckbox.h" |
10 | #include "qmessagebox.h" | 10 | #include "qmessagebox.h" |
11 | #include "qbuttongroup.h" | ||
12 | #include "qstringlist.h" | ||
13 | |||
14 | #include "metafactory.h" | ||
15 | |||
16 | static QWidget *factory_serial(QWidget *parent) | ||
17 | { | ||
18 | QFrame *device_frame = new QFrame(parent); | ||
19 | device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); | ||
20 | |||
21 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); | ||
22 | QLabel *frame_number = new QLabel(QObject::tr("Phone number"), device_frame); | ||
23 | frame_number->hide(); | ||
24 | |||
25 | QLineEdit *frame_device_line = new QLineEdit("/dev/ttyS0", device_frame); | ||
26 | QLineEdit *frame_number_line = new QLineEdit(device_frame); | ||
27 | frame_number_line->hide(); | ||
28 | |||
29 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); | ||
30 | vbox_frame->add(frame_device); | ||
31 | vbox_frame->add(frame_device_line); | ||
32 | vbox_frame->add(frame_number); | ||
33 | vbox_frame->add(frame_number_line); | ||
34 | |||
35 | return device_frame; | ||
36 | } | ||
37 | |||
38 | static QWidget *factory_irda(QWidget *parent) | ||
39 | { | ||
40 | return NULL; | ||
41 | } | ||
42 | |||
43 | static QWidget *factory_modem(QWidget *parent) | ||
44 | { | ||
45 | return NULL; | ||
46 | } | ||
11 | 47 | ||
12 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, | 48 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, |
13 | const Profile& prof ) | 49 | const Profile& prof ) |
@@ -27,36 +63,32 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) | |||
27 | tabterm = new QWidget(this); | 63 | tabterm = new QWidget(this); |
28 | tabconn = new QWidget(this); | 64 | tabconn = new QWidget(this); |
29 | 65 | ||
66 | // for the time being: fake factory | ||
67 | |||
68 | m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial); | ||
69 | m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda); | ||
70 | m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem); | ||
71 | |||
30 | // profile tab | 72 | // profile tab |
31 | 73 | ||
32 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); | 74 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); |
33 | QLabel *device = new QLabel(QObject::tr("Device"), tabprof); | ||
34 | 75 | ||
35 | name_line = new QLineEdit(tabprof); | 76 | name_line = new QLineEdit(tabprof); |
36 | 77 | ||
37 | device_box = new QComboBox(tabprof); | 78 | // connection tab, fixed part |
38 | device_box->insertItem(QObject::tr("Serial cable")); | ||
39 | device_box->insertItem(QObject::tr("IrDA port")); | ||
40 | device_box->insertItem(QObject::tr("Serial via modem")); | ||
41 | 79 | ||
42 | QFrame *device_frame = new QFrame(tabprof); | 80 | QLabel *device = new QLabel(QObject::tr("Device"), tabconn); |
43 | device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); | ||
44 | 81 | ||
45 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); | 82 | device_box = new QComboBox(tabconn); |
46 | frame_number = new QLabel(QObject::tr("Phone number"), device_frame); | ||
47 | frame_number->hide(); | ||
48 | 83 | ||
49 | frame_device_line = new QLineEdit("/dev/ttyS0", device_frame); | 84 | QStringList w = m_fact->configWidgets(); |
50 | frame_number_line = new QLineEdit(device_frame); | 85 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) |
51 | frame_number_line->hide(); | 86 | device_box->insertItem(m_fact->name((*it))); |
52 | 87 | ||
53 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); | 88 | // connection tab, factory part |
54 | vbox_frame->add(frame_device); | 89 | QFrame *device_frame = static_cast<QFrame*>(factory_serial(tabconn)); |
55 | vbox_frame->add(frame_device_line); | ||
56 | vbox_frame->add(frame_number); | ||
57 | vbox_frame->add(frame_number_line); | ||
58 | 90 | ||
59 | // connection tab | 91 | // connection tab, general part |
60 | 92 | ||
61 | speed_box = new QComboBox(tabconn); | 93 | speed_box = new QComboBox(tabconn); |
62 | speed_box->insertItem("115200 baud"); | 94 | speed_box->insertItem("115200 baud"); |
@@ -65,21 +97,23 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) | |||
65 | speed_box->insertItem("19200 baud"); | 97 | speed_box->insertItem("19200 baud"); |
66 | speed_box->insertItem("9600 baud"); | 98 | speed_box->insertItem("9600 baud"); |
67 | 99 | ||
68 | QLabel *protocol = new QLabel(QObject::tr("Protocol"), tabconn); | ||
69 | QLabel *speed = new QLabel(QObject::tr("Speed"), tabconn); | 100 | QLabel *speed = new QLabel(QObject::tr("Speed"), tabconn); |
70 | QLabel *flow = new QLabel(QObject::tr("Flow control"), tabconn); | 101 | QLabel *flow = new QLabel(QObject::tr("Flow control"), tabconn); |
71 | QLabel *parity = new QLabel(QObject::tr("Parity"), tabconn); | 102 | QLabel *parity = new QLabel(QObject::tr("Parity"), tabconn); |
72 | 103 | ||
73 | QComboBox *protocol_box = new QComboBox(tabconn); | 104 | QButtonGroup *group_flow = new QButtonGroup(tabconn); |
74 | protocol_box->insertItem(QObject::tr("XModem")); | 105 | group_flow->hide(); |
75 | protocol_box->insertItem(QObject::tr("YModem")); | ||
76 | protocol_box->insertItem(QObject::tr("ZModem")); | ||
77 | |||
78 | QRadioButton *flow_hw = new QRadioButton(QObject::tr("Hardware"), tabconn); | 106 | QRadioButton *flow_hw = new QRadioButton(QObject::tr("Hardware"), tabconn); |
79 | QRadioButton *flow_sw = new QRadioButton(QObject::tr("Software"), tabconn); | 107 | QRadioButton *flow_sw = new QRadioButton(QObject::tr("Software"), tabconn); |
108 | group_flow->insert(flow_hw); | ||
109 | group_flow->insert(flow_sw); | ||
80 | 110 | ||
111 | QButtonGroup *group_parity = new QButtonGroup(tabconn); | ||
112 | group_parity->hide(); | ||
81 | QRadioButton *parity_odd = new QRadioButton(QObject::tr("Odd"), tabconn); | 113 | QRadioButton *parity_odd = new QRadioButton(QObject::tr("Odd"), tabconn); |
82 | QRadioButton *parity_even = new QRadioButton(QObject::tr("Even"), tabconn); | 114 | QRadioButton *parity_even = new QRadioButton(QObject::tr("Even"), tabconn); |
115 | group_parity->insert(parity_odd); | ||
116 | group_parity->insert(parity_even); | ||
83 | 117 | ||
84 | flow_sw->setChecked(true); | 118 | flow_sw->setChecked(true); |
85 | parity_odd->setChecked(true); | 119 | parity_odd->setChecked(true); |
@@ -88,7 +122,8 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) | |||
88 | 122 | ||
89 | terminal_box = new QComboBox(tabterm); | 123 | terminal_box = new QComboBox(tabterm); |
90 | terminal_box->insertItem("VT 100"); | 124 | terminal_box->insertItem("VT 100"); |
91 | terminal_box->insertItem("VT 102"); | 125 | terminal_box->insertItem("VT 220"); |
126 | terminal_box->insertItem("ANSI"); | ||
92 | 127 | ||
93 | QLabel *terminal = new QLabel(QObject::tr("Terminal type"), tabterm); | 128 | QLabel *terminal = new QLabel(QObject::tr("Terminal type"), tabterm); |
94 | QLabel *colour = new QLabel(QObject::tr("Colour scheme"), tabterm); | 129 | QLabel *colour = new QLabel(QObject::tr("Colour scheme"), tabterm); |
@@ -100,9 +135,14 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) | |||
100 | colour_box->insertItem(QObject::tr("black on white")); | 135 | colour_box->insertItem(QObject::tr("black on white")); |
101 | colour_box->insertItem(QObject::tr("white on black")); | 136 | colour_box->insertItem(QObject::tr("white on black")); |
102 | 137 | ||
138 | QButtonGroup *group_size = new QButtonGroup(tabterm); | ||
139 | group_size->hide(); | ||
103 | QRadioButton *size_small = new QRadioButton(QObject::tr("small"), tabterm); | 140 | QRadioButton *size_small = new QRadioButton(QObject::tr("small"), tabterm); |
104 | QRadioButton *size_medium = new QRadioButton(QObject::tr("medium"), tabterm); | 141 | QRadioButton *size_medium = new QRadioButton(QObject::tr("medium"), tabterm); |
105 | QRadioButton *size_large = new QRadioButton(QObject::tr("large"), tabterm); | 142 | QRadioButton *size_large = new QRadioButton(QObject::tr("large"), tabterm); |
143 | group_size->insert(size_small); | ||
144 | group_size->insert(size_medium); | ||
145 | group_size->insert(size_large); | ||
106 | 146 | ||
107 | QCheckBox *option_echo = new QCheckBox(QObject::tr("Local echo"), tabterm); | 147 | QCheckBox *option_echo = new QCheckBox(QObject::tr("Local echo"), tabterm); |
108 | QCheckBox *option_wrap = new QCheckBox(QObject::tr("Line wrap"), tabterm); | 148 | QCheckBox *option_wrap = new QCheckBox(QObject::tr("Line wrap"), tabterm); |
@@ -115,23 +155,24 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) | |||
115 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); | 155 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); |
116 | vbox3->add(name); | 156 | vbox3->add(name); |
117 | vbox3->add(name_line); | 157 | vbox3->add(name_line); |
118 | vbox3->add(device); | 158 | vbox3->addStretch(1); |
119 | vbox3->add(device_box); | ||
120 | vbox3->add(device_frame); | ||
121 | 159 | ||
122 | QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2); | 160 | QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2); |
123 | vbox->add(protocol); | 161 | vbox->add(device); |
124 | vbox->add(protocol_box); | 162 | vbox->add(device_box); |
163 | vbox->add(device_frame); | ||
125 | vbox->add(speed); | 164 | vbox->add(speed); |
126 | vbox->add(speed_box); | 165 | vbox->add(speed_box); |
127 | vbox->add(flow); | 166 | vbox->add(flow); |
128 | QHBoxLayout *hbox = new QHBoxLayout(vbox, 2); | 167 | QHBoxLayout *hbox = new QHBoxLayout(vbox, 2); |
129 | hbox->add(flow_hw); | 168 | hbox->add(flow_hw); |
130 | hbox->add(flow_sw); | 169 | hbox->add(flow_sw); |
170 | //vbox->add(group_flow); | ||
131 | vbox->add(parity); | 171 | vbox->add(parity); |
132 | QHBoxLayout *hbox2 = new QHBoxLayout(vbox, 2); | 172 | QHBoxLayout *hbox2 = new QHBoxLayout(vbox, 2); |
133 | hbox2->add(parity_odd); | 173 | hbox2->add(parity_odd); |
134 | hbox2->add(parity_even); | 174 | hbox2->add(parity_even); |
175 | //vbox->add(group_parity); | ||
135 | 176 | ||
136 | QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2); | 177 | QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2); |
137 | vbox2->add(terminal); | 178 | vbox2->add(terminal); |
@@ -141,6 +182,7 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) | |||
141 | hbox3->add(size_small); | 182 | hbox3->add(size_small); |
142 | hbox3->add(size_medium); | 183 | hbox3->add(size_medium); |
143 | hbox3->add(size_large); | 184 | hbox3->add(size_large); |
185 | //vbox2->add(group_size); | ||
144 | vbox2->add(colour); | 186 | vbox2->add(colour); |
145 | vbox2->add(colour_box); | 187 | vbox2->add(colour_box); |
146 | vbox2->add(conversions); | 188 | vbox2->add(conversions); |
@@ -172,24 +214,12 @@ ProfileEditorDialog::~ProfileEditorDialog() { | |||
172 | 214 | ||
173 | void ProfileEditorDialog::slotDevice(int id) | 215 | void ProfileEditorDialog::slotDevice(int id) |
174 | { | 216 | { |
175 | switch(id) | 217 | MetaFactory::configWidget c; |
176 | { | 218 | |
177 | case 0: | 219 | //c = m_fact->; |
178 | frame_device_line->setText("/dev/ttyS0"); | 220 | c = factory_serial; |
179 | frame_number->hide(); | 221 | |
180 | frame_number_line->hide(); | 222 | QFrame *device_frame = static_cast<QFrame*>(c(NULL)); |
181 | break; | ||
182 | case 1: | ||
183 | frame_device_line->setText("/dev/ircomm0"); | ||
184 | frame_number->hide(); | ||
185 | frame_number_line->hide(); | ||
186 | break; | ||
187 | case 2: | ||
188 | frame_device_line->setText("/dev/ttyS0"); | ||
189 | frame_number->show(); | ||
190 | frame_number_line->show(); | ||
191 | break; | ||
192 | } | ||
193 | } | 223 | } |
194 | 224 | ||
195 | void ProfileEditorDialog::slotOk() | 225 | void ProfileEditorDialog::slotOk() |
@@ -235,7 +265,8 @@ QString ProfileEditorDialog::prof_type() | |||
235 | 265 | ||
236 | QString ProfileEditorDialog::conn_device() | 266 | QString ProfileEditorDialog::conn_device() |
237 | { | 267 | { |
238 | return frame_device_line->text(); | 268 | //return frame_device_line->text(); |
269 | return "serial"; | ||
239 | } | 270 | } |
240 | 271 | ||
241 | int ProfileEditorDialog::conn_baud() | 272 | int ProfileEditorDialog::conn_baud() |
diff --git a/noncore/apps/opie-console/profileeditordialog.h b/noncore/apps/opie-console/profileeditordialog.h index f81354c..dfe4490 100644 --- a/noncore/apps/opie-console/profileeditordialog.h +++ b/noncore/apps/opie-console/profileeditordialog.h | |||
@@ -48,8 +48,9 @@ private: | |||
48 | QHBoxLayout* m_lay; | 48 | QHBoxLayout* m_lay; |
49 | Profile m_prof; | 49 | Profile m_prof; |
50 | 50 | ||
51 | QLabel *frame_number; | 51 | //QLabel *frame_number; |
52 | QLineEdit *name_line, *frame_device_line, *frame_number_line; | 52 | QLineEdit *name_line; |
53 | //QLineEdit *frame_device_line, *frame_number_line; | ||
53 | QComboBox *terminal_box, *speed_box, *device_box; | 54 | QComboBox *terminal_box, *speed_box, *device_box; |
54 | }; | 55 | }; |
55 | 56 | ||