Gazebo Gui

API Reference

7.2.2
Screenshot.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef GZ_GUI_PLUGINS_SCREENSHOT_HH_
19 #define GZ_GUI_PLUGINS_SCREENSHOT_HH_
20 
21 #include <gz/msgs/boolean.pb.h>
22 #include <gz/msgs/stringmsg.pb.h>
23 
24 #include <memory>
25 
26 #include "gz/gui/qt.h"
27 #include "gz/gui/Plugin.hh"
28 
29 namespace gz::gui::plugins
30 {
31  class ScreenshotPrivate;
32 
39  class Screenshot : public Plugin
40  {
41  Q_OBJECT
42 
44  Q_PROPERTY(
45  QString directory
46  READ Directory
47  WRITE SetDirectory
48  NOTIFY DirectoryChanged
49  )
50 
51 
52  Q_PROPERTY(
53  QString savedScreenshotPath
54  READ SavedScreenshotPath
55  WRITE SetSavedScreenshotPath
56  NOTIFY SavedScreenshotPathChanged
57  )
58 
60  public: Screenshot();
61 
63  public: ~Screenshot() override;
64 
65  // Documentation inherited
66  public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override;
67 
69  public slots: void OnScreenshot();
70 
74  private: bool eventFilter(QObject *_obj, QEvent *_event) override;
75 
81  private: bool ScreenshotService(const msgs::StringMsg &_msg,
82  msgs::Boolean &_res);
83 
86  private: void FindUserCamera();
87 
89  private: void SaveScreenshot();
90 
93  public: Q_INVOKABLE QString Directory() const;
94 
98  public: Q_INVOKABLE void SetDirectory(const QString &_dirUrl);
99 
101  signals: void DirectoryChanged();
102 
106  public: Q_INVOKABLE QString SavedScreenshotPath() const;
107 
111  public: Q_INVOKABLE void SetSavedScreenshotPath(const QString &_filename);
112 
114  signals: void SavedScreenshotPathChanged();
115 
117  signals: void savedScreenshot();
118 
121  private: std::unique_ptr<ScreenshotPrivate> dataPtr;
122  };
123 } // namespace gz::gui::plugins
124 
125 #endif // GZ_GUI_PLUGINS_SCREENSHOT_HH_