author | hash <hash> | 2002-10-13 02:20:23 (UTC) |
---|---|---|
committer | hash <hash> | 2002-10-13 02:20:23 (UTC) |
commit | 2ce86d9be1bbf99092348adf815578b110fe7289 (patch) (unidiff) | |
tree | 4c2812b4f4edb1704a379e2f6a4d9b2af1a39c23 | |
parent | 173c272fa2dc860dbb2ff54b6be2680c544340bb (diff) | |
download | opie-2ce86d9be1bbf99092348adf815578b110fe7289.zip opie-2ce86d9be1bbf99092348adf815578b110fe7289.tar.gz opie-2ce86d9be1bbf99092348adf815578b110fe7289.tar.bz2 |
added a couple more buttons to the bar
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 2a4d069..3af0cba 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,204 +1,207 @@ | |||
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> | 7 | #include <qpe/resource.h> |
8 | 8 | ||
9 | 9 | ||
10 | #include "profileeditordialog.h" | 10 | #include "profileeditordialog.h" |
11 | #include "configdialog.h" | 11 | #include "configdialog.h" |
12 | #include "default.h" | 12 | #include "default.h" |
13 | #include "metafactory.h" | 13 | #include "metafactory.h" |
14 | #include "profile.h" | 14 | #include "profile.h" |
15 | #include "profilemanager.h" | 15 | #include "profilemanager.h" |
16 | #include "mainwindow.h" | 16 | #include "mainwindow.h" |
17 | #include "tabwidget.h" | 17 | #include "tabwidget.h" |
18 | #include "transferdialog.h" | 18 | #include "transferdialog.h" |
19 | #include "function_keyboard.h" | 19 | #include "function_keyboard.h" |
20 | 20 | ||
21 | MainWindow::MainWindow() { | 21 | MainWindow::MainWindow() { |
22 | m_factory = new MetaFactory(); | 22 | m_factory = new MetaFactory(); |
23 | Default def(m_factory); | 23 | Default def(m_factory); |
24 | m_sessions.setAutoDelete( TRUE ); | 24 | m_sessions.setAutoDelete( TRUE ); |
25 | m_curSession = 0; | 25 | m_curSession = 0; |
26 | m_manager = new ProfileManager( m_factory ); | 26 | m_manager = new ProfileManager( m_factory ); |
27 | m_manager->load(); | 27 | m_manager->load(); |
28 | 28 | ||
29 | initUI(); | 29 | initUI(); |
30 | populateProfiles(); | 30 | populateProfiles(); |
31 | } | 31 | } |
32 | void MainWindow::initUI() { | 32 | void MainWindow::initUI() { |
33 | setToolBarsMovable( FALSE ); | 33 | setToolBarsMovable( FALSE ); |
34 | 34 | ||
35 | /* tool bar for the menu */ | 35 | /* tool bar for the menu */ |
36 | m_tool = new QToolBar( this ); | 36 | m_tool = new QToolBar( this ); |
37 | m_tool->setHorizontalStretchable( TRUE ); | 37 | m_tool->setHorizontalStretchable( TRUE ); |
38 | 38 | ||
39 | m_bar = new QMenuBar( m_tool ); | 39 | m_bar = new QMenuBar( m_tool ); |
40 | m_console = new QPopupMenu( this ); | 40 | m_console = new QPopupMenu( this ); |
41 | m_sessionsPop= new QPopupMenu( this ); | 41 | m_sessionsPop= new QPopupMenu( this ); |
42 | m_settings = new QPopupMenu( this ); | 42 | m_settings = new QPopupMenu( this ); |
43 | 43 | ||
44 | /* add a toolbar for icons */ | 44 | /* add a toolbar for icons */ |
45 | m_icons = new QToolBar(this); | 45 | m_icons = new QToolBar(this); |
46 | m_icons->setHorizontalStretchable( TRUE ); | ||
47 | 46 | ||
48 | /* | 47 | /* |
49 | * new Action for new sessions | 48 | * new Action for new sessions |
50 | */ | 49 | */ |
51 | QAction* a = new QAction(); | 50 | QAction* a = new QAction(tr("New Connection"), |
52 | a->setText( tr("New Connection") ); | 51 | Resource::loadPixmap( "new" ), |
52 | QString::null, 0, this, 0); | ||
53 | a->addTo( m_console ); | 53 | a->addTo( m_console ); |
54 | a->addTo( m_icons ); | ||
54 | connect(a, SIGNAL(activated() ), | 55 | connect(a, SIGNAL(activated() ), |
55 | this, SLOT(slotNew() ) ); | 56 | this, SLOT(slotNew() ) ); |
56 | 57 | ||
57 | /* | 58 | /* |
58 | * connect action | 59 | * connect action |
59 | */ | 60 | */ |
60 | m_connect = new QAction(); | 61 | m_connect = new QAction(); |
61 | m_connect->setText( tr("Connect") ); | 62 | m_connect->setText( tr("Connect") ); |
62 | m_connect->addTo( m_console ); | 63 | m_connect->addTo( m_console ); |
63 | connect(m_connect, SIGNAL(activated() ), | 64 | connect(m_connect, SIGNAL(activated() ), |
64 | this, SLOT(slotConnect() ) ); | 65 | this, SLOT(slotConnect() ) ); |
65 | 66 | ||
66 | /* | 67 | /* |
67 | * disconnect action | 68 | * disconnect action |
68 | */ | 69 | */ |
69 | m_disconnect = new QAction(); | 70 | m_disconnect = new QAction(); |
70 | m_disconnect->setText( tr("Disconnect") ); | 71 | m_disconnect->setText( tr("Disconnect") ); |
71 | m_disconnect->addTo( m_console ); | 72 | m_disconnect->addTo( m_console ); |
72 | connect(m_disconnect, SIGNAL(activated() ), | 73 | connect(m_disconnect, SIGNAL(activated() ), |
73 | this, SLOT(slotDisconnect() ) ); | 74 | this, SLOT(slotDisconnect() ) ); |
74 | 75 | ||
75 | m_transfer = new QAction(); | 76 | m_transfer = new QAction(); |
76 | m_transfer->setText( tr("Transfer file...") ); | 77 | m_transfer->setText( tr("Transfer file...") ); |
77 | m_transfer->addTo( m_console ); | 78 | m_transfer->addTo( m_console ); |
78 | connect(m_transfer, SIGNAL(activated() ), | 79 | connect(m_transfer, SIGNAL(activated() ), |
79 | this, SLOT(slotTransfer() ) ); | 80 | this, SLOT(slotTransfer() ) ); |
80 | 81 | ||
81 | /* | 82 | /* |
82 | * terminate action | 83 | * terminate action |
83 | */ | 84 | */ |
84 | m_terminate = new QAction(); | 85 | m_terminate = new QAction(); |
85 | m_terminate->setText( tr("Terminate") ); | 86 | m_terminate->setText( tr("Terminate") ); |
86 | m_terminate->addTo( m_console ); | 87 | m_terminate->addTo( m_console ); |
87 | connect(m_terminate, SIGNAL(activated() ), | 88 | connect(m_terminate, SIGNAL(activated() ), |
88 | this, SLOT(slotTerminate() ) ); | 89 | this, SLOT(slotTerminate() ) ); |
89 | 90 | ||
90 | a = new QAction(); | 91 | a = new QAction(); |
91 | a->setText( tr("Close Window") ); | 92 | a->setText( tr("Close Window") ); |
92 | a->addTo( m_console ); | 93 | a->addTo( m_console ); |
93 | connect(a, SIGNAL(activated() ), | 94 | connect(a, SIGNAL(activated() ), |
94 | this, SLOT(slotClose() ) ); | 95 | this, SLOT(slotClose() ) ); |
95 | 96 | ||
96 | /* | 97 | /* |
97 | * the settings action | 98 | * the settings action |
98 | */ | 99 | */ |
99 | m_setProfiles = new QAction(); | 100 | m_setProfiles = new QAction(tr("Configure Profiles"), |
100 | m_setProfiles->setText( tr("Configure Profiles") ); | 101 | Resource::loadPixmap( "SettingsIcon" ), |
102 | QString::null, 0, this, 0); | ||
101 | m_setProfiles->addTo( m_settings ); | 103 | m_setProfiles->addTo( m_settings ); |
104 | m_setProfiles->addTo( m_icons ); | ||
102 | connect( m_setProfiles, SIGNAL(activated() ), | 105 | connect( m_setProfiles, SIGNAL(activated() ), |
103 | this, SLOT(slotConfigure() ) ); | 106 | this, SLOT(slotConfigure() ) ); |
104 | 107 | ||
105 | /* | 108 | /* |
106 | * action that open/closes the keyboard | 109 | * action that open/closes the keyboard |
107 | */ | 110 | */ |
108 | m_openKeys = new QAction ("Keyboard...", | 111 | m_openKeys = new QAction (tr("Open Keyboard..."), |
109 | Resource::loadPixmap( "down" ), | 112 | Resource::loadPixmap( "down" ), |
110 | QString::null, 0, this, 0); | 113 | QString::null, 0, this, 0); |
111 | 114 | ||
112 | m_openKeys->setToggleAction(true); | 115 | m_openKeys->setToggleAction(true); |
113 | 116 | ||
114 | connect (m_openKeys, SIGNAL(toggled(bool)), | 117 | connect (m_openKeys, SIGNAL(toggled(bool)), |
115 | this, SLOT(slotOpenKeb(bool))); | 118 | this, SLOT(slotOpenKeb(bool))); |
116 | m_openKeys->addTo(m_icons); | 119 | m_openKeys->addTo(m_icons); |
117 | 120 | ||
118 | 121 | ||
119 | /* insert the submenu */ | 122 | /* insert the submenu */ |
120 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 123 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
121 | -1, 0); | 124 | -1, 0); |
122 | 125 | ||
123 | /* insert the connection menu */ | 126 | /* insert the connection menu */ |
124 | m_bar->insertItem( tr("Connection"), m_console ); | 127 | m_bar->insertItem( tr("Connection"), m_console ); |
125 | 128 | ||
126 | /* the settings menu */ | 129 | /* the settings menu */ |
127 | m_bar->insertItem( tr("Settings"), m_settings ); | 130 | m_bar->insertItem( tr("Settings"), m_settings ); |
128 | 131 | ||
129 | /* and the keyboard */ | 132 | /* and the keyboard */ |
130 | m_keyBar = new QToolBar(this); | 133 | m_keyBar = new QToolBar(this); |
131 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 134 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
132 | m_keyBar->setHorizontalStretchable( TRUE ); | 135 | m_keyBar->setHorizontalStretchable( TRUE ); |
133 | m_keyBar->hide(); | 136 | m_keyBar->hide(); |
134 | 137 | ||
135 | m_kb = new FunctionKeyboard(m_keyBar); | 138 | m_kb = new FunctionKeyboard(m_keyBar); |
136 | 139 | ||
137 | /* | 140 | /* |
138 | * connect to the menu activation | 141 | * connect to the menu activation |
139 | */ | 142 | */ |
140 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 143 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
141 | this, SLOT(slotProfile( int ) ) ); | 144 | this, SLOT(slotProfile( int ) ) ); |
142 | 145 | ||
143 | m_consoleWindow = new TabWidget( this, "blah"); | 146 | m_consoleWindow = new TabWidget( this, "blah"); |
144 | setCentralWidget( m_consoleWindow ); | 147 | setCentralWidget( m_consoleWindow ); |
145 | 148 | ||
146 | } | 149 | } |
147 | 150 | ||
148 | ProfileManager* MainWindow::manager() { | 151 | ProfileManager* MainWindow::manager() { |
149 | return m_manager; | 152 | return m_manager; |
150 | } | 153 | } |
151 | TabWidget* MainWindow::tabWidget() { | 154 | TabWidget* MainWindow::tabWidget() { |
152 | return m_consoleWindow; | 155 | return m_consoleWindow; |
153 | } | 156 | } |
154 | void MainWindow::populateProfiles() { | 157 | void MainWindow::populateProfiles() { |
155 | m_sessionsPop->clear(); | 158 | m_sessionsPop->clear(); |
156 | Profile::ValueList list = manager()->all(); | 159 | Profile::ValueList list = manager()->all(); |
157 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 160 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
158 | m_sessionsPop->insertItem( (*it).name() ); | 161 | m_sessionsPop->insertItem( (*it).name() ); |
159 | } | 162 | } |
160 | 163 | ||
161 | } | 164 | } |
162 | MainWindow::~MainWindow() { | 165 | MainWindow::~MainWindow() { |
163 | delete m_factory; | 166 | delete m_factory; |
164 | manager()->save(); | 167 | manager()->save(); |
165 | } | 168 | } |
166 | 169 | ||
167 | MetaFactory* MainWindow::factory() { | 170 | MetaFactory* MainWindow::factory() { |
168 | return m_factory; | 171 | return m_factory; |
169 | } | 172 | } |
170 | 173 | ||
171 | Session* MainWindow::currentSession() { | 174 | Session* MainWindow::currentSession() { |
172 | return m_curSession; | 175 | return m_curSession; |
173 | } | 176 | } |
174 | 177 | ||
175 | QList<Session> MainWindow::sessions() { | 178 | QList<Session> MainWindow::sessions() { |
176 | return m_sessions; | 179 | return m_sessions; |
177 | } | 180 | } |
178 | 181 | ||
179 | void MainWindow::slotNew() { | 182 | void MainWindow::slotNew() { |
180 | qWarning("New Connection"); | 183 | qWarning("New Connection"); |
181 | ProfileEditorDialog dlg(factory() ); | 184 | ProfileEditorDialog dlg(factory() ); |
182 | int ret = dlg.exec(); | 185 | int ret = dlg.exec(); |
183 | 186 | ||
184 | if ( ret == QDialog::Accepted ) { | 187 | if ( ret == QDialog::Accepted ) { |
185 | create( dlg.profile() ); | 188 | create( dlg.profile() ); |
186 | } | 189 | } |
187 | } | 190 | } |
188 | 191 | ||
189 | void MainWindow::slotConnect() { | 192 | void MainWindow::slotConnect() { |
190 | if ( currentSession() ) | 193 | if ( currentSession() ) |
191 | currentSession()->layer()->open(); | 194 | currentSession()->layer()->open(); |
192 | } | 195 | } |
193 | 196 | ||
194 | void MainWindow::slotDisconnect() { | 197 | void MainWindow::slotDisconnect() { |
195 | if ( currentSession() ) | 198 | if ( currentSession() ) |
196 | currentSession()->layer()->close(); | 199 | currentSession()->layer()->close(); |
197 | } | 200 | } |
198 | 201 | ||
199 | void MainWindow::slotTerminate() { | 202 | void MainWindow::slotTerminate() { |
200 | if ( currentSession() ) | 203 | if ( currentSession() ) |
201 | currentSession()->layer()->close(); | 204 | currentSession()->layer()->close(); |
202 | 205 | ||
203 | slotClose(); | 206 | slotClose(); |
204 | /* FIXME move to the next session */ | 207 | /* FIXME move to the next session */ |