Changeset View
Changeset View
Standalone View
Standalone View
src/view/katemessagewidget.cpp
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 43 | { | |||
---|---|---|---|---|---|
54 | setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); | 54 | setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); | ||
55 | 55 | | |||
56 | // by default, hide widgets | 56 | // by default, hide widgets | ||
57 | m_messageWidget->hide(); | 57 | m_messageWidget->hide(); | ||
58 | hide(); | 58 | hide(); | ||
59 | 59 | | |||
60 | // create animation controller, and connect widgetHidden() to showNextMessage() | 60 | // create animation controller, and connect widgetHidden() to showNextMessage() | ||
61 | m_animation = new KateAnimation(m_messageWidget, applyFadeEffect ? KateAnimation::FadeEffect : KateAnimation::GrowEffect); | 61 | m_animation = new KateAnimation(m_messageWidget, applyFadeEffect ? KateAnimation::FadeEffect : KateAnimation::GrowEffect); | ||
62 | connect(m_animation, SIGNAL(widgetHidden()), this, SLOT(showNextMessage())); | 62 | connect(m_animation, &KateAnimation::widgetHidden, | ||
63 | this, &KateMessageWidget::showNextMessage); | ||||
63 | 64 | | |||
64 | // setup autoHide timer details | 65 | // setup autoHide timer details | ||
65 | m_autoHideTimer->setSingleShot(true); | 66 | m_autoHideTimer->setSingleShot(true); | ||
66 | 67 | | |||
67 | connect(m_messageWidget, SIGNAL(linkHovered(QString)), SLOT(linkHovered(QString))); | 68 | connect(m_messageWidget, &KMessageWidget::linkHovered, | ||
69 | this, &KateMessageWidget::linkHovered); | ||||
68 | } | 70 | } | ||
69 | 71 | | |||
70 | void KateMessageWidget::showNextMessage() | 72 | void KateMessageWidget::showNextMessage() | ||
71 | { | 73 | { | ||
72 | // at this point, we should not have a currently shown message | 74 | // at this point, we should not have a currently shown message | ||
73 | Q_ASSERT(m_currentMessage == nullptr); | 75 | Q_ASSERT(m_currentMessage == nullptr); | ||
74 | 76 | | |||
75 | // if not message to show, just stop | 77 | // if not message to show, just stop | ||
76 | if (m_messageQueue.size() == 0) { | 78 | if (m_messageQueue.size() == 0) { | ||
77 | hide(); | 79 | hide(); | ||
78 | return; | 80 | return; | ||
79 | } | 81 | } | ||
80 | 82 | | |||
81 | // track current message | 83 | // track current message | ||
82 | m_currentMessage = m_messageQueue[0]; | 84 | m_currentMessage = m_messageQueue[0]; | ||
83 | 85 | | |||
84 | // set text etc. | 86 | // set text etc. | ||
85 | m_messageWidget->setText(m_currentMessage->text()); | 87 | m_messageWidget->setText(m_currentMessage->text()); | ||
86 | m_messageWidget->setIcon(m_currentMessage->icon()); | 88 | m_messageWidget->setIcon(m_currentMessage->icon()); | ||
87 | 89 | | |||
88 | // connect textChanged() and iconChanged(), so it's possible to change this on the fly | 90 | // connect textChanged() and iconChanged(), so it's possible to change this on the fly | ||
89 | connect(m_currentMessage, SIGNAL(textChanged(QString)), m_messageWidget, SLOT(setText(QString)), Qt::UniqueConnection); | 91 | connect(m_currentMessage, &KTextEditor::Message::textChanged, | ||
90 | connect(m_currentMessage, SIGNAL(iconChanged(QIcon)), m_messageWidget, SLOT(setIcon(QIcon)), Qt::UniqueConnection); | 92 | m_messageWidget, &KMessageWidget::setText, Qt::UniqueConnection); | ||
93 | connect(m_currentMessage, &KTextEditor::Message::iconChanged, | ||||
94 | m_messageWidget, &KMessageWidget::setIcon, Qt::UniqueConnection); | ||||
91 | 95 | | |||
92 | // the enums values do not necessarily match, hence translate with switch | 96 | // the enums values do not necessarily match, hence translate with switch | ||
93 | switch (m_currentMessage->messageType()) { | 97 | switch (m_currentMessage->messageType()) { | ||
94 | case KTextEditor::Message::Positive: | 98 | case KTextEditor::Message::Positive: | ||
95 | m_messageWidget->setMessageType(KMessageWidget::Positive); | 99 | m_messageWidget->setMessageType(KMessageWidget::Positive); | ||
96 | break; | 100 | break; | ||
97 | case KTextEditor::Message::Information: | 101 | case KTextEditor::Message::Information: | ||
98 | m_messageWidget->setMessageType(KMessageWidget::Information); | 102 | m_messageWidget->setMessageType(KMessageWidget::Information); | ||
Show All 23 Lines | |||||
122 | 126 | | |||
123 | // set word wrap of the message | 127 | // set word wrap of the message | ||
124 | setWordWrap(m_currentMessage); | 128 | setWordWrap(m_currentMessage); | ||
125 | 129 | | |||
126 | // setup auto-hide timer, and start if requested | 130 | // setup auto-hide timer, and start if requested | ||
127 | m_autoHideTime = m_currentMessage->autoHide(); | 131 | m_autoHideTime = m_currentMessage->autoHide(); | ||
128 | m_autoHideTimer->stop(); | 132 | m_autoHideTimer->stop(); | ||
129 | if (m_autoHideTime >= 0) { | 133 | if (m_autoHideTime >= 0) { | ||
130 | connect(m_autoHideTimer, SIGNAL(timeout()), m_currentMessage, SLOT(deleteLater()), Qt::UniqueConnection); | 134 | connect(m_autoHideTimer, &QTimer::timeout, | ||
135 | m_currentMessage, &QObject::deleteLater, Qt::UniqueConnection); | ||||
131 | if (m_currentMessage->autoHideMode() == KTextEditor::Message::Immediate) { | 136 | if (m_currentMessage->autoHideMode() == KTextEditor::Message::Immediate) { | ||
132 | m_autoHideTimer->start(m_autoHideTime == 0 ? s_defaultAutoHideTime : m_autoHideTime); | 137 | m_autoHideTimer->start(m_autoHideTime == 0 ? s_defaultAutoHideTime : m_autoHideTime); | ||
133 | } | 138 | } | ||
134 | } | 139 | } | ||
135 | 140 | | |||
136 | // finally show | 141 | // finally show | ||
137 | show(); | 142 | show(); | ||
138 | m_animation->show(); | 143 | m_animation->show(); | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 194 | if (message->priority() > m_messageQueue[i]->priority()) { | |||
190 | break; | 195 | break; | ||
191 | } | 196 | } | ||
192 | } | 197 | } | ||
193 | 198 | | |||
194 | // queue message | 199 | // queue message | ||
195 | m_messageQueue.insert(i, message); | 200 | m_messageQueue.insert(i, message); | ||
196 | 201 | | |||
197 | // catch if the message gets deleted | 202 | // catch if the message gets deleted | ||
198 | connect(message, SIGNAL(closed(KTextEditor::Message *)), SLOT(messageDestroyed(KTextEditor::Message *))); | 203 | connect(message, &KTextEditor::Message::closed, | ||
204 | this, &KateMessageWidget::messageDestroyed); | ||||
199 | 205 | | |||
200 | if (i == 0 && !m_animation->isHideAnimationRunning()) { | 206 | if (i == 0 && !m_animation->isHideAnimationRunning()) { | ||
201 | // if message has higher priority than the one currently shown, | 207 | // if message has higher priority than the one currently shown, | ||
202 | // then hide the current one and then show the new one. | 208 | // then hide the current one and then show the new one. | ||
203 | if (m_currentMessage) { | 209 | if (m_currentMessage) { | ||
204 | // autoHide timer may be running for currently shown message, therefore | 210 | // autoHide timer may be running for currently shown message, therefore | ||
205 | // simply disconnect autoHide timer to all timeout() receivers | 211 | // simply disconnect autoHide timer to all timeout() receivers | ||
206 | disconnect(m_autoHideTimer, SIGNAL(timeout()), nullptr, nullptr); | 212 | disconnect(m_autoHideTimer, &QTimer::timeout, nullptr, nullptr); | ||
207 | m_autoHideTimer->stop(); | 213 | m_autoHideTimer->stop(); | ||
208 | 214 | | |||
209 | // if there is a current message, the message queue must contain 2 messages | 215 | // if there is a current message, the message queue must contain 2 messages | ||
210 | Q_ASSERT(m_messageQueue.size() > 1); | 216 | Q_ASSERT(m_messageQueue.size() > 1); | ||
211 | Q_ASSERT(m_currentMessage == m_messageQueue[1]); | 217 | Q_ASSERT(m_currentMessage == m_messageQueue[1]); | ||
212 | 218 | | |||
213 | // a bit unnice: disconnect textChanged() and iconChanged() signals of previously visible message | 219 | // a bit unnice: disconnect textChanged() and iconChanged() signals of previously visible message | ||
214 | disconnect(m_currentMessage, SIGNAL(textChanged(QString)), m_messageWidget, SLOT(setText(QString))); | 220 | disconnect(m_currentMessage, &KTextEditor::Message::textChanged, | ||
215 | disconnect(m_currentMessage, SIGNAL(iconChanged(QIcon)), m_messageWidget, SLOT(setIcon(QIcon))); | 221 | m_messageWidget, &KMessageWidget::setText); | ||
222 | disconnect(m_currentMessage, &KTextEditor::Message::iconChanged, | ||||
223 | m_messageWidget, &KMessageWidget::setIcon); | ||||
216 | 224 | | |||
217 | m_currentMessage = nullptr; | 225 | m_currentMessage = nullptr; | ||
218 | m_animation->hide(); | 226 | m_animation->hide(); | ||
219 | } else { | 227 | } else { | ||
220 | showNextMessage(); | 228 | showNextMessage(); | ||
221 | } | 229 | } | ||
222 | } | 230 | } | ||
223 | } | 231 | } | ||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |