Toggle panel with Space while grabbing a color

This commit is contained in:
lupoDharkael
2018-05-19 00:55:11 +02:00
parent a8bb555c12
commit 33377d50d5
3 changed files with 8 additions and 2 deletions

View File

@@ -540,11 +540,14 @@ void CaptureWidget::initPanel() {
panelRect.setWidth(m_colorPicker->width() * 3);
m_panel->setGeometry(panelRect);
ColorPickerWidget *colorPicker = new ColorPickerWidget(&m_context.screenshot);
ColorPickerWidget *colorPicker =
new ColorPickerWidget(&m_context.screenshot);
connect(colorPicker, &ColorPickerWidget::colorChanged,
this, &CaptureWidget::setDrawColor);
connect(this, &CaptureWidget::colorChanged,
colorPicker, &ColorPickerWidget::updateColor);
connect(colorPicker, &ColorPickerWidget::togglePanel,
m_panel, &UtilityPanel::toggle);
colorPicker->colorChanged(m_context.color);
m_panel->pushWidget(colorPicker);
m_panel->pushWidget(new QUndoView(&m_undoStack, this));

View File

@@ -125,7 +125,9 @@ QColor ColorPickerWidget::grabPixmapColor(const QPoint &p) {
}
bool ColorPickerWidget::handleKeyPress(QKeyEvent *e) {
if (e->key() == Qt::Key_Escape) {
if (e->key() == Qt::Key_Space) {
emit togglePanel();
} else if (e->key() == Qt::Key_Escape) {
releaseColorGrab();
updateColor(m_colorBackup);
} else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {

View File

@@ -34,6 +34,7 @@ public:
signals:
void colorChanged(const QColor &c);
void togglePanel();
public slots:
void updateColor(const QColor &c);