コード例 #1
0
ファイル: addtagslineedit.cpp プロジェクト: KDE/digikam
AddTagsLineEdit::AddTagsLineEdit(QWidget* const parent)
    : QLineEdit(parent),
      d(new Private)
{
    setClearButtonEnabled(true);

    d->completer = new TagCompleter(this);
    d->completer->setMaxVisibleItems(15);

    setCompleter(d->completer);

    connect(this, SIGNAL(returnPressed()),
            this, SLOT(slotReturnPressed()));

    connect(this, SIGNAL(editingFinished()),
            this, SLOT(slotEditingFinished()));

    connect(this, SIGNAL(textChanged(QString)),
            this, SLOT(slotTextChanged(QString)));

    connect(this, SIGNAL(textEdited(QString)),
            d->completer, SLOT(slotTextEdited(QString)));

    connect(d->completer, static_cast<void(TagCompleter::*)(const TaggingAction&)>(&TagCompleter::activated),
            [this](const TaggingAction& action){ completerActivated(action); });

    connect(d->completer, static_cast<void(TagCompleter::*)(const TaggingAction&)>(&TagCompleter::highlighted),
            [this](const TaggingAction& action){ completerHighlighted(action); });
}
コード例 #2
0
//////////////////////////////////////////////////////////////
/// \brief QQPalmiLineEditInt::QQPalmiLineEditInt
/// \param parent
///
QQPalmiLineEditInt::QQPalmiLineEditInt(QWidget *parent) :
	QLineEdit(parent),
	m_indexInPostHistory(0),
	m_postHistory()
{
	setAttribute(Qt::WA_InputMethodEnabled, true);
#if(QT_VERSION >= QT_VERSION_CHECK(5, 2, 0))
	setClearButtonEnabled(true);
	setStyleSheet(QString("QLineEdit {color: black; background-color: transparent; border: 0px;}"));
#else
	m_clearButton = new QToolButton(this);
	QFontMetrics fMetrics(font());
	QPixmap pixmap = QPixmap(":/img/palmi-clear.png").scaledToHeight(fMetrics.height() + 1);
	m_clearButton->setIcon(QIcon(pixmap));
	m_clearButton->setIconSize(pixmap.size());
	m_clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
	m_clearButton->hide();
	connect(m_clearButton, SIGNAL(clicked()), this, SLOT(clear()));
	connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&)));
	int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
	setStyleSheet(QString("QLineEdit {padding-right: %1px; color: black; background-color: transparent; border: 0px;}").arg(m_clearButton->sizeHint().width() + frameWidth + 1));
#endif

	m_postHistory.enqueue("");
}
コード例 #3
0
repo::gui::RepoLineEdit::RepoLineEdit(QWidget * parent) 
	: QLineEdit(parent)
{
	this->setPlaceholderText(tr("Filter"));
	clearButton = new QToolButton(this);

    // See http://doc.qt.io/qt-5/qstyle.html#StandardPixmap-enum
    clearButton->setIcon(this->style()->standardIcon(QStyle::SP_LineEditClearButton));
//	clearButton->setIcon(RepoFontAwesome::getInstance().getIcon(RepoFontAwesome::fa_ban, QColor(Qt::darkRed)));
	clearButton->setToolTip(tr("Clear"));
	clearButton->setCursor(Qt::ArrowCursor);
    clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");    
    //--------------------------------------------------------------------------
	QObject::connect(
		clearButton, &QToolButton::clicked,
		this, &RepoLineEdit::clear);
	QObject::connect(
		this, &RepoLineEdit::textChanged,
		this, &RepoLineEdit::setClearButtonEnabled);
    //--------------------------------------------------------------------------
	int width = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
	setStyleSheet(QString("QLineEdit { padding-right: %1px; } ").arg(
		clearButton->sizeHint().width() + width + 1));
	QSize sizeHint = minimumSizeHint();
	setMinimumSize(qMax(sizeHint.width(), clearButton->sizeHint().height() + width * 2 + 2),
		qMax(sizeHint.height(), clearButton->sizeHint().height() + width * 2 + 2));
	


	setClearButtonEnabled(this->text());
}
コード例 #4
0
KPropertyStringEditor::KPropertyStringEditor(QWidget *parent)
 : QLineEdit(parent)
 , m_slotTextChangedEnabled(true)
{
    setFrame(false);
    setContentsMargins(0,1,0,0);
    setClearButtonEnabled(true);
    connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(slotTextChanged(const QString&)));
}
コード例 #5
0
ファイル: searchedit.cpp プロジェクト: 0x163mL/zeal
SearchEdit::SearchEdit(QWidget *parent) :
    QLineEdit(parent)
{
    setClearButtonEnabled(true);

    m_completionLabel = new QLabel(this);
    m_completionLabel->setObjectName("completer");
    m_completionLabel->setStyleSheet("QLabel#completer { color: gray; }");
    m_completionLabel->setFont(font());

    connect(this, &SearchEdit::textChanged, this, &SearchEdit::showCompletions);
}
コード例 #6
0
FilterWidget::FilterWidget(QWidget *parent)
    : QLineEdit(parent)
    , m_patternGroup(new QActionGroup(this))
{
    setClearButtonEnabled(true);
    connect(this, SIGNAL(textChanged(QString)), this, SIGNAL(filterChanged()));

    QMenu *menu = new QMenu(this);
    m_caseSensitivityAction = menu->addAction(tr("Case Sensitive"));
    m_caseSensitivityAction->setCheckable(true);
    connect(m_caseSensitivityAction, SIGNAL(toggled(bool)), this, SIGNAL(filterChanged()));

    menu->addSeparator();
    m_patternGroup->setExclusive(true);
    QAction *patternAction = menu->addAction("Fixed String");
    patternAction->setData(QVariant(int(QRegExp::FixedString)));
    patternAction->setCheckable(true);
    patternAction->setChecked(true);
    m_patternGroup->addAction(patternAction);
    patternAction = menu->addAction("Regular Expression");
    patternAction->setCheckable(true);
    patternAction->setData(QVariant(int(QRegExp::RegExp2)));
    m_patternGroup->addAction(patternAction);
    patternAction = menu->addAction("Wildcard");
    patternAction->setCheckable(true);
    patternAction->setData(QVariant(int(QRegExp::Wildcard)));
    m_patternGroup->addAction(patternAction);
    connect(m_patternGroup, SIGNAL(triggered(QAction*)), this, SIGNAL(filterChanged()));

    const QIcon icon = QIcon(QPixmap(":/images/find.png"));
    QToolButton *optionsButton = new QToolButton;
#ifndef QT_NO_CURSOR
    optionsButton->setCursor(Qt::ArrowCursor);
#endif
    optionsButton->setFocusPolicy(Qt::NoFocus);
    optionsButton->setStyleSheet("* { border: none; }");
    optionsButton->setIcon(icon);
    optionsButton->setMenu(menu);
    optionsButton->setPopupMode(QToolButton::InstantPopup);

    QWidgetAction *optionsAction = new QWidgetAction(this);
    optionsAction->setDefaultWidget(optionsButton);
    addAction(optionsAction, QLineEdit::LeadingPosition);
}
コード例 #7
0
ファイル: dkdsearchedit.cpp プロジェクト: PADT/DKD
void DKDSearchEdit::Init()
{
     this->setStyleSheet(
            "  QLineEdit {background-image:url(:/centerwidget/img/centerwidget/20x20_search.png);"
                              "color: gray;"
                              "border-style: outset;"
                              "border-width: 1px;"
                              "border-color: gray;"
                              "background-position: center right;"
                              "background-repeat: no-repeat;"
                              "background-origin: content; }"
            );


    setText("搜索好友...");
    setCursorPosition(0);
    setClearButtonEnabled(false);
    setFocus();
}
コード例 #8
0
FilterLineEdit::FilterLineEdit(QWidget* parent, QList<FilterLineEdit*>* filters, int columnnum) : QLineEdit(parent), filterList(filters), columnNumber(columnnum)
{
    setPlaceholderText(tr("Filter"));
    setClearButtonEnabled(true);
    setProperty("column", columnnum);            // Store the column number for later use

    // Introduce a timer for delaying the signal triggered whenever the user changes the filter value.
    // The idea here is that the textChanged() event isn't connected to the update filter slot directly anymore
    // but instead there this timer mechanism in between: whenever the user changes the filter the delay timer
    // is (re)started. As soon as the user stops typing the timer has a chance to trigger and call the
    // delayedSignalTimerTriggered() method which then stops the timer and emits the delayed signal.
    delaySignalTimer = new QTimer(this);
    delaySignalTimer->setInterval(Settings::getValue("databrowser", "filter_delay").toInt());  // This is the milliseconds of not-typing we want to wait before triggering
    connect(this, SIGNAL(textChanged(QString)), delaySignalTimer, SLOT(start()));
    connect(delaySignalTimer, SIGNAL(timeout()), this, SLOT(delayedSignalTimerTriggered()));

    // Immediately emit the delayed filter value changed signal if the user presses the enter or the return key or
    // the line edit widget loses focus
    connect(this, SIGNAL(editingFinished()), this, SLOT(delayedSignalTimerTriggered()));
}
コード例 #9
0
SearchTextBar::SearchTextBar(QWidget* const parent, const QString& name, const QString& msg)
    : QLineEdit(parent),
      StateSavingObject(this),
      d(new Private)
{
    setAttribute(Qt::WA_DeleteOnClose);
    setClearButtonEnabled(true);
    setPlaceholderText(msg);
    setObjectName(name + QLatin1String(" Search Text Tool"));

    d->completer = new ModelCompleter(this);
    setCompleter(d->completer);

    setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));

    connect(this, SIGNAL(textChanged(QString)),
            this, SLOT(slotTextChanged(QString)));

    loadState();
}
コード例 #10
0
ファイル: dkdsearchedit.cpp プロジェクト: PADT/DKD
void DKDSearchEdit::Searching()
{
    this->setStyleSheet(
        "  QLineEdit {    selection-background-color: rgb(216,209,107);"
                          "background-color: white;"
                          "border-style: outset;"
                          "border-width: 1px;"
                          "border-color: gray;"
                          "padding-left: 2px;"
                          "text-align: left;"
                          "background-position: center right;"
                          "background-repeat: no-repeat;"
                          "background-origin: content; }"
        );

    if(this->text() == "搜索好友...")
    {
        this->clear();
    }

    setClearButtonEnabled(true);
}
コード例 #11
0
FilterLineEdit::FilterLineEdit(QWidget* parent, std::vector<FilterLineEdit*>* filters, size_t columnnum) : QLineEdit(parent), filterList(filters), columnNumber(columnnum)
{
    setPlaceholderText(tr("Filter"));
    setClearButtonEnabled(true);
    setProperty("column", static_cast<int>(columnnum));            // Store the column number for later use

    // Introduce a timer for delaying the signal triggered whenever the user changes the filter value.
    // The idea here is that the textChanged() event isn't connected to the update filter slot directly anymore
    // but instead there this timer mechanism in between: whenever the user changes the filter the delay timer
    // is (re)started. As soon as the user stops typing the timer has a chance to trigger and call the
    // delayedSignalTimerTriggered() method which then stops the timer and emits the delayed signal.
    delaySignalTimer = new QTimer(this);
    delaySignalTimer->setInterval(Settings::getValue("databrowser", "filter_delay").toInt());  // This is the milliseconds of not-typing we want to wait before triggering
    connect(this, SIGNAL(textChanged(QString)), delaySignalTimer, SLOT(start()));
    connect(delaySignalTimer, SIGNAL(timeout()), this, SLOT(delayedSignalTimerTriggered()));

    setWhatsThis(tr("These input fields allow you to perform quick filters in the currently selected table.\n"
                    "By default, the rows containing the input text are filtered out.\n"
                    "The following operators are also supported:\n"
                    "%\tWildcard\n"
                    ">\tGreater than\n"
                    "<\tLess than\n"
                    ">=\tEqual to or greater\n"
                    "<=\tEqual to or less\n"
                    "=\tEqual to: exact match\n"
                    "<>\tUnequal: exact inverse match\n"
                    "x~y\tRange: values between x and y\n"
                    "/regexp/\tValues matching the regular expression"));

    // Immediately emit the delayed filter value changed signal if the user presses the enter or the return key or
    // the line edit widget loses focus
    connect(this, SIGNAL(editingFinished()), this, SLOT(delayedSignalTimerTriggered()));

    // Prepare for adding the What's This information and filter helper actions to the context menu
    setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showContextMenu(const QPoint &)));
}
コード例 #12
0
SearchBar::SearchBar(QWidget *parent)
    : QLineEdit(parent)
{
    setObjectName("mSearchBar");

    // This property was introduced in Qt 5.2.
#if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0))
    setClearButtonEnabled(false);
#endif
#ifdef Q_OS_MAC
    setAttribute(Qt::WA_MacShowFocusRect, 0);
#endif

    placeholder_label_ = new QLabel(this);

    clear_button_ = new QToolButton(this);
    QIcon icon(":/images/cancel.png");
    clear_button_size_ = 12;
    clear_button_->setIcon(icon);
    clear_button_->setIconSize(QSize(clear_button_size_, clear_button_size_));
    clear_button_->setCursor(Qt::ArrowCursor);
    clear_button_->setStyleSheet("QToolButton { border: 0px; }");
    clear_button_->hide();
    connect(clear_button_, SIGNAL(clicked()),
            this, SLOT(clear()));

    connect(this, SIGNAL(textChanged(const QString&)),
            this, SLOT(onTextChanged(const QString&)));

    const QString style = QString(" QLineEdit#mSearchBar { "
                                      " padding-right: %1px; "
                                      " padding-left: %2px; } " )
                                  .arg(clear_button_size_ + kHMargin)
                                  .arg(kHMargin);
    setStyleSheet(style);
}
コード例 #13
0
ファイル: lineedit.cpp プロジェクト: jfmcarreira/ktikz-old
LineEdit::LineEdit(QWidget *parent)
    : QLineEdit(parent)
{
	setClearButtonEnabled(true);
}
コード例 #14
0
ファイル: lineedit.cpp プロジェクト: jfmcarreira/ktikz-old
LineEdit::LineEdit(const QString &text, QWidget *parent)
    : QLineEdit(text, parent)
{
	setClearButtonEnabled(true);
}