Example #1
0
void MsgSMS::init()
{
    if (lineEdit()->text().isEmpty()){
        setFocus();
        return;
    }
    m_edit->m_edit->setFocus();
}
Example #2
0
void PosEdit::stepBy(int steps)
{
    int segment = curSegment();
    int selPos;
    int selLen;

    bool changed = false;

    int bar, beat, tick;
    _pos.mbt(&bar, &beat, &tick);

    int tb = sigmap.ticksBeat(_pos.tick());
    unsigned tm = sigmap.ticksMeasure(_pos.tick());
    int bm = tm / tb;

    switch (segment)
    {
    case 0:
        bar += steps;
        if (bar < 0)
            bar = 0;
        selPos = 0;
        selLen = 4;
        break;
    case 1:
        beat += steps;
        if (beat < 0)
            beat = 0;
        else if (beat >= bm)
            beat = bm - 1;
        selPos = 5;
        selLen = 2;
        break;
    case 2:
        tick += steps;
        if (tick < 0)
            tick = 0;
        else if (tick >= tb)
            tick = tb - 1;
        selPos = 8;
        selLen = 3;
        break;
    default:
        return;
    }
    Pos newPos(bar, beat, tick);
    if (!(newPos == _pos))
    {
        changed = true;
        _pos = newPos;
    }
    if (changed)
    {
        updateValue();
        emit valueChanged(_pos);
    }
    lineEdit()->setSelection(selPos, selLen);
}
AddressWidget::AddressWidget(Window *window, QWidget *parent) : QComboBox(parent),
    m_window(NULL),
    m_completer(new QCompleter(AddressCompletionModel::getInstance(), this)),
    m_bookmarkLabel(NULL),
    m_feedsLabel(NULL),
    m_loadPluginsLabel(NULL),
    m_urlIconLabel(NULL),
    m_removeModelTimer(0),
    m_isHistoryDropdownEnabled(SettingsManager::getValue(QLatin1String("AddressField/EnableHistoryDropdown")).toBool()),
    m_isUsingSimpleMode(false),
    m_wasPopupVisible(false)
{
    m_completer->setCaseSensitivity(Qt::CaseInsensitive);
    m_completer->setCompletionMode(QCompleter::InlineCompletion);
    m_completer->setCompletionRole(Qt::DisplayRole);
    m_completer->setFilterMode(Qt::MatchStartsWith);

    setEditable(true);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    setMinimumWidth(100);
    setItemDelegate(new AddressDelegate(this));
    setInsertPolicy(QComboBox::NoInsert);
    setWindow(window);

    lineEdit()->setCompleter(m_completer);
    lineEdit()->setStyleSheet(QLatin1String("QLineEdit {background:transparent;}"));
    lineEdit()->setMouseTracking(true);
    lineEdit()->installEventFilter(this);

    ToolBarWidget *toolBar = qobject_cast<ToolBarWidget*>(parent);

    if (toolBar)
    {
        optionChanged(QLatin1String("AddressField/ShowBookmarkIcon"), SettingsManager::getValue(QLatin1String("AddressField/ShowBookmarkIcon")));
        optionChanged(QLatin1String("AddressField/ShowUrlIcon"), SettingsManager::getValue(QLatin1String("AddressField/ShowUrlIcon")));

        lineEdit()->setPlaceholderText(tr("Enter address or search…"));

        connect(SettingsManager::getInstance(), SIGNAL(valueChanged(QString,QVariant)), this, SLOT(optionChanged(QString,QVariant)));

        if (toolBar->getIdentifier() != ToolBarsManager::NavigationBar)
        {
            connect(toolBar, SIGNAL(windowChanged(Window*)), this, SLOT(setWindow(Window*)));
        }
    }
Example #4
0
QString QAccessibleLineEdit::textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType,
        int *startOffset, int *endOffset) const
{
    if (lineEdit()->echoMode() != QLineEdit::Normal) {
        *startOffset = *endOffset = -1;
        return QString();
    }
    return QAccessibleTextInterface::textAtOffset(offset, boundaryType, startOffset, endOffset);
}
Example #5
0
std::string DateField::createJS(DomElement *inContainer)
{
  std::stringstream result;
  result << elVar() << " = new Ext.form.DateField(" << configStruct() << ");";

  applyToWidget(lineEdit(), result, inContainer);

  return result.str();
}
/*
    ToolbarSearch is a very basic search widget that also contains a small history.
    Searches are turned into urls that use Google to perform search
 */
ToolbarSearch::ToolbarSearch(QWidget *parent)
    : SearchLineEdit(parent)
    , m_autosaver(new AutoSaver(this))
    , m_maxSavedSearches(10)
    , m_stringListModel(new QStringListModel(this))
{
    QMenu *m = menu();
    connect(m, SIGNAL(aboutToShow()), this, SLOT(aboutToShowMenu()));
    connect(m, SIGNAL(triggered(QAction*)), this, SLOT(triggeredMenuAction(QAction*)));

    QCompleter *completer = new QCompleter(m_stringListModel, this);
    completer->setCompletionMode(QCompleter::InlineCompletion);
    lineEdit()->setCompleter(completer);

    connect(lineEdit(), SIGNAL(returnPressed()), SLOT(searchNow()));
    setInactiveText(tr("Google"));
    load();
}
void WindowSelectComboBox::refreshWindowList()
{
    model()->setData(model()->index(0, 0), lineEdit()->text());

    while (count() > 1) {
        removeItem(1);
    }
    insertItems(1, autoType()->windowTitles());
}
Example #8
0
void SearchComboBox::setSearchStatus(int index, int total) {
	QPalette plt = lineEdit()->palette();
	if ( lineEdit()->text().isEmpty() ) {
		statusL_->setText("");
		plt.setColor(QPalette::Base, QPalette().color(QPalette::Base));
	}
	else {
		statusL_->setText(tr("%1 of %2").arg(index + 1).arg(total));
		
		if ( total == 0 ) {
			plt.setColor(QPalette::Base, QColor(255, 180, 180));
		}
		else {
			plt.setColor(QPalette::Base, QPalette().color(QPalette::Base));
		}
	}
	lineEdit()->setPalette(plt);
}
Example #9
0
void WBSearchLineEdit::paintEvent(QPaintEvent *event)
{
    WBExLineEdit::paintEvent(event);

    if (lineEdit()->text().isEmpty() && !hasFocus() && !mInactiveText.isEmpty())
    {
        QStyleOptionFrameV2 panel;
        initStyleOption(&panel);
        QRect r = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this);
        QFontMetrics fm = fontMetrics();
        int horizontalMargin = lineEdit()->x();
        QRect lineRect(horizontalMargin + r.x(), r.y() + (r.height() - fm.height() + 1) / 2,
                       r.width() - 2 * horizontalMargin, fm.height());
        QPainter painter(this);
        painter.setPen(palette().brush(QPalette::Disabled, QPalette::Text).color());
        painter.drawText(lineRect, Qt::AlignLeft|Qt::AlignVCenter, mInactiveText);
    }
}
Example #10
0
CSpinBox::CSpinBox(QWidget* parent)
    : QAbstractSpinBox(parent), min_value(-100), max_value(100), value(0), base(10), num_digits(0) {
    // TODO: Might be nice to not immediately call the slot.
    //       Think of an address that is being replaced by a different one, in which case a lot
    //       invalid intermediate addresses would be read from during editing.
    connect(lineEdit(), SIGNAL(textEdited(QString)), this, SLOT(OnEditingFinished()));

    UpdateText();
}
Example #11
0
void QgsDateTimeEdit::showEvent( QShowEvent *event )
{
  QDateTimeEdit::showEvent( event );
  if ( mAllowNull && mIsNull &&
       lineEdit()->text() != QgsApplication::nullRepresentation() )
  {
    displayNull();
  }
}
void DoubleSpinBox::interpretText()
{
	bool ok = false;
	double value = locale().toDouble(text(), &ok);
	if (ok && setValue(value))
        emit valueChanged(d_value);
    else
        lineEdit()->setText(textFromValue(d_value));
}
void ToolbarSearch::triggeredMenuAction(QAction *action)
{
    QVariant v = action->data();
    if (v.canConvert<QString>()) {
        QString text = v.toString();
        lineEdit()->setText(text);
        searchNow();
    }
}
Example #14
0
void PosEdit::updateValue()
{
    char buffer[64];
    int bar, beat;
    int tick;
    _pos.mbt(&bar, &beat, &tick);
    sprintf(buffer, "%04d.%02d.%03d", bar + 1, beat + 1, tick);
    lineEdit()->setText(buffer);
}
Example #15
0
void TimestampSpinBox::on_editingFinished()
{
	if (!lineEdit()->isModified())
		return;
	lineEdit()->setModified(false);

	QRegExp re(R"(\s*([-+]?)\s*([0-9]+\.?[0-9]*).*)");

	if (re.exactMatch(text())) {
		QStringList captures = re.capturedTexts();
		captures.removeFirst(); // remove entire match
		QString str = captures.join("");
		setValue(pv::util::Timestamp(str.toStdString()));
	} else {
		// replace the malformed entered string with the old value
		updateEdit();
	}
}
Example #16
0
bool KFileFilterCombo::eventFilter( QObject *o, QEvent *e )
{
    if ( o == lineEdit() && e->type() == QEvent::FocusOut ) {
        if ( currentText() != d->lastFilter )
            emit filterChanged();
    }

    return KComboBox::eventFilter( o, e );
}
Example #17
0
 void stepBy(int steps) {
     if (steps < 0 && (uint32_t)(-1 * steps) > value - minimum)
         value = minimum;
     else if (steps > 0 && maximum - value < (uint32_t)steps)
         value = maximum;
     else
         value += steps;
     lineEdit()->setText(QString::number(value));
 }
void DurationSpinBox::stepBy( int steps )
{
    //kDebug(planDbg())<<steps;
    int cpos = lineEdit()->cursorPosition();
    if ( isOnUnit() ) {
        // we are in unit
        if ( steps > 0 ) {
            stepUnitUp();
        } else if ( steps < 0 ) {
            stepUnitDown();
        }
        lineEdit()->setCursorPosition( cpos );
        return;
    }
    QDoubleSpinBox::stepBy( steps );
    // QDoubleSpinBox selects the whole text and the cursor might end up at the end (in the unit field)
    lineEdit()->setCursorPosition( cpos ); // also deselects
}
void FontSizeSpinBox::setText()
{
    QString text = QString::number(m_value);
    if (isPointSize())
        text.append(" pt");
    else
        text.append(" px");
    lineEdit()->setText(text);

}
Example #20
0
void SpinBox::setReadOnly(bool ro)
{
	if ((int)ro != (int)mReadOnly)
	{
		mReadOnly = ro;
		lineEdit()->setReadOnly(ro);
		if (ro)
			setShiftStepping(false, mCurrentButton);
	}
}
Example #21
0
void DbItemListComboBox::fetchCompleted(const QString &)
{
    removeItem(0);
    WidgetHelper::setComboBoxText(this, currentTxt);
    if(hasSelection){
        lineEdit()->selectAll();
    }

    emit loadingCompleted();
}
Example #22
0
void WindowSelectComboBox::showPopup()
{
    if (lineEdit()->isReadOnly()) {
        return;
    }

    refreshWindowList();

    QComboBox::showPopup();
}
Example #23
0
/// <summary>
/// Constructor that passes parent to the base and sets up height and step.
/// Specific focus policy is used to allow the user to hover over the control
/// and change its value using the mouse wheel without explicitly having to click
/// inside of it.
/// </summary>
/// <param name="p">The parent widget. Default: nullptr.</param>
/// <param name="h">The height of the spin box. Default: 16.</param>
/// <param name="step">The step used to increment/decrement the spin box when using the mouse wheel. Default: 1.</param>
SpinBox::SpinBox(QWidget* p, int h, int step)
	: QSpinBox(p)
{
	m_Select = false;
	m_DoubleClick = false;
	m_DoubleClickNonZero = 0;
	m_DoubleClickZero = 1;
	m_Step = step;
	m_SmallStep = 1;
	setSingleStep(step);
	setFrame(false);
	setButtonSymbols(QAbstractSpinBox::NoButtons);
	setFocusPolicy(Qt::StrongFocus);
	setMinimumHeight(h);//setGeometry() has no effect, so set both of these instead.
	setMaximumHeight(h);
	lineEdit()->installEventFilter(this);
	lineEdit()->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
	connect(this, SIGNAL(valueChanged(int)), this, SLOT(onSpinBoxValueChanged(int)), Qt::QueuedConnection);
}
Example #24
0
void KisDoubleParseSpinBox::setErrorStyle()
{

    if (!boolLastValid) {
        //setStyleSheet(_oldStyleSheet + "Background: red; color: white; padding-left: 18px;");

        if (!isOldPaletteSaved) {
            oldPalette = palette();
        }
        isOldPaletteSaved = true;

        QPalette nP = oldPalette;
        nP.setColor(QPalette::Background, Qt::red);
        nP.setColor(QPalette::Base, Qt::red);
        nP.setColor(QPalette::Text, Qt::white);
        setPalette(nP);

        if (!areOldMarginsSaved) {
            oldMargins = lineEdit()->textMargins();
        }
        areOldMarginsSaved = true;

        if (width() - height() >= 3*height()) { //if we have twice as much place as needed by the warning icon then display it.
            QMargins newMargins = oldMargins;
            newMargins.setLeft( newMargins.left() + height() - 4 );
            lineEdit()->setTextMargins(newMargins);

            int h = warningIcon->height();
            int hp = height()-2;

            if (h != hp) {
                warningIcon->resize(hp, hp);

                if (QFile(":/./16_light_warning.svg").exists()) {
                    warningIcon->setPixmap(QIcon(":/./16_light_warning.svg").pixmap(hp-7, hp-7));
                }
            }

            warningIcon->move(oldMargins.left()+4, 1);
            warningIcon->setVisible(true);
        }
    }
}
Example #25
0
void WBTabWidget::clear()
{
    // clear the recently closed tabs
    mRecentlyClosedTabs.clear();
    // clear the line edit history
    for (int i = 0; i < mLineEdits->count(); ++i) {
        QLineEdit *qLineEdit = lineEdit(i);
        qLineEdit->setText(qLineEdit->text());
    }
}
void VariableDoubleSpinBox::stepBy(int steps)
{
    double oldValue = value();
	
	// Default new value
	int i = -99;
	double newValue = oldValue + singleStep() * steps;

	// If a single digit is selected, increment or decrement that digit
	if (lineEdit()->hasSelectedText())
	{
		if (lineEdit()->selectedText().length() == 1)
		{
			if (lineEdit()->selectedText()[0].isDigit())
			{
				i = cleanText().length() - lineEdit()->selectionStart();
				int j = cleanText().length() - lineEdit()->selectionStart() - decimals();
				if (decimals() > 0)
				{
					j--;
				}
				if (j >= 0)
				{
					j--;
				}
				newValue = oldValue + pow(10.0, j) * steps;
			}
		}
	}

	// Check for out of bounds and set the new value
	if (newValue < minimum())
	{
		return;
	}
	else if (newValue > maximum())
	{
		return;
	}
	setValue(newValue);

	// For unknown reasons, after the new value is set the selected text changes in unpredictable ways
	// Fix it
	if (i == -99)
	{
		lineEdit()->selectAll();
	}
	else
	{
		i = cleanText().length() - i;
		if (i < 0)
		{
			i = 0;
		}
		lineEdit()->setSelection(i, 1);
	}
}
Example #27
0
void ULongLongSpinBox::setValue(qulonglong value)
{
    qulonglong clampedValue = std::min(m_max, std::max(value, m_min));

    if (clampedValue == m_value)
        return;
    
    m_value = clampedValue;
    lineEdit()->setText(textFromValue(m_value));
    emit valueChanged(m_value);
}
Example #28
0
DoubleSpinBox::DoubleSpinBox(const char format, QWidget *parent)
    : QAbstractSpinBox(parent), d_format(format), d_min_val(-DBL_MAX),
      d_max_val(DBL_MAX), d_value(0.0), d_step(0.1), d_prec(14) {
  if (format == 'f')
    d_prec = 1;

  setFocusPolicy(Qt::StrongFocus);
  lineEdit()->setText(locale().toString(d_value, d_format, d_prec));
  setWrapping(false);
  connect(this, SIGNAL(editingFinished()), this, SLOT(interpretText()));
}
Example #29
0
void QgsSpinBox::changeEvent( QEvent *event )
{
  QSpinBox::changeEvent( event );

  if ( event->type() == QEvent::FontChange )
  {
    lineEdit()->setFont( font() );
  }

  mLineEdit->setShowClearButton( shouldShowClearForValue( value() ) );
}
/*
    SearchLineEdit is an enhanced QLineEdit
    - A Search icon on the left with optional menu
    - When there is no text and doesn't have focus an "inactive text" is displayed
    - When there is text a clear button is displayed on the right hand side
 */
SearchLineEdit::SearchLineEdit(QWidget *parent) : ExLineEdit(parent),
    m_searchButton(new SearchButton(this))
{
    connect(lineEdit(), SIGNAL(textChanged(QString)),
            this, SIGNAL(textChanged(QString)));
    setLeftWidget(m_searchButton);
    m_inactiveText = tr("Search");

    QSizePolicy policy = sizePolicy();
    setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy());
}