コード例 #1
0
ファイル: guiutil.cpp プロジェクト: hrtrftrtwqh/coz
HelpMessageBox::HelpMessageBox(QWidget *parent) :
    QMessageBox(parent)
{
    header = tr("Whistle-Qt") + " " + tr("version") + " " +
             QString::fromStdString(FormatFullVersion()) + "\n\n" +
             tr("Usage:") + "\n" +
             "  Whistle-qt [" + tr("command-line options") + "]                     " + "\n";

    coreOptions = QString::fromStdString(HelpMessage());

    uiOptions = tr("UI options") + ":\n" +
                "  -lang=<lang>           " + tr("Set language, for example \"de_DE\" (default: system locale)") + "\n" +
                "  -min                   " + tr("Start minimized") + "\n" +
                "  -splash                " + tr("Show splash screen on startup (default: 1)") + "\n";

    setWindowTitle(tr("Whistle-Qt"));
    setTextFormat(Qt::PlainText);
    // setMinimumWidth is ignored for QMessageBox so put in non-breaking spaces to make it wider.
    setText(header + QString(QChar(0x2003)).repeated(50));
    setDetailedText(coreOptions + "\n" + uiOptions);
}
コード例 #2
0
ファイル: guiutil.cpp プロジェクト: birty/net2
HelpMessageBox::HelpMessageBox(QWidget *parent) :
    QMessageBox(parent)
{
    setStyleSheet("background: url(:/images/res/images/dialogBackground.jpg); background-attachment: fixed; color: #ffaa00; selection-background-color: rgb(255, 170, 0, 145); selection-color: white; font-family: Plantagenet Cherokee; font-size: 14px;");
    header = tr("Netcoin-Qt") + " " + tr("version") + " " +
        QString::fromStdString(FormatFullVersion()) + "\n\n" +
        tr("Usage:") + "\n" +
        "  netcoin-qt [" + tr("command-line options") + "]                     " + "\n";

    coreOptions = QString::fromStdString(HelpMessage());

    uiOptions = tr("UI options") + ":\n" +
        "  -lang=<lang>           " + tr("Set language, for example \"de_DE\" (default: system locale)") + "\n" +
        "  -min                   " + tr("Start minimized") + "\n" +
        "  -splash                " + tr("Show splash screen on startup (default: 1)") + "\n";

    setWindowTitle(tr("Netcoin-Qt"));
    setTextFormat(Qt::PlainText);
    // setMinimumWidth is ignored for QMessageBox so put in non-breaking spaces to make it wider.
    setText(header + QString(QChar(0x2003)).repeated(50));
    setDetailedText(coreOptions + "\n" + uiOptions);
}
コード例 #3
0
ファイル: locationbar.cpp プロジェクト: Jose41/qupzilla
void LocationBar::refreshTextFormat()
{
    if (!m_webView) {
        return;
    }

    TextFormat textFormat;
    const QString hostName = m_webView->url().isEmpty() ? QUrl(text()).host() : m_webView->url().host();

    if (!hostName.isEmpty()) {
        const int hostPos = text().indexOf(hostName);

        if (hostPos > 0) {
            QTextCharFormat format;
            format.setForeground(Colors::mid(palette().color(QPalette::Base), palette().color(QPalette::Text), 1, 1));

            QTextLayout::FormatRange schemePart;
            schemePart.start = 0;
            schemePart.length = hostPos;
            schemePart.format = format;

            QTextLayout::FormatRange hostPart;
            hostPart.start = hostPos;
            hostPart.length = hostName.size();

            QTextLayout::FormatRange remainingPart;
            remainingPart.start = hostPos + hostName.size();
            remainingPart.length = text().size() - remainingPart.start;
            remainingPart.format = format;

            textFormat.append(schemePart);
            textFormat.append(hostPart);
            textFormat.append(remainingPart);
        }
    }

    setTextFormat(textFormat);
}
コード例 #4
0
ファイル: qeditor.C プロジェクト: Federico2014/edg4x-rose
QEditor::QEditor( QWidget* parent, const char* name )
    : Q3TextEdit( parent, name )
{
	getDocument()->setUseFormatCollection( FALSE );

    parenMatcher = new ParenMatcher();

    m_currentLine = -1;

    getDocument()->addSelection( ParenMatcher::Match );
    getDocument()->addSelection( ParenMatcher::Mismatch );
    getDocument()->setSelectionColor( ParenMatcher::Match, QColor( 204, 232, 195 ) );
    getDocument()->setSelectionColor( ParenMatcher::Mismatch, Qt::magenta );
    //document()->setInvertSelectionText( ParenMatcher::Match, FALSE );
    //document()->setInvertSelectionText( ParenMatcher::Mismatch, FALSE );

    getDocument()->addSelection( sel0 );
    getDocument()->setSelectionColor( sel0, QColor( 204, 232, 195 ) );

    getDocument()->addSelection( sel1 );
    getDocument()->setSelectionColor( sel1, QColor( 204, 207, 255 ) );

    setLanguage("c++");

    setTabStop(2);

    setWordWrap(Q3TextEdit::NoWrap);
    setTextFormat(Qt::PlainText);



    //connect( this, SIGNAL(cursorPositionChanged(QTextCursor*) ),
	//     this, SLOT(doMatch(QTextCursor*)) );
//    connect( this, SIGNAL(cursorPositionChanged(int, int) ),
//	     this, SLOT(slotCursorPositionChanged(int, int)) );

}
コード例 #5
0
CvsProcessWidget::CvsProcessWidget( CvsService_stub *service, CvsServicePart *part, QWidget *parent, const char *name )
    : DCOPObject( "CvsProcessWidgetDCOPIface" ),
    QTextEdit( parent, name ),
	m_part( part ), m_service( service ), m_job( 0 )
{
    setReadOnly( true );
    setTextFormat( Qt::LogText );

    QStyleSheetItem *style = 0;
    style = new QStyleSheetItem( styleSheet(), "goodtag" );
    style->setColor( "black" );

    style = new QStyleSheetItem( styleSheet(), "errortag" );
    style->setColor( "red" );
    style->setFontWeight( QFont::Bold );

    style = new QStyleSheetItem( styleSheet(), "infotag" );
    style->setColor( "blue" );

    style = new QStyleSheetItem( styleSheet(), "cvs_conflict" );
    style->setColor( "red" );

    style = new QStyleSheetItem( styleSheet(), "cvs_added" );
    style->setColor( "green" );

    style = new QStyleSheetItem( styleSheet(), "cvs_removed" );
    style->setColor( "yellow" );

    style = new QStyleSheetItem( styleSheet(), "cvs_updated" );
    style->setColor( "lightblue" );

    style = new QStyleSheetItem( styleSheet(), "cvs_modified" );
    style->setColor( "darkgreen" );

    style = new QStyleSheetItem( styleSheet(), "cvs_unknown" );
    style->setColor( "gray" );
}
コード例 #6
0
ファイル: SIDlg.cpp プロジェクト: shooshx/happysolver
void GameWidget::endGame()
{
    if (m_score >= m_scores.last().score)
    {
        QString name = QInputDialog::getText(this, "Happy Cube Space Invaders!", 
            "<b style=\"font-size:24pt\">What is your name ?!");
        m_scores.append(Score(name, m_score));
        qSort(m_scores);
        m_scores.removeLast();
        saveScores();
    }

    setTextFormat(Qt::RichText);
    setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

    QString msg("<font face=\"Courier\"><b style=\"font-size:72pt\">Game Over!</b><br><b style=\"font-size:24pt\">");
    for (TScoreList::const_iterator it = m_scores.constBegin(); it != m_scores.constEnd(); ++it)
    {
        msg += QString("%1.......%2<br>").arg(it->name, -22, '.').arg(humanCount(it->score).c_str(), 13, QChar('.'));
    }
    msg += "</font>";

    setText(msg);
}
コード例 #7
0
ファイル: qgsfontbutton.cpp プロジェクト: cz172638/QGIS
void QgsFontButton::dropEvent( QDropEvent *e )
{
  //is dropped data valid format data?
  QColor mimeColor;
  QgsTextFormat format;
  QFont font;
  bool hasAlpha = false;
  if ( mMode == ModeTextRenderer && formatFromMimeData( e->mimeData(), format ) )
  {
    setTextFormat( format );
    QgsFontUtils::addRecentFontFamily( mFormat.font().family() );
    return;
  }
  else if ( mMode == ModeQFont && fontFromMimeData( e->mimeData(), font ) )
  {
    QgsFontUtils::addRecentFontFamily( font.family() );
    setCurrentFont( font );
    return;
  }
  else if ( mMode == ModeTextRenderer && colorFromMimeData( e->mimeData(), mimeColor, hasAlpha ) )
  {
    //accept drop and set new color
    e->acceptProposedAction();

    if ( hasAlpha )
    {
      mFormat.setOpacity( mimeColor.alphaF() );
    }
    mimeColor.setAlphaF( 1.0 );
    mFormat.setColor( mimeColor );
    QgsRecentColorScheme::addRecentColor( mimeColor );
    updatePreview();
    emit changed();
  }
  updatePreview();
}
コード例 #8
0
ファイル: QtElidingLabel.cpp プロジェクト: smuralireddy/swift
QtElidingLabel::QtElidingLabel(const QString& text, QWidget* parent, Qt::WindowFlags f) : QLabel(text, parent, f) {
    fullText_ = text;
    dirty_ = true;
    setSizes();
    setTextFormat(Qt::PlainText);
}
コード例 #9
0
ファイル: SkLabel.cpp プロジェクト: fb/startkladde
void SkLabel::setText (const QString &text, Qt::TextFormat format)
{
	setTextFormat (format);
	setText (text);
}
コード例 #10
0
int QDeclarativeText::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDeclarativeImplicitSizeItem::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 17)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 17;
    }
#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< QFont*>(_v) = font(); break;
        case 2: *reinterpret_cast< QColor*>(_v) = color(); break;
        case 3: *reinterpret_cast< TextStyle*>(_v) = style(); break;
        case 4: *reinterpret_cast< QColor*>(_v) = styleColor(); break;
        case 5: *reinterpret_cast< HAlignment*>(_v) = hAlign(); break;
        case 6: *reinterpret_cast< VAlignment*>(_v) = vAlign(); break;
        case 7: *reinterpret_cast< WrapMode*>(_v) = wrapMode(); break;
        case 8: *reinterpret_cast< int*>(_v) = lineCount(); break;
        case 9: *reinterpret_cast< bool*>(_v) = truncated(); break;
        case 10: *reinterpret_cast< int*>(_v) = maximumLineCount(); break;
        case 11: *reinterpret_cast< TextFormat*>(_v) = textFormat(); break;
        case 12: *reinterpret_cast< TextElideMode*>(_v) = elideMode(); break;
        case 13: *reinterpret_cast< qreal*>(_v) = paintedWidth(); break;
        case 14: *reinterpret_cast< qreal*>(_v) = paintedHeight(); break;
        case 15: *reinterpret_cast< qreal*>(_v) = lineHeight(); break;
        case 16: *reinterpret_cast< LineHeightMode*>(_v) = lineHeightMode(); break;
        }
        _id -= 17;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setText(*reinterpret_cast< QString*>(_v)); break;
        case 1: setFont(*reinterpret_cast< QFont*>(_v)); break;
        case 2: setColor(*reinterpret_cast< QColor*>(_v)); break;
        case 3: setStyle(*reinterpret_cast< TextStyle*>(_v)); break;
        case 4: setStyleColor(*reinterpret_cast< QColor*>(_v)); break;
        case 5: setHAlign(*reinterpret_cast< HAlignment*>(_v)); break;
        case 6: setVAlign(*reinterpret_cast< VAlignment*>(_v)); break;
        case 7: setWrapMode(*reinterpret_cast< WrapMode*>(_v)); break;
        case 10: setMaximumLineCount(*reinterpret_cast< int*>(_v)); break;
        case 11: setTextFormat(*reinterpret_cast< TextFormat*>(_v)); break;
        case 12: setElideMode(*reinterpret_cast< TextElideMode*>(_v)); break;
        case 15: setLineHeight(*reinterpret_cast< qreal*>(_v)); break;
        case 16: setLineHeightMode(*reinterpret_cast< LineHeightMode*>(_v)); break;
        }
        _id -= 17;
    } else if (_c == QMetaObject::ResetProperty) {
        switch (_id) {
        case 5: resetHAlign(); break;
        case 10: resetMaximumLineCount(); break;
        }
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 17;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
コード例 #11
0
ScriptEdit::ScriptEdit(ScriptingEnv *env, QWidget *parent, const char *name)
  : QTextEdit(parent, name), scripted(env), d_error(false), d_completer(0),
  d_file_name(QString::null), d_search_string(QString::null)
{
	myScript = scriptEnv->newScript("", this, name);
	connect(myScript, SIGNAL(error(const QString&, const QString&, int)), this, SLOT(insertErrorMsg(const QString&)));
	connect(myScript, SIGNAL(print(const QString&)), this, SLOT(scriptPrint(const QString&)));

	setLineWrapMode(NoWrap);
	setUndoRedoEnabled(true);
	setTextFormat(Qt::PlainText);
	setAcceptRichText (false);

#ifdef SCRIPTING_PYTHON
	if (scriptEnv->name() == QString("Python"))
		d_highlighter = new PythonSyntaxHighlighter(this);
	else
		d_highlighter = NULL;
#endif

	d_fmt_default.setBackground(palette().brush(QPalette::Base));

	printCursor = textCursor();
	scriptsDirPath = qApp->applicationDirPath();

	actionExecute = new QAction(tr("E&xecute"), this);
	actionExecute->setShortcut( tr("Ctrl+J") );
	connect(actionExecute, SIGNAL(activated()), this, SLOT(execute()));

	actionExecuteAll = new QAction(tr("Execute &All"), this);
	actionExecuteAll->setShortcut( tr("Ctrl+Shift+J") );
	connect(actionExecuteAll, SIGNAL(activated()), this, SLOT(executeAll()));

	actionEval = new QAction(tr("&Evaluate Expression"), this);
	actionEval->setShortcut( tr("Ctrl+Return") );
	connect(actionEval, SIGNAL(activated()), this, SLOT(evaluate()));

	actionPrint = new QAction(QPixmap(fileprint_xpm), tr("&Print"), this);
	connect(actionPrint, SIGNAL(activated()), this, SLOT(print()));

	actionImport = new QAction(tr("&Import..."), this);
	actionImport->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_O));
	connect(actionImport, SIGNAL(activated()), this, SLOT(importASCII()));

	QShortcut *accelImport = new QShortcut(actionImport->shortcut(), this);
	connect(accelImport, SIGNAL(activated()), this, SLOT(importASCII()));

	actionSave = new QAction(QPixmap(filesave_xpm), tr("&Save"), this);
	actionSave->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_S));
	connect(actionSave, SIGNAL(activated()), this, SLOT(save()));

	QShortcut *accelSave = new QShortcut(actionSave->shortcut(), this);
	connect(accelSave, SIGNAL(activated()), this, SLOT(save()));

	actionExport = new QAction(QIcon(QPixmap(filesaveas_xpm)), tr("Sa&ve as..."), this);
	connect(actionExport, SIGNAL(activated()), this, SLOT(exportASCII()));

	actionFind = new QAction(QPixmap(find_xpm), tr("&Find..."), this);
	actionFind->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_F));
	connect(actionFind, SIGNAL(activated()), this, SLOT(showFindDialog()));

	QShortcut *accelFind = new QShortcut(actionFind->shortcut(), this);
	connect(accelFind, SIGNAL(activated()), this, SLOT(showFindDialog()));

	actionReplace = new QAction(tr("&Replace..."), this);
	actionReplace->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_R));
	connect(actionReplace, SIGNAL(activated()), this, SLOT(replace()));

	QShortcut *accelReplace = new QShortcut(actionReplace->shortcut(), this);
	connect(accelReplace, SIGNAL(activated()), this, SLOT(replace()));

	actionFindNext = new QAction(tr("&Find next"), this);
	actionFindNext->setShortcut(QKeySequence(Qt::Key_F3));
	connect(actionFindNext, SIGNAL(activated()), this, SLOT(findNext()));

	QShortcut *accelFindNext = new QShortcut(actionFindNext->shortcut(), this);
	connect(accelFindNext, SIGNAL(activated()), this, SLOT(findNext()));

	actionFindPrevious = new QAction(tr("&Find previous"), this);
	actionFindPrevious->setShortcut(QKeySequence(Qt::Key_F4));
	connect(actionFindPrevious, SIGNAL(activated()), this, SLOT(findPrevious()));

	QShortcut *accelFindPrevious = new QShortcut(actionFindPrevious->shortcut(), this);
	connect(accelFindPrevious, SIGNAL(activated()), this, SLOT(findPrevious()));

	functionsMenu = new QMenu(this);
	Q_CHECK_PTR(functionsMenu);
	connect(functionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(insertFunction(QAction *)));
}
コード例 #12
0
void TableDialog::apply()
{
    if (colName->text().contains("_")){
        QMessageBox::warning(this, tr("MantidPlot - Warning"),
        tr("For internal consistency reasons the underscore character is replaced with a minus sign."));}

    QString name=colName->text().replace("-", "_");
    if (name.contains(QRegExp("\\W"))){
        QMessageBox::warning(this,tr("MantidPlot - Error"), tr("The column names must only contain letters and digits!"));
        name.remove(QRegExp("\\W"));
	}

    int sc = d_table->selectedColumn();
    d_table->setColumnWidth(colWidth->value(), applyToAllBox->isChecked());
    d_table->setColComment(sc, comments->text().replace("\n", " ").replace("\t", " "));
    d_table->setColName(sc, name.replace("_", "-"), enumerateAllBox->isChecked());

    bool rightColumns = applyToRightCols->isChecked();
    if (rightColumns){
        bool readOnly = boxReadOnly->isChecked();
		for (int i = sc; i<d_table->numCols(); i++){
            d_table->setReadOnlyColumn(i, readOnly);
			d_table->hideColumn(i, boxHideColumn->isChecked());
		}
    } else {
        d_table->setReadOnlyColumn(sc, boxReadOnly->isChecked());
		d_table->hideColumn(sc, boxHideColumn->isChecked());
	}

    int format = formatBox->currentIndex();
    int colType = displayBox->currentIndex();
    switch(colType)
	{
	case 0:
		setNumericFormat(formatBox->currentIndex(), precisionBox->value(), rightColumns);
	break;

	case 1:
		setTextFormat(rightColumns);
	break;

	case 2:
		 setDateTimeFormat(colType, formatBox->currentText(), rightColumns);
	break;

	case 3:
		setDateTimeFormat(colType, formatBox->currentText(), rightColumns);
	break;

	case 4:
        if(format == 0)
            setMonthFormat("MMM", rightColumns);
        else if(format == 1)
            setMonthFormat("MMMM", rightColumns);
        else if(format == 2)
            setMonthFormat("M", rightColumns);
	break;

	case 5:
        if(format == 0)
            setDayFormat("ddd", rightColumns);
        else if(format == 1)
            setDayFormat("dddd", rightColumns);
        else if(format == 2)
            setDayFormat("d", rightColumns);
	break;
	}
}
コード例 #13
0
ファイル: ScriptEdit.cpp プロジェクト: chaoqing/qtiplot
ScriptEdit::ScriptEdit(ScriptingEnv *env, QWidget *parent, const char *name)
  : QTextEdit(parent, name), scripted(env), d_error(false), d_completer(0), d_highlighter(0),
  d_file_name(QString::null), d_search_string(QString::null), d_output_widget(NULL)
{
	myScript = scriptEnv->newScript("", this, name);
	connect(myScript, SIGNAL(error(const QString&, const QString&, int)), this, SLOT(insertErrorMsg(const QString&)));
	connect(myScript, SIGNAL(print(const QString&)), this, SLOT(scriptPrint(const QString&)));
	connect(myScript, SIGNAL(error(const QString&, const QString&, int)),
			this, SIGNAL(error(const QString&, const QString&, int)));

	setLineWrapMode(NoWrap);
	setUndoRedoEnabled(true);
	setTextFormat(Qt::PlainText);
	setAcceptRichText (false);
	setFocusPolicy(Qt::StrongFocus);

	rehighlight();

	d_fmt_default.setBackground(palette().brush(QPalette::Base));

	//Init completer based on parser built-in functions
	QStringList functions = MyParser::functionNamesList();
	functions.sort();
	QCompleter *completer = new QCompleter(this);
	completer->setModelSorting(QCompleter::CaseSensitivelySortedModel);
	completer->setCompletionMode(QCompleter::PopupCompletion);
	completer->setModel(new QStringListModel(functions, completer));
	setCompleter(completer);

	printCursor = textCursor();
	scriptsDirPath = qApp->applicationDirPath();

	actionExecute = new QAction(tr("E&xecute"), this);
	actionExecute->setShortcut( tr("Ctrl+J") );
	connect(actionExecute, SIGNAL(activated()), this, SLOT(execute()));

	actionExecuteAll = new QAction(QIcon(":/play.png"), tr("Execute &All"), this);
	actionExecuteAll->setShortcut( tr("Ctrl+Shift+J") );
	connect(actionExecuteAll, SIGNAL(activated()), this, SLOT(executeAll()));

	actionEval = new QAction(tr("&Evaluate Expression"), this);
	actionEval->setShortcut( tr("Ctrl+Return") );
	connect(actionEval, SIGNAL(activated()), this, SLOT(evaluate()));

	actionPrint = new QAction(QIcon(":/fileprint.png"), tr("&Print"), this);
	connect(actionPrint, SIGNAL(activated()), this, SLOT(print()));

	actionImport = new QAction(QIcon(":/fileopen.png"), tr("&Import..."), this);
	actionImport->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_O));
	connect(actionImport, SIGNAL(activated()), this, SLOT(importASCII()));

	actionSave = new QAction(QIcon(":/filesave.png"), tr("&Save"), this);
	actionSave->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_S));
	connect(actionSave, SIGNAL(activated()), this, SLOT(save()));

	actionExport = new QAction(QIcon(":/filesaveas.png"), tr("Sa&ve as..."), this);
	connect(actionExport, SIGNAL(activated()), this, SLOT(exportASCII()));

	actionFind = new QAction(QIcon(":/find.png"), tr("&Find..."), this);
	actionFind->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_F));
	connect(actionFind, SIGNAL(activated()), this, SLOT(showFindDialog()));

	actionReplace = new QAction(QIcon(":/replace.png"), tr("&Replace..."), this);
	actionReplace->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_R));
	connect(actionReplace, SIGNAL(activated()), this, SLOT(replace()));

	actionFindNext = new QAction(QIcon(":/find_next.png"), tr("&Find next"), this);
	actionFindNext->setShortcut(QKeySequence(Qt::Key_F3));
	connect(actionFindNext, SIGNAL(activated()), this, SLOT(findNext()));

	actionFindPrevious = new QAction(QIcon(":/find_previous.png"), tr("&Find previous"), this);
	actionFindPrevious->setShortcut(QKeySequence(Qt::Key_F4));
	connect(actionFindPrevious, SIGNAL(activated()), this, SLOT(findPrevious()));

	functionsMenu = new QMenu(this);
	Q_CHECK_PTR(functionsMenu);
	connect(functionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(insertFunction(QAction *)));

	connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(matchParentheses()));
}
コード例 #14
0
ファイル: QtElidingLabel.cpp プロジェクト: smuralireddy/swift
QtElidingLabel::QtElidingLabel(QWidget* parent, Qt::WindowFlags f) : QLabel(parent, f) {
    fullText_ = "";
    dirty_ = true;
    setSizes();
    setTextFormat(Qt::PlainText);
}
コード例 #15
0
OptionsDialogHeader::OptionsDialogHeader(const QString &ACaption, QWidget *AParent) : QLabel(AParent)
{
	setTextFormat(Qt::RichText);
	setText(QString("<h2>%1</h2>").arg(ACaption.toHtmlEscaped()));
}
コード例 #16
0
TextShow::TextShow(QWidget *p, const char *name)
        : QTextEdit(p, name)
{
    setTextFormat(RichText);
    setReadOnly(true);
}
コード例 #17
0
ファイル: qgsfontbutton.cpp プロジェクト: cz172638/QGIS
void QgsFontButton::prepareMenu()
{
  //we need to tear down and rebuild this menu every time it is shown. Otherwise the space allocated to any
  //QgsColorSwatchGridAction is not recalculated by Qt and the swatch grid may not be the correct size
  //for the number of colors shown in the grid. Note that we MUST refresh color swatch grids every time this
  //menu is opened, otherwise color schemes like the recent color scheme grid are meaningless
  mMenu->clear();


  QWidgetAction *sizeAction = new QWidgetAction( mMenu );
  QWidget *sizeWidget = new QWidget();
  QVBoxLayout *sizeLayout = new QVBoxLayout();
  sizeLayout->setMargin( 0 );
  sizeLayout->setContentsMargins( 0, 0, 0, 3 );
  sizeLayout->setSpacing( 2 );

  QString fontHeaderLabel;
  switch ( mMode )
  {
    case ModeTextRenderer:
      fontHeaderLabel = tr( "Font size (%1)" ).arg( QgsUnitTypes::toString( mFormat.sizeUnit() ) );
      break;

    case ModeQFont:
      fontHeaderLabel = tr( "Font size (pt)" );
      break;
  }

  QgsMenuHeader *sizeLabel = new QgsMenuHeader( fontHeaderLabel );
  sizeLayout->addWidget( sizeLabel );

  QgsDoubleSpinBox *sizeSpin = new QgsDoubleSpinBox( nullptr );
  sizeSpin->setDecimals( 4 );
  sizeSpin->setMaximum( 1e+9 );
  sizeSpin->setShowClearButton( false );
  sizeSpin->setValue( mMode == ModeTextRenderer ? mFormat.size() : mFont.pointSizeF() );
  connect( sizeSpin, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ),
           this, [ = ]( double value )
  {
    switch ( mMode )
    {
      case ModeTextRenderer:
        mFormat.setSize( value );
        break;
      case ModeQFont:
        mFont.setPointSizeF( value );
        break;
    }
    updatePreview();
    emit changed();
  } );
  QHBoxLayout *spinLayout = new QHBoxLayout();
  spinLayout->setMargin( 0 );
  spinLayout->setContentsMargins( 4, 0, 4, 0 );
  spinLayout->addWidget( sizeSpin );
  sizeLayout->addLayout( spinLayout );
  sizeWidget->setLayout( sizeLayout );
  sizeAction->setDefaultWidget( sizeWidget );
  sizeWidget->setFocusProxy( sizeSpin );
  sizeWidget->setFocusPolicy( Qt::StrongFocus );
  mMenu->addAction( sizeAction );

  QMenu *recentFontMenu = new QMenu( tr( "Recent fonts" ), mMenu );
  Q_FOREACH ( const QString &family, QgsFontUtils::recentFontFamilies() )
  {
    QAction *fontAction = new QAction( family, recentFontMenu );
    QFont f = fontAction->font();
    f.setFamily( family );
    fontAction->setFont( f );
    fontAction->setToolTip( family );
    recentFontMenu->addAction( fontAction );
    if ( ( mMode == ModeTextRenderer && family == mFormat.font().family() )
         || ( mMode == ModeQFont && family == mFont.family() ) )
    {
      fontAction->setCheckable( true );
      fontAction->setChecked( true );
    }
    auto setFont = [this, family]
    {
      switch ( mMode )
      {
        case ModeTextRenderer:
        {
          QgsTextFormat newFormat = mFormat;
          QFont f = newFormat.font();
          f.setFamily( family );
          newFormat.setFont( f );
          setTextFormat( newFormat );
          QgsFontUtils::addRecentFontFamily( mFormat.font().family() );
          break;
        }
        case ModeQFont:
        {
          QFont font = mFont;
          font.setFamily( family );
          setCurrentFont( font );
          QgsFontUtils::addRecentFontFamily( family );
          break;
        }
      }
    };
    connect( fontAction, &QAction::triggered, this, setFont );
  }
コード例 #18
0
int QDeclarativeTextEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDeclarativeImplicitSizePaintedItem::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 47)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 47;
    }
#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< QColor*>(_v) = color(); break;
        case 2: *reinterpret_cast< QColor*>(_v) = selectionColor(); break;
        case 3: *reinterpret_cast< QColor*>(_v) = selectedTextColor(); break;
        case 4: *reinterpret_cast< QFont*>(_v) = font(); break;
        case 5: *reinterpret_cast< HAlignment*>(_v) = hAlign(); break;
        case 6: *reinterpret_cast< VAlignment*>(_v) = vAlign(); break;
        case 7: *reinterpret_cast< WrapMode*>(_v) = wrapMode(); break;
        case 8: *reinterpret_cast< int*>(_v) = lineCount(); break;
        case 9: *reinterpret_cast< qreal*>(_v) = paintedWidth(); break;
        case 10: *reinterpret_cast< qreal*>(_v) = paintedHeight(); break;
        case 11: *reinterpret_cast< TextFormat*>(_v) = textFormat(); break;
        case 12: *reinterpret_cast< bool*>(_v) = isReadOnly(); break;
        case 13: *reinterpret_cast< bool*>(_v) = isCursorVisible(); break;
        case 14: *reinterpret_cast< int*>(_v) = cursorPosition(); break;
        case 15: *reinterpret_cast< QRect*>(_v) = cursorRectangle(); break;
        case 16: *reinterpret_cast< QDeclarativeComponent**>(_v) = cursorDelegate(); break;
        case 17: *reinterpret_cast< int*>(_v) = selectionStart(); break;
        case 18: *reinterpret_cast< int*>(_v) = selectionEnd(); break;
        case 19: *reinterpret_cast< QString*>(_v) = selectedText(); break;
        case 20: *reinterpret_cast< bool*>(_v) = focusOnPress(); break;
        case 21: *reinterpret_cast< bool*>(_v) = persistentSelection(); break;
        case 22: *reinterpret_cast< qreal*>(_v) = textMargin(); break;
        case 23: *reinterpret_cast< Qt::InputMethodHints*>(_v) = inputMethodHints(); break;
        case 24: *reinterpret_cast< bool*>(_v) = selectByMouse(); break;
        case 25: *reinterpret_cast< SelectionMode*>(_v) = mouseSelectionMode(); break;
        case 26: *reinterpret_cast< bool*>(_v) = canPaste(); break;
        case 27: *reinterpret_cast< bool*>(_v) = isInputMethodComposing(); break;
        }
        _id -= 28;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setText(*reinterpret_cast< QString*>(_v)); break;
        case 1: setColor(*reinterpret_cast< QColor*>(_v)); break;
        case 2: setSelectionColor(*reinterpret_cast< QColor*>(_v)); break;
        case 3: setSelectedTextColor(*reinterpret_cast< QColor*>(_v)); break;
        case 4: setFont(*reinterpret_cast< QFont*>(_v)); break;
        case 5: setHAlign(*reinterpret_cast< HAlignment*>(_v)); break;
        case 6: setVAlign(*reinterpret_cast< VAlignment*>(_v)); break;
        case 7: setWrapMode(*reinterpret_cast< WrapMode*>(_v)); break;
        case 11: setTextFormat(*reinterpret_cast< TextFormat*>(_v)); break;
        case 12: setReadOnly(*reinterpret_cast< bool*>(_v)); break;
        case 13: setCursorVisible(*reinterpret_cast< bool*>(_v)); break;
        case 14: setCursorPosition(*reinterpret_cast< int*>(_v)); break;
        case 16: setCursorDelegate(*reinterpret_cast< QDeclarativeComponent**>(_v)); break;
        case 20: setFocusOnPress(*reinterpret_cast< bool*>(_v)); break;
        case 21: setPersistentSelection(*reinterpret_cast< bool*>(_v)); break;
        case 22: setTextMargin(*reinterpret_cast< qreal*>(_v)); break;
        case 23: setInputMethodHints(*reinterpret_cast< Qt::InputMethodHints*>(_v)); break;
        case 24: setSelectByMouse(*reinterpret_cast< bool*>(_v)); break;
        case 25: setMouseSelectionMode(*reinterpret_cast< SelectionMode*>(_v)); break;
        }
        _id -= 28;
    } else if (_c == QMetaObject::ResetProperty) {
        switch (_id) {
        case 5: resetHAlign(); break;
        }
        _id -= 28;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 28;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 28;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 28;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 28;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 28;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
コード例 #19
0
QMultiLineEdit::QMultiLineEdit( QWidget *parent , const char *name )
    : QTextEdit( parent, name )
{
    d = new QMultiLineEditData;
    setTextFormat( Qt::PlainText );
}
コード例 #20
0
TextEdit::TextEdit( QWidget *parent, const char *name )
    : QTextEdit( parent, name )
{
    setTextFormat( Qt::PlainText );
}