forked from qt-creator/qt-creator
Boot2Qt: Simplify QdbUtils
Change-Id: Ief211d00812284828197f34bc2aaf4a72bdffda4 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -143,7 +143,7 @@ QdbDevice::QdbDevice()
|
||||
}});
|
||||
|
||||
addDeviceAction({tr("Restore Default App"), [](const IDevice::Ptr &device, QWidget *) {
|
||||
CommandLine cmd{FilePath::fromString(appControllerFilePath()), {"--remove-default"}};
|
||||
CommandLine cmd{FilePath::fromString("appcontroller"), {"--remove-default"}};
|
||||
(void) new DeviceApplicationObserver(device, cmd);
|
||||
}});
|
||||
}
|
||||
|
@@ -78,6 +78,15 @@ static void startFlashingWizard()
|
||||
showMessage(message.arg(filePath), true);
|
||||
}
|
||||
|
||||
static bool isFlashActionDisabled()
|
||||
{
|
||||
QSettings * const settings = Core::ICore::settings();
|
||||
settings->beginGroup(settingsGroupKey());
|
||||
bool disabled = settings->value("flashActionDisabled", false).toBool();
|
||||
settings->endGroup();
|
||||
return disabled;
|
||||
}
|
||||
|
||||
void registerFlashAction(QObject *parentForAction)
|
||||
{
|
||||
if (isFlashActionDisabled())
|
||||
|
@@ -39,8 +39,6 @@ namespace Internal {
|
||||
static QString executableBaseName(QdbTool tool)
|
||||
{
|
||||
switch (tool) {
|
||||
case QdbTool::Adb:
|
||||
return QLatin1String("adb");
|
||||
case QdbTool::FlashingWizard:
|
||||
return QLatin1String("b2qt-flashing-wizard");
|
||||
case QdbTool::Qdb:
|
||||
@@ -50,24 +48,15 @@ static QString executableBaseName(QdbTool tool)
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString appControllerFilePath()
|
||||
{
|
||||
return QLatin1String("appcontroller");
|
||||
}
|
||||
|
||||
Utils::FilePath findTool(QdbTool tool, PathSource *source)
|
||||
Utils::FilePath findTool(QdbTool tool)
|
||||
{
|
||||
QString filePath = QString::fromLocal8Bit(qgetenv(overridingEnvironmentVariable(tool)));
|
||||
if (source)
|
||||
*source = PathSource::Environment;
|
||||
|
||||
if (filePath.isEmpty()) {
|
||||
QSettings * const settings = Core::ICore::settings();
|
||||
settings->beginGroup(settingsGroupKey());
|
||||
filePath = settings->value(settingsKey(tool)).toString();
|
||||
settings->endGroup();
|
||||
if (source)
|
||||
*source = PathSource::Settings;
|
||||
}
|
||||
|
||||
if (filePath.isEmpty()) {
|
||||
@@ -79,27 +68,14 @@ Utils::FilePath findTool(QdbTool tool, PathSource *source)
|
||||
+ QLatin1String("/../../b2qt/")
|
||||
#endif
|
||||
+ executableBaseName(tool));
|
||||
if (source)
|
||||
*source = PathSource::Fallback;
|
||||
}
|
||||
|
||||
return Utils::FilePath::fromString(QDir::cleanPath(filePath));
|
||||
}
|
||||
|
||||
bool isFlashActionDisabled()
|
||||
{
|
||||
QSettings * const settings = Core::ICore::settings();
|
||||
settings->beginGroup(settingsGroupKey());
|
||||
bool disabled = settings->value("flashActionDisabled", false).toBool();
|
||||
settings->endGroup();
|
||||
return disabled;
|
||||
}
|
||||
|
||||
const char *overridingEnvironmentVariable(QdbTool tool)
|
||||
{
|
||||
switch (tool) {
|
||||
case QdbTool::Adb:
|
||||
return "BOOT2QT_ADB_FILEPATH";
|
||||
case QdbTool::FlashingWizard:
|
||||
return "BOOT2QT_FLASHWIZARD_FILEPATH";
|
||||
case QdbTool::Qdb:
|
||||
@@ -124,8 +100,6 @@ QString settingsGroupKey()
|
||||
QString settingsKey(QdbTool tool)
|
||||
{
|
||||
switch (tool) {
|
||||
case QdbTool::Adb:
|
||||
return QLatin1String("adbFilePath");
|
||||
case QdbTool::FlashingWizard:
|
||||
return QLatin1String("flashingWizardFilePath");
|
||||
case QdbTool::Qdb:
|
||||
|
@@ -33,20 +33,11 @@ namespace Qdb {
|
||||
namespace Internal {
|
||||
|
||||
enum class QdbTool {
|
||||
Adb,
|
||||
FlashingWizard,
|
||||
Qdb
|
||||
};
|
||||
|
||||
enum class PathSource {
|
||||
Environment,
|
||||
Settings,
|
||||
Fallback
|
||||
};
|
||||
|
||||
QString appControllerFilePath();
|
||||
Utils::FilePath findTool(QdbTool tool, PathSource *source = nullptr);
|
||||
bool isFlashActionDisabled();
|
||||
Utils::FilePath findTool(QdbTool tool);
|
||||
const char *overridingEnvironmentVariable(QdbTool tool);
|
||||
void showMessage(const QString &message, bool important = false);
|
||||
QString settingsGroupKey();
|
||||
|
Reference in New Issue
Block a user