Use data-error/warning/information icons to mark problems

parent 09e418c2
Pipeline #15174 passed with stage
in 48 minutes and 35 seconds
......@@ -19,8 +19,28 @@
#include "iproblem.h"
// Qt
#include <QIcon>
#include <QString>
using namespace KDevelop;
QIcon IProblem::iconForSeverity(IProblem::Severity severity)
{
switch (severity) {
case IProblem::Hint:
return QIcon::fromTheme(QStringLiteral("data-information"), QIcon::fromTheme(QStringLiteral("dialog-information")));
case IProblem::Warning:
return QIcon::fromTheme(QStringLiteral("data-warning"), QIcon::fromTheme(QStringLiteral("dialog-warning")));
case IProblem::Error:
return QIcon::fromTheme(QStringLiteral("data-error"), QIcon::fromTheme(QStringLiteral("dialog-error")));
case IProblem::NoSeverity:
return {};
}
Q_UNREACHABLE();
return {};
}
IProblem::IProblem()
{
}
......
......@@ -27,6 +27,8 @@
#include "interfacesexport.h"
class QIcon;
namespace KDevelop
{
class IAssistant;
......@@ -79,6 +81,8 @@ public:
TrimmedLine
};
static QIcon iconForSeverity(IProblem::Severity severity);
IProblem();
virtual ~IProblem();
......
......@@ -39,22 +39,6 @@ using namespace KDevelop;
namespace {
QString KEY_INVOKE_ACTION(int num) { return QStringLiteral("invoke_action_%1").arg(num); }
QIcon iconForSeverity(IProblem::Severity severity)
{
switch (severity) {
case IProblem::Hint:
return QIcon::fromTheme(QStringLiteral("dialog-information"));
case IProblem::Warning:
return QIcon::fromTheme(QStringLiteral("dialog-warning"));
case IProblem::Error:
return QIcon::fromTheme(QStringLiteral("dialog-error"));
case IProblem::NoSeverity:
return {};
}
Q_UNREACHABLE();
return {};
}
QString htmlImg(const QIcon& icon, QStyle::PixelMetric metric)
{
const int size = qApp->style()->pixelMetric(metric, nullptr, nullptr);
......@@ -134,7 +118,7 @@ void ProblemNavigationContext::html(IProblem::Ptr problem)
modifyHtml() += QStringLiteral("<table><tr>");
modifyHtml() += QStringLiteral("<td valign=\"middle\">%1</td>")
.arg(htmlImg(iconForSeverity(problem->severity()), QStyle::PM_LargeIconSize));
.arg(htmlImg(IProblem::iconForSeverity(problem->severity()), QStyle::PM_LargeIconSize));
// BEGIN: right column
modifyHtml() += QStringLiteral("<td>");
......
......@@ -39,25 +39,6 @@
#include <shell/problemconstants.h>
#include <shell/watcheddocumentset.h>
namespace {
QIcon iconForSeverity(KDevelop::IProblem::Severity severity)
{
switch (severity) {
case KDevelop::IProblem::Hint:
return QIcon::fromTheme(QStringLiteral("dialog-information"));
case KDevelop::IProblem::Warning:
return QIcon::fromTheme(QStringLiteral("dialog-warning"));
case KDevelop::IProblem::Error:
return QIcon::fromTheme(QStringLiteral("dialog-error"));
case KDevelop::IProblem::NoSeverity:
return {};
}
return {};
}
}
namespace KDevelop
{
......@@ -195,7 +176,7 @@ QVariant ProblemModel::data(const QModelIndex& index, int role) const
case Qt::DecorationRole:
if (index.column() == Error) {
return iconForSeverity(p->severity());
return IProblem::iconForSeverity(p->severity());
}
break;
case Qt::ToolTipRole:
......
......@@ -119,17 +119,17 @@ void ProblemsView::setupActions()
m_errorSeverityAction = new QAction(this);
m_errorSeverityAction->setToolTip(i18nc("@info:tooltip", "Display errors"));
m_errorSeverityAction->setIcon(QIcon::fromTheme(QStringLiteral("dialog-error")));
m_errorSeverityAction->setIcon(IProblem::iconForSeverity(IProblem::Error));
m_errorSeverityAction->setIconText(i18n("Show Errors"));
m_warningSeverityAction = new QAction(this);
m_warningSeverityAction->setToolTip(i18nc("@info:tooltip", "Display warnings"));
m_warningSeverityAction->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning")));
m_warningSeverityAction->setIcon(IProblem::iconForSeverity(IProblem::Warning));
m_warningSeverityAction->setIconText(i18n("Show Warnings"));
m_hintSeverityAction = new QAction(this);
m_hintSeverityAction->setToolTip(i18nc("@info:tooltip", "Display hints"));
m_hintSeverityAction->setIcon(QIcon::fromTheme(QStringLiteral("dialog-information")));
m_hintSeverityAction->setIcon(IProblem::iconForSeverity(IProblem::Hint));
m_hintSeverityAction->setIconText(i18n("Show Hints"));
QAction* const severityActionArray[] = { m_errorSeverityAction, m_warningSeverityAction, m_hintSeverityAction };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment