-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 12 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.h | 2 |
2 files changed, 11 insertions, 3 deletions
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index c48ea53..d124067 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp | |||
@@ -15,184 +15,190 @@ namespace { | |||
15 | void setCurrent( const QString& str, QComboBox* bo ) { | 15 | void setCurrent( const QString& str, QComboBox* bo ) { |
16 | for (uint i = 0; i < bo->count(); i++ ) { | 16 | for (uint i = 0; i < bo->count(); i++ ) { |
17 | if ( bo->text(i) == str ) { | 17 | if ( bo->text(i) == str ) { |
18 | bo->setCurrentItem( i ); | 18 | bo->setCurrentItem( i ); |
19 | } | 19 | } |
20 | } | 20 | } |
21 | } | 21 | } |
22 | 22 | ||
23 | 23 | ||
24 | } | 24 | } |
25 | 25 | ||
26 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, | 26 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, |
27 | const Profile& prof ) | 27 | const Profile& prof ) |
28 | : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) | 28 | : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) |
29 | { | 29 | { |
30 | initUI(); | 30 | initUI(); |
31 | 31 | ||
32 | // Apply current profile | 32 | // Apply current profile |
33 | // plugin_plugin->load(profile); | 33 | // plugin_plugin->load(profile); |
34 | // ... (reset profile name line edit etc.) | 34 | // ... (reset profile name line edit etc.) |
35 | } | 35 | } |
36 | 36 | ||
37 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) | 37 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) |
38 | : QDialog(0, 0, TRUE), m_fact( fact ) | 38 | : QDialog(0, 0, TRUE), m_fact( fact ) |
39 | { | 39 | { |
40 | // Default profile | 40 | // Default profile |
41 | m_prof = Profile("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102); | 41 | m_prof = Profile("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102); |
42 | 42 | ||
43 | initUI(); | 43 | initUI(); |
44 | 44 | ||
45 | // Apply current profile | 45 | // Apply current profile |
46 | // plugin_plugin->load(profile); | 46 | // plugin_plugin->load(profile); |
47 | } | 47 | } |
48 | 48 | ||
49 | Profile ProfileEditorDialog::profile() const | 49 | Profile ProfileEditorDialog::profile() const |
50 | { | 50 | { |
51 | return m_prof; | 51 | return m_prof; |
52 | } | 52 | } |
53 | 53 | ||
54 | void ProfileEditorDialog::initUI() | 54 | void ProfileEditorDialog::initUI() |
55 | { | 55 | { |
56 | m_con = m_term = 0l; | 56 | m_con = m_term = 0l; |
57 | 57 | ||
58 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); | 58 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); |
59 | tabWidget = new OTabWidget( this ); | 59 | tabWidget = new OTabWidget( this ); |
60 | tabWidget->setTabStyle(OTabWidget::TextTab); | 60 | tabWidget->setTabStyle(OTabWidget::TextTab); |
61 | mainLayout->add(tabWidget); | 61 | mainLayout->add(tabWidget); |
62 | 62 | ||
63 | QWidget *tabprof; | ||
64 | |||
65 | /* base tabs */ | 63 | /* base tabs */ |
66 | tabprof = new QWidget(this); | 64 | tabprof = new QWidget(this); |
67 | m_tabTerm = new QWidget(this); | 65 | m_tabTerm = new QWidget(this); |
68 | m_tabCon = new QWidget(this); | 66 | m_tabCon = new QWidget(this); |
69 | 67 | ||
70 | /* base layout for tabs */ | 68 | /* base layout for tabs */ |
71 | m_layCon = new QHBoxLayout( m_tabCon , 2 ); | 69 | m_layCon = new QHBoxLayout( m_tabCon , 2 ); |
72 | m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); | 70 | m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); |
73 | 71 | ||
74 | // profile tab | 72 | // profile tab |
75 | 73 | ||
76 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); | 74 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); |
77 | m_name = new QLineEdit(tabprof); | 75 | m_name = new QLineEdit(tabprof); |
78 | QLabel *con = new QLabel(tr("Connection"), tabprof ); | 76 | QLabel *con = new QLabel(tr("Connection"), tabprof ); |
79 | QLabel *term = new QLabel(tr("Terminal"), tabprof ); | 77 | QLabel *term = new QLabel(tr("Terminal"), tabprof ); |
80 | m_conCmb = new QComboBox( tabprof ); | 78 | m_conCmb = new QComboBox( tabprof ); |
81 | m_termCmb = new QComboBox( tabprof ); | 79 | m_termCmb = new QComboBox( tabprof ); |
82 | m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof); | 80 | m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof); |
83 | 81 | ||
84 | // layouting | 82 | // layouting |
85 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); | 83 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); |
86 | vbox3->add(name); | 84 | vbox3->add(name); |
87 | vbox3->add(m_name); | 85 | vbox3->add(m_name); |
88 | vbox3->add(con ); | 86 | vbox3->add(con ); |
89 | vbox3->add(m_conCmb ); | 87 | vbox3->add(m_conCmb ); |
90 | vbox3->add(term ); | 88 | vbox3->add(term ); |
91 | vbox3->add(m_termCmb ); | 89 | vbox3->add(m_termCmb ); |
92 | vbox3->add(m_autoConnect); | 90 | vbox3->add(m_autoConnect); |
93 | vbox3->addStretch(1); | 91 | vbox3->addStretch(1); |
94 | 92 | ||
93 | m_showconntab = 0; | ||
95 | tabWidget->addTab(tabprof, "", QObject::tr("Profile")); | 94 | tabWidget->addTab(tabprof, "", QObject::tr("Profile")); |
96 | tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); | 95 | //tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); |
97 | tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); | 96 | tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); |
98 | tabWidget->setCurrentTab( tabprof ); | 97 | tabWidget->setCurrentTab( tabprof ); |
99 | 98 | ||
100 | 99 | ||
101 | // fill the comboboxes | 100 | // fill the comboboxes |
102 | QStringList list = m_fact->connectionWidgets(); | 101 | QStringList list = m_fact->connectionWidgets(); |
103 | QStringList::Iterator it; | 102 | QStringList::Iterator it; |
104 | for (it =list.begin(); it != list.end(); ++it ) { | 103 | for (it =list.begin(); it != list.end(); ++it ) { |
105 | m_conCmb->insertItem( (*it) ); | 104 | m_conCmb->insertItem( (*it) ); |
106 | } | 105 | } |
107 | list = m_fact->terminalWidgets(); | 106 | list = m_fact->terminalWidgets(); |
108 | for (it =list.begin(); it != list.end(); ++it ) { | 107 | for (it =list.begin(); it != list.end(); ++it ) { |
109 | m_termCmb->insertItem( (*it) ); | 108 | m_termCmb->insertItem( (*it) ); |
110 | } | 109 | } |
111 | 110 | ||
112 | // load profile values | 111 | // load profile values |
113 | m_name->setText(m_prof.name()); | 112 | m_name->setText(m_prof.name()); |
114 | slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); | 113 | slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); |
115 | slotTermActivated( m_fact->external(m_prof.terminalName() ) ); | 114 | slotTermActivated( m_fact->external(m_prof.terminalName() ) ); |
116 | setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); | 115 | setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); |
117 | setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); | 116 | setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); |
118 | m_autoConnect->setChecked(m_prof.autoConnect()); | 117 | m_autoConnect->setChecked(m_prof.autoConnect()); |
119 | 118 | ||
120 | 119 | ||
121 | // signal and slots | 120 | // signal and slots |
122 | connect(m_conCmb, SIGNAL(activated(const QString& ) ), | 121 | connect(m_conCmb, SIGNAL(activated(const QString& ) ), |
123 | this, SLOT(slotConActivated(const QString&) ) ); | 122 | this, SLOT(slotConActivated(const QString&) ) ); |
124 | connect(m_termCmb, SIGNAL(activated(const QString& ) ), | 123 | connect(m_termCmb, SIGNAL(activated(const QString& ) ), |
125 | this, SLOT(slotTermActivated(const QString& ) ) ); | 124 | this, SLOT(slotTermActivated(const QString& ) ) ); |
126 | 125 | ||
127 | } | 126 | } |
128 | 127 | ||
129 | ProfileEditorDialog::~ProfileEditorDialog() { | 128 | ProfileEditorDialog::~ProfileEditorDialog() { |
130 | 129 | ||
131 | } | 130 | } |
132 | void ProfileEditorDialog::accept() | 131 | void ProfileEditorDialog::accept() |
133 | { | 132 | { |
134 | if(profName().isEmpty()) | 133 | if(profName().isEmpty()) |
135 | { | 134 | { |
136 | QMessageBox::information(this, | 135 | QMessageBox::information(this, |
137 | QObject::tr("Invalid profile"), | 136 | QObject::tr("Invalid profile"), |
138 | QObject::tr("Please enter a profile name.")); | 137 | QObject::tr("Please enter a profile name.")); |
139 | return; | 138 | return; |
140 | } | 139 | } |
141 | // Save profile and plugin profile | 140 | // Save profile and plugin profile |
142 | //if(plugin_plugin) plugin_plugin->save(); | 141 | //if(plugin_plugin) plugin_plugin->save(); |
143 | 142 | ||
144 | // Save general values | 143 | // Save general values |
145 | m_prof.setName(profName()); | 144 | m_prof.setName(profName()); |
146 | m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); | 145 | m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); |
147 | m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); | 146 | m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); |
148 | m_prof.setAutoConnect( m_autoConnect->isChecked() ); | 147 | m_prof.setAutoConnect( m_autoConnect->isChecked() ); |
149 | 148 | ||
150 | if (m_con ) | 149 | if (m_con ) |
151 | m_con->save( m_prof ); | 150 | m_con->save( m_prof ); |
152 | if (m_term ) | 151 | if (m_term ) |
153 | m_term->save( m_prof ); | 152 | m_term->save( m_prof ); |
154 | 153 | ||
155 | QDialog::accept(); | 154 | QDialog::accept(); |
156 | } | 155 | } |
157 | 156 | ||
158 | 157 | ||
159 | QString ProfileEditorDialog::profName()const | 158 | QString ProfileEditorDialog::profName()const |
160 | { | 159 | { |
161 | return m_name->text(); | 160 | return m_name->text(); |
162 | } | 161 | } |
163 | 162 | ||
164 | QCString ProfileEditorDialog::profType()const | 163 | QCString ProfileEditorDialog::profType()const |
165 | { | 164 | { |
166 | /*QStringList w = m_fact->configWidgets(); | 165 | /*QStringList w = m_fact->configWidgets(); |
167 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) | 166 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) |
168 | if(device_box->currentText() == m_fact->name((*it))) return (*it); | 167 | if(device_box->currentText() == m_fact->name((*it))) return (*it); |
169 | */ | 168 | */ |
170 | return QCString(); | 169 | return QCString(); |
171 | } | 170 | } |
172 | /* | 171 | /* |
173 | * we need to switch the widget | 172 | * we need to switch the widget |
174 | */ | 173 | */ |
175 | void ProfileEditorDialog::slotConActivated( const QString& str ) { | 174 | void ProfileEditorDialog::slotConActivated( const QString& str ) { |
176 | delete m_con; | 175 | delete m_con; |
177 | m_con = m_fact->newConnectionPlugin( str, m_tabCon ); | 176 | m_con = m_fact->newConnectionPlugin( str, m_tabCon ); |
178 | 177 | ||
179 | if ( m_con ) { | 178 | if ( m_con ) { |
180 | m_con->load( m_prof ); | 179 | m_con->load( m_prof ); |
181 | m_layCon->addWidget( m_con ); | 180 | m_layCon->addWidget( m_con ); |
181 | if(!m_showconntab) | ||
182 | { | ||
183 | tabWidget->addTab( m_tabCon, "", QObject::tr("Connection") ); | ||
184 | tabWidget->setCurrentTab( tabprof ); | ||
185 | m_showconntab = 1; | ||
186 | } | ||
182 | } else { | 187 | } else { |
183 | tabWidget->removePage( m_tabCon ); | 188 | tabWidget->removePage( m_tabCon ); |
189 | m_showconntab = 0; | ||
184 | } | 190 | } |
185 | } | 191 | } |
186 | /* | 192 | /* |
187 | * we need to switch the widget | 193 | * we need to switch the widget |
188 | */ | 194 | */ |
189 | void ProfileEditorDialog::slotTermActivated( const QString& str ) { | 195 | void ProfileEditorDialog::slotTermActivated( const QString& str ) { |
190 | delete m_term; | 196 | delete m_term; |
191 | m_term = m_fact->newTerminalPlugin( str, m_tabTerm ); | 197 | m_term = m_fact->newTerminalPlugin( str, m_tabTerm ); |
192 | 198 | ||
193 | if (m_term) { | 199 | if (m_term) { |
194 | m_term->load(m_prof ); | 200 | m_term->load(m_prof ); |
195 | m_layTerm->addWidget( m_term ); | 201 | m_layTerm->addWidget( m_term ); |
196 | } | 202 | } |
197 | } | 203 | } |
198 | 204 | ||
diff --git a/noncore/apps/opie-console/profileeditordialog.h b/noncore/apps/opie-console/profileeditordialog.h index e01e636..cbda689 100644 --- a/noncore/apps/opie-console/profileeditordialog.h +++ b/noncore/apps/opie-console/profileeditordialog.h | |||
@@ -5,51 +5,53 @@ | |||
5 | #include <opie/otabwidget.h> | 5 | #include <opie/otabwidget.h> |
6 | 6 | ||
7 | #include "profile.h" | 7 | #include "profile.h" |
8 | 8 | ||
9 | class MetaFactory; | 9 | class MetaFactory; |
10 | class EditBase; | 10 | class EditBase; |
11 | class QTabWidget; | 11 | class QTabWidget; |
12 | class QHBoxLayout; | 12 | class QHBoxLayout; |
13 | class QLineEdit; | 13 | class QLineEdit; |
14 | class QComboBox; | 14 | class QComboBox; |
15 | class QCheckBox; | 15 | class QCheckBox; |
16 | class QLabel; | 16 | class QLabel; |
17 | class ProfileDialogWidget; | 17 | class ProfileDialogWidget; |
18 | 18 | ||
19 | class ProfileEditorDialog : public QDialog { | 19 | class ProfileEditorDialog : public QDialog { |
20 | Q_OBJECT | 20 | Q_OBJECT |
21 | public: | 21 | public: |
22 | ProfileEditorDialog(MetaFactory* fact, | 22 | ProfileEditorDialog(MetaFactory* fact, |
23 | const Profile& prof ); | 23 | const Profile& prof ); |
24 | ProfileEditorDialog(MetaFactory* fact ); | 24 | ProfileEditorDialog(MetaFactory* fact ); |
25 | ~ProfileEditorDialog(); | 25 | ~ProfileEditorDialog(); |
26 | Profile profile()const; | 26 | Profile profile()const; |
27 | 27 | ||
28 | 28 | ||
29 | 29 | ||
30 | public slots: | 30 | public slots: |
31 | void accept(); | 31 | void accept(); |
32 | 32 | ||
33 | private slots: | 33 | private slots: |
34 | void slotConActivated(const QString& ); | 34 | void slotConActivated(const QString& ); |
35 | void slotTermActivated( const QString& ); | 35 | void slotTermActivated( const QString& ); |
36 | private: | 36 | private: |
37 | void initUI(); | 37 | void initUI(); |
38 | QString profName()const; | 38 | QString profName()const; |
39 | QCString profType()const; | 39 | QCString profType()const; |
40 | 40 | ||
41 | MetaFactory* m_fact; | 41 | MetaFactory* m_fact; |
42 | QHBoxLayout* m_lay; | 42 | QHBoxLayout* m_lay; |
43 | Profile m_prof; | 43 | Profile m_prof; |
44 | 44 | ||
45 | QLineEdit *m_name; | 45 | QLineEdit *m_name; |
46 | QComboBox *m_conCmb, *m_termCmb; | 46 | QComboBox *m_conCmb, *m_termCmb; |
47 | QCheckBox *m_autoConnect; | 47 | QCheckBox *m_autoConnect; |
48 | 48 | ||
49 | QWidget *m_tabCon, *m_tabTerm; | 49 | QWidget *m_tabCon, *m_tabTerm; |
50 | ProfileDialogWidget* m_con, *m_term; | 50 | ProfileDialogWidget* m_con, *m_term; |
51 | QHBoxLayout *m_layCon, *m_layTerm; | 51 | QHBoxLayout *m_layCon, *m_layTerm; |
52 | OTabWidget *tabWidget; | 52 | OTabWidget *tabWidget; |
53 | QWidget *tabprof; | ||
54 | int m_showconntab; | ||
53 | }; | 55 | }; |
54 | 56 | ||
55 | #endif | 57 | #endif |