ProjectExplorer: Introduce DeviceManager::defaultDesktopDevice()

Just syntactic sugar to make doing the right thing less painful.

Change-Id: Ia51cda20e5395925215f226b9a379af66fddfd8b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2021-07-05 16:16:12 +02:00
parent 2e9604c092
commit 1e11f3eade
5 changed files with 10 additions and 6 deletions

View File

@@ -63,10 +63,8 @@ PerfTracePointDialog::PerfTracePointDialog() :
}
if (!m_device) {
const DeviceManager *deviceManager = DeviceManager::instance();
// There should at least be a desktop device.
m_device = deviceManager->defaultDevice(Constants::DESKTOP_DEVICE_TYPE);
m_device = DeviceManager::defaultDesktopDevice();
QTC_ASSERT(m_device, return);
}

View File

@@ -104,7 +104,7 @@ Runnable CustomExecutableRunConfiguration::runnable() const
r.setCommandLine(commandLine());
r.environment = aspect<EnvironmentAspect>()->environment();
r.workingDirectory = workingDirectory.toString();
r.device = DeviceManager::instance()->defaultDevice(Constants::DESKTOP_DEVICE_TYPE);
r.device = DeviceManager::defaultDesktopDevice();
if (!r.executable.isEmpty()) {
const QString expanded = macroExpander()->expand(r.executable.toString());

View File

@@ -331,6 +331,11 @@ IDevice::ConstPtr DeviceManager::deviceForPath(const FilePath &path)
return {};
}
IDevice::ConstPtr DeviceManager::defaultDesktopDevice()
{
return m_instance->defaultDevice(Constants::DESKTOP_DEVICE_TYPE);
}
void DeviceManager::setDefaultDevice(Utils::Id id)
{
QTC_ASSERT(this != instance(), return);

View File

@@ -69,7 +69,9 @@ public:
void setDeviceState(Utils::Id deviceId, IDevice::DeviceState deviceState);
bool isLoaded() const;
static IDevice::ConstPtr deviceForPath(const Utils::FilePath &path);
static IDevice::ConstPtr defaultDesktopDevice();
signals:
void deviceAdded(Utils::Id id);

View File

@@ -1231,8 +1231,7 @@ BuildDeviceKitAspect::BuildDeviceKitAspect()
QVariant BuildDeviceKitAspect::defaultValue(const Kit *k) const
{
Q_UNUSED(k);
IDevice::ConstPtr defaultDevice =
DeviceManager::instance()->defaultDevice(Constants::DESKTOP_DEVICE_TYPE);
IDevice::ConstPtr defaultDevice = DeviceManager::defaultDesktopDevice();
return defaultDevice->id().toString();
}