forked from qt-creator/qt-creator
RemoteLinux: Use a BoolAspect for the disconnected state
Change-Id: I8e5848167954ffa6ba3bd50e4e929c3885393238 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -58,8 +58,6 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace RemoteLinux {
|
namespace RemoteLinux {
|
||||||
|
|
||||||
const char DisconnectedKey[] = "Disconnected";
|
|
||||||
|
|
||||||
const QByteArray s_pidMarker = "__qtc";
|
const QByteArray s_pidMarker = "__qtc";
|
||||||
|
|
||||||
static Q_LOGGING_CATEGORY(linuxDeviceLog, "qtc.remotelinux.device", QtWarningMsg);
|
static Q_LOGGING_CATEGORY(linuxDeviceLog, "qtc.remotelinux.device", QtWarningMsg);
|
||||||
@@ -329,7 +327,6 @@ public:
|
|||||||
void queryOsType(std::function<RunResult(const CommandLine &)> run);
|
void queryOsType(std::function<RunResult(const CommandLine &)> run);
|
||||||
|
|
||||||
void setDisconnected(bool disconnected);
|
void setDisconnected(bool disconnected);
|
||||||
bool disconnected() const;
|
|
||||||
bool checkDisconnectedWithWarning();
|
bool checkDisconnectedWithWarning();
|
||||||
|
|
||||||
LinuxDevice *q = nullptr;
|
LinuxDevice *q = nullptr;
|
||||||
@@ -340,7 +337,6 @@ public:
|
|||||||
|
|
||||||
QReadWriteLock m_environmentCacheLock;
|
QReadWriteLock m_environmentCacheLock;
|
||||||
std::optional<Environment> m_environmentCache;
|
std::optional<Environment> m_environmentCache;
|
||||||
bool m_disconnected = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void LinuxDevicePrivate::invalidateEnvironmentCache()
|
void LinuxDevicePrivate::invalidateEnvironmentCache()
|
||||||
@@ -360,7 +356,7 @@ Environment LinuxDevicePrivate::getEnvironment()
|
|||||||
if (m_environmentCache.has_value())
|
if (m_environmentCache.has_value())
|
||||||
return m_environmentCache.value();
|
return m_environmentCache.value();
|
||||||
|
|
||||||
if (m_disconnected)
|
if (q->disconnected())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
Process getEnvProc;
|
Process getEnvProc;
|
||||||
@@ -1028,6 +1024,8 @@ LinuxDevice::LinuxDevice()
|
|||||||
sshParams.timeout = 10;
|
sshParams.timeout = 10;
|
||||||
setSshParameters(sshParams);
|
setSshParameters(sshParams);
|
||||||
|
|
||||||
|
disconnected.setSettingsKey("Disconnected");
|
||||||
|
|
||||||
addDeviceAction({Tr::tr("Deploy Public Key..."), [](const IDevice::Ptr &device, QWidget *parent) {
|
addDeviceAction({Tr::tr("Deploy Public Key..."), [](const IDevice::Ptr &device, QWidget *parent) {
|
||||||
if (auto d = Internal::PublicKeyDeploymentDialog::createDialog(device, parent)) {
|
if (auto d = Internal::PublicKeyDeploymentDialog::createDialog(device, parent)) {
|
||||||
d->exec();
|
d->exec();
|
||||||
@@ -1070,18 +1068,6 @@ LinuxDevice::LinuxDevice()
|
|||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinuxDevice::fromMap(const Utils::Store &map)
|
|
||||||
{
|
|
||||||
IDevice::fromMap(map);
|
|
||||||
d->m_disconnected = map.value(DisconnectedKey, false).toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LinuxDevice::toMap(Utils::Store &map) const
|
|
||||||
{
|
|
||||||
IDevice::toMap(map);
|
|
||||||
map.insert(DisconnectedKey, d->m_disconnected);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LinuxDevice::_setOsType(Utils::OsType osType)
|
void LinuxDevice::_setOsType(Utils::OsType osType)
|
||||||
{
|
{
|
||||||
qCDebug(linuxDeviceLog) << "Setting OS type to" << osType << "for" << displayName();
|
qCDebug(linuxDeviceLog) << "Setting OS type to" << osType << "for" << displayName();
|
||||||
@@ -1093,15 +1079,6 @@ LinuxDevice::~LinuxDevice()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDevice::Ptr LinuxDevice::clone() const
|
|
||||||
{
|
|
||||||
IDevice::Ptr clone = IDevice::clone();
|
|
||||||
Ptr linuxClone = std::dynamic_pointer_cast<LinuxDevice>(clone);
|
|
||||||
QTC_ASSERT(linuxClone, return clone);
|
|
||||||
linuxClone->d->setDisconnected(d->disconnected());
|
|
||||||
return clone;
|
|
||||||
}
|
|
||||||
|
|
||||||
IDeviceWidget *LinuxDevice::createWidget()
|
IDeviceWidget *LinuxDevice::createWidget()
|
||||||
{
|
{
|
||||||
return new Internal::GenericLinuxDeviceConfigurationWidget(shared_from_this());
|
return new Internal::GenericLinuxDeviceConfigurationWidget(shared_from_this());
|
||||||
@@ -1187,21 +1164,16 @@ void LinuxDevicePrivate::queryOsType(std::function<RunResult(const CommandLine &
|
|||||||
|
|
||||||
void LinuxDevicePrivate::setDisconnected(bool disconnected)
|
void LinuxDevicePrivate::setDisconnected(bool disconnected)
|
||||||
{
|
{
|
||||||
if (disconnected == m_disconnected)
|
if (disconnected == q->disconnected())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_disconnected = disconnected;
|
q->disconnected.setValue(disconnected);
|
||||||
|
|
||||||
if (m_disconnected)
|
if (disconnected)
|
||||||
m_handler->closeShell();
|
m_handler->closeShell();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LinuxDevicePrivate::disconnected() const
|
|
||||||
{
|
|
||||||
return m_disconnected;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LinuxDevicePrivate::checkOsType()
|
void LinuxDevicePrivate::checkOsType()
|
||||||
{
|
{
|
||||||
queryOsType([this](const CommandLine &cmd) { return runInShell(cmd); });
|
queryOsType([this](const CommandLine &cmd) { return runInShell(cmd); });
|
||||||
@@ -1271,7 +1243,7 @@ void LinuxDevicePrivate::unannounceConnectionAttempt()
|
|||||||
|
|
||||||
bool LinuxDevicePrivate::checkDisconnectedWithWarning()
|
bool LinuxDevicePrivate::checkDisconnectedWithWarning()
|
||||||
{
|
{
|
||||||
if (!disconnected())
|
if (!q->disconnected())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QMetaObject::invokeMethod(Core::ICore::infoBar(), [id = q->id(), name = q->displayName()] {
|
QMetaObject::invokeMethod(Core::ICore::infoBar(), [id = q->id(), name = q->displayName()] {
|
||||||
@@ -1735,11 +1707,7 @@ QString LinuxDevice::deviceStateToString() const
|
|||||||
|
|
||||||
bool LinuxDevice::isDisconnected() const
|
bool LinuxDevice::isDisconnected() const
|
||||||
{
|
{
|
||||||
return d->disconnected();
|
return disconnected();
|
||||||
}
|
|
||||||
void LinuxDevice::setDisconnected(bool disconnected)
|
|
||||||
{
|
|
||||||
d->setDisconnected(disconnected);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LinuxDevice::tryToConnect()
|
bool LinuxDevice::tryToConnect()
|
||||||
|
@@ -20,8 +20,6 @@ public:
|
|||||||
|
|
||||||
static Ptr create() { return Ptr(new LinuxDevice); }
|
static Ptr create() { return Ptr(new LinuxDevice); }
|
||||||
|
|
||||||
IDevice::Ptr clone() const override;
|
|
||||||
|
|
||||||
ProjectExplorer::IDeviceWidget *createWidget() override;
|
ProjectExplorer::IDeviceWidget *createWidget() override;
|
||||||
|
|
||||||
bool canCreateProcessModel() const override { return true; }
|
bool canCreateProcessModel() const override { return true; }
|
||||||
@@ -48,15 +46,12 @@ public:
|
|||||||
QString deviceStateToString() const override;
|
QString deviceStateToString() const override;
|
||||||
|
|
||||||
bool isDisconnected() const;
|
bool isDisconnected() const;
|
||||||
void setDisconnected(bool disconnected);
|
|
||||||
|
|
||||||
bool tryToConnect();
|
bool tryToConnect();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LinuxDevice();
|
LinuxDevice();
|
||||||
|
|
||||||
void fromMap(const Utils::Store &map) override;
|
Utils::BoolAspect disconnected{this};
|
||||||
void toMap(Utils::Store &map) const override;
|
|
||||||
|
|
||||||
void _setOsType(Utils::OsType osType);
|
void _setOsType(Utils::OsType osType);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user