예제 #1
0
void WebWidget::quickSearch(QAction *action)
{
	const SearchInformation engine = SearchesManager::getSearchEngine((!action || action->data().type() != QVariant::String) ? QString() : action->data().toString());

	if (engine.identifier.isEmpty())
	{
		return;
	}

	if (engine.identifier != m_options.value(QLatin1String("Search/DefaultQuickSearchEngine")).toString())
	{
		setOption(QLatin1String("Search/DefaultQuickSearchEngine"), engine.identifier);
	}

	const OpenHints hints = WindowsManager::calculateOpenHints();

	if (hints == CurrentTabOpen)
	{
		search(getSelectedText(), engine.identifier);
	}
	else
	{
		emit requestedSearch(getSelectedText(), engine.identifier, hints);
	}
}
예제 #2
0
	void TextField::copy()
	{
		if(getSelectionLength() > 0)
		{
			Clipboard::copy(getSelectedText());
		}
	}
예제 #3
0
파일: chatlog.cpp 프로젝트: BiTOk/qTox
void ChatLog::copySelectedText(bool toSelectionBuffer) const
{
    QString text = getSelectedText();
    QClipboard* clipboard = QApplication::clipboard();

    if (clipboard && !text.isNull())
        clipboard->setText(text, toSelectionBuffer ? QClipboard::Selection : QClipboard::Clipboard);
}
예제 #4
0
void CodeEditor::deleteRight(bool word)
{
    if(getSelectedText().length()!=0)
        clearSelection();
    else
    {
        moveRight(word,true);
        clearSelection();
    }
    updateCursorXPos();
    updateHorizontalScrollBarPos();
}
예제 #5
0
//鼠标钩子过程
//bool isruning=false;
LRESULT CALLBACK mouseProc(int nCode,WPARAM wParam,LPARAM lParam ){

    // qDebug()<<"hello hook"<<nCode<<"wParam"<<wParam;
    if (nCode>=0)
    {
        //        if(isruning){
        //            qDebug()<<"鼠标钩子重入了。。。。。。。。。。。。。。。";
        //            return 1;
        //        }
        //isruning=true;
        if(wParam==WM_LBUTTONDOWN){
            sct.restart();
            downPos=QCursor::pos();

        }
        if(wParam==WM_LBUTTONUP){//can't get WM_LBUTTONDBLCLK,so let's code
            // qDebug()<<"single clicked time"<<sct.elapsed()<<"double clicked time"<<dct.elapsed();;
            if(sct.elapsed()<CLKINTERVAL){
                if(dct.elapsed()<DBLCLKINTERVAL){
                    //qDebug("double click");
                    getSelectedText();
                }
                dct.restart();
            }else{
                upPos=QCursor::pos();
                //qDebug()<<upPos.x()-downPos.x()<<upPos.y()-downPos.y();
                if(qAbs(upPos.x()-downPos.x())>6||qAbs(upPos.y()-downPos.y())>10){
                    //qDebug("mouse move");
                    getSelectedText();
                }
            }
        }
        // isruning=false;

    }
    // 传给系统中的下一个钩子
    return CallNextHookEx(NULL, nCode, wParam, lParam);

}
void FGTextList::setSelection(Int32 iPos)
{
   const char *lpszVar;

   if ((iPos >= -1) && (iPos < textList.size()))
   {
      selectedCell.y = iPos;

      if ((lpszVar = getSelectedText()) != NULL)
      {
         setVariable(lpszVar);
      }

      setUpdate();
   }
}
예제 #7
0
void CodeEditor::copySelection()
{
    qApp->clipboard()->setText(getSelectedText());
}
예제 #8
0
파일: notice.c 프로젝트: andersk/zephyr
char *
decode_notice(ZNotice_t *notice,
	      char *hostname)
{
    char *temp;
    string when, notyear, year, date_string, time_string;

    /*
     * Convert useful notice fields to ascii and store away in
     * description language variables for later use by the
     * the user's program:
     */
    var_set_variable("zephyr_version", notice->z_version);
    var_set_variable("class", notice->z_class);
    var_set_variable("instance", notice->z_class_inst);
    var_set_variable("opcode", notice->z_opcode);
    var_set_variable("default", notice->z_default_format);
    var_set_variable("notice_charset", (char *)ZCharsetToString(notice->z_charset)); /*XXX const*/
    var_set_variable("recipient",
		     (notice->z_recipient[0] ? notice->z_recipient : "*"));
    var_set_variable("fullsender", notice->z_sender);
    var_set_variable_to_number("port", (int)ntohs(notice->z_port));
    var_set_variable_then_free_value("kind", z_kind_to_ascii(notice->z_kind));
    var_set_variable_then_free_value("auth", z_auth_to_ascii(notice->z_auth));

#ifdef CMU_ZWGCPLUS
    if ((temp=getSelectedText()) != 0)
	var_set_variable("selection", temp);
    
    var_set_variable("delete_window", "none");
    var_set_variable("event_time", "none");
    var_set_variable("event_name", "event");
#endif
    /*
     * Set $sender to the name of the notice sender except first strip off the
     * realm name if it is the local realm:
     */
    if ( (temp=strchr(notice->z_sender,'@')) && string_Eq(temp+1, ZGetRealm()) )
      var_set_variable_then_free_value("sender",
				string_CreateFromData(notice->z_sender,
						      temp-notice->z_sender));
    else
      var_set_variable("sender", notice->z_sender);
#ifdef CMU_ZWGCPLUS
    if (get_full_names) {
      struct passwd *pwnam = getpwnam(var_get_variable("sender"));
      if (pwnam) {
        temp = string_Copy(pwnam->pw_gecos);
        var_set_variable_then_free_value("sendername", temp);
      } else {
        var_set_variable("sendername", "unknown");
      }
    }
#endif
    
    /*
     * Convert time & date notice was sent to ascii.  The $time
     * has the format "01:03:52" while $date has the format
     * "Sun Sep 16 1973".
     */
    {
      /* the fields of struct timeval might not be the right type to pass
	 to ctime, so use a temporary */
      time_t sec = notice->z_time.tv_sec;
      when = ctime(&sec);
    }
    time_string = string_CreateFromData(when+11,8);
    var_set_variable_then_free_value("time", time_string);
    date_string = string_Concat(notyear=string_CreateFromData(when,11),
				year=string_CreateFromData(when+20,4));
    var_set_variable_then_free_value("date", date_string);
    free(notyear);
    free(year);

    /*
     * Convert host notice sent from to ascii:
     */
    var_set_variable("fromhost", hostname ? hostname :
		     inet_ntoa(notice->z_sender_addr));

    /*
     * Set $message to the message field of the notice with nulls changed
     * to newlines:
     */
    var_set_variable_then_free_value("message",
		     convert_nulls_to_newlines(notice->z_message,
					       notice->z_message_len));

    /*
     * Decide if its a control notice.  If so, return the notice's
     * opcode.  Otherwise, return NULL:
     */
    if ((strcasecmp(notice->z_class, WG_CTL_CLASS)==0) && /* <<<>>> */
	(strcasecmp(notice->z_class_inst, WG_CTL_USER)==0))
      return(notice->z_opcode);
    return(0);
}
예제 #9
0
const char *GuiTextListCtrl::getScriptValue()
{
   return getSelectedText();
}
예제 #10
0
void WebWidget::updateEditActions()
{
	const bool canPaste = (QApplication::clipboard()->mimeData() && QApplication::clipboard()->mimeData()->hasText());
	const bool hasSelection = (this->hasSelection() && !getSelectedText().trimmed().isEmpty());

	if (m_actions.contains(ActionsManager::CutAction))
	{
		m_actions[ActionsManager::CutAction]->setEnabled(hasSelection && m_hitResult.flags.testFlag(IsContentEditableTest));
	}

	if (m_actions.contains(ActionsManager::CopyAction))
	{
		m_actions[ActionsManager::CopyAction]->setEnabled(hasSelection);
	}

	if (m_actions.contains(ActionsManager::CopyPlainTextAction))
	{
		m_actions[ActionsManager::CopyPlainTextAction]->setEnabled(hasSelection);
	}

	if (m_actions.contains(ActionsManager::CopyToNoteAction))
	{
		m_actions[ActionsManager::CopyToNoteAction]->setEnabled(hasSelection);
	}

	if (m_actions.contains(ActionsManager::PasteAction))
	{
		m_actions[ActionsManager::PasteAction]->setEnabled(canPaste && m_hitResult.flags.testFlag(IsContentEditableTest));
	}

	if (m_actions.contains(ActionsManager::PasteAndGoAction))
	{
		m_actions[ActionsManager::PasteAndGoAction]->setEnabled(canPaste);
	}

	if (m_actions.contains(ActionsManager::PasteNoteAction))
	{
		m_actions[ActionsManager::PasteNoteAction]->setEnabled(canPaste && m_hitResult.flags.testFlag(IsContentEditableTest) && NotesManager::getModel()->getRootItem()->hasChildren());
	}

	if (m_actions.contains(ActionsManager::DeleteAction))
	{
		m_actions[ActionsManager::DeleteAction]->setEnabled(m_hitResult.flags.testFlag(IsContentEditableTest) && !m_hitResult.flags.testFlag(IsEmptyTest));
	}

	if (m_actions.contains(ActionsManager::SelectAllAction))
	{
		m_actions[ActionsManager::SelectAllAction]->setEnabled(!m_hitResult.flags.testFlag(IsEmptyTest));
	}

	if (m_actions.contains(ActionsManager::ClearAllAction))
	{
		m_actions[ActionsManager::ClearAllAction]->setEnabled(m_hitResult.flags.testFlag(IsContentEditableTest) && !m_hitResult.flags.testFlag(IsEmptyTest));
	}

	if (m_actions.contains(ActionsManager::SearchAction))
	{
		const SearchInformation engine = SearchesManager::getSearchEngine(getOption(QLatin1String("Search/DefaultQuickSearchEngine")).toString());
		const bool isValid = !engine.identifier.isEmpty();

		m_actions[ActionsManager::SearchAction]->setEnabled(isValid);
		m_actions[ActionsManager::SearchAction]->setData(isValid ? engine.identifier : QVariant());
		m_actions[ActionsManager::SearchAction]->setIcon((!isValid || engine.icon.isNull()) ? Utils::getIcon(QLatin1String("edit-find")) : engine.icon);
		m_actions[ActionsManager::SearchAction]->setOverrideText(isValid ? engine.title : QT_TRANSLATE_NOOP("actions", "Search"));
		m_actions[ActionsManager::SearchAction]->setToolTip(isValid ? engine.description : tr("No search engines defined"));
	}

	if (m_actions.contains(ActionsManager::SearchMenuAction))
	{
		m_actions[ActionsManager::SearchMenuAction]->setEnabled(SearchesManager::getSearchEngines().count() > 1);
	}

	updateLinkActions();
	updateFrameActions();
	updateImageActions();
	updateMediaActions();
}
예제 #11
0
void WebWidget::showContextMenu(const QPoint &position)
{
	m_contextMenuReason = QContextMenuEvent::Other;

	const bool hasSelection = (this->hasSelection() && !getSelectedText().trimmed().isEmpty());

	if (m_ignoreContextMenu || (position.isNull() && (!hasSelection || m_clickPosition.isNull())))
	{
		return;
	}

	const QPoint hitPosition = (position.isNull() ? m_clickPosition : position);

	if (isScrollBar(hitPosition) || (SettingsManager::getValue(QLatin1String("Browser/JavaScriptCanDisableContextMenu")).toBool() && !canShowContextMenu(hitPosition)))
	{
		return;
	}

	updateHitTestResult(hitPosition);
	updateEditActions();

	QStringList flags;

	if (m_hitResult.flags.testFlag(IsFormTest))
	{
		flags.append(QLatin1String("form"));
	}

	if (!m_hitResult.imageUrl.isValid() && m_hitResult.flags.testFlag(IsSelectedTest) && hasSelection)
	{
		flags.append(QLatin1String("selection"));
	}

	if (m_hitResult.linkUrl.isValid())
	{
		if (m_hitResult.linkUrl.scheme() == QLatin1String("mailto"))
		{
			flags.append(QLatin1String("mail"));
		}
		else
		{
			flags.append(QLatin1String("link"));
		}
	}

	if (!m_hitResult.imageUrl.isEmpty())
	{
		flags.append(QLatin1String("image"));
	}

	if (m_hitResult.mediaUrl.isValid())
	{
		flags.append(QLatin1String("media"));
	}

	if (m_hitResult.flags.testFlag(IsContentEditableTest))
	{
		flags.append(QLatin1String("edit"));
	}

	if (flags.isEmpty() || (flags.size() == 1 && flags.first() == QLatin1String("form")))
	{
		flags.append(QLatin1String("standard"));

		if (m_hitResult.frameUrl.isValid())
		{
			flags.append(QLatin1String("frame"));
		}
	}

	if (flags.isEmpty())
	{
		return;
	}

	Menu menu(Menu::NoMenuRole, this);
	menu.load(QLatin1String("menu/webWidget.json"), flags);
	menu.exec(mapToGlobal(hitPosition));
}