1 /*
2  * DesktopInfo.hpp
3  *
4  * Copyright (C) 2021 by RStudio, PBC
5  *
6  * Unless you have received this program directly from RStudio pursuant
7  * to the terms of a commercial license agreement with RStudio, then
8  * this program is licensed to you under the terms of version 3 of the
9  * GNU Affero General Public License. This program is distributed WITHOUT
10  * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
11  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
12  * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
13  *
14  */
15 
16 #ifndef DESKTOP_DESKTOP_INFO_HPP
17 #define DESKTOP_DESKTOP_INFO_HPP
18 
19 #include <QApplication>
20 #include <QObject>
21 #include <QString>
22 
23 #include "DesktopGwtCallback.hpp"
24 
25 namespace rstudio {
26 namespace desktop {
27 
28 class DesktopInfo : public QObject
29 {
30     Q_OBJECT
31 
32 Q_SIGNALS:
33    void fixedWidthFontListChanged(QString fontList);
34    void fixedWidthFontChanged(QString font);
35    void proportionalFontChanged(QString font);
36    void desktopSynctexViewerChanged(QString viewer);
37    void sumatraPdfExePathChanged(QString value);
38    void zoomLevelChanged(double value);
39    void chromiumDevtoolsPortChanged(quint16 value);
40 
41 public:
42    void onClose();
43 
44 public:
45    explicit DesktopInfo(QObject* parent = nullptr);
46 
47    Q_INVOKABLE QString getPlatform();
48    Q_PROPERTY(QString platform
49               READ getPlatform
50               CONSTANT)
51 
52    Q_INVOKABLE QString getVersion();
53    Q_PROPERTY(QString version
54               READ getVersion
55               CONSTANT)
56 
57    Q_INVOKABLE QString getScrollingCompensationType();
58    Q_PROPERTY(QString scrollingCompensationType
59               READ getScrollingCompensationType
60               CONSTANT)
61 
62    Q_INVOKABLE bool desktopHooksAvailable();
63    Q_PROPERTY(bool desktopHooksAvailable
64               READ desktopHooksAvailable
65               CONSTANT)
66 
67    Q_INVOKABLE QString getFixedWidthFontList();
68    Q_INVOKABLE void setFixedWidthFontList(QString fontList);
69    Q_PROPERTY(QString fixedWidthFontList
70               READ getFixedWidthFontList
71               WRITE setFixedWidthFontList
72               NOTIFY fixedWidthFontListChanged)
73 
74    Q_INVOKABLE QString getFixedWidthFont();
75    Q_INVOKABLE void setFixedWidthFont(QString font);
76    Q_PROPERTY(QString fixedWidthFont
77               READ getFixedWidthFont
78               WRITE setFixedWidthFont
79               NOTIFY fixedWidthFontChanged)
80 
81    Q_INVOKABLE QString getProportionalFont();
82    Q_INVOKABLE void setProportionalFont(QString font);
83    Q_PROPERTY(QString proportionalFont
84               READ getProportionalFont
85               WRITE setProportionalFont
86               NOTIFY proportionalFontChanged)
87 
88    Q_INVOKABLE QString getDesktopSynctexViewer();
89    Q_INVOKABLE void setDesktopSynctexViewer(QString viewer);
90    Q_PROPERTY(QString desktopSynctexViewer
91               READ getDesktopSynctexViewer
92               WRITE setDesktopSynctexViewer
93               NOTIFY desktopSynctexViewerChanged)
94 
95    Q_INVOKABLE QString getSumatraPdfExePath();
96    Q_INVOKABLE void setSumatraPdfExePath(QString path);
97    Q_PROPERTY(QString sumatraPdfExePath
98               READ getSumatraPdfExePath
99               WRITE setSumatraPdfExePath
100               NOTIFY sumatraPdfExePathChanged)
101 
102    Q_INVOKABLE double getZoomLevel();
103    Q_INVOKABLE void setZoomLevel(double zoomLevel);
104    Q_PROPERTY(double zoomLevel
105               READ getZoomLevel
106               WRITE setZoomLevel
107               NOTIFY zoomLevelChanged)
108 
109    Q_INVOKABLE int getChromiumDevtoolsPort();
110    Q_INVOKABLE void setChromiumDevtoolsPort(int port);
111    Q_PROPERTY(int chromiumDevtoolsPort
112               READ getChromiumDevtoolsPort
113               WRITE setChromiumDevtoolsPort
114               NOTIFY chromiumDevtoolsPortChanged)
115 };
116 
desktopInfo()117 inline DesktopInfo& desktopInfo()
118 {
119    static DesktopInfo* instance = new DesktopInfo(qApp);
120    return *instance;
121 }
122 
123 } // end namespace desktop
124 } // end namespace rstudio
125 
126 #endif /* DESKTOP_DESKTOP_INFO_HPP */
127 
128