summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/profileeditordialog.cpp
authorharlekin <harlekin>2002-10-07 18:05:43 (UTC)
committer harlekin <harlekin>2002-10-07 18:05:43 (UTC)
commitd55aa591770675008da9e3290617e463a77e4c98 (patch) (unidiff)
tree93d779cc85298545673f4d5f2ea0fcc7d4d301b7 /noncore/apps/opie-console/profileeditordialog.cpp
parentd25a925e70982b86539b98362ab2cd75c7883110 (diff)
downloadopie-d55aa591770675008da9e3290617e463a77e4c98.zip
opie-d55aa591770675008da9e3290617e463a77e4c98.tar.gz
opie-d55aa591770675008da9e3290617e463a77e4c98.tar.bz2
reworked config dialog gui a bit and adapted it to opie
Diffstat (limited to 'noncore/apps/opie-console/profileeditordialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index 8e63429..be23eff 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -1,55 +1,61 @@
1 1
2#include <opie/otabwidget.h>
2#include "profileeditordialog.h" 3#include "profileeditordialog.h"
3 4
4#include "qlayout.h" 5#include "qlayout.h"
5#include "qlineedit.h" 6#include "qlineedit.h"
6#include "qlabel.h" 7#include "qlabel.h"
7#include "qmessagebox.h" 8#include "qmessagebox.h"
8#include "qstringlist.h" 9#include "qstringlist.h"
9#include "qcombobox.h" 10#include "qcombobox.h"
10 11
11#include "profileeditorplugins.h" 12#include "profileeditorplugins.h"
12#include "metafactory.h" 13#include "metafactory.h"
13 14
14ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, 15ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact,
15 const Profile& prof ) 16 const Profile& prof )
16 : QTabDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) 17 : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof )
17{ 18{
18 initUI(); 19 initUI();
19 20
20 // Apply current profile 21 // Apply current profile
21 // plugin_plugin->load(profile); 22 // plugin_plugin->load(profile);
22 // ... (reset profile name line edit etc.) 23 // ... (reset profile name line edit etc.)
23} 24}
24 25
25ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) 26ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
26 : QTabDialog(0, 0, TRUE), m_fact( fact ) 27 : QDialog(0, 0, TRUE), m_fact( fact )
27{ 28{
28 // Default profile 29 // Default profile
29 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);
30 31
31 initUI(); 32 initUI();
32 33
33 // Apply current profile 34 // Apply current profile
34 // plugin_plugin->load(profile); 35 // plugin_plugin->load(profile);
35} 36}
36 37
37Profile ProfileEditorDialog::profile() const 38Profile ProfileEditorDialog::profile() const
38{ 39{
39 return m_prof; 40 return m_prof;
40} 41}
41 42
42void ProfileEditorDialog::initUI() 43void ProfileEditorDialog::initUI()
43{ 44{
45
46 QVBoxLayout *mainLayout = new QVBoxLayout( this );
47 OTabWidget *tabWidget = new OTabWidget( this );
48 mainLayout->add(tabWidget);
49
44 QWidget *tabterm, *tabconn, *tabprof; 50 QWidget *tabterm, *tabconn, *tabprof;
45 51
46 tabprof = new QWidget(this); 52 tabprof = new QWidget(this);
47 tabterm = new QWidget(this); 53 tabterm = new QWidget(this);
48 tabconn = new QWidget(this); 54 tabconn = new QWidget(this);
49 55
50 // for the time being: fake factory 56 // for the time being: fake factory
51 57
52 m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial); 58 m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial);
53 m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda); 59 m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda);
54 m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem); 60 m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem);
55 61
@@ -89,51 +95,49 @@ void ProfileEditorDialog::initUI()
89 // layouting 95 // layouting
90 96
91 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); 97 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
92 vbox3->add(name); 98 vbox3->add(name);
93 vbox3->add(name_line); 99 vbox3->add(name_line);
94 vbox3->addStretch(1); 100 vbox3->addStretch(1);
95 101
96 QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2); 102 QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2);
97 vbox->add(device); 103 vbox->add(device);
98 vbox->add(device_box); 104 vbox->add(device_box);
99 vbox->add(plugin_base); 105 vbox->add(plugin_base);
100 vbox->add(conn_widget); 106 vbox->add(conn_widget);
107 vbox->setStretchFactor(device, 1);
108 vbox->setStretchFactor(device_box, 1);
109 vbox->setStretchFactor(plugin_base, 1);
110 vbox->setStretchFactor(conn_widget, 7);
101 111
102 QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2); 112 QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2);
103 vbox2->add(term_widget); 113 vbox2->add(term_widget);
104 114
105 addTab(tabprof, QObject::tr("Profile")); 115 tabWidget->addTab(tabprof, "", QObject::tr("Profile"));
106 addTab(tabconn, QObject::tr("Connection")); 116 tabWidget->addTab(tabconn, "", QObject::tr("Connection"));
107 addTab(tabterm, QObject::tr("Terminal")); 117 tabWidget->addTab(tabterm, "", QObject::tr("Terminal"));
108
109 setOkButton(QObject::tr("OK"));
110 setCancelButton(QObject::tr("Cancel"));
111 118
112 // load profile values 119 // load profile values
113
114 name_line->setText(m_prof.name()); 120 name_line->setText(m_prof.name());
115 for(int i = 0; i < device_box->count(); i++) 121 for(int i = 0; i < device_box->count(); i++)
116 { 122 {
117 device_box->setCurrentItem(i); 123 device_box->setCurrentItem(i);
118 if(prof_type() == m_prof.ioLayerName()) 124 if(prof_type() == m_prof.ioLayerName())
119 { 125 {
120 slotDevice(i); 126 slotDevice(i);
121 break; 127 break;
122 } 128 }
123 } 129 }
124 130
125 // signals 131 // signals
126
127 connect(this, SIGNAL(cancelButtonPressed()), SLOT(slotCancel()));
128 connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int))); 132 connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int)));
129} 133}
130 134
131ProfileEditorDialog::~ProfileEditorDialog() { 135ProfileEditorDialog::~ProfileEditorDialog() {
132 136
133} 137}
134 138
135void ProfileEditorDialog::slotDevice(int id) 139void ProfileEditorDialog::slotDevice(int id)
136{ 140{
137 delete plugin_plugin; 141 delete plugin_plugin;
138 142
139 plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, &m_prof); 143 plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, &m_prof);
@@ -157,28 +161,24 @@ void ProfileEditorDialog::accept()
157 return; 161 return;
158 } 162 }
159 // Save profile and plugin profile 163 // Save profile and plugin profile
160 if(plugin_plugin) plugin_plugin->save(); 164 if(plugin_plugin) plugin_plugin->save();
161 165
162 // Save general values 166 // Save general values
163 m_prof.setName(prof_name()); 167 m_prof.setName(prof_name());
164 m_prof.setIOLayer(prof_type()); 168 m_prof.setIOLayer(prof_type());
165 169
166 QDialog::accept(); 170 QDialog::accept();
167} 171}
168 172
169void ProfileEditorDialog::slotCancel()
170{
171 reject();
172}
173 173
174QString ProfileEditorDialog::prof_name() 174QString ProfileEditorDialog::prof_name()
175{ 175{
176 return name_line->text(); 176 return name_line->text();
177} 177}
178 178
179QString ProfileEditorDialog::prof_type() 179QString ProfileEditorDialog::prof_type()
180{ 180{
181 QStringList w = m_fact->configWidgets(); 181 QStringList w = m_fact->configWidgets();
182 for(QStringList::Iterator it = w.begin(); it != w.end(); it++) 182 for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
183 if(device_box->currentText() == m_fact->name((*it))) return (*it); 183 if(device_box->currentText() == m_fact->name((*it))) return (*it);
184 184