mirror of
https://github.com/QuasarApp/QtDeployer.git
synced 2025-04-27 14:04:31 +00:00
fix
This commit is contained in:
parent
8b2cf4c39b
commit
bf4920afa1
@ -1,4 +1,5 @@
|
||||
#include "baseclass.h"
|
||||
#include <QRegularExpression>
|
||||
|
||||
QString BaseClass::m_qtdir = QString();
|
||||
QString BaseClass::m_outputdir = QString();
|
||||
@ -18,4 +19,18 @@ QStringList BaseClass::findFilesInsideDir(const QString &name, const QString &di
|
||||
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) {}
|
||||
|
@ -22,6 +22,8 @@ protected:
|
||||
|
||||
QStringList findFilesInsideDir(const QString &name, const QString &dirpath);
|
||||
|
||||
bool getName(QString &name, const QString &url) const;
|
||||
|
||||
public:
|
||||
explicit BaseClass(QObject *parent = nullptr);
|
||||
};
|
||||
|
@ -32,7 +32,7 @@ void CppManager::extractAllLibs(const QStringList &execfiles)
|
||||
{
|
||||
for (const QString &execfile : execfiles)
|
||||
for (const QString &lib : extractLibsFromExecutable(execfile))
|
||||
if (!m_cppLibraries.contains(lib))
|
||||
if (!m_cppLibraries.contains(lib))
|
||||
{
|
||||
m_cppLibraries << lib;
|
||||
extractAllLibs(QStringList(lib));
|
||||
@ -73,10 +73,7 @@ void CppManager::divideLibraries()
|
||||
{
|
||||
QString name;
|
||||
|
||||
QFileInfo libInfo(lib);
|
||||
name = libInfo.fileName();
|
||||
|
||||
if (!name.isEmpty() && isQtLib(libInfo.path()))
|
||||
if (getName(name, lib) && !name.isEmpty() && isQtLib(lib))
|
||||
{
|
||||
m_qtLibraries << name;
|
||||
m_cppLibraries.removeOne(lib);
|
||||
@ -95,9 +92,9 @@ void CppManager::start(const QStringList &executables)
|
||||
|
||||
m_notFoundLibs.removeDuplicates();
|
||||
|
||||
emit qtLibrariesChanged(m_qtLibraries);
|
||||
emit cppLibrariesChanged(m_cppLibraries);
|
||||
emit notFoundLibsChanged(m_notFoundLibs);
|
||||
emit qtLibrariesChanged(m_qtLibraries);
|
||||
emit cppLibrariesChanged(m_cppLibraries);
|
||||
emit notFoundLibsChanged(m_notFoundLibs);
|
||||
}
|
||||
|
||||
QStringList CppManager::getQtLibrariesFullPaths()
|
||||
|
@ -10,7 +10,7 @@ QStringList MainManager::getAllExecutables()
|
||||
}
|
||||
|
||||
MainManager::MainManager(CppManager *cpp, QmlManager *qml, OutputManager *out,
|
||||
PluginManager *plg, SnapManager *snp, QObject *parent)
|
||||
PluginManager *plg, QObject *parent)
|
||||
: BaseClass(parent)
|
||||
{
|
||||
setState(0);
|
||||
@ -19,7 +19,6 @@ MainManager::MainManager(CppManager *cpp, QmlManager *qml, OutputManager *out,
|
||||
m_qml = qml;
|
||||
m_out = out;
|
||||
m_plg = plg;
|
||||
m_snp = snp;
|
||||
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "outputmanager.h"
|
||||
#include "pluginmanager.h"
|
||||
#include "qmlmanager.h"
|
||||
#include "snapmanager.h"
|
||||
|
||||
class MainManager : public BaseClass
|
||||
{
|
||||
@ -18,7 +17,6 @@ class MainManager : public BaseClass
|
||||
QmlManager *m_qml;
|
||||
PluginManager *m_plg;
|
||||
OutputManager *m_out;
|
||||
SnapManager *m_snp;
|
||||
|
||||
int m_state;
|
||||
|
||||
@ -26,7 +24,7 @@ class MainManager : public BaseClass
|
||||
|
||||
public:
|
||||
explicit MainManager(CppManager *cpp, QmlManager *qml, OutputManager *out,
|
||||
PluginManager *plg, SnapManager *snp, QObject *parent = nullptr);
|
||||
PluginManager *plg, QObject *parent = nullptr);
|
||||
|
||||
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
|
||||
|
||||
Repeater {
|
||||
model: CppManager.cppLibraries
|
||||
model: CppManager.cppLibraries
|
||||
|
||||
delegate: CheckDelegate {
|
||||
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 {
|
||||
id: listview
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: createSnap.bottom
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.fill: parent
|
||||
ScrollBar.vertical: ScrollBar {}
|
||||
|
||||
model: VisualItemModel {
|
||||
|
@ -36,8 +36,7 @@ SOURCES += \
|
||||
CPP/mainmanager.cpp \
|
||||
CPP/outputmanager.cpp \
|
||||
CPP/pluginmanager.cpp \
|
||||
CPP/qmlmanager.cpp \
|
||||
CPP/snapmanager.cpp
|
||||
CPP/qmlmanager.cpp
|
||||
|
||||
HEADERS += \
|
||||
CPP/baseclass.h \
|
||||
@ -45,9 +44,7 @@ HEADERS += \
|
||||
CPP/mainmanager.h \
|
||||
CPP/outputmanager.h \
|
||||
CPP/pluginmanager.h \
|
||||
CPP/qmlmanager.h \
|
||||
CPP/snapmanager.h
|
||||
|
||||
CPP/qmlmanager.h
|
||||
|
||||
VERSION = 1.0.0.0
|
||||
TEMPLATE = app
|
||||
|
@ -7,33 +7,30 @@
|
||||
#include "CPP/outputmanager.h"
|
||||
#include "CPP/pluginmanager.h"
|
||||
#include "CPP/qmlmanager.h"
|
||||
#include "CPP/snapmanager.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QGuiApplication app(argc, argv);
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
CppManager C;
|
||||
QmlManager Q;
|
||||
PluginManager P;
|
||||
OutputManager O;
|
||||
SnapManager S;
|
||||
CppManager C;
|
||||
QmlManager Q;
|
||||
PluginManager P;
|
||||
OutputManager O;
|
||||
|
||||
MainManager M(&C, &Q, &O, &P, &S);
|
||||
MainManager M(&C, &Q, &O, &P);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
QQmlApplicationEngine engine;
|
||||
|
||||
auto *R = engine.rootContext();
|
||||
R->setContextProperty("CppManager", &C);
|
||||
R->setContextProperty("QmlManager", &Q);
|
||||
R->setContextProperty("PluginManager", &P);
|
||||
R->setContextProperty("MainManager", &M);
|
||||
R->setContextProperty("OutputManager", &O);
|
||||
R->setContextProperty("SnapManager", &S);
|
||||
auto *R = engine.rootContext();
|
||||
R->setContextProperty("CppManager", &C);
|
||||
R->setContextProperty("QmlManager", &Q);
|
||||
R->setContextProperty("PluginManager", &P);
|
||||
R->setContextProperty("MainManager", &M);
|
||||
R->setContextProperty("OutputManager", &O);
|
||||
|
||||
|
||||
engine.load(QUrl(QLatin1String("qrc:/QML/main.qml")));
|
||||
if (engine.rootObjects().isEmpty()) return -1;
|
||||
engine.load(QUrl(QLatin1String("qrc:/QML/main.qml")));
|
||||
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:
|
||||
plugin: dump
|
||||
source: .
|
||||
stage-package:
|
||||
- libc6
|
||||
|
Loading…
x
Reference in New Issue
Block a user