Add support for on-screen-message to kwineffects

Summary:
This adds support for the new on-screen-message support to the
kwineffects API and makes use of it in the colorpicker effect.

Not yet added to screenshot effect as for that we need support for
skip close animation on the on-screen-message window.

Reviewers: #plasma, #kwin

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3803
This commit is contained in:
Martin Gräßlin 2016-12-23 17:39:12 +01:00
parent 404a5afad7
commit ab45659677
6 changed files with 39 additions and 19 deletions

View file

@ -251,6 +251,11 @@ public:
void startInteractivePositionSelection(std::function<void (const QPoint &)> 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;

View file

@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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 @@ void EffectsHandlerImpl::startInteractivePositionSelection(std::function<void(co
kwinApp()->platform()->startInteractivePositionSelection(callback);
}
void EffectsHandlerImpl::showOnScreenMessage(const QString &message, const QString &iconName)
{
OSD::show(message, iconName);
}
void EffectsHandlerImpl::hideOnScreenMessage()
{
OSD::hide();
}
//****************************************
// EffectWindowImpl
//****************************************

View file

@ -234,6 +234,9 @@ public:
void startInteractiveWindowSelection(std::function<void(KWin::EffectWindow*)> callback) override;
void startInteractivePositionSelection(std::function<void(const QPoint &)> callback) override;
void showOnScreenMessage(const QString &message, const QString &iconName = QString()) override;
void hideOnScreenMessage() override;
Scene *scene() const {
return m_scene;
}

View file

@ -65,10 +65,6 @@ void ColorPickerEffect::paintScreen(int mask, QRegion region, ScreenPaintData &d
{
m_cachedOutputGeometry = data.outputGeometry();
effects->paintScreen(mask, region, data);
if (m_infoFrame) {
m_infoFrame->render(region);
}
}
void ColorPickerEffect::postPaintScreen()
@ -116,28 +112,17 @@ QColor ColorPickerEffect::pick()
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

View file

@ -58,7 +58,6 @@ private:
QRect m_cachedOutputGeometry;
QPoint m_scheduledPosition;
bool m_picking = false;
QScopedPointer<EffectFrame> m_infoFrame;
};
} // namespace

View file

@ -1229,6 +1229,23 @@ public:
**/
virtual void startInteractivePositionSelection(std::function<void(const QPoint &)> 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.