-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 37 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 7 |
2 files changed, 44 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 88727e4..2a4d069 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,170 +1,200 @@ | |||
1 | 1 | ||
2 | #include <qaction.h> | 2 | #include <qaction.h> |
3 | #include <qmenubar.h> | 3 | #include <qmenubar.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | #include <qpopupmenu.h> | 5 | #include <qpopupmenu.h> |
6 | #include <qtoolbar.h> | 6 | #include <qtoolbar.h> |
7 | #include <qpe/resource.h> | ||
8 | |||
7 | 9 | ||
8 | #include "profileeditordialog.h" | 10 | #include "profileeditordialog.h" |
9 | #include "configdialog.h" | 11 | #include "configdialog.h" |
10 | #include "default.h" | 12 | #include "default.h" |
11 | #include "metafactory.h" | 13 | #include "metafactory.h" |
12 | #include "profile.h" | 14 | #include "profile.h" |
13 | #include "profilemanager.h" | 15 | #include "profilemanager.h" |
14 | #include "mainwindow.h" | 16 | #include "mainwindow.h" |
15 | #include "tabwidget.h" | 17 | #include "tabwidget.h" |
16 | #include "transferdialog.h" | 18 | #include "transferdialog.h" |
19 | #include "function_keyboard.h" | ||
17 | 20 | ||
18 | MainWindow::MainWindow() { | 21 | MainWindow::MainWindow() { |
19 | m_factory = new MetaFactory(); | 22 | m_factory = new MetaFactory(); |
20 | Default def(m_factory); | 23 | Default def(m_factory); |
21 | m_sessions.setAutoDelete( TRUE ); | 24 | m_sessions.setAutoDelete( TRUE ); |
22 | m_curSession = 0; | 25 | m_curSession = 0; |
23 | m_manager = new ProfileManager( m_factory ); | 26 | m_manager = new ProfileManager( m_factory ); |
24 | m_manager->load(); | 27 | m_manager->load(); |
25 | 28 | ||
26 | initUI(); | 29 | initUI(); |
27 | populateProfiles(); | 30 | populateProfiles(); |
28 | } | 31 | } |
29 | void MainWindow::initUI() { | 32 | void MainWindow::initUI() { |
30 | setToolBarsMovable( FALSE ); | 33 | setToolBarsMovable( FALSE ); |
31 | 34 | ||
35 | /* tool bar for the menu */ | ||
32 | m_tool = new QToolBar( this ); | 36 | m_tool = new QToolBar( this ); |
33 | m_tool->setHorizontalStretchable( TRUE ); | 37 | m_tool->setHorizontalStretchable( TRUE ); |
34 | 38 | ||
35 | m_bar = new QMenuBar( m_tool ); | 39 | m_bar = new QMenuBar( m_tool ); |
36 | m_console = new QPopupMenu( this ); | 40 | m_console = new QPopupMenu( this ); |
37 | m_sessionsPop= new QPopupMenu( this ); | 41 | m_sessionsPop= new QPopupMenu( this ); |
38 | m_settings = new QPopupMenu( this ); | 42 | m_settings = new QPopupMenu( this ); |
39 | 43 | ||
44 | /* add a toolbar for icons */ | ||
45 | m_icons = new QToolBar(this); | ||
46 | m_icons->setHorizontalStretchable( TRUE ); | ||
47 | |||
40 | /* | 48 | /* |
41 | * new Action for new sessions | 49 | * new Action for new sessions |
42 | */ | 50 | */ |
43 | QAction* a = new QAction(); | 51 | QAction* a = new QAction(); |
44 | a->setText( tr("New Connection") ); | 52 | a->setText( tr("New Connection") ); |
45 | a->addTo( m_console ); | 53 | a->addTo( m_console ); |
46 | connect(a, SIGNAL(activated() ), | 54 | connect(a, SIGNAL(activated() ), |
47 | this, SLOT(slotNew() ) ); | 55 | this, SLOT(slotNew() ) ); |
48 | 56 | ||
49 | /* | 57 | /* |
50 | * connect action | 58 | * connect action |
51 | */ | 59 | */ |
52 | m_connect = new QAction(); | 60 | m_connect = new QAction(); |
53 | m_connect->setText( tr("Connect") ); | 61 | m_connect->setText( tr("Connect") ); |
54 | m_connect->addTo( m_console ); | 62 | m_connect->addTo( m_console ); |
55 | connect(m_connect, SIGNAL(activated() ), | 63 | connect(m_connect, SIGNAL(activated() ), |
56 | this, SLOT(slotConnect() ) ); | 64 | this, SLOT(slotConnect() ) ); |
57 | 65 | ||
58 | /* | 66 | /* |
59 | * disconnect action | 67 | * disconnect action |
60 | */ | 68 | */ |
61 | m_disconnect = new QAction(); | 69 | m_disconnect = new QAction(); |
62 | m_disconnect->setText( tr("Disconnect") ); | 70 | m_disconnect->setText( tr("Disconnect") ); |
63 | m_disconnect->addTo( m_console ); | 71 | m_disconnect->addTo( m_console ); |
64 | connect(m_disconnect, SIGNAL(activated() ), | 72 | connect(m_disconnect, SIGNAL(activated() ), |
65 | this, SLOT(slotDisconnect() ) ); | 73 | this, SLOT(slotDisconnect() ) ); |
66 | 74 | ||
67 | m_transfer = new QAction(); | 75 | m_transfer = new QAction(); |
68 | m_transfer->setText( tr("Transfer file...") ); | 76 | m_transfer->setText( tr("Transfer file...") ); |
69 | m_transfer->addTo( m_console ); | 77 | m_transfer->addTo( m_console ); |
70 | connect(m_transfer, SIGNAL(activated() ), | 78 | connect(m_transfer, SIGNAL(activated() ), |
71 | this, SLOT(slotTransfer() ) ); | 79 | this, SLOT(slotTransfer() ) ); |
72 | 80 | ||
73 | /* | 81 | /* |
74 | * terminate action | 82 | * terminate action |
75 | */ | 83 | */ |
76 | m_terminate = new QAction(); | 84 | m_terminate = new QAction(); |
77 | m_terminate->setText( tr("Terminate") ); | 85 | m_terminate->setText( tr("Terminate") ); |
78 | m_terminate->addTo( m_console ); | 86 | m_terminate->addTo( m_console ); |
79 | connect(m_terminate, SIGNAL(activated() ), | 87 | connect(m_terminate, SIGNAL(activated() ), |
80 | this, SLOT(slotTerminate() ) ); | 88 | this, SLOT(slotTerminate() ) ); |
81 | 89 | ||
82 | a = new QAction(); | 90 | a = new QAction(); |
83 | a->setText( tr("Close Window") ); | 91 | a->setText( tr("Close Window") ); |
84 | a->addTo( m_console ); | 92 | a->addTo( m_console ); |
85 | connect(a, SIGNAL(activated() ), | 93 | connect(a, SIGNAL(activated() ), |
86 | this, SLOT(slotClose() ) ); | 94 | this, SLOT(slotClose() ) ); |
87 | 95 | ||
88 | /* | 96 | /* |
89 | * the settings action | 97 | * the settings action |
90 | */ | 98 | */ |
91 | m_setProfiles = new QAction(); | 99 | m_setProfiles = new QAction(); |
92 | m_setProfiles->setText( tr("Configure Profiles") ); | 100 | m_setProfiles->setText( tr("Configure Profiles") ); |
93 | m_setProfiles->addTo( m_settings ); | 101 | m_setProfiles->addTo( m_settings ); |
94 | connect( m_setProfiles, SIGNAL(activated() ), | 102 | connect( m_setProfiles, SIGNAL(activated() ), |
95 | this, SLOT(slotConfigure() ) ); | 103 | this, SLOT(slotConfigure() ) ); |
96 | 104 | ||
105 | /* | ||
106 | * action that open/closes the keyboard | ||
107 | */ | ||
108 | m_openKeys = new QAction ("Keyboard...", | ||
109 | Resource::loadPixmap( "down" ), | ||
110 | QString::null, 0, this, 0); | ||
111 | |||
112 | m_openKeys->setToggleAction(true); | ||
113 | |||
114 | connect (m_openKeys, SIGNAL(toggled(bool)), | ||
115 | this, SLOT(slotOpenKeb(bool))); | ||
116 | m_openKeys->addTo(m_icons); | ||
117 | |||
118 | |||
97 | /* insert the submenu */ | 119 | /* insert the submenu */ |
98 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 120 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
99 | -1, 0); | 121 | -1, 0); |
100 | 122 | ||
101 | /* insert the connection menu */ | 123 | /* insert the connection menu */ |
102 | m_bar->insertItem( tr("Connection"), m_console ); | 124 | m_bar->insertItem( tr("Connection"), m_console ); |
103 | 125 | ||
104 | /* the settings menu */ | 126 | /* the settings menu */ |
105 | m_bar->insertItem( tr("Settings"), m_settings ); | 127 | m_bar->insertItem( tr("Settings"), m_settings ); |
106 | 128 | ||
129 | /* and the keyboard */ | ||
130 | m_keyBar = new QToolBar(this); | ||
131 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | ||
132 | m_keyBar->setHorizontalStretchable( TRUE ); | ||
133 | m_keyBar->hide(); | ||
134 | |||
135 | m_kb = new FunctionKeyboard(m_keyBar); | ||
136 | |||
107 | /* | 137 | /* |
108 | * connect to the menu activation | 138 | * connect to the menu activation |
109 | */ | 139 | */ |
110 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 140 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
111 | this, SLOT(slotProfile( int ) ) ); | 141 | this, SLOT(slotProfile( int ) ) ); |
112 | 142 | ||
113 | m_consoleWindow = new TabWidget( this, "blah"); | 143 | m_consoleWindow = new TabWidget( this, "blah"); |
114 | setCentralWidget( m_consoleWindow ); | 144 | setCentralWidget( m_consoleWindow ); |
115 | 145 | ||
116 | } | 146 | } |
117 | 147 | ||
118 | ProfileManager* MainWindow::manager() { | 148 | ProfileManager* MainWindow::manager() { |
119 | return m_manager; | 149 | return m_manager; |
120 | } | 150 | } |
121 | TabWidget* MainWindow::tabWidget() { | 151 | TabWidget* MainWindow::tabWidget() { |
122 | return m_consoleWindow; | 152 | return m_consoleWindow; |
123 | } | 153 | } |
124 | void MainWindow::populateProfiles() { | 154 | void MainWindow::populateProfiles() { |
125 | m_sessionsPop->clear(); | 155 | m_sessionsPop->clear(); |
126 | Profile::ValueList list = manager()->all(); | 156 | Profile::ValueList list = manager()->all(); |
127 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 157 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
128 | m_sessionsPop->insertItem( (*it).name() ); | 158 | m_sessionsPop->insertItem( (*it).name() ); |
129 | } | 159 | } |
130 | 160 | ||
131 | } | 161 | } |
132 | MainWindow::~MainWindow() { | 162 | MainWindow::~MainWindow() { |
133 | delete m_factory; | 163 | delete m_factory; |
134 | manager()->save(); | 164 | manager()->save(); |
135 | } | 165 | } |
136 | 166 | ||
137 | MetaFactory* MainWindow::factory() { | 167 | MetaFactory* MainWindow::factory() { |
138 | return m_factory; | 168 | return m_factory; |
139 | } | 169 | } |
140 | 170 | ||
141 | Session* MainWindow::currentSession() { | 171 | Session* MainWindow::currentSession() { |
142 | return m_curSession; | 172 | return m_curSession; |
143 | } | 173 | } |
144 | 174 | ||
145 | QList<Session> MainWindow::sessions() { | 175 | QList<Session> MainWindow::sessions() { |
146 | return m_sessions; | 176 | return m_sessions; |
147 | } | 177 | } |
148 | 178 | ||
149 | void MainWindow::slotNew() { | 179 | void MainWindow::slotNew() { |
150 | qWarning("New Connection"); | 180 | qWarning("New Connection"); |
151 | ProfileEditorDialog dlg(factory() ); | 181 | ProfileEditorDialog dlg(factory() ); |
152 | int ret = dlg.exec(); | 182 | int ret = dlg.exec(); |
153 | 183 | ||
154 | if ( ret == QDialog::Accepted ) { | 184 | if ( ret == QDialog::Accepted ) { |
155 | create( dlg.profile() ); | 185 | create( dlg.profile() ); |
156 | } | 186 | } |
157 | } | 187 | } |
158 | 188 | ||
159 | void MainWindow::slotConnect() { | 189 | void MainWindow::slotConnect() { |
160 | if ( currentSession() ) | 190 | if ( currentSession() ) |
161 | currentSession()->layer()->open(); | 191 | currentSession()->layer()->open(); |
162 | } | 192 | } |
163 | 193 | ||
164 | void MainWindow::slotDisconnect() { | 194 | void MainWindow::slotDisconnect() { |
165 | if ( currentSession() ) | 195 | if ( currentSession() ) |
166 | currentSession()->layer()->close(); | 196 | currentSession()->layer()->close(); |
167 | } | 197 | } |
168 | 198 | ||
169 | void MainWindow::slotTerminate() { | 199 | void MainWindow::slotTerminate() { |
170 | if ( currentSession() ) | 200 | if ( currentSession() ) |
@@ -172,64 +202,71 @@ void MainWindow::slotTerminate() { | |||
172 | 202 | ||
173 | slotClose(); | 203 | slotClose(); |
174 | /* FIXME move to the next session */ | 204 | /* FIXME move to the next session */ |
175 | } | 205 | } |
176 | 206 | ||
177 | void MainWindow::slotConfigure() { | 207 | void MainWindow::slotConfigure() { |
178 | qWarning("configure"); | 208 | qWarning("configure"); |
179 | ConfigDialog conf( manager()->all(), factory() ); | 209 | ConfigDialog conf( manager()->all(), factory() ); |
180 | conf.showMaximized(); | 210 | conf.showMaximized(); |
181 | 211 | ||
182 | int ret = conf.exec(); | 212 | int ret = conf.exec(); |
183 | 213 | ||
184 | if ( QDialog::Accepted == ret ) { | 214 | if ( QDialog::Accepted == ret ) { |
185 | qWarning("conf %d", conf.list().count() ); | 215 | qWarning("conf %d", conf.list().count() ); |
186 | manager()->setProfiles( conf.list() ); | 216 | manager()->setProfiles( conf.list() ); |
187 | populateProfiles(); | 217 | populateProfiles(); |
188 | } | 218 | } |
189 | } | 219 | } |
190 | /* | 220 | /* |
191 | * we will remove | 221 | * we will remove |
192 | * this window from the tabwidget | 222 | * this window from the tabwidget |
193 | * remove it from the list | 223 | * remove it from the list |
194 | * delete it | 224 | * delete it |
195 | * and set the currentSession() | 225 | * and set the currentSession() |
196 | */ | 226 | */ |
197 | void MainWindow::slotClose() { | 227 | void MainWindow::slotClose() { |
198 | qWarning("close"); | 228 | qWarning("close"); |
199 | if (!currentSession() ) | 229 | if (!currentSession() ) |
200 | return; | 230 | return; |
201 | 231 | ||
202 | tabWidget()->remove( currentSession() ); | 232 | tabWidget()->remove( currentSession() ); |
203 | /*it's autodelete */ | 233 | /*it's autodelete */ |
204 | m_sessions.remove( m_curSession ); | 234 | m_sessions.remove( m_curSession ); |
205 | m_curSession = m_sessions.first(); | 235 | m_curSession = m_sessions.first(); |
206 | tabWidget()->setCurrent( m_curSession ); | 236 | tabWidget()->setCurrent( m_curSession ); |
207 | } | 237 | } |
208 | 238 | ||
209 | /* | 239 | /* |
210 | * We will get the name | 240 | * We will get the name |
211 | * Then the profile | 241 | * Then the profile |
212 | * and then we will make a profile | 242 | * and then we will make a profile |
213 | */ | 243 | */ |
214 | void MainWindow::slotProfile( int id) { | 244 | void MainWindow::slotProfile( int id) { |
215 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 245 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
216 | create( prof ); | 246 | create( prof ); |
217 | } | 247 | } |
218 | void MainWindow::create( const Profile& prof ) { | 248 | void MainWindow::create( const Profile& prof ) { |
219 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 249 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
220 | 250 | ||
221 | m_sessions.append( ses ); | 251 | m_sessions.append( ses ); |
222 | tabWidget()->add( ses ); | 252 | tabWidget()->add( ses ); |
223 | m_curSession = ses; | 253 | m_curSession = ses; |
224 | 254 | ||
225 | } | 255 | } |
226 | 256 | ||
227 | void MainWindow::slotTransfer() | 257 | void MainWindow::slotTransfer() |
228 | { | 258 | { |
229 | if ( currentSession() ) { | 259 | if ( currentSession() ) { |
230 | TransferDialog dlg(this); | 260 | TransferDialog dlg(this); |
231 | dlg.showMaximized(); | 261 | dlg.showMaximized(); |
232 | dlg.exec(); | 262 | dlg.exec(); |
233 | } | 263 | } |
234 | } | 264 | } |
235 | 265 | ||
266 | |||
267 | void MainWindow::slotOpenKeb(bool state) { | ||
268 | |||
269 | if (state) m_keyBar->show(); | ||
270 | else m_keyBar->hide(); | ||
271 | |||
272 | } | ||
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index c8b0b65..73bb285 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h | |||
@@ -1,95 +1,102 @@ | |||
1 | #ifndef OPIE_MAIN_WINDOW_H | 1 | #ifndef OPIE_MAIN_WINDOW_H |
2 | #define OPIE_MAIN_WINDOW_H | 2 | #define OPIE_MAIN_WINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | 6 | ||
7 | #include "session.h" | 7 | #include "session.h" |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * this is the MainWindow of the new opie console | 10 | * this is the MainWindow of the new opie console |
11 | * it's also the dispatcher between the different | 11 | * it's also the dispatcher between the different |
12 | * actions supported by the gui | 12 | * actions supported by the gui |
13 | */ | 13 | */ |
14 | class QToolBar; | 14 | class QToolBar; |
15 | class QToolButton; | ||
15 | class QMenuBar; | 16 | class QMenuBar; |
16 | class QAction; | 17 | class QAction; |
17 | class MetaFactory; | 18 | class MetaFactory; |
18 | class TabWidget; | 19 | class TabWidget; |
19 | class ProfileManager; | 20 | class ProfileManager; |
20 | class Profile; | 21 | class Profile; |
22 | class FunctionKeyboard; | ||
21 | class MainWindow : public QMainWindow { | 23 | class MainWindow : public QMainWindow { |
22 | Q_OBJECT | 24 | Q_OBJECT |
23 | public: | 25 | public: |
24 | MainWindow(); | 26 | MainWindow(); |
25 | ~MainWindow(); | 27 | ~MainWindow(); |
26 | 28 | ||
27 | /** | 29 | /** |
28 | * our factory to generate IOLayer and so on | 30 | * our factory to generate IOLayer and so on |
29 | * | 31 | * |
30 | */ | 32 | */ |
31 | MetaFactory* factory(); | 33 | MetaFactory* factory(); |
32 | 34 | ||
33 | /** | 35 | /** |
34 | * A session contains a QWidget*, | 36 | * A session contains a QWidget*, |
35 | * an IOLayer* and some infos for us | 37 | * an IOLayer* and some infos for us |
36 | */ | 38 | */ |
37 | Session* currentSession(); | 39 | Session* currentSession(); |
38 | 40 | ||
39 | /** | 41 | /** |
40 | * the session list | 42 | * the session list |
41 | */ | 43 | */ |
42 | QList<Session> sessions(); | 44 | QList<Session> sessions(); |
43 | 45 | ||
44 | /** | 46 | /** |
45 | * | 47 | * |
46 | */ | 48 | */ |
47 | ProfileManager* manager(); | 49 | ProfileManager* manager(); |
48 | TabWidget* tabWidget(); | 50 | TabWidget* tabWidget(); |
49 | 51 | ||
50 | private slots: | 52 | private slots: |
51 | void slotNew(); | 53 | void slotNew(); |
52 | void slotConnect(); | 54 | void slotConnect(); |
53 | void slotDisconnect(); | 55 | void slotDisconnect(); |
54 | void slotTerminate(); | 56 | void slotTerminate(); |
55 | void slotConfigure(); | 57 | void slotConfigure(); |
56 | void slotClose(); | 58 | void slotClose(); |
57 | void slotProfile(int); | 59 | void slotProfile(int); |
58 | void slotTransfer(); | 60 | void slotTransfer(); |
61 | void slotOpenKeb(bool); | ||
59 | 62 | ||
60 | private: | 63 | private: |
61 | void initUI(); | 64 | void initUI(); |
62 | void populateProfiles(); | 65 | void populateProfiles(); |
63 | void create( const Profile& ); | 66 | void create( const Profile& ); |
64 | /** | 67 | /** |
65 | * the current session | 68 | * the current session |
66 | */ | 69 | */ |
67 | Session* m_curSession; | 70 | Session* m_curSession; |
68 | 71 | ||
69 | /** | 72 | /** |
70 | * the session list | 73 | * the session list |
71 | */ | 74 | */ |
72 | QList<Session> m_sessions; | 75 | QList<Session> m_sessions; |
73 | 76 | ||
74 | /** | 77 | /** |
75 | * the metafactory | 78 | * the metafactory |
76 | */ | 79 | */ |
77 | MetaFactory* m_factory; | 80 | MetaFactory* m_factory; |
78 | ProfileManager* m_manager; | 81 | ProfileManager* m_manager; |
79 | 82 | ||
80 | TabWidget* m_consoleWindow; | 83 | TabWidget* m_consoleWindow; |
81 | QToolBar* m_tool; | 84 | QToolBar* m_tool; |
85 | QToolBar* m_icons; | ||
86 | QToolBar* m_keyBar; | ||
82 | QMenuBar* m_bar; | 87 | QMenuBar* m_bar; |
83 | QPopupMenu* m_console; | 88 | QPopupMenu* m_console; |
84 | QPopupMenu* m_settings; | 89 | QPopupMenu* m_settings; |
85 | QPopupMenu* m_sessionsPop; | 90 | QPopupMenu* m_sessionsPop; |
86 | QAction* m_connect; | 91 | QAction* m_connect; |
87 | QAction* m_disconnect; | 92 | QAction* m_disconnect; |
88 | QAction* m_terminate; | 93 | QAction* m_terminate; |
89 | QAction* m_transfer; | 94 | QAction* m_transfer; |
90 | QAction* m_setProfiles; | 95 | QAction* m_setProfiles; |
96 | QAction* m_openKeys; | ||
91 | 97 | ||
98 | FunctionKeyboard *m_kb; | ||
92 | }; | 99 | }; |
93 | 100 | ||
94 | 101 | ||
95 | #endif | 102 | #endif |