Add standardized OverlayMessage

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>
This commit is contained in:
Haris Gušić
2021-10-08 15:23:48 +02:00
parent 5ee85ed5c0
commit 1f2afebaa5
8 changed files with 82 additions and 53 deletions

View File

@@ -220,12 +220,7 @@ CaptureWidget::CaptureWidget(uint id,
QGuiAppCurrentScreen().currentScreen()->geometry());
if (m_config.showHelp()) {
OverlayMessage::push(
tr("Select an area with the mouse, or press Esc to exit."
"\nPress Enter to capture the screen."
"\nPress Right Click to show the color picker."
"\nUse the Mouse Wheel to change the thickness of your tool."
"\nPress Space to open the side panel."));
initHelpMessage();
}
updateCursor();
@@ -319,6 +314,26 @@ void CaptureWidget::initButtons()
m_buttonHandler->setButtons(vectorButtons);
}
void CaptureWidget::initHelpMessage()
{
QList<QPair<QString, QString>> keyMap;
keyMap << QPair("Mouse", "Select screenshot area");
using CT = CaptureTool;
for (auto toolType : { CT::TYPE_ACCEPT, CT::TYPE_SAVE, CT::TYPE_COPY }) {
auto* tool = ToolFactory().CreateTool(toolType);
QString shortcut =
ConfigHandler().shortcut(QVariant::fromValue(toolType).toString());
if (!shortcut.isEmpty()) {
keyMap << QPair(shortcut, tool->description());
}
}
keyMap << QPair("Mouse Wheel", "Change tool size");
keyMap << QPair("Right Click", "Show color picker");
keyMap << QPair("Space", "Open side panel");
keyMap << QPair("Esc", "Exit");
OverlayMessage::pushKeyMap(keyMap);
}
QPixmap CaptureWidget::pixmap()
{
return m_context.selectedScreenshotArea();