Ignition Gui

API Reference

5.0.0
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 #ifndef IGNITION_GUI_PLUGINS_SCREENSHOT_HH_
18 #define IGNITION_GUI_PLUGINS_SCREENSHOT_HH_
19 
20 #ifdef _MSC_VER
21 #pragma warning(push, 0)
22 #endif
23 #include <ignition/msgs/boolean.pb.h>
24 #include <ignition/msgs/stringmsg.pb.h>
25 #ifdef _MSC_VER
26 #pragma warning(pop)
27 #endif
28 
29 #include <memory>
30 
31 #include "ignition/gui/qt.h"
32 #include "ignition/gui/Plugin.hh"
33 
34 namespace ignition
35 {
36 namespace gui
37 {
38 namespace plugins
39 {
40  class ScreenshotPrivate;
41 
48  class Screenshot : public Plugin
49  {
50  Q_OBJECT
51 
53  Q_PROPERTY(
55  READ Directory
56  WRITE SetDirectory
57  NOTIFY DirectoryChanged
58  )
59 
60 
61  Q_PROPERTY(
65  NOTIFY SavedScreenshotPathChanged
66  )
67 
69  public: Screenshot();
70 
72  public: ~Screenshot() override;
73 
74  // Documentation inherited
75  public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override;
76 
78  public slots: void OnScreenshot();
79 
83  private: bool eventFilter(QObject *_obj, QEvent *_event) override;
84 
90  private: bool ScreenshotService(const msgs::StringMsg &_msg,
91  msgs::Boolean &_res);
92 
95  private: void FindUserCamera();
96 
98  private: void SaveScreenshot();
99 
102  public: Q_INVOKABLE QString Directory() const;
103 
107  public: Q_INVOKABLE void SetDirectory(const QString &_dirUrl);
108 
110  signals: void DirectoryChanged();
111 
115  public: Q_INVOKABLE QString SavedScreenshotPath() const;
116 
120  public: Q_INVOKABLE void SetSavedScreenshotPath(const QString &_filename);
121 
123  signals: void SavedScreenshotPathChanged();
124 
126  signals: void savedScreenshot();
127 
130  private: std::unique_ptr<ScreenshotPrivate> dataPtr;
131  };
132 }
133 }
134 }
135 
136 #endif
Q_INVOKABLE QString SavedScreenshotPath() const
Get the filepath of the saved screenshot as a string, for example &#39;/home/Pictures/[timestamp].png&#39;.
STL namespace.
void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override
Load the plugin with a configuration file. Override this on custom plugins to handle custom configura...
Definition: Application.hh:35
Base class for Ignition GUI plugins.
Definition: Plugin.hh:54
Q_INVOKABLE void SetDirectory(const QString &_dirUrl)
Set the directory path from a string, for example &#39;/home/Pictures&#39;.
Q_INVOKABLE QString Directory() const
Get the directory path as a string, for example &#39;/home/Pictures&#39;.
QString directory
Directory to save screenshots.
Definition: Screenshot.hh:58
QString savedScreenshotPath
Saved screenshot filepath.
Definition: Screenshot.hh:66
Q_INVOKABLE void SetSavedScreenshotPath(const QString &_filename)
Set the filepath of the saved screenshot from a string, for example &#39;/home/Pictures/[timestamp].png&#39;.
Definition: Application.hh:40