Commit cfdc1acb authored by Martin Flöser's avatar Martin Flöser

[effects] Show info message in interactive window screenshot mode

Summary:
While taking an interactive screenshot we should inform the user about
what's going on, how to take the screenshot and how to cancel it.

For this the effect creates an EffectFrame with the required
information.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3403
parent 17e0bad9
......@@ -79,6 +79,10 @@ void ScreenShotEffect::paintScreen(int mask, QRegion region, ScreenPaintData &da
{
m_cachedOutputGeometry = data.outputGeometry();
effects->paintScreen(mask, region, data);
if (m_infoFrame) {
m_infoFrame->render(region);
}
}
void ScreenShotEffect::postPaintScreen()
......@@ -302,6 +306,7 @@ QString ScreenShotEffect::interactive(int mask)
setDelayedReply(true);
effects->startInteractiveWindowSelection(
[this] (EffectWindow *w) {
m_infoFrame.reset();
if (!w) {
m_replyConnection.send(m_replyMessage.createErrorReply(QDBusError::Failed, "Screenshot got cancelled"));
m_windowMode = WindowMode::NoCapture;
......@@ -311,6 +316,18 @@ QString ScreenShotEffect::interactive(int mask)
m_scheduledScreenshot->addRepaintFull();
}
});
if (m_infoFrame.isNull()) {
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 window to screen shot with left click or enter.\nEscape or right click to cancel."));
effects->addRepaintFull();
}
return QString();
}
......@@ -461,7 +478,7 @@ void ScreenShotEffect::convertFromGLImage(QImage &img, int w, int h)
bool ScreenShotEffect::isActive() const
{
return (m_scheduledScreenshot != NULL || !m_scheduledGeometry.isNull()) && !effects->isScreenLocked();
return (m_scheduledScreenshot != NULL || !m_scheduledGeometry.isNull() || !m_infoFrame.isNull()) && !effects->isScreenLocked();
}
void ScreenShotEffect::windowClosed( EffectWindow* w )
......
......@@ -118,6 +118,7 @@ private:
File
};
WindowMode m_windowMode = WindowMode::NoCapture;
QScopedPointer<EffectFrame> m_infoFrame;
};
} // namespace
......
Markdown is supported
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