Utils: Replace PathChooser::{fileP,p}athChanged signals

... by a new PathChooser::textChanged signal.

They were both emitted in reaction to the underlying line edit's
textChanged() signal.

Use 'textChanged()' as name to mimic/match the Qt side. This also
makes it more clear on the user code side, when this happens.

Some textChanged() consumers should probably use editingFinished()
instead, but that's left for later changes.

Change-Id: Ib07347f616cbf1c5d09bc2f8671ca860d185d1f9
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2022-09-02 11:49:36 +02:00
committed by Christian Stenger
parent b0defb65c2
commit 1567d24980
34 changed files with 69 additions and 73 deletions

View File

@@ -1087,7 +1087,7 @@ void StringAspect::addToLayout(LayoutBuilder &builder)
connect(d->m_pathChooserDisplay, &PathChooser::editingFinished, this, setPathChooserValue);
connect(d->m_pathChooserDisplay, &PathChooser::browsingFinished, this, setPathChooserValue);
} else {
connect(d->m_pathChooserDisplay, &PathChooser::pathChanged,
connect(d->m_pathChooserDisplay, &PathChooser::textChanged,
this, [this](const QString &path) {
setValue(path);
});

View File

@@ -75,7 +75,7 @@ FileWizardPage::FileWizardPage(QWidget *parent) :
setProperty(SHORT_TITLE_PROPERTY, tr("Location"));
registerFieldWithName(QLatin1String("Path"), d->m_pathChooser, "path", SIGNAL(pathChanged(QString)));
registerFieldWithName(QLatin1String("Path"), d->m_pathChooser, "path", SIGNAL(textChanged(QString)));
registerFieldWithName(QLatin1String("FileName"), d->m_nameLineEdit);
}

View File

@@ -246,11 +246,7 @@ PathChooser::PathChooser(QWidget *parent) :
[this] { emit rawPathChanged(rawPath()); });
connect(d->m_lineEdit, &FancyLineEdit::validChanged, this, &PathChooser::validChanged);
connect(d->m_lineEdit, &QLineEdit::editingFinished, this, &PathChooser::editingFinished);
connect(d->m_lineEdit, &QLineEdit::textChanged, this, [this] {
const QString text = d->m_lineEdit->text();
emit pathChanged(text);
emit filePathChanged(FilePath::fromUserInput(text));
});
connect(d->m_lineEdit, &QLineEdit::textChanged, this, &PathChooser::textChanged);
d->m_lineEdit->setMinimumWidth(120);
d->m_hLayout->addWidget(d->m_lineEdit);

View File

@@ -26,7 +26,7 @@ class PathChooserPrivate;
class QTCREATOR_UTILS_EXPORT PathChooser : public QWidget
{
Q_OBJECT
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged DESIGNABLE true)
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY textChanged DESIGNABLE true)
Q_PROPERTY(QString promptDialogTitle READ promptDialogTitle WRITE setPromptDialogTitle DESIGNABLE true)
Q_PROPERTY(QString promptDialogFilter READ promptDialogFilter WRITE setPromptDialogFilter DESIGNABLE true)
Q_PROPERTY(Kind expectedKind READ expectedKind WRITE setExpectedKind DESIGNABLE true)
@@ -150,9 +150,8 @@ private:
signals:
void validChanged(bool validState);
void rawPathChanged(const QString &text);
void pathChanged(const QString &path);
void filePathChanged(const FilePath &path);
void editingFinished();
void textChanged(const QString &text); // Triggered from the line edit's textChanged()
void editingFinished(); // Triggered from the line edit's editingFinished()
void beforeBrowsing();
void browsingFinished();
void returnPressed();

View File

@@ -118,7 +118,8 @@ ProjectIntroPage::ProjectIntroPage(QWidget *parent) :
d->m_stateLabel
}.attachTo(this);
connect(d->m_pathChooser, &PathChooser::filePathChanged, this, &ProjectIntroPage::slotChanged);
connect(d->m_pathChooser, &PathChooser::textChanged,
this, &ProjectIntroPage::slotChanged);
connect(d->m_nameLineEdit, &QLineEdit::textChanged,
this, &ProjectIntroPage::slotChanged);
connect(d->m_pathChooser, &PathChooser::validChanged,
@@ -131,7 +132,7 @@ ProjectIntroPage::ProjectIntroPage(QWidget *parent) :
this, &ProjectIntroPage::slotChanged);
setProperty(SHORT_TITLE_PROPERTY, tr("Location"));
registerFieldWithName(QLatin1String("Path"), d->m_pathChooser, "path", SIGNAL(pathChanged(QString)));
registerFieldWithName(QLatin1String("Path"), d->m_pathChooser, "path", SIGNAL(textChanged(QString)));
registerFieldWithName(QLatin1String("ProjectName"), d->m_nameLineEdit);
}

View File

@@ -208,7 +208,8 @@ QWidget *AndroidBuildApkWidget::createSignPackageGroup()
keystoreLocationChooser->setInitialBrowsePathBackup(FileUtils::homePath());
keystoreLocationChooser->setPromptDialogFilter(tr("Keystore files (*.keystore *.jks)"));
keystoreLocationChooser->setPromptDialogTitle(tr("Select Keystore File"));
connect(keystoreLocationChooser, &PathChooser::filePathChanged, this, [this](const FilePath &file) {
connect(keystoreLocationChooser, &PathChooser::textChanged, this, [this, keystoreLocationChooser] {
const FilePath file = keystoreLocationChooser->rawFilePath();
m_step->setKeystorePath(file);
m_signPackageCheckBox->setChecked(!file.isEmpty());
if (!file.isEmpty())

View File

@@ -154,8 +154,9 @@ ChooseDirectoryPage::ChooseDirectoryPage(CreateAndroidManifestWizard *wizard)
m_sourceDirectoryWarning->setWordWrap(true);
m_layout->addRow(m_sourceDirectoryWarning);
connect(m_androidPackageSourceDir, &PathChooser::filePathChanged,
m_wizard, &CreateAndroidManifestWizard::setDirectory);
connect(m_androidPackageSourceDir, &PathChooser::textChanged, m_wizard, [this] {
m_wizard->setDirectory(m_androidPackageSourceDir->rawFilePath());
});
if (wizard->copyGradle()) {
auto checkBox = new QCheckBox(this);

View File

@@ -219,7 +219,7 @@ GdbServerProviderConfigWidget::GdbServerProviderConfigWidget(
connect(m_startupModeComboBox, &QComboBox::currentIndexChanged,
this, &GdbServerProviderConfigWidget::dirty);
connect(m_peripheralDescriptionFileChooser, &PathChooser::filePathChanged,
connect(m_peripheralDescriptionFileChooser, &PathChooser::textChanged,
this, &GdbServerProviderConfigWidget::dirty);
}

View File

@@ -277,7 +277,7 @@ UvscServerProviderConfigWidget::UvscServerProviderConfigWidget(UvscServerProvide
connect(m_hostWidget, &HostWidget::dataChanged,
this, &UvscServerProviderConfigWidget::dirty);
connect(m_toolsIniChooser, &PathChooser::filePathChanged,
connect(m_toolsIniChooser, &PathChooser::textChanged,
this, &UvscServerProviderConfigWidget::dirty);
connect(m_deviceSelector, &DeviceSelector::selectionChanged,
this, &UvscServerProviderConfigWidget::dirty);
@@ -290,7 +290,7 @@ UvscServerProviderConfigWidget::UvscServerProviderConfigWidget(UvscServerProvide
m_driverSelector->setToolsIniFile(toolsIniFile);
};
connect(m_toolsIniChooser, &PathChooser::filePathChanged, this, updateSelectors);
connect(m_toolsIniChooser, &PathChooser::textChanged, this, updateSelectors);
updateSelectors();
}

View File

@@ -83,7 +83,7 @@ DeviceSelectorDetailsPanel::DeviceSelectorDetailsPanel(DeviceSelection &selectio
m_selection.algorithmIndex = index;
emit selectionChanged();
});
connect(m_peripheralDescriptionFileChooser, &Utils::PathChooser::filePathChanged,
connect(m_peripheralDescriptionFileChooser, &Utils::PathChooser::textChanged,
this, &DeviceSelectorDetailsPanel::selectionChanged);
}

View File

@@ -89,11 +89,11 @@ public:
label->setWordWrap(true);
vlayout->addWidget(label);
auto path = new PathChooser;
path->setExpectedKind(PathChooser::Any);
vlayout->addWidget(path);
connect(path, &PathChooser::pathChanged, this, [this, path] {
m_data->sourcePath = path->filePath();
auto chooser = new PathChooser;
chooser->setExpectedKind(PathChooser::Any);
vlayout->addWidget(chooser);
connect(chooser, &PathChooser::textChanged, this, [this, chooser] {
m_data->sourcePath = chooser->filePath();
updateWarnings();
});

View File

@@ -372,7 +372,7 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
return;
}
};
connect(&d->clangdChooser, &Utils::PathChooser::filePathChanged, this, updateWarningLabel);
connect(&d->clangdChooser, &Utils::PathChooser::textChanged, this, updateWarningLabel);
updateWarningLabel();
connect(&d->useClangdCheckBox, &QCheckBox::toggled,
@@ -389,7 +389,7 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
this, &ClangdSettingsWidget::settingsDataChanged);
connect(&d->documentUpdateThreshold, &QSpinBox::valueChanged,
this, &ClangdSettingsWidget::settingsDataChanged);
connect(&d->clangdChooser, &Utils::PathChooser::filePathChanged,
connect(&d->clangdChooser, &Utils::PathChooser::textChanged,
this, &ClangdSettingsWidget::settingsDataChanged);
connect(d->configSelectionWidget, &ClangDiagnosticConfigsSelectionWidget::changed,
this, &ClangdSettingsWidget::settingsDataChanged);

View File

@@ -324,9 +324,9 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget()
formLayout->addRow(new QLabel(Tr::tr("Version:")), m_versionLabel);
formLayout->addRow(new QLabel(Tr::tr("Working directory:")), m_workingDirectoryChooser);
connect(m_binaryChooser, &PathChooser::filePathChanged,
connect(m_binaryChooser, &PathChooser::textChanged,
this, &DebuggerItemConfigWidget::binaryPathHasChanged);
connect(m_workingDirectoryChooser, &PathChooser::filePathChanged,
connect(m_workingDirectoryChooser, &PathChooser::textChanged,
this, &DebuggerItemConfigWidget::store);
connect(m_displayNameLineEdit, &QLineEdit::textChanged,
this, &DebuggerItemConfigWidget::store);

View File

@@ -272,7 +272,7 @@ DebuggerSourcePathMappingWidget::DebuggerSourcePathMappingWidget() :
m_targetChooser->setHistoryCompleter("Debugger.MappingTarget.History");
connect(m_sourceLineEdit, &QLineEdit::textChanged,
this, &DebuggerSourcePathMappingWidget::slotEditSourceFieldChanged);
connect(m_targetChooser, &PathChooser::filePathChanged,
connect(m_targetChooser, &PathChooser::textChanged,
this, &DebuggerSourcePathMappingWidget::slotEditTargetFieldChanged);
auto editLayout = new QFormLayout;
const QString sourceToolTip = Tr::tr("<p>The source path contained in the "

View File

@@ -276,9 +276,13 @@ AttachCoreDialog::~AttachCoreDialog()
int AttachCoreDialog::exec()
{
connect(d->selectRemoteCoreButton, &QAbstractButton::clicked, this, &AttachCoreDialog::selectRemoteCoreFile);
connect(d->remoteCoreFileName, &PathChooser::filePathChanged, this, &AttachCoreDialog::coreFileChanged);
connect(d->symbolFileName, &PathChooser::filePathChanged, this, &AttachCoreDialog::changed);
connect(d->localCoreFileName, &PathChooser::filePathChanged, this, &AttachCoreDialog::coreFileChanged);
connect(d->remoteCoreFileName, &PathChooser::textChanged, this, [this] {
coreFileChanged(d->remoteCoreFileName->rawFilePath());
});
connect(d->symbolFileName, &PathChooser::textChanged, this, &AttachCoreDialog::changed);
connect(d->localCoreFileName, &PathChooser::textChanged, this, [this] {
coreFileChanged(d->localCoreFileName->rawFilePath());
});
connect(d->forceLocalCheckBox, &QCheckBox::stateChanged, this, &AttachCoreDialog::changed);
connect(d->kitChooser, &KitChooser::currentIndexChanged, this, &AttachCoreDialog::changed);
connect(d->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);

View File

@@ -145,7 +145,7 @@ UnstartedAppWatcherDialog::UnstartedAppWatcherDialog(QWidget *parent)
this, &UnstartedAppWatcherDialog::selectExecutable);
connect(m_watchingPushButton, &QAbstractButton::toggled,
this, &UnstartedAppWatcherDialog::startStopWatching);
connect(m_pathChooser, &Utils::PathChooser::filePathChanged,
connect(m_pathChooser, &Utils::PathChooser::textChanged,
this, &UnstartedAppWatcherDialog::stopAndCheckExecutable);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
connect(&m_timer, &QTimer::timeout,

View File

@@ -83,9 +83,9 @@ ChangeSelectionDialog::ChangeSelectionDialog(const FilePath &workingDirectory, I
connect(m_changeNumberEdit, &CompletingLineEdit::textChanged,
this, &ChangeSelectionDialog::changeTextChanged);
connect(m_workingDirectoryChooser, &PathChooser::filePathChanged,
connect(m_workingDirectoryChooser, &PathChooser::textChanged,
this, &ChangeSelectionDialog::recalculateDetails);
connect(m_workingDirectoryChooser, &PathChooser::filePathChanged,
connect(m_workingDirectoryChooser, &PathChooser::textChanged,
this, &ChangeSelectionDialog::recalculateCompletion);
connect(selectFromHistoryButton, &QPushButton::clicked,
this, &ChangeSelectionDialog::selectCommitFromRecentHistory);

View File

@@ -91,7 +91,7 @@ GitLabCloneDialog::GitLabCloneDialog(const Project &project, QWidget *parent)
QTC_ASSERT(slashIndex > 0, return);
m_directoryLE->setText(path.mid(slashIndex + 1));
connect(m_pathChooser, &Utils::PathChooser::filePathChanged, this, [this]() {
connect(m_pathChooser, &Utils::PathChooser::textChanged, this, [this] {
m_directoryLE->validate();
GitLabCloneDialog::updateUi();
});

View File

@@ -260,7 +260,7 @@ QWidget *McuPackage::widget()
QObject::connect(this, &McuPackage::statusChanged, this, [this] { updateStatusUi(); });
QObject::connect(m_fileChooser, &PathChooser::filePathChanged, this, [this] {
QObject::connect(m_fileChooser, &PathChooser::textChanged, this, [this] {
updatePath();
emit changed();
});

View File

@@ -45,7 +45,7 @@ void ExtPropertiesMView::visitMPackage(const qmt::MPackage *package)
m_configPath->setInitialBrowsePathBackup(
Utils::FilePath::fromString(project->fileName()).absolutePath());
addRow(tr("Config path:"), m_configPath, "configpath");
connect(m_configPath, &Utils::PathChooser::filePathChanged,
connect(m_configPath, &Utils::PathChooser::textChanged,
this, &ExtPropertiesMView::onConfigPathChanged);
}
if (!m_configPath->hasFocus()) {
@@ -64,8 +64,9 @@ void ExtPropertiesMView::visitMPackage(const qmt::MPackage *package)
}
}
void ExtPropertiesMView::onConfigPathChanged(const Utils::FilePath &path)
void ExtPropertiesMView::onConfigPathChanged()
{
const Utils::FilePath path = m_configPath->rawFilePath();
bool modified = false;
qmt::Project *project = m_projectController->project();
if (path.isEmpty()) {

View File

@@ -7,10 +7,7 @@
namespace qmt { class ProjectController; }
namespace Utils {
class FilePath;
class PathChooser;
} // Utils
namespace Utils { class PathChooser; }
namespace ModelEditor {
namespace Internal {
@@ -28,7 +25,7 @@ public:
void visitMPackage(const qmt::MPackage *package) override;
private:
void onConfigPathChanged(const Utils::FilePath &path);
void onConfigPathChanged();
private:
qmt::ProjectController *m_projectController = nullptr;

View File

@@ -10,8 +10,9 @@
#include <utils/algorithm.h>
#include <utils/environment.h>
#include <utils/pathchooser.h>
#include <utils/fileutils.h>
#include <utils/pathchooser.h>
#include <utils/qtcassert.h>
#include <QFormLayout>
@@ -84,7 +85,13 @@ NimToolChainConfigWidget::NimToolChainConfigWidget(NimToolChain *tc)
fillUI();
// Connect
connect(m_compilerCommand, &PathChooser::pathChanged, this, &NimToolChainConfigWidget::onCompilerCommandChanged);
connect(m_compilerCommand, &PathChooser::textChanged, this, [this] {
const FilePath path = m_compilerCommand->rawFilePath();
auto tc = static_cast<NimToolChain *>(toolChain());
QTC_ASSERT(tc, return);
tc->setCompilerCommand(path);
fillUI();
});
}
void NimToolChainConfigWidget::applyImpl()
@@ -121,12 +128,4 @@ void NimToolChainConfigWidget::fillUI()
m_compilerVersion->setText(tc->compilerVersion());
}
void NimToolChainConfigWidget::onCompilerCommandChanged(const QString &path)
{
auto tc = static_cast<NimToolChain *>(toolChain());
Q_ASSERT(tc);
tc->setCompilerCommand(FilePath::fromString(path));
fillUI();
}
}

View File

@@ -36,10 +36,9 @@ protected:
private:
void fillUI();
void onCompilerCommandChanged(const QString &path);
Utils::PathChooser *m_compilerCommand;
QLineEdit *m_compilerVersion;
};
}
} // Nim

View File

@@ -135,7 +135,7 @@ void SshSettingsWidget::setupPathChooser(PathChooser &chooser, const FilePath &i
{
chooser.setExpectedKind(PathChooser::ExistingCommand);
chooser.setFilePath(initialPath);
connect(&chooser, &PathChooser::filePathChanged, [&changedFlag] { changedFlag = true; });
connect(&chooser, &PathChooser::textChanged, [&changedFlag] { changedFlag = true; });
}
void SshSettingsWidget::updateCheckboxEnabled()

View File

@@ -834,7 +834,7 @@ QWidget *PathChooserField::createWidget(const QString &displayName, JsonFieldPag
auto w = new PathChooser;
if (!m_historyId.isEmpty())
w->setHistoryCompleter(m_historyId);
QObject::connect(w, &PathChooser::filePathChanged, [this, w] {
QObject::connect(w, &PathChooser::textChanged, [this, w] {
if (w->filePath() != m_path)
setHasUserChanges();
});

View File

@@ -58,7 +58,7 @@ public:
m_chooser->setExpectedKind(PathChooser::ExistingDirectory);
m_chooser->setHistoryCompleter(QLatin1String("PE.SysRoot.History"));
m_chooser->setFilePath(SysRootKitAspect::sysRoot(k));
connect(m_chooser, &PathChooser::filePathChanged,
connect(m_chooser, &PathChooser::textChanged,
this, &SysRootKitAspectWidget::pathWasChanged);
}

View File

@@ -172,7 +172,7 @@ void WorkingDirectoryAspect::addToLayout(LayoutBuilder &builder)
m_chooser->setPromptDialogTitle(tr("Select Working Directory"));
m_chooser->setBaseDirectory(m_defaultWorkingDirectory);
m_chooser->setFilePath(m_workingDirectory.isEmpty() ? m_defaultWorkingDirectory : m_workingDirectory);
connect(m_chooser.data(), &PathChooser::filePathChanged, this, [this] {
connect(m_chooser.data(), &PathChooser::textChanged, this, [this] {
m_workingDirectory = m_chooser->rawFilePath();
m_resetButton->setEnabled(m_workingDirectory != m_defaultWorkingDirectory);
});

View File

@@ -87,7 +87,7 @@ public:
m_executable->setExpectedKind(PathChooser::ExistingCommand);
connect(m_name, &QLineEdit::textChanged, this, &InterpreterDetailsWidget::changed);
connect(m_executable, &PathChooser::filePathChanged, this, &InterpreterDetailsWidget::changed);
connect(m_executable, &PathChooser::textChanged, this, &InterpreterDetailsWidget::changed);
Form {
Tr::tr("Name:"), m_name, br,

View File

@@ -161,7 +161,7 @@ public:
layout->addRow(tr("Default installation directory:"), &m_defaultInstallDirLineEdit);
layout->addRow(tr("Qbs version:"), &m_versionLabel);
connect(&m_qbsExePathChooser, &PathChooser::filePathChanged, [this] {
connect(&m_qbsExePathChooser, &PathChooser::textChanged, [this] {
m_versionLabel.setText(getQbsVersionString());
});
}

View File

@@ -94,12 +94,10 @@ void CmakeProjectConverterDialog::pathValidChanged()
{
bool valid = isValid();
if (valid) {
m_newProjectDir = FilePath::fromString(m_dirSelector->path()).pathAppended(m_nameEditor->text());
}
else {
if (valid)
m_newProjectDir = m_dirSelector->filePath().pathAppended(m_nameEditor->text());
else
m_newProjectDir = FilePath();
}
const QString error = errorText();
m_errorLabel->setType(error.isEmpty() ? InfoLabel::None : InfoLabel::Warning);

View File

@@ -196,7 +196,7 @@ GenericLinuxDeviceConfigurationWizardKeyDeploymentPage::GenericLinuxDeviceConfig
deployLayout->addWidget(&d->iconLabel);
deployLayout->addStretch();
mainLayout->addLayout(deployLayout);
connect(&d->keyFileChooser, &PathChooser::filePathChanged, this, [this, deployButton] {
connect(&d->keyFileChooser, &PathChooser::textChanged, this, [this, deployButton] {
deployButton->setEnabled(d->keyFileChooser.filePath().exists());
d->iconLabel.clear();
emit completeChanged();

View File

@@ -59,7 +59,7 @@ OpenSquishSuitesDialog::OpenSquishSuitesDialog(QWidget *parent)
}.attachTo(this);
connect(m_directoryLineEdit,
&Utils::PathChooser::pathChanged,
&Utils::PathChooser::textChanged,
this,
&OpenSquishSuitesDialog::onDirectoryChanged);
connect(selectAllPushButton,

View File

@@ -149,8 +149,8 @@ QWidget *FindInFiles::createConfigWidget()
m_directory = new PathChooser;
m_directory->setExpectedKind(PathChooser::ExistingDirectory);
m_directory->setPromptDialogTitle(tr("Directory to Search"));
connect(m_directory.data(), &PathChooser::filePathChanged,
this, &FindInFiles::pathChanged);
connect(m_directory.data(), &PathChooser::textChanged, this,
[this] { pathChanged(m_directory->rawFilePath()); });
m_directory->setHistoryCompleter(QLatin1String(HistoryKey),
/*restoreLastItemFromHistory=*/ true);
if (!HistoryCompleter::historyExistsFor(QLatin1String(HistoryKey))) {

View File

@@ -67,7 +67,7 @@ WebAssemblyOptionsWidget::WebAssemblyOptionsWidget()
m_emSdkPathChooser->setExpectedKind(PathChooser::Directory);
m_emSdkPathChooser->setInitialBrowsePathBackup(FileUtils::homePath());
m_emSdkPathChooser->setFilePath(WebAssemblyEmSdk::registeredEmSdk());
connect(m_emSdkPathChooser, &PathChooser::filePathChanged,
connect(m_emSdkPathChooser, &PathChooser::textChanged,
this, &WebAssemblyOptionsWidget::updateStatus);
layout->addWidget(m_emSdkPathChooser);
m_emSdkVersionDisplay = new InfoLabel(this);