void OpenLocalHelper::checkPendingOpenLocalRequest()
{
    if (!url_.isEmpty()) {
        openLocalFile(QUrl::fromEncoded(url_));
        setUrl(NULL);
    }
}
Example #2
0
void QUAlbumArtExCollector::processSearchResults() {
	QRegExp rx = QRegExp(";src=(.*)\" width=.*(\\d+)×(\\d+)\"");

	rx.setMinimal(true);
	rx.setCaseSensitivity(Qt::CaseInsensitive);

	QString text(buffer()->data());
	QStringList allUrls;
	QList<QPair<int, int> > resolutions;
	int pos = 0;

	while ((pos = rx.indexIn(text, pos)) != -1) {
		allUrls << rx.cap(1).trimmed().replace("%2F", "/");
		resolutions << QPair<int, int>(QVariant(rx.cap(2)).toInt(), QVariant(rx.cap(3)).toInt());
		pos += rx.matchedLength();
	}

	rx.setPattern("Images (\\d+)\\-(\\d+) of (\\d+)\\.");
	rx.indexIn(text);
	int from = QVariant(rx.cap(1)).toInt();
	int to = QVariant(rx.cap(2)).toInt();
	int last = QVariant(rx.cap(3)).toInt();

	handleOldDownloads();

	QStringList urls;
	QPair<int, int> maxResolution(
			QVariant(source()->customDataField(source()->customDataFields().at(0))).toInt(),
			QVariant(source()->customDataField(source()->customDataFields().at(1))).toInt());
	for(int i = 0; i < allUrls.size(); i++)
		if(resolutions.at(i).first <= maxResolution.first and
		   resolutions.at(i).second <= maxResolution.second)
			urls << allUrls.at(i);

	ignoredUrls = allUrls.size() - qMin(urls.size(), source()->limit()) + last - to;

	if(urls.isEmpty()) {
		setState(Idle);
		if(ignoredUrls > 0)
			communicator()->send(tr("No results, %1 ignored.").arg(ignoredUrls));
		else
			communicator()->send(tr("No results."));
		communicator()->send(QUCommunicatorInterface::Done);
		return;
	}

	setState(ImageRequest);

	for(int i = 0; i < urls.size() and i < source()->limit(); i++) {
		QFile *file = openLocalFile(source()->imageFolder(song()).filePath(QFileInfo(urls.at(i)).fileName()));

//		song()->log(tr("[albumartex - result] ") + "http://" + source()->host() + urls.at(i), QU::Help);

		if(file) {
			http()->setHost(source()->host());
			http()->get("http://" + source()->host() + urls.at(i), file);
		}
	}
}
void StarredFilesListView::openLocalFile()
{
    StarredItem file = qvariant_cast<StarredItem>(view_file_on_web_action_->data());

    if (!file.isFile()) {
        openLocalDir(file);
    } else {
        openLocalFile(file);
    }
}
void StarredFilesListView::createActions()
{
    open_file_action_ = new QAction(tr("&Open"), this);
    open_file_action_->setIcon(QIcon(":/images/toolbar/file-gray.png"));
    open_file_action_->setIconVisibleInMenu(true);
    open_file_action_->setStatusTip(tr("Open this file"));
    connect(open_file_action_, SIGNAL(triggered()), this, SLOT(openLocalFile()));

    view_file_on_web_action_ = new QAction(tr("view on &Web"), this);
    view_file_on_web_action_->setIcon(QIcon(":/images/cloud-gray.png"));
    view_file_on_web_action_->setIconVisibleInMenu(true);
    view_file_on_web_action_->setStatusTip(tr("view this file on website"));
    connect(view_file_on_web_action_, SIGNAL(triggered()), this, SLOT(viewFileOnWeb()));
}
Example #5
0
void EventFilter::showMenu(const QPoint &p)
{
    if (!menu) {
        menu = new QMenu();
        menu->addAction(tr("Open"), this, SLOT(openLocalFile()));
        menu->addAction(tr("Open Url"), this, SLOT(openUrl()));
        menu->addSeparator();
        menu->addAction(tr("About"), this, SLOT(about()));
        menu->addAction(tr("Help"), this, SLOT(help()));
        menu->addSeparator();
        menu->addAction(tr("About Qt"), qApp, SLOT(aboutQt()));
    }
    menu->exec(p);
}
void StarredFilesListView::onItemDoubleClicked(const QModelIndex& index)
{
    QStandardItem *item = getFileItem(index);
    if (!item) {
        return;
    }

    const StarredItem& file = ((StarredFileItem *)item)->file();

    if (!file.isFile()) {
        openLocalDir(file);
    } else {
        openLocalFile(file);
    }
}
Example #7
0
/*
 * Open a disk file on remote host.
 */
int
SamrftOpen(
	SamrftImpl_t *rftd,
	char *filename,
	int oflag,
	SamrftCreateAttr_t *creat)
{
	int rc;
	int error;

	Trace(TR_RFT, "Samrft [%d] open file %s %d %x",
	    traceRftd(rftd), filename, oflag, creat);

	/*
	 * If first open following connect, initialize data ports.
	 */
	if (rftd->crew == NULL) {
		if (initDataPorts(rftd) < 0) {
			return (-1);
		}
	}

	if (rftd->remotehost) {
		if (creat) {
			SendCommand(rftd, "%s %s %d %d %d %d %d",
			    SAMRFT_CMD_OPEN, filename, oflag,
			    TRUE, creat->mode, creat->uid, creat->gid);
		} else {
			SendCommand(rftd, "%s %s %d %d",
			    SAMRFT_CMD_OPEN, filename, oflag,
			    FALSE);
		}
		if (GetReply(rftd) >= 0) {
			rc = GetOpenReply(rftd, &error);
			if (rc < 0) {
				SetErrno = error;
			}
		}
	} else {
		/*
		 * Open file on local machine.
		 */
		rc = openLocalFile(rftd, filename, oflag, creat);
	}

	return (rc);
}
Example #8
0
void FileTransferWindow::doubleClicked(FileTransferItem * it, const QPoint &)
{
	if(it)
		openLocalFile();
}
Example #9
0
bool EventFilter::eventFilter(QObject *watched, QEvent *event)
{
    Q_UNUSED(watched);
    AVPlayer *player = static_cast<AVPlayer*>(parent());
    if (!player)
        return false;
#ifndef QT_NO_DYNAMIC_CAST //dynamic_cast is defined as a macro to force a compile error
    if (player->renderer() != dynamic_cast<VideoRenderer*>(watched)) {
        return false;
    }
#endif
    QEvent::Type type = event->type();
    switch (type) {
    case QEvent::MouseButtonPress:
        qDebug("EventFilter: Mouse press");
        static_cast<QMouseEvent*>(event)->button();
        //TODO: wheel to control volume etc.
        return false;
        break;
    case QEvent::KeyPress: {
        QKeyEvent *key_event = static_cast<QKeyEvent*>(event);
        int key = key_event->key();
        switch (key) {
        case Qt::Key_C: //capture
            player->captureVideo();
            break;
        case Qt::Key_N: //check playing?
            player->playNextFrame();
            break;
        case Qt::Key_P:
            player->play();
            break;
        case Qt::Key_Q:
        case Qt::Key_Escape:
            qApp->quit();
            break;
        case Qt::Key_S:
            player->stop(); //check playing?
            break;
        case Qt::Key_Space: //check playing?
            qDebug("isPaused = %d", player->isPaused());
            player->pause(!player->isPaused());
            break;
        case Qt::Key_F: { //TODO: move to gui
            QWidget *w = qApp->activeWindow();
            if (!w)
                return false;
            if (w->isFullScreen())
                w->showNormal();
            else
                w->showFullScreen();
        }
            break;
        case Qt::Key_Up:
            if (player->audio()) {
                qreal v = player->audio()->volume();
                if (v > 0.5)
                    v += 0.1;
                else if (v > 0.1)
                    v += 0.05;
                else
                    v += 0.025;
                player->audio()->setVolume(v);
                qDebug("vol = %.3f", player->audio()->volume());
            }
            break;
        case Qt::Key_Down:
            if (player->audio()) {
                qreal v = player->audio()->volume();
                if (v > 0.5)
                    v -= 0.1;
                else if (v > 0.1)
                    v -= 0.05;
                else
                    v -= 0.025;
                player->audio()->setVolume(v);
                qDebug("vol = %.3f", player->audio()->volume());
            }
            break;
        case Qt::Key_O: {
            Qt::KeyboardModifiers m = key_event->modifiers();
            if (m == Qt::ControlModifier) {
                //TODO: emit a signal so we can use custome dialogs?
                openLocalFile();
            } else/* if (m == Qt::NoModifier) */{
                player->osdFilter()->useNextShowType();
            }
        }
            break;
        case Qt::Key_Left:
            qDebug("<-");
            player->seekBackward();
            break;
        case Qt::Key_Right:
            qDebug("->");
            player->seekForward();
            break;
        case Qt::Key_M:
            if (player->audio()) {
                player->audio()->setMute(!player->audio()->isMute());
            }
            break;
        case Qt::Key_R: {
            VideoRenderer* renderer = player->renderer();
            VideoRenderer::OutAspectRatioMode r = renderer->outAspectRatioMode();
            if (r == VideoRenderer::VideoAspectRatio)
                renderer->setOutAspectRatioMode(VideoRenderer::RendererAspectRatio);
            else
                renderer->setOutAspectRatioMode(VideoRenderer::VideoAspectRatio);
        }
            break;
        case Qt::Key_T: {
            QWidget *w = qApp->activeWindow();
            if (!w)
                return false;
            Qt::WindowFlags wf = w->windowFlags();
            if (wf & Qt::WindowStaysOnTopHint) {
                qDebug("Window not stays on top");
                w->setWindowFlags(wf & ~Qt::WindowStaysOnTopHint);
            } else {
                qDebug("Window stays on top");
                w->setWindowFlags(wf | Qt::WindowStaysOnTopHint);
            }
            //call setParent() when changing the flags, causing the widget to be hidden
            w->show();
        }
            break;
        case Qt::Key_F1:
            help();
            break;
        default:
            return false;
        }
        break;
    }
    case QEvent::DragEnter:
    case QEvent::DragMove: {
        QDropEvent *e = static_cast<QDropEvent*>(event);
        e->acceptProposedAction();
    }
        break;
    case QEvent::Drop: {
        QDropEvent *e = static_cast<QDropEvent*>(event);
        QString path = e->mimeData()->urls().first().toLocalFile();
        player->stop();
        player->load(path);
        player->play();
        e->acceptProposedAction();
    }
        break;
    case QEvent::GraphicsSceneContextMenu: {
        QGraphicsSceneContextMenuEvent *e = static_cast<QGraphicsSceneContextMenuEvent*>(event);
        showMenu(e->screenPos());
    }
        break;
    case QEvent::ContextMenu: {
        QContextMenuEvent *e = static_cast<QContextMenuEvent*>(event);
        showMenu(e->globalPos());
    }
        break;
    default:
        return false;
    }
    return true; //false: for text input
}