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)
|
||||
: 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();
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user