Overte C++ Documentation
HMDToolsDialog.h
1 //
2 // HMDToolsDialog.h
3 // interface/src/ui
4 //
5 // Created by Brad Hefta-Gaub on 7/19/13.
6 // Copyright 2013 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_HMDToolsDialog_h
13 #define hifi_HMDToolsDialog_h
14 
15 #include <QDialog>
16 
17 class HMDWindowWatcher;
18 class QLabel;
19 
20 class HMDToolsDialog : public QDialog {
21  Q_OBJECT
22 public:
23  // Sets up the UI
24  HMDToolsDialog(QWidget* parent);
25  ~HMDToolsDialog();
26 
27  QString getDebugDetails() const;
28  QScreen* getHMDScreen() const { return _hmdScreen; }
29  QScreen* getLastApplicationScreen() const { return _previousScreen; }
30  bool hasHMDScreen() const { return _hmdScreenNumber >= -1; }
31  void watchWindow(QWindow* window);
32 
33 signals:
34  void closed();
35 
36 public slots:
37  void reject() override;
38  void screenCountChanged();
39 
40 protected:
41  virtual void closeEvent(QCloseEvent*) override; // Emits a 'closed' signal when this dialog is closed.
42  virtual void showEvent(QShowEvent* event) override;
43  virtual void hideEvent(QHideEvent* event) override;
44 
45 private:
46  void centerCursorOnWidget(QWidget* widget);
47  void enterHMDMode();
48  void leaveHMDMode();
49  void toggleHMDMode();
50  void updateUi();
51 
52  QScreen* _previousScreen{ nullptr };
53  QScreen* _hmdScreen{ nullptr };
54  int _hmdScreenNumber{ -1 };
55  QPushButton* _switchModeButton{ nullptr };
56  QLabel* _debugDetails{ nullptr };
57 
58  QRect _previousDialogRect;
59  QScreen* _previousDialogScreen{ nullptr };
60  QString _hmdPluginName;
61  QString _defaultPluginName;
62 
63  QHash<QWindow*, HMDWindowWatcher*> _windowWatchers;
64  friend class HMDWindowWatcher;
65 };
66 
67 
68 class HMDWindowWatcher : public QObject {
69  Q_OBJECT
70 public:
71  // Sets up the UI
72  HMDWindowWatcher(QWindow* window, HMDToolsDialog* hmdTools);
73  ~HMDWindowWatcher();
74 
75 public slots:
76  void windowScreenChanged(QScreen* screen);
77  void windowGeometryChanged(int arg);
78 
79 private:
80  QWindow* _window;
81  HMDToolsDialog* _hmdTools;
82  QRect _previousRect;
83  QScreen* _previousScreen;
84 };
85 
86 #endif // hifi_HMDToolsDialog_h