1
0
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:
Nils Fenner 2015-10-10 17:45:23 +02:00
parent 24aec1dfd3
commit 6e383fa0f1
No known key found for this signature in database
GPG Key ID: 9591A163FF9BE04C
2 changed files with 32 additions and 0 deletions

View File

@ -38,6 +38,7 @@
ScreenshotGrabber::ScreenshotGrabber(QObject* parent)
: QObject(parent)
, scene(0)
, mQToxVisible(true)
{
window = new QGraphicsView (scene); // Top-level widget
window->setAttribute(Qt::WA_DeleteOnClose);
@ -208,6 +209,29 @@ QPixmap ScreenshotGrabber::grabScreen()
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)
{
QPointF pos = event->scenePos();

View File

@ -21,6 +21,7 @@
#define SCREENSHOTGRABBER_H
#include <QPixmap>
#include <QPointer>
class QGraphicsSceneMouseEvent;
class QGraphicsPixmapItem;
@ -70,8 +71,12 @@ private:
QPixmap grabScreen();
void hideVisibleWindows();
void restoreHiddenWindows();
void beginRectChooser(QGraphicsSceneMouseEvent* event);
private:
QPixmap screenGrab;
QGraphicsScene* scene;
QGraphicsView* window;
@ -80,6 +85,9 @@ private:
ScreenGrabberChooserRectItem* chooserRect;
ToolBoxGraphicsItem* helperToolbox;
QGraphicsTextItem* helperTooltip;
bool mQToxVisible;
QVector< QPointer<QWidget> > mHiddenWindows;
};