Exemplo n.º 1
0
void ItemLabel::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
	QTextCursor myCursor = this->textCursor();
	if (textInteractionFlags() == Qt::NoTextInteraction)
	{
		//QPoint p = this->textCursor()->pos();
		setTextInteractionFlags(Qt::TextEditorInteraction);//|Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse|Qt::TextEditable);
		setTextInteractionFlags(Qt::TextEditable);	
		
		//myCursor->setCursorMoveStyle;
	    //cursor.movePosition(QTextCursor::Start);

		//setTextInteractionFlags(Qt::TextEditable);	
		//this->cursor().setS
		//QTextCursor tt = ;  
		//this->setMQt::LogicalMoveStyle.
		//this->textCursor()->setTabChangesFocus(true);
		//this->cursor().setCursorMoveStyle();
		//this->textCursor().setPos(p);				
	}
	/*myCursor.setKeepPositionOnInsert(true);	
	bool flag = myCursor.keepPositionOnInsert();
	bool mflag = myCursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, 1);*/
	QGraphicsTextItem::mouseDoubleClickEvent(event);
	//myCursor.setPosition(10, QTextCursor::MoveAnchor);
	return;
}
Exemplo n.º 2
0
void Label::setTextInteraction(bool on, bool selectAll)
{
    if(on && textInteractionFlags() == Qt::NoTextInteraction)
       {
           // switch on editor mode:
        qDebug() << textInteractionFlags();
           setTextInteractionFlags(Qt::TextEditorInteraction);
           qDebug() << textInteractionFlags();

           // manually do what a mouse click would do else:
           setFocus(Qt::MouseFocusReason); // this gives the item keyboard focus
           setSelected(true); // this ensures that itemChange() gets called when we click out of the item
           if(selectAll) // option to select the whole text (e.g. after creation of the TextItem)
           {
               QTextCursor c = textCursor();
               c.select(QTextCursor::Document);
               setTextCursor(c);
           }
       }
       else if(!on && textInteractionFlags() == Qt::TextEditorInteraction)
       {
           // turn off editor mode:
           setTextInteractionFlags(Qt::NoTextInteraction);
           // deselect text (else it keeps gray shade):
           QTextCursor c = this->textCursor();
           c.clearSelection();
           this->setTextCursor(c);
           clearFocus();
       }
   }
Exemplo n.º 3
0
void ElementTitle::startTextInteraction()
{
	parentItem()->setSelected(true);

	// Already interacting?
	if (hasFocus())
		return;

	mOldText = toPlainText();

	// Clear scene selection
	//if (!(event->modifiers() & Qt::ControlModifier)) - was here.
	scene()->clearSelection();

	if (mReadOnly)
		setTextInteractionFlags(Qt::TextBrowserInteraction);
	else
		setTextInteractionFlags(Qt::TextEditorInteraction);
	setFocus(Qt::OtherFocusReason);

	// Set full text selection
	QTextCursor cursor = QTextCursor(document());
	cursor.select(QTextCursor::Document);
	setTextCursor(cursor);
	setCursor(Qt::IBeamCursor);
}
Exemplo n.º 4
0
QVariant UBGraphicsTextItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
    if (QGraphicsItem::ItemSelectedChange == change)
    {
        bool selected = value.toBool();

        if (selected)
        {
            setTextInteractionFlags(Qt::TextEditorInteraction);
        }
        else
        {
            QTextCursor tc = textCursor();
            tc.clearSelection();
            setTextCursor(tc);
            setTextInteractionFlags(Qt::NoTextInteraction);
        }
    }

    QVariant newValue = value;

    if(mDelegate)
        newValue = mDelegate->itemChange(change, value);

    return QGraphicsTextItem::itemChange(change, newValue);
}
Exemplo n.º 5
0
void
FormText::enableEditing( bool on )
{
	if( on )
		setTextInteractionFlags( Qt::TextEditorInteraction );
	else
		setTextInteractionFlags( Qt::NoTextInteraction );
}
Exemplo n.º 6
0
void GaduEditAccountWidget::createGeneralTab(QTabWidget *tabWidget)
{
	QWidget *generalTab = new QWidget(this);

	QGridLayout *layout = new QGridLayout(generalTab);
	QWidget *form = new QWidget(generalTab);
	layout->addWidget(form, 0, 0);

	QFormLayout *formLayout = new QFormLayout(form);

	AccountId = new QLineEdit(this);
	AccountId->setValidator(createOwnedGaduIdValidator(AccountId).get());
	connect(AccountId, SIGNAL(textEdited(QString)), this, SLOT(dataChanged()));
	formLayout->addRow(tr("Gadu-Gadu number") + ':', AccountId);

	AccountPassword = new QLineEdit(this);
	AccountPassword->setEchoMode(QLineEdit::Password);
	connect(AccountPassword, SIGNAL(textEdited(QString)), this, SLOT(dataChanged()));
	formLayout->addRow(tr("Password") + ':', AccountPassword);

	RememberPassword = new QCheckBox(tr("Remember password"), this);
	RememberPassword->setChecked(true);
	connect(RememberPassword, SIGNAL(clicked()), this, SLOT(dataChanged()));
	formLayout->addRow(0, RememberPassword);

	auto remindUinLabel = new QLabel(QString("<a href='change'>%1</a>").arg(tr("Remind GG number")));
	remindUinLabel->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard | Qt::LinksAccessibleByMouse);
	formLayout->addRow(0, remindUinLabel);
	connect(remindUinLabel, SIGNAL(linkActivated(QString)), this, SLOT(remindUin()));

	auto remindPasswordLabel = new QLabel(QString("<a href='change'>%1</a>").arg(tr("Remind Password")));
	remindPasswordLabel->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard | Qt::LinksAccessibleByMouse);
	formLayout->addRow(0, remindPasswordLabel);
	connect(remindPasswordLabel, SIGNAL(linkActivated(QString)), this, SLOT(remindPassword()));

	Identities = m_pluginInjectedFactory->makeInjected<IdentitiesComboBox>(this);
	connect(Identities, SIGNAL(currentIndexChanged(int)), this, SLOT(dataChanged()));
	formLayout->addRow(tr("Account Identity") + ':', Identities);

	QLabel *infoLabel = new QLabel(tr("<font size='-1'><i>Select or enter the identity that will be associated with this account.</i></font>"), this);
	infoLabel->setWordWrap(true);
	infoLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
	infoLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
	formLayout->addRow(0, infoLabel);

	AccountAvatarWidget *avatarWidget = m_pluginInjectedFactory->makeInjected<AccountAvatarWidget>(account(), this);
	layout->addWidget(avatarWidget, 0, 1, Qt::AlignTop);

	tabWidget->addTab(generalTab, tr("General"));
}
Exemplo n.º 7
0
void TupTextItem::setEditable(bool editable)
{
    m_isEditable = editable;
    
    if (editable) {
        m_flags = flags(); // save flags
        setTextInteractionFlags(Qt::TextEditorInteraction);
        setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
        setFocus(Qt::MouseFocusReason);
    } else {
        setTextInteractionFlags(Qt::TextBrowserInteraction);
        setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable); // restore flags
    }
    update();
}
Exemplo n.º 8
0
void GraphNodeText::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
    if(textInteractionFlags() == Qt::NoTextInteraction)
        setTextInteractionFlags(Qt::TextEditable | Qt::TextSelectableByKeyboard);

    QGraphicsTextItem::mouseDoubleClickEvent(event);
}
Exemplo n.º 9
0
ItemData::ItemData(const QModelIndex &index, int maxBytes, QWidget *parent)
    : QLabel(parent)
    , ItemWidget(this)
{
    setTextInteractionFlags(Qt::TextSelectableByMouse);
    setContentsMargins(4, 4, 4, 4);
    setTextFormat(Qt::RichText);

    QString text;

    const QStringList formats = index.data(contentType::formats).toStringList();
    for (int i = 0; i < formats.size(); ++i ) {
        QByteArray data = index.data(contentType::firstFormat + i).toByteArray();
        const int size = data.size();
        bool trimmed = size > maxBytes;
        if (trimmed)
            data = data.left(maxBytes);

        const QString &format = formats[i];
        bool hasText = format.startsWith("text/") ||
                       format.startsWith("application/x-copyq-owner-window-title");
        const QString content = hasText ? escapeHtml(stringFromBytes(data, format)) : hexData(data);
        text.append( QString("<p>") );
        text.append( QString("<b>%1</b> (%2 bytes)<pre>%3</pre>")
                     .arg(format)
                     .arg(size)
                     .arg(content) );
        text.append( QString("</p>") );

        if (trimmed)
            text.append( QString("<p>...</p>") );
    }

    setText(text);
}
Exemplo n.º 10
0
VBoxDbgConsoleOutput::VBoxDbgConsoleOutput(QWidget *pParent/* = NULL*/, const char *pszName/* = NULL*/)
    : QTextEdit(pParent), m_uCurLine(0), m_uCurPos(0), m_hGUIThread(RTThreadNativeSelf())
{
    setReadOnly(true);
    setUndoRedoEnabled(false);
    setOverwriteMode(false);
    setPlainText("");
    setTextInteractionFlags(Qt::TextBrowserInteraction);
    setAutoFormatting(QTextEdit::AutoAll);
    setTabChangesFocus(true);
    setAcceptRichText(false);

    /*
     * Font.
     * Create actions for font menu items.
     */
    m_pCourierFontAction = new QAction(tr("Courier"), this);
    m_pCourierFontAction->setCheckable(true);
    m_pCourierFontAction->setShortcut(Qt::ControlModifier + Qt::Key_D);
    connect(m_pCourierFontAction, SIGNAL(triggered()), this, SLOT(setFontCourier()));

    m_pMonospaceFontAction = new QAction(tr("Monospace"), this);
    m_pMonospaceFontAction->setCheckable(true);
    m_pMonospaceFontAction->setShortcut(Qt::ControlModifier + Qt::Key_M);
    connect(m_pMonospaceFontAction, SIGNAL(triggered()), this, SLOT(setFontMonospace()));

    /* Create action group for grouping of exclusive font menu items. */
    QActionGroup *pActionFontGroup = new QActionGroup(this);
    pActionFontGroup->addAction(m_pCourierFontAction);
    pActionFontGroup->addAction(m_pMonospaceFontAction);
    pActionFontGroup->setExclusive(true);

    /*
     * Color scheme.
     * Create actions for color-scheme menu items.
     */
    m_pGreenOnBlackAction = new QAction(tr("Green On Black"), this);
    m_pGreenOnBlackAction->setCheckable(true);
    m_pGreenOnBlackAction->setShortcut(Qt::ControlModifier + Qt::Key_1);
    connect(m_pGreenOnBlackAction, SIGNAL(triggered()), this, SLOT(setColorGreenOnBlack()));

    m_pBlackOnWhiteAction = new QAction(tr("Black On White"), this);
    m_pBlackOnWhiteAction->setCheckable(true);
    m_pBlackOnWhiteAction->setShortcut(Qt::ControlModifier + Qt::Key_2);
    connect(m_pBlackOnWhiteAction, SIGNAL(triggered()), this, SLOT(setColorBlackOnWhite()));

    /* Create action group for grouping of exclusive color-scheme menu items. */
    QActionGroup *pActionColorGroup = new QActionGroup(this);
    pActionColorGroup->addAction(m_pGreenOnBlackAction);
    pActionColorGroup->addAction(m_pBlackOnWhiteAction);
    pActionColorGroup->setExclusive(true);

    /*
     * Set the defaults (which syncs with the menu item checked state).
     */
    setFontCourier();
    setColorGreenOnBlack();

    NOREF(pszName);
}
Exemplo n.º 11
0
//Reset the console
void pConsole::reset()
{
	clear();
	
	setTextInteractionFlags( Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard | Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard | Qt::TextEditable );
	setUndoRedoEnabled( false );
	setTabStopWidth( 30 );
	
	QFont font = QFont( "Bitstream Vera Sans Mono", 11 );
	font.setBold( true );
	setFont( font );
	
	QPalette pal = viewport()->palette();
	pal.setColor( viewport()->backgroundRole(), QColor( Qt::black ) );
	pal.setColor( viewport()->foregroundRole(), QColor( Qt::white ) );
	viewport()->setPalette( pal );
	
	mColors[ ctCommand ] = Qt::white;
	mColors[ ctError ] = Qt::red;
	mColors[ ctOutput ] = Qt::blue;
	mColors[ ctCompletion ] = Qt::green;
	
	mRecordedScript.clear();
	mTypedCommand.clear();
	
	setHistory( QStringList() );
	setPromptVisible( true );
	setPrompt( "@:/> " );
}
Exemplo n.º 12
0
ChatView::ChatView(const TabSupervisor *_tabSupervisor, TabGame *_game, bool _showTimestamps, QWidget *parent)
    : QTextBrowser(parent), tabSupervisor(_tabSupervisor), game(_game), evenNumber(true), showTimestamps(_showTimestamps), hoveredItemType(HoveredNothing)
{
    document()->setDefaultStyleSheet("a { text-decoration: none; color: blue; }");
    userContextMenu = new UserContextMenu(tabSupervisor, this, game);
    connect(userContextMenu, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
    
    if(tabSupervisor->getUserInfo())
    {
        userName = QString::fromStdString(tabSupervisor->getUserInfo()->name());
        mention = "@" + userName;
    }

    mentionFormat.setFontWeight(QFont::Bold);

    mentionFormatOtherUser.setFontWeight(QFont::Bold);
    mentionFormatOtherUser.setForeground(Qt::blue);
    mentionFormatOtherUser.setAnchor(true);

    viewport()->setCursor(Qt::IBeamCursor);
    setReadOnly(true);
    setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
    setOpenLinks(false);
    connect(this, SIGNAL(anchorClicked(const QUrl &)), this, SLOT(openLink(const QUrl &)));
}
Exemplo n.º 13
0
void LogViewer::init()
{
    setAcceptDrops(true);
    setReadOnly(true);
    setTabWidth(4);
    setLineWrapMode(QPlainTextEdit::NoWrap);
    setTextInteractionFlags(Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse);

    QPalette palette;
    palette.setColor(QPalette::Inactive, QPalette::Highlight, palette.color(QPalette::Active, QPalette::Highlight));
    palette.setColor(QPalette::Inactive, QPalette::HighlightedText, palette.color(QPalette::Active, QPalette::HighlightedText));
    setPalette(palette);

    // Read settings.
    setFont(INIMANAGER()->font());
    setForegroundColor(INIMANAGER()->foregroundColor());
    setBackgroundColor(INIMANAGER()->backgroundColor());
    setCustomBackgroundColor(INIMANAGER()->customBackgroundColor());
    setCurrentLineFgColor(INIMANAGER()->currentLineFgColor());
    setCurrentLineBgColor(INIMANAGER()->currentLineBgColor());

    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(drawCurrentLine()));
    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(blockCountChanged(int)));
    connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));

    // Line Number.
    updateLineNumberAreaWidth(0);
    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
    connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));

    // Keyword Highlighter.
    connect(m_keywordHighlighter, SIGNAL(modelCreated(QStandardItemModel*)), this, SLOT(modelCreated(QStandardItemModel*)));
    connect(m_keywordHighlighter, SIGNAL(chartLoaded(QPixmap*)), this, SLOT(chartLoaded(QPixmap*)));
}
CreditsDialog::CreditsDialog(QWidget *parent) :
    QDialog(parent)
{
    auto mainLayout = new QVBoxLayout();

    auto titleLabel = new QLabel(tr("Credits"), this);
    titleLabel->setObjectName("CreditsDialogTitleLabel");

    auto programmersLabel = new QLabel(tr("Programmers"), this);
    programmersLabel->setObjectName("CreditsDialogProgrammersLabel");

    auto iconsLabel = new QLabel(tr("Icons"), this);
    iconsLabel->setObjectName("CreditsDialogIconsLabel");

    auto icons8LinkLabel = new QLabel("<a href=\"http://icons8.com/\">http://icons8.com/</a>", this);
    icons8LinkLabel->setObjectName("CreditsDialogIcons8LinkLabel");
    icons8LinkLabel->setTextFormat(Qt::RichText);
    icons8LinkLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
    icons8LinkLabel->setOpenExternalLinks(true);

    mainLayout->addWidget(titleLabel);

    mainLayout->addWidget(programmersLabel);

    mainLayout->addWidget(iconsLabel);
    mainLayout->addWidget(icons8LinkLabel);

    this->setLayout(mainLayout);
}
Exemplo n.º 15
0
void LabelItem::focusOutEvent ( QFocusEvent* event ) {
  setTextInteractionFlags ( Qt::NoTextInteraction );
  setFlag ( QGraphicsItem::ItemIsSelectable, false );
  scene()->update();
  emit lostFocus ( this );
  QGraphicsTextItem::focusOutEvent ( event );
}
Exemplo n.º 16
0
void ElementTitle::focusOutEvent(QFocusEvent *event)
{
	QGraphicsTextItem::focusOutEvent(event);

	QString htmlNormalizedText = toHtml().remove("\n", Qt::CaseInsensitive);

	setTextInteractionFlags(Qt::NoTextInteraction);

	parentItem()->setSelected(true);

	// Clear selection
	QTextCursor cursor = textCursor();
	cursor.clearSelection();
	setTextCursor(cursor);

	unsetCursor();

	if (mReadOnly)
		return;

	if (mOldText != toPlainText()) {
		QString value = toPlainText();
		if (mBinding == "name")
			static_cast<NodeElement*>(parentItem())->setName(value);
		else
			static_cast<NodeElement*>(parentItem())->setLogicalProperty(mBinding, value);
	}
	setHtml(htmlNormalizedText);
}
Exemplo n.º 17
0
void UBGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    QColor color = UBSettings::settings()->isDarkBackground() ? mColorOnDarkBackground : mColorOnLightBackground;
    setDefaultTextColor(color);

    // Never draw the rubber band, we draw our custom selection with the DelegateFrame
    QStyleOptionGraphicsItem styleOption = QStyleOptionGraphicsItem(*option);
    styleOption.state &= ~QStyle::State_Selected;
    styleOption.state &= ~QStyle::State_HasFocus;

    QGraphicsTextItem::paint(painter, &styleOption, widget);

    if (widget == UBApplication::boardController->controlView()->viewport() &&
            !isSelected() && toPlainText().isEmpty())
    {
        QFontMetrics fm(font());
        setTextWidth(fm.width(mTypeTextHereLabel));
        painter->setFont(font());
        painter->setPen(UBSettings::paletteColor);
        painter->drawText(boundingRect(), Qt::AlignCenter, mTypeTextHereLabel);
        setTextInteractionFlags(Qt::NoTextInteraction);
    }

    Delegate()->postpaint(painter, option, widget);
}
Exemplo n.º 18
0
eCommentItem::eCommentItem(const QString &text, const QPointF &pos, QGraphicsScene *parentScene) : QGraphicsTextItem(text, eNULL, parentScene)
{
    setPos(pos);
    setTextInteractionFlags(Qt::TextEditorInteraction);
    setDefaultTextColor(Qt::white);
    setFlags(flags() | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
}
Exemplo n.º 19
0
ScriptEditorItem::ScriptEditorItem(ScriptDatum* datum, Canvas* canvas)
    : QGraphicsTextItem("HELLO WORLD"), datum(datum), border(10),
      close(new ScriptEditorCloseButton(this)),
      move(new ScriptEditorMoveButton(this))
{
    QFont font;
    font.setFamily("Courier");
    setFont(font);

    canvas->scene->addItem(this);

    new SyntaxHighlighter(document());
    setDefaultTextColor(Colors::base04);

    setTextInteractionFlags(Qt::TextEditorInteraction);

    connect(document(), SIGNAL(contentsChanged()),
            this, SLOT(onTextChanged()));
    connect(datum, SIGNAL(changed()),
            this, SLOT(onDatumChanged()));
    connect(datum, SIGNAL(destroyed()),
            this, SLOT(deleteLater()));

    onDatumChanged(); // update tooltip and text
    setZValue(3);
}
Exemplo n.º 20
0
ItemData::ItemData(const QModelIndex &index, int maxBytes, QWidget *parent)
    : QLabel(parent)
    , ItemWidget(this)
{
    setTextInteractionFlags(Qt::TextSelectableByMouse);
    setContentsMargins(4, 4, 4, 4);
    setTextFormat(Qt::RichText);

    QString text;

    const QVariantMap data = index.data(contentType::data).toMap();
    foreach ( const QString &format, data.keys() ) {
        QByteArray bytes = data[format].toByteArray();
        const int size = bytes.size();
        bool trimmed = size > maxBytes;
        if (trimmed)
            bytes = bytes.left(maxBytes);

        bool hasText = format.startsWith("text/") ||
                       format.startsWith("application/x-copyq-owner-window-title");
        const QString content = hasText ? escapeHtml(stringFromBytes(bytes, format)) : hexData(bytes);
        text.append( QString("<p>") );
        text.append( QString("<b>%1</b> (%2 bytes)<pre>%3</pre>")
                     .arg(format)
                     .arg(size)
                     .arg(content) );
        text.append( QString("</p>") );

        if (trimmed)
            text.append( QString("<p>...</p>") );
    }

    setText(text);
}
Exemplo n.º 21
0
UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent) :
    QGraphicsTextItem(parent)
    , UBGraphicsItem()
    , mMultiClickState(0)
    , mLastMousePressTime(QTime::currentTime())
{
    setDelegate(new UBGraphicsTextItemDelegate(this, 0));

    // TODO claudio remove this because in contrast with the fact the frame should be created on demand.
    Delegate()->createControls();
    Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
    Delegate()->setUBFlag(GF_FLIPPABLE_ALL_AXIS, false);
    Delegate()->setUBFlag(GF_REVOLVABLE, true);

    mTypeTextHereLabel = tr("<Type Text Here>");

    setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
    setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly


    setFlag(QGraphicsItem::ItemIsSelectable, true);
    setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);

    setTextInteractionFlags(Qt::TextEditorInteraction);

    setUuid(QUuid::createUuid());

    connect(document(), SIGNAL(contentsChanged()), Delegate(), SLOT(contentsChanged()));
    connect(document(), SIGNAL(undoCommandAdded()), this, SLOT(undoCommandAdded()));

    connect(document()->documentLayout(), SIGNAL(documentSizeChanged(const QSizeF &)),
            this, SLOT(documentSizeChanged(const QSizeF &)));

}
Exemplo n.º 22
0
TextResultItem::TextResultItem(QGraphicsObject* parent)
    : WorksheetTextItem(parent), ResultItem()
{
    setTextInteractionFlags(Qt::TextSelectableByMouse);
    connect(this, SIGNAL(removeResult()), parentEntry(),
            SLOT(removeResult()));
}
Exemplo n.º 23
0
DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, QGraphicsScene *scene)
    : QGraphicsTextItem(parent /*, scene*/)
{
    setFlag(QGraphicsItem::ItemIsMovable, false);
    setFlag(QGraphicsItem::ItemIsSelectable, false);
    setTextInteractionFlags(Qt::NoTextInteraction);
}
Exemplo n.º 24
0
int QLabel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QFrame::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 12)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 12;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = text(); break;
        case 1: *reinterpret_cast< Qt::TextFormat*>(_v) = textFormat(); break;
        case 2: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(pixmap())); break;
        case 3: *reinterpret_cast< bool*>(_v) = hasScaledContents(); break;
        case 4: *reinterpret_cast< Qt::Alignment*>(_v) = alignment(); break;
        case 5: *reinterpret_cast< bool*>(_v) = wordWrap(); break;
        case 6: *reinterpret_cast< int*>(_v) = margin(); break;
        case 7: *reinterpret_cast< int*>(_v) = indent(); break;
        case 8: *reinterpret_cast< bool*>(_v) = openExternalLinks(); break;
        case 9: *reinterpret_cast< Qt::TextInteractionFlags*>(_v) = textInteractionFlags(); break;
        case 10: *reinterpret_cast< bool*>(_v) = hasSelectedText(); break;
        case 11: *reinterpret_cast< QString*>(_v) = selectedText(); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setText(*reinterpret_cast< QString*>(_v)); break;
        case 1: setTextFormat(*reinterpret_cast< Qt::TextFormat*>(_v)); break;
        case 2: setPixmap(*reinterpret_cast< QPixmap*>(_v)); break;
        case 3: setScaledContents(*reinterpret_cast< bool*>(_v)); break;
        case 4: setAlignment(*reinterpret_cast< Qt::Alignment*>(_v)); break;
        case 5: setWordWrap(*reinterpret_cast< bool*>(_v)); break;
        case 6: setMargin(*reinterpret_cast< int*>(_v)); break;
        case 7: setIndent(*reinterpret_cast< int*>(_v)); break;
        case 8: setOpenExternalLinks(*reinterpret_cast< bool*>(_v)); break;
        case 9: setTextInteractionFlags(*reinterpret_cast< Qt::TextInteractionFlags*>(_v)); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 12;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemplo n.º 25
0
ChatView::ChatView(const QString &_ownName, bool _showTimestamps, QWidget *parent)
    : QTextBrowser(parent), evenNumber(true), ownName(_ownName), showTimestamps(_showTimestamps)
{
    setReadOnly(true);
    setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
    setOpenLinks(false);
    connect(this, SIGNAL(anchorClicked(const QUrl &)), this, SLOT(openLink(const QUrl &)));
}
Exemplo n.º 26
0
MySimpleTextItem::MySimpleTextItem(const QString & text, QGraphicsItem * parent)
		: QGraphicsTextItem(text, parent){
	//Since this does not inherits from MyCentralGraphicsItem, I have to set the flags here
	setFlag(QGraphicsItem::ItemIsMovable, true);
	setFlag(QGraphicsItem::ItemIsSelectable,true);
	
	setTextInteractionFlags(Qt::TextEditable | Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse);
}
Exemplo n.º 27
0
 explicit DataItem( const QString& text, const QUrl& url ) 
 :m_url(url),
  m_text(text)
 {
     setOpenExternalLinks( true );
     setTextInteractionFlags( Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse );
     QString ss = qobject_cast<unicorn::Application*>(qApp)->loadedStyleSheet();
     setText( "<style>" + ss + "</style><a href=\"" + url.toString() + "\">" + text + "</a>" );
 }
Exemplo n.º 28
0
GLabel::GLabel(QWidget *parent, GLabel::PEOPLE f)
    : QLabel(parent)
    , people(f)
    , parent_maxwidth(((QWidget*)this->parent())->width())
{
    init();
    setTextInteractionFlags(Qt::TextSelectableByMouse);//设置鼠标可以选择标志
    connect(this, SIGNAL(clicked()), this, SLOT(onDetailClicked()));
}
Exemplo n.º 29
0
ClientTextEdit::ClientTextEdit(QWidget* parent) : QTextEdit(parent) {
    setReadOnly(true);
    setOverwriteMode(true);
    setUndoRedoEnabled(false);
    setDocumentTitle("mClient");
    setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
    setTabChangesFocus(false);

    //_doc->setMaximumBlockCount(Config().scrollbackSize); // max number of lines?
    document()->setUndoRedoEnabled(false);
    QTextFrame* frame = document()->rootFrame();
    _cursor = frame->firstCursorPosition();

    // Default Colors
    _foregroundColor = Qt::lightGray;
    _backgroundColor = Qt::black;
    _blackColor = Qt::darkGray;
    _redColor = Qt::darkRed;
    _greenColor = Qt::darkGreen;
    _yellowColor = Qt::darkYellow;
    _blueColor = Qt::darkBlue;
    _magentaColor = Qt::darkMagenta;
    _cyanColor = Qt::darkCyan;
    _grayColor = Qt::lightGray;
    _darkGrayColor = Qt::gray;
    _brightRedColor = Qt::red;
    _brightGreenColor = Qt::green;
    _brightYellowColor = Qt::yellow;
    _brightBlueColor = Qt::blue;
    _brightMagentaColor = Qt::magenta;
    _brightCyanColor = Qt::cyan;
    _whiteColor = Qt::white;
    // Default Fonts
    _serverOutputFont = QFont("Monospace", 10);
    _inputLineFont = QFont("Monospace", 10); //QApplication::font();
    _serverOutputFont.setStyleHint(QFont::TypeWriter, QFont::PreferAntialias);

    QTextFrameFormat frameFormat = frame->frameFormat();
    frameFormat.setBackground(_backgroundColor);
    frameFormat.setForeground(_foregroundColor);
    frame->setFrameFormat(frameFormat);

    _format = _cursor.charFormat();
    setDefaultFormat(_format);
    _defaultFormat = _format;
    _cursor.setCharFormat(_format);

    QFontMetrics fm(_serverOutputFont);
    setTabStopWidth(fm.width(" ") * 8); // A tab is 8 spaces wide
    QScrollBar* scrollbar = verticalScrollBar();
    scrollbar->setSingleStep(fm.leading()+fm.height());

    connect(scrollbar, SIGNAL(sliderReleased()), 
                this, SLOT(scrollBarReleased()));

    previous = 0;
}
Exemplo n.º 30
0
ChatView::ChatView(const QString &_ownName, QWidget *parent)
	: QTextEdit(parent), ownName(_ownName)
{
	setTextInteractionFlags(Qt::TextSelectableByMouse);
	
	QTextTableFormat format;
	format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
	table = textCursor().insertTable(1, 3, format);
}