mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Screen grabber: Show correct tooltip for selected/no-selection states
When the user just clicks somewhere, and thus rejects the selection due to the previous commit, show the initial 'nothing selected' helper tooltip again.
This commit is contained in:
parent
96a1cf93d5
commit
db8b70e225
|
@ -119,32 +119,41 @@ void ScreenshotGrabber::setupScene(QGraphicsScene* scene)
|
|||
useNothingSelectedTooltip();
|
||||
|
||||
connect(this->chooserRect, &ScreenGrabberChooserRectItem::doubleClicked, this, &ScreenshotGrabber::acceptRegion);
|
||||
connect(this->chooserRect, &ScreenGrabberChooserRectItem::regionChosen, this, &ScreenshotGrabber::useRegionSelectedTooltip);
|
||||
connect(this->chooserRect, &ScreenGrabberChooserRectItem::regionChosen, this, &ScreenshotGrabber::chooseHelperTooltipText);
|
||||
connect(this->chooserRect, &ScreenGrabberChooserRectItem::regionChosen, this->overlay, &ScreenGrabberOverlayItem::setChosenRect);
|
||||
}
|
||||
|
||||
void ScreenshotGrabber::useNothingSelectedTooltip()
|
||||
{
|
||||
this->helperTooltip->setHtml(tr("Click and drag to select a region. Press <b>Escape</b> to cancel.",
|
||||
"Help text shown when no region has been selected yet"));
|
||||
helperTooltip->setHtml(tr("Click and drag to select a region. Press <b>Escape</b> to cancel.",
|
||||
"Help text shown when no region has been selected yet"));
|
||||
adjustTooltipPosition();
|
||||
}
|
||||
|
||||
void ScreenshotGrabber::useRegionSelectedTooltip()
|
||||
{
|
||||
this->helperTooltip->setHtml(tr("Press <b>Enter</b> to send a screenshot of the selected region or select a new region. Press <b>Escape</b> to cancel.",
|
||||
"Help text shown when a region has been selected"));
|
||||
helperTooltip->setHtml(tr("Press <b>Enter</b> to send a screenshot of the selected region or select a new region. Press <b>Escape</b> to cancel.",
|
||||
"Help text shown when a region has been selected"));
|
||||
adjustTooltipPosition();
|
||||
}
|
||||
|
||||
void ScreenshotGrabber::chooseHelperTooltipText(QRect rect)
|
||||
{
|
||||
if (rect.size().isNull())
|
||||
useNothingSelectedTooltip();
|
||||
else
|
||||
useRegionSelectedTooltip();
|
||||
|
||||
}
|
||||
|
||||
void ScreenshotGrabber::adjustTooltipPosition()
|
||||
{
|
||||
QRectF size = this->helperToolbox->childrenBoundingRect();
|
||||
QRect screenRect = QApplication::desktop()->screen()->rect();
|
||||
|
||||
// Align the toolbox center-top.
|
||||
this->helperToolbox->setX(screenRect.x() + (screenRect.width() - size.width() + size.x()) / 2);
|
||||
this->helperToolbox->setY(screenRect.y());
|
||||
helperToolbox->setX(screenRect.x() + (screenRect.width() - size.width() + size.x()) / 2);
|
||||
helperToolbox->setY(screenRect.y());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ private:
|
|||
|
||||
void useNothingSelectedTooltip();
|
||||
void useRegionSelectedTooltip();
|
||||
void chooseHelperTooltipText(QRect rect);
|
||||
void adjustTooltipPosition();
|
||||
|
||||
bool handleKeyPress(QKeyEvent* event);
|
||||
|
|
Loading…
Reference in New Issue
Block a user