This commit is contained in:
Your Name
2024-03-26 16:29:28 +01:00
parent e70d907fa3
commit 593f713cb9
12 changed files with 278 additions and 251 deletions

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Installer>
<Name>ProjektManager</Name>
<Version>1.10.1</Version>
<Version>1.10.2</Version>
<Title><Name>ProjektManager</Name> Installer</Title>
<InstallerApplicationIcon>installerIcon1</InstallerApplicationIcon>
<InstallerWindowIcon>installerIcon2</InstallerWindowIcon>

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<Package>
<DisplayName>ProjektManager 1.10.1</DisplayName>
<DisplayName>ProjektManager 1.10.2</DisplayName>
<Description>A Program to manage my Qt Projects</Description>
<Version>1.10.1</Version>
<Version>1.10.2</Version>
<Default>true</Default>
<ReleaseDate>2024-03-26</ReleaseDate>
<Licenses>

View File

@@ -1,4 +1,5 @@
#include "createupdaterdialog.h"
#include "mainsettingsdialog.h"
#include "ui_createupdaterdialog.h"
@@ -86,10 +87,11 @@ ThreadData::ThreadData(QString newVersion, bool copyRelease,
}
void ThreadData::appendToStoredTimes(QString path, int time)
void ThreadData::appendToStoredTimes(int time)
{
QString path = MainSettingsDialog::appDataLocal() + "tasktimeslist.qt" ;
this->elapsedtime = time;
QList<ThreadData> keysToStore = getThreadDataListHistory(path);
QList<ThreadData> keysToStore = getThreadDataListHistory();
keysToStore.append(*this);
// Store the list of structs to a file
@@ -104,8 +106,10 @@ void ThreadData::appendToStoredTimes(QString path, int time)
}
}
QList<ThreadData> ThreadData::getThreadDataListHistory(QString path)
QList<ThreadData> ThreadData::getThreadDataListHistory()
{
QString path = MainSettingsDialog::appDataLocal() + "tasktimeslist.qt" ;
// Load the list of structs from the file
QList<ThreadData> loadedKeys;
QFile file(path);
@@ -120,9 +124,11 @@ QList<ThreadData> ThreadData::getThreadDataListHistory(QString path)
return loadedKeys;
}
unsigned ThreadData::getAvgElapsedTimePrediction(QString path)
unsigned ThreadData::getAvgElapsedTimePrediction()
{
QList<ThreadData> keysToStore = getThreadDataListHistory(path);
QString path = MainSettingsDialog::appDataLocal() + "tasktimeslist.qt" ;
QList<ThreadData> keysToStore = getThreadDataListHistory();
int time = 0;
int count = 0;
for(const auto & key : keysToStore) {

View File

@@ -45,9 +45,9 @@ struct ThreadData {
>> key.commit_nad_push_u_repo >> key.gitAddAll >> key.gitHochladen >> key.elapsedtime;
}
void appendToStoredTimes(QString path, int time);
QList<ThreadData> getThreadDataListHistory(QString path);
unsigned getAvgElapsedTimePrediction(QString path);
void appendToStoredTimes(int time);
QList<ThreadData> getThreadDataListHistory();
unsigned getAvgElapsedTimePrediction();
bool sameKey(const ThreadData &other) const;
};

View File

@@ -48,6 +48,23 @@ bool MainSettingsDialog::checkDefPaths() {
return ok;
}
QString MainSettingsDialog::appDataLocal()
{
// Retrieve the configuration location for the current platform
QCoreApplication::setApplicationName(appName);
QString configLocation = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
// Create the directory if it doesn't exist
QDir dir(configLocation);
if (!dir.exists()) {
if (!dir.mkpath(".")) {
qWarning() << "Failed to create directory:" << configLocation;
exit(1);
}
}
return configLocation + QDir::separator();
}
void MainSettingsDialog::loadDefaults()

View File

@@ -33,6 +33,7 @@ public:
bool checkDefPaths();
static QString appDataLocal();
private slots:
void on_buttonBox_accepted();

View File

@@ -3,6 +3,7 @@
#include "projektlistelementform.h"
#include "ui_mainwindow.h"
#include "newprojektdialog.h"
#include "mainsettingsdialog.h"
#include <QList>
@@ -46,19 +47,8 @@ MainWindow::MainWindow(QWidget *parent)
}
});
// Retrieve the configuration location for the current platform
QCoreApplication::setApplicationName(appName);
QString configLocation = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
// Create the directory if it doesn't exist
QDir dir(configLocation);
if (!dir.exists()) {
if (!dir.mkpath(".")) {
qWarning() << "Failed to create directory:" << configLocation;
exit(1);
}
}
settingsPath = (configLocation + "/projectsList.settings");
settingsPath = (MainSettingsDialog::appDataLocal() + "projectsList.settings");
ueberdialog = new DialogUeber(( "C:\\Program Files\\" + appName + "\\ProjektManagerMaintenanceTool.exe" ), "M$RKUS", appName, this->version, Qt::darkGreen, this,
true, false, false, {"WindowsVista", "Fusion", "Fusion_OWN_dark_blue2", "Fusion_OWN_dark_gray"});

View File

@@ -66,7 +66,7 @@ private:
StatisticsDialog * statDialog;
QString version = "1.10.1";
QString version = "1.10.2";
QString appName = "ProjektManager";

View File

@@ -205,7 +205,7 @@ Worker::Worker(ProjektData *data)
int Worker::getStatusTimerIntervall()
{
return this->extraData.getAvgElapsedTimePrediction("./testTimes");
return this->extraData.getAvgElapsedTimePrediction();
}
void Worker::setSMax(unsigned int max)
@@ -314,11 +314,14 @@ void Worker::run()
case UPDATE_PROJECT_DATA:
setSMax(33);
setupIDE();
if(!setupIDE())
return;
setSMax(66);
setupGit();
if(!setupGit())
return;
setSMax(100);
setupInstaller(data->getAppVersion());
if(!setupInstaller(data->getAppVersion()))
return;
break;
@@ -326,21 +329,24 @@ void Worker::run()
setSMax(33);
if(extraData.updateVersionInFile)
this->updateVersionInFile();
if(!this->updateVersionInFile())
return;
setSMax(66);
if(extraData.updater)
setupInstaller(extraData.newVersion);
if(!setupInstaller(extraData.newVersion))
return;
setSMax(100);
createInstaller();
if(!createInstaller())
return;
break;
}
if(!isInterruptionRequested())
this->extraData.appendToStoredTimes("./testTimes", elapsedtimer.elapsed() / 100.0);
this->extraData.appendToStoredTimes( elapsedtimer.elapsed() / 100.0);
return;
}
@@ -374,17 +380,16 @@ void TaskManager::on_TaskManager_accepted()
this->deleteLater();
}
void Worker::setupInstaller(QString programmVersion)
bool Worker::setupInstaller(QString programmVersion)
{
if(!data->isQtInstaller())
return;
return false;
QDir projectDir(data->getProjectDirPath());
if(!projectDir.mkpath(data->getProjectDirPath() + "installer/config")) {
emit newOutput(" !! Failed to create the Path: " + data->getProjectDirPath() + "installer/config => Skip Updater!" );
return;
return false;
}
// if(!projectDir.mkpath("/installer/packages/" + data->getQtInstallerPackageName() + "/data/" )) {
@@ -394,7 +399,7 @@ void Worker::setupInstaller(QString programmVersion)
if(!projectDir.mkpath(data->getProjectDirPath() + "installer/packages/" + data->getQtInstallerPackageName() + "/meta/" )) {
emit newOutput(" !! Failed to create the Path: " + data->getProjectDirPath() + "installer/packages/" + data->getQtInstallerPackageName() + "/meta/ => Skip Updater!" );
return;
return false;
}
emit newOutput(" > Copy Icons..." );
@@ -405,22 +410,22 @@ void Worker::setupInstaller(QString programmVersion)
//wenn nicht, schau ob anderer pfad ok ist und kopiere icons & ändere pfad
if(!useIcon && !data->getQtInstallerUpdaterIconPath().isEmpty() && QFile(data->getQtInstallerUpdaterIconPath()).exists() ) {
// Copy icon & update path:
for(const QString &num : {"1", "2"}) {
for(const char* num : {"1", "2"}) {
QString iconP = data->getProjectDirPath() + "installer/config/installerIcon" + num + ".ico";
if(QFile(iconP).exists()) {
if(!QFile(iconP).remove()) {
emit newOutput(" !! Failed to remove the Icon: " + iconP );
return;
return false;
}
}
QFile icon(data->getQtInstallerUpdaterIconPath());
if(!icon.copy(iconP)) {
emit newOutput(" !! Failed to copy the Icon: " + data->getQtInstallerUpdaterIconPath() + " to " + iconP );
return;
return false;
} else {
emit newOutput(" ...Copied Icon" + num );
emit newOutput(" ...Copied Icon" + QString(num) );
}
}
@@ -441,7 +446,7 @@ void Worker::setupInstaller(QString programmVersion)
QFile configFile(data->getProjectDirPath() + "installer/config/config.xml");
if(! configFile.open(QFile::OpenModeFlag::WriteOnly | QFile::OpenModeFlag::Truncate ) ) {
emit newOutput(" !! Failed to open config File! => Skip Updater!" );
return;
return false;
}
QTextStream out(&configFile);
@@ -486,7 +491,7 @@ void Worker::setupInstaller(QString programmVersion)
QFile packageFile( data->getProjectDirPath() + "installer/packages/" + data->getQtInstallerPackageName() + "/meta/package.xml");
if(! packageFile.open(QFile::OpenModeFlag::WriteOnly | QFile::OpenModeFlag::Truncate ) ) {
emit newOutput(" !! Failed to open packageFile!" );
return;
return false;
}
QTextStream outP(&packageFile);
@@ -536,7 +541,7 @@ void Worker::setupInstaller(QString programmVersion)
QFile resourceFile(":/ressources/license.txt");
if (!resourceFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "Failed to open resource file for reading";
return;
return false;
}
// Read data from the resource file and write it to the local file
while (!resourceFile.atEnd()) {
@@ -551,6 +556,7 @@ void Worker::setupInstaller(QString programmVersion)
} else {
emit newOutput(" ...failed!");
return false;
}
}
@@ -561,7 +567,7 @@ void Worker::setupInstaller(QString programmVersion)
QFile installScriptFile( data->getProjectDirPath() + "installer/packages/" + data->getQtInstallerPackageName() + "/meta/installscript.qs");
if(! installScriptFile.open(QIODevice::WriteOnly | QFile::OpenModeFlag::Truncate ) ) {
emit newOutput(" !! Failed to open installscript!" );
return;
return false;
}
QTextStream outJS(&installScriptFile);
@@ -620,16 +626,17 @@ void Worker::setupInstaller(QString programmVersion)
<< "\n";
installScriptFile.close();
return true;
}
void Worker::createInstaller()
bool Worker::createInstaller()
{
QDir dataDir( data->getProjectDirPath() + "installer/packages/" + data->getQtInstallerPackageName() + "/data/" );
QString gitExe = MainSettingsDialog::getGitExe();
QFile executable(data->getExePath());
if(!executable.exists()) {
emit newOutput(" !! Failed: No Executable in /release/!");
return;
return false;
}
@@ -638,7 +645,7 @@ void Worker::createInstaller()
//cleanup
if(!this->mingwclean()) {
emit newOutput(" !! MingwClean failed!" );
return;
return false;
}
}
@@ -650,18 +657,18 @@ void Worker::createInstaller()
if(dataDir.exists()) {
if(!dataDir.removeRecursively()) {
emit newOutput(" !! Cannot remove old data directory:" + dataDir.absolutePath());
return;
return false;
}
}
if(!QDir(data->getProjectDirPath()).mkpath(data->getProjectDirPath() + "installer/packages/" + data->getQtInstallerPackageName() + "/data/" )) {
emit newOutput(" !! Failed to create the Path: " + data->getProjectDirPath() + "installer/packages/" + data->getQtInstallerPackageName() + "/data/ => Skip Updater!" );
return;
return false;
}
if(!QDir(data->getProjectDirPath() + "release/").exists()) {
emit newOutput(" !! Release Folder with Executable doesn't exist!" );
return;
return false;
}
emit newOutput(" ...cleanup components folder before copy" );
@@ -669,13 +676,13 @@ void Worker::createInstaller()
//windeployqt
if(!this->windeployqt()) {
emit newOutput(" !! WindeployQt failed!" );
return;
return false;
}
//cleanup
if(!this->mingwclean()) {
emit newOutput(" !! MingwClean failed!" );
return;
return false;
}
//copy
@@ -695,13 +702,13 @@ void Worker::createInstaller()
if(oldExe.exists()) {
if(!oldExe.remove()) {
emit newOutput(" !! Failed to remove old Executable!" );
return;
return false;
}
}
if(!executable.copy(oldexepath)) {
emit newOutput(" !! Failed to copy Executable!" );
return;
return false;
}
emit newOutput(" ...copied Application into components folder" );
}
@@ -718,17 +725,17 @@ void Worker::createInstaller()
process->start(gitExe, {"add", "."});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
return;
return false;
}
emit newOutput(" > git commit -m '" + extraData.commitMessage +"'");
process->start(gitExe, {"commit", "-m", extraData.commitMessage});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
return;
return false;
}
if(isInterruptionRequested())
return;
return false;
}
@@ -747,10 +754,10 @@ void Worker::createInstaller()
process->start(gitExe, {"tag", "v" + extraData.newVersion});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
return;
return false;
}
if(isInterruptionRequested())
return;
return false;
} else {
emit newOutput(" ...skip: Tag already exists!");
}
@@ -766,19 +773,19 @@ void Worker::createInstaller()
process->start(gitExe, {"push"});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
return;
return false;
}
if(isInterruptionRequested())
return;
return false;
emit newOutput(" > git push --tags");
process->start(gitExe, {"push", "--tags"});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
return;
return false;
}
if(isInterruptionRequested())
return;
return false;
}
@@ -830,40 +837,41 @@ void Worker::createInstaller()
emit newOutput(" ...created onlineInstaller successfully!");
} else {
emit newOutput(" ...failed to create onlineInstaller: " +silentProcess2->errorString() + silentProcess2->readAllStandardOutput() + silentProcess2->readAllStandardError() );
return false;
}
}
if(isInterruptionRequested())
return;
return false;
bool ok = true;
if(extraData.update_updater_repo) {
if(silentProcess3->waitForFinished(-1)&& silentProcess3->exitCode() == 0) {
emit newOutput(" ...repository has been created successfully!" );
} else {
emit newOutput(" ...failed to create the repository: " + silentProcess3->errorString() +silentProcess3->readAllStandardOutput() + silentProcess3->readAllStandardError() );
ok = false;
return false;
}
}
if(isInterruptionRequested())
return;
return false;
if(extraData.offline_installer) {
if(silentProcess1->waitForFinished(-1) && silentProcess1->exitCode() == 0) {
emit newOutput(" ...created offlineInstaller successfully!" );
} else {
emit newOutput(" ...failed to create offlineInstaller: " + silentProcess1->errorString() + silentProcess1->readAllStandardOutput() + silentProcess1->readAllStandardError() );
return false;
}
}
if(isInterruptionRequested())
return;
return false;
// push repo
if(ok && extraData.commit_nad_push_u_repo) {
if(extraData.commit_nad_push_u_repo) {
emit newOutput(" > Updating git Repo..." );
process->setWorkingDirectory(data->getProjectDirPath() + "installer");
@@ -872,41 +880,40 @@ void Worker::createInstaller()
process->start(gitExe, {"add", "./repository/"});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
return;
return false;
}
if(isInterruptionRequested())
return;
return false;
emit newOutput(" > git commit -m \"update repository to version " + extraData.newVersion +" --quiet\"");
process->start(gitExe, {"commit", "-m", "Update repository to version " + extraData.newVersion});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
return;
return false;
}
if(isInterruptionRequested())
return;
return false;
emit newOutput(" > git push");
process->start(gitExe, {"push"});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
return;
return false;
}
if(isInterruptionRequested())
return;
return false;
}
}
return true;
}
void Worker::setupIDE()
bool Worker::setupIDE()
{
if(data->hasQtAppIcon() && QFile(data->getQtAppIconPath()).exists()) {
emit newOutput(" > Setup App Icon...");
@@ -920,8 +927,6 @@ void Worker::setupIDE()
QString iconFile = QString("icons/appicon") + /*(data->getQtAppIconPath().endsWith(".ico") ?*/ ".ico"/* : ".png")*/;
QString appIconFilePath = data->getProjectDirPath() + iconFile;
bool ok = true;
//wenn icon nicht an richtigen stelle ist
if(data->getQtAppIconPath() != appIconFilePath) {
@@ -929,7 +934,7 @@ void Worker::setupIDE()
emit newOutput(" > Remove existing icon...");
if(!QFile(appIconFilePath).remove()) {
emit newOutput(" ...failed to remove " + appIconFilePath + ".");
ok = false;
return false;
} else {
emit newOutput(" ...removed " + appIconFilePath + ".");
@@ -944,17 +949,17 @@ void Worker::setupIDE()
emit newOutput(" > Move icon...");
if(!file.rename(appIconFilePath)) {
ok = false;
emit newOutput(" !! Failed to rename the File: " + data->getQtAppIconPath() + " to " + appIconFilePath + ": " + file.errorString());
return false;
} else {
emit newOutput( " " + data->getQtAppIconPath() + " moved to " + appIconFilePath );
}
} else if(ok) { //sonst copy erstellen
} else { //sonst copy erstellen
emit newOutput(" > Copy icon...");
if(!file.copy(appIconFilePath)) {
ok = false;
emit newOutput(" !! Failed to copy the File: " + data->getQtAppIconPath() + " to " + appIconFilePath + ": " + file.errorString() );
return false;
} else {
emit newOutput( " " + data->getQtAppIconPath() + " copied to " + appIconFilePath );
}
@@ -965,7 +970,7 @@ void Worker::setupIDE()
// Icon copied/moved =>
if(ok) {
if(true) {
data->setQt_app_icon_path(appIconFilePath);
if(data->getParentList())
@@ -985,6 +990,7 @@ void Worker::setupIDE()
proFile.close();
} else {
emit newOutput(" !! .pro File konnte nicht geöffnet werden!");
return false;
}
if(content.contains("win32:RC_ICONS += "))
@@ -1001,6 +1007,7 @@ void Worker::setupIDE()
emit newOutput(" RC_ICONS erfolgreich dem .pro File hinzugefügt!");
} else {
emit newOutput(" !! .pro File konnte nicht geöffnet werden!");
return false;
}
}
}
@@ -1015,6 +1022,8 @@ void Worker::setupIDE()
QFile proFile(data->getPath());
if(!proFile.exists()) {
emit newOutput(" !! .pro Path is incorrect!");
return false;
} else {
QString content;
if (proFile.open(QIODevice::OpenModeFlag::ReadOnly | QIODevice::Text)) {
@@ -1024,6 +1033,8 @@ void Worker::setupIDE()
proFile.close();
} else {
emit newOutput(" !! .pro File konnte nicht geöffnet werden!");
return false;
}
if(content.contains("-lMUpdater"))
@@ -1053,6 +1064,7 @@ void Worker::setupIDE()
emit newOutput(" MUpdater-Lib erfolgreich dem .pro File hinzugefügt!");
} else {
emit newOutput(" !! .pro File konnte nicht zum Schreiben geöffnet werden!");
return false;
}
}
}
@@ -1061,68 +1073,68 @@ void Worker::setupIDE()
}
if(data->shouldMoveFilesToSrcSubDir()) {
do {
QFile fileX(data->getPath());
if (!fileX.open(QIODevice::ReadOnly | QIODevice::Text)) {
QFile fileX(data->getPath());
if (!fileX.open(QIODevice::ReadOnly | QIODevice::Text)) {
emit newOutput(" !! ...Failed to open .pro File!");
return false;
}
QTextStream inX(&fileX);
QString content = inX.readAll();
fileX.close();
// Get list of files in directory y
QDir dirY(data->getProjectDirPath());
if(!dirY.mkpath("./src/")) {
emit newOutput(" !! Failed to create Folder 'src' !" );
return false;
}
QStringList files = dirY.entryList(QStringList() << "*.cpp" << "*.h" << "*.ui", QDir::Files);
// Process each file
foreach (const QString& file, files) {
if(file.startsWith("ui_"))
continue;
emit newOutput(" > Move " + file + " to " + data->getProjectDirPath() + "src/ ..." );
QString filePath = data->getProjectDirPath() + file;
// Move file to src/ directory
QString newFilePath = data->getProjectDirPath() + "src/" + file;
if (!QFile::rename(filePath, newFilePath)) {
emit newOutput(" !! ...Failed to move " + file + " to " + data->getProjectDirPath() + "src/" );
continue;
}
// Replace filename in content of file x
content.replace(file, "src/" + file);
// Process the content of file x
// Write back to file x
if (!fileX.open(QIODevice::WriteOnly | QIODevice::Text)) {
emit newOutput(" !! ...Failed to open .pro File!");
break;
continue;
}
QTextStream inX(&fileX);
QString content = inX.readAll();
QTextStream outX(&fileX);
outX << content;
fileX.close();
// Get list of files in directory y
QDir dirY(data->getProjectDirPath());
if(!dirY.mkpath("./src/")) {
emit newOutput(" !! Failed to create Folder 'src' !" );
break;
}
QStringList files = dirY.entryList(QStringList() << "*.cpp" << "*.h" << "*.ui", QDir::Files);
// Process each file
foreach (const QString& file, files) {
if(file.startsWith("ui_"))
continue;
emit newOutput(" > Move " + file + " to " + data->getProjectDirPath() + "src/ ..." );
}
QString filePath = data->getProjectDirPath() + file;
// Move file to src/ directory
QString newFilePath = data->getProjectDirPath() + "src/" + file;
if (!QFile::rename(filePath, newFilePath)) {
emit newOutput(" !! ...Failed to move " + file + " to " + data->getProjectDirPath() + "src/" );
continue;
}
// Replace filename in content of file x
content.replace(file, "src/" + file);
// Process the content of file x
// Write back to file x
if (!fileX.open(QIODevice::WriteOnly | QIODevice::Text)) {
emit newOutput(" !! ...Failed to open .pro File!");
continue;
}
QTextStream outX(&fileX);
outX << content;
fileX.close();
}
} while(false);
}
if(data->shouldRemoveShadowBuildSetting()) {
}
return true;
}
void Worker::setupGit()
bool Worker::setupGit()
{
QString gitExe = MainSettingsDialog::getGitExe();
@@ -1130,153 +1142,148 @@ void Worker::setupGit()
if(data->isGitInit()) {
process->setWorkingDirectory(data->getProjectDirPath());
do {
//Git init
//Git init
if(data->shouldInitReadme()) {
emit newOutput(" > Write README.md");
if(data->shouldInitReadme()) {
emit newOutput(" > Write README.md");
QFile file(data->getProjectDirPath() + "README.md");
if(!data->getGit_overwriteReadmeFile() && file.exists()) {
emit newOutput(" ...Skip adding README File -> File already exists!");
QFile file(data->getProjectDirPath() + "README.md");
if(!data->getGit_overwriteReadmeFile() && file.exists()) {
emit newOutput(" ...Skip adding README File -> File already exists!");
} else {
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream out(&file);
out << data->getReadme_init_text();
file.close();
} else {
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream out(&file);
out << data->getReadme_init_text();
file.close();
} else {
emit newOutput(" !! Failed to open README.md File!");
break;
}
emit newOutput(" !! Failed to open README.md File!");
return false;
}
}
}
//Check if git repo exists
silentProcess1->start(gitExe, {"-C", data->getProjectDirPath() , "status"});
if(silentProcess1->waitForFinished(-1) && silentProcess1->exitCode() == 0) {
emit newOutput(" > Skip git init -> A Repo already exists!");
break;
} else {
// qDebug() << "GIT STATUS: " << silentProcess1->readAllStandardOutput();
// qDebug() << "GIT STATUS ERROR: " << silentProcess1->readAllStandardError();
// qDebug() << "GIT STATUS RETURN V: " << silentProcess1->exitCode();
}
//Check if git repo exists
silentProcess1->start(gitExe, {"-C", data->getProjectDirPath() , "status"});
if(silentProcess1->waitForFinished(-1) && silentProcess1->exitCode() == 0) {
emit newOutput(" > Skip git init -> A Repo already exists!");
return false;
} else {
// qDebug() << "GIT STATUS: " << silentProcess1->readAllStandardOutput();
// qDebug() << "GIT STATUS ERROR: " << silentProcess1->readAllStandardError();
// qDebug() << "GIT STATUS RETURN V: " << silentProcess1->exitCode();
}
if(isInterruptionRequested())
return;
if(isInterruptionRequested())
return false;
emit newOutput(" > git init");
process->start(gitExe, {"init"});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
break;
}
if(isInterruptionRequested())
return;
emit newOutput(" > git init");
process->start(gitExe, {"init"});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
return false;
}
if(isInterruptionRequested())
return false;
emit newOutput(" > git checkout -b main");
process->start(gitExe, {"checkout", "-b", "main"});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
break;
}
if(isInterruptionRequested())
return;
emit newOutput(" > git checkout -b main");
process->start(gitExe, {"checkout", "-b", "main"});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
return false;
}
if(isInterruptionRequested())
return false;
emit newOutput(" > git add README.md");
process->start(gitExe, {"add", "README.md"});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
break;
}
if(isInterruptionRequested())
return;
emit newOutput(" > git add README.md");
process->start(gitExe, {"add", "README.md"});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
return false;
}
if(isInterruptionRequested())
return false;
emit newOutput(" > git commit -m add README");
process->start(gitExe, {"commit", "-m", "add README"});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
break;
}
if(isInterruptionRequested())
return;
} while(false);
emit newOutput(" > git commit -m add README");
process->start(gitExe, {"commit", "-m", "add README"});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
return false;
}
if(isInterruptionRequested())
return false;
//Git push
do {
if(data->shouldSetRemoteRepo()) {
if(data->shouldSetRemoteRepo()) {
emit newOutput(" > Set git remote repo...");
emit newOutput(" > Set git remote repo...");
//Check if git repo exists
silentProcess1->start(gitExe, {"-C", data->getProjectDirPath() , "status"});
if(silentProcess1->waitForFinished(-1) && silentProcess1->exitCode() != 0) {
emit newOutput(" !! ...No git repo in " + data->getProjectDirPath());
break;
}
if(isInterruptionRequested())
return;
//Check if git repo exists
silentProcess1->start(gitExe, {"-C", data->getProjectDirPath() , "status"});
if(silentProcess1->waitForFinished(-1) && silentProcess1->exitCode() != 0) {
emit newOutput(" !! ...No git repo in " + data->getProjectDirPath());
return false;
}
if(isInterruptionRequested())
return false;
silentProcess1->start(gitExe, {"-C", data->getProjectDirPath(), "config", "--get", "remote.origin.url"});
silentProcess1->waitForFinished(-1);// && silentProcess1->exitCode();// != 0)
// emit newOutput(" !! git config --get remote.origin.url failed!: " + silentProcess1->readAllStandardError());
// break;
// e.g. no origin upstream
silentProcess1->start(gitExe, {"-C", data->getProjectDirPath(), "config", "--get", "remote.origin.url"});
silentProcess1->waitForFinished(-1);// && silentProcess1->exitCode();// != 0)
// emit newOutput(" !! git config --get remote.origin.url failed!: " + silentProcess1->readAllStandardError());
// break;
// e.g. no origin upstream
QString output = silentProcess1->readAllStandardOutput();
int index = output.indexOf(".git");
if (index != -1)
output = output.left(index + 4); // Including the ".git" itself
QString output = silentProcess1->readAllStandardOutput();
int index = output.indexOf(".git");
if (index != -1)
output = output.left(index + 4); // Including the ".git" itself
if(isInterruptionRequested())
return;
if(isInterruptionRequested())
return false;
qDebug() << output << " =?= " << data->getRemoteRepoUrl();
if(output == data->getRemoteRepoUrl()) {
emit newOutput(" ... skip operation: remote url is alreay set");
break;
}
emit newOutput(" > git remote add origin " + data->getRemoteRepoUrl());
process->start(gitExe, {"remote", "add", "origin", data->getRemoteRepoUrl() });
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
break;
}
if(isInterruptionRequested())
return;
emit newOutput(" > git push -u origin main");
process->start(gitExe, {"push", "-u", "origin", "main"});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
break;
}
if(isInterruptionRequested())
return;
qDebug() << output << " =?= " << data->getRemoteRepoUrl();
if(output == data->getRemoteRepoUrl()) {
emit newOutput(" ... skip operation: remote url is alreay set");
return false;
}
} while (false);
emit newOutput(" > git remote add origin " + data->getRemoteRepoUrl());
process->start(gitExe, {"remote", "add", "origin", data->getRemoteRepoUrl() });
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
return false;
}
if(isInterruptionRequested())
return false;
emit newOutput(" > git push -u origin main");
process->start(gitExe, {"push", "-u", "origin", "main"});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
return false;
}
if(isInterruptionRequested())
return false;
}
@@ -1294,7 +1301,7 @@ void Worker::setupGit()
QFile resourceFile("://ressources/gitignoreTemplate.txt");
if (!resourceFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "Failed to open resource file for reading";
return;
return false;
}
// Read data from the resource file and write it to the local file
@@ -1310,6 +1317,7 @@ void Worker::setupGit()
} else {
emit newOutput(" ...failed!");
return false;
}
emit newOutput(" > Add .gitignore to git...");
@@ -1322,18 +1330,22 @@ void Worker::setupGit()
process->start(gitExe, {"add", ".gitignore"});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
return false;
} else {
emit newOutput(" > git commit -m 'add gitignore'");
process->start(gitExe, {"commit", "-m", "add gitignore"});
if(process->waitForFinished(-1) && process->exitCode() != 0 ) {
emit newOutput(" ...failed!");
return false;
}
}
} else {
emit newOutput(" > ...failed: No Repo in " + data->getProjectDirPath() );
return false;
}
if(isInterruptionRequested())
return;
return false;
}
@@ -1341,6 +1353,7 @@ void Worker::setupGit()
}
return true;
}
int Worker::getProcessStatus()
@@ -1353,7 +1366,7 @@ int Worker::getProcessStatus()
bool Worker::windeployqt()
{
QString projectDir = data->getProjectDirPath();
for(const QString &mode : {"release/", "debug/"}) {
for(const char * mode: {"release/", "debug/"}) {
if(QDir(projectDir + mode ).exists() /*&& !QFile(projectDir + mode + "libstdc++-6.dll").exists()*/ && QFile(projectDir + mode + data->getAppName() + ".exe").exists()) {
QString path = MainSettingsDialog::getQtKitDirPath() + "windeployqt.exe";
silentProcess2->start(path, QStringList() << projectDir + mode + data->getAppName() + ".exe");

View File

@@ -29,10 +29,10 @@ public:
bool stop();
void setupInstaller(QString programmVersion);
void createInstaller();
void setupIDE();
void setupGit();
bool setupInstaller(QString programmVersion);
bool createInstaller();
bool setupIDE();
bool setupGit();
int getProcessStatus();

BIN
testTimes

Binary file not shown.