Implement selectAll and keyboard shortcut (#1106)

This commit is contained in:
David Mitchell
2021-02-06 18:01:45 -08:00
committed by GitHub
parent 013c0f1169
commit aee943af5d
3 changed files with 23 additions and 0 deletions

View File

@@ -39,6 +39,10 @@ const QVector<QStringList>& ConfigShortcuts::captureShortcutsDefault(
<< QObject::tr("Resize selection down 1px")
<< QKeySequence(Qt::SHIFT + Qt::Key_Down).toString());
m_shortcuts << (QStringList()
<< "TYPE_SELECT_ALL" << QObject::tr("Select entire screen")
<< QKeySequence(Qt::CTRL + Qt::Key_A).toString());
m_shortcuts << (QStringList() << "TYPE_MOVE_LEFT"
<< QObject::tr("Move selection left 1px")
<< QKeySequence(Qt::Key_Left).toString());

View File

@@ -1036,6 +1036,19 @@ void CaptureWidget::resizeDown()
adjustSelection(QMargins(0, 0, 0, 1));
}
void CaptureWidget::selectAll()
{
QRect newGeometry = rect();
m_selection->setGeometry(newGeometry);
m_context.selection = extendedRect(&newGeometry);
m_selection->setVisible(true);
m_showInitialMsg = false;
m_buttonHandler->updatePosition(m_selection->geometry());
updateSizeIndicator();
m_buttonHandler->show();
update();
}
void CaptureWidget::initShortcuts()
{
QString shortcut = ConfigHandler().shortcut(
@@ -1097,6 +1110,10 @@ void CaptureWidget::initShortcuts()
this,
SLOT(commitCurrentTool()));
new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_SELECT_ALL")),
this,
SLOT(selectAll()));
new QShortcut(Qt::Key_Escape, this, SLOT(deleteToolwidgetOrClose()));
}

View File

@@ -83,6 +83,8 @@ private slots:
void childEnter();
void childLeave();
void selectAll();
void resizeLeft();
void resizeRight();
void resizeUp();