Overte C++ Documentation
LocationBookmarks.h
1 //
2 // LocationBookmarks.h
3 // interface/src
4 //
5 // Created by Triplelexx on 23/03/17.
6 // Copyright 2017 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_LocationBookmarks_h
13 #define hifi_LocationBookmarks_h
14 
15 #include <DependencyManager.h>
16 
17 #include "Bookmarks.h"
18 
19 /*@jsdoc
20  * The <code>LocationBookmarks</code> API provides facilities for working with location bookmarks. A location bookmark
21  * associates a name with a directory services address.
22  *
23  * @namespace LocationBookmarks
24  *
25  * @hifi-client-entity
26  * @hifi-interface
27  * @hifi-avatar
28  */
29 
30 class LocationBookmarks : public Bookmarks, public Dependency {
31  Q_OBJECT
32  SINGLETON_DEPENDENCY
33 
34 public:
35  LocationBookmarks();
36 
37  void setupMenus(Menu* menubar, MenuWrapper* menu) override;
38  static const QString HOME_BOOKMARK;
39 
40  /*@jsdoc
41  * Gets the directory services address associated with a bookmark.
42  * @function LocationBookmarks.getAddress
43  * @param {string} bookmarkName - Name of the bookmark to get the directory services address for (case sensitive).
44  * @returns {string} The directory services address for the bookmark. If the bookmark does not exist, <code>""</code> is returned.
45  * @example <caption>Report the "Home" bookmark's directory services address.</caption>
46  * print("Home bookmark's address: " + LocationBookmarks.getAddress("Home"));
47  */
48  Q_INVOKABLE QString getAddress(const QString& bookmarkName);
49 
50 public slots:
51 
52  /*@jsdoc
53  * Prompts the user to bookmark their current location. The user can specify the name of the bookmark in the dialog that is
54  * opened.
55  * @function LocationBookmarks.addBookmark
56  */
57  void addBookmark();
58 
59  /*@jsdoc
60  * Sets the directory services address associated with the "Home" bookmark.
61  * @function LocationBookmarks.setHomeLocationToAddress
62  * @param {string} address - The directory services address to set the "Home" bookmark to.
63  */
64  void setHomeLocationToAddress(const QVariant& address);
65 
66  /*@jsdoc
67  * Gets the directory services address associated with the "Home" bookmark.
68  * @function LocationBookmarks.getHomeLocationAddress
69  * @returns {string} The directory services address for the "Home" bookmark.
70  */
71  QString getHomeLocationAddress();
72 
73 protected:
74  void addBookmarkToMenu(Menu* menubar, const QString& name, const QVariant& address) override;
75 
76 private:
77  const QString LOCATIONBOOKMARKS_FILENAME = "bookmarks.json";
78 
79 private slots:
80  void setHomeLocation();
81  void teleportToBookmark();
82 };
83 
84 #endif // hifi_LocationBookmarks_h