Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 72 additions & 2 deletions Qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ LICENSE: MIT
**********************************************************/
import QtQuick 2.0
import QtQuick.Window 2.2
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.0
import Qt.labs.platform 1.0
import VersionMode 1.0

import "./Common"
Expand All @@ -20,7 +23,7 @@ Window {
| Qt.CustomizeWindowHint | Qt.WindowSystemMenuHint
| Qt.WindowMinimizeButtonHint | Qt.WindowStaysOnTopHint
width: 640
height: 480
height: 560
title: qsTr("Qt程序打包工具v1.0.1")

DropArea {
Expand Down Expand Up @@ -63,7 +66,7 @@ Window {
Column {
anchors.verticalCenter: parent.verticalCenter
width: parent.width
spacing: 15
spacing: 10

ContentBar {
z: 2
Expand All @@ -89,6 +92,73 @@ Window {
}
}

ContentBar {
z: 1
width: parent.width
height: 40
text: "选择构建方式"

MyComboBox {
model: versionMode.buildTypeList
onCurrentTextChanged: versionMode.buildType = currentText
}
}

ContentBar {
width: parent.width
height: 40
text: "选择Qt类型"

Row {
height: 40
RadioButton {
id: widgetButton
checked: true
text: "widget"
width: 90
onCheckedChanged: {
if(checked) {
versionMode.qmlDir = ""
}
}
}

RadioButton {
id: qmlButton
text: "qml"
width: 70
}

TextField {
width: parent.width - qmlButton.width - widgetButton.width - qmlFileDialogButton.width
height: 40
visible: qmlButton.checked
text: qmlFolderDialog.folder
placeholderText: "qml 文件路径"
selectByMouse: true
onTextChanged: {
versionMode.qmlDir = text
}
}

MyButton {
visible: qmlButton.checked
id: qmlFileDialogButton
text: "..."
height: 40
width: 30
onClicked: {
qmlFolderDialog.open()
}
}

FolderDialog {
id: qmlFolderDialog
}
}

}

Item {
width: parent.width
height: 240
Expand Down
47 changes: 45 additions & 2 deletions VersionModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ bool VersionModel::create()
qDebug()<<"[Info] "<<"Exe File: "<<m_exeFile;
qDebug()<<"[Info] "<<"Qt Version: "<<m_qtVersion;
qDebug()<<"[Info] "<<"Compiler Version: "<<m_compilerVersion;
qDebug()<<"[Info] "<<"Build Type: "<< m_buildType;

QDir dir(PROGRAMS_PATH + m_qtVersion + "/" + m_qtVersionDirName + "/" + m_compilerVersion);
QStringList dirs = dir.entryList(QDir::Files);
Expand All @@ -58,11 +59,19 @@ bool VersionModel::create()
QDir qtDir = sourceFile.dir();
qtDir.cdUp();
QString qtPath = qtDir.path();
QString qmlPath;
if(m_qmlDir.isLocalFile()) {
qmlPath = m_qmlDir.toLocalFile();
}
qDebug()<<"[Info] "<<"Qt Path"<<qtPath;
qDebug()<<"[Info] "<<qtBinPath;

qDebug()<<"[Info] "<<"qmldir" <<qmlPath;
QStringList arguments;
arguments<<"--qmldir"<<qtPath + "/qml"<<m_exeFile<<"--release";
if(!qmlPath.isEmpty()) {
arguments << "--qmldir" << qmlPath;
}

arguments << m_exeFile << "--" << m_buildType;

QProcess process;
QString path = qtEnvPath(qtBinPath) + ";" + m_sourceEnvPath;
Expand Down Expand Up @@ -127,6 +136,28 @@ QStringList VersionModel::compilerVersionList()
return compilerList;
}

QStringList VersionModel::buildTypeList()
{
static const QStringList list {
"debug",
"profile",
"release"
};

return list;
}

QString VersionModel::buildType()
{
return m_buildType;
}

void VersionModel::setBuildType(const QString &buildType)
{
m_buildType = buildType;
emit statusChanged();
}

QString VersionModel::qtVersion()
{
return m_qtVersion;
Expand Down Expand Up @@ -161,3 +192,15 @@ void VersionModel::setExeFile(const QString &file)
m_exeFile = file;
emit statusChanged();
}

QUrl VersionModel::qmlDir()
{
return m_qmlDir;
}

void VersionModel::setQmlDir(const QUrl &dir)
{
m_qmlDir = dir;
qDebug() << m_qmlDir;
emit statusChanged();
}
14 changes: 13 additions & 1 deletion VersionModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ LICENSE: MIT

#include <QObject>
#include <QProcess>
#include <QUrl>

class VersionModel : public QObject
{
Q_OBJECT
Q_PROPERTY(QStringList qtVersionList READ qtVersionList NOTIFY listChanged)
Q_PROPERTY(QStringList compilerVersionList READ compilerVersionList NOTIFY listChanged)
Q_PROPERTY(QStringList buildTypeList READ buildTypeList NOTIFY listChanged)
Q_PROPERTY(QString qtVersion READ qtVersion WRITE setQtVersion NOTIFY statusChanged)
Q_PROPERTY(QString buildType READ buildType WRITE setBuildType NOTIFY statusChanged)
Q_PROPERTY(QString compilerVersion READ compilerVersion WRITE setCompilerVersion NOTIFY statusChanged)
Q_PROPERTY(QString exeFile READ exeFile WRITE setExeFile NOTIFY statusChanged)

Q_PROPERTY(QUrl qmlDir READ qmlDir WRITE setQmlDir NOTIFY statusChanged)
public:
VersionModel();

Expand All @@ -28,7 +31,10 @@ class VersionModel : public QObject

QStringList qtVersionList();
QStringList compilerVersionList();
QStringList buildTypeList();

QString buildType();
void setBuildType(const QString &buildType);

QString qtVersion();
void setQtVersion(const QString &version);
Expand All @@ -39,6 +45,10 @@ class VersionModel : public QObject
QString exeFile();
void setExeFile(const QString &file);


QUrl qmlDir();
void setQmlDir(const QUrl &dir);

signals:
void listChanged();
void statusChanged();
Expand All @@ -49,7 +59,9 @@ class VersionModel : public QObject
QString m_qtVersion;
QString m_qtVersionDirName;
QString m_compilerVersion;
QString m_buildType;
QString m_exeFile;
QUrl m_qmlDir;
QString m_sourceEnvPath;
QProcess m_testProcess;
};
Expand Down