mirror of
https://github.com/QuasarApp/QtDeployer.git
synced 2025-04-27 05:54:31 +00:00
commit
21ac323630
@ -5,6 +5,9 @@ QString BaseClass::m_qtdir = QString();
|
||||
QString BaseClass::m_outputdir = QString();
|
||||
QString BaseClass::m_projectdir = QString();
|
||||
QString BaseClass::m_executablepath = QString();
|
||||
QString BaseClass::m_binarycreator = QString();
|
||||
QString BaseClass::projectName = QString();
|
||||
QString BaseClass::appIcon = QString();
|
||||
|
||||
QStringList BaseClass::findFilesInsideDir(const QString &name, const QString &dirpath)
|
||||
{
|
||||
|
@ -17,8 +17,11 @@ class BaseClass : public QObject
|
||||
protected:
|
||||
static QString m_qtdir;
|
||||
static QString m_outputdir;
|
||||
static QString m_binarycreator;
|
||||
static QString m_projectdir;
|
||||
static QString m_executablepath;
|
||||
static QString projectName;
|
||||
static QString appIcon;
|
||||
|
||||
QStringList findFilesInsideDir(const QString &name, const QString &dirpath);
|
||||
|
||||
|
@ -12,7 +12,6 @@ private:
|
||||
QString qmake;
|
||||
QString tempBuildFolder;
|
||||
QString tempLog;
|
||||
QString projectName;
|
||||
QProcess pQMake;
|
||||
|
||||
bool createFulder(QDir& dir, QString& path, const QString& name) const;
|
||||
|
@ -91,9 +91,6 @@ void CppManager::divideLibraries()
|
||||
|
||||
void CppManager::start(const QStringList &executables)
|
||||
{
|
||||
m_qtLibraries.clear();
|
||||
m_cppLibraries.clear();
|
||||
m_notFoundLibs.clear();
|
||||
|
||||
extractAllLibs(executables);
|
||||
divideLibraries();
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "mainmanager.h"
|
||||
#include "utils.h"
|
||||
#include <QThread>
|
||||
#include <QSettings>
|
||||
|
||||
QStringList MainManager::getAllExecutables()
|
||||
{
|
||||
@ -41,7 +43,7 @@ CppManager* MainManager::getCpp(){
|
||||
return m_cpp;
|
||||
}
|
||||
|
||||
void MainManager::prepare(const QString &qtdir, const QString &projectdir)
|
||||
void MainManager::prepare(const QString &qtdir, const QString &projectdir, const QString& icon)
|
||||
{
|
||||
QStringList list;
|
||||
list << qtdir << projectdir ;
|
||||
@ -52,9 +54,23 @@ void MainManager::prepare(const QString &qtdir, const QString &projectdir)
|
||||
m_qtdir = list[0];
|
||||
m_projectdir = list[1];
|
||||
|
||||
if(QFileInfo(icon).exists()){
|
||||
appIcon = icon;
|
||||
} else {
|
||||
appIcon = ":/install/res/iconInstaller.png";
|
||||
}
|
||||
|
||||
QSettings s;
|
||||
s.setValue("qtDir", m_qtdir);
|
||||
|
||||
m_bld->build();
|
||||
}
|
||||
|
||||
QString MainManager::qtDir() const {
|
||||
QSettings s;
|
||||
return s.value("qtDir", "").toString();
|
||||
}
|
||||
|
||||
void MainManager::deploy(const QStringList& list){
|
||||
m_cpp->setCppLibraries(list);
|
||||
start(true);
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "pluginmanager.h"
|
||||
#include "qmlmanager.h"
|
||||
#include "buildmanager.h"
|
||||
#include <QThread>
|
||||
|
||||
class MainManager : public BaseClass
|
||||
{
|
||||
@ -23,7 +24,6 @@ class MainManager : public BaseClass
|
||||
OutputManager *m_out;
|
||||
BuildManager *m_bld;
|
||||
|
||||
|
||||
int m_state;
|
||||
|
||||
QStringList getAllExecutables();
|
||||
@ -41,7 +41,9 @@ public:
|
||||
CppManager* getCpp();
|
||||
|
||||
public slots:
|
||||
void prepare(const QString &qtdir, const QString &projectdir);
|
||||
void prepare(const QString &qtdir, const QString &projectdir, const QString &icon);
|
||||
|
||||
QString qtDir() const;
|
||||
|
||||
void deploy(const QStringList& list);
|
||||
void start(bool erase);
|
||||
|
@ -1,4 +1,12 @@
|
||||
#include "outputmanager.h"
|
||||
#include "utils.h"
|
||||
#include <QDate>
|
||||
|
||||
OutputManager::OutputManager(QObject *parent) : BaseClass(parent) {/*finished*/
|
||||
connect(&installer_process, &QProcess::readyReadStandardOutput, this, &OutputManager::buildLog);
|
||||
// connect(&installer_process, &QProcess::finished, this, &OutputManager::buildFunished);
|
||||
connect(&installer_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(buildFunished(int, QProcess::ExitStatus)));
|
||||
}
|
||||
|
||||
void OutputManager::setPathsToCopy(const QStringList &pathsToCopy)
|
||||
{
|
||||
@ -16,6 +24,21 @@ void OutputManager::setCopySuccess(const QList<bool> ©Success)
|
||||
emit copySuccessChanged(m_copySuccess);
|
||||
}
|
||||
|
||||
const QString& OutputManager::log() const{
|
||||
return tempLog;
|
||||
}
|
||||
|
||||
void OutputManager::buildLog(){
|
||||
tempLog = installer_process.readAll();
|
||||
emit logChanged(tempLog);
|
||||
}
|
||||
|
||||
void OutputManager::buildFunished(int error, QProcess::ExitStatus){
|
||||
if(!error){
|
||||
emit finished();
|
||||
}
|
||||
}
|
||||
|
||||
bool OutputManager::copyDir(const QString &source, const QString &destin)
|
||||
{
|
||||
QDir().mkpath(destin);
|
||||
@ -30,8 +53,14 @@ bool OutputManager::copyDir(const QString &source, const QString &destin)
|
||||
}
|
||||
|
||||
void OutputManager::copyCpp(const QStringList &libs)
|
||||
{
|
||||
auto libdir = m_outputdir + "/lib";
|
||||
{
|
||||
|
||||
QString temp = "/lib";
|
||||
if(isInstallFW()){
|
||||
temp = "/packages/lib/data/lib";
|
||||
}
|
||||
|
||||
auto libdir = m_outputdir + temp;
|
||||
|
||||
for (const QString &S : libs)
|
||||
{
|
||||
@ -48,30 +77,64 @@ void OutputManager::copyAll(const QStringList &qtlibs, const QStringList &libs,
|
||||
m_pathsToCopy.clear();
|
||||
m_copySuccess.clear();
|
||||
|
||||
tempLog = tr("Start preparing project");
|
||||
emit logChanged(tempLog);
|
||||
|
||||
if (erase)
|
||||
{
|
||||
|
||||
tempLog = tr("Start erase output dir");
|
||||
emit logChanged(tempLog);
|
||||
|
||||
QDir(m_outputdir).removeRecursively();
|
||||
QDir dir(m_outputdir);
|
||||
dir.cdUp();
|
||||
dir.mkdir(QDir(m_outputdir).dirName());
|
||||
}
|
||||
|
||||
checkInstallFrameWork();
|
||||
|
||||
createDirectories();
|
||||
|
||||
if (libs.count() != 0) copyCpp(libs);
|
||||
if (libs.count() != 0){
|
||||
tempLog = tr("Copy c++ libs");
|
||||
emit logChanged(tempLog);
|
||||
copyCpp(libs);
|
||||
}
|
||||
tempLog = tr("Copy c++/qt libs");
|
||||
emit logChanged(tempLog);
|
||||
copyCpp(qtlibs);
|
||||
|
||||
tempLog = tr("Copy qml libs");
|
||||
emit logChanged(tempLog);
|
||||
copyQml(dirs);
|
||||
|
||||
tempLog = tr("Copy Plugins");
|
||||
emit logChanged(tempLog);
|
||||
copyPlugins(plugins);
|
||||
|
||||
tempLog = tr("Copy Execute files");
|
||||
emit logChanged(tempLog);
|
||||
copyExec();
|
||||
|
||||
createRunFile();
|
||||
|
||||
if(isInstallFW())
|
||||
createInstaller();
|
||||
|
||||
emit pathsToCopyChanged(m_pathsToCopy);
|
||||
emit copySuccessChanged(m_copySuccess);
|
||||
}
|
||||
|
||||
void OutputManager::copyQml(const QStringList &dirs)
|
||||
{
|
||||
auto qmldir = m_outputdir + "/qml";
|
||||
QString temp = "/qml";
|
||||
if(isInstallFW()){
|
||||
temp = "/packages/qml/data/qml";
|
||||
}
|
||||
|
||||
|
||||
auto qmldir = m_outputdir + temp;
|
||||
|
||||
for (const QString &S : dirs)
|
||||
{
|
||||
@ -81,10 +144,67 @@ void OutputManager::copyQml(const QStringList &dirs)
|
||||
}
|
||||
}
|
||||
|
||||
bool OutputManager::isInstallFW() const {
|
||||
return !m_binarycreator.isEmpty();
|
||||
}
|
||||
|
||||
void OutputManager::checkInstallFrameWork(){
|
||||
|
||||
tempLog = tr("check InstallFrameWork");
|
||||
emit logChanged(tempLog);
|
||||
|
||||
QDir dir(m_qtdir);
|
||||
if(!dir.cd("../../Tools/QtInstallerFramework")){
|
||||
m_binarycreator = QString();
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList list = dir.entryList();
|
||||
|
||||
int index_of_max = 0;
|
||||
double maxVersion = 0;
|
||||
for(int i = 0; i < list.size(); i++){
|
||||
if(list.at(i).toDouble() > maxVersion){
|
||||
index_of_max = i;
|
||||
maxVersion = list.at(i).toDouble();
|
||||
}
|
||||
}
|
||||
|
||||
if(!maxVersion || !index_of_max){
|
||||
m_binarycreator = QString();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!dir.cd(list[index_of_max])){
|
||||
m_binarycreator = QString();
|
||||
return;
|
||||
}
|
||||
|
||||
m_binarycreator = dir.absolutePath() + "/bin/binarycreator";
|
||||
|
||||
|
||||
if(!QFile::exists(m_binarycreator)){
|
||||
m_binarycreator = QString();
|
||||
tempLog = tr("InstallFrameWork not findet");
|
||||
emit logChanged(tempLog);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
tempLog = tr("InstallFrameWork findet in %0").arg(m_binarycreator);
|
||||
emit logChanged(tempLog);
|
||||
|
||||
}
|
||||
|
||||
void OutputManager::copyPlugins(const QStringList &plugins)
|
||||
{
|
||||
QString temp = "/plugins/";
|
||||
if(isInstallFW()){
|
||||
temp = "/packages/plugins/data/plugins/";
|
||||
}
|
||||
|
||||
QString qtpath = m_qtdir + "/plugins/";
|
||||
QString path = m_outputdir + "/plugins/";
|
||||
QString path = m_outputdir + temp;
|
||||
|
||||
for (const QString &plugin : plugins)
|
||||
{
|
||||
@ -95,26 +215,97 @@ void OutputManager::copyPlugins(const QStringList &plugins)
|
||||
|
||||
void OutputManager::copyExec()
|
||||
{
|
||||
auto path = m_outputdir + "/bin/" + QFileInfo(m_executablepath).fileName();
|
||||
QString temp = "/bin/";
|
||||
if(isInstallFW()){
|
||||
temp = "/packages/base/data/bin/";
|
||||
}
|
||||
|
||||
auto path = m_outputdir + temp + QFileInfo(m_executablepath).fileName();
|
||||
|
||||
m_pathsToCopy << path;
|
||||
m_copySuccess << copyFile(m_executablepath, path);
|
||||
}
|
||||
|
||||
bool OutputManager::createIcon(){
|
||||
QFile f(appIcon);
|
||||
QByteArray icon;
|
||||
|
||||
if(!f.open(QIODevice::ReadOnly)){
|
||||
return false;
|
||||
}
|
||||
icon = f.readAll();
|
||||
f.close();
|
||||
|
||||
QString name = QFileInfo(appIcon).fileName();
|
||||
f.setFileName(m_outputdir + "/packages/base/data/" + name);
|
||||
|
||||
if(!f.open(QIODevice::WriteOnly)){
|
||||
return false;
|
||||
}
|
||||
f.write(icon.data(), icon.size());
|
||||
|
||||
f.close();
|
||||
|
||||
f.setFileName(m_outputdir + "/config/" + name);
|
||||
if(!f.open(QIODevice::WriteOnly)){
|
||||
return false;
|
||||
}
|
||||
f.write(icon.data(), icon.size());
|
||||
|
||||
f.close();
|
||||
|
||||
appIcon = name;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OutputManager::createEntryScript(){
|
||||
QString temp = "";
|
||||
if(isInstallFW()){
|
||||
temp = "/packages/base/data";
|
||||
}
|
||||
|
||||
QFile f(":/install/InstallTemplate/CreateDesktopEntry.sh");
|
||||
f.open(QIODevice::ReadOnly);
|
||||
|
||||
QString content = f.readAll();
|
||||
|
||||
QString fname = m_outputdir + temp + QDir::separator() +
|
||||
"CreateDesktopEntry.sh";
|
||||
|
||||
QFile F(fname);
|
||||
m_pathsToCopy << fname;
|
||||
m_copySuccess << F.open(QIODevice::WriteOnly);
|
||||
|
||||
F.write(content.toUtf8());
|
||||
F.flush();
|
||||
F.close();
|
||||
|
||||
F.setPermissions(QFileDevice::ExeUser | QFileDevice::WriteUser |
|
||||
QFileDevice::ReadUser);
|
||||
}
|
||||
|
||||
void OutputManager::createRunFile()
|
||||
{
|
||||
QString content =
|
||||
"#!/bin/sh\n"
|
||||
"export LD_LIBRARY_PATH=`pwd`/lib\n"
|
||||
"export QML_IMPORT_PATH=`pwd`/qml\n"
|
||||
"export QML2_IMPORT_PATH=`pwd`/qml\n"
|
||||
"export QT_PLUGIN_PATH=`pwd`/plugins\n"
|
||||
"export QT_QPA_PLATFORM_PLUGIN_PATH=`pwd`/plugins/platforms\n"
|
||||
"./bin/%1";
|
||||
|
||||
QString temp = "";
|
||||
if(isInstallFW()){
|
||||
temp = "/packages/base/data";
|
||||
}
|
||||
|
||||
QString content =
|
||||
"#!/bin/sh\n"
|
||||
"BASEDIR=$(dirname $0)\n"
|
||||
"export LD_LIBRARY_PATH=\"$BASEDIR/lib\"\n"
|
||||
"export QML_IMPORT_PATH=\"$BASEDIR/qml\"\n"
|
||||
"export QML2_IMPORT_PATH=\"$BASEDIR/qml\"\n"
|
||||
"export QT_PLUGIN_PATH=\"$BASEDIR/plugins\"\n"
|
||||
"export QT_QPA_PLATFORM_PLUGIN_PATH=\"$BASEDIR/plugins/platforms\"\n"
|
||||
"$BASEDIR/bin/%1";
|
||||
|
||||
content = content.arg(QFileInfo(m_executablepath).completeBaseName());
|
||||
|
||||
QString fname = m_outputdir + QDir::separator() +
|
||||
QString fname = m_outputdir + temp + QDir::separator() +
|
||||
QFileInfo(m_executablepath).completeBaseName() + ".sh";
|
||||
|
||||
QFile F(fname);
|
||||
@ -127,21 +318,154 @@ void OutputManager::createRunFile()
|
||||
|
||||
F.setPermissions(QFileDevice::ExeUser | QFileDevice::WriteUser |
|
||||
QFileDevice::ReadUser);
|
||||
|
||||
}
|
||||
|
||||
bool OutputManager::createModule(const QString &from, const QString &to, const QStringList ¶ms){
|
||||
QFile tempFile;
|
||||
tempFile.setFileName(from);
|
||||
|
||||
if(!tempFile.open(QIODevice::ReadOnly)){
|
||||
return false;
|
||||
}
|
||||
|
||||
QString text = tempFile.readAll();
|
||||
tempFile.close();
|
||||
|
||||
for(QString i : params){
|
||||
text = text.arg(i);
|
||||
}
|
||||
|
||||
tempFile.setFileName(to);
|
||||
|
||||
if(!tempFile.open(QIODevice::ReadWrite) &&
|
||||
QDir().mkpath(QFileInfo(to).absolutePath()) &&
|
||||
!tempFile.open(QIODevice::ReadWrite)){
|
||||
return false;
|
||||
}
|
||||
|
||||
tempFile.write(text.toLatin1());
|
||||
tempFile.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OutputManager::createInstaller(){
|
||||
|
||||
tempLog = tr("create installer");
|
||||
emit logChanged(tempLog);
|
||||
|
||||
if(!createIcon()){
|
||||
tempLog = tr("create icon fail!");
|
||||
emit logChanged(tempLog);
|
||||
return;
|
||||
}
|
||||
|
||||
createModule(":/install/InstallTemplate/config.xml",
|
||||
m_outputdir + "/config/config.xml",
|
||||
QStringList() << projectName <<
|
||||
Utils::getVersion() <<
|
||||
Utils::getPublicher() <<
|
||||
"QtDeployer" <<
|
||||
QDate::currentDate().toString("yyyy-MM-dd") <<
|
||||
appIcon);
|
||||
|
||||
|
||||
createModule(":/install/InstallTemplate/controlScript.js",
|
||||
m_outputdir + "/config/controlScript.js",
|
||||
QStringList() << appIcon);
|
||||
|
||||
|
||||
createModule(":/install/InstallTemplate/package.xml",
|
||||
m_outputdir + "/packages/base/meta/package.xml",
|
||||
QStringList() << "base" <<
|
||||
"base data of " + projectName <<
|
||||
Utils::getVersion() <<
|
||||
QDate::currentDate().toString("yyyy-MM-dd") <<
|
||||
"true" <<
|
||||
"<Script>componentScript.js</Script>");
|
||||
|
||||
createModule(":/install/InstallTemplate/componentScript.js",
|
||||
m_outputdir + "/packages/base/meta/componentScript.js",
|
||||
QStringList() << appIcon);
|
||||
|
||||
|
||||
createModule(":/install/InstallTemplate/package.xml",
|
||||
m_outputdir + "/packages/qml/meta/package.xml",
|
||||
QStringList() << "qml" <<
|
||||
"qml data of " + projectName <<
|
||||
Utils::getVersion() <<
|
||||
QDate::currentDate().toString("yyyy-MM-dd") <<
|
||||
"true" <<
|
||||
"");
|
||||
|
||||
createModule(":/install/InstallTemplate/package.xml",
|
||||
m_outputdir + "/packages/lib/meta/package.xml",
|
||||
QStringList() << "lib" <<
|
||||
"lib data of " + projectName <<
|
||||
Utils::getVersion() <<
|
||||
QDate::currentDate().toString("yyyy-MM-dd") <<
|
||||
"true" <<
|
||||
"");
|
||||
|
||||
createModule(":/install/InstallTemplate/package.xml",
|
||||
m_outputdir + "/packages/plugins/meta/package.xml",
|
||||
QStringList() << "plugins" <<
|
||||
"plugins data of " + projectName <<
|
||||
Utils::getVersion() <<
|
||||
QDate::currentDate().toString("yyyy-MM-dd") <<
|
||||
"true" <<
|
||||
"");
|
||||
|
||||
installer_process.setProgram(m_binarycreator);
|
||||
/*
|
||||
-c $$PWD/config/config.xml -p $$PWD/packages ${QMAKE_FILE_OUT}*/
|
||||
installer_process.setArguments(QStringList() << "-c" <<
|
||||
m_outputdir + "/config/config.xml" <<
|
||||
"-p" <<
|
||||
m_outputdir + "/packages" <<
|
||||
m_outputdir + "/installer_" + projectName <<
|
||||
"-v");
|
||||
|
||||
installer_process.start();
|
||||
|
||||
}
|
||||
|
||||
void OutputManager::createDirectories()
|
||||
{
|
||||
m_pathsToCopy << m_outputdir + "/bin/";
|
||||
m_copySuccess << QDir(m_outputdir).mkdir("bin");
|
||||
|
||||
m_pathsToCopy << m_outputdir + "/qml/";
|
||||
m_copySuccess << QDir(m_outputdir).mkdir("qml");
|
||||
tempLog = tr("Create Directories");
|
||||
emit logChanged(tempLog);
|
||||
|
||||
m_pathsToCopy << m_outputdir + "/lib/";
|
||||
m_copySuccess << QDir(m_outputdir).mkdir("lib");
|
||||
if(isInstallFW()){
|
||||
m_pathsToCopy << m_outputdir + "/config";
|
||||
m_copySuccess << QDir(m_outputdir).mkpath("config");
|
||||
|
||||
m_pathsToCopy << m_outputdir + "/plugins/";
|
||||
m_copySuccess << QDir(m_outputdir).mkdir("plugins");
|
||||
m_pathsToCopy << m_outputdir + "/packages/base/data/bin";
|
||||
m_copySuccess << QDir(m_outputdir).mkpath("packages/base/data/bin");
|
||||
|
||||
m_pathsToCopy << m_outputdir + "/packages/qml/data/qml";
|
||||
m_copySuccess << QDir(m_outputdir).mkpath("packages/qml/data/qml");
|
||||
|
||||
m_pathsToCopy << m_outputdir + "/packages/lib/data/lib/";
|
||||
m_copySuccess << QDir(m_outputdir).mkpath("packages/lib/data/lib");
|
||||
|
||||
m_pathsToCopy << m_outputdir + "/packages/plugins/data/plugins";
|
||||
m_copySuccess << QDir(m_outputdir).mkpath("packages/plugins/data/plugins");
|
||||
|
||||
} else {
|
||||
m_pathsToCopy << m_outputdir + "/bin/";
|
||||
m_copySuccess << QDir(m_outputdir).mkdir("bin");
|
||||
|
||||
m_pathsToCopy << m_outputdir + "/qml/";
|
||||
m_copySuccess << QDir(m_outputdir).mkdir("qml");
|
||||
|
||||
m_pathsToCopy << m_outputdir + "/lib/";
|
||||
m_copySuccess << QDir(m_outputdir).mkdir("lib");
|
||||
|
||||
m_pathsToCopy << m_outputdir + "/plugins/";
|
||||
m_copySuccess << QDir(m_outputdir).mkdir("plugins");
|
||||
}
|
||||
}
|
||||
|
||||
bool OutputManager::copyFile(const QString &source, const QString &destin)
|
||||
@ -149,6 +473,5 @@ bool OutputManager::copyFile(const QString &source, const QString &destin)
|
||||
return QFile::copy(source, destin);
|
||||
}
|
||||
|
||||
OutputManager::OutputManager(QObject *parent) : BaseClass(parent) {}
|
||||
QStringList OutputManager::pathsToCopy() const { return m_pathsToCopy; }
|
||||
QList<bool> OutputManager::copySuccess() const { return m_copySuccess; }
|
||||
|
@ -13,8 +13,14 @@ class OutputManager : public BaseClass
|
||||
Q_PROPERTY(QList<bool> copySuccess READ copySuccess WRITE setCopySuccess
|
||||
NOTIFY copySuccessChanged)
|
||||
|
||||
Q_PROPERTY(QString log READ log NOTIFY logChanged)
|
||||
|
||||
|
||||
QStringList m_pathsToCopy;
|
||||
QList<bool> m_copySuccess;
|
||||
QProcess installer_process;
|
||||
QString tempLog;
|
||||
|
||||
|
||||
bool copyDir(const QString &source, const QString &destin);
|
||||
bool copyFile(const QString &source, const QString &destin);
|
||||
@ -23,10 +29,22 @@ class OutputManager : public BaseClass
|
||||
void copyQml(const QStringList &dirs);
|
||||
void copyPlugins(const QStringList &plugins);
|
||||
|
||||
bool isInstallFW() const;
|
||||
|
||||
void checkInstallFrameWork();
|
||||
|
||||
void createDirectories();
|
||||
void createRunFile();
|
||||
void createEntryScript();
|
||||
bool createIcon();
|
||||
void createInstaller();
|
||||
bool createModule(const QString& from, const QString& to, const QStringList& params);
|
||||
void copyExec();
|
||||
|
||||
private slots:
|
||||
void buildLog();
|
||||
void buildFunished(int, QProcess::ExitStatus exitStatus);
|
||||
|
||||
public:
|
||||
explicit OutputManager(QObject *parent = nullptr);
|
||||
|
||||
@ -40,10 +58,15 @@ public:
|
||||
public slots:
|
||||
void setPathsToCopy(const QStringList &pathsToCopy);
|
||||
void setCopySuccess(const QList<bool> ©Success);
|
||||
const QString& log() const;
|
||||
|
||||
signals:
|
||||
void pathsToCopyChanged(QStringList pathsToCopy);
|
||||
void copySuccessChanged(QList<bool> copySuccess);
|
||||
void finished();
|
||||
void logChanged(QString);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // OUTPUTMANAGER_H
|
||||
|
@ -33,3 +33,13 @@ QString Utils::getVersion(){
|
||||
|
||||
return file.errorString();
|
||||
}
|
||||
|
||||
/** @todo add get description method */
|
||||
QString Utils::getDescription(){
|
||||
return "";
|
||||
}
|
||||
|
||||
/** @todo add get Publicher method */
|
||||
QString Utils::getPublicher(){
|
||||
return "QtDeployer";
|
||||
}
|
||||
|
@ -8,7 +8,8 @@ private:
|
||||
Utils() = delete;
|
||||
public:
|
||||
static QString getVersion();
|
||||
|
||||
static QString getDescription();
|
||||
static QString getPublicher();
|
||||
};
|
||||
|
||||
#endif // UTILS_H
|
||||
|
30
source/InstallTemplate/CreateDesktopEntry.sh
Normal file
30
source/InstallTemplate/CreateDesktopEntry.sh
Normal file
@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
IS_INSTALL=$1
|
||||
TARGET_DIR= $2
|
||||
APP_NAME=$3
|
||||
VERSION=$4
|
||||
ICONS_DIR="~/.local/share/applications"
|
||||
DESKTOP_FILE="$ICONS_DIR/$APP_NAME.desktop"
|
||||
EXE="$TARGET_DIR/$APP_NAME.sh"
|
||||
ICON="$TARGET_DIR/$5"
|
||||
|
||||
if [ "$IS_INSTALL" == "install" ]; then
|
||||
|
||||
echo "Version=$VERSION\n">>$DESKTOP_FILE
|
||||
echo "Type=Application\n">>$DESKTOP_FILE
|
||||
echo "Terminal=false\n">>$DESKTOP_FILE
|
||||
echo "Exec=$EXE\n">>$DESKTOP_FILE
|
||||
echo "Name=$APP_NAME\n">>$DESKTOP_FILE
|
||||
echo "Icon=$ICON\n">>$DESKTOP_FILE
|
||||
echo "Name[en_US]=$APP_NAME\n">>$DESKTOP_FILE
|
||||
|
||||
else
|
||||
|
||||
rm -drf $DESKTOP_FILE
|
||||
|
||||
fi
|
||||
|
||||
echo "All done!"
|
||||
|
||||
|
2
source/InstallTemplate/README
Normal file
2
source/InstallTemplate/README
Normal file
@ -0,0 +1,2 @@
|
||||
# installer of qt Deployer
|
||||
this is install scripts of qt install framework
|
54
source/InstallTemplate/componentScript.js
Normal file
54
source/InstallTemplate/componentScript.js
Normal file
@ -0,0 +1,54 @@
|
||||
function Component()
|
||||
{
|
||||
// default constructor
|
||||
}
|
||||
|
||||
Component.prototype.createOperations = function()
|
||||
{
|
||||
// call default implementation to actually install README.txt!
|
||||
component.createOperations();
|
||||
|
||||
if (!component.isUninstalled()) {
|
||||
console.log("remove icons!!!");
|
||||
|
||||
if (systemInfo.kernelType === "winnt") {
|
||||
console.log("create icons!!! on Windows");
|
||||
component.addOperation("Delete",
|
||||
"@DesktopDir@/@Name@.lnk");
|
||||
}
|
||||
|
||||
console.log("remove icons!!!");
|
||||
|
||||
if (systemInfo.kernelType === "linux") {
|
||||
|
||||
console.log("create icons!!! on LINUX");
|
||||
component.addOperation("Delete",
|
||||
"@HomeDir@/.local/share/applications/@Name@.desktop");
|
||||
component.addOperation("Delete",
|
||||
"@HomeDir@/Desktop/@Name@.desktop");
|
||||
|
||||
console.log("remove icons!!! on LINUX done");
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log("create icons!!!");
|
||||
|
||||
if (systemInfo.kernelType === "winnt") {
|
||||
console.log("create icons!!! on Windows");
|
||||
component.addOperation("CreateShortcut",
|
||||
"@TargetDir@/@Name@.exe",
|
||||
"@DesktopDir@/@Name@.lnk");
|
||||
}
|
||||
|
||||
console.log("create icons!!!");
|
||||
|
||||
if (systemInfo.kernelType === "linux") {
|
||||
console.log("create icons!!! on LINUX");
|
||||
component.addOperation("CreateDesktopEntry",
|
||||
"@HomeDir@/.local/share/applications/@Name@.desktop",
|
||||
"Version=@Version@\nType=Application\nTerminal=false\nExec=@TargetDir@/@Name@.sh\nName=@Name@\nIcon=@TargetDir@/%0\nName[en_US]=@Name@");
|
||||
|
||||
console.log("create icons!!! on LINUX done");
|
||||
}
|
||||
}
|
||||
}
|
14
source/InstallTemplate/config.xml
Normal file
14
source/InstallTemplate/config.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Installer>
|
||||
<Name>%0</Name>
|
||||
<Version>%1</Version>
|
||||
<Title>%2</Title>
|
||||
<Publisher>%3</Publisher>
|
||||
<StartMenuDir>%4</StartMenuDir>
|
||||
<TargetDir>@HomeDir@/%0</TargetDir>
|
||||
<AllowNonAsciiCharacters>true</AllowNonAsciiCharacters>
|
||||
<MaintenanceToolName>%0Uninstall</MaintenanceToolName>
|
||||
<RemoveTargetDir>true</RemoveTargetDir>
|
||||
<ControlScript>controlScript.js</ControlScript>
|
||||
<Logo>%5</Logo>
|
||||
</Installer>
|
42
source/InstallTemplate/controlScript.js
Normal file
42
source/InstallTemplate/controlScript.js
Normal file
@ -0,0 +1,42 @@
|
||||
function Controller()
|
||||
{
|
||||
installer.uninstallationFinished.connect(this, Controller.prototype.uninstallationFinished);
|
||||
installer.installationFinished.connect(this, Controller.prototype.installationFinished);
|
||||
}
|
||||
|
||||
Controller.prototype.installationFinished = function()
|
||||
{
|
||||
|
||||
if (systemInfo.kernelType === "winnt") {
|
||||
component.addOperation("CreateShortcut",
|
||||
"@TargetDir@/@Name@.exe",
|
||||
"@DesktopDir@/@Name@.lnk");
|
||||
}
|
||||
|
||||
console.log("create icons!!!");
|
||||
|
||||
if (systemInfo.kernelType === "linux") {
|
||||
|
||||
console.log("create icons!!! on LINUX");
|
||||
|
||||
installer.performOperation("CreateDesktopEntry",
|
||||
"@HomeDir@/.local/share/applications/@Name@.desktop",
|
||||
"Version=@Version@\nType=Application\nTerminal=false\nExec=@TargetDir@/@Name@.sh\nName=@Name@\nIcon=@TargetDir@/bin/%0\nName[en_US]=YourApp_name");
|
||||
|
||||
// installer.addElevatedOperation("Copy",
|
||||
// "@HomeDir@/.local/share/applications/@Name@.desktop",
|
||||
// "@HomeDir@/Desktop/@Name@.desktop");
|
||||
|
||||
console.log("create icons!!! on LINUX done");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Controller.prototype.uninstallationFinished = function()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
10
source/InstallTemplate/package.xml
Normal file
10
source/InstallTemplate/package.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<Package>
|
||||
<DisplayName>%0</DisplayName>
|
||||
<Description>%1</Description>
|
||||
<Version>%2</Version>
|
||||
<ReleaseDate>%3</ReleaseDate>
|
||||
<SortingPriority>200</SortingPriority>
|
||||
<Default>%4</Default>
|
||||
%5
|
||||
</Package>
|
@ -92,9 +92,10 @@ Page {
|
||||
Layout.alignment: Qt.AlignRight
|
||||
|
||||
onClicked: {
|
||||
pp.erase = erase.checked
|
||||
swipeview.currentIndex = 3
|
||||
CppManager.cppLibraries = cpplibs
|
||||
MainManager.start(erase.checked)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,25 +7,53 @@ Page {
|
||||
id: page
|
||||
clip: true
|
||||
|
||||
property bool erase
|
||||
property int state: MainManager.state
|
||||
|
||||
header: Header {
|
||||
message: qsTr("Qt Deployer")
|
||||
}
|
||||
|
||||
Button {
|
||||
width: 200
|
||||
padding: 18
|
||||
anchors.centerIn: parent
|
||||
Material.background: buttonColor
|
||||
text: page.state == 0 ? "Go!":(page.state == 1 ? qsTr("Wait!"):qsTr("Done!"))
|
||||
property string outdir
|
||||
property var cpplibs: []
|
||||
|
||||
onClicked: {
|
||||
if (page.state == 0)
|
||||
MainManager.start(erase)
|
||||
else if (page.state == 2)
|
||||
swipeview.currentIndex = 4
|
||||
}
|
||||
}
|
||||
Flickable {
|
||||
id: flick
|
||||
|
||||
Connections {
|
||||
target: OutputManager
|
||||
onLogChanged:{
|
||||
log.append(OutputManager.log)
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: OutputManager
|
||||
onFinished:{
|
||||
swipeview.currentIndex = 4
|
||||
}
|
||||
}
|
||||
|
||||
anchors.fill: parent
|
||||
contentWidth: log.paintedWidth
|
||||
contentHeight: log.paintedHeight
|
||||
clip: true
|
||||
|
||||
function ensureVisible(r)
|
||||
{
|
||||
if (contentX >= r.x)
|
||||
contentX = r.x;
|
||||
else if (contentX+width <= r.x+r.width)
|
||||
contentX = r.x+r.width-width;
|
||||
if (contentY >= r.y)
|
||||
contentY = r.y;
|
||||
else if (contentY+height <= r.y+r.height)
|
||||
contentY = r.y+r.height-height;
|
||||
}
|
||||
|
||||
TextEdit {
|
||||
id: log
|
||||
width: flick.width
|
||||
focus: true
|
||||
wrapMode: TextEdit.Wrap
|
||||
onCursorRectangleChanged: flick.ensureVisible(cursorRectangle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ Page {
|
||||
PathChooser {
|
||||
id: qtdir
|
||||
title: qsTr("Qt Build Directory")
|
||||
content: MainManager.qtDir();
|
||||
}
|
||||
|
||||
PathChooser {
|
||||
@ -28,6 +29,12 @@ Page {
|
||||
title: qsTr("Project Directory")
|
||||
}
|
||||
|
||||
PathChooser {
|
||||
id: icon
|
||||
title: qsTr("Project icon")
|
||||
isdir: false
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
@ -40,7 +47,7 @@ Page {
|
||||
enabled: qtdir.confirmed && projectdir.confirmed
|
||||
|
||||
onClicked: {
|
||||
MainManager.prepare(qtdir.content, projectdir.content)
|
||||
MainManager.prepare(qtdir.content, projectdir.content, icon.content)
|
||||
|
||||
prp.outdir = MainManager.outDir
|
||||
swipeview.currentIndex = 1
|
||||
|
@ -40,7 +40,7 @@ bool initLocale(const QString &locale, QGuiApplication& app, QTranslator &transl
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QGuiApplication *app;;
|
||||
QGuiApplication *app;
|
||||
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
|
||||
@ -50,6 +50,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
#endif
|
||||
|
||||
QCoreApplication::setOrganizationName("QuasarApp");
|
||||
QCoreApplication::setOrganizationDomain("https://quasarapp.github.io/QtDeployer/");
|
||||
QCoreApplication::setApplicationName("Qt-Deployer");
|
||||
|
||||
app->setWindowIcon(QIcon("://icon"));
|
||||
|
||||
|
@ -22,4 +22,13 @@
|
||||
<qresource prefix="/snapcraft">
|
||||
<file alias="snapcraft">../snap/snapcraft.yaml</file>
|
||||
</qresource>
|
||||
<qresource prefix="/install">
|
||||
<file>InstallTemplate/config.xml</file>
|
||||
<file>InstallTemplate/controlScript.js</file>
|
||||
<file>InstallTemplate/package.xml</file>
|
||||
<file>InstallTemplate/README</file>
|
||||
<file>InstallTemplate/CreateDesktopEntry.sh</file>
|
||||
<file>res/iconInstaller.png</file>
|
||||
<file>InstallTemplate/componentScript.js</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
BIN
source/res/iconInstaller.png
Normal file
BIN
source/res/iconInstaller.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
Loading…
x
Reference in New Issue
Block a user