Overte C++ Documentation
DesktopPreviewProvider.h
1 //
2 // Created by Alexander Ivash on 2018/01/08
3 // Copyright 2018 High Fidelity, Inc.
4 //
5 // Distributed under the Apache License, Version 2.0.
6 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 //
8 
9 #include <DependencyManager.h>
10 #include <QImage>
11 #include <QtCore/QSharedPointer>
12 
13 class DesktopPreviewProvider : public QObject, public Dependency {
14  SINGLETON_DEPENDENCY
15  Q_OBJECT
16 
17  DesktopPreviewProvider();
18  DesktopPreviewProvider(const DesktopPreviewProvider& other) = delete;
19 
20  constexpr static const char* imagePaths[] = {
21  "images/preview-disabled.png", // USER
22  "images/preview-privacy.png", // SECURE_SCREEN
23  "images/preview.png", // VSYNC
24  };
25 
26 public:
27  enum PreviewDisabledReasons {
28  USER = 0,
29  SECURE_SCREEN,
30  VSYNC // Not settable via this interface, as VSYNC is controlled by HMD plugin..
31  };
32  Q_ENUM(PreviewDisabledReasons)
33 
34  static QSharedPointer<DesktopPreviewProvider> getInstance();
35 
36  QImage getPreviewDisabledImage(bool vsyncEnabled) const;
37  void setPreviewDisabledReason(PreviewDisabledReasons reason);
38 
39 public slots:
40  void setPreviewDisabledReason(const QString& reason);
41 
42 private:
43  QImage& loadPreviewImage(QImage& image, const QString& path) const;
44 
45  PreviewDisabledReasons m_previewDisabledReason = { USER };
46 
47  mutable QImage m_previewDisabled[3];
48 };