Commit 796decdb authored by Thomas Friedrichsmeier's avatar Thomas Friedrichsmeier
Browse files

For non-plot windows, do not overlay messages with the actual view.

Also, add a brief timeout, to avoid flicker.
parent ba8846b9
- More tolerant handshake on Windows? Simply a matter of allowing more time?
- Better placement of messages in non-plot preview windows
- Fixed some problems with cancelling running commands
- Package installation uses inline widget to provide progress feedback, instead of separate dialogs
- TODO: Remove "Ok" button from dialog, rename "Cancel" to "Close"
......@@ -67,6 +67,8 @@ RKMDIWindow::RKMDIWindow (QWidget *parent, int type, bool tool_window, const cha
ui_buddy = nullptr;
file_save_action = nullptr;
file_save_as_action = nullptr;
connect(&status_message_timer, &QTimer::timeout, this, &RKMDIWindow::showStatusMessageNow);
if (!(type & KatePluginWindow)) setWindowIcon (RKStandardIcons::iconForWindow (this));
......@@ -321,15 +323,19 @@ void RKMDIWindow::enterEvent (QEvent *event) {
QFrame::enterEvent (event);
void RKMDIWindow::setStatusMessage (const QString& message, RCommand *command) {
void RKMDIWindow::showStatusMessageNow() {
if (!status_popup) {
// NOTE: Yes, this clearly goes against the explicit recommendation, but we do want the status message as an overlay to the main widget.
// This is especially important for plots, where changing the plot area geometry will trigger redraws of the plot.
// NOTE: For plots, against the recommendation, we want the status message as an overlay to the main widget.
// This is because changing the plot area geometry will trigger redraws of the plot.
// Note that these messages are mostly used on previews, so far, where they will either be a) transient ("preview updating"),
// or b) in case of errors, the place of interest will be outside the preview widget _and_ the preview will generally be invalid.
status_popup_container = new QWidget (this);
if (!isType(RKMDIWindow::X11Window)) {
auto blayout = qobject_cast<QVBoxLayout*> (layout());
if (blayout) blayout->insertWidget(0, status_popup_container);
QVBoxLayout *layout = new QVBoxLayout (status_popup_container);
layout->setContentsMargins (10, 10, 10, 10);
status_popup = new KMessageWidget (status_popup_container);
......@@ -347,23 +353,22 @@ void RKMDIWindow::setStatusMessage (const QString& message, RCommand *command) {
connect (status_popup, &KMessageWidget::hideAnimationFinished, status_popup_container, &QWidget::hide);
if (command) connect (command->notifier (), &RCommandNotifier::commandFinished, this, &RKMDIWindow::clearStatusMessage);
if (!message.isEmpty ()) {
if (!status_message.isEmpty ()) {
status_popup_container->resize (size ());
status_popup_container->show ();
if (status_popup->text () == message) {
if (status_popup->text () == status_message) {
if (!status_popup->isVisible ()) status_popup->animatedShow (); // it might have been closed by user. And no, simply show() is _not_ good enough. KF5 (5.15.0)
if (status_popup->text () != message) {
if (status_popup->text () != status_message) {
if (status_popup->isVisible ()) status_popup->hide (); // otherwise, the KMessageWidget does not update geometry (KF5, 5.15.0)
// silly workaround: KMessageWidget does not specify top-alignment for its buttons unless in wordwrap mode.
// we don't want actual word wrap, but we do want top alignment
QString dummy = message;
QString dummy = status_message;
if (!dummy.startsWith("<")) dummy = "<p>" + dummy + "</p>";
status_popup->setText (dummy.replace(" ", "&nbsp;"));
status_popup->setText (message);
status_popup->setText (status_message);
status_popup->animatedShow ();
......@@ -374,10 +379,19 @@ void RKMDIWindow::setStatusMessage (const QString& message, RCommand *command) {
void RKMDIWindow::setStatusMessage(const QString& message, RCommand *command) {
if (command) connect(command->notifier(), &RCommandNotifier::commandFinished, this, &RKMDIWindow::clearStatusMessage);
status_message = message;
// delay the actual show a bit. Often it's just a very brief "preview updating", that will just look like an annoying flicker
void RKMDIWindow::clearStatusMessage () {
setStatusMessage (QString ());
void RKMDIWindow::resizeEvent (QResizeEvent*) {
......@@ -11,6 +11,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include <QFrame>
#include <QMap>
#include <QUrl>
#include <QTimer>
#include <kparts/part.h>
......@@ -179,6 +180,9 @@ friend class RKToolWindowBar;
QUrl help_url;
RKSettings::SettingsPage settings_page;
KXMLGUIClient* ui_buddy;
void showStatusMessageNow();
QTimer status_message_timer;
QString status_message;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment