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