void Popup::mouseClick(int x, int y) { if (cursorInside(x,y)) { y -= int(m_pnl.GetY() + m_list.GetY()); y /= 14; if (y < int(items.size())) if (items[y]->cb) items[y]->cb(items[y]); } prepareToDie(); }
void KFMExec::slotFinished( ) { // The 'list' command worked. We can now open the new window for this URL. if (dirURL) { KfmGui *m = new KfmGui( 0L, 0L, dirURL ); if ( dlg ) // hide progress dialog box { delete dlg; dlg = 0L; } m->show(); // We are a zombie now prepareToDie(); } }
void KFMExec::openURL( const char *_url ) { KURL u( _url ); if ( u.isMalformed() ) { QString tmp; tmp << klocale->translate("Malformed URL\n") << _url; QMessageBox::warning( 0, klocale->translate("KFM Error"), tmp ); // We are a zombie now prepareToDie(); return; } // --- start do mailto kdelnks ---- // Pasted from kfmman.cpp - almost verbatim // This way kfm can open mailto kdelnks from desktop and other // places too - nothing can stop us now to have address book // done like bookmarks :-) (sven) // Dirty hack for calling kmail if ( strcmp( u.protocol(), "mailto" ) == 0 ) { QString subject; QString to( u.path() ); int i; if ( ( i = to.find( '?' ) ) != -1 ) to = to.left( i ).data(); QString cmd; cmd << "kmail -s \"" << subject << "\" \"" << to << "\""; KMimeBind::runCmd( cmd ); return; } // --- end do mailto kdelnks ---- // A link to the web in form of a *.kdelnk file ? QString path = u.path(); if ( !u.hasSubProtocol() && strcmp( u.protocol(), "file" ) == 0 && path.right(7) == ".kdelnk" ) { // Try tp open the *.kdelnk file QFile file( path ); if ( file.open( IO_ReadOnly ) ) { file.close(); KConfig config( path ); config.setGroup( "KDE Desktop Entry" ); QString typ = config.readEntry( "Type" ); // Is it a link ? if ( typ == "Link" ) { // Is there a URL ? QString u2 = config.readEntry( "URL" ); if ( !u2.isEmpty() ) { // It is a link and we have new URL => Recursion with the new URL openURL( u2 ); return; } else { // The *.kdelnk file is broken QMessageBox::warning( 0, klocale->translate("KFM Error"), klocale->translate("The file does not contain a URL") ); // We are a zombie now prepareToDie(); return; } } file.close(); } } // Do we know that it is !really! a file ? // This gives us some speedup on local hard disks. if ( KIOServer::isDir( _url ) == 0 && !u.hasSubProtocol() && strcmp( u.protocol(), "file" ) == 0 ) { tryURL = openLocalURL( _url ); if ( tryURL.isEmpty() ) return; } // Do we really know that it is a directory ? else if ( KIOServer::isDir( _url ) == 1 ) { // Ok, lets open a new window KfmGui *m = new KfmGui( 0L, 0L, _url ); if ( dlg ) { delete dlg; dlg = 0L; } m->show(); return; } // We are not shure about the URL else // We try to load this URL now tryURL = _url; // Show the user that we are doing something, since it may take // us some time. dlg = new QDialog( 0L ); // make sure window doesn't initially have the focus KWM::setDecoration(dlg->winId(), KWM::normalDecoration | KWM::noFocus); dlg->resize( 300, 120 ); QPushButton *pb = new QPushButton( klocale->translate("Cancel"), dlg ); pb->setGeometry( 110, 70, 80, 30 ); pb->setDefault(TRUE); connect( pb, SIGNAL( clicked() ), this, SLOT( slotCancel() ) ); QLabel* line1 = new QLabel( dlg ); line1->setGeometry( 10, 10, 280, 20 ); line1->setText( klocale->translate("Trying to open") ); QLabel* line2 = new QLabel( dlg ); line2->setGeometry( 10, 30, 280, 20 ); KURL displayedURL (tryURL); displayedURL.setPassword(""); // hide password line2->setText( displayedURL.url() ); dlg->show(); // Find out what to do with this URL. job->browse( tryURL, false ); }
void KFMExec::slotMimeType( const char *_type ) { // A dirty hack for passing the character set char *typestr=0; const char *aType=0; const char *aCharset=0; if ( _type ) { typestr=new char[strlen(_type)+1]; strcpy(typestr,_type); aType=strtok(typestr," ;\t\n"); char *tmp; while((tmp=strtok(0," ;\t\n"))){ if ( strncmp(tmp,"charset=",8)==0 ) aCharset=tmp+8; } if ( aCharset != 0 ) { tmp=strpbrk((char*)aCharset," ;\t\n"); if ( tmp != 0 ) *tmp=0; } } // Stop browsing. We need an application job->stop(); // delete job; // job = 0L; // GZIP if ( aType && strcmp( aType, "application/x-gzip" ) == 0L ) { job->stop(); tryURL += "#gzip:/"; openURL( tryURL ); } // TAR else if ( aType && strcmp( aType, "application/x-tar" ) == 0L ) { // Is this tar file perhaps hosted in a gzipped file ? KURL u( tryURL ); // ... then we already have a 'gzip' subprotocol if ( u.hasSubProtocol() ) { KURL u2( u.nestedURL() ); if ( strcmp( u2.protocol(), "gzip" ) == 0 ) { // Remove the 'gzip' protocol. It will only slow down the process, // since two subprotocols '#gzip:/#tar:/' are not very fast // right now. tryURL = u.parentURL(); } } job->stop(); tryURL += "#tar:/"; openURL( tryURL ); } // No HTML ? else if ( aType == 0L || strcmp( aType, "text/html" ) != 0L ) { bool bdone = false; // Do we know the mime type ? if ( aType != 0L ) { KMimeType *mime = KMimeType::findByName( aType ); // Try to run the URL if we know the mime type if ( mime && mime->run( tryURL ) ) { // We are a zombie now prepareToDie(); bdone = true; } } if ( !bdone ) { // Ask the user what we should do OpenWithDlg l( klocale->translate("Open With:"), "", 0L, true ); if ( l.exec() ) { KMimeBind *bind = l.mimeBind(); if ( bind ) { bind->runBinding( tryURL ); } else { QString pattern = l.getText(); // The user did not something ? if ( !pattern.isEmpty() ) { QStrList list; list.append( tryURL ); openWithOldApplication( pattern, list ); } // We are a zombie now prepareToDie(); } } } } // It is HTML else { // Ok, lets open a new window KfmGui *m = new KfmGui( 0L, 0L, tryURL ); if ( aCharset != 0 ) m->setCharset(aCharset); if ( dlg ) { delete dlg; dlg = 0L; } m->show(); // We are a zombie now prepareToDie(); } delete typestr; }
void KFMExec::slotError( int, const char * ) { // Bad Doggie !! You should clean up after Errors!!! prepareToDie(); return; }
void KFMExec::slotCancel() { // We are a zombie now prepareToDie(); return; }