forked from qt-creator/qt-creator
Analyzer: Add status label.
Factor out the status label with timeout from the debugger plugin. Use in analyzer manager, add standard messages and use that in memcheck. Task-number: QTCREATORBUG-4077 Reviewed-by: Daniel Molkentin <daniel.molkentin@nokia.com>
This commit is contained in:
87
src/libs/utils/statuslabel.cpp
Normal file
87
src/libs/utils/statuslabel.cpp
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** No Commercial Usage
|
||||||
|
**
|
||||||
|
** This file contains pre-release code and may not be distributed.
|
||||||
|
** You may use this file in accordance with the terms and conditions
|
||||||
|
** contained in the Technology Preview License Agreement accompanying
|
||||||
|
** this package.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Nokia gives you certain additional
|
||||||
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** If you have questions regarding the use of this file, please contact
|
||||||
|
** Nokia at qt-info@nokia.com.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "statuslabel.h"
|
||||||
|
|
||||||
|
#include <QtCore/QTimer>
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class Utils::StatusLabel
|
||||||
|
|
||||||
|
\brief A status label that displays messages for a while with a timeout.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Utils {
|
||||||
|
|
||||||
|
StatusLabel::StatusLabel(QWidget *parent) : QLabel(parent), m_timer(0)
|
||||||
|
{
|
||||||
|
// A manual size let's us shrink below minimum text width which is what
|
||||||
|
// we want in [fake] status bars.
|
||||||
|
setMinimumSize(QSize(30, 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatusLabel::stopTimer()
|
||||||
|
{
|
||||||
|
if (m_timer && m_timer->isActive())
|
||||||
|
m_timer->stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatusLabel::showStatusMessage(const QString &message, int timeoutMS)
|
||||||
|
{
|
||||||
|
setText(message);
|
||||||
|
if (timeoutMS > 0) {
|
||||||
|
if (!m_timer) {
|
||||||
|
m_timer = new QTimer(this);
|
||||||
|
m_timer->setSingleShot(true);
|
||||||
|
connect(m_timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));
|
||||||
|
}
|
||||||
|
m_timer->start(timeoutMS);
|
||||||
|
} else {
|
||||||
|
m_lastPermanentStatusMessage = message;
|
||||||
|
stopTimer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatusLabel::slotTimeout()
|
||||||
|
{
|
||||||
|
setText(m_lastPermanentStatusMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatusLabel::clearStatusMessage()
|
||||||
|
{
|
||||||
|
stopTimer();
|
||||||
|
m_lastPermanentStatusMessage.clear();
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Utils
|
||||||
67
src/libs/utils/statuslabel.h
Normal file
67
src/libs/utils/statuslabel.h
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** No Commercial Usage
|
||||||
|
**
|
||||||
|
** This file contains pre-release code and may not be distributed.
|
||||||
|
** You may use this file in accordance with the terms and conditions
|
||||||
|
** contained in the Technology Preview License Agreement accompanying
|
||||||
|
** this package.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Nokia gives you certain additional
|
||||||
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** If you have questions regarding the use of this file, please contact
|
||||||
|
** Nokia at qt-info@nokia.com.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef UTILS_STATUSLABEL_H
|
||||||
|
#define UTILS_STATUSLABEL_H
|
||||||
|
|
||||||
|
#include "utils_global.h"
|
||||||
|
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QTimer)
|
||||||
|
|
||||||
|
#include <QtGui/QLabel>
|
||||||
|
|
||||||
|
namespace Utils {
|
||||||
|
|
||||||
|
class QTCREATOR_UTILS_EXPORT StatusLabel : public QLabel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit StatusLabel(QWidget *parent = 0);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void showStatusMessage(const QString &message, int timeoutMS = 5000);
|
||||||
|
void clearStatusMessage();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void slotTimeout();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void stopTimer();
|
||||||
|
|
||||||
|
QTimer *m_timer;
|
||||||
|
QString m_lastPermanentStatusMessage;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Utils
|
||||||
|
|
||||||
|
#endif // UTILS_STATUSLABEL_H
|
||||||
@@ -57,6 +57,7 @@ SOURCES += $$PWD/environment.cpp \
|
|||||||
$$PWD/annotateditemdelegate.cpp \
|
$$PWD/annotateditemdelegate.cpp \
|
||||||
$$PWD/fileinprojectfinder.cpp \
|
$$PWD/fileinprojectfinder.cpp \
|
||||||
$$PWD/ipaddresslineedit.cpp \
|
$$PWD/ipaddresslineedit.cpp \
|
||||||
|
$$PWD/statuslabel.cpp \
|
||||||
$$PWD/ssh/sshsendfacility.cpp \
|
$$PWD/ssh/sshsendfacility.cpp \
|
||||||
$$PWD/ssh/sshremoteprocess.cpp \
|
$$PWD/ssh/sshremoteprocess.cpp \
|
||||||
$$PWD/ssh/sshpacketparser.cpp \
|
$$PWD/ssh/sshpacketparser.cpp \
|
||||||
@@ -169,7 +170,8 @@ HEADERS += $$PWD/environment.h \
|
|||||||
$$PWD/ssh/sftpchannel.h \
|
$$PWD/ssh/sftpchannel.h \
|
||||||
$$PWD/ssh/sftpchannel_p.h \
|
$$PWD/ssh/sftpchannel_p.h \
|
||||||
$$PWD/ssh/sshremoteprocessrunner.h \
|
$$PWD/ssh/sshremoteprocessrunner.h \
|
||||||
$$PWD/settingsutils.h
|
$$PWD/settingsutils.h \
|
||||||
|
$$PWD/statuslabel.h
|
||||||
|
|
||||||
FORMS += $$PWD/filewizardpage.ui \
|
FORMS += $$PWD/filewizardpage.ui \
|
||||||
$$PWD/projectintropage.ui \
|
$$PWD/projectintropage.ui \
|
||||||
|
|||||||
@@ -71,6 +71,7 @@
|
|||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/checkablemessagebox.h>
|
#include <utils/checkablemessagebox.h>
|
||||||
|
#include <utils/statuslabel.h>
|
||||||
|
|
||||||
#include <cmakeprojectmanager/cmakeprojectconstants.h>
|
#include <cmakeprojectmanager/cmakeprojectconstants.h>
|
||||||
#include <qt4projectmanager/qt4projectmanagerconstants.h>
|
#include <qt4projectmanager/qt4projectmanagerconstants.h>
|
||||||
@@ -210,6 +211,7 @@ public:
|
|||||||
QMenu *m_menu;
|
QMenu *m_menu;
|
||||||
QComboBox *m_toolBox;
|
QComboBox *m_toolBox;
|
||||||
ActionContainer *m_viewsMenu;
|
ActionContainer *m_viewsMenu;
|
||||||
|
Utils::StatusLabel *m_statusLabel;
|
||||||
typedef QPair<Qt::DockWidgetArea, QDockWidget*> ToolWidgetPair;
|
typedef QPair<Qt::DockWidgetArea, QDockWidget*> ToolWidgetPair;
|
||||||
typedef QList<ToolWidgetPair> ToolWidgetPairList;
|
typedef QList<ToolWidgetPair> ToolWidgetPairList;
|
||||||
QMap<IAnalyzerTool*, ToolWidgetPairList> m_toolWidgets;
|
QMap<IAnalyzerTool*, ToolWidgetPairList> m_toolWidgets;
|
||||||
@@ -236,6 +238,7 @@ AnalyzerManager::AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager
|
|||||||
m_menu(0),
|
m_menu(0),
|
||||||
m_toolBox(new QComboBox),
|
m_toolBox(new QComboBox),
|
||||||
m_viewsMenu(0),
|
m_viewsMenu(0),
|
||||||
|
m_statusLabel(new Utils::StatusLabel),
|
||||||
m_resizeEventFilter(new DockWidgetEventFilter(qq)),
|
m_resizeEventFilter(new DockWidgetEventFilter(qq)),
|
||||||
m_initialized(false)
|
m_initialized(false)
|
||||||
{
|
{
|
||||||
@@ -339,12 +342,13 @@ static QToolButton *toolButton(QAction *action)
|
|||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidgetList AnalyzerManager::outputPaneToolBarWidgets() const
|
void AnalyzerManager::addOutputPaneToolBarWidgets(QWidgetList *list) const
|
||||||
{
|
{
|
||||||
QWidgetList result;
|
list->prepend(d->m_toolBox);
|
||||||
result << toolButton(d->m_startAction) << toolButton(d->m_stopAction)
|
list->prepend(toolButton(d->m_stopAction));
|
||||||
<< new Utils::StyledSeparator << d->m_toolBox;
|
list->prepend(toolButton(d->m_startAction));
|
||||||
return result;
|
(*list) << new Utils::StyledSeparator << d->m_statusLabel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *AnalyzerManager::AnalyzerManagerPrivate::createModeMainWindow()
|
QWidget *AnalyzerManager::AnalyzerManagerPrivate::createModeMainWindow()
|
||||||
@@ -733,4 +737,26 @@ void AnalyzerManager::updateRunActions()
|
|||||||
d->m_startAction->setEnabled(startEnabled);
|
d->m_startAction->setEnabled(startEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AnalyzerManager::showStatusMessage(const QString &message, int timeoutMS)
|
||||||
|
{
|
||||||
|
d->m_statusLabel->showStatusMessage(message, timeoutMS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnalyzerManager::showPermanentStatusMessage(const QString &message)
|
||||||
|
{
|
||||||
|
showStatusMessage(message, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AnalyzerManager::msgToolStarted(const QString &name)
|
||||||
|
{
|
||||||
|
return tr("Tool '%1' started...").arg(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AnalyzerManager::msgToolFinished(const QString &name, int issuesFound)
|
||||||
|
{
|
||||||
|
return issuesFound ?
|
||||||
|
tr("Tool '%1' finished, %n issues were found.", 0, issuesFound).arg(name) :
|
||||||
|
tr("Tool '%1' finished, no issues were found.").arg(name);
|
||||||
|
}
|
||||||
|
|
||||||
#include "analyzermanager.moc"
|
#include "analyzermanager.moc"
|
||||||
|
|||||||
@@ -88,7 +88,14 @@ public:
|
|||||||
|
|
||||||
void selectTool(IAnalyzerTool *tool);
|
void selectTool(IAnalyzerTool *tool);
|
||||||
|
|
||||||
QList<QWidget *> outputPaneToolBarWidgets() const;
|
void addOutputPaneToolBarWidgets(QList<QWidget *> *) const;
|
||||||
|
|
||||||
|
static QString msgToolStarted(const QString &name);
|
||||||
|
static QString msgToolFinished(const QString &name, int issuesFound);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void showStatusMessage(const QString &message, int timeoutMS = 10000);
|
||||||
|
void showPermanentStatusMessage(const QString &message);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void startTool();
|
void startTool();
|
||||||
|
|||||||
@@ -227,8 +227,9 @@ QWidgetList AnalyzerOutputPane::toolBarWidgets() const
|
|||||||
qDebug() << "AnalyzerOutputPane::toolBarWidget";
|
qDebug() << "AnalyzerOutputPane::toolBarWidget";
|
||||||
QTC_ASSERT(isInitialized(), return QWidgetList(); )
|
QTC_ASSERT(isInitialized(), return QWidgetList(); )
|
||||||
|
|
||||||
QWidgetList list = AnalyzerManager::instance()->outputPaneToolBarWidgets();
|
QWidgetList list;
|
||||||
list << m_toolBarSeparator << m_toolbarStackedWidget;
|
list << m_toolBarSeparator << m_toolbarStackedWidget;
|
||||||
|
AnalyzerManager::instance()->addOutputPaneToolBarWidgets(&list);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,6 +106,7 @@
|
|||||||
#include <utils/savedaction.h>
|
#include <utils/savedaction.h>
|
||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
#include <utils/proxyaction.h>
|
#include <utils/proxyaction.h>
|
||||||
|
#include <utils/statuslabel.h>
|
||||||
|
|
||||||
#include <qml/scriptconsole.h>
|
#include <qml/scriptconsole.h>
|
||||||
|
|
||||||
@@ -746,8 +747,6 @@ public slots:
|
|||||||
void updateWatchersWindow();
|
void updateWatchersWindow();
|
||||||
void onCurrentProjectChanged(ProjectExplorer::Project *project);
|
void onCurrentProjectChanged(ProjectExplorer::Project *project);
|
||||||
|
|
||||||
void clearStatusMessage();
|
|
||||||
|
|
||||||
void sessionLoaded();
|
void sessionLoaded();
|
||||||
void aboutToUnloadSession();
|
void aboutToUnloadSession();
|
||||||
void aboutToSaveSession();
|
void aboutToSaveSession();
|
||||||
@@ -1018,7 +1017,7 @@ public:
|
|||||||
QIcon m_interruptIcon;
|
QIcon m_interruptIcon;
|
||||||
QIcon m_locationMarkIcon;
|
QIcon m_locationMarkIcon;
|
||||||
|
|
||||||
QLabel *m_statusLabel;
|
Utils::StatusLabel *m_statusLabel;
|
||||||
QComboBox *m_threadBox;
|
QComboBox *m_threadBox;
|
||||||
|
|
||||||
BreakWindow *m_breakWindow;
|
BreakWindow *m_breakWindow;
|
||||||
@@ -1037,7 +1036,6 @@ public:
|
|||||||
ScriptConsole *m_scriptConsoleWindow;
|
ScriptConsole *m_scriptConsoleWindow;
|
||||||
|
|
||||||
bool m_busy;
|
bool m_busy;
|
||||||
QTimer m_statusTimer;
|
|
||||||
QString m_lastPermanentStatusMessage;
|
QString m_lastPermanentStatusMessage;
|
||||||
|
|
||||||
mutable CPlusPlus::Snapshot m_codeModelSnapshot;
|
mutable CPlusPlus::Snapshot m_codeModelSnapshot;
|
||||||
@@ -2152,11 +2150,6 @@ void DebuggerPluginPrivate::dumpLog()
|
|||||||
ts << m_logWindow->combinedContents();
|
ts << m_logWindow->combinedContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerPluginPrivate::clearStatusMessage()
|
|
||||||
{
|
|
||||||
m_statusLabel->setText(m_lastPermanentStatusMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Activates the previous mode when the current mode is the debug mode. */
|
/*! Activates the previous mode when the current mode is the debug mode. */
|
||||||
void DebuggerPluginPrivate::activatePreviousMode()
|
void DebuggerPluginPrivate::activatePreviousMode()
|
||||||
{
|
{
|
||||||
@@ -2216,15 +2209,8 @@ void DebuggerPluginPrivate::showStatusMessage(const QString &msg0, int timeout)
|
|||||||
{
|
{
|
||||||
showMessage(msg0, LogStatus);
|
showMessage(msg0, LogStatus);
|
||||||
QString msg = msg0;
|
QString msg = msg0;
|
||||||
msg.replace(QLatin1Char('\n'), QString());
|
msg.remove(QLatin1Char('\n'));
|
||||||
m_statusLabel->setText(msg);
|
m_statusLabel->showStatusMessage(msg, timeout);
|
||||||
if (timeout > 0) {
|
|
||||||
m_statusTimer.setSingleShot(true);
|
|
||||||
m_statusTimer.start(timeout);
|
|
||||||
} else {
|
|
||||||
m_lastPermanentStatusMessage = msg;
|
|
||||||
m_statusTimer.stop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerPluginPrivate::scriptExpressionEntered(const QString &expression)
|
void DebuggerPluginPrivate::scriptExpressionEntered(const QString &expression)
|
||||||
@@ -2550,8 +2536,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
|
|||||||
|
|
||||||
m_busy = false;
|
m_busy = false;
|
||||||
|
|
||||||
m_statusLabel = new QLabel;
|
m_statusLabel = new Utils::StatusLabel;
|
||||||
m_statusLabel->setMinimumSize(QSize(30, 10));
|
|
||||||
|
|
||||||
m_breakHandler = new BreakHandler;
|
m_breakHandler = new BreakHandler;
|
||||||
m_breakWindow = new BreakWindow;
|
m_breakWindow = new BreakWindow;
|
||||||
@@ -2674,8 +2659,6 @@ void DebuggerPluginPrivate::extensionsInitialized()
|
|||||||
connect(action(OperateByInstruction), SIGNAL(triggered(bool)),
|
connect(action(OperateByInstruction), SIGNAL(triggered(bool)),
|
||||||
SLOT(handleOperateByInstructionTriggered(bool)));
|
SLOT(handleOperateByInstructionTriggered(bool)));
|
||||||
|
|
||||||
connect(&m_statusTimer, SIGNAL(timeout()), SLOT(clearStatusMessage()));
|
|
||||||
|
|
||||||
ActionContainer *debugMenu =
|
ActionContainer *debugMenu =
|
||||||
am->actionContainer(ProjectExplorer::Constants::M_DEBUG);
|
am->actionContainer(ProjectExplorer::Constants::M_DEBUG);
|
||||||
|
|
||||||
|
|||||||
@@ -430,6 +430,8 @@ IAnalyzerEngine *MemcheckTool::createEngine(ProjectExplorer::RunConfiguration *r
|
|||||||
this, SLOT(parserError(Valgrind::XmlProtocol::Error)));
|
this, SLOT(parserError(Valgrind::XmlProtocol::Error)));
|
||||||
connect(engine, SIGNAL(internalParserError(QString)),
|
connect(engine, SIGNAL(internalParserError(QString)),
|
||||||
this, SLOT(internalParserError(QString)));
|
this, SLOT(internalParserError(QString)));
|
||||||
|
connect(engine, SIGNAL(finished()), this, SLOT(finished()));
|
||||||
|
AnalyzerManager::instance()->showStatusMessage(AnalyzerManager::msgToolStarted(displayName()));
|
||||||
return engine;
|
return engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,5 +525,11 @@ IAnalyzerOutputPaneAdapter *MemcheckTool::outputPaneAdapter()
|
|||||||
return m_outputPaneAdapter;
|
return m_outputPaneAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MemcheckTool::finished()
|
||||||
|
{
|
||||||
|
const QString msg = AnalyzerManager::msgToolFinished(displayName(), m_errorModel->rowCount());
|
||||||
|
AnalyzerManager::instance()->showStatusMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Analyzer
|
} // namespace Analyzer
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ private slots:
|
|||||||
void internalParserError(const QString &errorString);
|
void internalParserError(const QString &errorString);
|
||||||
void updateErrorFilter();
|
void updateErrorFilter();
|
||||||
void suppressionActionTriggered();
|
void suppressionActionTriggered();
|
||||||
|
void finished();
|
||||||
QMenu *filterMenu() const;
|
QMenu *filterMenu() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user