mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
add methods to hide & restore currently visible qTox windows
This commit is contained in:
parent
24aec1dfd3
commit
6e383fa0f1
|
@ -38,6 +38,7 @@
|
||||||
ScreenshotGrabber::ScreenshotGrabber(QObject* parent)
|
ScreenshotGrabber::ScreenshotGrabber(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, scene(0)
|
, scene(0)
|
||||||
|
, mQToxVisible(true)
|
||||||
{
|
{
|
||||||
window = new QGraphicsView (scene); // Top-level widget
|
window = new QGraphicsView (scene); // Top-level widget
|
||||||
window->setAttribute(Qt::WA_DeleteOnClose);
|
window->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
@ -208,6 +209,29 @@ QPixmap ScreenshotGrabber::grabScreen()
|
||||||
rec.height());
|
rec.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenshotGrabber::hideVisibleWindows()
|
||||||
|
{
|
||||||
|
foreach(QWidget* w, qApp->topLevelWidgets()) {
|
||||||
|
if (w != window && w->isVisible()) {
|
||||||
|
mHiddenWindows << w;
|
||||||
|
w->setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mQToxVisible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenshotGrabber::restoreHiddenWindows()
|
||||||
|
{
|
||||||
|
foreach(QWidget* w, mHiddenWindows) {
|
||||||
|
if (w)
|
||||||
|
w->setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
mHiddenWindows.clear();
|
||||||
|
mQToxVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenshotGrabber::beginRectChooser(QGraphicsSceneMouseEvent* event)
|
void ScreenshotGrabber::beginRectChooser(QGraphicsSceneMouseEvent* event)
|
||||||
{
|
{
|
||||||
QPointF pos = event->scenePos();
|
QPointF pos = event->scenePos();
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#define SCREENSHOTGRABBER_H
|
#define SCREENSHOTGRABBER_H
|
||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
class QGraphicsSceneMouseEvent;
|
class QGraphicsSceneMouseEvent;
|
||||||
class QGraphicsPixmapItem;
|
class QGraphicsPixmapItem;
|
||||||
|
@ -70,8 +71,12 @@ private:
|
||||||
|
|
||||||
QPixmap grabScreen();
|
QPixmap grabScreen();
|
||||||
|
|
||||||
|
void hideVisibleWindows();
|
||||||
|
void restoreHiddenWindows();
|
||||||
|
|
||||||
void beginRectChooser(QGraphicsSceneMouseEvent* event);
|
void beginRectChooser(QGraphicsSceneMouseEvent* event);
|
||||||
|
|
||||||
|
private:
|
||||||
QPixmap screenGrab;
|
QPixmap screenGrab;
|
||||||
QGraphicsScene* scene;
|
QGraphicsScene* scene;
|
||||||
QGraphicsView* window;
|
QGraphicsView* window;
|
||||||
|
@ -80,6 +85,9 @@ private:
|
||||||
ScreenGrabberChooserRectItem* chooserRect;
|
ScreenGrabberChooserRectItem* chooserRect;
|
||||||
ToolBoxGraphicsItem* helperToolbox;
|
ToolBoxGraphicsItem* helperToolbox;
|
||||||
QGraphicsTextItem* helperTooltip;
|
QGraphicsTextItem* helperTooltip;
|
||||||
|
|
||||||
|
bool mQToxVisible;
|
||||||
|
QVector< QPointer<QWidget> > mHiddenWindows;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user