forked from qt-creator/qt-creator
Add option to display locate results using relative paths to project root
Task-number: QTCREATORBUG-29462 Change-Id: Idc52ec206d73d23b958a60391e8d0be9a6b000b0 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
committed by
Xavier BESSON (Personal)
parent
1ddc71fcda
commit
2166647682
@@ -166,6 +166,7 @@ void Locator::loadSettings()
|
||||
const Settings def;
|
||||
DB::beginGroup(settingsGroup);
|
||||
m_refreshTimer.setInterval(minutes(DB::value("RefreshInterval", 60).toInt()));
|
||||
m_relativePaths = DB::value("RelativePaths", false).toBool();
|
||||
m_settings.useCenteredPopup = DB::value(kUseCenteredPopup, def.useCenteredPopup).toBool();
|
||||
|
||||
for (ILocatorFilter *filter : std::as_const(m_filters)) {
|
||||
@@ -294,6 +295,7 @@ void Locator::saveSettings() const
|
||||
DB::beginGroup("Locator");
|
||||
DB::remove(QString());
|
||||
DB::setValue("RefreshInterval", refreshInterval());
|
||||
DB::setValue("RelativePaths", relativePaths());
|
||||
DB::setValueWithDefault(kUseCenteredPopup, m_settings.useCenteredPopup, def.useCenteredPopup);
|
||||
for (ILocatorFilter *filter : m_filters) {
|
||||
if (!m_customFilters.contains(filter) && filter->id().isValid()) {
|
||||
@@ -363,6 +365,16 @@ void Locator::setRefreshInterval(int interval)
|
||||
m_refreshTimer.start();
|
||||
}
|
||||
|
||||
bool Locator::relativePaths() const
|
||||
{
|
||||
return m_relativePaths;
|
||||
}
|
||||
|
||||
void Locator::setRelativePaths(bool use)
|
||||
{
|
||||
m_relativePaths = use;
|
||||
}
|
||||
|
||||
bool Locator::useCenteredPopupForShortcut()
|
||||
{
|
||||
return m_instance->m_settings.useCenteredPopup;
|
||||
|
@@ -40,6 +40,8 @@ public:
|
||||
void setCustomFilters(QList<ILocatorFilter *> f);
|
||||
int refreshInterval() const;
|
||||
void setRefreshInterval(int interval);
|
||||
bool relativePaths() const;
|
||||
void setRelativePaths(bool use);
|
||||
|
||||
static bool useCenteredPopupForShortcut();
|
||||
static void setUseCenteredPopupForShortcut(bool center);
|
||||
@@ -73,6 +75,7 @@ private:
|
||||
QTimer m_refreshTimer;
|
||||
Tasking::TaskTreeRunner m_taskTreeRunner;
|
||||
QList<ILocatorFilter *> m_refreshingFilters;
|
||||
bool m_relativePaths = false;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <utils/treemodel.h>
|
||||
|
||||
#include <QAbstractTextDocumentLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QHash>
|
||||
#include <QHeaderView>
|
||||
#include <QLabel>
|
||||
@@ -273,6 +274,12 @@ public:
|
||||
m_refreshInterval->setSingleStep(5);
|
||||
m_refreshInterval->setValue(60);
|
||||
|
||||
auto relativePathsLabel = new QLabel(Tr::tr("Show Paths in Relation to Active Project:"));
|
||||
relativePathsLabel->setToolTip(Tr::tr("Locator filters show relative paths to the active project when possible."));
|
||||
|
||||
m_relativePaths = new QCheckBox;
|
||||
m_relativePaths->setToolTip(relativePathsLabel->toolTip());
|
||||
|
||||
auto filterEdit = new FancyLineEdit;
|
||||
filterEdit->setFiltering(true);
|
||||
|
||||
@@ -320,7 +327,9 @@ public:
|
||||
m_filterList,
|
||||
buttons,
|
||||
br,
|
||||
Span(2, Row{refreshIntervalLabel, m_refreshInterval, st})}
|
||||
Span(2, Row{refreshIntervalLabel, m_refreshInterval, st}),
|
||||
br,
|
||||
Span(2, Row{relativePathsLabel, m_relativePaths, st})}
|
||||
.attachTo(this);
|
||||
|
||||
connect(filterEdit, &FancyLineEdit::filterChanged, this, &LocatorSettingsWidget::setFilter);
|
||||
@@ -355,6 +364,7 @@ public:
|
||||
addButton->setMenu(addMenu);
|
||||
|
||||
m_refreshInterval->setValue(m_plugin->refreshInterval());
|
||||
m_relativePaths->setChecked(m_plugin->relativePaths());
|
||||
saveFilterStates();
|
||||
}
|
||||
|
||||
@@ -376,6 +386,7 @@ private:
|
||||
QPushButton *m_removeButton;
|
||||
QPushButton *m_editButton;
|
||||
QSpinBox *m_refreshInterval;
|
||||
QCheckBox *m_relativePaths;
|
||||
Locator *m_plugin = nullptr;
|
||||
Utils::TreeModel<> *m_model = nullptr;
|
||||
QSortFilterProxyModel *m_proxyModel = nullptr;
|
||||
@@ -399,6 +410,7 @@ void LocatorSettingsWidget::apply()
|
||||
m_plugin->setFilters(m_filters);
|
||||
m_plugin->setCustomFilters(m_customFilters);
|
||||
m_plugin->setRefreshInterval(m_refreshInterval->value());
|
||||
m_plugin->setRelativePaths(m_relativePaths->isChecked());
|
||||
requestRefresh();
|
||||
m_plugin->saveSettings();
|
||||
saveFilterStates();
|
||||
|
@@ -162,8 +162,13 @@ QVariant LocatorModel::data(const QModelIndex &index, int role) const
|
||||
case Qt::DisplayRole:
|
||||
if (index.column() == DisplayNameColumn)
|
||||
return m_entries.at(index.row()).displayName;
|
||||
else if (index.column() == ExtraInfoColumn)
|
||||
return m_entries.at(index.row()).extraInfo;
|
||||
if (index.column() == ExtraInfoColumn) {
|
||||
if (Locator::instance()->relativePaths()) {
|
||||
return ICore::pathRelativeToActiveProject(FilePath::fromUserInput(m_entries.at(index.row()).extraInfo)).toUserOutput();
|
||||
} else {
|
||||
return m_entries.at(index.row()).extraInfo;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Qt::ToolTipRole: {
|
||||
const LocatorFilterEntry &entry = m_entries.at(index.row());
|
||||
|
Reference in New Issue
Block a user