Right click to open panel and select tool (#2008)
* Right click to open panel and select tool * Renamed slots
This commit is contained in:
@@ -131,11 +131,11 @@ void UIcolorEditor::initButtons()
|
||||
" mode of the contrast color."));
|
||||
|
||||
connect(m_buttonMainColor,
|
||||
&CaptureToolButton::pressedButton,
|
||||
&CaptureToolButton::pressedButtonLeftClick,
|
||||
this,
|
||||
&UIcolorEditor::changeLastButton);
|
||||
connect(m_buttonContrast,
|
||||
&CaptureToolButton::pressedButton,
|
||||
&CaptureToolButton::pressedButtonLeftClick,
|
||||
this,
|
||||
&UIcolorEditor::changeLastButton);
|
||||
// clicking the labels changes the button too
|
||||
|
||||
@@ -100,7 +100,10 @@ void CaptureToolButton::mousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
activateWindow();
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
emit pressedButton(this);
|
||||
emit pressedButtonLeftClick(this);
|
||||
emit pressed();
|
||||
} else if (e->button() == Qt::RightButton) {
|
||||
emit pressedButtonRightClick(this);
|
||||
emit pressed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ protected:
|
||||
CaptureTool* m_tool;
|
||||
|
||||
signals:
|
||||
void pressedButton(CaptureToolButton*);
|
||||
void pressedButtonLeftClick(CaptureToolButton*);
|
||||
void pressedButtonRightClick(CaptureToolButton*);
|
||||
|
||||
private:
|
||||
CaptureToolButton(QWidget* parent = nullptr);
|
||||
|
||||
@@ -318,15 +318,47 @@ void CaptureWidget::initButtons()
|
||||
|
||||
if (visibleButtonTypes.contains(t)) {
|
||||
connect(b,
|
||||
&CaptureToolButton::pressedButton,
|
||||
&CaptureToolButton::pressedButtonLeftClick,
|
||||
this,
|
||||
&CaptureWidget::setState);
|
||||
&CaptureWidget::handleButtonLeftClick);
|
||||
|
||||
if (b->tool()->isSelectable()) {
|
||||
connect(b,
|
||||
&CaptureToolButton::pressedButtonRightClick,
|
||||
this,
|
||||
&CaptureWidget::handleButtonRightClick);
|
||||
}
|
||||
|
||||
vectorButtons << b;
|
||||
}
|
||||
}
|
||||
m_buttonHandler->setButtons(vectorButtons);
|
||||
}
|
||||
|
||||
void CaptureWidget::handleButtonRightClick(CaptureToolButton* b)
|
||||
{
|
||||
if (!b) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if button already selected, do not deselect it on right click
|
||||
if (!m_activeButton || m_activeButton != b) {
|
||||
setState(b);
|
||||
}
|
||||
if (!m_panel->isVisible()) {
|
||||
m_panel->show();
|
||||
}
|
||||
}
|
||||
|
||||
void CaptureWidget::handleButtonLeftClick(CaptureToolButton* b)
|
||||
{
|
||||
if (!b) {
|
||||
return;
|
||||
}
|
||||
|
||||
setState(b);
|
||||
}
|
||||
|
||||
void CaptureWidget::initHelpMessage()
|
||||
{
|
||||
QList<QPair<QString, QString>> keyMap;
|
||||
|
||||
@@ -73,6 +73,8 @@ private slots:
|
||||
|
||||
void setState(CaptureToolButton* b);
|
||||
void handleToolSignal(CaptureTool::Request r);
|
||||
void handleButtonLeftClick(CaptureToolButton* b);
|
||||
void handleButtonRightClick(CaptureToolButton* b);
|
||||
void setDrawColor(const QColor& c);
|
||||
void onToolSizeChanged(int size);
|
||||
void onToolSizeSettled(int size);
|
||||
|
||||
@@ -214,3 +214,8 @@ void UtilityPanel::slotButtonDelete(bool clicked)
|
||||
}
|
||||
m_captureTools->setCurrentRow(currentRow);
|
||||
}
|
||||
|
||||
bool UtilityPanel::isVisible() const
|
||||
{
|
||||
return !m_internalPanel->isHidden();
|
||||
}
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
QList<QPointer<CaptureTool>> captureToolObjectsHistory);
|
||||
void setActiveLayer(int index);
|
||||
int activeLayerIndex();
|
||||
bool isVisible() const;
|
||||
|
||||
signals:
|
||||
void layerChanged(int layer);
|
||||
|
||||
Reference in New Issue
Block a user