[education/rkward] /: Avoid close button being pushed out of reach for long warning messages.
Thomas Friedrichsmeier
null at kde.org
Wed Oct 20 12:31:10 BST 2021
Git commit 4d0b70a09eee31518696d240a983e966b51ae040 by Thomas Friedrichsmeier.
Committed on 20/10/2021 at 11:31.
Pushed by tfry into branch 'master'.
Avoid close button being pushed out of reach for long warning messages.
M +1 -0 ChangeLog
M +13 -0 rkward/windows/rkmdiwindow.cpp
https://invent.kde.org/education/rkward/commit/4d0b70a09eee31518696d240a983e966b51ae040
diff --git a/ChangeLog b/ChangeLog
index 0f9d5abb..229abadf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+- Use top alignment button to close (warning) messages in preview windows/areas
- (Try to) automatically create custom R library locations, if they do not exist
- Workaround for invalid EDITOR variable set by Kate Terminal plugin (also fixed in recent kate)
- kate plugin related actions are now active whenever a script window is active (not only the corresponding tool window)
diff --git a/rkward/windows/rkmdiwindow.cpp b/rkward/windows/rkmdiwindow.cpp
index fd54f637..ec22f2b5 100644
--- a/rkward/windows/rkmdiwindow.cpp
+++ b/rkward/windows/rkmdiwindow.cpp
@@ -30,6 +30,7 @@
#include <kactioncollection.h>
#include <KLocalizedString>
#include <kmessagewidget.h>
+#include <kwidgetsaddons_version.h>
#include "rkworkplace.h"
#include "rkworkplaceview.h"
@@ -343,6 +344,10 @@ void RKMDIWindow::setStatusMessage (const QString& message, RCommand *command) {
layout->setContentsMargins (10, 10, 10, 10);
status_popup = new KMessageWidget (status_popup_container);
status_popup->setCloseButtonVisible (true);
+#if KWIDGETSADDONS_VERSION < QT_VERSION_CHECK(6,0,0)
+ // see below
+ status_popup->setWordWrap(true);
+#endif
status_popup->setMessageType (KMessageWidget::Warning);
layout->addWidget (status_popup);
layout->addStretch ();
@@ -361,7 +366,15 @@ void RKMDIWindow::setStatusMessage (const QString& message, RCommand *command) {
}
if (status_popup->text () != message) {
if (status_popup->isVisible ()) status_popup->hide (); // otherwise, the KMessageWidget does not update geometry (KF5, 5.15.0)
+#if KWIDGETSADDONS_VERSION < QT_VERSION_CHECK(6,0,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;
+ if (!dummy.startsWith("<")) dummy = "<p>" + dummy + "</p>";
+ status_popup->setText (dummy.replace(" ", " "));
+#else
status_popup->setText (message);
+#endif
status_popup->animatedShow ();
}
} else {
More information about the rkward-tracker
mailing list