Files
pay/src/ModuleSection.h
T

101 lines
3.1 KiB
C++
Raw Permalink Normal View History

/*
* This file is part of the Flowee project
* Copyright (C) 2023 Tom Zander <tom@flowee.org>
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
2023-06-11 19:06:16 +02:00
#ifndef MODULE_SECTION_H
#define MODULE_SECTION_H
#include <QObject>
2023-06-13 13:01:17 +02:00
/**
* The module section represts a single Hook into the Flowee Pay user interface.
* This class fits in the ModuleInfo and ModuleManager framework for modules.
*
* A module can fit into one or more placs in the UI and the user can enable those
* separately in the modules overview.
*/
2023-06-11 19:06:16 +02:00
class ModuleSection : public QObject
{
Q_OBJECT
2023-06-12 15:26:31 +02:00
Q_PROPERTY(QString text READ text CONSTANT)
Q_PROPERTY(QString subtext READ subtext CONSTANT)
Q_PROPERTY(QString qml READ startQMLFile CONSTANT)
2023-06-12 23:43:22 +02:00
Q_PROPERTY(bool isSendMethod READ isSendMethod CONSTANT)
2023-07-04 23:16:35 +02:00
Q_PROPERTY(bool isMainMenuMethod READ isMainMenuMethod CONSTANT)
2023-06-11 19:06:16 +02:00
public:
2023-06-12 15:26:31 +02:00
/// The placement in the main app of this section.
enum SectionType {
SendMethod, //< A specific way to send coin, shown in list of send-methods.
// BuildTxComponent, //< Inside the 'build-transactions' this adds a new buildingblock.
MainMenuItem, //< A text-button in the main menu
2023-06-12 15:26:31 +02:00
};
2023-06-11 19:06:16 +02:00
2023-06-12 15:26:31 +02:00
explicit ModuleSection(SectionType type, QObject *parent = nullptr);
/**
* This text is used on in the chosen UI-type to select this module.
*/
void setText(const QString &newText);
QString text() const;
/// This text is the alt-text
void setSubtext(const QString &newSubtext);
QString subtext() const;
/**
* This section may only show if another module is enabled,
* name that module (by id) here.
* \sa ModuleInfo::id()
*/
void setRequiredModules(const QStringList &modules);
QStringList requiredModules() const;
/**
* The QML file that should be loaded to invoke this module.
*/
void setStartQMLFile(const QString &filename);
QString startQMLFile() const;
SectionType type() const;
2023-06-12 23:43:22 +02:00
bool isSendMethod() const {
return m_type == SendMethod;
}
2023-07-04 23:16:35 +02:00
bool isMainMenuMethod() const {
return m_type == MainMenuItem;
}
2023-06-12 23:43:22 +02:00
bool enabled() const;
2023-06-13 13:01:17 +02:00
/**
* This is set by the user or restored from the save file upon restart.
*/
2023-06-12 23:43:22 +02:00
void setEnabled(bool on);
signals:
void enabledChanged();
2023-06-11 19:06:16 +02:00
private:
2023-06-12 15:26:31 +02:00
const SectionType m_type;
2023-06-11 19:06:16 +02:00
QString m_text;
QString m_subtext;
2023-06-12 15:26:31 +02:00
QString m_startQMLfile;
2023-06-12 23:43:22 +02:00
bool m_enabled = true;
2023-06-11 19:06:16 +02:00
QStringList m_requiredModules;
2023-06-12 23:43:22 +02:00
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
2023-06-11 19:06:16 +02:00
};
#endif