mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
parent
aa311fb065
commit
7f29940625
|
@ -32,18 +32,26 @@
|
||||||
#include "screengrabberchooserrectitem.h"
|
#include "screengrabberchooserrectitem.h"
|
||||||
#include "screengrabberoverlayitem.h"
|
#include "screengrabberoverlayitem.h"
|
||||||
#include "toolboxgraphicsitem.h"
|
#include "toolboxgraphicsitem.h"
|
||||||
|
#include "src/widget/widget.h"
|
||||||
|
|
||||||
ScreenshotGrabber::ScreenshotGrabber(QWidget* parent)
|
ScreenshotGrabber::ScreenshotGrabber(QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
scene = new QGraphicsScene;
|
scene = new QGraphicsScene;
|
||||||
window = new QGraphicsView (scene); // Top-level widget
|
window = new QGraphicsView (scene); // Top-level widget
|
||||||
setupWindow();
|
setupWindow();
|
||||||
setupScene(scene);
|
setupScene(scene);
|
||||||
|
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenshotGrabber::reInit()
|
||||||
|
{
|
||||||
|
scene = new QGraphicsScene;
|
||||||
|
window = new QGraphicsView (scene); // Top-level widget
|
||||||
|
setupWindow();
|
||||||
|
setupScene(scene);
|
||||||
|
showGrabber();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenshotGrabber::~ScreenshotGrabber()
|
ScreenshotGrabber::~ScreenshotGrabber()
|
||||||
|
@ -76,6 +84,15 @@ bool ScreenshotGrabber::handleKeyPress(QKeyEvent* event)
|
||||||
reject();
|
reject();
|
||||||
else if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)
|
else if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)
|
||||||
acceptRegion();
|
acceptRegion();
|
||||||
|
else if (event->key() == Qt::Key_Space) // minimize qTox window
|
||||||
|
{
|
||||||
|
Widget *Widget = Widget::getInstance();
|
||||||
|
Widget->setVisible(false);
|
||||||
|
this->window->setVisible(false);
|
||||||
|
this->window->resetCachedContent();
|
||||||
|
// Give the window manager a moment to hide windows
|
||||||
|
QTimer::singleShot(200, this, SLOT(reInit()));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -129,14 +146,14 @@ void ScreenshotGrabber::setupScene(QGraphicsScene* scene)
|
||||||
|
|
||||||
void ScreenshotGrabber::useNothingSelectedTooltip()
|
void ScreenshotGrabber::useNothingSelectedTooltip()
|
||||||
{
|
{
|
||||||
helperTooltip->setHtml(tr("Click and drag to select a region. Press <b>Escape</b> to cancel.",
|
helperTooltip->setHtml(tr("Click and drag to select a region. Press <b>Space</b> to hide qTox window. Press <b>Escape</b> to cancel.",
|
||||||
"Help text shown when no region has been selected yet"));
|
"Help text shown when no region has been selected yet"));
|
||||||
adjustTooltipPosition();
|
adjustTooltipPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenshotGrabber::useRegionSelectedTooltip()
|
void ScreenshotGrabber::useRegionSelectedTooltip()
|
||||||
{
|
{
|
||||||
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.",
|
helperTooltip->setHtml(tr("Press <b>Enter</b> to send a screenshot of the selected region or select a new region. Press <b>Space</b> to hide qTox window and repeat region selection. Press <b>Escape</b> to cancel.",
|
||||||
"Help text shown when a region has been selected"));
|
"Help text shown when a region has been selected"));
|
||||||
adjustTooltipPosition();
|
adjustTooltipPosition();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
class ScreenGrabberChooserRectItem;
|
class ScreenGrabberChooserRectItem;
|
||||||
class QGraphicsSceneMouseEvent;
|
class QGraphicsSceneMouseEvent;
|
||||||
|
@ -48,6 +49,7 @@ public slots:
|
||||||
|
|
||||||
void showGrabber();
|
void showGrabber();
|
||||||
void acceptRegion();
|
void acceptRegion();
|
||||||
|
void reInit();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void screenshotTaken(const QPixmap &pixmap);
|
void screenshotTaken(const QPixmap &pixmap);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user