2019-04-03 06:07:15 +02:00
|
|
|
#ifndef QTGUI_CALCULATOR_H
|
|
|
|
#define QTGUI_CALCULATOR_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2019-04-04 06:33:42 +02:00
|
|
|
#include <QThread>
|
|
|
|
#include <QString>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QMutex>
|
|
|
|
|
|
|
|
class CalcThread : public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void run() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-04-03 06:07:15 +02:00
|
|
|
|
|
|
|
class Calculator : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2019-04-04 06:33:42 +02:00
|
|
|
Q_PROPERTY(QString lcdText READ lcdText WRITE setLcdText NOTIFY lcdTextChanged)
|
|
|
|
|
2019-04-03 06:07:15 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
explicit Calculator(QObject *parent = 0);
|
2019-04-04 06:33:42 +02:00
|
|
|
~Calculator();
|
|
|
|
|
|
|
|
inline QString lcdText(){return m_lcdText;}
|
|
|
|
inline void setLcdText(const QString &lcdText){m_lcdText = lcdText;}
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void lcdTextChanged();
|
2019-04-03 06:07:15 +02:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void buttonClicked(const QString& in);
|
2019-04-04 06:33:42 +02:00
|
|
|
void updateLcd();
|
|
|
|
|
|
|
|
private:
|
|
|
|
CalcThread calc_thread;
|
|
|
|
QString m_lcdText;
|
|
|
|
QTimer m_timer;
|
2019-04-03 06:07:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-04-04 06:33:42 +02:00
|
|
|
|
|
|
|
|
2019-04-03 06:07:15 +02:00
|
|
|
#endif //include guard
|