Reappear help message when selection hidden

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>
This commit is contained in:
Haris Gušić
2021-10-12 13:35:57 +02:00
parent 0b31fcf4cb
commit 5b815e83d3
6 changed files with 46 additions and 23 deletions

View File

@@ -219,7 +219,7 @@ CaptureWidget::CaptureWidget(uint id,
QGuiAppCurrentScreen().currentScreen()->geometry());
if (m_config.showHelp()) {
initHelpMessage();
pushHelpMessage();
}
updateCursor();
@@ -317,27 +317,30 @@ void CaptureWidget::initButtons()
m_buttonHandler->setButtons(vectorButtons);
}
void CaptureWidget::initHelpMessage()
void CaptureWidget::pushHelpMessage()
{
QList<QPair<QString, QString>> keyMap;
keyMap << QPair(tr("Mouse"), tr("Select screenshot area"));
using CT = CaptureTool;
for (auto toolType : { CT::TYPE_ACCEPT, CT::TYPE_SAVE, CT::TYPE_COPY }) {
if (!m_tools.contains(toolType)) {
continue;
}
auto* tool = m_tools[toolType];
QString shortcut =
ConfigHandler().shortcut(QVariant::fromValue(toolType).toString());
shortcut.replace("Return", "Enter");
if (!shortcut.isEmpty()) {
keyMap << QPair(shortcut, tool->description());
static QList<QPair<QString, QString>> keyMap;
if (keyMap.isEmpty()) {
keyMap << QPair(tr("Mouse"), tr("Select screenshot area"));
using CT = CaptureTool;
for (auto toolType :
{ CT::TYPE_ACCEPT, CT::TYPE_SAVE, CT::TYPE_COPY }) {
if (!m_tools.contains(toolType)) {
continue;
}
auto* tool = m_tools[toolType];
QString shortcut = ConfigHandler().shortcut(
QVariant::fromValue(toolType).toString());
shortcut.replace("Return", "Enter");
if (!shortcut.isEmpty()) {
keyMap << QPair(shortcut, tool->description());
}
}
keyMap << QPair(tr("Mouse Wheel"), tr("Change tool size"));
keyMap << QPair(tr("Right Click"), tr("Show color picker"));
keyMap << QPair(tr("Space"), tr("Open side panel"));
keyMap << QPair(tr("Esc"), tr("Exit"));
}
keyMap << QPair(tr("Mouse Wheel"), tr("Change tool size"));
keyMap << QPair(tr("Right Click"), tr("Show color picker"));
keyMap << QPair(tr("Space"), tr("Open side panel"));
keyMap << QPair(tr("Esc"), tr("Exit"));
OverlayMessage::pushKeyMap(keyMap);
}
@@ -1017,6 +1020,11 @@ void CaptureWidget::initSelection()
m_buttonHandler->hide();
}
});
connect(m_selection, &SelectionWidget::visibilityChanged, this, [this]() {
if (!m_selection->isVisible() && ConfigHandler().showHelp()) {
pushHelpMessage();
}
});
}
void CaptureWidget::setState(CaptureToolButton* b)