Files
qt-creator/src/libs/utils/statuslabel.cpp
Leena Miettinen 8c288bf05f Doc: Add "\inmodule QtCreator" to \class and \namespace docs
To get rid of QDoc warnings.

Change-Id: Idd39b7ae4327798c376f424c94d6617bcaee2258
Reviewed-by: hjk <hjk@qt.io>
2023-05-22 12:48:35 +00:00

59 lines
1.3 KiB
C++

// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "statuslabel.h"
#include <QTimer>
/*!
\class Utils::StatusLabel
\inmodule QtCreator
\brief The StatusLabel class displays messages for a while with a timeout.
*/
namespace Utils {
StatusLabel::StatusLabel(QWidget *parent) : QLabel(parent)
{
// 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, &QTimer::timeout, this, &StatusLabel::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