- fixed os selection row for one item
- implemented new executeCommand() function - further implemented backend functionality
This commit is contained in:
parent
b73d45d955
commit
ba722f1634
9 changed files with 305 additions and 188 deletions
|
@ -40,6 +40,7 @@ using namespace std;
|
||||||
class LinboBackend : public QObject
|
class LinboBackend : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(LinboState state READ getState NOTIFY stateChanged)
|
||||||
public:
|
public:
|
||||||
explicit LinboBackend(QObject *parent = nullptr);
|
explicit LinboBackend(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
@ -49,9 +50,10 @@ public:
|
||||||
Partitioning,
|
Partitioning,
|
||||||
Starting,
|
Starting,
|
||||||
Syncing,
|
Syncing,
|
||||||
Installing
|
Reinstalling
|
||||||
};
|
};
|
||||||
|
|
||||||
|
LinboState getState();
|
||||||
LinboConfig* getConfig();
|
LinboConfig* getConfig();
|
||||||
QList<LinboOs*> getOperatingSystems();
|
QList<LinboOs*> getOperatingSystems();
|
||||||
|
|
||||||
|
@ -64,25 +66,40 @@ protected:
|
||||||
LinboDiskPartition* read_partition(ifstream* input);
|
LinboDiskPartition* read_partition(ifstream* input);
|
||||||
void read_globals( ifstream* input, LinboConfig* config );
|
void read_globals( ifstream* input, LinboConfig* config );
|
||||||
void saveappend( QStringList& command, const QString& item );
|
void saveappend( QStringList& command, const QString& item );
|
||||||
QStringList mksyncstartcommand(LinboConfig& config, LinboOs& os);
|
|
||||||
QStringList mksynccommand(LinboConfig& config, LinboOs& os);
|
|
||||||
QStringList mksyncrcommand(LinboConfig& config, LinboOs& os);
|
|
||||||
QStringList mkpartitioncommand(vector <LinboDiskPartition> &p);
|
QStringList mkpartitioncommand(vector <LinboDiskPartition> &p);
|
||||||
QStringList mkpartitioncommand_noformat(vector <LinboDiskPartition> &p);
|
QStringList mkpartitioncommand_noformat(vector <LinboDiskPartition> &p);
|
||||||
QStringList mkcacheinitcommand(LinboConfig& config, vector<LinboOs> &os, const QString& type);
|
QStringList mkcacheinitcommand(LinboConfig& config, vector<LinboOs> &os, const QString& type);
|
||||||
QStringList mklinboupdatecommand(LinboConfig& config);
|
QStringList mklinboupdatecommand(LinboConfig& config);
|
||||||
|
|
||||||
|
void setState(LinboState state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
LinboState state;
|
||||||
LinboConfig* config;
|
LinboConfig* config;
|
||||||
|
QStringList linboCommandCache;
|
||||||
QList<LinboOs*> operatingSystems;
|
QList<LinboOs*> operatingSystems;
|
||||||
QList<LinboDiskPartition*> diskPartitions;
|
QList<LinboDiskPartition*> diskPartitions;
|
||||||
|
|
||||||
QProcess* process;
|
QProcess* process;
|
||||||
|
|
||||||
|
QString executeCommand(bool waitForFinished);
|
||||||
|
|
||||||
|
template<typename ... Strings>
|
||||||
|
QString executeCommand(bool waitForFinished, QString argument, const Strings&... arguments) {
|
||||||
|
// this appends a quoted space in case item is empty and resolves
|
||||||
|
// problems with linbo_cmd's weird "shift"-usage
|
||||||
|
if (argument.isEmpty())
|
||||||
|
this->linboCommandCache.append("");
|
||||||
|
else
|
||||||
|
this->linboCommandCache.append(argument);
|
||||||
|
|
||||||
|
return executeCommand(waitForFinished, arguments...);
|
||||||
|
}
|
||||||
|
|
||||||
void readFromStdout();
|
void readFromStdout();
|
||||||
void readFromStderr();
|
void readFromStderr();
|
||||||
|
|
||||||
void executeCommand(QStringList commandArgs, bool waitForFinished = true);
|
QString executeCommand(bool wait, QString command, QStringList commandArgs);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void executeAutostart();
|
void executeAutostart();
|
||||||
|
@ -90,10 +107,11 @@ public slots:
|
||||||
void reboot();
|
void reboot();
|
||||||
|
|
||||||
bool startOs(LinboOs* os);
|
bool startOs(LinboOs* os);
|
||||||
//bool syncStartOs();
|
bool syncOs(LinboOs* os);
|
||||||
//bool reinstallStartOs();
|
bool reinstallOs(LinboOs* os);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void stateChanged();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#define LINBOOS_H
|
#define LINBOOS_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
#include "linboimage.h"
|
#include "linboimage.h"
|
||||||
|
|
||||||
|
@ -29,6 +30,13 @@ class LinboOs : public QObject
|
||||||
public:
|
public:
|
||||||
friend class LinboBackend;
|
friend class LinboBackend;
|
||||||
|
|
||||||
|
enum LinboOsStartAction {
|
||||||
|
UnknownAction = -1,
|
||||||
|
StartOs,
|
||||||
|
SyncOs,
|
||||||
|
ReinstallOs
|
||||||
|
};
|
||||||
|
|
||||||
const QString& getName() const {return this->name;}
|
const QString& getName() const {return this->name;}
|
||||||
const QString& getDescription() const {return this->description;}
|
const QString& getDescription() const {return this->description;}
|
||||||
const QString& getVersion() const {return this->version;}
|
const QString& getVersion() const {return this->version;}
|
||||||
|
@ -45,9 +53,29 @@ public:
|
||||||
const bool& getNewbutton() const {return this->newButton;}
|
const bool& getNewbutton() const {return this->newButton;}
|
||||||
const bool& getAutostart() const {return this->autostart;}
|
const bool& getAutostart() const {return this->autostart;}
|
||||||
const int& getAutostartTimeout() const {return this->autostartTimeout;}
|
const int& getAutostartTimeout() const {return this->autostartTimeout;}
|
||||||
const QString& getDefaultAction() const {return this->defaultAction;}
|
const LinboOsStartAction& getDefaultAction() const {return this->defaultAction;}
|
||||||
const bool& getHidden() const {return this->hidden;}
|
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 {
|
||||||
|
qDebug() << "default action name is: " << name;
|
||||||
|
if(name == "start")
|
||||||
|
return StartOs;
|
||||||
|
else if(name == "sync")
|
||||||
|
return SyncOs;
|
||||||
|
else if(name == "new")
|
||||||
|
return ReinstallOs;
|
||||||
|
return UnknownAction;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit LinboOs(QObject *parent = nullptr);
|
explicit LinboOs(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
@ -67,7 +95,7 @@ protected:
|
||||||
void setNewButton ( const bool& newButton ) {this->newButton = newButton;}
|
void setNewButton ( const bool& newButton ) {this->newButton = newButton;}
|
||||||
void setAutostart ( const bool& autostart ) {this->autostart = autostart;}
|
void setAutostart ( const bool& autostart ) {this->autostart = autostart;}
|
||||||
void setAutostartTimeout ( const int& autostartTimeout ) {this->autostartTimeout = autostartTimeout;}
|
void setAutostartTimeout ( const int& autostartTimeout ) {this->autostartTimeout = autostartTimeout;}
|
||||||
void setDefaultAction ( const QString& defaultAction ) {this->defaultAction = defaultAction;}
|
void setDefaultAction ( const LinboOsStartAction& defaultAction ) {this->defaultAction = defaultAction;}
|
||||||
void setHidden ( const bool& hidden ) {this->hidden = hidden;}
|
void setHidden ( const bool& hidden ) {this->hidden = hidden;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -80,11 +108,11 @@ private:
|
||||||
image,
|
image,
|
||||||
kernel,
|
kernel,
|
||||||
initrd,
|
initrd,
|
||||||
kernelOptions,
|
kernelOptions;
|
||||||
defaultAction;
|
|
||||||
int autostartTimeout;
|
int autostartTimeout;
|
||||||
bool syncButton, startButton, newButton, autostart,
|
bool syncButton, startButton, newButton, autostart,
|
||||||
hidden; // show OS tab or not
|
hidden; // show OS tab or not
|
||||||
|
LinboOsStartAction defaultAction;
|
||||||
|
|
||||||
LinboImage* baseImage;
|
LinboImage* baseImage;
|
||||||
LinboImage* differentialImage;
|
LinboImage* differentialImage;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
#include "linbobackend.h"
|
#include "linbobackend.h"
|
||||||
#include "linboosselectionrow.h"
|
#include "linboosselectionrow.h"
|
||||||
|
@ -28,9 +29,10 @@ private:
|
||||||
QModernStackedWidget* stackView;
|
QModernStackedWidget* stackView;
|
||||||
|
|
||||||
QWidget* buttonWidget;
|
QWidget* buttonWidget;
|
||||||
QModernPushButton* defaultActionButton;
|
QModernPushButton* startOsButton;
|
||||||
QModernPushButton* secondActionButton;
|
QModernPushButton* syncOsButton;
|
||||||
QModernPushButton* thirdActionButton;
|
QModernPushButton* reinstallOsButton;
|
||||||
|
QList<QModernPushButton*> actionButtons;
|
||||||
|
|
||||||
QWidget* progressBarWidget;
|
QWidget* progressBarWidget;
|
||||||
QModernProgressBar* progressBar;
|
QModernProgressBar* progressBar;
|
||||||
|
@ -38,9 +40,12 @@ private:
|
||||||
void resizeAndPositionAllItems();
|
void resizeAndPositionAllItems();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void startOs();
|
void executeStartAction();
|
||||||
|
void executeSyncAction();
|
||||||
|
void executeReinstallAction();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void selectedOsChanged();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include "linbobackend.h"
|
#include "linbobackend.h"
|
||||||
|
|
||||||
#define LINBO_CMD(arg) QStringList("linbo_cmd") << (arg);
|
#define LINBO_CMD(arg) QStringList("linbo_cmd") << (arg)
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -88,65 +88,33 @@ LinboBackend::LinboBackend(QObject *parent) : QObject(parent)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// client ip
|
// client ip
|
||||||
command = LINBO_CMD("ip");
|
this->config->setIpAddress(this->executeCommand(true, "ip"));
|
||||||
// myprocess->setArguments( command );
|
|
||||||
process->start( command.join(" ") );
|
|
||||||
while( !process->waitForFinished(10000) ) {}
|
|
||||||
this->config->setIpAddress(process->readAllStandardOutput());
|
|
||||||
|
|
||||||
// mac address
|
// mac address
|
||||||
command.clear();
|
this->config->setMacAddress(this->executeCommand(true, "mac"));
|
||||||
command = LINBO_CMD("mac");
|
|
||||||
|
|
||||||
process->start( command.join(" ") );
|
|
||||||
while( !process->waitForFinished(10000) ) {}
|
|
||||||
this->config->setMacAddress(process->readAllStandardOutput());
|
|
||||||
|
|
||||||
// Version
|
// Version
|
||||||
command = LINBO_CMD("version");
|
this->config->setVersion(this->executeCommand(true, "version").stripWhiteSpace());
|
||||||
// myprocess->setArguments( command );
|
|
||||||
process->start( command.join(" ") );
|
|
||||||
while( !process->waitForFinished(10000) ) {}
|
|
||||||
this->config->setVersion(process->readAllStandardOutput().stripWhiteSpace());
|
|
||||||
|
|
||||||
// hostname
|
// hostname
|
||||||
command = LINBO_CMD("hostname");
|
this->config->setHostname(this->executeCommand(true, "hostname"));
|
||||||
// myprocess->setArguments( command );
|
|
||||||
process->start( command.join(" ") );
|
|
||||||
while( !process->waitForFinished(10000) ) {}
|
|
||||||
this->config->setHostname(process->readAllStandardOutput());
|
|
||||||
|
|
||||||
// CPU
|
// CPU
|
||||||
command = LINBO_CMD("cpu");
|
this->config->setCpu(this->executeCommand(true, "cpu"));
|
||||||
// myprocess->setArguments( command );
|
|
||||||
process->start( command.join(" ") );
|
|
||||||
while( !process->waitForFinished(10000) ) {}
|
|
||||||
this->config->setCpu(process->readAllStandardOutput());
|
|
||||||
|
|
||||||
// Memory
|
// Memory
|
||||||
command = LINBO_CMD("memory");
|
this->config->setRamSize(this->executeCommand(true, "memory"));
|
||||||
process->start( command.join(" ") );
|
|
||||||
while( !process->waitForFinished(10000) ) {}
|
|
||||||
this->config->setRamSize(process->readAllStandardOutput());
|
|
||||||
|
|
||||||
// Cache Size
|
// Cache Size
|
||||||
command = LINBO_CMD("size");
|
this->config->setCacheSize(this->executeCommand(true, "size"));
|
||||||
saveappend( command, this->config->getCache() );
|
|
||||||
process->start( command.join(" ") );
|
|
||||||
while( !process->waitForFinished(10000) ) {}
|
|
||||||
this->config->setCacheSize(process->readAllStandardOutput());
|
|
||||||
|
|
||||||
// Harddisk Size
|
// Harddisk Size
|
||||||
QRegExp *removePartition = new QRegExp("[0-9]{1,2}");
|
QRegExp *removePartition = new QRegExp("[0-9]{1,2}");
|
||||||
QString hd = this->config->getCache();
|
QString hd = this->config->getCache();
|
||||||
|
// e.g. turn /dev/sda1 into /dev/sda
|
||||||
hd.remove( *removePartition );
|
hd.remove( *removePartition );
|
||||||
|
|
||||||
command = LINBO_CMD("size");
|
this->config->setHddSize(this->executeCommand(true, "size", hd));
|
||||||
saveappend( command, hd );
|
|
||||||
|
|
||||||
process->start( command.join(" ") );
|
|
||||||
while( !process->waitForFinished(10000) ) {}
|
|
||||||
this->config->setHddSize(process->readAllStandardOutput());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------
|
// --------------------
|
||||||
|
@ -158,36 +126,76 @@ void LinboBackend::executeAutostart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinboBackend::shutdown() {
|
void LinboBackend::shutdown() {
|
||||||
QStringList command;
|
this->executeCommand(false, "busybox", QStringList("poweroff"));
|
||||||
command.clear();
|
|
||||||
command = QStringList("busybox");
|
|
||||||
command.append("poweroff");
|
|
||||||
// TODO logConsole->writeStdOut( QString("shutdown entered") );
|
|
||||||
process->start( command.join(" ") );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinboBackend::reboot() {
|
void LinboBackend::reboot() {
|
||||||
QStringList command;
|
this->executeCommand(false, "busybox", QStringList("reboot"));
|
||||||
command.clear();
|
|
||||||
command = QStringList("busybox");
|
|
||||||
command.append("reboot");
|
|
||||||
// TODO logConsole->writeStdOut( QString("reboot entered") );
|
|
||||||
process->start( command.join(" ") );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LinboBackend::startOs(LinboOs* os) {
|
bool LinboBackend::startOs(LinboOs* os) {
|
||||||
if(os == nullptr)
|
if(os == nullptr || this->state != Idle)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QStringList command = LINBO_CMD("start");
|
this->setState(Starting);
|
||||||
saveappend( command, os->getBootPartition() );
|
|
||||||
saveappend( command, os->getRootPartition() );
|
|
||||||
saveappend( command, os->getKernel() );
|
|
||||||
saveappend( command, os->getInitrd() );
|
|
||||||
saveappend( command, os->getKernelOptions() );
|
|
||||||
saveappend( command, this->config->getCache() );
|
|
||||||
|
|
||||||
this->executeCommand(command, false);
|
this->executeCommand(
|
||||||
|
false,
|
||||||
|
"start",
|
||||||
|
os->getBootPartition(),
|
||||||
|
os->getRootPartition(),
|
||||||
|
os->getKernel(),
|
||||||
|
os->getInitrd(),
|
||||||
|
os->getKernelOptions(),
|
||||||
|
this->config->getCache()
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LinboBackend::syncOs(LinboOs* os) {
|
||||||
|
if(os == nullptr || this->state != Idle)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
this->setState(Syncing);
|
||||||
|
|
||||||
|
this->executeCommand(
|
||||||
|
false,
|
||||||
|
"syncstart",
|
||||||
|
this->config->getServer(),
|
||||||
|
this->config->getCache(),
|
||||||
|
os->getBaseImage()->getName(),
|
||||||
|
os->getDifferentialImage()->getName(),
|
||||||
|
os->getBootPartition(),
|
||||||
|
os->getRootPartition(),
|
||||||
|
os->getKernel(),
|
||||||
|
os->getInitrd(),
|
||||||
|
os->getKernelOptions()
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LinboBackend::reinstallOs(LinboOs* os) {
|
||||||
|
if(os == nullptr || this->state != Idle)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
this->setState(Reinstalling);
|
||||||
|
|
||||||
|
this->executeCommand(
|
||||||
|
false,
|
||||||
|
"syncr",
|
||||||
|
this->config->getServer(),
|
||||||
|
this->config->getCache(),
|
||||||
|
os->getBaseImage()->getName(),
|
||||||
|
os->getDifferentialImage()->getName(),
|
||||||
|
os->getBootPartition(),
|
||||||
|
os->getRootPartition(),
|
||||||
|
os->getKernel(),
|
||||||
|
os->getInitrd(),
|
||||||
|
os->getKernelOptions(),
|
||||||
|
QString("force")
|
||||||
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -205,19 +213,42 @@ QList<LinboOs*> LinboBackend::getOperatingSystems() {
|
||||||
// - Helpers -
|
// - Helpers -
|
||||||
// -----------
|
// -----------
|
||||||
|
|
||||||
void LinboBackend::executeCommand(QStringList commandArgs, bool waitForFinished) {
|
QString LinboBackend::executeCommand(bool waitForFinished) {
|
||||||
|
QStringList tmpList = this->linboCommandCache;
|
||||||
|
this->linboCommandCache.clear();
|
||||||
|
|
||||||
QString command = commandArgs.takeFirst();
|
return this->executeCommand(waitForFinished, "linbo_cmd", tmpList);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString LinboBackend::executeCommand(bool waitForFinished, QString command, QStringList commandArgs) {
|
||||||
|
|
||||||
|
if(waitForFinished)
|
||||||
|
// clear old output
|
||||||
|
this->process->readAll();
|
||||||
|
|
||||||
qDebug() << "Executing: " << command << " " << commandArgs.join(" ");
|
qDebug() << "Executing: " << command << " " << commandArgs.join(" ");
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
process->start(command, commandArgs);
|
process->start(command, commandArgs);
|
||||||
process->waitForStarted();
|
process->waitForStarted();
|
||||||
|
|
||||||
if(waitForFinished)
|
if(waitForFinished) {
|
||||||
while( !process->waitForFinished(10000) ) {}
|
while( !process->waitForFinished(10000) ) {}
|
||||||
|
return this->process->readAllStandardOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
LinboBackend::LinboState LinboBackend::getState() {
|
||||||
|
return this->state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinboBackend::setState(LinboState state) {
|
||||||
|
if(this->state == state)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this->state = state;
|
||||||
|
emit this->stateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinboBackend::read_qstring( ifstream* input, QString& tmp ) {
|
void LinboBackend::read_qstring( ifstream* input, QString& tmp ) {
|
||||||
|
@ -258,6 +289,7 @@ LinboOs* LinboBackend::read_os(ifstream* input) {
|
||||||
LinboOs* os = new LinboOs(this);
|
LinboOs* os = new LinboOs(this);
|
||||||
QString key, value;
|
QString key, value;
|
||||||
while(!input->eof() && read_pair(input, key, value)) {
|
while(!input->eof() && read_pair(input, key, value)) {
|
||||||
|
qDebug() << key << "=" << value;
|
||||||
if(key.compare("name") == 0) os->setName(value);
|
if(key.compare("name") == 0) os->setName(value);
|
||||||
else if(key.compare("description") == 0) os->setDescription(value);
|
else if(key.compare("description") == 0) os->setDescription(value);
|
||||||
else if(key.compare("version") == 0) os->setVersion(value);
|
else if(key.compare("version") == 0) os->setVersion(value);
|
||||||
|
@ -272,7 +304,7 @@ LinboOs* LinboBackend::read_os(ifstream* input) {
|
||||||
else if(key.compare("syncenabled") == 0) os->setSyncButton(toBool(value));
|
else if(key.compare("syncenabled") == 0) os->setSyncButton(toBool(value));
|
||||||
else if(key.compare("startenabled") == 0) os->setStartButton(toBool(value));
|
else if(key.compare("startenabled") == 0) os->setStartButton(toBool(value));
|
||||||
else if((key.compare("remotesyncenabled") == 0) || (key.compare("newenabled") == 0)) os->setNewButton(toBool(value));
|
else if((key.compare("remotesyncenabled") == 0) || (key.compare("newenabled") == 0)) os->setNewButton(toBool(value));
|
||||||
else if(key.compare("defaultaction") == 0) os->setDefaultAction(value);
|
else if(key.compare("defaultaction") == 0) os->setDefaultAction(os->startActionFromString(value));
|
||||||
else if(key.compare("autostart") == 0) os->setAutostart(toBool(value));
|
else if(key.compare("autostart") == 0) os->setAutostart(toBool(value));
|
||||||
else if(key.compare("autostarttimeout") == 0) os->setAutostartTimeout(value.toInt());
|
else if(key.compare("autostarttimeout") == 0) os->setAutostartTimeout(value.toInt());
|
||||||
else if(key.compare("hidden") == 0) os->setHidden(toBool(value));
|
else if(key.compare("hidden") == 0) os->setHidden(toBool(value));
|
||||||
|
@ -316,61 +348,6 @@ void LinboBackend::read_globals( ifstream* input, LinboConfig* config ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this appends a quoted space in case item is empty and resolves
|
|
||||||
// problems with linbo_cmd's weird "shift"-usage
|
|
||||||
void LinboBackend::saveappend( QStringList& command, const QString& item ) {
|
|
||||||
if ( item.isEmpty() )
|
|
||||||
command.append("");
|
|
||||||
else
|
|
||||||
command.append( item );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sync+start image
|
|
||||||
QStringList LinboBackend::mksyncstartcommand(LinboConfig& config, LinboOs& os) {
|
|
||||||
QStringList command = LINBO_CMD("syncstart");
|
|
||||||
saveappend( command, config.getServer() );
|
|
||||||
saveappend( command, config.getCache() );
|
|
||||||
saveappend( command, os.getBaseImage()->getName() );
|
|
||||||
saveappend( command, os.getDifferentialImage()->getName() );
|
|
||||||
saveappend( command, os.getBootPartition() ); // boot is same as root
|
|
||||||
saveappend( command, os.getRootPartition() );
|
|
||||||
saveappend( command, os.getKernel() );
|
|
||||||
saveappend( command, os.getInitrd() );
|
|
||||||
saveappend( command, os.getKernelOptions() );
|
|
||||||
return command;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sync image from cache
|
|
||||||
QStringList LinboBackend::mksynccommand(LinboConfig& config, LinboOs& os) {
|
|
||||||
QStringList command = LINBO_CMD("sync");
|
|
||||||
saveappend( command, config.getCache() );
|
|
||||||
saveappend( command, os.getBaseImage()->getName() );
|
|
||||||
saveappend( command, os.getDifferentialImage()->getName() );
|
|
||||||
saveappend( command, os.getBootPartition() );
|
|
||||||
saveappend( command, os.getRootPartition() );
|
|
||||||
saveappend( command, os.getKernel() );
|
|
||||||
saveappend( command, os.getInitrd() );
|
|
||||||
saveappend( command, os.getKernelOptions() );
|
|
||||||
return command;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sync image from server
|
|
||||||
QStringList LinboBackend::mksyncrcommand(LinboConfig& config, LinboOs& os) {
|
|
||||||
QStringList command = LINBO_CMD("syncr");
|
|
||||||
saveappend( command, config.getServer() );
|
|
||||||
saveappend( command, config.getCache() );
|
|
||||||
saveappend( command, os.getBaseImage()->getName() );
|
|
||||||
saveappend( command, os.getDifferentialImage()->getName() );
|
|
||||||
saveappend( command, os.getBootPartition() );
|
|
||||||
saveappend( command, os.getRootPartition() );
|
|
||||||
saveappend( command, os.getKernel() );
|
|
||||||
saveappend( command, os.getInitrd() );
|
|
||||||
saveappend( command, os.getKernelOptions() );
|
|
||||||
saveappend( command, QString("force") );
|
|
||||||
return command;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList LinboBackend::mkpartitioncommand(vector <LinboDiskPartition> &p) {
|
QStringList LinboBackend::mkpartitioncommand(vector <LinboDiskPartition> &p) {
|
||||||
QStringList command = LINBO_CMD("partition");
|
QStringList command = LINBO_CMD("partition");
|
||||||
for(unsigned int i=0; i<p.size(); i++) {
|
for(unsigned int i=0; i<p.size(); i++) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ LinboOs::LinboOs(QObject *parent) : QObject(parent)
|
||||||
autostart = false;
|
autostart = false;
|
||||||
autostartTimeout = 0;
|
autostartTimeout = 0;
|
||||||
hidden = false;
|
hidden = false;
|
||||||
defaultAction = QString("sync");
|
defaultAction = SyncOs;
|
||||||
// TODO ?? image_history.clear();
|
// TODO ?? image_history.clear();
|
||||||
iconName = QString("defaultIcon.svg");
|
iconName = QString("defaultIcon.svg");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//#define NEVERDEF
|
#define NEVERDEF
|
||||||
#ifdef NEVERDEF
|
#ifdef NEVERDEF
|
||||||
|
|
||||||
/* class building the LINBO GUI
|
/* class building the LINBO GUI
|
||||||
|
|
|
@ -21,8 +21,8 @@ LinboOsSelectionRow::LinboOsSelectionRow(LinboBackend* backend, QWidget *parent)
|
||||||
|
|
||||||
void LinboOsSelectionRow::resizeAndPositionAllButtons() {
|
void LinboOsSelectionRow::resizeAndPositionAllButtons() {
|
||||||
qDebug() << "Resizing all Buttons";
|
qDebug() << "Resizing all Buttons";
|
||||||
if(this->showOnlySelectedButton) {
|
|
||||||
int buttonWidth = this->width() / this->osButtonGroup->buttons().length();
|
int buttonWidth = this->width() / this->osButtonGroup->buttons().length();
|
||||||
|
if(this->showOnlySelectedButton) {
|
||||||
for(int i = 0; i < this->osButtons.length(); i++) {
|
for(int i = 0; i < this->osButtons.length(); i++) {
|
||||||
if(!this->osButtons[i]->button->isChecked())
|
if(!this->osButtons[i]->button->isChecked())
|
||||||
this->osButtons[i]->hide();
|
this->osButtons[i]->hide();
|
||||||
|
@ -31,13 +31,12 @@ void LinboOsSelectionRow::resizeAndPositionAllButtons() {
|
||||||
moveAnimation->setEasingCurve(QEasingCurve::InOutQuad);
|
moveAnimation->setEasingCurve(QEasingCurve::InOutQuad);
|
||||||
moveAnimation->setDuration(400);
|
moveAnimation->setDuration(400);
|
||||||
moveAnimation->setStartValue(this->osButtons[i]->geometry());
|
moveAnimation->setStartValue(this->osButtons[i]->geometry());
|
||||||
moveAnimation->setEndValue(QRect(buttonWidth / 2, 0, buttonWidth, this->height()));
|
moveAnimation->setEndValue(QRect((this->width() - buttonWidth) / 2, 0, buttonWidth, this->height()));
|
||||||
moveAnimation->start();
|
moveAnimation->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int buttonWidth = this->width() / this->osButtonGroup->buttons().length();
|
|
||||||
for(int i = 0; i < this->osButtons.length(); i++) {
|
for(int i = 0; i < this->osButtons.length(); i++) {
|
||||||
this->osButtons[i]->setGeometry(buttonWidth * i, 0, buttonWidth, this->height());
|
this->osButtons[i]->setGeometry(buttonWidth * i, 0, buttonWidth, this->height());
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,16 @@ LinboStartActions::LinboStartActions(LinboBackend* backend, LinboOsSelectionRow*
|
||||||
|
|
||||||
// Action Buttons
|
// Action Buttons
|
||||||
this->buttonWidget = new QWidget();
|
this->buttonWidget = new QWidget();
|
||||||
defaultActionButton = new QModernPushButton(":/svgIcons/startAction.svg", this->buttonWidget);
|
startOsButton = new QModernPushButton(":/svgIcons/startAction.svg", this->buttonWidget);
|
||||||
connect(defaultActionButton, SIGNAL(clicked()), this, SLOT(startOs()));
|
connect(startOsButton, SIGNAL(clicked()), this, SLOT(executeStartAction()));
|
||||||
secondActionButton = new QModernPushButton(":/svgIcons/syncAction.svg", this->buttonWidget);
|
syncOsButton = new QModernPushButton(":/svgIcons/syncAction.svg", this->buttonWidget);
|
||||||
thirdActionButton = new QModernPushButton(":/svgIcons/resetAction.svg", this->buttonWidget);
|
reinstallOsButton = new QModernPushButton(":/svgIcons/resetAction.svg", this->buttonWidget);
|
||||||
this->stackView->addWidget(this->buttonWidget);
|
this->stackView->addWidget(this->buttonWidget);
|
||||||
|
|
||||||
|
actionButtons.append(startOsButton);
|
||||||
|
actionButtons.append(syncOsButton);
|
||||||
|
actionButtons.append(reinstallOsButton);
|
||||||
|
|
||||||
// Progress bar
|
// Progress bar
|
||||||
this->progressBarWidget = new QWidget();
|
this->progressBarWidget = new QWidget();
|
||||||
progressBar = new QModernProgressBar(this->progressBarWidget);
|
progressBar = new QModernProgressBar(this->progressBarWidget);
|
||||||
|
@ -30,24 +34,96 @@ void LinboStartActions::resizeAndPositionAllItems() {
|
||||||
this->stackView->setFixedSize(this->size());
|
this->stackView->setFixedSize(this->size());
|
||||||
|
|
||||||
// Action buttons
|
// Action buttons
|
||||||
|
// bring buttons in correct order:
|
||||||
|
LinboOs* selectedOs = this->osSelectionRow->getSelectedOs();
|
||||||
|
LinboOs::LinboOsStartAction defaultAction = selectedOs->getDefaultAction();
|
||||||
|
|
||||||
|
int startOsPosition = 0;
|
||||||
|
int syncOsPosition = 1;
|
||||||
|
int reinstallOsPosition = 2;
|
||||||
|
|
||||||
|
qDebug() << "Default action is: " << defaultAction;
|
||||||
|
|
||||||
|
switch (defaultAction) {
|
||||||
|
case LinboOs::StartOs:
|
||||||
|
break;
|
||||||
|
case LinboOs::SyncOs:
|
||||||
|
syncOsPosition = 0;
|
||||||
|
startOsPosition = 1;
|
||||||
|
reinstallOsPosition = 2;
|
||||||
|
break;
|
||||||
|
case LinboOs::ReinstallOs:
|
||||||
|
reinstallOsPosition = 0;
|
||||||
|
syncOsPosition = 1;
|
||||||
|
startOsPosition = 2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//this->actionButtons.move(this->actionButtons.indexOf(this->startOsButton), startOsPosition);
|
||||||
|
//this->actionButtons.move(this->actionButtons.indexOf(this->syncOsButton), syncOsPosition);
|
||||||
|
//this->actionButtons.move(this->actionButtons.indexOf(this->reinstallOsButton), reinstallOsPosition);
|
||||||
|
|
||||||
|
while (this->actionButtons.length() < 3) {
|
||||||
|
this->actionButtons.append(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->actionButtons[startOsPosition] = this->startOsButton;
|
||||||
|
this->actionButtons[syncOsPosition] = this->syncOsButton;
|
||||||
|
this->actionButtons[reinstallOsPosition] = this->reinstallOsButton;
|
||||||
|
|
||||||
|
// check for disabled actions
|
||||||
|
QList<bool> positionsEnabled;
|
||||||
|
positionsEnabled.append(true);
|
||||||
|
positionsEnabled.append(true);
|
||||||
|
positionsEnabled.append(true);
|
||||||
|
|
||||||
|
positionsEnabled[startOsPosition] = selectedOs->getStartbutton();
|
||||||
|
positionsEnabled[syncOsPosition] = selectedOs->getSyncbutton();
|
||||||
|
positionsEnabled[reinstallOsPosition] = selectedOs->getNewbutton();
|
||||||
|
|
||||||
|
// move buttons into place
|
||||||
this->buttonWidget->setFixedSize(this->size());
|
this->buttonWidget->setFixedSize(this->size());
|
||||||
|
|
||||||
int buttonSpacing = this->height() * 0.1;
|
int buttonSpacing = this->height() * 0.1;
|
||||||
int defaultButtonHeight = this->height() * 0.6;
|
int defaultButtonHeight = this->height() * 0.6;
|
||||||
defaultActionButton->setGeometry((this->width() - defaultButtonHeight) / 2, 0,defaultButtonHeight, defaultButtonHeight);
|
this->actionButtons[0]->setGeometry((this->width() - defaultButtonHeight) / 2, 0,defaultButtonHeight, defaultButtonHeight);
|
||||||
|
|
||||||
int secondaryButtonHeight = this->height() * 0.3;
|
int secondaryButtonHeight = this->height() * 0.3;
|
||||||
secondActionButton->setGeometry(
|
if(positionsEnabled[1] && positionsEnabled[2]) {
|
||||||
|
this->actionButtons[1]->setGeometry(
|
||||||
this->width() / 2 - secondaryButtonHeight - buttonSpacing / 2,
|
this->width() / 2 - secondaryButtonHeight - buttonSpacing / 2,
|
||||||
defaultButtonHeight + buttonSpacing,
|
defaultButtonHeight + buttonSpacing,
|
||||||
secondaryButtonHeight,
|
secondaryButtonHeight,
|
||||||
secondaryButtonHeight
|
secondaryButtonHeight
|
||||||
);
|
);
|
||||||
|
|
||||||
thirdActionButton->setGeometry(
|
this->actionButtons[2]->setGeometry(
|
||||||
this->width() / 2 + buttonSpacing / 2,
|
this->width() / 2 + buttonSpacing / 2,
|
||||||
defaultButtonHeight + buttonSpacing,
|
defaultButtonHeight + buttonSpacing,
|
||||||
secondaryButtonHeight,
|
secondaryButtonHeight,
|
||||||
secondaryButtonHeight
|
secondaryButtonHeight
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
else if(!positionsEnabled[1]) {
|
||||||
|
this->actionButtons[1]->hide();
|
||||||
|
this->actionButtons[2]->setGeometry(
|
||||||
|
this->width() / 2 - secondaryButtonHeight / 2,
|
||||||
|
defaultButtonHeight + buttonSpacing,
|
||||||
|
secondaryButtonHeight,
|
||||||
|
secondaryButtonHeight
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if(!positionsEnabled[2]) {
|
||||||
|
this->actionButtons[1]->setGeometry(
|
||||||
|
this->width() / 2 - secondaryButtonHeight / 2,
|
||||||
|
defaultButtonHeight + buttonSpacing,
|
||||||
|
secondaryButtonHeight,
|
||||||
|
secondaryButtonHeight
|
||||||
|
);
|
||||||
|
this->actionButtons[2]->hide();
|
||||||
|
}
|
||||||
|
|
||||||
// Progress bar
|
// Progress bar
|
||||||
this->progressBarWidget->setFixedSize(this->size());
|
this->progressBarWidget->setFixedSize(this->size());
|
||||||
|
@ -61,7 +137,21 @@ void LinboStartActions::resizeEvent(QResizeEvent *event) {
|
||||||
QWidget::resizeEvent(event);
|
QWidget::resizeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinboStartActions::startOs() {
|
void LinboStartActions::executeStartAction() {
|
||||||
|
this->stackView->setCurrentWidgetAnimated(this->progressBarWidget);
|
||||||
|
this->osSelectionRow->setShowOnlySelectedButton(true);
|
||||||
|
this->backend->startOs(this->osSelectionRow->getSelectedOs());
|
||||||
|
//this->progressBar->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinboStartActions::executeSyncAction() {
|
||||||
|
this->stackView->setCurrentWidgetAnimated(this->progressBarWidget);
|
||||||
|
this->osSelectionRow->setShowOnlySelectedButton(true);
|
||||||
|
this->backend->startOs(this->osSelectionRow->getSelectedOs());
|
||||||
|
//this->progressBar->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinboStartActions::executeReinstallAction() {
|
||||||
this->stackView->setCurrentWidgetAnimated(this->progressBarWidget);
|
this->stackView->setCurrentWidgetAnimated(this->progressBarWidget);
|
||||||
this->osSelectionRow->setShowOnlySelectedButton(true);
|
this->osSelectionRow->setShowOnlySelectedButton(true);
|
||||||
this->backend->startOs(this->osSelectionRow->getSelectedOs());
|
this->backend->startOs(this->osSelectionRow->getSelectedOs());
|
||||||
|
|
|
@ -47,7 +47,7 @@ LinboStartPage::LinboStartPage(LinboBackend* backend, QWidget *parent) : QWidget
|
||||||
QWidget* mainLayoutWidget = new QWidget(this);
|
QWidget* mainLayoutWidget = new QWidget(this);
|
||||||
mainLayoutWidget->setGeometry(this->geometry());
|
mainLayoutWidget->setGeometry(this->geometry());
|
||||||
QVBoxLayout* mainLayout = new QVBoxLayout(mainLayoutWidget);
|
QVBoxLayout* mainLayout = new QVBoxLayout(mainLayoutWidget);
|
||||||
mainLayout->setSpacing(0);
|
mainLayout->setSpacing(this->height()*0.025);
|
||||||
mainLayout->setContentsMargins(0,0,0,0);
|
mainLayout->setContentsMargins(0,0,0,0);
|
||||||
mainLayout->addItem(new QSpacerItem(0,0, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
mainLayout->addItem(new QSpacerItem(0,0, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||||
mainLayout->addWidget(osSelectionRow);
|
mainLayout->addWidget(osSelectionRow);
|
||||||
|
|
Reference in a new issue