KTextEditor

katemessagewidget.h
1/*
2 SPDX-FileCopyrightText: 2012 Dominik Haumann <dhaumann@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KATE_MESSAGE_WIDGET_H
8#define KATE_MESSAGE_WIDGET_H
9
10#include <QHash>
11#include <QPointer>
12#include <QWidget>
13
14#include <ktexteditor_export.h>
15
16namespace KTextEditor
17{
18class Message;
19class ViewPrivate;
20}
21
22class KMessageWidget;
23class KateAnimation;
24
25/**
26 * This class implements a message widget based on KMessageWidget.
27 * It is used to show messages through the KTextEditior::MessageInterface.
28 */
30{
32
33public:
34 /**
35 * The position of the KateMessageWidget
36 *
37 * @see KMessageWidget::Position
38 */
39 enum class Position {
40 Inline, ///< Inline message.
41 Header, ///< Message positioned at the top of the view.
42 Footer, ///< Message positioned at the bottom of the view.
43 };
44
45 /**
46 * Constructor. By default, the widget is hidden.
47 */
48 explicit KateMessageWidget(QWidget *parent, bool applyFadeEffect = false);
49
50 /**
51 * Post a new incoming message. Show either directly, or queue
52 */
53 void postMessage(KTextEditor::Message *message, QList<std::shared_ptr<QAction>> actions);
54
55 // for unit test
56 KTEXTEDITOR_EXPORT QString text() const;
57
58 void setPosition(Position position);
59
60protected Q_SLOTS:
61 /**
62 * Show the next message in the queue.
63 */
64 void showNextMessage();
65
66 /**
67 * Helper that enables word wrap to avoid breaking the layout
68 */
69 void setWordWrap(KTextEditor::Message *message);
70
71 /**
72 * catch when a message is deleted, then show next one, if applicable.
73 */
75
76 // ViewPrivate calls startAutoHideTimer()
77 friend class KTextEditor::ViewPrivate;
78 /**
79 * Start autoHide timer if requested
80 */
81 void startAutoHideTimer();
82 /**
83 * User hovers on a link in the message widget.
84 */
85 void linkHovered(const QString &link);
86
87private:
88 // sorted list of pending messages
89 QList<KTextEditor::Message *> m_messageQueue;
90 // pointer to current Message
91 QPointer<KTextEditor::Message> m_currentMessage;
92 // shared pointers to QActions as guard
94 // the message widget, showing the actual contents
95 KMessageWidget *m_messageWidget;
96 // the show / hide effect controller
97 KateAnimation *m_animation;
98
99private: // some state variables
100 // autoHide only once user interaction took place
101 QTimer *m_autoHideTimer;
102 // flag: save message's autohide time
103 int m_autoHideTime;
104};
105
106#endif
This class holds a Message to display in Views.
Definition message.h:94
This class provides a fade in/out effect for KMessageWidgets.
This class implements a message widget based on KMessageWidget.
void setWordWrap(KTextEditor::Message *message)
Helper that enables word wrap to avoid breaking the layout.
Position
The position of the KateMessageWidget.
@ Header
Message positioned at the top of the view.
@ Footer
Message positioned at the bottom of the view.
void linkHovered(const QString &link)
User hovers on a link in the message widget.
void showNextMessage()
Show the next message in the queue.
void messageDestroyed(KTextEditor::Message *message)
catch when a message is deleted, then show next one, if applicable.
void startAutoHideTimer()
Start autoHide timer if requested.
void postMessage(KTextEditor::Message *message, QList< std::shared_ptr< QAction > > actions)
Post a new incoming message.
KateMessageWidget(QWidget *parent, bool applyFadeEffect=false)
Constructor.
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
QObject * parent() const const
QList< QAction * > actions() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 1 2024 18:51:36 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.