KanoopGuiQt 1.3.0
Qt GUI utility library
Loading...
Searching...
No Matches
statusbar.h
1#ifndef STATUSBAR_H
2#define STATUSBAR_H
3
4#include <QStatusBar>
5#include <QTimer>
6#include <Kanoop/gui/libkanoopgui.h>
7#include <Kanoop/timespan.h>
8
9/**
10 * @brief QStatusBar subclass with timed messages, color styling, and animated progress text.
11 *
12 * StatusBar extends QStatusBar with:
13 * - showStatusMessage() overloads that accept a TimeSpan timeout and/or a text color
14 * - showAnimatedProgressMessage() which appends animated dots until stopAnimation() is called
15 * - setForegroundColor() for permanent foreground color overrides
16 */
17class LIBKANOOPGUI_EXPORT StatusBar : public QStatusBar
18{
19 Q_OBJECT
20public:
21 /**
22 * @brief Construct with an optional parent.
23 * @param parent Optional QWidget parent
24 */
25 explicit StatusBar(QWidget *parent = nullptr);
26
27 /**
28 * @brief Show a message that disappears after a timeout.
29 * @param text Message text
30 * @param timeout Duration before the message is cleared
31 */
32 void showStatusMessage(const QString &text, const TimeSpan& timeout);
33
34 /**
35 * @brief Show a colored message with no automatic timeout.
36 * @param text Message text
37 * @param textColor Text color
38 */
39 void showStatusMessage(const QString &text, const QColor& textColor);
40
41 /**
42 * @brief Show a colored message that disappears after a timeout.
43 * @param text Message text
44 * @param textColor Text color
45 * @param timeout Duration before the message is cleared
46 */
47 void showStatusMessage(const QString &text, const QColor& textColor, const TimeSpan& timeout);
48
49 /**
50 * @brief Show a message with animated trailing dots to indicate progress.
51 * @param text Base message text (dots are appended automatically)
52 * @param textColor Optional text color (invalid QColor = default)
53 */
54 void showAnimatedProgressMessage(const QString &text, const QColor& textColor = QColor());
55
56 /** @brief Stop the animated progress message and clear the status bar. */
58
59 /**
60 * @brief Set a permanent foreground color for status bar text.
61 * @param color Foreground color
62 */
63 void setForegroundColor(const QColor& color);
64
65private:
66 void reset();
67
68 // animation stuff
69 QTimer _dotTimer;
70 int _dots = 0;
71 QString _progressMessage;
72
73private slots:
74 void onDotTimerExpired();
75};
76
77#endif // STATUSBAR_H
QStatusBar subclass with timed messages, color styling, and animated progress text.
Definition statusbar.h:18
void showStatusMessage(const QString &text, const TimeSpan &timeout)
Show a message that disappears after a timeout.
void showStatusMessage(const QString &text, const QColor &textColor)
Show a colored message with no automatic timeout.
StatusBar(QWidget *parent=nullptr)
Construct with an optional parent.
void showAnimatedProgressMessage(const QString &text, const QColor &textColor=QColor())
Show a message with animated trailing dots to indicate progress.
void showStatusMessage(const QString &text, const QColor &textColor, const TimeSpan &timeout)
Show a colored message that disappears after a timeout.
void setForegroundColor(const QColor &color)
Set a permanent foreground color for status bar text.
void stopAnimation()
Stop the animated progress message and clear the status bar.