Diffstat (limited to 'noncore/apps/opie-console/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 3531478..aeb3742 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -5,9 +5,11 @@ | |||
5 | #include <qpopupmenu.h> | 5 | #include <qpopupmenu.h> |
6 | #include <qtoolbar.h> | 6 | #include <qtoolbar.h> |
7 | 7 | ||
8 | #include "profileeditordialog.h" | ||
8 | #include "configdialog.h" | 9 | #include "configdialog.h" |
9 | #include "default.h" | 10 | #include "default.h" |
10 | #include "metafactory.h" | 11 | #include "metafactory.h" |
12 | #include "profile.h" | ||
11 | #include "profilemanager.h" | 13 | #include "profilemanager.h" |
12 | #include "mainwindow.h" | 14 | #include "mainwindow.h" |
13 | #include "tabwidget.h" | 15 | #include "tabwidget.h" |
@@ -109,7 +111,9 @@ void MainWindow::initUI() { | |||
109 | ProfileManager* MainWindow::manager() { | 111 | ProfileManager* MainWindow::manager() { |
110 | return m_manager; | 112 | return m_manager; |
111 | } | 113 | } |
112 | 114 | TabWidget* MainWindow::tabWidget() { | |
115 | return m_consoleWindow; | ||
116 | } | ||
113 | void MainWindow::populateProfiles() { | 117 | void MainWindow::populateProfiles() { |
114 | m_sessionsPop->clear(); | 118 | m_sessionsPop->clear(); |
115 | Profile::ValueList list = manager()->all(); | 119 | Profile::ValueList list = manager()->all(); |
@@ -137,6 +141,12 @@ QList<Session> MainWindow::sessions() { | |||
137 | 141 | ||
138 | void MainWindow::slotNew() { | 142 | void MainWindow::slotNew() { |
139 | qWarning("New Connection"); | 143 | qWarning("New Connection"); |
144 | ProfileEditorDialog dlg(factory() ); | ||
145 | int ret = dlg.exec(); | ||
146 | |||
147 | if ( ret == QDialog::Accepted ) { | ||
148 | create( dlg.profile() ); | ||
149 | } | ||
140 | } | 150 | } |
141 | 151 | ||
142 | void MainWindow::slotConnect() { | 152 | void MainWindow::slotConnect() { |
@@ -152,8 +162,8 @@ void MainWindow::slotDisconnect() { | |||
152 | void MainWindow::slotTerminate() { | 162 | void MainWindow::slotTerminate() { |
153 | if ( currentSession() ) | 163 | if ( currentSession() ) |
154 | currentSession()->layer()->close(); | 164 | currentSession()->layer()->close(); |
155 | delete m_curSession; | 165 | |
156 | m_curSession = 0l; | 166 | slotClose(); |
157 | /* FIXME move to the next session */ | 167 | /* FIXME move to the next session */ |
158 | } | 168 | } |
159 | 169 | ||
@@ -170,11 +180,37 @@ void MainWindow::slotConfigure() { | |||
170 | populateProfiles(); | 180 | populateProfiles(); |
171 | } | 181 | } |
172 | } | 182 | } |
173 | 183 | /* | |
184 | * we will remove | ||
185 | * this window from the tabwidget | ||
186 | * remove it from the list | ||
187 | * delete it | ||
188 | * and set the currentSession() | ||
189 | */ | ||
174 | void MainWindow::slotClose() { | 190 | void MainWindow::slotClose() { |
175 | } | 191 | if (!currentSession() ) |
192 | return; | ||
176 | 193 | ||
177 | void MainWindow::slotProfile( int ) { | 194 | tabWidget()->remove( currentSession() ); |
195 | tabWidget()->setCurrent( m_sessions.first() ); | ||
196 | m_sessions.remove( m_curSession ); | ||
197 | delete m_curSession; | ||
198 | m_curSession = m_sessions.first(); | ||
199 | } | ||
178 | 200 | ||
201 | /* | ||
202 | * We will get the name | ||
203 | * Then the profile | ||
204 | * and then we will make a profile | ||
205 | */ | ||
206 | void MainWindow::slotProfile( int id) { | ||
207 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | ||
208 | create( prof ); | ||
209 | } | ||
210 | void MainWindow::create( const Profile& prof ) { | ||
211 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | ||
179 | 212 | ||
213 | m_sessions.append( ses ); | ||
214 | tabWidget()->add( ses ); | ||
215 | m_curSession = ses; | ||
180 | } | 216 | } |