void RadialMap::Widget::dropEvent( QDropEvent *e ) { DEBUG_ANNOUNCE KURL::List urls; if (KURLDrag::decode( e, urls ) && urls.count()) emit giveMeTreeFor( urls.first() ); }
void RadialMap::Widget::dropEvent(QDropEvent *e) { QList<QUrl> uriList = KUrlMimeData::urlsFromMimeData(e->mimeData()); if (!uriList.isEmpty()) emit giveMeTreeFor(uriList.first()); }
void RadialMap::Widget::mousePressEvent( QMouseEvent *e ) { //m_tip is hidden already by event filter //m_focus is set correctly (I've been strict, I assure you it is correct!) enum { Konqueror, Konsole, Center, Open, Copy, Delete }; if (m_focus && !m_focus->isFake()) { const KURL url = Widget::url( m_focus->file() ); const bool isDir = m_focus->file()->isDirectory(); if( e->button() == Qt::RightButton ) { KPopupMenu popup; popup.insertTitle( m_focus->file()->fullPath( m_tree ) ); if (isDir) { popup.insertItem( SmallIconSet( "konqueror" ), i18n( "Open &Konqueror Here" ), Konqueror ); if( url.protocol() == "file" ) popup.insertItem( SmallIconSet( "konsole" ), i18n( "Open &Konsole Here" ), Konsole ); if (m_focus->file() != m_tree) { popup.insertSeparator(); popup.insertItem( SmallIconSet( "viewmag" ), i18n( "&Center Map Here" ), Center ); } } else popup.insertItem( SmallIconSet( "fileopen" ), i18n( "&Open" ), Open ); popup.insertSeparator(); popup.insertItem( SmallIconSet( "editcopy" ), i18n( "&Copy to clipboard" ), Copy ); popup.insertSeparator(); popup.insertItem( SmallIconSet( "editdelete" ), i18n( "&Delete" ), Delete ); switch (popup.exec( e->globalPos(), 1 )) { case Konqueror: //KRun::runCommand will show an error message if there was trouble KRun::runCommand( QString( "kfmclient openURL \"%1\"" ).arg( url.url() ) ); break; case Konsole: // --workdir only works for local file paths KRun::runCommand( QString( "konsole --workdir \"%1\"" ).arg( url.path() ) ); break; case Center: case Open: goto section_two; case Copy: QApplication::clipboard()->setData( new KURLDrag( KURL::List( url ) ) ); break; case Delete: { const KURL url = Widget::url( m_focus->file() ); const QString message = m_focus->file()->isDirectory() ? i18n( "<qt>The directory at <i>'%1'</i> will be <b>recursively</b> and <b>permanently</b> deleted." ) : i18n( "<qt><i>'%1'</i> will be <b>permanently</b> deleted." ); const int userIntention = KMessageBox::warningContinueCancel( this, message.arg( url.prettyURL() ), QString::null, KGuiItem( i18n("&Delete"), "editdelete" ) ); if (userIntention == KMessageBox::Continue) { KIO::Job *job = KIO::del( url ); job->setWindow( this ); connect( job, SIGNAL(result( KIO::Job* )), SLOT(deleteJobFinished( KIO::Job* )) ); QApplication::setOverrideCursor( KCursor::workingCursor() ); } } default: //ensure m_focus is set for new mouse position sendFakeMouseEvent(); } } else { // not right mouse button section_two: const QRect rect( e->x() - 20, e->y() - 20, 40, 40 ); m_tip->hide(); // user expects this if (!isDir || e->button() == Qt::MidButton) { KIconEffect::visualActivate( this, rect ); new KRun( url, this, true ); //FIXME see above } else if (m_focus->file() != m_tree) { // is left click KIconEffect::visualActivate( this, rect ); emit activated( url ); //activate first, this will cause UI to prepare itself createFromCache( (Directory *)m_focus->file() ); } else emit giveMeTreeFor( url.upURL() ); } } }
void RadialMap::Widget::mousePressEvent(QMouseEvent *e) { if (!isEnabled()) return; //m_focus is set correctly (I've been strict, I assure you it is correct!) if (!m_focus || m_focus->isFake()) { return; } const QUrl url = Widget::url(m_focus->file()); const bool isDir = m_focus->file()->isFolder(); // Open file if (e->button() == Qt::MidButton || (e->button() == Qt::LeftButton && !isDir)) { new KRun(url, this, true); return; } if (e->button() == Qt::LeftButton) { if (m_focus->file() != m_tree) { emit activated(url); //activate first, this will cause UI to prepare itself createFromCache((Folder *)m_focus->file()); } else if (KIO::upUrl(url) != url) { emit giveMeTreeFor(KIO::upUrl(url)); } return; } if (e->button() != Qt::RightButton) { // Ignore other mouse buttons return; } // Actions in the right click menu QAction* openFileManager = 0; QAction* openTerminal = 0; QAction* centerMap = 0; QAction* openFile = 0; QAction* copyClipboard = 0; QAction* deleteItem = 0; QMenu popup; popup.setTitle(m_focus->file()->fullPath(m_tree)); if (isDir) { openFileManager = popup.addAction(QIcon::fromTheme(QLatin1String("system-file-manager")), i18n("Open &File Manager Here")); if (url.scheme() == QLatin1String("file")) { openTerminal = popup.addAction(QIcon::fromTheme(QLatin1String( "utilities-terminal" )), i18n("Open &Terminal Here")); } if (m_focus->file() != m_tree) { popup.addSeparator(); centerMap = popup.addAction(QIcon::fromTheme(QLatin1String( "zoom-in" )), i18n("&Center Map Here")); } } else { openFile = popup.addAction(QIcon::fromTheme(QLatin1String("document-open")), i18nc("Scan/open the path of the selected element", "&Open")); } popup.addSeparator(); copyClipboard = popup.addAction(QIcon::fromTheme(QLatin1String( "edit-copy" )), i18n("&Copy to clipboard")); if (m_focus->file() != m_tree) { popup.addSeparator(); deleteItem = popup.addAction(QIcon::fromTheme(QLatin1String( "edit-delete" )), i18n("&Delete")); } QAction* clicked = popup.exec(e->globalPos(), 0); if (openFileManager && clicked == openFileManager) { KRun::runUrl(url, QLatin1String( "inode/directory" ), this); } else if (openTerminal && clicked == openTerminal) { KToolInvocation::invokeTerminal(QString(),url.path()); } else if (centerMap && clicked == centerMap) { emit activated(url); //activate first, this will cause UI to prepare itself createFromCache((Folder *)m_focus->file()); } else if (openFile && clicked == openFile) { new KRun(url, this, true); } else if (clicked == copyClipboard) { QMimeData* mimedata = new QMimeData(); mimedata->setUrls(QList<QUrl>() << url); QApplication::clipboard()->setMimeData(mimedata , QClipboard::Clipboard); } else if (clicked == deleteItem && m_focus->file() != m_tree) { m_toBeDeleted = m_focus; const QUrl url = Widget::url(m_toBeDeleted->file()); const QString message = m_toBeDeleted->file()->isFolder() ? i18n("<qt>The folder at <i>'%1'</i> will be <b>recursively</b> and <b>permanently</b> deleted.</qt>", url.toString()) : i18n("<qt><i>'%1'</i> will be <b>permanently</b> deleted.</qt>", url.toString()); const int userIntention = KMessageBox::warningContinueCancel( this, message, QString(), KGuiItem(i18n("&Delete"), QLatin1String("edit-delete"))); if (userIntention == KMessageBox::Continue) { KIO::Job *job = KIO::del(url); connect(job, &KJob::finished, this, &RadialMap::Widget::deleteJobFinished); QApplication::setOverrideCursor(Qt::BusyCursor); setEnabled(false); } } else { //ensure m_focus is set for new mouse position sendFakeMouseEvent(); } }