Commit 85387c07 authored by Christian Kandeler's avatar Christian Kandeler

QbsProjectManager: Adapt to qbs API change.

Logging API was updated.

Change-Id: I78ce4bfeb441d6b496c3331aebf924e7dc81b9c7
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 2c872643
......@@ -44,6 +44,10 @@ namespace Internal {
// QbsLogSink:
// --------------------------------------------------------------------
QbsLogSink::QbsLogSink(QObject *parent) : QObject(parent)
{
}
void QbsLogSink::sendMessages()
{
QStringList toSend;
......@@ -55,77 +59,20 @@ void QbsLogSink::sendMessages()
Core::MessageManager *mm = Core::MessageManager::instance();
foreach (const QString &msg, toSend)
mm->printToOutputPanePopup(msg);
mm->printToOutputPane(msg);
}
void QbsLogSink::outputLogMessage(qbs::LoggerLevel level, const qbs::LogMessage &logMessage)
void QbsLogSink::doPrintMessage(qbs::LoggerLevel level, const QString &message, const QString &tag)
{
QString msg;
if (logMessage.printLogLevel) {
QByteArray levelTag = qbs::Logger::logLevelTag(level);
qbs::Internal::TextColor color = qbs::Internal::TextColorDefault;
switch (level) {
case qbs::LoggerError:
color = qbs::Internal::TextColorRed;
break;
case qbs::LoggerWarning:
color = qbs::Internal::TextColorYellow;
break;
default:
break;
}
msg = colorize(color, levelTag);
}
msg.append(colorize(logMessage.textColor, logMessage.data));
Q_UNUSED(tag);
const QString fullMessage = QString::fromLocal8Bit(qbs::logLevelTag(level)) + message;
{
QMutexLocker l(&m_mutex);
m_messages.append(msg);
m_messages.append(fullMessage);
}
QMetaObject::invokeMethod(this, "sendMessages", Qt::QueuedConnection);
}
QString QbsLogSink::colorize(qbs::Internal::TextColor color, const QByteArray &text)
{
switch (color) {
case qbs::Internal::TextColorBlack:
return QString::fromLatin1("<font color=\"rgb(0,0, 0)\">%1</font>").arg(QString::fromLocal8Bit(text));
case qbs::Internal::TextColorDarkRed:
return QString::fromLatin1("<font color=\"rgb(170,0,0)\">%1</font>").arg(QString::fromLocal8Bit(text));
case qbs::Internal::TextColorDarkGreen:
return QString::fromLatin1("<font color=\"rgb(0,170,0)\">%1</font>").arg(QString::fromLocal8Bit(text));
case qbs::Internal::TextColorDarkBlue:
return QString::fromLatin1("<font color=\"rgb(0,0,170)\">%1</font>").arg(QString::fromLocal8Bit(text));
case qbs::Internal::TextColorDarkCyan:
return QString::fromLatin1("<font color=\"rgb(0,170,170)\">%1</font>").arg(QString::fromLocal8Bit(text));
case qbs::Internal::TextColorDarkMagenta:
return QString::fromLatin1("<font color=\"rgb(170,0,170)\">%1</font>").arg(QString::fromLocal8Bit(text));
case qbs::Internal::TextColorDarkYellow:
return QString::fromLatin1("<font color=\"rgb(170,85,0)\">%1</font>").arg(QString::fromLocal8Bit(text));
case qbs::Internal::TextColorGray:
return QString::fromLatin1("<font color=\"rgb(170,170,170)\">%1</font>").arg(QString::fromLocal8Bit(text));
case qbs::Internal::TextColorRed:
return QString::fromLatin1("<font color=\"rgb(255,85,85)\">%1</font>").arg(QString::fromLocal8Bit(text));
case qbs::Internal::TextColorGreen:
return QString::fromLatin1("<font color=\"rgb(85,255,85)\">%1</font>").arg(QString::fromLocal8Bit(text));
case qbs::Internal::TextColorBlue:
return QString::fromLatin1("<font color=\"rgb(85,85,255)\">%1</font>").arg(QString::fromLocal8Bit(text));
case qbs::Internal::TextColorCyan:
return QString::fromLatin1("<font color=\"rgb(85,255,255)\">%1</font>").arg(QString::fromLocal8Bit(text));
case qbs::Internal::TextColorMagenta:
return QString::fromLatin1("<font color=\"rgb(255,85,255)\">%1</font>").arg(QString::fromLocal8Bit(text));
case qbs::Internal::TextColorYellow:
return QString::fromLatin1("<font color=\"rgb(255,255,85)\">%1</font>").arg(QString::fromLocal8Bit(text));
case qbs::Internal::TextColorWhite:
return QString::fromLatin1("<font color=\"rgb(255,255,255)\">%1</font>").arg(QString::fromLocal8Bit(text));
case qbs::Internal::TextColorBright:
case qbs::Internal::TextColorDefault:
// fallthrough:
default:
return QString::fromLocal8Bit(text);
}
}
} // namespace Internal
} // namespace QbsProjectManager
......@@ -42,14 +42,14 @@ namespace Internal {
class QbsLogSink : public QObject, public qbs::ILogSink
{
Q_OBJECT
public:
QbsLogSink(QObject *parent = 0);
private slots:
void sendMessages();
private:
void outputLogMessage(qbs::LoggerLevel level, const qbs::LogMessage &logMessage);
QString colorize(qbs::TextColor color, const QByteArray &text);
void doPrintMessage(qbs::LoggerLevel level, const QString &message, const QString &tag);
QStringList m_messages;
QMutex m_mutex;
......
......@@ -30,6 +30,7 @@
#include "qbsproject.h"
#include "qbsbuildconfiguration.h"
#include "qbslogsink.h"
#include "qbsprojectfile.h"
#include "qbsprojectmanagerconstants.h"
#include "qbsnodes.h"
......@@ -389,7 +390,7 @@ void QbsProject::parse(const QVariantMap &config, const QString &dir)
params.ignoreDifferentProjectFilePath = false;
m_qbsSetupProjectJob
= qbs::Project::setupProject(params, m_manager->settings(), 0);
= qbs::Project::setupProject(params, m_manager->settings(), m_manager->logSink(), 0);
connect(m_qbsSetupProjectJob, SIGNAL(finished(bool,qbs::AbstractJob*)),
this, SLOT(handleQbsParsingDone(bool)));
......
......@@ -82,7 +82,7 @@ QbsManager::QbsManager(Internal::QbsProjectManagerPlugin *plugin) :
setObjectName(QLatin1String("QbsProjectManager"));
connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsChanged()), this, SLOT(pushKitsToQbs()));
qbs::Logger::instance().setLogSink(new Internal::QbsLogSink);
m_logSink = new Internal::QbsLogSink(this);
int level = qbs::LoggerWarning;
const QString levelEnv = QString::fromLocal8Bit(qgetenv("QBS_LOG_LEVEL"));
if (!levelEnv.isEmpty()) {
......@@ -93,7 +93,7 @@ QbsManager::QbsManager(Internal::QbsProjectManagerPlugin *plugin) :
tmp = static_cast<int>(qbs::LoggerMaxLevel);
level = tmp;
}
qbs::Logger::instance().setLevel(level);
m_logSink->setLogLevel(static_cast<qbs::LoggerLevel>(level));
}
QbsManager::~QbsManager()
......
......@@ -47,6 +47,7 @@ class ProjectExplorerPlugin;
namespace QbsProjectManager {
namespace Internal {
class QbsLogSink;
class QbsProject;
class QbsProjectManagerPlugin;
} // namespace Internal
......@@ -68,6 +69,7 @@ public:
QStringList profileNames() const;
static qbs::Settings *settings();
Internal::QbsLogSink *logSink() { return m_logSink; }
private slots:
void pushKitsToQbs();
......@@ -79,6 +81,7 @@ private:
void addProfileFromKit(const ProjectExplorer::Kit *k);
Internal::QbsProjectManagerPlugin *m_plugin;
Internal::QbsLogSink *m_logSink;
static qbs::Settings *m_settings;
};
......
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