UI update + clean code

This commit is contained in:
OpexHunter 2025-03-04 17:12:00 +03:00
parent 47294fef88
commit 086702dc14
6 changed files with 25 additions and 42 deletions

View File

@ -23,10 +23,6 @@ Launcher::Launcher(QObject *parent) :
mainWindow(qobject_cast<MainWindow *>(parent)),
app_dir(QDir(QCoreApplication::applicationDirPath()))
{
if (!mainWindow) {
qCritical() << "Failed to cast parent object to MainWindow";
}
OS_type = "linux";
#ifdef Q_OS_WIN
QString vcsBinPath = app_dir.absoluteFilePath(".vcs/bin");
@ -46,11 +42,7 @@ Launcher::~Launcher() {
void Launcher::startProcess(QString &username, QString &uuid, QString &access_token) {
if (run_status) {
qDebug() << "Process is already running";
return;
}
run_status = true;
if (run_status) { return; } run_status = true;
selected_profile = this->mainWindow->ui->selected_profile->currentText();
client_dir = app_dir.absolutePath() + "/" + selected_profile;
@ -65,20 +57,8 @@ void Launcher::startProcess(QString &username, QString &uuid, QString &access_to
garbarge_collector = garbarge_collector.isEmpty() ? "default_collector" : garbarge_collector;
version = "1.12.2";
}
arguments = get_args->getCrossPlatformArgs(RAM, username, uuid, access_token, garbarge_collector);
if (version == "1.12.2") {
sync_dirs
<< "java/zulu8"
<< "versions/1.12.2"
<< "libraries/1.12.2"
<< selected_profile;
sync_files
<< "PunkLauncher"
<< "PunkLauncher.exe";
}
QEventLoop loop;
connect(this, &Launcher::updateFinished, &loop, &QEventLoop::quit);
update();
@ -86,9 +66,8 @@ void Launcher::startProcess(QString &username, QString &uuid, QString &access_to
process->setWorkingDirectory(client_dir);
process->start(java_path, arguments);
this->mainWindow->hide();
if (!process->waitForStarted()) {
qDebug() << "Failed to start process";
qDebug() << process->errorString();
run_status = false;
return;
@ -98,8 +77,6 @@ void Launcher::startProcess(QString &username, QString &uuid, QString &access_to
this->mainWindow->show();
run_status = false;
});
this->mainWindow->hide();
}
@ -121,7 +98,6 @@ void Launcher::update() {
}
}
});
connect(rsyncProcess, &QProcess::readyReadStandardError, [this, rsyncProcess]() {
QString errorOutput = rsyncProcess->readAllStandardError();
this->mainWindow->ui->download_bar->setText(errorOutput);
@ -130,23 +106,30 @@ void Launcher::update() {
QStringList rsyncArgs;
rsyncArgs << "-azH" << "--info=progress2" << "--no-perms" << "--no-owner" << "--no-group";
if (version == "1.12.2") {
sync_dirs
<< "java/zulu8"
<< "versions/1.12.2"
<< "libraries/1.12.2"
<< selected_profile;
sync_files
<< "PunkLauncher"
<< "PunkLauncher.exe";
}
for (const QString &dir : sync_dirs) { rsyncArgs << "--include=" + dir + "/**"; }
for (const QString &file : sync_files) { rsyncArgs << "--include=" + file; }
QStringList excludeFiles = {
QStringList exclude_exist_files = {
"./" + selected_profile + "/options.txt",
"./" + selected_profile + "/optionsof.txt",
"./" + selected_profile + "/optionsshaders.txt"
};
for (const QString &filePath : excludeFiles) {
};
for (const QString &filePath : exclude_exist_files) {
QFileInfo fileInfo(filePath);
if (fileInfo.exists() && fileInfo.isFile()) {
QString relativePath = QDir().relativeFilePath(fileInfo.absoluteFilePath());
rsyncArgs << "--exclude=" + relativePath;
}
}
rsyncArgs << "--exclude=./*";
rsyncArgs << "punkcraft.ru::PunkCraft/" + OS_type + "/uncompressed/" << "./";
@ -163,8 +146,8 @@ void Launcher::update() {
rsyncProcess->deleteLater();
rsyncProcess2->setWorkingDirectory(app_dir.absolutePath());
QStringList modsArgs;
modsArgs
QStringList rsyncArgs2;
rsyncArgs2
<< "-azH" << "--info=progress2" << "--no-perms" << "--no-owner" << "--no-group" << "--delete-after"
<< "--include=" + selected_profile
<< "--include=" + selected_profile + "/mods/"
@ -175,7 +158,7 @@ void Launcher::update() {
<< "--exclude=" + selected_profile + "/*"
<< "punkcraft.ru::PunkCraft/" + OS_type + "/uncompressed/" << "./";
rsyncProcess2->start("rsync", modsArgs);
rsyncProcess2->start("rsync", rsyncArgs2);
connect(rsyncProcess2, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), [this, rsyncProcess2]() {
rsyncProcess2->deleteLater();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 KiB

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1009</width>
<height>658</height>
<height>657</height>
</rect>
</property>
<property name="sizePolicy">
@ -176,7 +176,7 @@ QLineEdit::placeholder {
}</string>
</property>
<property name="currentIndex">
<number>1</number>
<number>2</number>
</property>
<widget class="QWidget" name="load"/>
<widget class="QWidget" name="auth">
@ -480,7 +480,7 @@ QPushButton:pressed {
<widget class="QStackedWidget" name="main_stackedWidget">
<property name="styleSheet">
<string notr="true">QWidget#CyberExtrieme {
border-image: url(:/main/banner.jpg) 0 0 0 0 stretch stretch;
border-image: url(:/main/banner.png) 0 0 0 0 stretch stretch;
}</string>
</property>
<widget class="QWidget" name="CyberExtrieme">
@ -525,8 +525,8 @@ QPushButton:pressed {
</property>
<property name="minimumSize">
<size>
<width>280</width>
<height>32</height>
<width>320</width>
<height>45</height>
</size>
</property>
<property name="maximumSize">
@ -566,7 +566,7 @@ QPushButton:pressed {
и styleSheet виджета, поэтому пользуемся :)
Здесь padding-left как затычка чтобы в глаза не бросалось
*/
padding-left: 60px;
padding-left: 85px;
}

View File

@ -1,11 +1,11 @@
<RCC>
<qresource prefix="/">
<file>main/banner.png</file>
<file>auth/logo.png</file>
<file>app.ico</file>
<file>main/selected_profile.png</file>
<file>main/settings_pressed_32x32.png</file>
<file>main/settings_hover_32x32.png</file>
<file>main/settings_32x32.png</file>
<file>main/banner.jpg</file>
</qresource>
</RCC>