summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-03-03 23:54:03 (UTC)
committer mickeyl <mickeyl>2003-03-03 23:54:03 (UTC)
commit8173569e94a72051d80b8441e70fa1d99f79ef3e (patch) (unidiff)
tree725b67bbee90a0deebb5177f58329cf23ee21baf
parent3688aa2cd692e3226f67a599daea99e35a36036f (diff)
downloadopie-8173569e94a72051d80b8441e70fa1d99f79ef3e.zip
opie-8173569e94a72051d80b8441e70fa1d99f79ef3e.tar.gz
opie-8173569e94a72051d80b8441e70fa1d99f79ef3e.tar.bz2
add exit to file menu (not that someone would want to exit this fine app... :-D
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp
index 9065351..1185f84 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.cpp
+++ b/noncore/net/wellenreiter/gui/mainwindow.cpp
@@ -1,245 +1,247 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "configwindow.h" 16#include "configwindow.h"
17#include "logwindow.h" 17#include "logwindow.h"
18#include "mainwindow.h" 18#include "mainwindow.h"
19#include "wellenreiter.h" 19#include "wellenreiter.h"
20 20
21#include "scanlist.h" 21#include "scanlist.h"
22 22
23#include <qcombobox.h> 23#include <qcombobox.h>
24#include <qdatastream.h> 24#include <qdatastream.h>
25#include <qfile.h> 25#include <qfile.h>
26#include <qfileinfo.h> 26#include <qfileinfo.h>
27#include <qiconset.h> 27#include <qiconset.h>
28#include <qmenubar.h> 28#include <qmenubar.h>
29#include <qmessagebox.h> 29#include <qmessagebox.h>
30#include <qpopupmenu.h> 30#include <qpopupmenu.h>
31#include <qstatusbar.h> 31#include <qstatusbar.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qtoolbutton.h> 33#include <qtoolbutton.h>
34 34
35#ifdef QWS 35#ifdef QWS
36#include <qpe/resource.h> 36#include <qpe/resource.h>
37#include <opie/ofiledialog.h> 37#include <opie/ofiledialog.h>
38#else 38#else
39#include "resource.h" 39#include "resource.h"
40#include <qfiledialog.h> 40#include <qfiledialog.h>
41#endif 41#endif
42 42
43WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) 43WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f )
44 :QMainWindow( parent, name, f ) 44 :QMainWindow( parent, name, f )
45{ 45{
46 cw = new WellenreiterConfigWindow( this ); 46 cw = new WellenreiterConfigWindow( this );
47 mw = new Wellenreiter( this ); 47 mw = new Wellenreiter( this );
48 mw->setConfigWindow( cw ); 48 mw->setConfigWindow( cw );
49 setCentralWidget( mw ); 49 setCentralWidget( mw );
50 50
51 // setup application icon 51 // setup application icon
52 52
53 #ifndef QWS 53 #ifndef QWS
54 setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); 54 setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) );
55 setIconText( "Wellenreiter/X11" ); 55 setIconText( "Wellenreiter/X11" );
56 #endif 56 #endif
57 57
58 // setup icon sets 58 // setup icon sets
59 59
60 infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) ); 60 infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) );
61 settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) ); 61 settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) );
62 #ifdef QWS 62 #ifdef QWS
63 searchIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); 63 searchIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) );
64 cancelIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); 64 cancelIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) );
65 #else 65 #else
66 startStopIconSet = new QIconSet(); 66 startStopIconSet = new QIconSet();
67 startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/SearchIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::Off ); 67 startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/SearchIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::Off );
68 startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/CancelIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::On ); 68 startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/CancelIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::On );
69 #endif 69 #endif
70 70
71 // setup tool buttons 71 // setup tool buttons
72 72
73 startStopButton = new QToolButton( 0 ); 73 startStopButton = new QToolButton( 0 );
74 #ifdef QWS 74 #ifdef QWS
75 startStopButton->setAutoRaise( true ); 75 startStopButton->setAutoRaise( true );
76 #endif 76 #endif
77 #ifdef QWS 77 #ifdef QWS
78 startStopButton->setOnIconSet( *cancelIconSet ); 78 startStopButton->setOnIconSet( *cancelIconSet );
79 startStopButton->setOffIconSet( *searchIconSet ); 79 startStopButton->setOffIconSet( *searchIconSet );
80 #else 80 #else
81 startStopButton->setIconSet( *startStopIconSet ); 81 startStopButton->setIconSet( *startStopIconSet );
82 #endif 82 #endif
83 startStopButton->setToggleButton( true ); 83 startStopButton->setToggleButton( true );
84 connect( startStopButton, SIGNAL( clicked() ), mw, SLOT( startStopClicked() ) ); 84 connect( startStopButton, SIGNAL( clicked() ), mw, SLOT( startStopClicked() ) );
85 startStopButton->setEnabled( false ); 85 startStopButton->setEnabled( false );
86 86
87 QToolButton* c = new QToolButton( 0 ); 87 QToolButton* c = new QToolButton( 0 );
88 #ifdef QWS 88 #ifdef QWS
89 c->setAutoRaise( true ); 89 c->setAutoRaise( true );
90 #endif 90 #endif
91 c->setIconSet( *infoIconSet ); 91 c->setIconSet( *infoIconSet );
92 c->setEnabled( false ); 92 c->setEnabled( false );
93 93
94 QToolButton* d = new QToolButton( 0 ); 94 QToolButton* d = new QToolButton( 0 );
95 #ifdef QWS 95 #ifdef QWS
96 d->setAutoRaise( true ); 96 d->setAutoRaise( true );
97 #endif 97 #endif
98 d->setIconSet( *settingsIconSet ); 98 d->setIconSet( *settingsIconSet );
99 connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); 99 connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) );
100 100
101 // setup menu bar 101 // setup menu bar
102 102
103 int id; 103 int id;
104 104
105 QMenuBar* mb = menuBar(); 105 QMenuBar* mb = menuBar();
106 106
107 QPopupMenu* fileSave = new QPopupMenu( mb ); 107 QPopupMenu* fileSave = new QPopupMenu( mb );
108 fileSave->insertItem( "&Session...", this, SLOT( fileSaveSession() ) ); 108 fileSave->insertItem( "&Session...", this, SLOT( fileSaveSession() ) );
109 fileSave->insertItem( "&Log...", this, SLOT( fileSaveLog() ) ); 109 fileSave->insertItem( "&Log...", this, SLOT( fileSaveLog() ) );
110 110
111 QPopupMenu* fileLoad = new QPopupMenu( mb ); 111 QPopupMenu* fileLoad = new QPopupMenu( mb );
112 fileLoad->insertItem( "&Session...", this, SLOT( fileLoadSession() ) ); 112 fileLoad->insertItem( "&Session...", this, SLOT( fileLoadSession() ) );
113 //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); 113 //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) );
114 114
115 QPopupMenu* file = new QPopupMenu( mb ); 115 QPopupMenu* file = new QPopupMenu( mb );
116 id = file->insertItem( "&Load", fileLoad ); 116 id = file->insertItem( "&Load", fileLoad );
117 file->insertItem( "&Save", fileSave ); 117 file->insertItem( "&Save", fileSave );
118 file->insertSeparator();
119 file->insertItem( "&Exit", qApp, SLOT( quit() ) );
118 120
119 QPopupMenu* view = new QPopupMenu( mb ); 121 QPopupMenu* view = new QPopupMenu( mb );
120 view->insertItem( "&Configure..." ); 122 view->insertItem( "&Configure..." );
121 123
122 QPopupMenu* sniffer = new QPopupMenu( mb ); 124 QPopupMenu* sniffer = new QPopupMenu( mb );
123 sniffer->insertItem( "&Configure..." ); 125 sniffer->insertItem( "&Configure..." );
124 sniffer->insertSeparator(); 126 sniffer->insertSeparator();
125 127
126 QPopupMenu* demo = new QPopupMenu( mb ); 128 QPopupMenu* demo = new QPopupMenu( mb );
127 demo->insertItem( "&Add something", this, SLOT( demoAddStations() ) ); 129 demo->insertItem( "&Add something", this, SLOT( demoAddStations() ) );
128 130
129 id = mb->insertItem( "&File", file ); 131 id = mb->insertItem( "&File", file );
130 id = mb->insertItem( "&View", view ); 132 id = mb->insertItem( "&View", view );
131 mb->setItemEnabled( id, false ); 133 mb->setItemEnabled( id, false );
132 id = mb->insertItem( "&Sniffer", sniffer ); 134 id = mb->insertItem( "&Sniffer", sniffer );
133 mb->setItemEnabled( id, false ); 135 mb->setItemEnabled( id, false );
134 id = mb->insertItem( "&Demo", demo ); 136 id = mb->insertItem( "&Demo", demo );
135 mb->setItemEnabled( id, true ); 137 mb->setItemEnabled( id, true );
136 138
137 #ifdef QWS 139 #ifdef QWS
138 mb->insertItem( startStopButton ); 140 mb->insertItem( startStopButton );
139 mb->insertItem( c ); 141 mb->insertItem( c );
140 mb->insertItem( d ); 142 mb->insertItem( d );
141 #else // Qt3 changed the insertion order. It's now totally random :( 143 #else // Qt3 changed the insertion order. It's now totally random :(
142 mb->insertItem( d ); 144 mb->insertItem( d );
143 mb->insertItem( c ); 145 mb->insertItem( c );
144 mb->insertItem( startStopButton ); 146 mb->insertItem( startStopButton );
145 #endif 147 #endif
146 148
147 // setup status bar (for now only on X11) 149 // setup status bar (for now only on X11)
148 150
149 #ifndef QWS 151 #ifndef QWS
150 statusBar()->message( "Ready." ); 152 statusBar()->message( "Ready." );
151 #endif 153 #endif
152 154
153}; 155};
154 156
155void WellenreiterMainWindow::showConfigure() 157void WellenreiterMainWindow::showConfigure()
156{ 158{
157 qDebug( "show configure..." ); 159 qDebug( "show configure..." );
158 cw->setCaption( tr( "Configure" ) ); 160 cw->setCaption( tr( "Configure" ) );
159 #ifdef QWS 161 #ifdef QWS
160 cw->showMaximized(); 162 cw->showMaximized();
161 #endif 163 #endif
162 int result = cw->exec(); 164 int result = cw->exec();
163 165
164 if ( result ) 166 if ( result )
165 { 167 {
166 // check configuration from config window 168 // check configuration from config window
167 169
168 const QString& interface = cw->interfaceName->currentText(); 170 const QString& interface = cw->interfaceName->currentText();
169 const int cardtype = cw->daemonDeviceType(); 171 const int cardtype = cw->daemonDeviceType();
170 const int interval = cw->daemonHopInterval(); 172 const int interval = cw->daemonHopInterval();
171 173
172 if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) 174 if ( ( interface != "<select>" ) && ( cardtype != 0 ) )
173 startStopButton->setEnabled( true ); 175 startStopButton->setEnabled( true );
174 //TODO ... 176 //TODO ...
175 else 177 else
176 startStopButton->setEnabled( false ); 178 startStopButton->setEnabled( false );
177 //TODO ... 179 //TODO ...
178 } 180 }
179} 181}
180 182
181WellenreiterMainWindow::~WellenreiterMainWindow() 183WellenreiterMainWindow::~WellenreiterMainWindow()
182{ 184{
183 185
184 delete infoIconSet; 186 delete infoIconSet;
185 delete settingsIconSet; 187 delete settingsIconSet;
186 #ifdef QWS 188 #ifdef QWS
187 delete searchIconSet; 189 delete searchIconSet;
188 delete cancelIconSet; 190 delete cancelIconSet;
189 #else 191 #else
190 delete startStopIconSet; 192 delete startStopIconSet;
191 #endif 193 #endif
192 194
193}; 195};
194 196
195void WellenreiterMainWindow::demoAddStations() 197void WellenreiterMainWindow::demoAddStations()
196{ 198{
197 mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 ); 199 mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 );
198 mw->netView()->addNewItem( "managed", "Vanille", "00:30:6D:EF:A6:23", true, 11, 10 ); 200 mw->netView()->addNewItem( "managed", "Vanille", "00:30:6D:EF:A6:23", true, 11, 10 );
199 mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 ); 201 mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 );
200 mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 ); 202 mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 );
201 mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 ); 203 mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 );
202} 204}
203 205
204QString WellenreiterMainWindow::getFileName( bool save ) 206QString WellenreiterMainWindow::getFileName( bool save )
205{ 207{
206 QMap<QString, QStringList> map; 208 QMap<QString, QStringList> map;
207 map.insert( tr("All"), QStringList() ); 209 map.insert( tr("All"), QStringList() );
208 QStringList text; 210 QStringList text;
209 text << "text/*"; 211 text << "text/*";
210 map.insert(tr("Text"), text ); 212 map.insert(tr("Text"), text );
211 text << "*"; 213 text << "*";
212 map.insert(tr("All"), text ); 214 map.insert(tr("All"), text );
213 215
214 QString str; 216 QString str;
215 if ( save ) 217 if ( save )
216 { 218 {
217 #ifdef QWS 219 #ifdef QWS
218 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); 220 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map );
219 #else 221 #else
220 str = QFileDialog::getSaveFileName(); 222 str = QFileDialog::getSaveFileName();
221 #endif 223 #endif
222 if ( str.isEmpty() || QFileInfo(str).isDir() ) 224 if ( str.isEmpty() || QFileInfo(str).isDir() )
223 return ""; 225 return "";
224 } 226 }
225 else 227 else
226 { 228 {
227 #ifdef QWS 229 #ifdef QWS
228 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); 230 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map );
229 #else 231 #else
230 str = QFileDialog::getOpenFileName(); 232 str = QFileDialog::getOpenFileName();
231 #endif 233 #endif
232 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) 234 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() )
233 return ""; 235 return "";
234 } 236 }
235 return str; 237 return str;
236} 238}
237 239
238void WellenreiterMainWindow::fileSaveLog() 240void WellenreiterMainWindow::fileSaveLog()
239{ 241{
240 QString fname = getFileName( true ); 242 QString fname = getFileName( true );
241 if ( !fname.isEmpty() ) 243 if ( !fname.isEmpty() )
242 { 244 {
243 QFile f( fname ); 245 QFile f( fname );
244 if ( f.open(IO_WriteOnly) ) 246 if ( f.open(IO_WriteOnly) )
245 { 247 {