mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
DolphinSearchBox: Add a "More search tools..." menu button
Additionally, moves the "More/Fewer options" button from right to left to reduce the mouse travelling distance when the dolphin is maximized on a large screen (see screenshots) The current location url will be passed to the search tool to set the initial search root directory. REVIEW: 123883
This commit is contained in:
parent
0aed243beb
commit
728e6712b8
2 changed files with 20 additions and 1 deletions
|
@ -26,6 +26,7 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <KSeparator>
|
#include <KSeparator>
|
||||||
|
#include <KNS3/KMoreToolsMenuFactory>
|
||||||
|
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
@ -385,6 +386,20 @@ void DolphinSearchBox::init()
|
||||||
searchLocationGroup->addButton(m_fromHereButton);
|
searchLocationGroup->addButton(m_fromHereButton);
|
||||||
searchLocationGroup->addButton(m_everywhereButton);
|
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
|
// Create "Facets" widgets
|
||||||
m_facetsToggleButton = new QToolButton(this);
|
m_facetsToggleButton = new QToolButton(this);
|
||||||
m_facetsToggleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
m_facetsToggleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||||
|
@ -404,8 +419,10 @@ void DolphinSearchBox::init()
|
||||||
optionsLayout->addWidget(m_separator);
|
optionsLayout->addWidget(m_separator);
|
||||||
optionsLayout->addWidget(m_fromHereButton);
|
optionsLayout->addWidget(m_fromHereButton);
|
||||||
optionsLayout->addWidget(m_everywhereButton);
|
optionsLayout->addWidget(m_everywhereButton);
|
||||||
optionsLayout->addStretch(1);
|
optionsLayout->addWidget(new KSeparator(Qt::Vertical, this));
|
||||||
optionsLayout->addWidget(m_facetsToggleButton);
|
optionsLayout->addWidget(m_facetsToggleButton);
|
||||||
|
optionsLayout->addWidget(moreSearchToolsButton);
|
||||||
|
optionsLayout->addStretch(1);
|
||||||
|
|
||||||
// Put the options into a QScrollArea. This prevents increasing the view width
|
// Put the options into a QScrollArea. This prevents increasing the view width
|
||||||
// in case that not enough width for the options is available.
|
// in case that not enough width for the options is available.
|
||||||
|
|
|
@ -30,6 +30,7 @@ class QToolButton;
|
||||||
class QScrollArea;
|
class QScrollArea;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
|
class KMoreToolsMenuFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Input box for searching files with or without Baloo.
|
* @brief Input box for searching files with or without Baloo.
|
||||||
|
@ -176,6 +177,7 @@ private:
|
||||||
DolphinFacetsWidget* m_facetsWidget;
|
DolphinFacetsWidget* m_facetsWidget;
|
||||||
|
|
||||||
QUrl m_searchPath;
|
QUrl m_searchPath;
|
||||||
|
QScopedPointer<KMoreToolsMenuFactory> m_menuFactory;
|
||||||
|
|
||||||
QTimer* m_startSearchTimer;
|
QTimer* m_startSearchTimer;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue