This repository has been archived on 2022-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
modern-linbo-gui/headers/backend/linboos.h

122 lines
5.0 KiB
C++

/****************************************************************************
** Modern Linbo GUI
** Copyright (C) 2020 Dorian Zedler <dorian@itsblue.de>
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Affero 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef LINBOOS_H
#define LINBOOS_H
#include <QObject>
#include <QtDebug>
#include "linboimage.h"
class LinboOs : public QObject
{
Q_OBJECT
public:
friend class LinboBackend;
enum LinboOsStartAction {
UnknownAction = -1,
StartOs,
SyncOs,
ReinstallOs
};
const QString& getName() const {return this->name;}
const QString& getDescription() const {return this->description;}
const QString& getVersion() const {return this->version;}
const LinboImage* getBaseImage() const {return this->baseImage;}
const LinboImage* getDifferentialImage() const {return this->differentialImage;}
const QString& getIconName() const {return this->iconName;}
const QString& getRootPartition() const {return this->rootPartition;}
const QString& getBootPartition() const {return this->bootPartition;}
const QString& getKernel() const {return this->kernel;}
const QString& getInitrd() const {return this->initrd;}
const QString& getKernelOptions() const {return this->kernelOptions;}
const bool& getSyncbutton() const {return this->syncButton;}
const bool& getStartbutton() const {return this->startButton;}
const bool& getNewbutton() const {return this->newButton;}
const bool& getAutostart() const {return this->autostart;}
const int& getAutostartTimeout() const {return this->autostartTimeout;}
const LinboOsStartAction& getDefaultAction() const {return this->defaultAction;}
const bool& getHidden() const {return this->hidden;}
bool getActionEnabled(LinboOsStartAction action) {
switch (action) {
case StartOs: return this->getStartbutton();
case SyncOs: return this->getSyncbutton();
case ReinstallOs: return this->getNewbutton();
case UnknownAction: return false;
}
}
LinboOsStartAction startActionFromString(const QString& name) const {
if(name == "start")
return StartOs;
else if(name == "sync")
return SyncOs;
else if(name == "new")
return ReinstallOs;
return UnknownAction;
}
protected:
explicit LinboOs(QObject *parent = nullptr);
void setName( const QString& name ) {this->name = name;}
void setDescription ( const QString& description ) {this->description = description;}
void setVersion( const QString& version ) {this->version = version;}
void setBaseImage( LinboImage* baseImage ) {this->baseImage = baseImage;}
void setDifferentialImage(LinboImage* differentialImage) {this->differentialImage = differentialImage;}
void setIconName( const QString& iconName ) {this->iconName = iconName;}
void setRootPartition( const QString& rootPartition ) {this->rootPartition = rootPartition;}
void setBootPartition( const QString& bootPartition ) {this->bootPartition = bootPartition;}
void setKernel( const QString& kernel ) {this->kernel = kernel;}
void setInitrd( const QString& initrd ) {this->initrd = initrd;}
void setKernelOptions( const QString& kernelOptions ) {this->kernelOptions = kernelOptions;}
void setSyncButton ( const bool& syncButton ) {this->syncButton = syncButton;}
void setStartButton( const bool& startButton) {this->startButton = startButton;}
void setNewButton ( const bool& newButton ) {this->newButton = newButton;}
void setAutostart ( const bool& autostart ) {this->autostart = autostart;}
void setAutostartTimeout ( const int& autostartTimeout ) {this->autostartTimeout = autostartTimeout;}
void setDefaultAction ( const LinboOsStartAction& defaultAction ) {this->defaultAction = defaultAction;}
void setHidden ( const bool& hidden ) {this->hidden = hidden;}
private:
QString name, // OS Name
version,
description,
iconName, // Thumbnail for Image
rootPartition, // Root partition
bootPartition, // Root partition
image,
kernel,
initrd,
kernelOptions;
int autostartTimeout;
bool syncButton, startButton, newButton, autostart,
hidden; // show OS tab or not
LinboOsStartAction defaultAction;
LinboImage* baseImage;
LinboImage* differentialImage;
};
#endif // LINBOOS_H