|
QtCanpool 3.3.0
|
One short message, shown over the window it belongs to and gone a few seconds later. 更多...
#include <qxapp/qxtoast.h>

Public 类型 | |
| enum | Level { Information , Success , Warning , Error } |
| What the message is about; it selects the icon and the accent colour. 更多... | |
Public 成员函数 | |
| QxToast (const QString &text, Level level=Information, QWidget *parent=0) | |
| ~QxToast () override | |
| QString | text () const |
| void | setText (const QString &text) |
| Replaces the message; sizeHintChanged() follows when the size changed. | |
| Level | level () const |
| void | setLevel (Level level) |
| int | timeout () const |
| Milliseconds left before the toast dismisses itself, zero or less when it is to stay until something dismisses it. | |
| void | setTimeout (int timeoutMs) |
| int | fadeDuration () const |
| void | setFadeDuration (int ms) |
| Zero turns the animation off, which makes the life cycle immediate. | |
| bool | isPaused () const |
| Whether the pointer is holding the countdown back right now. | |
| bool | isDismissing () const |
| True from the moment dismiss() is called until the widget is gone. | |
| QColor | accentColor () const |
| The colour the level is drawn with. | |
| QSize | sizeHint () const override |
| int | heightForWidth (int width) const override |
| Height of the whole widget when it is width wide, text wrapping included. | |
| void | start () |
| Puts the toast on screen, fades it in and starts the countdown. | |
| void | stop () |
| Stops the countdown and leaves the toast on screen. | |
| void | dismiss () |
| Takes the toast off screen: the countdown stops, the fade out runs and dismissed() follows once the widget is hidden. | |
| void | dismissRequested () |
| The toast wants to leave; emitted before the fade out starts. | |
| void | dismissed () |
| The toast is off screen. | |
| void | clicked () |
| The user clicked the toast. | |
| void | sizeHintChanged () |
| The preferred size changed and whoever placed the toast should look again. | |
静态 Public 属性 | |
| static constexpr int | DefaultTimeout = 4000 |
| Milliseconds a toast stays on screen when the caller does not say. | |
| static constexpr int | DefaultFadeDuration = 160 |
| Milliseconds the fade in and the fade out take when no one says otherwise. | |
| static constexpr int | ShadowMargin = 4 |
| Pixels of room the widget keeps around its plate for the drop shadow. | |
| static constexpr int | MinPlateWidth = 160 |
| The narrowest and the widest plate a toast settles for, whatever width it is given. | |
| static constexpr int | MaxPlateWidth = 420 |
Protected 成员函数 | |
| void | paintEvent (QPaintEvent *event) override |
| void | resizeEvent (QResizeEvent *event) override |
| bool | event (QEvent *event) override |
| void | mouseReleaseEvent (QMouseEvent *event) override |
One short message, shown over the window it belongs to and gone a few seconds later.
A toast carries a Level - information, success, warning or error - which picks the icon and the accent colour, and it carries the text. Everything else about it is transient: it fades in, waits for its timeout, fades out and is destroyed. Hovering holds the countdown back, so a message that arrived while the pointer happened to be in the way does not vanish unread.
Applications normally talk to QxToastManager rather than to this class:
The class is a plain child widget of its host rather than a top level window of its own. That is deliberate: it needs no window manager to appear, the host's stacking order puts it above the ribbon and the docks for free, and it cannot take the keyboard focus away from the window the user is working in. A Qt::ToolTip window would need a platform window of its own and would behave differently under the offscreen platform and under WebAssembly, which is exactly where this class has to keep working.
The colours are read from the widget palette - the plate from QPalette::ToolTipBase, its border from QPalette::Mid, the accent from QPalette::Highlight - so a theme change reaches the toast without a line of code here.
|
explicit |
在文件 qxtoast.cpp 第 223 行定义.
|
override |
在文件 qxtoast.cpp 第 234 行定义.
| QColor QxApp::QxToast::accentColor | ( | ) | const |
The colour the level is drawn with.
Qt has no palette role for "success" or "warning", and writing four colours down here would freeze the toast against every theme. The theme's highlight colour therefore supplies saturation and lightness - so the accent stays as loud as the theme it runs under - and only the hue moves to the corner of the wheel the level is read in: the theme's own hue for information, green for success, amber for warning, red for error.
在文件 qxtoast.cpp 第 313 行定义.
| void QxApp::QxToast::clicked | ( | ) |
The user clicked the toast.
| void QxApp::QxToast::dismiss | ( | ) |
Takes the toast off screen: the countdown stops, the fade out runs and dismissed() follows once the widget is hidden.
Calling it again on a toast that is already leaving changes nothing.
在文件 qxtoast.cpp 第 358 行定义.
| void QxApp::QxToast::dismissed | ( | ) |
The toast is off screen.
Its owner deletes the widget.
| void QxApp::QxToast::dismissRequested | ( | ) |
The toast wants to leave; emitted before the fade out starts.
|
overrideprotected |
在文件 qxtoast.cpp 第 426 行定义.
| int QxApp::QxToast::fadeDuration | ( | ) | const |
在文件 qxtoast.cpp 第 289 行定义.
|
override |
Height of the whole widget when it is width wide, text wrapping included.
在文件 qxtoast.cpp 第 325 行定义.
| bool QxApp::QxToast::isDismissing | ( | ) | const |
True from the moment dismiss() is called until the widget is gone.
在文件 qxtoast.cpp 第 307 行定义.
| bool QxApp::QxToast::isPaused | ( | ) | const |
Whether the pointer is holding the countdown back right now.
在文件 qxtoast.cpp 第 301 行定义.
| QxToast::Level QxApp::QxToast::level | ( | ) | const |
在文件 qxtoast.cpp 第 260 行定义.
|
overrideprotected |
在文件 qxtoast.cpp 第 457 行定义.
|
overrideprotected |
在文件 qxtoast.cpp 第 375 行定义.
|
overrideprotected |
在文件 qxtoast.cpp 第 419 行定义.
| void QxApp::QxToast::setFadeDuration | ( | int | ms | ) |
Zero turns the animation off, which makes the life cycle immediate.
在文件 qxtoast.cpp 第 295 行定义.
| void QxApp::QxToast::setLevel | ( | Level | level | ) |
在文件 qxtoast.cpp 第 266 行定义.
| void QxApp::QxToast::setText | ( | const QString & | text | ) |
Replaces the message; sizeHintChanged() follows when the size changed.
在文件 qxtoast.cpp 第 245 行定义.
| void QxApp::QxToast::setTimeout | ( | int | timeoutMs | ) |
在文件 qxtoast.cpp 第 283 行定义.
|
override |
在文件 qxtoast.cpp 第 319 行定义.
| void QxApp::QxToast::sizeHintChanged | ( | ) |
The preferred size changed and whoever placed the toast should look again.
| void QxApp::QxToast::start | ( | ) |
Puts the toast on screen, fades it in and starts the countdown.
The manager calls this; calling it twice restarts the countdown.
在文件 qxtoast.cpp 第 331 行定义.
| void QxApp::QxToast::stop | ( | ) |
Stops the countdown and leaves the toast on screen.
在文件 qxtoast.cpp 第 351 行定义.
| QString QxApp::QxToast::text | ( | ) | const |
在文件 qxtoast.cpp 第 239 行定义.
| int QxApp::QxToast::timeout | ( | ) | const |
Milliseconds left before the toast dismisses itself, zero or less when it is to stay until something dismisses it.
在文件 qxtoast.cpp 第 277 行定义.
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |