rework launcher images from sync

This commit is contained in:
Micah
2020-10-10 12:43:43 -04:00
parent 922718d827
commit 19b09abd4e
5 changed files with 25 additions and 6 deletions

View File

@@ -65,12 +65,31 @@ LauncherWindow::LauncherWindow(std::string basePath, bool profileEnabled,
ui->comboBoxWindowConfigs->setDisabled(!_sgctConfigChangeAllowed);
_fullyConfiguredViaCliArgs = (!profileEnabled && !sgctConfigEnabled);
std::random_device rd;
std::mt19937 rng(rd());
std::uniform_int_distribution<int> uni(0, 4);
auto random_integer = uni(rng);
QString filename = QString::fromStdString("/data/images/profile" + std::to_string(random_integer) + ".png");
QString bgpath = QDir::fromNativeSeparators(_basePath)+ filename;
bool hasSyncFiles = false;
QString syncFilePath = QString(globalConfig.pathTokens["SYNC"].c_str()) + "/http/launcher_images/1/profile1.png";
QFileInfo check_file(syncFilePath);
// check if file exists and if yes: Is it really a file and no directory?
if (check_file.exists() && check_file.isFile()) {
hasSyncFiles = true;
}
QString filename;
QString bgpath;
if (hasSyncFiles) {
std::random_device rd;
std::mt19937 rng(rd());
std::uniform_int_distribution<int> uni(0, 4);
auto random_integer = uni(rng);
filename = QString::fromStdString("/http/launcher_images/1/profile" + std::to_string(random_integer) + ".png");
bgpath = QString(globalConfig.pathTokens["SYNC"].c_str()) + filename;
}
else {
filename = QString::fromStdString("/data/images/profile0.png");
bgpath = QDir::fromNativeSeparators(_basePath) + filename;
}
QPixmap bgpix(bgpath);
ui->backgroundImage->setPixmap(bgpix);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 237 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 KiB