forked from qt-creator/qt-creator
ProjectExplorer: Replace two uses of QAction::setData
... by a connection to a lambda. Change-Id: I32a276146cf6a4cfc79ae9c133a4cb5f0783c867 Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
@@ -219,12 +219,15 @@ void KitManagerConfigWidget::addConfigWidget(KitConfigWidget *widget)
|
||||
|
||||
QAction *action = new QAction(tr("Mark as Mutable"), 0);
|
||||
action->setCheckable(true);
|
||||
action->setData(QVariant::fromValue(qobject_cast<QObject *>(widget)));
|
||||
action->setChecked(widget->isMutable());
|
||||
action->setEnabled(!widget->isSticky());
|
||||
widget->mainWidget()->addAction(action);
|
||||
widget->mainWidget()->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
connect(action, &QAction::toggled, this, &KitManagerConfigWidget::updateMutableState);
|
||||
connect(action, &QAction::toggled, this, [this, widget, action] {
|
||||
widget->setMutable(action->isChecked());
|
||||
emit dirty();
|
||||
});
|
||||
|
||||
m_actions << action;
|
||||
|
||||
int row = m_layout->rowCount();
|
||||
@@ -363,18 +366,6 @@ void KitManagerConfigWidget::kitWasUpdated(Kit *k)
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
void KitManagerConfigWidget::updateMutableState()
|
||||
{
|
||||
QAction *action = qobject_cast<QAction *>(sender());
|
||||
if (!action)
|
||||
return;
|
||||
KitConfigWidget *widget = qobject_cast<KitConfigWidget *>(action->data().value<QObject *>());
|
||||
if (!widget)
|
||||
return;
|
||||
widget->setMutable(action->isChecked());
|
||||
emit dirty();
|
||||
}
|
||||
|
||||
QLabel *KitManagerConfigWidget::createLabel(const QString &name, const QString &toolTip)
|
||||
{
|
||||
QLabel *label = new QLabel(name);
|
||||
|
@@ -85,7 +85,6 @@ private slots:
|
||||
void setFileSystemFriendlyName();
|
||||
void workingCopyWasUpdated(ProjectExplorer::Kit *k);
|
||||
void kitWasUpdated(ProjectExplorer::Kit *k);
|
||||
void updateMutableState();
|
||||
|
||||
private:
|
||||
enum LayoutColumns {
|
||||
|
@@ -266,7 +266,7 @@ public:
|
||||
|
||||
void updateRecentProjectMenu();
|
||||
void clearRecentProjects();
|
||||
void openRecentProject();
|
||||
void openRecentProject(const QString &fileName);
|
||||
void updateUnloadProjectMenu();
|
||||
void openTerminalHere();
|
||||
|
||||
@@ -2830,12 +2830,13 @@ void ProjectExplorerPluginPrivate::updateRecentProjectMenu()
|
||||
//projects (ignore sessions, they used to be in this list)
|
||||
const StringPairListConstIterator end = dd->m_recentProjects.constEnd();
|
||||
for (StringPairListConstIterator it = dd->m_recentProjects.constBegin(); it != end; ++it) {
|
||||
const QPair<QString, QString> &s = *it;
|
||||
if (s.first.endsWith(QLatin1String(".qws")))
|
||||
const QString fileName = it->first;
|
||||
if (fileName.endsWith(QLatin1String(".qws")))
|
||||
continue;
|
||||
QAction *action = menu->addAction(Utils::withTildeHomePath(s.first));
|
||||
action->setData(s.first);
|
||||
connect(action, &QAction::triggered, this, &ProjectExplorerPluginPrivate::openRecentProject);
|
||||
QAction *action = menu->addAction(Utils::withTildeHomePath(fileName));
|
||||
connect(action, &QAction::triggered, this, [this, fileName] {
|
||||
openRecentProject(fileName);
|
||||
});
|
||||
hasRecentProjects = true;
|
||||
}
|
||||
menu->setEnabled(hasRecentProjects);
|
||||
@@ -2856,15 +2857,11 @@ void ProjectExplorerPluginPrivate::clearRecentProjects()
|
||||
updateWelcomePage();
|
||||
}
|
||||
|
||||
void ProjectExplorerPluginPrivate::openRecentProject()
|
||||
void ProjectExplorerPluginPrivate::openRecentProject(const QString &fileName)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << "ProjectExplorerPlugin::openRecentProject()";
|
||||
|
||||
QAction *a = qobject_cast<QAction*>(sender());
|
||||
if (!a)
|
||||
return;
|
||||
QString fileName = a->data().toString();
|
||||
if (!fileName.isEmpty()) {
|
||||
QString errorMessage;
|
||||
ProjectExplorerPlugin::openProject(fileName, &errorMessage);
|
||||
|
Reference in New Issue
Block a user