forked from qt-creator/qt-creator
IDevice: Simplify addDeviceAction()
Change-Id: I84c486f310c0170ed3d0aa65811e61034c1650e4 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -388,8 +388,7 @@ AndroidDevice::AndroidDevice()
|
||||
setOsType(OsType::OsTypeOtherUnix);
|
||||
setDeviceState(DeviceDisconnected);
|
||||
|
||||
addDeviceAction({Tr::tr("Refresh"), [](const IDevice::Ptr &device, QWidget *parent) {
|
||||
Q_UNUSED(parent)
|
||||
addDeviceAction({Tr::tr("Refresh"), [](const IDevice::Ptr &device) {
|
||||
updateDeviceState(device);
|
||||
}});
|
||||
}
|
||||
@@ -419,27 +418,26 @@ void AndroidDevice::addActionsIfNotFound()
|
||||
|
||||
if (machineType() == Emulator) {
|
||||
if (!hasStartAction) {
|
||||
addDeviceAction({startAvdAction, [](const IDevice::Ptr &device, QWidget *) {
|
||||
addDeviceAction({startAvdAction, [](const IDevice::Ptr &device) {
|
||||
static_cast<AndroidDevice *>(device.get())->startAvd();
|
||||
}});
|
||||
}
|
||||
|
||||
if (!hasEraseAction) {
|
||||
addDeviceAction({eraseAvdAction, [](const IDevice::Ptr &device, QWidget *) {
|
||||
addDeviceAction({eraseAvdAction, [](const IDevice::Ptr &device) {
|
||||
s_instance->eraseAvd(device);
|
||||
}});
|
||||
}
|
||||
|
||||
if (!hasAvdArgumentsAction) {
|
||||
addDeviceAction({avdArgumentsAction, [](const IDevice::Ptr &device, QWidget *) {
|
||||
Q_UNUSED(device)
|
||||
addDeviceAction({avdArgumentsAction, [](const IDevice::Ptr &) {
|
||||
setEmulatorArguments();
|
||||
}});
|
||||
}
|
||||
} else if (machineType() == Hardware && !ipRegex.match(id().toString()).hasMatch()) {
|
||||
if (!hasSetupWifi) {
|
||||
addDeviceAction({setupWifi, [](const IDevice::Ptr &device, QWidget *parent) {
|
||||
setupWifiForDevice(device, parent);
|
||||
addDeviceAction({setupWifi, [](const IDevice::Ptr &device) {
|
||||
setupWifiForDevice(device, Core::ICore::dialogParent());
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
@@ -110,11 +110,11 @@ QdbDevice::QdbDevice()
|
||||
setDisplayType(Tr::tr("Boot to Qt Device"));
|
||||
setType(Constants::QdbLinuxOsType);
|
||||
|
||||
addDeviceAction({Tr::tr("Reboot Device"), [](const IDevice::Ptr &device, QWidget *) {
|
||||
addDeviceAction({Tr::tr("Reboot Device"), [](const IDevice::Ptr &device) {
|
||||
(void) new DeviceApplicationObserver(device, CommandLine{device->filePath("reboot")});
|
||||
}});
|
||||
|
||||
addDeviceAction({Tr::tr("Restore Default App"), [](const IDevice::Ptr &device, QWidget *) {
|
||||
addDeviceAction({Tr::tr("Restore Default App"), [](const IDevice::Ptr &device) {
|
||||
(void) new DeviceApplicationObserver(device, {device->filePath("appcontroller"), {"--remove-default"}});
|
||||
}});
|
||||
}
|
||||
|
@@ -668,7 +668,7 @@ DockerDevice::DockerDevice()
|
||||
});
|
||||
|
||||
addDeviceAction(
|
||||
{Tr::tr("Open Shell in Container"), [](const IDevice::Ptr &device, QWidget *) {
|
||||
{Tr::tr("Open Shell in Container"), [](const IDevice::Ptr &device) {
|
||||
expected_str<Environment> env = device->systemEnvironmentWithError();
|
||||
if (!env) {
|
||||
QMessageBox::warning(ICore::dialogParent(), Tr::tr("Error"), env.error());
|
||||
|
@@ -34,8 +34,6 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QValidator>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
@@ -373,7 +371,7 @@ void DeviceSettingsWidget::currentDeviceChanged(int index)
|
||||
const IDevice::Ptr device = m_deviceManager->mutableDevice(currentDevice()->id());
|
||||
QTC_ASSERT(device, return);
|
||||
updateDeviceFromUi();
|
||||
deviceAction.execute(device, this);
|
||||
deviceAction.execute(device);
|
||||
// Widget must be set up from scratch, because the action could have
|
||||
// changed random attributes.
|
||||
currentDeviceChanged(currentIndex());
|
||||
|
@@ -128,7 +128,7 @@ public:
|
||||
|
||||
struct DeviceAction {
|
||||
QString display;
|
||||
std::function<void(const IDevice::Ptr &device, QWidget *parent)> execute;
|
||||
std::function<void(const IDevice::Ptr &device)> execute;
|
||||
};
|
||||
void addDeviceAction(const DeviceAction &deviceAction);
|
||||
const QList<DeviceAction> deviceActions() const;
|
||||
|
@@ -70,8 +70,8 @@ public:
|
||||
setFreePorts(PortList::fromString("10000-10100"));
|
||||
setExtraData(RemoteLinux::Constants::SourceProfile, true);
|
||||
|
||||
addDeviceAction({Tr::tr("Deploy Qt libraries..."), [](const IDevice::Ptr &device, QWidget *parent) {
|
||||
QnxDeployQtLibrariesDialog dialog(device, parent);
|
||||
addDeviceAction({Tr::tr("Deploy Qt libraries..."), [](const IDevice::Ptr &device) {
|
||||
QnxDeployQtLibrariesDialog dialog(device, Core::ICore::dialogParent());
|
||||
dialog.exec();
|
||||
}});
|
||||
}
|
||||
|
@@ -1028,8 +1028,8 @@ LinuxDevice::LinuxDevice()
|
||||
sshParams.timeout = 10;
|
||||
setSshParameters(sshParams);
|
||||
|
||||
addDeviceAction({Tr::tr("Deploy Public Key..."), [](const IDevice::Ptr &device, QWidget *parent) {
|
||||
if (auto d = Internal::PublicKeyDeploymentDialog::createDialog(device, parent)) {
|
||||
addDeviceAction({Tr::tr("Deploy Public Key..."), [](const IDevice::Ptr &device) {
|
||||
if (auto d = Internal::PublicKeyDeploymentDialog::createDialog(device, Core::ICore::dialogParent())) {
|
||||
d->exec();
|
||||
delete d;
|
||||
}
|
||||
@@ -1062,7 +1062,7 @@ LinuxDevice::LinuxDevice()
|
||||
return {};
|
||||
});
|
||||
|
||||
addDeviceAction({Tr::tr("Open Remote Shell"), [](const IDevice::Ptr &device, QWidget *) {
|
||||
addDeviceAction({Tr::tr("Open Remote Shell"), [](const IDevice::Ptr &device) {
|
||||
Result result = device->openTerminal(Environment(), FilePath());
|
||||
|
||||
if (!result)
|
||||
|
@@ -28,7 +28,7 @@ public:
|
||||
};
|
||||
|
||||
PublicKeyDeploymentDialog *PublicKeyDeploymentDialog::createDialog(
|
||||
const DeviceConstRef &device, QWidget *parent)
|
||||
const DeviceConstRef &device, QWidget *parent) // TODO: Use Core::ICore::dialogParent()
|
||||
{
|
||||
const FilePath dir = device.sshParameters().privateKeyFile.parentDir();
|
||||
const FilePath publicKeyFileName = FileUtils::getOpenFilePath(
|
||||
|
Reference in New Issue
Block a user