+ // Create close button
+ QToolButton* closeButton = new QToolButton(this);
+ closeButton->setAutoRaise(true);
+ closeButton->setIcon(QIcon::fromTheme(QStringLiteral("dialog-close")));
+ closeButton->setToolTip(i18nc("@info:tooltip", "Quit searching"));
+ connect(closeButton, &QToolButton::clicked, this, &DolphinSearchBox::emitCloseRequest);
+
+ // Create search label
+ m_searchLabel = new QLabel(this);
+
+ // Create search box
+ m_searchInput = new QLineEdit(this);
+ m_searchInput->installEventFilter(this);
+ m_searchInput->setClearButtonEnabled(true);
+ m_searchInput->setFont(QFontDatabase::systemFont(QFontDatabase::GeneralFont));
+ connect(m_searchInput, &QLineEdit::returnPressed,
+ this, &DolphinSearchBox::slotReturnPressed);
+ connect(m_searchInput, &QLineEdit::textChanged,
+ this, &DolphinSearchBox::slotSearchTextChanged);
+ setFocusProxy(m_searchInput);
+
+ // Apply layout for the search input
+ QHBoxLayout* searchInputLayout = new QHBoxLayout();
+ searchInputLayout->setMargin(0);
+ searchInputLayout->addWidget(closeButton);
+ searchInputLayout->addWidget(m_searchLabel);
+ searchInputLayout->addWidget(m_searchInput);
+
+ // Create "Filename" and "Content" button
+ m_fileNameButton = new QToolButton(this);
+ m_fileNameButton->setText(i18nc("action:button", "Filename"));
+ initButton(m_fileNameButton);
+
+ m_contentButton = new QToolButton();
+ m_contentButton->setText(i18nc("action:button", "Content"));
+ initButton(m_contentButton);
+
+ QButtonGroup* searchWhatGroup = new QButtonGroup(this);
+ searchWhatGroup->addButton(m_fileNameButton);
+ searchWhatGroup->addButton(m_contentButton);
+
+ m_separator = new KSeparator(Qt::Vertical, this);
+
+ // Create "From Here" and "Everywhere"button
+ m_fromHereButton = new QToolButton(this);
+ m_fromHereButton->setText(i18nc("action:button", "From Here"));
+ initButton(m_fromHereButton);
+
+ m_everywhereButton = new QToolButton(this);
+ m_everywhereButton->setText(i18nc("action:button", "Everywhere"));
+ initButton(m_everywhereButton);
+
+ QButtonGroup* searchLocationGroup = new QButtonGroup(this);
+ searchLocationGroup->addButton(m_fromHereButton);
+ searchLocationGroup->addButton(m_everywhereButton);
+
+ auto moreSearchToolsButton = new QToolButton(this);
+ moreSearchToolsButton->setAutoRaise(true);
+ moreSearchToolsButton->setPopupMode(QToolButton::InstantPopup);
+ moreSearchToolsButton->setIcon(QIcon::fromTheme("arrow-down-double"));
+ moreSearchToolsButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ moreSearchToolsButton->setText(i18n("More Search Tools"));
+ moreSearchToolsButton->setMenu(new QMenu(this));
+ connect(moreSearchToolsButton->menu(), &QMenu::aboutToShow, moreSearchToolsButton->menu(), [this, moreSearchToolsButton]()
+ {
+ m_menuFactory.reset(new KMoreToolsMenuFactory("dolphin/search-tools"));
+ moreSearchToolsButton->menu()->clear();
+ m_menuFactory->fillMenuFromGroupingNames(moreSearchToolsButton->menu(), { "files-find" }, this->m_searchPath);
+ } );
+
+ // Create "Facets" widgets
+ m_facetsToggleButton = new QToolButton(this);
+ m_facetsToggleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ initButton(m_facetsToggleButton);
+ connect(m_facetsToggleButton, &QToolButton::clicked, this, &DolphinSearchBox::slotFacetsButtonToggled);
+
+ m_facetsWidget = new DolphinFacetsWidget(this);
+ m_facetsWidget->installEventFilter(this);
+ m_facetsWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
+ connect(m_facetsWidget, &DolphinFacetsWidget::facetChanged, this, &DolphinSearchBox::slotFacetChanged);
+
+ // Apply layout for the options
+ QHBoxLayout* optionsLayout = new QHBoxLayout();
+ optionsLayout->setMargin(0);
+ optionsLayout->addWidget(m_fileNameButton);
+ optionsLayout->addWidget(m_contentButton);
+ optionsLayout->addWidget(m_separator);
+ optionsLayout->addWidget(m_fromHereButton);
+ optionsLayout->addWidget(m_everywhereButton);
+ optionsLayout->addWidget(new KSeparator(Qt::Vertical, this));
+ optionsLayout->addWidget(m_facetsToggleButton);
+ optionsLayout->addWidget(moreSearchToolsButton);
+ optionsLayout->addStretch(1);
+
+ // Put the options into a QScrollArea. This prevents increasing the view width
+ // in case that not enough width for the options is available.
+ QWidget* optionsContainer = new QWidget(this);
+ optionsContainer->setLayout(optionsLayout);
+
+ m_optionsScrollArea = new QScrollArea(this);
+ m_optionsScrollArea->setFrameShape(QFrame::NoFrame);
+ m_optionsScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ m_optionsScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ m_optionsScrollArea->setMaximumHeight(optionsContainer->sizeHint().height());
+ m_optionsScrollArea->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ m_optionsScrollArea->setWidget(optionsContainer);
+ m_optionsScrollArea->setWidgetResizable(true);
+
+ m_topLayout = new QVBoxLayout(this);
+ m_topLayout->setMargin(0);
+ m_topLayout->addLayout(searchInputLayout);
+ m_topLayout->addWidget(m_optionsScrollArea);
+ m_topLayout->addWidget(m_facetsWidget);
+
+ loadSettings();
+
+ // The searching should be started automatically after the user did not change
+ // the text within one second
+ m_startSearchTimer = new QTimer(this);
+ m_startSearchTimer->setSingleShot(true);
+ m_startSearchTimer->setInterval(1000);
+ connect(m_startSearchTimer, &QTimer::timeout, this, &DolphinSearchBox::emitSearchRequest);
+
+ updateFacetsToggleButton();