mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
100 lines
3.9 KiB
C++
100 lines
3.9 KiB
C++
/***************************************************************************
|
|
* This file is part of awesome-widgets *
|
|
* *
|
|
* awesome-widgets is free software: you can redistribute it and/or *
|
|
* modify it under the terms of the GNU General Public License as *
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
* License, or (at your option) any later version. *
|
|
* *
|
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
* GNU General Public License for more details. *
|
|
* *
|
|
* You should have received a copy of the GNU General Public License *
|
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
|
***************************************************************************/
|
|
|
|
#pragma once
|
|
|
|
#include <QVariant>
|
|
|
|
|
|
class QCronScheduler;
|
|
class QLocalServer;
|
|
class QWidget;
|
|
|
|
class AbstractExtItem : public QObject
|
|
{
|
|
Q_OBJECT
|
|
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
|
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
|
|
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
|
Q_PROPERTY(QString cron READ cron WRITE setCron)
|
|
Q_PROPERTY(QString fileName READ fileName)
|
|
Q_PROPERTY(QString filePath READ filePath)
|
|
Q_PROPERTY(int interval READ interval WRITE setInterval)
|
|
Q_PROPERTY(QString name READ name WRITE setName)
|
|
Q_PROPERTY(int number READ number WRITE setNumber)
|
|
Q_PROPERTY(QString socket READ socket WRITE setSocket)
|
|
Q_PROPERTY(QString uniq READ uniq)
|
|
|
|
public:
|
|
explicit AbstractExtItem(QObject *_parent = nullptr, const QString &_filePath = "");
|
|
~AbstractExtItem() override;
|
|
virtual void bumpApi(int _newVer);
|
|
virtual AbstractExtItem *copy(const QString &_fileName, int _number) = 0;
|
|
virtual void copyDefaults(AbstractExtItem *_other) const;
|
|
virtual void startTimer();
|
|
[[nodiscard]] QString writableConfig() const;
|
|
// get methods
|
|
[[nodiscard]] int apiVersion() const;
|
|
[[nodiscard]] QString comment() const;
|
|
[[nodiscard]] QString cron() const;
|
|
[[nodiscard]] QString fileName() const;
|
|
[[nodiscard]] QString filePath() const;
|
|
[[nodiscard]] int interval() const;
|
|
[[nodiscard]] bool isActive() const;
|
|
[[nodiscard]] QString name() const;
|
|
[[nodiscard]] int number() const;
|
|
[[nodiscard]] QString socket() const;
|
|
[[nodiscard]] QString tag(const QString &_type) const;
|
|
[[nodiscard]] virtual QString uniq() const = 0;
|
|
// set methods
|
|
void setApiVersion(int _apiVersion);
|
|
void setActive(bool _state);
|
|
void setComment(const QString &_comment);
|
|
void setCron(const QString &_cron);
|
|
void setInterval(int _interval);
|
|
void setName(const QString &_name);
|
|
void setNumber(int _number);
|
|
void setSocket(const QString &_socket);
|
|
|
|
signals:
|
|
void dataReceived(const QVariantHash &_data);
|
|
void requestDataUpdate();
|
|
|
|
public slots:
|
|
virtual void initSocket();
|
|
virtual void readConfiguration();
|
|
virtual QVariantHash run() = 0;
|
|
virtual int showConfiguration(QWidget *_parent, const QVariant &_args) = 0;
|
|
[[nodiscard]] virtual bool tryDelete() const;
|
|
virtual void writeConfiguration() const;
|
|
|
|
private:
|
|
QCronScheduler *m_scheduler = nullptr;
|
|
QString m_filePath = "";
|
|
int m_times = 0;
|
|
// properties
|
|
int m_apiVersion = 0;
|
|
bool m_active = true;
|
|
QString m_comment = "empty";
|
|
QString m_cron = "";
|
|
int m_interval = 1;
|
|
QString m_name = "none";
|
|
int m_number = -1;
|
|
QLocalServer *m_socket = nullptr;
|
|
QString m_socketFile = "";
|
|
};
|