forked from qt-creator/qt-creator
Core: Inline locatorsettingspage.ui
Change-Id: I7e590817a9919a8e9f32929e99cfc6732423987b Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -116,7 +116,7 @@ add_qtc_plugin(Core
|
|||||||
locator/locatorfiltersfilter.cpp locator/locatorfiltersfilter.h
|
locator/locatorfiltersfilter.cpp locator/locatorfiltersfilter.h
|
||||||
locator/locatormanager.cpp locator/locatormanager.h
|
locator/locatormanager.cpp locator/locatormanager.h
|
||||||
locator/locatorsearchutils.cpp locator/locatorsearchutils.h
|
locator/locatorsearchutils.cpp locator/locatorsearchutils.h
|
||||||
locator/locatorsettingspage.cpp locator/locatorsettingspage.h locator/locatorsettingspage.ui
|
locator/locatorsettingspage.cpp locator/locatorsettingspage.h
|
||||||
locator/locatorwidget.cpp locator/locatorwidget.h
|
locator/locatorwidget.cpp locator/locatorwidget.h
|
||||||
locator/opendocumentsfilter.cpp locator/opendocumentsfilter.h
|
locator/opendocumentsfilter.cpp locator/opendocumentsfilter.h
|
||||||
locator/spotlightlocatorfilter.h locator/spotlightlocatorfilter.cpp
|
locator/spotlightlocatorfilter.h locator/spotlightlocatorfilter.cpp
|
||||||
|
|||||||
@@ -366,7 +366,6 @@ Project {
|
|||||||
"locatorsearchutils.h",
|
"locatorsearchutils.h",
|
||||||
"locatorsettingspage.cpp",
|
"locatorsettingspage.cpp",
|
||||||
"locatorsettingspage.h",
|
"locatorsettingspage.h",
|
||||||
"locatorsettingspage.ui",
|
|
||||||
"locatorwidget.cpp",
|
"locatorwidget.cpp",
|
||||||
"locatorwidget.h",
|
"locatorwidget.h",
|
||||||
"opendocumentsfilter.cpp",
|
"opendocumentsfilter.cpp",
|
||||||
|
|||||||
@@ -25,27 +25,31 @@
|
|||||||
|
|
||||||
#include "locatorsettingspage.h"
|
#include "locatorsettingspage.h"
|
||||||
|
|
||||||
#include "ui_locatorsettingspage.h"
|
|
||||||
|
|
||||||
#include "directoryfilter.h"
|
#include "directoryfilter.h"
|
||||||
#include "ilocatorfilter.h"
|
#include "ilocatorfilter.h"
|
||||||
#include "locator.h"
|
#include "locator.h"
|
||||||
#include "locatorconstants.h"
|
#include "locatorconstants.h"
|
||||||
#include "urllocatorfilter.h"
|
#include "urllocatorfilter.h"
|
||||||
|
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
#include <utils/treemodel.h>
|
#include <utils/treemodel.h>
|
||||||
|
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/categorysortfiltermodel.h>
|
#include <utils/categorysortfiltermodel.h>
|
||||||
|
#include <utils/fancylineedit.h>
|
||||||
#include <utils/headerviewstretcher.h>
|
#include <utils/headerviewstretcher.h>
|
||||||
|
#include <utils/itemviews.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/treemodel.h>
|
#include <utils/treemodel.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
#include <QHeaderView>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QSpinBox>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -177,41 +181,82 @@ public:
|
|||||||
m_filters = Locator::filters();
|
m_filters = Locator::filters();
|
||||||
m_customFilters = m_plugin->customFilters();
|
m_customFilters = m_plugin->customFilters();
|
||||||
|
|
||||||
m_ui.setupUi(this);
|
auto addButton = new QPushButton(tr("Add..."));
|
||||||
m_ui.refreshInterval->setToolTip(m_ui.refreshIntervalLabel->toolTip());
|
|
||||||
|
|
||||||
m_ui.filterEdit->setFiltering(true);
|
auto refreshIntervalLabel = new QLabel(tr("Refresh interval:"));
|
||||||
|
refreshIntervalLabel->setToolTip(
|
||||||
|
tr("Locator filters that do not update their cached data immediately, such as the "
|
||||||
|
"custom directory filters, update it after this time interval."));
|
||||||
|
|
||||||
m_ui.filterList->setSelectionMode(QAbstractItemView::SingleSelection);
|
m_refreshInterval = new QSpinBox;
|
||||||
m_ui.filterList->setSelectionBehavior(QAbstractItemView::SelectRows);
|
m_refreshInterval->setToolTip(refreshIntervalLabel->toolTip());
|
||||||
m_ui.filterList->setSortingEnabled(true);
|
m_refreshInterval->setSuffix(tr(" min"));
|
||||||
m_ui.filterList->setUniformRowHeights(true);
|
m_refreshInterval->setFrame(true);
|
||||||
m_ui.filterList->setActivationMode(Utils::DoubleClickActivation);
|
m_refreshInterval->setButtonSymbols(QAbstractSpinBox::PlusMinus);
|
||||||
|
m_refreshInterval->setMaximum(320);
|
||||||
|
m_refreshInterval->setSingleStep(5);
|
||||||
|
m_refreshInterval->setValue(60);
|
||||||
|
|
||||||
m_model = new TreeModel<>(m_ui.filterList);
|
auto filterEdit = new FancyLineEdit;
|
||||||
|
filterEdit->setFiltering(true);
|
||||||
|
|
||||||
|
m_filterList = new TreeView;
|
||||||
|
m_filterList->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
m_filterList->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
m_filterList->setSortingEnabled(true);
|
||||||
|
m_filterList->setUniformRowHeights(true);
|
||||||
|
m_filterList->setActivationMode(Utils::DoubleClickActivation);
|
||||||
|
|
||||||
|
m_model = new TreeModel<>(m_filterList);
|
||||||
initializeModel();
|
initializeModel();
|
||||||
m_proxyModel = new CategorySortFilterModel(m_ui.filterList);
|
m_proxyModel = new CategorySortFilterModel(m_filterList);
|
||||||
m_proxyModel->setSourceModel(m_model);
|
m_proxyModel->setSourceModel(m_model);
|
||||||
m_proxyModel->setSortRole(SortRole);
|
m_proxyModel->setSortRole(SortRole);
|
||||||
m_proxyModel->setFilterKeyColumn(-1/*all*/);
|
m_proxyModel->setFilterKeyColumn(-1/*all*/);
|
||||||
m_ui.filterList->setModel(m_proxyModel);
|
m_filterList->setModel(m_proxyModel);
|
||||||
m_ui.filterList->expandAll();
|
m_filterList->expandAll();
|
||||||
|
|
||||||
new HeaderViewStretcher(m_ui.filterList->header(), FilterName);
|
new HeaderViewStretcher(m_filterList->header(), FilterName);
|
||||||
m_ui.filterList->header()->setSortIndicator(FilterName, Qt::AscendingOrder);
|
m_filterList->header()->setSortIndicator(FilterName, Qt::AscendingOrder);
|
||||||
|
|
||||||
connect(m_ui.filterEdit, &FancyLineEdit::filterChanged,
|
m_removeButton = new QPushButton(tr("Remove"));
|
||||||
this, &LocatorSettingsWidget::setFilter);
|
m_removeButton->setEnabled(false);
|
||||||
connect(m_ui.filterList->selectionModel(), &QItemSelectionModel::currentChanged,
|
|
||||||
this, &LocatorSettingsWidget::updateButtonStates);
|
|
||||||
connect(m_ui.filterList, &Utils::TreeView::activated,
|
|
||||||
this, &LocatorSettingsWidget::configureFilter);
|
|
||||||
connect(m_ui.editButton, &QPushButton::clicked,
|
|
||||||
this, [this] { configureFilter(m_ui.filterList->currentIndex()); });
|
|
||||||
connect(m_ui.removeButton, &QPushButton::clicked,
|
|
||||||
this, &LocatorSettingsWidget::removeCustomFilter);
|
|
||||||
|
|
||||||
auto addMenu = new QMenu(m_ui.addButton);
|
m_editButton = new QPushButton(tr("Edit..."));
|
||||||
|
m_editButton->setEnabled(false);
|
||||||
|
|
||||||
|
using namespace Layouting;
|
||||||
|
static const Break br;
|
||||||
|
static const Stretch st;
|
||||||
|
|
||||||
|
Column buttons{addButton, m_removeButton, m_editButton, st};
|
||||||
|
|
||||||
|
Grid{filterEdit,
|
||||||
|
br,
|
||||||
|
m_filterList,
|
||||||
|
buttons,
|
||||||
|
br,
|
||||||
|
Span(2, Row{refreshIntervalLabel, m_refreshInterval, st})}
|
||||||
|
.attachTo(this);
|
||||||
|
|
||||||
|
connect(filterEdit, &FancyLineEdit::filterChanged, this, &LocatorSettingsWidget::setFilter);
|
||||||
|
connect(m_filterList->selectionModel(),
|
||||||
|
&QItemSelectionModel::currentChanged,
|
||||||
|
this,
|
||||||
|
&LocatorSettingsWidget::updateButtonStates);
|
||||||
|
connect(m_filterList,
|
||||||
|
&Utils::TreeView::activated,
|
||||||
|
this,
|
||||||
|
&LocatorSettingsWidget::configureFilter);
|
||||||
|
connect(m_editButton, &QPushButton::clicked, this, [this] {
|
||||||
|
configureFilter(m_filterList->currentIndex());
|
||||||
|
});
|
||||||
|
connect(m_removeButton,
|
||||||
|
&QPushButton::clicked,
|
||||||
|
this,
|
||||||
|
&LocatorSettingsWidget::removeCustomFilter);
|
||||||
|
|
||||||
|
auto addMenu = new QMenu(addButton);
|
||||||
addMenu->addAction(tr("Files in Directories"), this, [this] {
|
addMenu->addAction(tr("Files in Directories"), this, [this] {
|
||||||
addCustomFilter(new DirectoryFilter(Id(Constants::CUSTOM_DIRECTORY_FILTER_BASEID)
|
addCustomFilter(new DirectoryFilter(Id(Constants::CUSTOM_DIRECTORY_FILTER_BASEID)
|
||||||
.withSuffix(m_customFilters.size() + 1)));
|
.withSuffix(m_customFilters.size() + 1)));
|
||||||
@@ -222,9 +267,9 @@ public:
|
|||||||
filter->setIsCustomFilter(true);
|
filter->setIsCustomFilter(true);
|
||||||
addCustomFilter(filter);
|
addCustomFilter(filter);
|
||||||
});
|
});
|
||||||
m_ui.addButton->setMenu(addMenu);
|
addButton->setMenu(addMenu);
|
||||||
|
|
||||||
m_ui.refreshInterval->setValue(m_plugin->refreshInterval());
|
m_refreshInterval->setValue(m_plugin->refreshInterval());
|
||||||
saveFilterStates();
|
saveFilterStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +287,10 @@ private:
|
|||||||
void requestRefresh();
|
void requestRefresh();
|
||||||
void setFilter(const QString &text);
|
void setFilter(const QString &text);
|
||||||
|
|
||||||
Ui::LocatorSettingsWidget m_ui;
|
Utils::TreeView *m_filterList;
|
||||||
|
QPushButton *m_removeButton;
|
||||||
|
QPushButton *m_editButton;
|
||||||
|
QSpinBox *m_refreshInterval;
|
||||||
Locator *m_plugin = nullptr;
|
Locator *m_plugin = nullptr;
|
||||||
Utils::TreeModel<> *m_model = nullptr;
|
Utils::TreeModel<> *m_model = nullptr;
|
||||||
QSortFilterProxyModel *m_proxyModel = nullptr;
|
QSortFilterProxyModel *m_proxyModel = nullptr;
|
||||||
@@ -265,7 +313,7 @@ void LocatorSettingsWidget::apply()
|
|||||||
// Pass the new configuration on to the plugin
|
// Pass the new configuration on to the plugin
|
||||||
m_plugin->setFilters(m_filters);
|
m_plugin->setFilters(m_filters);
|
||||||
m_plugin->setCustomFilters(m_customFilters);
|
m_plugin->setCustomFilters(m_customFilters);
|
||||||
m_plugin->setRefreshInterval(m_ui.refreshInterval->value());
|
m_plugin->setRefreshInterval(m_refreshInterval->value());
|
||||||
requestRefresh();
|
requestRefresh();
|
||||||
m_plugin->saveSettings();
|
m_plugin->saveSettings();
|
||||||
saveFilterStates();
|
saveFilterStates();
|
||||||
@@ -299,7 +347,7 @@ void LocatorSettingsWidget::setFilter(const QString &text)
|
|||||||
m_proxyModel->setFilterRegularExpression(
|
m_proxyModel->setFilterRegularExpression(
|
||||||
QRegularExpression(QRegularExpression::escape(text),
|
QRegularExpression(QRegularExpression::escape(text),
|
||||||
QRegularExpression::CaseInsensitiveOption));
|
QRegularExpression::CaseInsensitiveOption));
|
||||||
m_ui.filterList->expandAll();
|
m_filterList->expandAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocatorSettingsWidget::saveFilterStates()
|
void LocatorSettingsWidget::saveFilterStates()
|
||||||
@@ -340,7 +388,7 @@ void LocatorSettingsWidget::initializeModel()
|
|||||||
|
|
||||||
void LocatorSettingsWidget::updateButtonStates()
|
void LocatorSettingsWidget::updateButtonStates()
|
||||||
{
|
{
|
||||||
const QModelIndex currentIndex = m_proxyModel->mapToSource(m_ui.filterList->currentIndex());
|
const QModelIndex currentIndex = m_proxyModel->mapToSource(m_filterList->currentIndex());
|
||||||
bool selected = currentIndex.isValid();
|
bool selected = currentIndex.isValid();
|
||||||
ILocatorFilter *filter = nullptr;
|
ILocatorFilter *filter = nullptr;
|
||||||
if (selected) {
|
if (selected) {
|
||||||
@@ -348,8 +396,8 @@ void LocatorSettingsWidget::updateButtonStates()
|
|||||||
if (item)
|
if (item)
|
||||||
filter = item->filter();
|
filter = item->filter();
|
||||||
}
|
}
|
||||||
m_ui.editButton->setEnabled(filter && filter->isConfigurable());
|
m_editButton->setEnabled(filter && filter->isConfigurable());
|
||||||
m_ui.removeButton->setEnabled(filter && m_customFilters.contains(filter));
|
m_removeButton->setEnabled(filter && m_customFilters.contains(filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocatorSettingsWidget::configureFilter(const QModelIndex &proxyIndex)
|
void LocatorSettingsWidget::configureFilter(const QModelIndex &proxyIndex)
|
||||||
@@ -386,7 +434,7 @@ void LocatorSettingsWidget::addCustomFilter(ILocatorFilter *filter)
|
|||||||
|
|
||||||
void LocatorSettingsWidget::removeCustomFilter()
|
void LocatorSettingsWidget::removeCustomFilter()
|
||||||
{
|
{
|
||||||
QModelIndex currentIndex = m_proxyModel->mapToSource(m_ui.filterList->currentIndex());
|
QModelIndex currentIndex = m_proxyModel->mapToSource(m_filterList->currentIndex());
|
||||||
QTC_ASSERT(currentIndex.isValid(), return);
|
QTC_ASSERT(currentIndex.isValid(), return);
|
||||||
auto item = dynamic_cast<FilterItem *>(m_model->itemForIndex(currentIndex));
|
auto item = dynamic_cast<FilterItem *>(m_model->itemForIndex(currentIndex));
|
||||||
QTC_ASSERT(item, return);
|
QTC_ASSERT(item, return);
|
||||||
|
|||||||
@@ -1,132 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Core::Internal::LocatorSettingsWidget</class>
|
|
||||||
<widget class="QWidget" name="Core::Internal::LocatorSettingsWidget">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>411</width>
|
|
||||||
<height>287</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Configure Filters</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="Utils::FancyLineEdit" name="filterEdit"/>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="Utils::TreeView" name="filterList"/>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<layout class="QVBoxLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="addButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="removeButton">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Remove</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="editButton">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Edit...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0" colspan="2">
|
|
||||||
<layout class="QHBoxLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="refreshIntervalLabel">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Locator filters that do not update their cached data immediately, such as the custom directory filters, update it after this time interval.</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Refresh interval:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QSpinBox" name="refreshInterval">
|
|
||||||
<property name="frame">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="buttonSymbols">
|
|
||||||
<enum>QAbstractSpinBox::PlusMinus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="suffix">
|
|
||||||
<string> min</string>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>320</number>
|
|
||||||
</property>
|
|
||||||
<property name="singleStep">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>60</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>Utils::TreeView</class>
|
|
||||||
<extends>QTreeView</extends>
|
|
||||||
<header location="global">utils/itemviews.h</header>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
|
||||||
<class>Utils::FancyLineEdit</class>
|
|
||||||
<extends>QLineEdit</extends>
|
|
||||||
<header location="global">utils/fancylineedit.h</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
Reference in New Issue
Block a user