示例#1
0
bool
VideoInput::initFile(std::string path)
{
    size_t dot = path.find_last_of('.');
    std::string ext = dot == std::string::npos ? "" : path.substr(dot + 1);

    /* File exists? */
    if (access(path.c_str(), R_OK) != 0) {
        ERROR("file '%s' unavailable\n", path.c_str());
        return false;
    }

    clearOptions();
    input_ = path;
    emulateRate_ = true;
    decOpts_["loop"] = "1";

    // Force 1fps for static image
    if (ext == "jpeg" || ext == "jpg" || ext == "png") {
        format_ = "image2";
        decOpts_["framerate"] = "1";
    } else {
        WARN("Guessing file type for %s", path.c_str());
        // FIXME: proper parsing of FPS etc. should be done in
        // VideoDecoder, not here.
        decOpts_["framerate"] = "25";
    }

    return true;
}
void UserManager::add(const QString& user, const QString& uin, const QString& passwd)
{
    clearOptions(user);
    QSqlQuery query;
    /* prepare + bindvalue doesn't work... at least on sqlite */
    query.exec( QString("REPLACE INTO users VALUES('%1', '%2', '%3')").arg(user,uin,passwd) );
}
示例#3
0
bool
VideoInput::switchInput(const std::string& resource)
{
    DEBUG("MRL: '%s'", resource.c_str());

    if (switchPending_) {
        ERROR("Video switch already requested");
        return false;
    }

    // Switch off video input?
    if (resource.empty()) {
        clearOptions();
        switchPending_ = true;
        if (!loop_.isRunning())
            loop_.start();
        return true;
    }

    // Supported MRL schemes
    static const std::string sep = "://";

    const auto pos = resource.find(sep);
    if (pos == std::string::npos)
        return false;

    const auto prefix = resource.substr(0, pos);
    if ((pos + sep.size()) >= resource.size())
        return false;

    const auto suffix = resource.substr(pos + sep.size());

    bool valid = false;

    if (prefix == "v4l2") {
        /* Video4Linux2 */
        valid = initCamera(suffix);
    } else if (prefix == "display") {
        /* X11 display name */
        valid = initX11(suffix);
    } else if (prefix == "file") {
        /* Pathname */
        valid = initFile(suffix);
    }

    /* Unsupported MRL or failed initialization */
    if (valid) {
        switchPending_ = true;
        if (!loop_.isRunning())
            loop_.start();
    }
    else
        ERROR("Failed to init input for MRL '%s'\n", resource.c_str());

    return valid;
}
示例#4
0
void DialogueBoxWidget::updateOptions()
{
    clearOptions();

    // load options if the end of dialogues part
    if (_dialoguePartIndex == _currentDialogueNode->dialogue_parts.size() - 1 &&
        !_currentDialogueNode->dialogue_options.empty())
    {
        for (std::size_t i = 0; i < _currentDialogueNode->dialogue_options.size(); ++i)
        {
            const NPCData::OptionDialogueNode& optionDialogueNode = _currentDialogueNode->dialogue_options[i];
            NPCOptionLink* link = new NPCOptionLink(QString::fromStdString(optionDialogueNode.option_content), optionDialogueNode);
            connect(link, SIGNAL(onClicked(NPCOptionLink*)), this, SLOT(onLinkClicked(NPCOptionLink*)));
            _linksLayout->addWidget(link);
            _optionLinks.push_back(link);
        }
    }
}
示例#5
0
bool
VideoInput::initCamera(const std::string& device)
{
    std::map<std::string, std::string> map =
        Manager::instance().getVideoManager()->getSettings(device);

    if (map.empty())
        return false;

    clearOptions();
    input_ = map["input"];
    format_ = "video4linux2";
    decOpts_["channel"] = map["channel_num"];
    decOpts_["framerate"] = map["framerate"];
    decOpts_["video_size"] = map["video_size"];

    return true;
}
示例#6
0
bool
VideoInput::initX11(std::string display)
{
    size_t space = display.find(' ');

    clearOptions();
    decOpts_.format = "x11grab";
    decOpts_.framerate = 25;

    if (space != std::string::npos) {
        std::istringstream iss(display.substr(space + 1));
        char sep;
        unsigned w, h;
        iss >> w >> sep >> h;
        // round to 8 pixel block
        decOpts_.width = round2pow(w, 3);
        decOpts_.height = round2pow(h, 3);
        decOpts_.input = display.erase(space);
    } else {
示例#7
0
bool
VideoInput::initX11(std::string display)
{
    size_t space = display.find(' ');

    clearOptions();
    format_ = "x11grab";
    decOpts_["framerate"] = "25";

    if (space != std::string::npos) {
        decOpts_["video_size"] = display.substr(space + 1);
        input_ = display.erase(space);
    } else {
        input_ = display;
        decOpts_["video_size"] = "vga";
    }

    return true;
}
示例#8
0
void WebContentsWidget::triggerAction(ActionIdentifier action, bool checked)
{
	const bool isFindAction = (action == FindAction || action == QuickFindAction);

	if (isFindAction || action == FindNextAction || action == FindPreviousAction)
	{
		if (!m_ui->findWidget->isVisible())
		{
			if (action == QuickFindAction)
			{
				killTimer(m_quickFindTimer);

				m_quickFindTimer = startTimer(2000);
			}

			if (!isFindAction || SettingsManager::getValue(QLatin1String("Search/ReuseLastQuickFindQuery")).toBool())
			{
				m_ui->findLineEdit->setText(m_quickFindQuery);

				if (isFindAction)
				{
					updateFind();
				}
			}

			m_ui->findWidget->setVisible(true);
		}

		m_ui->findLineEdit->setFocus();
		m_ui->findLineEdit->selectAll();

		if (!isFindAction)
		{
			updateFind(action == FindPreviousAction);
		}
	}
	else if (action == QuickPreferencesAction)
	{
		if (m_isTabPreferencesMenuVisible)
		{
			return;
		}

		m_isTabPreferencesMenuVisible = true;

		QActionGroup popupsGroup(this);
		popupsGroup.setExclusive(true);
		popupsGroup.setEnabled(false);

		QMenu menu;

		popupsGroup.addAction(menu.addAction(tr("Open all pop-ups")));
		popupsGroup.addAction(menu.addAction(tr("Open pop-ups in background")));
		popupsGroup.addAction(menu.addAction(tr("Block all pop-ups")));

		menu.addSeparator();

		QAction *enableImagesAction = menu.addAction(tr("Enable Images"));
		enableImagesAction->setCheckable(true);
		enableImagesAction->setChecked(m_webWidget->getOption(QLatin1String("Browser/EnableImages")).toBool());
		enableImagesAction->setData(QLatin1String("Browser/EnableImages"));

		QAction *enableJavaScriptAction = menu.addAction(tr("Enable JavaScript"));
		enableJavaScriptAction->setCheckable(true);
		enableJavaScriptAction->setChecked(m_webWidget->getOption(QLatin1String("Browser/EnableJavaScript")).toBool());
		enableJavaScriptAction->setData(QLatin1String("Browser/EnableJavaScript"));

		QAction *enableJavaAction = menu.addAction(tr("Enable Java"));
		enableJavaAction->setCheckable(true);
		enableJavaAction->setChecked(m_webWidget->getOption(QLatin1String("Browser/EnableJava")).toBool());
		enableJavaAction->setData(QLatin1String("Browser/EnableJava"));

		QAction *enablePluginsAction = menu.addAction(tr("Enable Plugins"));
		enablePluginsAction->setCheckable(true);
		enablePluginsAction->setChecked(m_webWidget->getOption(QLatin1String("Browser/EnablePlugins")).toString() == QLatin1String("enabled"));
		enablePluginsAction->setData(QLatin1String("Browser/EnablePlugins"));

		menu.addSeparator();

		QAction *enableCookiesAction = menu.addAction(tr("Enable Cookies"));
		enableCookiesAction->setCheckable(true);
		enableCookiesAction->setEnabled(false);

		QAction *enableReferrerAction = menu.addAction(tr("Enable Referrer"));
		enableReferrerAction->setCheckable(true);
		enableReferrerAction->setEnabled(false);

		QAction *enableProxyAction = menu.addAction(tr("Enable Proxy"));
		enableProxyAction->setCheckable(true);
		enableProxyAction->setEnabled(false);

		menu.addSeparator();
		menu.addAction(tr("Reset Options"), m_webWidget, SLOT(clearOptions()))->setEnabled(!m_webWidget->getOptions().isEmpty());
		menu.addSeparator();
		menu.addAction(ActionsManager::getAction(WebsitePreferencesAction, parent()));

		QAction *triggeredAction = menu.exec(QCursor::pos());

		if (triggeredAction && triggeredAction->data().isValid())
		{
			if (triggeredAction->data().toString() == QLatin1String("Browser/EnablePlugins"))
			{
				m_webWidget->setOption(QLatin1String("Browser/EnablePlugins"), (triggeredAction->isChecked() ? QLatin1String("enabled") : QLatin1String("disabled")));
			}
			else
			{
				m_webWidget->setOption(triggeredAction->data().toString(), triggeredAction->isChecked());
			}
		}

		m_isTabPreferencesMenuVisible = false;
	}
	else if (action == ActivateWebpageAction)
	{
		m_webWidget->setFocus();
	}
	else
	{
		m_webWidget->triggerAction(action, checked);
	}
}
示例#9
0
ComboBox::~ComboBox()
{
  clearOptions();
  if (dropdown)
    dropdown->close();
}