author | harlekin <harlekin> | 2002-10-07 18:10:10 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-10-07 18:10:10 (UTC) |
commit | 3d7d26f3c6ec040d883f1a1f7137c1ded6d9d76d (patch) (unidiff) | |
tree | 7fdc70be408f3c4ac5160ccf1cbc2e3584630ef9 | |
parent | d55aa591770675008da9e3290617e463a77e4c98 (diff) | |
download | opie-3d7d26f3c6ec040d883f1a1f7137c1ded6d9d76d.zip opie-3d7d26f3c6ec040d883f1a1f7137c1ded6d9d76d.tar.gz opie-3d7d26f3c6ec040d883f1a1f7137c1ded6d9d76d.tar.bz2 |
forgot about a otabwidget speciality
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index be23eff..3843943 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp | |||
@@ -1,188 +1,189 @@ | |||
1 | 1 | ||
2 | #include <opie/otabwidget.h> | 2 | #include <opie/otabwidget.h> |
3 | #include "profileeditordialog.h" | 3 | #include "profileeditordialog.h" |
4 | 4 | ||
5 | #include "qlayout.h" | 5 | #include "qlayout.h" |
6 | #include "qlineedit.h" | 6 | #include "qlineedit.h" |
7 | #include "qlabel.h" | 7 | #include "qlabel.h" |
8 | #include "qmessagebox.h" | 8 | #include "qmessagebox.h" |
9 | #include "qstringlist.h" | 9 | #include "qstringlist.h" |
10 | #include "qcombobox.h" | 10 | #include "qcombobox.h" |
11 | 11 | ||
12 | #include "profileeditorplugins.h" | 12 | #include "profileeditorplugins.h" |
13 | #include "metafactory.h" | 13 | #include "metafactory.h" |
14 | 14 | ||
15 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, | 15 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, |
16 | const Profile& prof ) | 16 | const Profile& prof ) |
17 | : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) | 17 | : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) |
18 | { | 18 | { |
19 | initUI(); | 19 | initUI(); |
20 | 20 | ||
21 | // Apply current profile | 21 | // Apply current profile |
22 | // plugin_plugin->load(profile); | 22 | // plugin_plugin->load(profile); |
23 | // ... (reset profile name line edit etc.) | 23 | // ... (reset profile name line edit etc.) |
24 | } | 24 | } |
25 | 25 | ||
26 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) | 26 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) |
27 | : QDialog(0, 0, TRUE), m_fact( fact ) | 27 | : QDialog(0, 0, TRUE), m_fact( fact ) |
28 | { | 28 | { |
29 | // Default profile | 29 | // Default profile |
30 | m_prof = Profile(QString::null, "serial", Profile::Black, Profile::White, Profile::VT102); | 30 | m_prof = Profile(QString::null, "serial", Profile::Black, Profile::White, Profile::VT102); |
31 | 31 | ||
32 | initUI(); | 32 | initUI(); |
33 | 33 | ||
34 | // Apply current profile | 34 | // Apply current profile |
35 | // plugin_plugin->load(profile); | 35 | // plugin_plugin->load(profile); |
36 | } | 36 | } |
37 | 37 | ||
38 | Profile ProfileEditorDialog::profile() const | 38 | Profile ProfileEditorDialog::profile() const |
39 | { | 39 | { |
40 | return m_prof; | 40 | return m_prof; |
41 | } | 41 | } |
42 | 42 | ||
43 | void ProfileEditorDialog::initUI() | 43 | void ProfileEditorDialog::initUI() |
44 | { | 44 | { |
45 | 45 | ||
46 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); | 46 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); |
47 | OTabWidget *tabWidget = new OTabWidget( this ); | 47 | OTabWidget *tabWidget = new OTabWidget( this ); |
48 | mainLayout->add(tabWidget); | 48 | mainLayout->add(tabWidget); |
49 | 49 | ||
50 | QWidget *tabterm, *tabconn, *tabprof; | 50 | QWidget *tabterm, *tabconn, *tabprof; |
51 | 51 | ||
52 | tabprof = new QWidget(this); | 52 | tabprof = new QWidget(this); |
53 | tabterm = new QWidget(this); | 53 | tabterm = new QWidget(this); |
54 | tabconn = new QWidget(this); | 54 | tabconn = new QWidget(this); |
55 | 55 | ||
56 | // for the time being: fake factory | 56 | // for the time being: fake factory |
57 | 57 | ||
58 | m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial); | 58 | m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial); |
59 | m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda); | 59 | m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda); |
60 | m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem); | 60 | m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem); |
61 | 61 | ||
62 | // profile tab | 62 | // profile tab |
63 | 63 | ||
64 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); | 64 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); |
65 | 65 | ||
66 | name_line = new QLineEdit(tabprof); | 66 | name_line = new QLineEdit(tabprof); |
67 | 67 | ||
68 | // connection tab, fixed part | 68 | // connection tab, fixed part |
69 | 69 | ||
70 | QLabel *device = new QLabel(QObject::tr("Device"), tabconn); | 70 | QLabel *device = new QLabel(QObject::tr("Device"), tabconn); |
71 | 71 | ||
72 | device_box = new QComboBox(tabconn); | 72 | device_box = new QComboBox(tabconn); |
73 | 73 | ||
74 | QStringList w = m_fact->configWidgets(); | 74 | QStringList w = m_fact->configWidgets(); |
75 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) | 75 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) |
76 | device_box->insertItem(m_fact->name((*it))); | 76 | device_box->insertItem(m_fact->name((*it))); |
77 | 77 | ||
78 | // connection tab, factory part | 78 | // connection tab, factory part |
79 | plugin_base = new QWidget(tabconn); | 79 | plugin_base = new QWidget(tabconn); |
80 | plugin_layout = new QHBoxLayout(plugin_base, 0); | 80 | plugin_layout = new QHBoxLayout(plugin_base, 0); |
81 | 81 | ||
82 | plugin_plugin = m_fact->newConfigPlugin("serial", plugin_base, &m_prof); | 82 | plugin_plugin = m_fact->newConfigPlugin("serial", plugin_base, &m_prof); |
83 | plugin_layout->add(plugin_plugin->widget()); | 83 | plugin_layout->add(plugin_plugin->widget()); |
84 | 84 | ||
85 | // connection tab, general part | 85 | // connection tab, general part |
86 | 86 | ||
87 | QWidget *conn_widget = plugin_plugin->connection_widget(); | 87 | QWidget *conn_widget = plugin_plugin->connection_widget(); |
88 | conn_widget->reparent(tabconn, 0, QPoint(), true); | 88 | conn_widget->reparent(tabconn, 0, QPoint(), true); |
89 | 89 | ||
90 | // terminal tab | 90 | // terminal tab |
91 | 91 | ||
92 | QWidget *term_widget = plugin_plugin->terminal_widget(); | 92 | QWidget *term_widget = plugin_plugin->terminal_widget(); |
93 | term_widget->reparent(tabterm, 0, QPoint(), true); | 93 | term_widget->reparent(tabterm, 0, QPoint(), true); |
94 | 94 | ||
95 | // layouting | 95 | // layouting |
96 | 96 | ||
97 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); | 97 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); |
98 | vbox3->add(name); | 98 | vbox3->add(name); |
99 | vbox3->add(name_line); | 99 | vbox3->add(name_line); |
100 | vbox3->addStretch(1); | 100 | vbox3->addStretch(1); |
101 | 101 | ||
102 | QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2); | 102 | QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2); |
103 | vbox->add(device); | 103 | vbox->add(device); |
104 | vbox->add(device_box); | 104 | vbox->add(device_box); |
105 | vbox->add(plugin_base); | 105 | vbox->add(plugin_base); |
106 | vbox->add(conn_widget); | 106 | vbox->add(conn_widget); |
107 | vbox->setStretchFactor(device, 1); | 107 | vbox->setStretchFactor(device, 1); |
108 | vbox->setStretchFactor(device_box, 1); | 108 | vbox->setStretchFactor(device_box, 1); |
109 | vbox->setStretchFactor(plugin_base, 1); | 109 | vbox->setStretchFactor(plugin_base, 1); |
110 | vbox->setStretchFactor(conn_widget, 7); | 110 | vbox->setStretchFactor(conn_widget, 7); |
111 | 111 | ||
112 | QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2); | 112 | QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2); |
113 | vbox2->add(term_widget); | 113 | vbox2->add(term_widget); |
114 | 114 | ||
115 | tabWidget->addTab(tabprof, "", QObject::tr("Profile")); | 115 | tabWidget->addTab(tabprof, "", QObject::tr("Profile")); |
116 | tabWidget->addTab(tabconn, "", QObject::tr("Connection")); | 116 | tabWidget->addTab(tabconn, "", QObject::tr("Connection")); |
117 | tabWidget->addTab(tabterm, "", QObject::tr("Terminal")); | 117 | tabWidget->addTab(tabterm, "", QObject::tr("Terminal")); |
118 | tabWidget->setCurrentTab( tabprof ); | ||
118 | 119 | ||
119 | // load profile values | 120 | // load profile values |
120 | name_line->setText(m_prof.name()); | 121 | name_line->setText(m_prof.name()); |
121 | for(int i = 0; i < device_box->count(); i++) | 122 | for(int i = 0; i < device_box->count(); i++) |
122 | { | 123 | { |
123 | device_box->setCurrentItem(i); | 124 | device_box->setCurrentItem(i); |
124 | if(prof_type() == m_prof.ioLayerName()) | 125 | if(prof_type() == m_prof.ioLayerName()) |
125 | { | 126 | { |
126 | slotDevice(i); | 127 | slotDevice(i); |
127 | break; | 128 | break; |
128 | } | 129 | } |
129 | } | 130 | } |
130 | 131 | ||
131 | // signals | 132 | // signals |
132 | connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int))); | 133 | connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int))); |
133 | } | 134 | } |
134 | 135 | ||
135 | ProfileEditorDialog::~ProfileEditorDialog() { | 136 | ProfileEditorDialog::~ProfileEditorDialog() { |
136 | 137 | ||
137 | } | 138 | } |
138 | 139 | ||
139 | void ProfileEditorDialog::slotDevice(int id) | 140 | void ProfileEditorDialog::slotDevice(int id) |
140 | { | 141 | { |
141 | delete plugin_plugin; | 142 | delete plugin_plugin; |
142 | 143 | ||
143 | plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, &m_prof); | 144 | plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, &m_prof); |
144 | plugin_layout->add(plugin_plugin->widget()); | 145 | plugin_layout->add(plugin_plugin->widget()); |
145 | 146 | ||
146 | // Reload profile associated to device, including e.g. conn_device() | 147 | // Reload profile associated to device, including e.g. conn_device() |
147 | // m_prof = plugin_plugin->profile() | 148 | // m_prof = plugin_plugin->profile() |
148 | // or, keeping the profile name: m_prof->reload(plugin_plugin->profile()) | 149 | // or, keeping the profile name: m_prof->reload(plugin_plugin->profile()) |
149 | 150 | ||
150 | //plugin_plugin->show(); | 151 | //plugin_plugin->show(); |
151 | plugin_plugin->widget()->show(); | 152 | plugin_plugin->widget()->show(); |
152 | } | 153 | } |
153 | 154 | ||
154 | void ProfileEditorDialog::accept() | 155 | void ProfileEditorDialog::accept() |
155 | { | 156 | { |
156 | if(prof_name().isEmpty()) | 157 | if(prof_name().isEmpty()) |
157 | { | 158 | { |
158 | QMessageBox::information(this, | 159 | QMessageBox::information(this, |
159 | QObject::tr("Invalid profile"), | 160 | QObject::tr("Invalid profile"), |
160 | QObject::tr("Please enter a profile name.")); | 161 | QObject::tr("Please enter a profile name.")); |
161 | return; | 162 | return; |
162 | } | 163 | } |
163 | // Save profile and plugin profile | 164 | // Save profile and plugin profile |
164 | if(plugin_plugin) plugin_plugin->save(); | 165 | if(plugin_plugin) plugin_plugin->save(); |
165 | 166 | ||
166 | // Save general values | 167 | // Save general values |
167 | m_prof.setName(prof_name()); | 168 | m_prof.setName(prof_name()); |
168 | m_prof.setIOLayer(prof_type()); | 169 | m_prof.setIOLayer(prof_type()); |
169 | 170 | ||
170 | QDialog::accept(); | 171 | QDialog::accept(); |
171 | } | 172 | } |
172 | 173 | ||
173 | 174 | ||
174 | QString ProfileEditorDialog::prof_name() | 175 | QString ProfileEditorDialog::prof_name() |
175 | { | 176 | { |
176 | return name_line->text(); | 177 | return name_line->text(); |
177 | } | 178 | } |
178 | 179 | ||
179 | QString ProfileEditorDialog::prof_type() | 180 | QString ProfileEditorDialog::prof_type() |
180 | { | 181 | { |
181 | QStringList w = m_fact->configWidgets(); | 182 | QStringList w = m_fact->configWidgets(); |
182 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) | 183 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) |
183 | if(device_box->currentText() == m_fact->name((*it))) return (*it); | 184 | if(device_box->currentText() == m_fact->name((*it))) return (*it); |
184 | 185 | ||
185 | return QString::null; | 186 | return QString::null; |
186 | } | 187 | } |
187 | 188 | ||
188 | 189 | ||