Diffstat (limited to 'noncore/apps/opie-gutenbrowser/gutenbrowser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp index fac21da..c7cdd83 100644 --- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp +++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | |||
@@ -128,209 +128,220 @@ Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) | |||
128 | 128 | ||
129 | for (int i = 0; i <= i_numofFiles; i++) { | 129 | for (int i = 0; i <= i_numofFiles; i++) { |
130 | // tempFileName.setNum(i); | 130 | // tempFileName.setNum(i); |
131 | config.setGroup( "Files" ); | 131 | config.setGroup( "Files" ); |
132 | QString ramble = config.readEntry( QString::number(i), "" ); | 132 | QString ramble = config.readEntry( QString::number(i), "" ); |
133 | 133 | ||
134 | config.setGroup( "Titles" ); | 134 | config.setGroup( "Titles" ); |
135 | QString tempTitle = config.readEntry( ramble, ""); | 135 | QString tempTitle = config.readEntry( ramble, ""); |
136 | config.setGroup( tempTitle); | 136 | config.setGroup( tempTitle); |
137 | int index = config.readNumEntry( "LineNumber", -1 ); | 137 | int index = config.readNumEntry( "LineNumber", -1 ); |
138 | if( index != -1) { | 138 | if( index != -1) { |
139 | odebug << tempTitle << oendl; | 139 | odebug << tempTitle << oendl; |
140 | if(!tempTitle.isEmpty()) bookmarksMenu->insertItem( tempTitle); | 140 | if(!tempTitle.isEmpty()) bookmarksMenu->insertItem( tempTitle); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | // QString gutenIndex= local_library + "GUTINDEX.ALL"; | 144 | // QString gutenIndex= local_library + "GUTINDEX.ALL"; |
145 | QString gutenIndex = QPEApplication::qpeDir()+ "etc/gutenbrowser/GUTINDEX.ALL"; | 145 | QString gutenIndex = QPEApplication::qpeDir()+ "etc/gutenbrowser/GUTINDEX.ALL"; |
146 | qDebug("gutenindex "+gutenIndex ); | 146 | qDebug("gutenindex "+gutenIndex ); |
147 | if( QFile( gutenIndex).exists() ) { | 147 | if( QFile( gutenIndex).exists() ) { |
148 | indexLib.setName( gutenIndex); | 148 | indexLib.setName( gutenIndex); |
149 | } else { | 149 | } else { |
150 | QString localLibIndexFile = QPEApplication::qpeDir()+ "etc/gutenbrowser/PGWHOLE.TXT"; | 150 | QString localLibIndexFile = QPEApplication::qpeDir()+ "etc/gutenbrowser/PGWHOLE.TXT"; |
151 | // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; | 151 | // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; |
152 | newindexLib.setName( localLibIndexFile); | 152 | newindexLib.setName( localLibIndexFile); |
153 | } | 153 | } |
154 | qDebug("attempting new library"); | 154 | qDebug("attempting new library"); |
155 | LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); | 155 | LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); |
156 | loadCheck = false; | 156 | loadCheck = false; |
157 | chdir(local_library); | 157 | chdir(local_library); |
158 | if(!showMainList) { | 158 | if(!showMainList) { |
159 | Lview->setFocus(); | 159 | Lview->setFocus(); |
160 | // if(firstTime) | 160 | // if(firstTime) |
161 | // Bookmark(); | 161 | // Bookmark(); |
162 | for (int i=1;i< qApp->argc();i++) { | 162 | for (int i=1;i< qApp->argc();i++) { |
163 | qDebug("Suppose we open somethin"); | 163 | qDebug("Suppose we open somethin"); |
164 | if(!load(qApp->argv()[i])) return; | 164 | if(!load(qApp->argv()[i])) return; |
165 | } | 165 | } |
166 | } else { | 166 | } else { |
167 | fillWithTitles(); | 167 | fillWithTitles(); |
168 | mainList->setFocus(); | 168 | mainList->setFocus(); |
169 | // mainList->setCurrentItem(0); | 169 | // mainList->setCurrentItem(0); |
170 | 170 | ||
171 | } | 171 | } |
172 | writeConfig(); | 172 | writeConfig(); |
173 | QTimer::singleShot( 250, this, SLOT(hideView()) ); | 173 | QTimer::singleShot( 250, this, SLOT(hideView()) ); |
174 | } //end init | 174 | } //end init |
175 | 175 | ||
176 | Gutenbrowser::~Gutenbrowser() { | 176 | Gutenbrowser::~Gutenbrowser() { |
177 | // QPEApplication::grabKeyboard(); | 177 | // QPEApplication::grabKeyboard(); |
178 | // QPEApplication::ungrabKeyboard(); | 178 | // QPEApplication::ungrabKeyboard(); |
179 | odebug << "Exit" << oendl; | 179 | odebug << "Exit" << oendl; |
180 | } | 180 | } |
181 | 181 | ||
182 | /* | 182 | /* |
183 | Google.com search */ | 183 | Google.com search */ |
184 | void Gutenbrowser::InfoBarClick() { | 184 | void Gutenbrowser::InfoBarClick() { |
185 | QString text; | 185 | QString text; |
186 | if( Lview->hasSelectedText()) { | 186 | if( Lview->hasSelectedText()) { |
187 | Lview->copy(); | 187 | Lview->copy(); |
188 | QClipboard *cb = QApplication::clipboard(); | 188 | QClipboard *cb = QApplication::clipboard(); |
189 | text = cb->text(); | 189 | text = cb->text(); |
190 | } else { | 190 | } else { |
191 | // text=title; | 191 | // text=title; |
192 | text=this->caption(); | 192 | text=this->caption(); |
193 | } | 193 | } |
194 | searchGoogle(text); | 194 | searchGoogle(text); |
195 | } | 195 | } |
196 | 196 | ||
197 | /* | 197 | /* |
198 | download http with wget or preferred browser */ | 198 | download http with wget or preferred browser */ |
199 | void Gutenbrowser::goGetit( const QString &url, bool showMsg) { | 199 | void Gutenbrowser::goGetit( const QString &url, bool showMsg) { |
200 | // int eexit=0; | 200 | // int eexit=0; |
201 | QString cmd; | 201 | QString cmd; |
202 | // config.read(); | 202 | // config.read(); |
203 | qApp->processEvents(); | 203 | qApp->processEvents(); |
204 | QString filename = QPEApplication::qpeDir(); | 204 | QString filename = QPEApplication::qpeDir(); |
205 | if(filename.right(1)!="/") | 205 | if(filename.right(1)!="/") |
206 | filename+="/etc/gutenbrowser/"; | 206 | filename+="/etc/gutenbrowser/"; |
207 | else | 207 | else |
208 | filename+="etc/gutenbrowser/"; | 208 | filename+="etc/gutenbrowser/"; |
209 | odebug << "filename "+filename << oendl; | 209 | odebug << "filename "+filename << oendl; |
210 | // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; | 210 | // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; |
211 | 211 | ||
212 | filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); | 212 | filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); |
213 | 213 | ||
214 | Config config("Gutenbrowser"); | 214 | Config config("Gutenbrowser"); |
215 | config.setGroup( "Browser" ); | 215 | config.setGroup( "Browser" ); |
216 | QString brow = config.readEntry("Preferred", "Opera"); | 216 | QString brow = config.readEntry("Preferred", "Opera"); |
217 | odebug << "Preferred browser is "+brow << oendl; | 217 | odebug << "Preferred browser is "+brow << oendl; |
218 | if(!showMsg) { //if we just get the gutenindex.all | 218 | if(!showMsg) { //if we just get the gutenindex.all |
219 | cmd="wget -O " + filename +" " + url+" 2>&1" ; | 219 | cmd="wget -O " + filename +" " + url+" 2>&1" ; |
220 | chdir(local_library); | 220 | chdir(local_library); |
221 | odebug << "Issuing the system command: " << cmd << "" << oendl; | 221 | odebug << "Issuing the system command: " << cmd << "" << oendl; |
222 | 222 | ||
223 | Output *outDlg; | 223 | Output *outDlg; |
224 | outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE); | 224 | |
225 | outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); | ||
226 | |||
225 | outDlg->showMaximized(); | 227 | outDlg->showMaximized(); |
226 | outDlg->show(); | 228 | outDlg->show(); |
227 | qApp->processEvents(); | 229 | qApp->processEvents(); |
228 | FILE *fp; | 230 | FILE *fp; |
229 | char line[130]; | 231 | char line[130]; |
230 | outDlg->OutputEdit->append( tr("Running wget") ); | 232 | outDlg->OutputEdit->append( tr("Running wget") ); |
233 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
231 | sleep(1); | 234 | sleep(1); |
232 | fp = popen( (const char *) cmd, "r"); | 235 | fp = popen( (const char *) cmd, "r"); |
233 | odebug << "Issuing the command\n"+cmd << oendl; | 236 | if ( !fp ) { |
234 | // system(cmd); | 237 | } else { |
235 | while ( fgets( line, sizeof line, fp)) { | 238 | //odebug << "Issuing the command\n"+cmd << oendl; |
236 | outDlg->OutputEdit->append(line); | 239 | // system(cmd); |
237 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 240 | while ( fgets( line, sizeof line, fp)) { |
241 | outDlg->OutputEdit->append(line); | ||
242 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
243 | } | ||
244 | pclose(fp); | ||
245 | outDlg->OutputEdit->append("Finished downloading\n"); | ||
246 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
247 | qApp->processEvents(); | ||
248 | |||
238 | } | 249 | } |
239 | pclose(fp); | 250 | outDlg->close(); |
240 | outDlg->close(); | 251 | |
241 | if(outDlg) | 252 | if(outDlg) |
242 | delete outDlg; | 253 | delete outDlg; |
243 | } else { | 254 | } else { |
244 | if( brow == "Konq") { | 255 | if( brow == "Konq") { |
245 | cmd = "konqueror "+url+" &"; | 256 | cmd = "konqueror "+url+" &"; |
246 | } | 257 | } |
247 | if( brow == "Opera") { //for desktop testing | 258 | if( brow == "Opera") { //for desktop testing |
248 | cmd = "opera "+url+" &"; | 259 | cmd = "opera "+url+" &"; |
249 | } | 260 | } |
250 | // if( brow == "Opera") { // on Zaurus | 261 | // if( brow == "Opera") { // on Zaurus |
251 | // cmd = "operagui "+url+" &"; | 262 | // cmd = "operagui "+url+" &"; |
252 | // } | 263 | // } |
253 | if( brow == "Mozilla") { | 264 | if( brow == "Mozilla") { |
254 | cmd = "mozilla "+url+" &"; | 265 | cmd = "mozilla "+url+" &"; |
255 | } | 266 | } |
256 | if( brow == "Netscape") { | 267 | if( brow == "Netscape") { |
257 | cmd = "netscape "+url+" &"; | 268 | cmd = "netscape "+url+" &"; |
258 | } | 269 | } |
259 | if(brow == "wget") { | 270 | if(brow == "wget") { |
260 | // cmd="wget -q "+url+" &"; | 271 | // cmd="wget -q "+url+" &"; |
261 | QString tempHtml=local_library+"webster.html"; | 272 | QString tempHtml=local_library+"webster.html"; |
262 | cmd="wget -O "+tempHtml+" -q "+url; | 273 | cmd="wget -O "+tempHtml+" -q "+url; |
263 | } | 274 | } |
264 | 275 | ||
265 | chdir(local_library); | 276 | chdir(local_library); |
266 | odebug << "Issuing the sys command: " << cmd << "" << oendl; | 277 | odebug << "Issuing the sys command: " << cmd << "" << oendl; |
267 | system(cmd); | 278 | system(cmd); |
268 | } | 279 | } |
269 | } | 280 | } |
270 | 281 | ||
271 | void Gutenbrowser::toggleButtonIcons( bool useEm) { | 282 | void Gutenbrowser::toggleButtonIcons( bool useEm) { |
272 | QString pixDir; | 283 | QString pixDir; |
273 | if(useEm) | 284 | if(useEm) |
274 | useEm=TRUE; | 285 | useEm=TRUE; |
275 | pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser"; | 286 | pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser"; |
276 | odebug << "Docdir is "+QPEApplication::documentDir() << oendl; | 287 | odebug << "Docdir is "+QPEApplication::documentDir() << oendl; |
277 | 288 | ||
278 | if( useIcons && QDir( pixDir).exists() ) { | 289 | if( useIcons && QDir( pixDir).exists() ) { |
279 | LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline | 290 | LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline |
280 | OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook")); | 291 | OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook")); |
281 | ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline | 292 | ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline |
282 | BackButton->setPixmap( Resource::loadPixmap("back") );//in inline | 293 | BackButton->setPixmap( Resource::loadPixmap("back") );//in inline |
283 | SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline | 294 | SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline |
284 | lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder")); | 295 | lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder")); |
285 | setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") ); | 296 | setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") ); |
286 | dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") ); | 297 | dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") ); |
287 | InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google")); | 298 | InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google")); |
288 | } | 299 | } |
289 | } | 300 | } |
290 | 301 | ||
291 | 302 | ||
292 | bool Gutenbrowser::queryExit() | 303 | bool Gutenbrowser::queryExit() |
293 | { | 304 | { |
294 | int exit=QMessageBox::information(this, "Quit...", "Do your really want to quit?", | 305 | int exit=QMessageBox::information(this, "Quit...", "Do your really want to quit?", |
295 | QMessageBox::Ok, QMessageBox::Cancel); | 306 | QMessageBox::Ok, QMessageBox::Cancel); |
296 | if (exit==1) { | 307 | if (exit==1) { |
297 | writeConfig(); | 308 | writeConfig(); |
298 | qApp->quit(); | 309 | qApp->quit(); |
299 | } else { | 310 | } else { |
300 | }; | 311 | }; |
301 | return (exit==1); | 312 | return (exit==1); |
302 | } | 313 | } |
303 | 314 | ||
304 | // SLOT IMPLEMENTATION | 315 | // SLOT IMPLEMENTATION |
305 | 316 | ||
306 | void Gutenbrowser::slotFilePrint() { | 317 | void Gutenbrowser::slotFilePrint() { |
307 | } | 318 | } |
308 | 319 | ||
309 | void Gutenbrowser::ByeBye() { | 320 | void Gutenbrowser::ByeBye() { |
310 | if (b_queryExit) | 321 | if (b_queryExit) |
311 | queryExit(); | 322 | queryExit(); |
312 | else { | 323 | else { |
313 | // writeConfig(); | 324 | // writeConfig(); |
314 | qApp->quit(); | 325 | qApp->quit(); |
315 | } | 326 | } |
316 | } | 327 | } |
317 | 328 | ||
318 | void Gutenbrowser::HelpBtn() { | 329 | void Gutenbrowser::HelpBtn() { |
319 | HelpMe* HelpDlg; | 330 | HelpMe* HelpDlg; |
320 | HelpDlg = new HelpMe( this, "Help Dialog"); | 331 | HelpDlg = new HelpMe( this, "Help Dialog"); |
321 | HelpDlg->showMaximized(); | 332 | HelpDlg->showMaximized(); |
322 | } | 333 | } |
323 | 334 | ||
324 | void Gutenbrowser::DownloadIndex() { | 335 | void Gutenbrowser::DownloadIndex() { |
325 | #ifndef Q_WS_QWS | 336 | #ifndef Q_WS_QWS |
326 | { | 337 | { |
327 | switch( QMessageBox::information( 0, (tr("Download Library Index, or FTP sites?")), | 338 | switch( QMessageBox::information( 0, (tr("Download Library Index, or FTP sites?")), |
328 | (tr("Do you want to download the newest\n" | 339 | (tr("Do you want to download the newest\n" |
329 | "Project Gutenberg Library Index?\n" | 340 | "Project Gutenberg Library Index?\n" |
330 | "or select an ftp site?\n")), | 341 | "or select an ftp site?\n")), |
331 | (tr("&Library Index")), (tr("&Ftp Site")), (tr("&Cancel")), 2, 2 ) ) | 342 | (tr("&Library Index")), (tr("&Ftp Site")), (tr("&Cancel")), 2, 2 ) ) |
332 | { | 343 | { |
333 | case 0: // index clicked, | 344 | case 0: // index clicked, |
334 | downloadLibIndex(); | 345 | downloadLibIndex(); |
335 | break; | 346 | break; |
336 | 347 | ||