diff --git a/autotests/mock_effectshandler.h b/autotests/mock_effectshandler.h --- a/autotests/mock_effectshandler.h +++ b/autotests/mock_effectshandler.h @@ -251,6 +251,11 @@ void startInteractivePositionSelection(std::function callback) override { callback(QPoint(-1, -1)); } + void showOnScreenMessage(const QString &message, const QString &iconName = QString()) override { + Q_UNUSED(message) + Q_UNUSED(iconName) + } + void hideOnScreenMessage() override {} private: bool m_animationsSuported = true; diff --git a/effects.h b/effects.h --- a/effects.h +++ b/effects.h @@ -234,6 +234,9 @@ void startInteractiveWindowSelection(std::function callback) override; void startInteractivePositionSelection(std::function callback) override; + void showOnScreenMessage(const QString &message, const QString &iconName = QString()) override; + void hideOnScreenMessage() override; + Scene *scene() const { return m_scene; } diff --git a/effects.cpp b/effects.cpp --- a/effects.cpp +++ b/effects.cpp @@ -30,6 +30,7 @@ #include "client.h" #include "cursor.h" #include "group.h" +#include "osd.h" #include "pointer_input.h" #include "scene_xrender.h" #include "scene_qpainter.h" @@ -1590,6 +1591,16 @@ kwinApp()->platform()->startInteractivePositionSelection(callback); } +void EffectsHandlerImpl::showOnScreenMessage(const QString &message, const QString &iconName) +{ + OSD::show(message, iconName); +} + +void EffectsHandlerImpl::hideOnScreenMessage() +{ + OSD::hide(); +} + //**************************************** // EffectWindowImpl //**************************************** diff --git a/effects/colorpicker/colorpicker.h b/effects/colorpicker/colorpicker.h --- a/effects/colorpicker/colorpicker.h +++ b/effects/colorpicker/colorpicker.h @@ -58,7 +58,6 @@ QRect m_cachedOutputGeometry; QPoint m_scheduledPosition; bool m_picking = false; - QScopedPointer m_infoFrame; }; } // namespace diff --git a/effects/colorpicker/colorpicker.cpp b/effects/colorpicker/colorpicker.cpp --- a/effects/colorpicker/colorpicker.cpp +++ b/effects/colorpicker/colorpicker.cpp @@ -65,10 +65,6 @@ { m_cachedOutputGeometry = data.outputGeometry(); effects->paintScreen(mask, region, data); - - if (m_infoFrame) { - m_infoFrame->render(region); - } } void ColorPickerEffect::postPaintScreen() @@ -116,28 +112,17 @@ void ColorPickerEffect::showInfoMessage() { - if (!m_infoFrame.isNull()) { - return; - } - // TODO: turn the info message into a system wide service which performs hiding on mouse over - m_infoFrame.reset(effects->effectFrame(EffectFrameStyled, false)); - QFont font; - font.setBold(true); - m_infoFrame->setFont(font); - QRect area = effects->clientArea(ScreenArea, effects->activeScreen(), effects->currentDesktop()); - m_infoFrame->setPosition(QPoint(area.x() + area.width() / 2, area.y() + area.height() / 3)); - m_infoFrame->setText(i18n("Select a position for color picking with left click or enter.\nEscape or right click to cancel.")); - effects->addRepaintFull(); + effects->showOnScreenMessage(i18n("Select a position for color picking with left click or enter.\nEscape or right click to cancel."), QStringLiteral("color-picker")); } void ColorPickerEffect::hideInfoMessage() { - m_infoFrame.reset(); + effects->hideOnScreenMessage(); } bool ColorPickerEffect::isActive() const { - return m_picking && ((m_scheduledPosition != QPoint(-1, -1)) || !m_infoFrame.isNull()) && !effects->isScreenLocked(); + return m_picking && ((m_scheduledPosition != QPoint(-1, -1))) && !effects->isScreenLocked(); } } // namespace diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -1229,6 +1229,23 @@ **/ virtual void startInteractivePositionSelection(std::function callback) = 0; + /** + * Shows an on-screen-message. To hide it again use @link{hideOnScreenMessage}. + * + * @param message The message to show + * @param iconName The optional themed icon name + * @see hideOnScreenMessage + * @since 5.9 + **/ + virtual void showOnScreenMessage(const QString &message, const QString &iconName = QString()) = 0; + + /** + * Hides a previously shown on-screen-message again. + * @see showOnScreenMessage + * @since 5.9 + **/ + virtual void hideOnScreenMessage() = 0; + Q_SIGNALS: /** * Signal emitted when the current desktop changed.