aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/components/eventlist/filterlinewidget.cpp
blob: e4d2a2a3a9707c2e75b9b87e3f15b1c349475aef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#include "filterlinewidget.h"

#include <theme.h>
#include <utils/fancylineedit.h>
#include <utils/stylehelper.h>

#include <QHBoxLayout>
#include <QIcon>
#include <QLabel>

namespace QmlDesigner {

FilterLineWidget::FilterLineWidget(QWidget *parent)
    : QWidget(parent)
    , m_edit(new Utils::FancyLineEdit())
{
    const QString unicode = Theme::getIconUnicode(Theme::Icon::search);
    const QString fontName = "qtds_propertyIconFont.ttf";
    QIcon icon = Utils::StyleHelper::getIconFromIconFont(fontName, unicode, 28, 28);

    auto *label = new QLabel;
    label->setPixmap(icon.pixmap(QSize(18, 18)));
    label->setAlignment(Qt::AlignCenter);

    m_edit->setPlaceholderText(QObject::tr("<Filter>", "Library search input hint text"));
    m_edit->setDragEnabled(false);
    m_edit->setMinimumWidth(75);
    m_edit->setTextMargins(0, 0, 20, 0);
    m_edit->setFiltering(true);

    auto *box = new QHBoxLayout;
    box->addWidget(label);
    box->addWidget(m_edit);
    setLayout(box);

    connect(m_edit, &Utils::FancyLineEdit::filterChanged, this, &FilterLineWidget::filterChanged);
}

void FilterLineWidget::clear()
{
    m_edit->clear();
}

} // namespace QmlDesigner.