AtCore  1.0.70
AtCore is a API to manage the serial connection between the computer and 3D Printers.
machineinfo.h
Go to the documentation of this file.
1 /* AtCore
2  Copyright (C) <2019>
3 
4  Authors:
5  Chris Rizzitello <rizzitello@kde.org>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) version 3, or any
11  later version accepted by the membership of KDE e.V. (or its
12  successor approved by the membership of KDE e.V.), which shall
13  act as a proxy defined in Section 6 of version 3 of the license.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library. If not, see <http://www.gnu.org/licenses/>.
22 */
23 
24 #pragma once
25 #include "atcore_export.h"
26 
27 #include <QObject>
28 #include <QQmlEngine>
29 #include <QSettings>
30 #include <QVariant>
31 
32 class ATCORE_EXPORT MachineInfo : public QObject
33 {
34  Q_OBJECT
35  Q_PROPERTY(QStringList profileNames READ profileNames NOTIFY profilesChanged)
36 public:
40  enum class KEY {
41  NAME = 0,
42  BAUDRATE,
43  FIRMWARE,
44  MAXBEDTEMP,
45  MAXEXTTEMP,
46  POSTPAUSE,
47  ISCARTESIAN,
48  XMAX,
49  YMAX,
50  ZMAX,
51  AUTOTEMPREPORT,
52  };
53  Q_ENUM(KEY)
54 
55 
59  static MachineInfo *instance();
60 
64  QObject *qmlSingletonRegister(QQmlEngine *engine, QJSEngine *scriptEngine);
65 
72  Q_INVOKABLE QVariantMap readProfile(const QString &profileName) const;
73 
81  Q_INVOKABLE QVariant readKey(const QString &profileName, const MachineInfo::KEY key) const;
82 
88  void storeProfile(const QMap<MachineInfo::KEY, QVariant> &profile) const;
89 
95  Q_INVOKABLE void storeProfile(const QVariantMap &profile) const;
96 
105  Q_INVOKABLE bool storeKey(const QString &profileName, const MachineInfo::KEY key, const QVariant &value) const;
106 
114  Q_INVOKABLE bool copyProfile(const QString &srcProfile, const QString &destProfile, bool rmSrc = false) const;
120  Q_INVOKABLE bool removeProfile(const QString &profileName) const;
121 
126  QStringList profileNames() const;
127 
133  Q_INVOKABLE QString keyName(const MachineInfo::KEY key) const;
134 
135 signals:
139  void profilesChanged() const;
140 
141 private:
142  MachineInfo *operator=(MachineInfo &other) = delete;
143  MachineInfo(const MachineInfo &other) = delete;
144  explicit MachineInfo(QObject *parent = nullptr);
145  ~MachineInfo() = default;
146 
150  struct keyInfo {
151  QString name;
152  QVariant defaultValue;
153  };
157  static const QMap<MachineInfo::KEY, MachineInfo::keyInfo> decoderMap;
158 
163  QSettings *m_settings = nullptr;
164 };
Definition: machineinfo.h:32
QVariant defaultValue
Defaut Value for the key.
Definition: machineinfo.h:152
static const QMap< MachineInfo::KEY, MachineInfo::keyInfo > decoderMap
Map of MachineInfo::KEY , KeyString and DefaultValue.
Definition: machineinfo.h:157
QString name
Key name used in the settings file.
Definition: machineinfo.h:151
KEY
KEYS enum Possible keys for the printer settings.
Definition: machineinfo.h:40
used to hold MachineInfo::KEY name and defaultValues.
Definition: machineinfo.h:150