cross-compile patch

This commit is contained in:
OpexHunter 2025-03-04 03:04:28 +03:00
parent 3852dad8c9
commit 67966443bd
9 changed files with 312 additions and 436 deletions

View File

@ -19,6 +19,6 @@ if(WIN32)
../resources/app.rc
)
set_target_properties(PunkLauncher PROPERTIES
WIN32_EXECUTABLE ON
WIN32_EXECUTABLE OFF
)
endif()

View File

@ -83,7 +83,8 @@ void Backend::sendPostRequest(const QString &url, const QJsonObject &payload, st
void Backend::authWithPassword(
QString &username, QString &password, bool &session_save_flag,
QString &username,
QString &password,
std::function<void(QString, QString, QString)> callback)
{
QString url = "https://root-kit.ru:3002/punkcraft/session/auth";
@ -91,7 +92,7 @@ void Backend::authWithPassword(
payload["username"] = username;
payload["password"] = password;
sendPostRequest(url, payload, [this, callback, session_save_flag](QJsonObject response) {
sendPostRequest(url, payload, [this, callback](QJsonObject response) {
if (response.isEmpty()) {
qWarning() << "Ошибка авторизации: пустой ответ.";
if (callback) {
@ -104,10 +105,7 @@ void Backend::authWithPassword(
QString username = response["username"].toString();
QString uuid = response["uuid"].toString();
QString access_token = response["access_token"].toString();
if (session_save_flag) {
saveToJson(uuid, access_token);
}
saveToJson(uuid, access_token);
if (callback) {

View File

@ -9,9 +9,13 @@
class Backend {
public:
Backend();
void authWithPassword(
QString &username, QString &password, bool &session_save_flag,
std::function<void(QString, QString, QString)> callback);
QString &username,
QString &password,
std::function<void(QString, QString, QString)> callback
);
void authWithToken(std::function<void(QString, QString, QString)> callback);
QString getStateFilePath();

View File

@ -16,16 +16,26 @@
Launcher::Launcher(QObject *parent) :
QObject(parent),
QObject(parent),
process(new QProcess(this)),
get_args(new forge1_12_2()),
run_status(false),
mainWindow(qobject_cast<MainWindow *>(parent)),
app_dir(QDir(QCoreApplication::applicationDirPath()))
{
if (!mainWindow) {
if (!mainWindow) {
qCritical() << "Failed to cast parent object to MainWindow";
}
OS_type = "unix";
#ifdef Q_OS_WIN
QString vcsBinPath = app_dir.absoluteFilePath(".vcs/bin");
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString currentPath = env.value("PATH");
QString newPath = QString("%1;%2").arg(vcsBinPath, currentPath);
_putenv_s("PATH", newPath.toUtf8().constData());
OS_type = "win";
#endif
}
@ -50,21 +60,22 @@ void Launcher::startProcess(QString &username, QString &uuid, QString &access_to
garbarge_collector = json_settings["garbarge_collector"].toString();
if (selected_profile == "ZombieExtrieme") {
arguments = get_args->getCrossPlatformArgs(RAM, username, uuid, access_token, garbarge_collector);
java_path = java_path.isEmpty() ? app_dir.absolutePath() + "/java/zulu8.84.0.15-ca-jre8.0.442-linux_x64/bin/java" : java_path;
RAM = RAM.isEmpty() ? "4096M" : RAM;
arguments = get_args->getCrossPlatformArgs(RAM, username, uuid, access_token, garbarge_collector);
java_path = java_path.isEmpty() ? app_dir.absolutePath() + QDir::toNativeSeparators("/java/zulu8.84.0.15-ca-jre8.0.442-linux_x64/bin/java") : java_path;
garbarge_collector = garbarge_collector.isEmpty() ? "default_collector" : garbarge_collector;
version = "1.12.2";
}
if (version == "1.12.2") {
sync_dirs
<< "./java/zulu8.84.0.15-ca-jre8.0.442-linux_x64"
<< "./versions/1.12.2"
<< "./libraries/1.12.2"
<< "./" + selected_profile;
<< "java/zulu8.84.0.15-ca-jre8.0.442-linux_x64"
<< "versions/1.12.2"
<< "libraries/1.12.2"
<< selected_profile;
sync_files
<< "./PunkLauncher";
<< "PunkLauncher"
<< "PunkLauncher.exe";
}
QEventLoop loop;
@ -82,15 +93,12 @@ void Launcher::startProcess(QString &username, QString &uuid, QString &access_to
return;
}
connect(process,
QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
[this](int, QProcess::ExitStatus) {
this->mainWindow->show();
run_status = false;
});
connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), [this](int, QProcess::ExitStatus) {
this->mainWindow->show();
run_status = false;
});
this->mainWindow->hide();
qDebug() << "Process started successfully";
}
@ -98,7 +106,7 @@ void Launcher::update() {
QProcess *rsyncProcess = new QProcess(this);
rsyncProcess->setWorkingDirectory(app_dir.absolutePath());
connect(rsyncProcess, &QProcess::readyReadStandardOutput, [rsyncProcess, this]() {
connect(rsyncProcess, &QProcess::readyReadStandardOutput, [this, rsyncProcess]() {
QString output = rsyncProcess->readAllStandardOutput();
QStringList lines = output.split('\n');
if (!lines.isEmpty()) {
@ -113,33 +121,33 @@ void Launcher::update() {
}
});
connect(rsyncProcess, &QProcess::readyReadStandardError, [rsyncProcess, this]() {
connect(rsyncProcess, &QProcess::readyReadStandardError, [this, rsyncProcess]() {
QString errorOutput = rsyncProcess->readAllStandardError();
this->mainWindow->ui->download_bar->setText(errorOutput);
qDebug() << errorOutput;
});
QStringList rsyncArgs;
rsyncArgs << "-azH" << "--info=progress2";
for (const QString &dir : sync_dirs) { rsyncArgs << "--include" << dir + "/**"; }
for (const QString &file : sync_files) { rsyncArgs << "--include" << file; }
rsyncArgs << "-azH" << "--info=progress2" << "--no-perms" << "--no-owner" << "--no-group";
for (const QString &dir : sync_dirs) { rsyncArgs << "--include=" + dir + "/**"; }
for (const QString &file : sync_files) { rsyncArgs << "--include=" + file; }
QStringList excludeFiles = {
QDir::toNativeSeparators("./" + selected_profile + "/options.txt"),
QDir::toNativeSeparators("./" + selected_profile + "/optionsof.txt"),
QDir::toNativeSeparators("./" + selected_profile + "/optionsshaders.txt")
"./" + selected_profile + "/options.txt",
"./" + selected_profile + "/optionsof.txt",
"./" + selected_profile + "/optionsshaders.txt"
};
for (const QString &filePath : excludeFiles) {
QFileInfo fileInfo(filePath);
if (fileInfo.exists() && fileInfo.isFile()) {
QString relativePath = QDir().relativeFilePath(fileInfo.absoluteFilePath());
rsyncArgs << "--exclude" << relativePath;
rsyncArgs << "--exclude=" + relativePath;
}
}
rsyncArgs << "--exclude" << "./**";
rsyncArgs << "punkcraft.ru::PunkCraft/unix/uncompressed/" << "./";
rsyncArgs << "--exclude=./*";
rsyncArgs << "punkcraft.ru::PunkCraft/" + OS_type + "/uncompressed/" << "./";
rsyncProcess->start("rsync", rsyncArgs);
if (!rsyncProcess->waitForStarted()) {
@ -150,13 +158,13 @@ void Launcher::update() {
}
connect(rsyncProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), [this, rsyncProcess]() {
QProcess *rsyncProcess2 = new QProcess(this);
rsyncProcess->deleteLater();
QProcess *rsyncProcess2 = new QProcess(this);
rsyncProcess2->setWorkingDirectory(app_dir.absolutePath());
QStringList modsArgs;
modsArgs
<< "-azH" << "--info=progress2" << "--delete-after"
<< "-azH" << "--info=progress2" << "--no-perms" << "--no-owner" << "--no-group" << "--delete-after"
<< "--include=" + selected_profile
<< "--include=" + selected_profile + "/mods/"
<< "--include=" + selected_profile + "/mods/**"
@ -164,7 +172,7 @@ void Launcher::update() {
<< "--include=" + selected_profile + "/resourcepacks/**"
<< "--exclude=*"
<< "--exclude=" + selected_profile + "/*"
<< "punkcraft.ru::PunkCraft/unix/uncompressed/" << "./";
<< "punkcraft.ru::PunkCraft/" + OS_type + "/uncompressed/" << "./";
rsyncProcess2->start("rsync", modsArgs);

View File

@ -31,6 +31,8 @@ private:
MainWindow *mainWindow;
QDir app_dir;
QString client_dir;
QString OS_type;
QStringList sync_dirs;
QStringList sync_files;

View File

@ -7,78 +7,92 @@
#include <QCoreApplication>
#include <QString>
#include <QList>
#include <QOperatingSystemVersion>
#include <QStringList>
forge1_12_2::forge1_12_2() {
#ifdef Q_OS_WIN
classpath_separator = ';';
#else
classpath_separator = ':';
#endif
}
forge1_12_2::~forge1_12_2() {
}
QStringList forge1_12_2::getCrossPlatformArgs(QString &RAM, QString &username, QString &uuid, QString &access_token, QString &garbarge_collector) {
QStringList jarPaths = {
"../libraries/1.12.2/net/minecraftforge/forge/1.12.2-14.23.5.2860/forge-1.12.2-14.23.5.2860.jar",
"../libraries/1.12.2/org/ow2/asm/asm-debug-all/5.2/asm-debug-all-5.2.jar",
"../libraries/1.12.2/net/minecraft/launchwrapper/1.12/launchwrapper-1.12.jar",
"../libraries/1.12.2/org/jline/jline/3.5.1/jline-3.5.1.jar",
"../libraries/1.12.2/com/typesafe/akka/akka-actor_2.11/2.3.3/akka-actor_2.11-2.3.3.jar",
"../libraries/1.12.2/com/typesafe/config/1.2.1/config-1.2.1.jar",
"../libraries/1.12.2/org/scala-lang/scala-actors-migration_2.11/1.1.0/scala-actors-migration_2.11-1.1.0.jar",
"../libraries/1.12.2/org/scala-lang/scala-compiler/2.11.1/scala-compiler-2.11.1.jar",
"../libraries/1.12.2/org/scala-lang/plugins/scala-continuations-library_2.11/1.0.2_mc/scala-continuations-library_2.11-1.0.2_mc.jar",
"../libraries/1.12.2/org/scala-lang/plugins/scala-continuations-plugin_2.11.1/1.0.2_mc/scala-continuations-plugin_2.11.1-1.0.2_mc.jar",
"../libraries/1.12.2/org/scala-lang/scala-library/2.11.1/scala-library-2.11.1.jar",
"../libraries/1.12.2/org/scala-lang/scala-parser-combinators_2.11/1.0.1/scala-parser-combinators_2.11-1.0.1.jar",
"../libraries/1.12.2/org/scala-lang/scala-reflect/2.11.1/scala-reflect-2.11.1.jar",
"../libraries/1.12.2/org/scala-lang/scala-swing_2.11/1.0.1/scala-swing_2.11-1.0.1.jar",
"../libraries/1.12.2/org/scala-lang/scala-xml_2.11/1.0.2/scala-xml_2.11-1.0.2.jar",
"../libraries/1.12.2/lzma/lzma/0.0.1/lzma-0.0.1.jar",
"../libraries/1.12.2/java3d/vecmath/1.5.2/vecmath-1.5.2.jar",
"../libraries/1.12.2/net/sf/trove4j/trove4j/3.0.3/trove4j-3.0.3.jar",
"../libraries/1.12.2/org/apache/maven/maven-artifact/3.5.3/maven-artifact-3.5.3.jar",
"../libraries/1.12.2/net/sf/jopt-simple/jopt-simple/5.0.3/jopt-simple-5.0.3.jar",
"../libraries/1.12.2/org/apache/logging/log4j/log4j-api/2.15.0/log4j-api-2.15.0.jar",
"../libraries/1.12.2/org/apache/logging/log4j/log4j-core/2.15.0/log4j-core-2.15.0.jar",
"../libraries/1.12.2/com/mojang/patchy/1.3.9/patchy-1.3.9.jar",
"../libraries/1.12.2/oshi-project/oshi-core/1.1/oshi-core-1.1.jar",
"../libraries/1.12.2/net/java/dev/jna/jna/4.4.0/jna-4.4.0.jar",
"../libraries/1.12.2/net/java/dev/jna/platform/3.4.0/platform-3.4.0.jar",
"../libraries/1.12.2/com/ibm/icu/icu4j-core-mojang/51.2/icu4j-core-mojang-51.2.jar",
"../libraries/1.12.2/com/paulscode/codecjorbis/20101023/codecjorbis-20101023.jar",
"../libraries/1.12.2/com/paulscode/codecwav/20101023/codecwav-20101023.jar",
"../libraries/1.12.2/com/paulscode/libraryjavasound/20101123/libraryjavasound-20101123.jar",
"../libraries/1.12.2/com/paulscode/librarylwjglopenal/20100824/librarylwjglopenal-20100824.jar",
"../libraries/1.12.2/com/paulscode/soundsystem/20120107/soundsystem-20120107.jar",
"../libraries/1.12.2/io/netty/netty-all/4.1.9.Final/netty-all-4.1.9.Final.jar",
"../libraries/1.12.2/com/google/guava/guava/21.0/guava-21.0.jar",
"../libraries/1.12.2/org/apache/commons/commons-lang3/3.5/commons-lang3-3.5.jar",
"../libraries/1.12.2/commons-io/commons-io/2.5/commons-io-2.5.jar",
"../libraries/1.12.2/commons-codec/commons-codec/1.10/commons-codec-1.10.jar",
"../libraries/1.12.2/net/java/jinput/jinput/2.0.5/jinput-2.0.5.jar",
"../libraries/1.12.2/net/java/jutils/jutils/1.0.0/jutils-1.0.0.jar",
"../libraries/1.12.2/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar",
"../libraries/1.12.2/com/mojang/authlib/1.5.25/authlib-1.5.25.jar",
"../libraries/1.12.2/com/mojang/realms/1.10.22/realms-1.10.22.jar",
"../libraries/1.12.2/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.jar",
"../libraries/1.12.2/org/apache/httpcomponents/httpclient/4.3.3/httpclient-4.3.3.jar",
"../libraries/1.12.2/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar",
"../libraries/1.12.2/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar",
"../libraries/1.12.2/it/unimi/dsi/fastutil/7.1.0/fastutil-7.1.0.jar",
"../libraries/1.12.2/org/lwjgl/lwjgl/lwjgl/2.9.4-nightly-20150209/lwjgl-2.9.4-nightly-20150209.jar",
"../libraries/1.12.2/org/lwjgl/lwjgl/lwjgl_util/2.9.4-nightly-20150209/lwjgl_util-2.9.4-nightly-20150209.jar",
"../libraries/1.12.2/com/mojang/text2speech/1.10.3/text2speech-1.10.3.jar",
"../versions/1.12.2-forge-14.23.5.2860/1.12.2-forge-14.23.5.2860.jar"
};
QStringList nativePaths;
for (const QString &path : jarPaths) { nativePaths << QDir::toNativeSeparators(path); }
QString classPath = nativePaths.join(classpath_separator);
QStringList arguments;
arguments
<< "-Djava.library.path=../versions/1.12.2-forge-14.23.5.2860/natives"
<< "-Djava.library.path=" + QDir::toNativeSeparators("../versions/1.12.2-forge-14.23.5.2860/natives")
<< "-Xmx" + RAM
<< "-cp"
<< "../libraries/1.12.2/net/minecraftforge/forge/1.12.2-14.23.5.2860/forge-1.12.2-14.23.5.2860.jar:"
"../libraries/1.12.2/org/ow2/asm/asm-debug-all/5.2/asm-debug-all-5.2.jar:"
"../libraries/1.12.2/net/minecraft/launchwrapper/1.12/launchwrapper-1.12.jar:"
"../libraries/1.12.2/org/jline/jline/3.5.1/jline-3.5.1.jar:"
"../libraries/1.12.2/com/typesafe/akka/akka-actor_2.11/2.3.3/akka-actor_2.11-2.3.3.jar:"
"../libraries/1.12.2/com/typesafe/config/1.2.1/config-1.2.1.jar:"
"../libraries/1.12.2/org/scala-lang/scala-actors-migration_2.11/1.1.0/scala-actors-migration_2.11-1.1.0.jar:"
"../libraries/1.12.2/org/scala-lang/scala-compiler/2.11.1/scala-compiler-2.11.1.jar:"
"../libraries/1.12.2/org/scala-lang/plugins/scala-continuations-library_2.11/1.0.2_mc/scala-continuations-library_2.11-1.0.2_mc.jar:"
"../libraries/1.12.2/org/scala-lang/plugins/scala-continuations-plugin_2.11.1/1.0.2_mc/scala-continuations-plugin_2.11.1-1.0.2_mc.jar:"
"../libraries/1.12.2/org/scala-lang/scala-library/2.11.1/scala-library-2.11.1.jar:"
"../libraries/1.12.2/org/scala-lang/scala-parser-combinators_2.11/1.0.1/scala-parser-combinators_2.11-1.0.1.jar:"
"../libraries/1.12.2/org/scala-lang/scala-reflect/2.11.1/scala-reflect-2.11.1.jar:"
"../libraries/1.12.2/org/scala-lang/scala-swing_2.11/1.0.1/scala-swing_2.11-1.0.1.jar:"
"../libraries/1.12.2/org/scala-lang/scala-xml_2.11/1.0.2/scala-xml_2.11-1.0.2.jar:"
"../libraries/1.12.2/lzma/lzma/0.0.1/lzma-0.0.1.jar:"
"../libraries/1.12.2/java3d/vecmath/1.5.2/vecmath-1.5.2.jar:"
"../libraries/1.12.2/net/sf/trove4j/trove4j/3.0.3/trove4j-3.0.3.jar:"
"../libraries/1.12.2/org/apache/maven/maven-artifact/3.5.3/maven-artifact-3.5.3.jar:"
"../libraries/1.12.2/net/sf/jopt-simple/jopt-simple/5.0.3/jopt-simple-5.0.3.jar:"
"../libraries/1.12.2/org/apache/logging/log4j/log4j-api/2.15.0/log4j-api-2.15.0.jar:"
"../libraries/1.12.2/org/apache/logging/log4j/log4j-core/2.15.0/log4j-core-2.15.0.jar:"
"../libraries/1.12.2/com/mojang/patchy/1.3.9/patchy-1.3.9.jar:"
"../libraries/1.12.2/oshi-project/oshi-core/1.1/oshi-core-1.1.jar:"
"../libraries/1.12.2/net/java/dev/jna/jna/4.4.0/jna-4.4.0.jar:"
"../libraries/1.12.2/net/java/dev/jna/platform/3.4.0/platform-3.4.0.jar:"
"../libraries/1.12.2/com/ibm/icu/icu4j-core-mojang/51.2/icu4j-core-mojang-51.2.jar:"
"../libraries/1.12.2/com/paulscode/codecjorbis/20101023/codecjorbis-20101023.jar:"
"../libraries/1.12.2/com/paulscode/codecwav/20101023/codecwav-20101023.jar:"
"../libraries/1.12.2/com/paulscode/libraryjavasound/20101123/libraryjavasound-20101123.jar:"
"../libraries/1.12.2/com/paulscode/librarylwjglopenal/20100824/librarylwjglopenal-20100824.jar:"
"../libraries/1.12.2/com/paulscode/soundsystem/20120107/soundsystem-20120107.jar:"
"../libraries/1.12.2/io/netty/netty-all/4.1.9.Final/netty-all-4.1.9.Final.jar:"
"../libraries/1.12.2/com/google/guava/guava/21.0/guava-21.0.jar:"
"../libraries/1.12.2/org/apache/commons/commons-lang3/3.5/commons-lang3-3.5.jar:"
"../libraries/1.12.2/commons-io/commons-io/2.5/commons-io-2.5.jar:"
"../libraries/1.12.2/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:"
"../libraries/1.12.2/net/java/jinput/jinput/2.0.5/jinput-2.0.5.jar:"
"../libraries/1.12.2/net/java/jutils/jutils/1.0.0/jutils-1.0.0.jar:"
"../libraries/1.12.2/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar:"
"../libraries/1.12.2/com/mojang/authlib/1.5.25/authlib-1.5.25.jar:"
"../libraries/1.12.2/com/mojang/realms/1.10.22/realms-1.10.22.jar:"
"../libraries/1.12.2/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.jar:"
"../libraries/1.12.2/org/apache/httpcomponents/httpclient/4.3.3/httpclient-4.3.3.jar:"
"../libraries/1.12.2/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar:"
"../libraries/1.12.2/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar:"
"../libraries/1.12.2/it/unimi/dsi/fastutil/7.1.0/fastutil-7.1.0.jar:"
"../libraries/1.12.2/org/lwjgl/lwjgl/lwjgl/2.9.4-nightly-20150209/lwjgl-2.9.4-nightly-20150209.jar:"
"../libraries/1.12.2/org/lwjgl/lwjgl/lwjgl_util/2.9.4-nightly-20150209/lwjgl_util-2.9.4-nightly-20150209.jar:"
"../libraries/1.12.2/com/mojang/text2speech/1.10.3/text2speech-1.10.3.jar:"
"../versions/1.12.2-forge-14.23.5.2860/1.12.2-forge-14.23.5.2860.jar"
<< classPath
<< "-Dfml.ignoreInvalidMinecraftCertificates=true"
<< "-Dfml.ignorePatchDiscrepancies=true"
<< "-Djava.net.preferIPv4Stack=true"
<< "-Dminecraft.applet.TargetDirectory=./"
<< "-DlibraryDirectory=../libraries/1.12.2"
<< "-Dlog4j.configurationFile=./assets/1.12.2/log_configs/client-1.12.xml"
<< "-Dminecraft.applet.TargetDirectory=" + QDir::toNativeSeparators("./")
<< "-DlibraryDirectory=" + QDir::toNativeSeparators("../libraries/1.12.2")
<< "-Dlog4j.configurationFile=" + QDir::toNativeSeparators("./assets/1.12.2/log_configs/client-1.12.xml")
// Garbarge Collector общие настройки
<< "-XX:+UnlockExperimentalVMOptions"
//<< "-XX:+UnlockDiagnosticVMOptions"
@ -122,8 +136,8 @@ QStringList forge1_12_2::getCrossPlatformArgs(QString &RAM, QString &username, Q
<< "net.minecraft.launchwrapper.Launch"
<< "--username" << username
<< "--version" << "1.12.2-forge-14.23.5.2860"
<< "--gameDir" << "./"
<< "--assetsDir" << "../assets/1.12.2"
<< "--gameDir" << QDir::toNativeSeparators("./")
<< "--assetsDir" << QDir::toNativeSeparators("../assets/1.12.2")
<< "--assetIndex" << "1.12"
<< "--uuid" << uuid
<< "--accessToken" << access_token

View File

@ -16,6 +16,8 @@ public:
~forge1_12_2();
QStringList getCrossPlatformArgs(QString &RAM, QString &username, QString &uuid, QString &access_token, QString &garbarge_collector);
private:
QChar classpath_separator;
};

View File

@ -31,8 +31,8 @@ MainWindow::MainWindow(QWidget *parent) :
// Инициализация
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
ui->StackedWidget->setCurrentWidget(ui->load); // Окно по умолчанию
on_selected_profile_currentTextChanged(ui->selected_profile->currentText()); // Обновление ui->selected_profile
ui->StackedWidget->setCurrentWidget(ui->load);
on_selected_profile_currentTextChanged(ui->selected_profile->currentText());
backend->authWithToken([this](QString username, QString uuid, QString access_token) {
@ -83,12 +83,9 @@ void MainWindow::on_auth_login_btn_clicked() {
QString username = ui->auth_login_line->text();
QString password = ui->auth_pass_line->text();
bool flag = ui->auth_save_session_check_btn->isChecked();
backend->authWithPassword(
username,
password,
flag,
[this](QString username, QString uuid, QString access_token)
{
if (!username.isEmpty() && !uuid.isEmpty() && !access_token.isEmpty()) {
@ -117,7 +114,6 @@ void MainWindow::on_selected_profile_currentTextChanged(QString text) {
int comboBoxWidth = ui->selected_profile->width();
int paddingLeft = (comboBoxWidth - textWidth) / 2;
// Обновление stylesheet заменой
QString currentStyleSheet = ui->selected_profile->styleSheet();
QString newStyleSheet = currentStyleSheet;
if (currentStyleSheet.contains("padding-left:")) {
@ -132,7 +128,6 @@ void MainWindow::on_selected_profile_currentTextChanged(QString text) {
void MainWindow::on_settings_btn_clicked() {
ui->StackedWidget->setCurrentWidget(ui->settings);
// Обновление значений
QString selected_profile = ui->selected_profile->currentText();
json_settings = settings->loadFromJson(selected_profile);
@ -152,6 +147,8 @@ void MainWindow::on_logout_btn_clicked() {
ui->StackedWidget->setCurrentWidget(ui->auth);
QString session_cache = backend->getStateFilePath();
QFile::remove(session_cache);
ui->auth_login_line->setText("");
ui->auth_pass_line->setText("");
}

View File

@ -253,341 +253,172 @@ QLineEdit::placeholder {
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="toolTipDuration">
<number>6</number>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgba(255, 255, 255, 0);</string>
</property>
<property name="text">
<string>Авторизация</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="verticalFrame">
<property name="styleSheet">
<string notr="true">QFrame {
border: 0px solid rgba(255, 255, 255, 0.5);
background-color: rgba(255, 255, 255, 0);
border-radius: 10px;
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QLineEdit {
border: 2px solid rgb(66, 68, 70);
border-radius: 4px;
background-color: rgb(36, 38, 41);
padding-left: 15px;
color: rgb(200, 200, 200);
}
QFrame &gt; QFrame {
border: none; /* Убираем бордер у дочерних фреймов */
border-radius: 0; /* Убираем закругление у дочерних фреймов */
QPushButton {
border: 1px solid rgb(66, 68, 70);
border-radius: 4px;
background-color: rgb(48, 50, 53);
color: rgb(200, 200, 200);
padding: 5px 10px;
}
QLineEdit {
padding-left: 10px; /* Отступ слева для вводимого текста */
border: 1px solid #ccc; /* Граница */
border-radius: 5px; /* Закругленные углы */
QPushButton:hover {
background-color: rgb(46, 48, 51);
}
QLineEdit::placeholder {
color: gray; /* Цвет placeholder */
padding-left: 10px; /* Отступ слева для placeholder */
QPushButton:pressed {
background-color: rgb(41, 43, 46);
}</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0">
<property name="leftMargin">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,1,4">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="auth_login_line">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="topMargin">
<number>0</number>
<property name="minimumSize">
<size>
<width>0</width>
<height>43</height>
</size>
</property>
<property name="rightMargin">
<number>0</number>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="bottomMargin">
<number>20</number>
<property name="font">
<font>
<family>Noto Sans Cherokee</family>
<pointsize>12</pointsize>
</font>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>280</width>
<height>125</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>280</width>
<height>125</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,1,4">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="auth_login_line">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>35</height>
</size>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="placeholderText">
<string>Логин</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="auth_pass_line">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>35</height>
</size>
</property>
<property name="font">
<font>
<family>Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
<property name="placeholderText">
<string>Пароль</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="auth_login_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>Войти</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="auth_save_session_check_btn">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Не выходить с аккаунта</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="auth_reg_label">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://root-kit.ru&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#e9e7ff;&quot;&gt;Регистрация&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="placeholderText">
<string>Логин</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="auth_pass_line">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>43</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<family>Noto Sans Cherokee</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
<property name="placeholderText">
<string>Пароль</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="auth_login_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<family>Source Sans Pro</family>
<pointsize>16</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">margin-top: 1px;</string>
</property>
<property name="text">
<string>Войти в аккаунт</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
@ -604,6 +435,22 @@ QLineEdit::placeholder {
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>140</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="main">
@ -678,14 +525,14 @@ QLineEdit::placeholder {
</property>
<property name="minimumSize">
<size>
<width>351</width>
<height>45</height>
<width>280</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>351</width>
<height>45</height>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
@ -719,7 +566,7 @@ QLineEdit::placeholder {
и styleSheet виджета, поэтому пользуемся :)
Здесь padding-left как затычка чтобы в глаза не бросалось
*/
padding-left: 100px;
padding-left: 60px;
}
@ -1111,15 +958,19 @@ QPushButton:pressed {
</property>
<property name="styleSheet">
<string notr="true">QPushButton {
color: rgba(255,255,255,0.96);
border: 1px solid rgb(66, 68, 70);
border-radius: 2px;
background-color: rgb(48, 50, 53);
color: rgb(220, 220, 220);
padding: 5px 10px;
}
QPushButton:hover {
color: rgba(255,255,255,0.8);
background-color: rgb(46, 48, 51);
}
QPushButton:pressed {
color: rgba(255,255,255,0.96);
background-color: rgb(41, 43, 46);
}</string>
</property>
<property name="text">