mirror of
https://github.com/QuasarApp/QtDeployer.git
synced 2025-04-28 22:44:32 +00:00
fix
This commit is contained in:
parent
8b2cf4c39b
commit
bf4920afa1
@ -1,4 +1,5 @@
|
|||||||
#include "baseclass.h"
|
#include "baseclass.h"
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
QString BaseClass::m_qtdir = QString();
|
QString BaseClass::m_qtdir = QString();
|
||||||
QString BaseClass::m_outputdir = QString();
|
QString BaseClass::m_outputdir = QString();
|
||||||
@ -18,4 +19,18 @@ QStringList BaseClass::findFilesInsideDir(const QString &name, const QString &di
|
|||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BaseClass::getName(QString &name, const QString &url) const{
|
||||||
|
|
||||||
|
int index = url.lastIndexOf(QRegularExpression("[\\\/]"));
|
||||||
|
|
||||||
|
if(index < 0 || url.isEmpty()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
index = url.length() - index - 1;
|
||||||
|
|
||||||
|
name = url.right(index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
BaseClass::BaseClass(QObject *parent) : QObject(parent) {}
|
BaseClass::BaseClass(QObject *parent) : QObject(parent) {}
|
||||||
|
@ -22,6 +22,8 @@ protected:
|
|||||||
|
|
||||||
QStringList findFilesInsideDir(const QString &name, const QString &dirpath);
|
QStringList findFilesInsideDir(const QString &name, const QString &dirpath);
|
||||||
|
|
||||||
|
bool getName(QString &name, const QString &url) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BaseClass(QObject *parent = nullptr);
|
explicit BaseClass(QObject *parent = nullptr);
|
||||||
};
|
};
|
||||||
|
@ -32,7 +32,7 @@ void CppManager::extractAllLibs(const QStringList &execfiles)
|
|||||||
{
|
{
|
||||||
for (const QString &execfile : execfiles)
|
for (const QString &execfile : execfiles)
|
||||||
for (const QString &lib : extractLibsFromExecutable(execfile))
|
for (const QString &lib : extractLibsFromExecutable(execfile))
|
||||||
if (!m_cppLibraries.contains(lib))
|
if (!m_cppLibraries.contains(lib))
|
||||||
{
|
{
|
||||||
m_cppLibraries << lib;
|
m_cppLibraries << lib;
|
||||||
extractAllLibs(QStringList(lib));
|
extractAllLibs(QStringList(lib));
|
||||||
@ -73,10 +73,7 @@ void CppManager::divideLibraries()
|
|||||||
{
|
{
|
||||||
QString name;
|
QString name;
|
||||||
|
|
||||||
QFileInfo libInfo(lib);
|
if (getName(name, lib) && !name.isEmpty() && isQtLib(lib))
|
||||||
name = libInfo.fileName();
|
|
||||||
|
|
||||||
if (!name.isEmpty() && isQtLib(libInfo.path()))
|
|
||||||
{
|
{
|
||||||
m_qtLibraries << name;
|
m_qtLibraries << name;
|
||||||
m_cppLibraries.removeOne(lib);
|
m_cppLibraries.removeOne(lib);
|
||||||
@ -95,9 +92,9 @@ void CppManager::start(const QStringList &executables)
|
|||||||
|
|
||||||
m_notFoundLibs.removeDuplicates();
|
m_notFoundLibs.removeDuplicates();
|
||||||
|
|
||||||
emit qtLibrariesChanged(m_qtLibraries);
|
emit qtLibrariesChanged(m_qtLibraries);
|
||||||
emit cppLibrariesChanged(m_cppLibraries);
|
emit cppLibrariesChanged(m_cppLibraries);
|
||||||
emit notFoundLibsChanged(m_notFoundLibs);
|
emit notFoundLibsChanged(m_notFoundLibs);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CppManager::getQtLibrariesFullPaths()
|
QStringList CppManager::getQtLibrariesFullPaths()
|
||||||
|
@ -10,7 +10,7 @@ QStringList MainManager::getAllExecutables()
|
|||||||
}
|
}
|
||||||
|
|
||||||
MainManager::MainManager(CppManager *cpp, QmlManager *qml, OutputManager *out,
|
MainManager::MainManager(CppManager *cpp, QmlManager *qml, OutputManager *out,
|
||||||
PluginManager *plg, SnapManager *snp, QObject *parent)
|
PluginManager *plg, QObject *parent)
|
||||||
: BaseClass(parent)
|
: BaseClass(parent)
|
||||||
{
|
{
|
||||||
setState(0);
|
setState(0);
|
||||||
@ -19,7 +19,6 @@ MainManager::MainManager(CppManager *cpp, QmlManager *qml, OutputManager *out,
|
|||||||
m_qml = qml;
|
m_qml = qml;
|
||||||
m_out = out;
|
m_out = out;
|
||||||
m_plg = plg;
|
m_plg = plg;
|
||||||
m_snp = snp;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include "outputmanager.h"
|
#include "outputmanager.h"
|
||||||
#include "pluginmanager.h"
|
#include "pluginmanager.h"
|
||||||
#include "qmlmanager.h"
|
#include "qmlmanager.h"
|
||||||
#include "snapmanager.h"
|
|
||||||
|
|
||||||
class MainManager : public BaseClass
|
class MainManager : public BaseClass
|
||||||
{
|
{
|
||||||
@ -18,7 +17,6 @@ class MainManager : public BaseClass
|
|||||||
QmlManager *m_qml;
|
QmlManager *m_qml;
|
||||||
PluginManager *m_plg;
|
PluginManager *m_plg;
|
||||||
OutputManager *m_out;
|
OutputManager *m_out;
|
||||||
SnapManager *m_snp;
|
|
||||||
|
|
||||||
int m_state;
|
int m_state;
|
||||||
|
|
||||||
@ -26,7 +24,7 @@ class MainManager : public BaseClass
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainManager(CppManager *cpp, QmlManager *qml, OutputManager *out,
|
explicit MainManager(CppManager *cpp, QmlManager *qml, OutputManager *out,
|
||||||
PluginManager *plg, SnapManager *snp, QObject *parent = nullptr);
|
PluginManager *plg, QObject *parent = nullptr);
|
||||||
|
|
||||||
int state() const;
|
int state() const;
|
||||||
|
|
||||||
|
@ -1,76 +0,0 @@
|
|||||||
#include "snapmanager.h"
|
|
||||||
|
|
||||||
bool SnapManager::checkSnapDirs()const{
|
|
||||||
QDir dir(m_projectdir);
|
|
||||||
|
|
||||||
if(!dir.cd("snap")){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(dir.entryList(QStringList() << "*.desktop" << "snapcraft.yaml").length() < 2){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool copyRecursively(const QString &srcFilePath,
|
|
||||||
const QString &tgtFilePath)
|
|
||||||
{
|
|
||||||
QFileInfo srcFileInfo(srcFilePath);
|
|
||||||
if (srcFileInfo.isDir()) {
|
|
||||||
|
|
||||||
QDir targetDir(tgtFilePath);
|
|
||||||
targetDir.cdUp();
|
|
||||||
|
|
||||||
if (!targetDir.mkdir(QFileInfo(tgtFilePath).fileName()))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
QDir sourceDir(srcFilePath);
|
|
||||||
QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
|
|
||||||
|
|
||||||
foreach (const QString &fileName, fileNames) {
|
|
||||||
const QString newSrcFilePath
|
|
||||||
= srcFilePath + QLatin1Char('/') + fileName;
|
|
||||||
|
|
||||||
const QString newTgtFilePath
|
|
||||||
= tgtFilePath + QLatin1Char('/') + fileName;
|
|
||||||
|
|
||||||
if (!copyRecursively(newSrcFilePath, newTgtFilePath))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (!QFile::copy(srcFilePath, tgtFilePath))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SnapManager::copySnap()const {
|
|
||||||
return copyRecursively(m_projectdir + "/snap", m_outputdir);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SnapManager::start()
|
|
||||||
{
|
|
||||||
if(!copySnap()){
|
|
||||||
emit fail(tr("copy snapcraft error!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!checkSnapDirs()){
|
|
||||||
emit fail(tr("create a snapcraft.yaml and desktop file!"));
|
|
||||||
} else {
|
|
||||||
QProcess P;
|
|
||||||
P.setArguments(QStringList() << "snapcraft");
|
|
||||||
P.start("gnome-terminal", QProcess::ReadOnly);
|
|
||||||
|
|
||||||
if (!P.waitForStarted() || !P.waitForFinished()){
|
|
||||||
emit fail(tr("gnome-terminal not found, if you need a create snap package."
|
|
||||||
"you need call \'snapcraft\' in final build directory"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SnapManager::SnapManager(QObject *parent) : BaseClass(parent) {}
|
|
@ -1,26 +0,0 @@
|
|||||||
#ifndef SNAPMANAGER_H
|
|
||||||
#define SNAPMANAGER_H
|
|
||||||
|
|
||||||
#include "baseclass.h"
|
|
||||||
|
|
||||||
class SnapManager : public BaseClass
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
bool checkSnapDirs()const;
|
|
||||||
|
|
||||||
bool copySnap()const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit SnapManager(QObject *parent = nullptr);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void start();
|
|
||||||
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void done(QString snap);
|
|
||||||
void fail(QString error);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CPPMANAGER_H
|
|
@ -58,7 +58,7 @@ Page {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: CppManager.cppLibraries
|
model: CppManager.cppLibraries
|
||||||
|
|
||||||
delegate: CheckDelegate {
|
delegate: CheckDelegate {
|
||||||
id: del
|
id: del
|
||||||
|
@ -19,23 +19,9 @@ Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
|
||||||
id: createSnap
|
|
||||||
text: "Create a snap package"
|
|
||||||
Material.background: buttonColor
|
|
||||||
Layout.alignment: Qt.AlignRight
|
|
||||||
anchors.top: parent.top;
|
|
||||||
onClicked: {
|
|
||||||
SnapManager.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: listview
|
id: listview
|
||||||
anchors.left: parent.left
|
anchors.fill: parent
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.top: createSnap.bottom
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
ScrollBar.vertical: ScrollBar {}
|
ScrollBar.vertical: ScrollBar {}
|
||||||
|
|
||||||
model: VisualItemModel {
|
model: VisualItemModel {
|
||||||
|
@ -36,8 +36,7 @@ SOURCES += \
|
|||||||
CPP/mainmanager.cpp \
|
CPP/mainmanager.cpp \
|
||||||
CPP/outputmanager.cpp \
|
CPP/outputmanager.cpp \
|
||||||
CPP/pluginmanager.cpp \
|
CPP/pluginmanager.cpp \
|
||||||
CPP/qmlmanager.cpp \
|
CPP/qmlmanager.cpp
|
||||||
CPP/snapmanager.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
CPP/baseclass.h \
|
CPP/baseclass.h \
|
||||||
@ -45,9 +44,7 @@ HEADERS += \
|
|||||||
CPP/mainmanager.h \
|
CPP/mainmanager.h \
|
||||||
CPP/outputmanager.h \
|
CPP/outputmanager.h \
|
||||||
CPP/pluginmanager.h \
|
CPP/pluginmanager.h \
|
||||||
CPP/qmlmanager.h \
|
CPP/qmlmanager.h
|
||||||
CPP/snapmanager.h
|
|
||||||
|
|
||||||
|
|
||||||
VERSION = 1.0.0.0
|
VERSION = 1.0.0.0
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
|
@ -7,33 +7,30 @@
|
|||||||
#include "CPP/outputmanager.h"
|
#include "CPP/outputmanager.h"
|
||||||
#include "CPP/pluginmanager.h"
|
#include "CPP/pluginmanager.h"
|
||||||
#include "CPP/qmlmanager.h"
|
#include "CPP/qmlmanager.h"
|
||||||
#include "CPP/snapmanager.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QGuiApplication app(argc, argv);
|
QGuiApplication app(argc, argv);
|
||||||
|
|
||||||
CppManager C;
|
CppManager C;
|
||||||
QmlManager Q;
|
QmlManager Q;
|
||||||
PluginManager P;
|
PluginManager P;
|
||||||
OutputManager O;
|
OutputManager O;
|
||||||
SnapManager S;
|
|
||||||
|
|
||||||
MainManager M(&C, &Q, &O, &P, &S);
|
MainManager M(&C, &Q, &O, &P);
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
|
|
||||||
auto *R = engine.rootContext();
|
auto *R = engine.rootContext();
|
||||||
R->setContextProperty("CppManager", &C);
|
R->setContextProperty("CppManager", &C);
|
||||||
R->setContextProperty("QmlManager", &Q);
|
R->setContextProperty("QmlManager", &Q);
|
||||||
R->setContextProperty("PluginManager", &P);
|
R->setContextProperty("PluginManager", &P);
|
||||||
R->setContextProperty("MainManager", &M);
|
R->setContextProperty("MainManager", &M);
|
||||||
R->setContextProperty("OutputManager", &O);
|
R->setContextProperty("OutputManager", &O);
|
||||||
R->setContextProperty("SnapManager", &S);
|
|
||||||
|
|
||||||
|
|
||||||
engine.load(QUrl(QLatin1String("qrc:/QML/main.qml")));
|
engine.load(QUrl(QLatin1String("qrc:/QML/main.qml")));
|
||||||
if (engine.rootObjects().isEmpty()) return -1;
|
if (engine.rootObjects().isEmpty()) return -1;
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
15
source/snap/gui/QtDeployer.desktop
Executable file
15
source/snap/gui/QtDeployer.desktop
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Version=1.0
|
||||||
|
Name=Qt Deployer
|
||||||
|
Comment=Deploy Qt projects.
|
||||||
|
Exec=qt-deployer
|
||||||
|
Icon=/snap/qt-deployer/current/meta/gui/icon.png
|
||||||
|
Terminal=false
|
||||||
|
Type=Application
|
||||||
|
Categories=utils;Application;
|
||||||
|
X-GNOME-Bugzilla-Bugzilla=GNOME
|
||||||
|
X-GNOME-Bugzilla-Product=qt-deployer
|
||||||
|
X-GNOME-Bugzilla-Component=General
|
||||||
|
X-GNOME-Bugzilla-Version=1.0
|
||||||
|
StartupNotify=true
|
||||||
|
Name[ru_RU]=QtDeployer
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
@ -25,4 +25,6 @@ parts:
|
|||||||
qt-deployer:
|
qt-deployer:
|
||||||
plugin: dump
|
plugin: dump
|
||||||
source: .
|
source: .
|
||||||
|
stage-package:
|
||||||
|
- libc6
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user