diff --git a/src/plugins/debugger/debuggeritem.cpp b/src/plugins/debugger/debuggeritem.cpp index dfa45da6d9b..6709bb4c55c 100644 --- a/src/plugins/debugger/debuggeritem.cpp +++ b/src/plugins/debugger/debuggeritem.cpp @@ -306,24 +306,46 @@ QDateTime DebuggerItem::lastModified() const return m_lastModified; } -QIcon DebuggerItem::decoration() const +DebuggerItem::Problem DebuggerItem::problem() const { if (isGeneric()) - return {}; + return Problem::None; if (m_engineType == NoEngineType) - return Icons::CRITICAL.icon(); + return Problem::NoEngine; if (!m_command.isExecutableFile()) - return Icons::WARNING.icon(); + return Problem::InvalidCommand; if (!m_workingDirectory.isEmpty() && !m_workingDirectory.isDir()) + return Problem::InvalidWorkingDir; + return Problem::None; +} + +QIcon DebuggerItem::decoration() const +{ + switch (problem()) { + case Problem::NoEngine: + return Icons::CRITICAL.icon(); + case Problem::InvalidCommand: + case Problem::InvalidWorkingDir: return Icons::WARNING.icon(); + case Problem::None: + break; + } return {}; } QString DebuggerItem::validityMessage() const { - if (m_engineType == NoEngineType) + switch (problem()) { + case Problem::NoEngine: return Tr::tr("Could not determine debugger type"); - return QString(); + case Problem::InvalidCommand: + return Tr::tr("Invalid debugger command"); + case Problem::InvalidWorkingDir: + return Tr::tr("Invalid working directory"); + case Problem::None: + break; + } + return {}; } bool DebuggerItem::operator==(const DebuggerItem &other) const diff --git a/src/plugins/debugger/debuggeritem.h b/src/plugins/debugger/debuggeritem.h index dcdd80ad7ce..96e3cf4cc57 100644 --- a/src/plugins/debugger/debuggeritem.h +++ b/src/plugins/debugger/debuggeritem.h @@ -67,6 +67,8 @@ public: QStringList abiNames() const; QDateTime lastModified() const; + enum class Problem { NoEngine, InvalidCommand, InvalidWorkingDir, None }; + Problem problem() const; QIcon decoration() const; QString validityMessage() const;