forked from qt-creator/qt-creator
QbsProjectManager: Adapt to qbs API change.
Logging API was updated. Change-Id: I78ce4bfeb441d6b496c3331aebf924e7dc81b9c7 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -44,6 +44,10 @@ namespace Internal {
|
|||||||
// QbsLogSink:
|
// QbsLogSink:
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
QbsLogSink::QbsLogSink(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void QbsLogSink::sendMessages()
|
void QbsLogSink::sendMessages()
|
||||||
{
|
{
|
||||||
QStringList toSend;
|
QStringList toSend;
|
||||||
@@ -55,77 +59,20 @@ void QbsLogSink::sendMessages()
|
|||||||
|
|
||||||
Core::MessageManager *mm = Core::MessageManager::instance();
|
Core::MessageManager *mm = Core::MessageManager::instance();
|
||||||
foreach (const QString &msg, toSend)
|
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;
|
Q_UNUSED(tag);
|
||||||
if (logMessage.printLogLevel) {
|
const QString fullMessage = QString::fromLocal8Bit(qbs::logLevelTag(level)) + message;
|
||||||
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));
|
|
||||||
|
|
||||||
{
|
{
|
||||||
QMutexLocker l(&m_mutex);
|
QMutexLocker l(&m_mutex);
|
||||||
m_messages.append(msg);
|
m_messages.append(fullMessage);
|
||||||
}
|
}
|
||||||
QMetaObject::invokeMethod(this, "sendMessages", Qt::QueuedConnection);
|
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 Internal
|
||||||
} // namespace QbsProjectManager
|
} // namespace QbsProjectManager
|
||||||
|
|||||||
@@ -42,14 +42,14 @@ namespace Internal {
|
|||||||
class QbsLogSink : public QObject, public qbs::ILogSink
|
class QbsLogSink : public QObject, public qbs::ILogSink
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
QbsLogSink(QObject *parent = 0);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void sendMessages();
|
void sendMessages();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void outputLogMessage(qbs::LoggerLevel level, const qbs::LogMessage &logMessage);
|
void doPrintMessage(qbs::LoggerLevel level, const QString &message, const QString &tag);
|
||||||
|
|
||||||
QString colorize(qbs::TextColor color, const QByteArray &text);
|
|
||||||
|
|
||||||
QStringList m_messages;
|
QStringList m_messages;
|
||||||
QMutex m_mutex;
|
QMutex m_mutex;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "qbsproject.h"
|
#include "qbsproject.h"
|
||||||
|
|
||||||
#include "qbsbuildconfiguration.h"
|
#include "qbsbuildconfiguration.h"
|
||||||
|
#include "qbslogsink.h"
|
||||||
#include "qbsprojectfile.h"
|
#include "qbsprojectfile.h"
|
||||||
#include "qbsprojectmanagerconstants.h"
|
#include "qbsprojectmanagerconstants.h"
|
||||||
#include "qbsnodes.h"
|
#include "qbsnodes.h"
|
||||||
@@ -389,7 +390,7 @@ void QbsProject::parse(const QVariantMap &config, const QString &dir)
|
|||||||
params.ignoreDifferentProjectFilePath = false;
|
params.ignoreDifferentProjectFilePath = false;
|
||||||
|
|
||||||
m_qbsSetupProjectJob
|
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*)),
|
connect(m_qbsSetupProjectJob, SIGNAL(finished(bool,qbs::AbstractJob*)),
|
||||||
this, SLOT(handleQbsParsingDone(bool)));
|
this, SLOT(handleQbsParsingDone(bool)));
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ QbsManager::QbsManager(Internal::QbsProjectManagerPlugin *plugin) :
|
|||||||
setObjectName(QLatin1String("QbsProjectManager"));
|
setObjectName(QLatin1String("QbsProjectManager"));
|
||||||
connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsChanged()), this, SLOT(pushKitsToQbs()));
|
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;
|
int level = qbs::LoggerWarning;
|
||||||
const QString levelEnv = QString::fromLocal8Bit(qgetenv("QBS_LOG_LEVEL"));
|
const QString levelEnv = QString::fromLocal8Bit(qgetenv("QBS_LOG_LEVEL"));
|
||||||
if (!levelEnv.isEmpty()) {
|
if (!levelEnv.isEmpty()) {
|
||||||
@@ -93,7 +93,7 @@ QbsManager::QbsManager(Internal::QbsProjectManagerPlugin *plugin) :
|
|||||||
tmp = static_cast<int>(qbs::LoggerMaxLevel);
|
tmp = static_cast<int>(qbs::LoggerMaxLevel);
|
||||||
level = tmp;
|
level = tmp;
|
||||||
}
|
}
|
||||||
qbs::Logger::instance().setLevel(level);
|
m_logSink->setLogLevel(static_cast<qbs::LoggerLevel>(level));
|
||||||
}
|
}
|
||||||
|
|
||||||
QbsManager::~QbsManager()
|
QbsManager::~QbsManager()
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class ProjectExplorerPlugin;
|
|||||||
namespace QbsProjectManager {
|
namespace QbsProjectManager {
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
class QbsLogSink;
|
||||||
class QbsProject;
|
class QbsProject;
|
||||||
class QbsProjectManagerPlugin;
|
class QbsProjectManagerPlugin;
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
@@ -68,6 +69,7 @@ public:
|
|||||||
QStringList profileNames() const;
|
QStringList profileNames() const;
|
||||||
|
|
||||||
static qbs::Settings *settings();
|
static qbs::Settings *settings();
|
||||||
|
Internal::QbsLogSink *logSink() { return m_logSink; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void pushKitsToQbs();
|
void pushKitsToQbs();
|
||||||
@@ -79,6 +81,7 @@ private:
|
|||||||
void addProfileFromKit(const ProjectExplorer::Kit *k);
|
void addProfileFromKit(const ProjectExplorer::Kit *k);
|
||||||
|
|
||||||
Internal::QbsProjectManagerPlugin *m_plugin;
|
Internal::QbsProjectManagerPlugin *m_plugin;
|
||||||
|
Internal::QbsLogSink *m_logSink;
|
||||||
static qbs::Settings *m_settings;
|
static qbs::Settings *m_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user