diff options
author | hjk <[email protected]> | 2023-11-22 17:46:57 +0100 |
---|---|---|
committer | hjk <[email protected]> | 2023-11-24 10:25:51 +0000 |
commit | 353c3cc93081a7d44f42f611f38f0248a26175bd (patch) | |
tree | 92c48e4d1140d4c8ee5ba2094a4cdf8f5aebd4e0 /src/plugins/android/androiddevice.cpp | |
parent | 497b9b3c2cfba811591c609804da26b4ec5cf5fa (diff) |
Android: Use new setup for more plugin items
Change-Id: Id5ff09813ab7b4be425d007abd4cc04d9c9472c1
Reviewed-by: Jarek Kobus <[email protected]>
Diffstat (limited to 'src/plugins/android/androiddevice.cpp')
-rw-r--r-- | src/plugins/android/androiddevice.cpp | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/src/plugins/android/androiddevice.cpp b/src/plugins/android/androiddevice.cpp index 23cfa76592f..3e42b42a930 100644 --- a/src/plugins/android/androiddevice.cpp +++ b/src/plugins/android/androiddevice.cpp @@ -41,8 +41,7 @@ namespace { static Q_LOGGING_CATEGORY(androidDeviceLog, "qtc.android.androiddevice", QtWarningMsg) } -namespace Android { -namespace Internal { +namespace Android::Internal { static constexpr char ipRegexStr[] = "(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})"; static const QRegularExpression ipRegex = QRegularExpression(ipRegexStr); @@ -831,33 +830,44 @@ AndroidDeviceManager::~AndroidDeviceManager() // Factory -AndroidDeviceFactory::AndroidDeviceFactory() - : IDeviceFactory(Constants::ANDROID_DEVICE_TYPE), - m_androidConfig(AndroidConfigurations::currentConfig()) -{ - setDisplayName(Tr::tr("Android Device")); - setCombinedIcon(":/android/images/androiddevicesmall.png", - ":/android/images/androiddevice.png"); - setConstructionFunction(&AndroidDevice::create); - if (m_androidConfig.sdkToolsOk()) { - setCreator([this] { - AvdDialog dialog = AvdDialog(m_androidConfig, Core::ICore::dialogParent()); - if (dialog.exec() != QDialog::Accepted) - return IDevice::Ptr(); - - const IDevice::Ptr dev = dialog.device(); - if (const auto androidDev = static_cast<AndroidDevice *>(dev.data())) { - qCDebug(androidDeviceLog, "Created new Android AVD id \"%s\".", - qPrintable(androidDev->avdName())); - } else { - AndroidDeviceWidget::criticalDialog( +class AndroidDeviceFactory final : public ProjectExplorer::IDeviceFactory +{ +public: + AndroidDeviceFactory() + : IDeviceFactory(Constants::ANDROID_DEVICE_TYPE), + m_androidConfig(AndroidConfigurations::currentConfig()) + { + setDisplayName(Tr::tr("Android Device")); + setCombinedIcon(":/android/images/androiddevicesmall.png", + ":/android/images/androiddevice.png"); + setConstructionFunction(&AndroidDevice::create); + if (m_androidConfig.sdkToolsOk()) { + setCreator([this] { + AvdDialog dialog = AvdDialog(m_androidConfig, Core::ICore::dialogParent()); + if (dialog.exec() != QDialog::Accepted) + return IDevice::Ptr(); + + const IDevice::Ptr dev = dialog.device(); + if (const auto androidDev = static_cast<AndroidDevice *>(dev.data())) { + qCDebug(androidDeviceLog, "Created new Android AVD id \"%s\".", + qPrintable(androidDev->avdName())); + } else { + AndroidDeviceWidget::criticalDialog( Tr::tr("The device info returned from AvdDialog is invalid.")); - } + } - return IDevice::Ptr(dev); - }); + return IDevice::Ptr(dev); + }); + } } + +private: + const AndroidConfig &m_androidConfig; +}; + +void setupAndroidDevice() +{ + static AndroidDeviceFactory theAndroidDeviceFactory; } -} // namespace Internal -} // namespace Android +} // Android::Internal |