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