MapLibre Native for Qt
Loading...
Searching...
No Matches
settings.hpp
1// Copyright (C) 2023 MapLibre contributors
2// Copyright (C) 2019 Mapbox, Inc.
3
4// SPDX-License-Identifier: BSD-2-Clause
5
6#ifndef QMAPLIBRE_SETTINGS_H
7#define QMAPLIBRE_SETTINGS_H
8
9#include <QMapLibre/Export>
10#include <QMapLibre/Types>
11
12#include <QtCore/QString>
13#include <QtGui/QImage>
14
15#include <functional>
16#include <memory>
17
18// TODO: this will be wrapped at some point
19namespace mbgl {
20class TileServerOptions;
21} // namespace mbgl
22
23namespace QMapLibre {
24
25class SettingsPrivate;
26
27class Q_MAPLIBRE_CORE_EXPORT Settings {
28public:
29 enum GLContextMode : bool {
31 SharedGLContext
32 };
33
34 enum MapMode {
35 Continuous = 0,
36 Static
37 };
38
40 NoConstrain = 0,
42 ConstrainWidthAndHeight
43 };
44
46 DefaultViewport = 0,
47 FlippedYViewport
48 };
49
51 NoProvider = 0,
54 MapboxProvider
55 };
56
57 using ResourceTransformFunction = std::function<std::string(const std::string &)>;
58
59 explicit Settings(ProviderTemplate provider = NoProvider);
60 ~Settings();
61 Settings(const Settings &s);
62 Settings(Settings &&s) noexcept;
63 Settings &operator=(const Settings &s);
64 Settings &operator=(Settings &&s) noexcept;
65
66 [[nodiscard]] GLContextMode contextMode() const;
67 void setContextMode(GLContextMode);
68
69 [[nodiscard]] MapMode mapMode() const;
70 void setMapMode(MapMode);
71
72 [[nodiscard]] ConstrainMode constrainMode() const;
73 void setConstrainMode(ConstrainMode);
74
75 [[nodiscard]] ViewportMode viewportMode() const;
76 void setViewportMode(ViewportMode);
77
78 [[nodiscard]] unsigned cacheDatabaseMaximumSize() const;
79 void setCacheDatabaseMaximumSize(unsigned);
80
81 [[nodiscard]] QString cacheDatabasePath() const;
82 void setCacheDatabasePath(const QString &path);
83
84 [[nodiscard]] QString assetPath() const;
85 void setAssetPath(const QString &path);
86
87 [[nodiscard]] QString apiKey() const;
88 void setApiKey(const QString &key);
89
90 [[nodiscard]] QString apiBaseUrl() const;
91 void setApiBaseUrl(const QString &url);
92
93 [[nodiscard]] QString localFontFamily() const;
94 void setLocalFontFamily(const QString &family);
95
96 [[nodiscard]] QString clientName() const;
97 void setClientName(const QString &name);
98
99 [[nodiscard]] QString clientVersion() const;
100 void setClientVersion(const QString &version);
101
102 [[nodiscard]] ResourceTransformFunction resourceTransform() const;
103 void setResourceTransform(const ResourceTransformFunction &transform);
104
105 void setProviderTemplate(ProviderTemplate providerTemplate);
106 void setStyles(const Styles &styles);
107
108 [[nodiscard]] const Styles &styles() const;
109 [[nodiscard]] Styles providerStyles() const;
110
111 [[nodiscard]] Coordinate defaultCoordinate() const;
112 void setDefaultCoordinate(const Coordinate &coordinate);
113 [[nodiscard]] double defaultZoom() const;
114 void setDefaultZoom(double zoom);
115
116 [[nodiscard]] bool customTileServerOptions() const;
117 [[nodiscard]] const mbgl::TileServerOptions &tileServerOptions() const;
118
119private:
120 std::unique_ptr<SettingsPrivate> d_ptr;
121};
122
123} // namespace QMapLibre
124
125#endif // QMAPLIBRE_SETTINGS_H
The Settings class stores the initial configuration for Map.
Definition settings.hpp:27
ProviderTemplate
Definition settings.hpp:50
@ MapTilerProvider
Definition settings.hpp:53
@ MapLibreProvider
Definition settings.hpp:52
ConstrainMode
Definition settings.hpp:39
@ ConstrainHeightOnly
Definition settings.hpp:41
std::function< std::string(const std::string &)> ResourceTransformFunction
Resource transformation callback type.
Definition settings.hpp:57
ViewportMode
Definition settings.hpp:45
Settings & operator=(Settings &&s) noexcept
Move assignment operator.
Settings(Settings &&s) noexcept
Move constructor.
GLContextMode
Definition settings.hpp:29
@ UniqueGLContext
Definition settings.hpp:30
MapMode
Definition settings.hpp:34
Definition geojson.cpp:10
QVector< Style > Styles
Style vector.
Definition types.hpp:62
QPair< double, double > Coordinate
Coordinate helper type.
Definition types.hpp:20