diff --git a/libs/libkis/View.h b/libs/libkis/View.h --- a/libs/libkis/View.h +++ b/libs/libkis/View.h @@ -124,6 +124,16 @@ qreal paintingFlow() const; void setPaintingFlow(qreal flow); + /** + * @brief showFloatingMessage displayes a floating message box on the top-left corner of the canvas + * @param message: Message to be displayed inside the floating message box + * @param icon: Icon to be displayed inside the message box next to the message string + * @param timeout: Milliseconds until the message box disappears + * @param priority: 0 = High, 1 = Medium, 2 = Low. Higher priority + * messages will be displayed in place of lower priority messages + */ + void showFloatingMessage(const QString &message, const QIcon& icon, int timeout, int priority); + /** * @brief selectedNodes returns a list of Nodes that are selected in this view. * diff --git a/libs/libkis/View.cpp b/libs/libkis/View.cpp --- a/libs/libkis/View.cpp +++ b/libs/libkis/View.cpp @@ -271,3 +271,12 @@ return LibKisUtils::createNodeList(selectedNodes, d->view->image()); } +void View::showFloatingMessage(const QString &message, const QIcon& icon, int timeout, int priority) +{ + if (!d->view) return; + + KisFloatingMessage::Priority p; + p = static_cast(priority); + + d->view->showFloatingMessage(message, icon, timeout, p); +} diff --git a/plugins/extensions/pykrita/sip/krita/View.sip b/plugins/extensions/pykrita/sip/krita/View.sip --- a/plugins/extensions/pykrita/sip/krita/View.sip +++ b/plugins/extensions/pykrita/sip/krita/View.sip @@ -49,6 +49,8 @@ qreal paintingFlow() const; void setPaintingFlow(qreal flow); + void showFloatingMessage(const QString &message, const QIcon& icon, int timeout, int priority); + QList selectedNodes() const /Factory/; private: }; diff --git a/plugins/python/tenbrushes/tenbrushes.py b/plugins/python/tenbrushes/tenbrushes.py --- a/plugins/python/tenbrushes/tenbrushes.py +++ b/plugins/python/tenbrushes/tenbrushes.py @@ -10,6 +10,7 @@ https://creativecommons.org/publicdomain/zero/1.0/legalcode ''' import krita +from PyQt5.QtGui import QPixmap, QIcon from . import uitenbrushes @@ -75,6 +76,11 @@ currentPreset = Application.activeWindow().views()[0].currentBrushPreset() if self.activatePrev and self.sender().preset == currentPreset.name(): Application.activeWindow().views()[0].activateResource(self.oldPreset) + + if self.oldPreset: + Application.activeWindow().views()[0].showFloatingMessage(str(i18n("{}\nselected")).format(self.oldPreset.name()), + QIcon(QPixmap.fromImage(self.oldPreset.image())), + 1000, 1) else: self.oldPreset = Application.activeWindow().views()[0].currentBrushPreset() Application.activeWindow().views()[0].activateResource(allPresets[self.sender().preset])